diff --git a/ci-scripts/main.py b/ci-scripts/main.py index eb1f0bfd220201c802e9c10d9845808deefc51dc..8d5ca76b78019b9d3ccd2a4df15515196035df30 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -436,7 +436,7 @@ class SSHConnection(): self.copyout(self.eNBIPAddress, self.eNBUserName, self.eNBPassword, pcap_log_file, self.eNBSourceCodePath + '/cmake_targets/.') sys.exit(1) else: - self.command('stdbuf -o0 cat enb_' + SSH.testCase_id + '.log | egrep --color=never -i "wait|sync"', '\$', 4) + self.command('stdbuf -o0 cat enb_' + SSH.testCase_id + '.log | egrep --text --color=never -i "wait|sync"', '\$', 4) if rruCheck: result = re.search('wait RUs', str(self.ssh.before)) else: @@ -1573,6 +1573,8 @@ class SSHConnection(): rrcReestablishRequest = 0 rrcReestablishComplete = 0 rrcReestablishReject = 0 + rlcDiscardBuffer = 0 + rachCanceledProcedure = 0 uciStatMsgCount = 0 pdcpFailure = 0 ulschFailure = 0 @@ -1625,6 +1627,12 @@ class SSHConnection(): result = re.search('ULSCH in error in round', str(line)) if result is not None: ulschFailure += 1 + result = re.search('BAD all_segments_received', str(line)) + if result is not None: + rlcDiscardBuffer += 1 + result = re.search('Canceled RA procedure for UE rnti', str(line)) + if result is not None: + rachCanceledProcedure += 1 enb_log_file.close() self.htmleNBFailureMsg = '' if uciStatMsgCount > 0: @@ -1667,6 +1675,10 @@ class SSHConnection(): rrcMsg = ' -- ' + str(rrcReestablishReject) + ' were rejected' logging.debug('\u001B[1;30;43m ' + rrcMsg + ' \u001B[0m') self.htmleNBFailureMsg += rrcMsg + '\n' + if rachCanceledProcedure > 0: + rachMsg = 'eNB cancelled ' + str(rachCanceledProcedure) + ' RA procedure(s)' + logging.debug('\u001B[1;30;43m ' + rachMsg + ' \u001B[0m') + self.htmleNBFailureMsg += rachMsg + '\n' if foundSegFault: logging.debug('\u001B[1;37;41m eNB ended with a Segmentation Fault! \u001B[0m') return ENB_PROCESS_SEG_FAULT @@ -1677,6 +1689,11 @@ class SSHConnection(): if foundRealTimeIssue: logging.debug('\u001B[1;37;41m eNB faced real time issues! \u001B[0m') return ENB_PROCESS_REALTIME_ISSUE + if rlcDiscardBuffer > 0: + rlcMsg = 'eNB RLC discarded ' + str(rlcDiscardBuffer) + ' buffer(s)' + logging.debug('\u001B[1;37;41m ' + rlcMsg + ' \u001B[0m') + self.htmleNBFailureMsg += rlcMsg + '\n' + return ENB_PROCESS_REALTIME_ISSUE return 0 def TerminateeNB(self): diff --git a/ci-scripts/xml_files/if4p5_usrp210_band40.xml b/ci-scripts/xml_files/if4p5_usrp210_band40.xml index b7877009fde5e9ebc3dbd1f3c621646eff17a0f0..ac5d9ef5ba7783ed272dc7d3ab8589240aeefab3 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band40.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band40.xml @@ -21,17 +21,15 @@ --> <testCaseList> - <!-- Only 5MHz is tested since neither 10MHz nor 20MHz work in this configuration --> - <!-- Also no UL iperf in 5MHz (040642) --> + <!-- Only 5MHz/10MHz is tested since 20MHz does not work as in monolithic --> <TestCaseRequestedList> 010101 050101 060101 070101 040101 - 030104 030105 040301 040501 040602 040401 040201 030201 030202 + 030104 030105 040301 040501 040602 040642 040401 040201 030201 030202 + 030114 030115 040301 040511 040612 040652 040401 040201 030201 030202 050201 060201 070201 </TestCaseRequestedList> <!-- - 030104 030105 040301 040501 040602 040642 040401 040201 030201 030202 - 030114 030115 040301 040511 040612 040652 040401 040201 030201 030202 030124 030125 040301 040521 040622 040662 040401 040201 030201 030202 --> <TestCaseExclusionList> diff --git a/ci-scripts/xml_files/if4p5_usrp210_band7.xml b/ci-scripts/xml_files/if4p5_usrp210_band7.xml index 9ca3a113bf143d48359b70b5bcb25e4dcd77ea3a..a582754229e8dfc402295e7abec52fe55257df71 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band7.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band7.xml @@ -21,17 +21,14 @@ --> <testCaseList> - <!-- Only 5MHz is tested since neither 10MHz nor 20MHz work in this configuration --> <TestCaseRequestedList> 010101 050101 060101 070101 040101 030101 030102 040301 040501 040604 040642 040401 040201 030201 030202 - 050201 060201 070201 - </TestCaseRequestedList> - <!-- 030111 030112 040301 040511 040614 040652 040401 040201 030201 030202 030121 030122 040301 040521 040624 040662 040401 040201 030201 030202 - --> + 050201 060201 070201 + </TestCaseRequestedList> <TestCaseExclusionList> </TestCaseExclusionList> diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 143cd6fc7bdbe62ccbf97160af5c10dfcc27c654..8d9a5d263d828b298c6d94d5ee1b498939abae4e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -232,7 +232,7 @@ add_definitions("-DPACKAGE_BUGREPORT=\"openair4g-devel@lists.eurecom.fr\"") # Debug related options ######################################### add_boolean_option(ASN_DEBUG False "ASN1 coder/decoder Debug") -add_boolean_option(EMIT_ASN_DEBUG False "ASN1 coder/decoder Debug") +add_boolean_option(ASN_EMIT_DEBUG False "ASN1 coder/decoder Debug") add_boolean_option(MSG_PRINT False "print debug messages") add_boolean_option(DISABLE_XER_PRINT False "print XER Format") add_boolean_option(XER_PRINT False "print XER Format") diff --git a/common/utils/LOG/log.c b/common/utils/LOG/log.c index 98f4b19f20910bec481138853e1b0e9b60e0a68f..e2dbac43ef584462dfbcfc23b42bb5b4dd3cca12 100644 --- a/common/utils/LOG/log.c +++ b/common/utils/LOG/log.c @@ -39,10 +39,9 @@ #include "vcd_signal_dumper.h" #include "assertions.h" - -# include <pthread.h> -# include <string.h> -#include <linux/prctl.h> +#include <pthread.h> +#include <string.h> +#include <linux/prctl.h> #include "common/config/config_userapi.h" // main log variables diff --git a/common/utils/T/tracer/gui/x.c b/common/utils/T/tracer/gui/x.c index ef5334767cb086044d34a4fd1f6f7e6210c8adab..71bd80545562a1f30a5e86f19222220d35313964 100644 --- a/common/utils/T/tracer/gui/x.c +++ b/common/utils/T/tracer/gui/x.c @@ -7,21 +7,19 @@ #include <stdlib.h> #include <string.h> -int x_connection_fd(x_connection *_x) -{ +int x_connection_fd(x_connection *_x) { struct x_connection *x = _x; return ConnectionNumber(x->d); } -static GC create_gc(Display *d, char *color) -{ +static GC create_gc(Display *d, char *color) { GC ret = XCreateGC(d, DefaultRootWindow(d), 0, NULL); XGCValues gcv; XColor rcol, scol; - XCopyGC(d, DefaultGC(d, DefaultScreen(d)), -1L, ret); + if (XAllocNamedColor(d, DefaultColormap(d, DefaultScreen(d)), - color, &scol, &rcol)) { + color, &scol, &rcol)) { gcv.foreground = scol.pixel; XChangeGC(d, ret, GCForeground, &gcv); } else ERR("X: could not allocate color '%s'\n", color); @@ -29,82 +27,81 @@ static GC create_gc(Display *d, char *color) return ret; } -int x_new_color(x_connection *_x, char *color) -{ +int x_new_color(x_connection *_x, char *color) { struct x_connection *x = _x; x->ncolors++; - x->colors = realloc(x->colors, x->ncolors * sizeof(GC)); + if (x->colors == NULL) OOM; - x->colors[x->ncolors-1] = create_gc(x->d, color); + x->colors[x->ncolors-1] = create_gc(x->d, color); x->xft_colors = realloc(x->xft_colors, x->ncolors * sizeof(XftColor)); + if (x->xft_colors == NULL) OOM; + if (XftColorAllocName(x->d, DefaultVisual(x->d, DefaultScreen(x->d)), - DefaultColormap(x->d, DefaultScreen(x->d)), - color, &x->xft_colors[x->ncolors-1]) == False) + DefaultColormap(x->d, DefaultScreen(x->d)), + color, &x->xft_colors[x->ncolors-1]) == False) ERR("could not allocate color '%s'\n", color); return x->ncolors - 1; } -int x_new_font(x_connection *_x, char *font) -{ +int x_new_font(x_connection *_x, char *font) { struct x_connection *x = _x; /* TODO: allocate fonts only once */ x->nfonts++; x->fonts = realloc(x->fonts, x->nfonts * sizeof(XftFont *)); + if (x->fonts == NULL) OOM; + x->fonts[x->nfonts-1] = XftFontOpenName(x->d, DefaultScreen(x->d), font); + if (x->fonts[x->nfonts-1] == NULL) ERR("failed allocating font '%s'\n", font); + return x->nfonts - 1; } -x_connection *x_open(void) -{ +x_connection *x_open(void) { struct x_connection *ret; - ret = calloc(1, sizeof(struct x_connection)); + if (ret == NULL) OOM; ret->d = XOpenDisplay(0); LOGD("XOpenDisplay display %p return x_connection %p\n", ret->d, ret); + if (ret->d == NULL) ERR("error calling XOpenDisplay: no X? you root?\n"); x_new_color(ret, "white"); /* background color */ x_new_color(ret, "black"); /* foreground color */ - x_new_font(ret, "sans-8"); - return ret; } x_window *x_create_window(x_connection *_x, int width, int height, - char *title) -{ + char *title) { struct x_connection *x = _x; struct x_window *ret; - ret = calloc(1, sizeof(struct x_window)); + if (ret == NULL) OOM; ret->w = XCreateSimpleWindow(x->d, DefaultRootWindow(x->d), 0, 0, - width, height, 0, WhitePixel(x->d, DefaultScreen(x->d)), - WhitePixel(x->d, DefaultScreen(x->d))); + width, height, 0, WhitePixel(x->d, DefaultScreen(x->d)), + WhitePixel(x->d, DefaultScreen(x->d))); ret->width = width; ret->height = height; - XStoreName(x->d, ret->w, title); - ret->p = XCreatePixmap(x->d, ret->w, width, height, - DefaultDepth(x->d, DefaultScreen(x->d))); + DefaultDepth(x->d, DefaultScreen(x->d))); XFillRectangle(x->d, ret->p, x->colors[BACKGROUND_COLOR], - 0, 0, width, height); - + 0, 0, width, height); ret->xft = XftDrawCreate(x->d, ret->p, - DefaultVisual(x->d, DefaultScreen(x->d)), - DefaultColormap(x->d, DefaultScreen(x->d))); + DefaultVisual(x->d, DefaultScreen(x->d)), + DefaultColormap(x->d, DefaultScreen(x->d))); + if (ret->xft == NULL) ERR("XftDrawCreate failed\n"); /* enable backing store */ @@ -113,23 +110,19 @@ x_window *x_create_window(x_connection *_x, int width, int height, att.backing_store = Always; XChangeWindowAttributes(x->d, ret->w, CWBackingStore, &att); } - XSelectInput(x->d, ret->w, - KeyPressMask | - ButtonPressMask | - ButtonReleaseMask | - PointerMotionMask | - ExposureMask | - StructureNotifyMask); - + KeyPressMask | + ButtonPressMask | + ButtonReleaseMask | + PointerMotionMask | + ExposureMask | + StructureNotifyMask); XMapWindow(x->d, ret->w); - return ret; } x_image *x_create_image(x_connection *_x, unsigned char *data, - int width, int height) -{ + int width, int height) { struct x_connection *x = _x; struct x_image *ret; XImage *ximage; @@ -137,8 +130,9 @@ x_image *x_create_image(x_connection *_x, unsigned char *data, XVisualInfo template; int nvs; Visual *v; + ret = calloc(1, sizeof(struct x_image)); - ret = calloc(1, sizeof(struct x_image)); if (ret == NULL) OOM; + if (ret == NULL) OOM; template.class = TrueColor; template.depth = 24; @@ -146,68 +140,65 @@ x_image *x_create_image(x_connection *_x, unsigned char *data, template.green_mask = 0x00ff00; template.blue_mask = 0x0000ff; template.bits_per_rgb = 8; - vs = XGetVisualInfo(x->d, VisualDepthMask | VisualClassMask | - VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | - VisualBitsPerRGBMask, &template, &nvs); + VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | + VisualBitsPerRGBMask, &template, &nvs); if (vs == NULL) { /* try again with 32 bpp */ template.depth = 32; vs = XGetVisualInfo(x->d, VisualDepthMask | VisualClassMask | - VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | - VisualBitsPerRGBMask, &template, &nvs); + VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask | + VisualBitsPerRGBMask, &template, &nvs); } if (vs == NULL) ERR("no good visual found\n"); v = vs[0].visual; XFree(vs); - ximage = XCreateImage(x->d, v, 24, ZPixmap, 0, - (char*)data, width, height, 32, 0); + (char *)data, width, height, 32, 0); + if (ximage == NULL) ERR("image creation failed\n"); ret->p = XCreatePixmap(x->d, DefaultRootWindow(x->d), width, height, 24); - XPutImage(x->d, ret->p, DefaultGC(x->d, DefaultScreen(x->d)), - ximage, 0, 0, 0, 0, width, height); - + ximage, 0, 0, 0, 0, width, height); /* TODO: be sure it's fine to set data to NULL */ ximage->data = NULL; XDestroyImage(ximage); - ret->width = width; ret->height = height; - return ret; } -static struct toplevel_window_widget *find_x_window(struct gui *g, Window id) -{ +static struct toplevel_window_widget *find_x_window(struct gui *g, Window id) { struct widget_list *cur; struct toplevel_window_widget *w; struct x_window *xw; cur = g->toplevel; + while (cur) { w = (struct toplevel_window_widget *)cur->item; xw = w->x; + if (xw->w == id) return w; + cur = cur->next; } + return NULL; } -void x_events(gui *_gui) -{ +void x_events(gui *_gui) { struct gui *g = _gui; struct widget_list *cur; struct x_connection *x = g->x; struct toplevel_window_widget *w; - LOGD("x_events START\n"); /* preprocessing (to "compress" events) */ cur = g->toplevel; + while (cur) { struct x_window *xw; w = (struct toplevel_window_widget *)cur->item; @@ -222,58 +213,84 @@ void x_events(gui *_gui) XEvent ev; XNextEvent(x->d, &ev); LOGD("XEV %d\n", ev.type); + switch (ev.type) { - case MapNotify: - case Expose: - if ((w = find_x_window(g, ev.xexpose.window)) != NULL) { - struct x_window *xw = w->x; - xw->redraw = 1; - } - break; - case ConfigureNotify: - if ((w = find_x_window(g, ev.xconfigure.window)) != NULL) { - struct x_window *xw = w->x; - xw->resize = 1; - xw->new_width = ev.xconfigure.width; - xw->new_height = ev.xconfigure.height; - if (xw->new_width < 10) xw->new_width = 10; - if (xw->new_height < 10) xw->new_height = 10; - LOGD("ConfigureNotify %d %d\n", ev.xconfigure.width, ev.xconfigure.height); - } - break; - case ButtonPress: - if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { - int key_modifiers = 0; - if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; - if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; - if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; - w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, - ev.xbutton.button, 0); - } - break; - case ButtonRelease: - if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { - int key_modifiers = 0; - if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; - if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; - if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; - w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, - ev.xbutton.button, 1); - } - break; - default: if (gui_logd) WARN("TODO: X event type %d\n", ev.type); break; + case MapNotify: + case Expose: + if ((w = find_x_window(g, ev.xexpose.window)) != NULL) { + struct x_window *xw = w->x; + xw->redraw = 1; + } + + break; + + case ConfigureNotify: + if ((w = find_x_window(g, ev.xconfigure.window)) != NULL) { + struct x_window *xw = w->x; + xw->resize = 1; + xw->new_width = ev.xconfigure.width; + xw->new_height = ev.xconfigure.height; + + if (xw->new_width < 10) xw->new_width = 10; + + if (xw->new_height < 10) xw->new_height = 10; + + LOGD("ConfigureNotify %d %d\n", ev.xconfigure.width, ev.xconfigure.height); + } + + break; + + case ButtonPress: + if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { + int key_modifiers = 0; + + if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; + + if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; + + if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; + + w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, + ev.xbutton.button, 0); + } + + break; + + case ButtonRelease: + if ((w = find_x_window(g, ev.xbutton.window)) != NULL) { + int key_modifiers = 0; + + if (ev.xbutton.state & ShiftMask) key_modifiers |= KEY_SHIFT; + + if (ev.xbutton.state & Mod1Mask) key_modifiers |= KEY_ALT; + + if (ev.xbutton.state & ControlMask) key_modifiers |= KEY_CONTROL; + + w->common.button(g, w, ev.xbutton.x, ev.xbutton.y, key_modifiers, + ev.xbutton.button, 1); + } + + break; + + default: + if (gui_logd) WARN("TODO: X event type %d\n", ev.type); + + break; } } /* postprocessing */ LOGD("post processing\n"); cur = g->toplevel; + while (cur) { struct toplevel_window_widget *w = - (struct toplevel_window_widget *)cur->item; + (struct toplevel_window_widget *)cur->item; struct x_window *xw = w->x; + if (xw->resize) { LOGD("resize old %d %d new %d %d\n", xw->width, xw->height, xw->new_width, xw->new_height); + if (xw->width != xw->new_width || xw->height != xw->new_height) { w->common.allocate(g, w, 0, 0, xw->new_width, xw->new_height); xw->width = xw->new_width; @@ -281,46 +298,47 @@ void x_events(gui *_gui) XftDrawDestroy(xw->xft); XFreePixmap(x->d, xw->p); xw->p = XCreatePixmap(x->d, xw->w, xw->width, xw->height, - DefaultDepth(x->d, DefaultScreen(x->d))); + DefaultDepth(x->d, DefaultScreen(x->d))); XFillRectangle(x->d, xw->p, x->colors[BACKGROUND_COLOR], - 0, 0, xw->width, xw->height); + 0, 0, xw->width, xw->height); xw->xft = XftDrawCreate(x->d, xw->p, - DefaultVisual(x->d, DefaultScreen(x->d)), - DefaultColormap(x->d, DefaultScreen(x->d))); + DefaultVisual(x->d, DefaultScreen(x->d)), + DefaultColormap(x->d, DefaultScreen(x->d))); + if (xw->xft == NULL) ERR("XftDrawCreate failed\n"); //xw->repaint = 1; } } + if (xw->repaint) { w->common.paint(g, w); xw->redraw = 1; } + if (xw->redraw) { struct x_connection *x = g->x; LOGD("XCopyArea w h %d %d\n", xw->width, xw->height); XCopyArea(x->d, xw->p, xw->w, x->colors[1], - 0, 0, xw->width, xw->height, 0, 0); + 0, 0, xw->width, xw->height, 0, 0); } + cur = cur->next; } + LOGD("x_events DONE\n"); } -void x_flush(x_connection *_x) -{ +void x_flush(x_connection *_x) { struct x_connection *x = _x; XFlush(x->d); } void x_text_get_dimensions(x_connection *_c, int font, const char *t, - int *width, int *height, int *baseline) -{ + int *width, int *height, int *baseline) { struct x_connection *c = _c; XGlyphInfo ext; - XftTextExtentsUtf8(c->d, c->fonts[font], (FcChar8 *)t, strlen(t), &ext); - *width = ext.width; *height = c->fonts[font]->height; *baseline = c->fonts[font]->ascent; @@ -331,63 +349,57 @@ void x_text_get_dimensions(x_connection *_c, int font, const char *t, /***********************************************************************/ void x_draw_line(x_connection *_c, x_window *_w, int color, - int x1, int y1, int x2, int y2) -{ + int x1, int y1, int x2, int y2) { struct x_connection *c = _c; struct x_window *w = _w; XDrawLine(c->d, w->p, c->colors[color], x1, y1, x2, y2); } void x_draw_rectangle(x_connection *_c, x_window *_w, int color, - int x, int y, int width, int height) -{ + int x, int y, int width, int height) { struct x_connection *c = _c; struct x_window *w = _w; XDrawRectangle(c->d, w->p, c->colors[color], x, y, width, height); } void x_fill_rectangle(x_connection *_c, x_window *_w, int color, - int x, int y, int width, int height) -{ + int x, int y, int width, int height) { struct x_connection *c = _c; struct x_window *w = _w; XFillRectangle(c->d, w->p, c->colors[color], x, y, width, height); } void x_draw_string(x_connection *_c, x_window *_w, int font, int color, - int x, int y, const char *t) -{ + int x, int y, const char *t) { struct x_connection *c = _c; struct x_window *w = _w; int tlen = strlen(t); XftDrawStringUtf8(w->xft, &c->xft_colors[color], c->fonts[font], - x, y, (const unsigned char *)t, tlen); + x, y, (const unsigned char *)t, tlen); } void x_draw_clipped_string(x_connection *_c, x_window *_w, int font, - int color, int x, int y, const char *t, - int clipx, int clipy, int clipwidth, int clipheight) -{ + int color, int x, int y, const char *t, + int clipx, int clipy, int clipwidth, int clipheight) { struct x_window *w = _w; - XRectangle clip = { clipx, clipy, clipwidth, clipheight }; + if (XftDrawSetClipRectangles(w->xft, 0, 0, &clip, 1) == False) abort(); + x_draw_string(_c, _w, font, color, x, y, t); + if (XftDrawSetClip(w->xft, NULL) == False) abort(); } -void x_draw_image(x_connection *_c, x_window *_w, x_image *_img, int x, int y) -{ +void x_draw_image(x_connection *_c, x_window *_w, x_image *_img, int x, int y) { struct x_connection *c = _c; struct x_window *w = _w; struct x_image *img = _img; - XCopyArea(c->d, img->p, w->p, DefaultGC(c->d, DefaultScreen(c->d)), - 0, 0, img->width, img->height, x, y); + 0, 0, img->width, img->height, x, y); } -void x_draw(x_connection *_c, x_window *_w) -{ +void x_draw(x_connection *_c, x_window *_w) { struct x_connection *c = _c; struct x_window *w = _w; LOGD("x_draw XCopyArea w h %d %d display %p window %d pixmap %d\n", w->width, w->height, c->d, (int)w->w, (int)w->p); @@ -397,13 +409,13 @@ void x_draw(x_connection *_c, x_window *_w) /* those two special functions are to plot many points * first call x_add_point many times then x_plot_points once */ -void x_add_point(x_connection *_c, int x, int y) -{ +void x_add_point(x_connection *_c, int x, int y) { struct x_connection *c = _c; if (c->pts_size == c->pts_maxsize) { c->pts_maxsize += 65536; c->pts = realloc(c->pts, c->pts_maxsize * sizeof(XPoint)); + if (c->pts == NULL) OOM; } @@ -412,12 +424,11 @@ void x_add_point(x_connection *_c, int x, int y) c->pts_size++; } -void x_plot_points(x_connection *_c, x_window *_w, int color) -{ +void x_plot_points(x_connection *_c, x_window *_w, int color) { struct x_connection *c = _c; LOGD("x_plot_points %d points\n", c->pts_size); struct x_window *w = _w; XDrawPoints(c->d, w->p, c->colors[color], c->pts, c->pts_size, - CoordModeOrigin); + CoordModeOrigin); c->pts_size = 0; } diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c index 8022bc53f43d2b2defa5fbc19c633ae70715310b..bd9ce8dc1c1abc3b875f43fd264f6bd48d42f8fc 100644 --- a/nfapi/oai_integration/nfapi_vnf.c +++ b/nfapi/oai_integration/nfapi_vnf.c @@ -196,14 +196,12 @@ 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 td:%p te:%p if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->td, eNB->te, 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; - eNB->td = ulsch_decoding_data_all;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding_all;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; RC.nb_CC[bodge_counter] = 1; diff --git a/openair1/PHY/INIT/init_top.c b/openair1/PHY/INIT/init_top.c index 1bb36bd2e52f295b4f3165bb66559a1c632ad70f..698f34833d7d12995596530d3cc573d246816fa6 100644 --- a/openair1/PHY/INIT/init_top.c +++ b/openair1/PHY/INIT/init_top.c @@ -59,14 +59,11 @@ void generate_qpsk_table(void) { } } -void init_7_5KHz(void); void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) { ccodelte_init(); ccodelte_init_inv(); - init_dfts(); phy_generate_viterbi_tables_lte(); load_codinglib(); - lte_sync_time_init(frame_parms); generate_ul_ref_sigs(); generate_ul_ref_sigs_rx(); generate_64qam_table(); @@ -76,13 +73,11 @@ void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) { init_unscrambling_lut(); init_scrambling_lut(); //set_taus_seed(1328); -// init_7_5KHz(); init_sss(); } void free_lte_top(void) { free_codinglib(); - lte_sync_time_free(); /* free_ul_ref_sigs() is called in phy_free_lte_eNB() */ } diff --git a/openair1/PHY/INIT/lte_init_ru.c b/openair1/PHY/INIT/lte_init_ru.c index e2f6259447889a2d4bbc981fb0cfa27c9f53ca36..c4cd3600c053fac24658923fd18073e845fe2661 100644 --- a/openair1/PHY/INIT/lte_init_ru.c +++ b/openair1/PHY/INIT/lte_init_ru.c @@ -67,6 +67,7 @@ int phy_init_RU(RU_t *ru) { } if (ru->function != NGFI_RRU_IF5) { // we need to do RX/TX RU processing + init_dfts(); init_7_5KHz(); LOG_I(PHY,"nb_tx %d\n",ru->nb_tx); ru->common.rxdata_7_5kHz = (int32_t**)malloc16(ru->nb_rx*sizeof(int32_t*) ); diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index 31c37e4669cc3d3d14c0d4a0d4711032a834f53f..1361c41087de62efeb04bd809add2ad929028104 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -30,6 +30,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "assertions.h" #include <math.h> +#include "PHY/LTE_ESTIMATION/lte_estimation.h" #include "PHY/LTE_TRANSPORT/transport_common_proto.h" #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" #include "PHY/LTE_REFSIG/lte_refsig.h" @@ -661,8 +662,9 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, - + init_dfts(); init_frame_parms(&ue->frame_parms,1); + lte_sync_time_init(&ue->frame_parms); init_lte_top(&ue->frame_parms); init_7_5KHz(); init_ul_hopping(&ue->frame_parms); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 046e456916a104bf5afc892142a9317807ac4e80..50b9ef17acb6a0b2b8e06c0fe1cdf4a120f3a1cc 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -1505,7 +1505,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, // Do ULSCH Decoding for data portion - ret = eNB->td(eNB,UE_id,harq_pid,llr8_flag); + ret = ulsch_decoding_data_all(eNB,UE_id,harq_pid,llr8_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index e8f20c85de6a682ce3cf947ee23aa4447c0eb776..89b15ece93761e9f88ede5b2b3ae7d2b5d5f203d 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -1298,7 +1298,7 @@ void dlsch_channel_compensation(int **rxdataF_ext, unsigned short rb; unsigned char aatx,aarx,symbol_mod,pilots=0; __m128i *dl_ch128,*dl_ch128_2,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -1311,9 +1311,9 @@ void dlsch_channel_compensation(int **rxdataF_ext, } for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { + __m128i QAM_amp128b = _mm_setzero_si128(); if (mod_order == 4) { QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) - QAM_amp128b = _mm_setzero_si128(); } else if (mod_order == 6) { QAM_amp128 = _mm_set1_epi16(QAM64_n1); // QAM_amp128b = _mm_set1_epi16(QAM64_n2); @@ -1766,11 +1766,11 @@ void dlsch_channel_compensation_core(int **rxdataF_ext, int length_mod8 = 0; int length2; __m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b, *dl_ch128_2, *rxdataF128,*rxdataF_comp128,*rho128; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128; int aatx = 0, aarx = 0; for (aatx=0; aatx<n_tx; aatx++) { - + __m128i QAM_amp128b; if (mod_order == 4) { QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) QAM_amp128b = _mm_setzero_si128(); @@ -2158,7 +2158,7 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext, __m128i *dl_ch0_128,*dl_ch1_128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128; unsigned char aarx=0,symbol_mod,pilots=0; int precoded_signal_strength=0; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -2167,10 +2167,9 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext, //printf("comp prec: symbol %d, pilots %d\n",symbol, pilots); - + __m128i QAM_amp128b = _mm_setzero_si128(); if (mod_order == 4) { QAM_amp128 = _mm_set1_epi16(QAM16_n1); - QAM_amp128b = _mm_setzero_si128(); } else if (mod_order == 6) { QAM_amp128 = _mm_set1_epi16(QAM64_n1); QAM_amp128b = _mm_set1_epi16(QAM64_n2); @@ -2621,7 +2620,7 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms, int **rxdataF_comp0 = pdsch_vars->rxdataF_comp0; int **rxdataF_comp1 = pdsch_vars->rxdataF_comp1[harq_pid][round]; unsigned char *pmi_ext = pdsch_vars->pmi_ext; - __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp0_128,QAM_amp0_128b,QAM_amp1_128,QAM_amp1_128b; + __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp0_128,QAM_amp1_128; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; @@ -2632,17 +2631,17 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms, // printf("comp prec: symbol %d, pilots %d\n",symbol, pilots); + __m128i QAM_amp0_128b = _mm_setzero_si128(); if (mod_order0 == 4) { QAM_amp0_128 = _mm_set1_epi16(QAM16_n1); - QAM_amp0_128b = _mm_setzero_si128(); } else if (mod_order0 == 6) { QAM_amp0_128 = _mm_set1_epi16(QAM64_n1); QAM_amp0_128b = _mm_set1_epi16(QAM64_n2); } + __m128i QAM_amp1_128b = _mm_setzero_si128(); if (mod_order1 == 4) { QAM_amp1_128 = _mm_set1_epi16(QAM16_n1); - QAM_amp1_128b = _mm_setzero_si128(); } else if (mod_order1 == 6) { QAM_amp1_128 = _mm_set1_epi16(QAM64_n1); QAM_amp1_128b = _mm_set1_epi16(QAM64_n2); diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index ae0168b53c638ef179e3d1494b7170359425270d..9f4a196a9b21648590b62cec8899e0f46fe9cf88 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -58,6 +58,7 @@ #include <math.h> #include "common_lib.h" #include "msc.h" +#include <common/utils/LOG/log.h> //#include <complex.h> @@ -862,22 +863,60 @@ typedef enum { RESYNCH=4 } UE_MODE_t; -/// Threading Parameter +#define FOREACH_PARALLEL(GEN) \ + GEN(PARALLEL_SINGLE_THREAD) \ + GEN(PARALLEL_RU_L1_SPLIT) \ + GEN(PARALLEL_RU_L1_TRX_SPLIT) + +#define GENERATE_ENUM(N) N, +#define GENERATE_ENUMTXT(N) {(char*)#N, N}, + typedef enum { - PARALLEL_SINGLE_THREAD =0, - PARALLEL_RU_L1_SPLIT =1, - PARALLEL_RU_L1_TRX_SPLIT =2 -}PARALLEL_CONF_t; + FOREACH_PARALLEL(GENERATE_ENUM) +} PARALLEL_CONF_t; +#define FOREACH_WORKER(GEN) GEN(WORKER_DISABLE) GEN(WORKER_ENABLE) typedef enum { - WORKER_DISABLE =0, - WORKER_ENABLE =1 + FOREACH_WORKER(GENERATE_ENUM) }WORKER_CONF_t; typedef struct THREAD_STRUCT_s { PARALLEL_CONF_t parallel_conf; WORKER_CONF_t worker_conf; } THREAD_STRUCT; +extern THREAD_STRUCT thread_struct; + +static inline void set_parallel_conf(char *parallel_conf) { + mapping config[]= { + FOREACH_PARALLEL(GENERATE_ENUMTXT) + {NULL,-1} + }; + thread_struct.parallel_conf = (PARALLEL_CONF_t)map_str_to_int(config, parallel_conf); + if (thread_struct.parallel_conf == -1 ) { + LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf); + thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; + } +} + +static inline void set_worker_conf(char *worker_conf) { + mapping config[]={ + FOREACH_WORKER(GENERATE_ENUMTXT) + {NULL, -1} + }; + thread_struct.worker_conf = (WORKER_CONF_t)map_str_to_int(config, worker_conf); + if (thread_struct.worker_conf == -1 ) { + LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf); + thread_struct.worker_conf = WORKER_DISABLE ; + } +} + +static inline PARALLEL_CONF_t get_thread_parallel_conf(void) { + return thread_struct.parallel_conf; +} + +static inline WORKER_CONF_t get_thread_worker_conf(void) { + return thread_struct.worker_conf; +} typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 2db81aef7734a41be6121d966bea5cdf2f1d7f7d..bb147a3963375266c1a04832d0cd014bf8625fd0 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -904,8 +904,6 @@ typedef struct PHY_VARS_eNB_s { /// Ethernet parameters for fronthaul interface eth_params_t eth_params; int rx_total_gain_dB; - int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag); - int (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *); int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); uint8_t local_flag; LTE_DL_FRAME_PARMS frame_parms; @@ -1080,6 +1078,7 @@ typedef struct PHY_VARS_eNB_s { time_stats_t ofdm_mod_stats; time_stats_t dlsch_common_and_dci; + time_stats_t dlsch_ue_specific; time_stats_t dlsch_encoding_stats; time_stats_t dlsch_modulation_stats; time_stats_t dlsch_scrambling_stats; diff --git a/openair1/PHY/phy_vars_ue.h b/openair1/PHY/phy_vars_ue.h index 0d29b03f63d0970103d1ed18d376ec5a712e9793..33f93fc78d7cbadef6540ca314278e51ab3f74f8 100644 --- a/openair1/PHY/phy_vars_ue.h +++ b/openair1/PHY/phy_vars_ue.h @@ -28,9 +28,9 @@ #include "common/ran_context.h" -char* namepointer_chMag ; +char *namepointer_chMag ; char fmageren_name2[512]; -char* namepointer_log2; +char *namepointer_log2; #include "PHY/LTE_REFSIG/primary_synch.h" @@ -45,7 +45,7 @@ int16_t *primary_synch2_time; PHY_VARS_UE ***PHY_vars_UE_g; LTE_DL_FRAME_PARMS *lte_frame_parms_g; #else -PHY_VARS_UE * PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]={NULL}; +PHY_VARS_UE *PHY_vars_UE_g[MAX_UE][MAX_NUM_CCs]= {NULL}; #endif @@ -62,10 +62,10 @@ char mode_string[4][20] = {"NOT SYNCHED","PRACH","RAR","PUSCH"}; #ifndef OPENAIR2 -unsigned char NB_eNB_INST=0; -unsigned char NB_UE_INST=0; -unsigned char NB_RN_INST=0; -unsigned char NB_INST=0; + unsigned char NB_eNB_INST=0; + unsigned char NB_UE_INST=0; + unsigned char NB_RN_INST=0; + unsigned char NB_INST=0; #endif unsigned int ULSCH_max_consecutive_errors = 20; @@ -134,9 +134,9 @@ double beta2_dlsch[6][MCS_COUNT] = { {2.52163, 0.83231, 0.77472, 1.36536, 1.1682 #ifdef OCP_FRAMEWORK #include <enums.h> #else -char eNB_functions[6][20]={"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",}; -char eNB_timing[2][20]={"synch_to_ext_device","synch_to_other"}; -char ru_if_types[MAX_RU_IF_TYPES][20]={"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; +char eNB_functions[6][20]= {"eNodeB_3GPP","eNodeB_3GPP_BBU","NGFI_RAU_IF4p5","NGFI_RRU_IF5","NGFI_RRU_IF4p5",}; +char eNB_timing[2][20]= {"synch_to_ext_device","synch_to_other"}; +char ru_if_types[MAX_RU_IF_TYPES][20]= {"local RF","IF5 RRU","IF5 Mobipass","IF4p5 RRU","IF1pp RRU"}; #endif /// lookup table for unscrambling in RX diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index b1d09ba8e9306e22c805759c85d656d99b0a2fa7..141f6e43ffbedb3190da404a341b1094b0b28ded 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -400,7 +400,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, start_meas(&eNB->dlsch_encoding_stats); - eNB->te(eNB, + dlsch_encoding_all(eNB, dlsch_harq->pdu, dlsch_harq->pdsch_start, dlsch, @@ -582,6 +582,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, } if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci); + if (do_meas==1) start_meas(&eNB->dlsch_ue_specific); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0); @@ -649,6 +650,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),0); + if (do_meas==1) stop_meas(&eNB->dlsch_ue_specific); if (do_meas==1) stop_meas(&eNB->phy_proc_tx); } diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c index f8fc0369bdd5990a9f66fed8d9c6921b9be325a3..2af47fb2c011b38a0ae29bf7b7898527843e2025 100644 --- a/openair1/SCHED_UE/phy_procedures_lte_ue.c +++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c @@ -45,7 +45,7 @@ #ifndef PUCCH -#define PUCCH + #define PUCCH #endif #include "LAYER2/MAC/mac.h" @@ -55,7 +55,7 @@ #include "UTIL/OPT/opt.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "PHY/defs_UE.h" @@ -77,41 +77,36 @@ void Msg1_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8 void Msg3_transmitted(module_id_t module_idP,uint8_t CC_id,frame_t frameP, uint8_t eNB_id); #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) -extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; + extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; #endif void get_dumpparam(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, uint8_t nb_rb, uint32_t *alloc_even, uint8_t subframe,uint32_t Qm, uint32_t Nl, uint32_t tm, uint8_t *nsymb, uint32_t *coded_bits_per_codeword) { - *nsymb = (ue->frame_parms.Ncp == 0) ? 14 : 12; - *coded_bits_per_codeword = get_G(&ue->frame_parms, - nb_rb, - alloc_even, - Qm, - Nl, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - proc->frame_rx, - subframe, - tm); + nb_rb, + alloc_even, + Qm, + Nl, + ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, + proc->frame_rx, + subframe, + tm); } -void dump_dlsch(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid) -{ - if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)) { +void dump_dlsch(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid) { + if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)) { unsigned int coded_bits_per_codeword; uint8_t nsymb ; - - get_dumpparam(ue, proc, eNB_id, - ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->nb_rb , - ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->rb_alloc_even, - subframe, - ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->Qm, - ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->Nl, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], - &nsymb, &coded_bits_per_codeword); - + get_dumpparam(ue, proc, eNB_id, + ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->nb_rb, + ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->rb_alloc_even, + subframe, + ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->Qm, + ue->dlsch[ue->current_thread_id[subframe]][eNB_id][0]->harq_processes[harq_pid]->Nl, + ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], + &nsymb, &coded_bits_per_codeword); LOG_M("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,2,1); LOG_M("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars[ue->current_thread_id[subframe]][0]->rxdataF_ext[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,1,1); LOG_M("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars[ue->current_thread_id[subframe]][0]->dl_ch_estimates_ext[0],300*nsymb,1,1); @@ -123,36 +118,30 @@ void dump_dlsch(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subf */ LOG_M("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars[ue->current_thread_id[subframe]][0]->rxdataF_comp0[0],300*12,1,1); LOG_M("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars[ue->current_thread_id[subframe]][0]->llr[0],coded_bits_per_codeword,1,0); - LOG_M("dlsch_mag1.m","dlschmag1",ue->pdsch_vars[ue->current_thread_id[subframe]][0]->dl_ch_mag0,300*12,1,1); LOG_M("dlsch_mag2.m","dlschmag2",ue->pdsch_vars[ue->current_thread_id[subframe]][0]->dl_ch_magb0,300*12,1,1); - } + } } -void dump_dlsch_SI(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe) -{ - if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)){ +void dump_dlsch_SI(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe) { + if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)) { unsigned int coded_bits_per_codeword; uint8_t nsymb; - get_dumpparam(ue, proc, eNB_id, - ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_SI[eNB_id]->harq_processes[0]->rb_alloc_even, - subframe,2,1,0, - &nsymb, &coded_bits_per_codeword); - + ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, + ue->dlsch_SI[eNB_id]->harq_processes[0]->rb_alloc_even, + subframe,2,1,0, + &nsymb, &coded_bits_per_codeword); LOG_D(PHY,"[UE %d] Dumping dlsch_SI : ofdm_symbol_size %d, nsymb %d, nb_rb %d, mcs %d, nb_rb %d, num_pdcch_symbols %d,G %d\n", - ue->Mod_id, - ue->frame_parms.ofdm_symbol_size, - nsymb, - ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_SI[eNB_id]->harq_processes[0]->mcs, - ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - coded_bits_per_codeword); - + ue->Mod_id, + ue->frame_parms.ofdm_symbol_size, + nsymb, + ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, + ue->dlsch_SI[eNB_id]->harq_processes[0]->mcs, + ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, + ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, + coded_bits_per_codeword); LOG_M("rxsig0.m","rxs0", &ue->common_vars.rxdata[0][subframe*ue->frame_parms.samples_per_tti],ue->frame_parms.samples_per_tti,1,1); - LOG_M("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[0],nsymb*ue->frame_parms.ofdm_symbol_size,1,1); LOG_M("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars_SI[0]->rxdataF_ext[0],2*nsymb*ue->frame_parms.ofdm_symbol_size,1,1); LOG_M("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars_SI[0]->dl_ch_estimates_ext[0],ue->frame_parms.N_RB_DL*12*nsymb,1,1); @@ -164,7 +153,6 @@ void dump_dlsch_SI(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t s */ LOG_M("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars_SI[0]->rxdataF_comp0[0],ue->frame_parms.N_RB_DL*12*nsymb,1,1); LOG_M("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars_SI[0]->llr[0],coded_bits_per_codeword,1,0); - LOG_M("dlsch_mag1.m","dlschmag1",ue->pdsch_vars_SI[0]->dl_ch_mag0,300*nsymb,1,1); LOG_M("dlsch_mag2.m","dlschmag2",ue->pdsch_vars_SI[0]->dl_ch_magb0,300*nsymb,1,1); sleep(1); @@ -214,9 +202,7 @@ void dump_dlsch_SI(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t s } */ -unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb) -{ - +unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb) { int gain_dB; double gain_lin; @@ -232,27 +218,22 @@ unsigned int get_tx_amp(int power_dBm, int power_max_dBm, int N_RB_UL, int nb_rb #endif -void dump_dlsch_ra(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe) -{ - if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)){ +void dump_dlsch_ra(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe) { + if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)) { unsigned int coded_bits_per_codeword; uint8_t nsymb ; - - get_dumpparam(ue, proc, eNB_id, - ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_SI[eNB_id]->harq_processes[0]->rb_alloc_even, - subframe,2,1,0, - &nsymb, &coded_bits_per_codeword); - + ue->dlsch_SI[eNB_id]->harq_processes[0]->nb_rb, + ue->dlsch_SI[eNB_id]->harq_processes[0]->rb_alloc_even, + subframe,2,1,0, + &nsymb, &coded_bits_per_codeword); LOG_D(PHY,"[UE %d] Dumping dlsch_ra : nb_rb %d, mcs %d, nb_rb %d, num_pdcch_symbols %d,G %d\n", - ue->Mod_id, - ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb, - ue->dlsch_ra[eNB_id]->harq_processes[0]->mcs, - ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb, - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, - coded_bits_per_codeword); - + ue->Mod_id, + ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb, + ue->dlsch_ra[eNB_id]->harq_processes[0]->mcs, + ue->dlsch_ra[eNB_id]->harq_processes[0]->nb_rb, + ue->pdcch_vars[0%RX_NB_TH][eNB_id]->num_pdcch_symbols, + coded_bits_per_codeword); LOG_M("rxsigF0.m","rxsF0", ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe]].rxdataF[0],2*12*ue->frame_parms.ofdm_symbol_size,2,1); LOG_M("rxsigF0_ext.m","rxsF0_ext", ue->pdsch_vars_ra[0]->rxdataF_ext[0],2*12*ue->frame_parms.ofdm_symbol_size,1,1); LOG_M("dlsch00_ch0_ext.m","dl00_ch0_ext", ue->pdsch_vars_ra[0]->dl_ch_estimates_ext[0],300*nsymb,1,1); @@ -264,60 +245,53 @@ void dump_dlsch_ra(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t s */ LOG_M("dlsch_rxF_comp0.m","dlsch0_rxF_comp0", ue->pdsch_vars_ra[0]->rxdataF_comp0[0],300*nsymb,1,1); LOG_M("dlsch_rxF_llr.m","dlsch_llr", ue->pdsch_vars_ra[0]->llr[0],coded_bits_per_codeword,1,0); - LOG_M("dlsch_mag1.m","dlschmag1",ue->pdsch_vars_ra[0]->dl_ch_mag0,300*nsymb,1,1); LOG_M("dlsch_mag2.m","dlschmag2",ue->pdsch_vars_ra[0]->dl_ch_magb0,300*nsymb,1,1); } } -void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index) -{ - +void phy_reset_ue(module_id_t Mod_id,uint8_t CC_id,uint8_t eNB_index) { // This flushes ALL DLSCH and ULSCH harq buffers of ALL connected eNBs...add the eNB_index later // for more flexibility - uint8_t i,j,k,s; PHY_VARS_UE *ue = PHY_vars_UE_g[Mod_id][CC_id]; //[NUMBER_OF_RX_THREAD=2][NUMBER_OF_CONNECTED_eNB_MAX][2]; for(int l=0; l<RX_NB_TH; l++) { - for(i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { - for(j=0; j<2; j++) { - //DL HARQ - if(ue->dlsch[l][i][j]) { - for(k=0; k<NUMBER_OF_HARQ_PID_MAX && ue->dlsch[l][i][j]->harq_processes[k]; k++) { - ue->dlsch[l][i][j]->harq_processes[k]->status = SCH_IDLE; - for (s=0; s<10; s++) { - // reset ACK/NACK bit to DTX for all subframes s = 0..9 - ue->dlsch[l][i][j]->harq_ack[s].ack = 2; - ue->dlsch[l][i][j]->harq_ack[s].send_harq_status = 0; - ue->dlsch[l][i][j]->harq_ack[s].vDAI_UL = 0xff; - ue->dlsch[l][i][j]->harq_ack[s].vDAI_DL = 0xff; - } - } - } - } - - //UL HARQ - if(ue->ulsch[i]) { - for(k=0; k<NUMBER_OF_HARQ_PID_MAX && ue->ulsch[i]->harq_processes[k]; k++) { - ue->ulsch[i]->harq_processes[k]->status = SCH_IDLE; - //Set NDIs for all UL HARQs to 0 - // ue->ulsch[i]->harq_processes[k]->Ndi = 0; - - } + for(i=0; i<NUMBER_OF_CONNECTED_eNB_MAX; i++) { + for(j=0; j<2; j++) { + //DL HARQ + if(ue->dlsch[l][i][j]) { + for(k=0; k<NUMBER_OF_HARQ_PID_MAX && ue->dlsch[l][i][j]->harq_processes[k]; k++) { + ue->dlsch[l][i][j]->harq_processes[k]->status = SCH_IDLE; + + for (s=0; s<10; s++) { + // reset ACK/NACK bit to DTX for all subframes s = 0..9 + ue->dlsch[l][i][j]->harq_ack[s].ack = 2; + ue->dlsch[l][i][j]->harq_ack[s].send_harq_status = 0; + ue->dlsch[l][i][j]->harq_ack[s].vDAI_UL = 0xff; + ue->dlsch[l][i][j]->harq_ack[s].vDAI_DL = 0xff; + } } + } + } - // flush Msg3 buffer - ue->ulsch_Msg3_active[i] = 0; - + //UL HARQ + if(ue->ulsch[i]) { + for(k=0; k<NUMBER_OF_HARQ_PID_MAX && ue->ulsch[i]->harq_processes[k]; k++) { + ue->ulsch[i]->harq_processes[k]->status = SCH_IDLE; + //Set NDIs for all UL HARQs to 0 + // ue->ulsch[i]->harq_processes[k]->Ndi = 0; + } } + + // flush Msg3 buffer + ue->ulsch_Msg3_active[i] = 0; + } } } -void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) -{ - +void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) { // if contention resolution fails, go back to PRACH PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[eNB_index] = PRACH; PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_index]->crnti_is_temporary = 0; @@ -327,13 +301,9 @@ void ra_failed(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) LOG_E(PHY,"[UE %d] Random-access procedure fails, going back to PRACH, setting SIStatus = 0, discard temporary C-RNTI and State RRC_IDLE\n",Mod_id); } -void ra_succeeded(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) -{ - +void ra_succeeded(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) { int i; - LOG_I(PHY,"[UE %d][RAPROC] Random-access procedure succeeded. Set C-RNTI = Temporary C-RNTI\n",Mod_id); - PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[0][eNB_index]->crnti_is_temporary = 0; PHY_vars_UE_g[Mod_id][CC_id]->pdcch_vars[1][eNB_index]->crnti_is_temporary = 0; PHY_vars_UE_g[Mod_id][CC_id]->ulsch_Msg3_active[eNB_index] = 0; @@ -347,50 +317,31 @@ void ra_succeeded(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) PHY_vars_UE_g[Mod_id][CC_id]->ulsch[eNB_index]->harq_processes[i]->subframe_scheduling_flag=0; } } - - } -UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) -{ - +UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index) { return(PHY_vars_UE_g[Mod_id][CC_id]->UE_mode[eNB_index]); - } void process_timing_advance_rar(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint16_t timing_advance) { - ue->timing_advance = timing_advance*4; - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - /* TODO: fix this log, what is 'HW timing advance'? */ - /*LOG_I(PHY,"[UE %d] AbsoluteSubFrame %d.%d, received (rar) timing_advance %d, HW timing advance %d\n",ue->Mod_id,proc->frame_rx, proc->subframe_rx, ue->timing_advance);*/ + /* TODO: fix this log, what is 'HW timing advance'? */ + /*LOG_I(PHY,"[UE %d] AbsoluteSubFrame %d.%d, received (rar) timing_advance %d, HW timing advance %d\n",ue->Mod_id,proc->frame_rx, proc->subframe_rx, ue->timing_advance);*/ LOG_UI(PHY,"[UE %d] AbsoluteSubFrame %d.%d, received (rar) timing_advance %d\n",ue->Mod_id,proc->frame_rx, proc->subframe_rx, ue->timing_advance); } - } -void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance) -{ - +void process_timing_advance(module_id_t Mod_id,uint8_t CC_id,int16_t timing_advance) { // uint32_t frame = PHY_vars_UE_g[Mod_id]->frame; - // timing advance has Q1.5 format timing_advance = timing_advance - 31; - PHY_vars_UE_g[Mod_id][CC_id]->timing_advance = PHY_vars_UE_g[Mod_id][CC_id]->timing_advance+timing_advance*4; //this is for 25RB only!!! - - LOG_D(PHY,"[UE %d] Got timing advance %d from MAC, new value %d\n",Mod_id, timing_advance, PHY_vars_UE_g[Mod_id][CC_id]->timing_advance); - - } -uint8_t is_SR_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) -{ - +uint8_t is_SR_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) { int subframe=proc->subframe_tx; - LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d Checking for SR TXOp (sr_ConfigIndex %d)\n", ue->Mod_id,ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->crnti,proc->frame_tx,subframe, ue->scheduling_request_config[eNB_id].sr_ConfigIndex); @@ -415,8 +366,7 @@ uint8_t is_SR_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) return(0); } -uint8_t is_cqi_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) -{ +uint8_t is_cqi_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) { int subframe = proc->subframe_tx; int frame = proc->frame_tx; CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; @@ -433,10 +383,7 @@ uint8_t is_cqi_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) else return(0); } -uint8_t is_ri_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) -{ - - +uint8_t is_ri_TXOp(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id) { int subframe = proc->subframe_tx; int frame = proc->frame_tx; CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; @@ -462,22 +409,17 @@ void compute_cqi_ri_resources(PHY_VARS_UE *ue, uint16_t p_rnti, uint16_t cba_rnti, uint8_t cqi_status, - uint8_t ri_status) -{ - //PHY_MEASUREMENTS *meas = &ue->measurements; - //uint8_t transmission_mode = ue->transmission_mode[eNB_id]; + uint8_t ri_status) { + //PHY_MEASUREMENTS *meas = &ue->measurements; + //uint8_t transmission_mode = ue->transmission_mode[eNB_id]; - - //LOG_I(PHY,"compute_cqi_ri_resources O_RI %d O %d uci format %d \n",ulsch->O_RI,ulsch->O,ulsch->uci_format); - if (cqi_status == 1 || ri_status == 1) - { - ulsch->O = 4; - } + //LOG_I(PHY,"compute_cqi_ri_resources O_RI %d O %d uci format %d \n",ulsch->O_RI,ulsch->O,ulsch->uci_format); + if (cqi_status == 1 || ri_status == 1) { + ulsch->O = 4; + } } -void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t isSubframeSRS) -{ - +void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t isSubframeSRS) { LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int frame_tx = proc->frame_tx; int subframe_tx = proc->subframe_tx; @@ -486,91 +428,81 @@ void ue_compute_srs_occasion(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id uint16_t srsOffset; uint8_t is_pucch2_subframe = 0; uint8_t is_sr_an_subframe = 0; - // check for SRS opportunity pSoundingrs_ul_config_dedicated->srsUeSubframe = 0; pSoundingrs_ul_config_dedicated->srsCellSubframe = isSubframeSRS; if (isSubframeSRS) { LOG_D(PHY," SrsDedicatedSetup: %d \n",pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup); - if(pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup) - { - compute_srs_pos(frame_parms->frame_type, pSoundingrs_ul_config_dedicated->srs_ConfigIndex, &srsPeriodicity, &srsOffset); - - LOG_D(PHY," srsPeriodicity: %d srsOffset: %d isSubframeSRS %d \n",srsPeriodicity,srsOffset,isSubframeSRS); - - // transmit SRS if the four following constraints are respected: - // - UE is configured to transmit SRS - // - SRS are configured in current subframe - // - UE is configured to send SRS in this subframe - - // 36.213 8.2 - // 1- A UE shall not transmit SRS whenever SRS and PUCCH format 2/2a/2b transmissions happen to coincide in the same subframe - // 2- A UE shall not transmit SRS whenever SRS transmit - // on and PUCCH transmission carrying ACK/NACK and/or - // positive SR happen to coincide in the same subframe if the parameter - // Simultaneous-AN-and-SRS is FALSE - - // check PUCCH format 2/2a/2b transmissions - is_pucch2_subframe = is_cqi_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0); - is_pucch2_subframe = (is_ri_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0)) || is_pucch2_subframe; - - // check ACK/SR transmission - if(frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission == FALSE) - { - if(is_SR_TXOp(ue,proc,eNB_id)) - { - uint32_t SR_payload = 0; - if (ue->mac_enabled==1) - { - int Mod_id = ue->Mod_id; - int CC_id = ue->CC_id; - SR_payload = ue_get_SR(Mod_id, - CC_id, - frame_tx, - eNB_id, - ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->crnti, - subframe_tx); // subframe used for meas gap - - if (SR_payload > 0) - is_sr_an_subframe = 1; - } - } - - uint8_t pucch_ack_payload[2]; - if (get_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, - subframe_tx,proc->subframe_rx,pucch_ack_payload,0) > 0) - { - is_sr_an_subframe = 1; - } - } - // check SRS UE opportunity - if( isSubframeSRS && - (((10*frame_tx+subframe_tx) % srsPeriodicity) == srsOffset) - ) - { - if ((is_pucch2_subframe == 0) && (is_sr_an_subframe == 0)) - { - pSoundingrs_ul_config_dedicated->srsUeSubframe = 1; - ue->ulsch[eNB_id]->srs_active = 1; - ue->ulsch[eNB_id]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)- ue->ulsch[eNB_id]->srs_active; - } - else - { - LOG_I(PHY,"DROP UE-SRS-TX for this subframe %d.%d: collision with PUCCH2 or SR/AN: PUCCH2-occasion: %d, SR-AN-occasion[simSRS-SR-AN %d]: %d \n", frame_tx, subframe_tx, is_pucch2_subframe, frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, is_sr_an_subframe); - } + if(pSoundingrs_ul_config_dedicated->srsConfigDedicatedSetup) { + compute_srs_pos(frame_parms->frame_type, pSoundingrs_ul_config_dedicated->srs_ConfigIndex, &srsPeriodicity, &srsOffset); + LOG_D(PHY," srsPeriodicity: %d srsOffset: %d isSubframeSRS %d \n",srsPeriodicity,srsOffset,isSubframeSRS); + // transmit SRS if the four following constraints are respected: + // - UE is configured to transmit SRS + // - SRS are configured in current subframe + // - UE is configured to send SRS in this subframe + // 36.213 8.2 + // 1- A UE shall not transmit SRS whenever SRS and PUCCH format 2/2a/2b transmissions happen to coincide in the same subframe + // 2- A UE shall not transmit SRS whenever SRS transmit + // on and PUCCH transmission carrying ACK/NACK and/or + // positive SR happen to coincide in the same subframe if the parameter + // Simultaneous-AN-and-SRS is FALSE + // check PUCCH format 2/2a/2b transmissions + is_pucch2_subframe = is_cqi_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0); + is_pucch2_subframe = (is_ri_TXOp(ue,proc,eNB_id) && (ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0)) || is_pucch2_subframe; + + // check ACK/SR transmission + if(frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission == FALSE) { + if(is_SR_TXOp(ue,proc,eNB_id)) { + uint32_t SR_payload = 0; + + if (ue->mac_enabled==1) { + int Mod_id = ue->Mod_id; + int CC_id = ue->CC_id; + SR_payload = ue_get_SR(Mod_id, + CC_id, + frame_tx, + eNB_id, + ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->crnti, + subframe_tx); // subframe used for meas gap + + if (SR_payload > 0) + is_sr_an_subframe = 1; } + } + + uint8_t pucch_ack_payload[2]; + + if (get_ack(&ue->frame_parms, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, + subframe_tx,proc->subframe_rx,pucch_ack_payload,0) > 0) { + is_sr_an_subframe = 1; + } + } + + // check SRS UE opportunity + if( isSubframeSRS && + (((10*frame_tx+subframe_tx) % srsPeriodicity) == srsOffset) + ) { + if ((is_pucch2_subframe == 0) && (is_sr_an_subframe == 0)) { + pSoundingrs_ul_config_dedicated->srsUeSubframe = 1; + ue->ulsch[eNB_id]->srs_active = 1; + ue->ulsch[eNB_id]->Nsymb_pusch = 12-(frame_parms->Ncp<<1)- ue->ulsch[eNB_id]->srs_active; + } else { + LOG_I(PHY,"DROP UE-SRS-TX for this subframe %d.%d: collision with PUCCH2 or SR/AN: PUCCH2-occasion: %d, SR-AN-occasion[simSRS-SR-AN %d]: %d \n", frame_tx, subframe_tx, is_pucch2_subframe, + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, is_sr_an_subframe); + } } - LOG_D(PHY," srsCellSubframe: %d, srsUeSubframe: %d, Nsymb-pusch: %d \n", pSoundingrs_ul_config_dedicated->srsCellSubframe, pSoundingrs_ul_config_dedicated->srsUeSubframe, ue->ulsch[eNB_id]->Nsymb_pusch); + } + + LOG_D(PHY," srsCellSubframe: %d, srsUeSubframe: %d, Nsymb-pusch: %d \n", pSoundingrs_ul_config_dedicated->srsCellSubframe, pSoundingrs_ul_config_dedicated->srsUeSubframe, + ue->ulsch[eNB_id]->Nsymb_pusch); } } -void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id) -{ - +void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id) { CQI_REPORTPERIODIC *cqirep = &ue->cqi_report_config[eNB_id].CQI_ReportPeriodic; int cqi_PMI_ConfigIndex = cqirep->cqi_PMI_ConfigIndex; @@ -596,46 +528,41 @@ void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id) } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period cqirep->Npd = 160; cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-157; - } - else if (cqi_PMI_ConfigIndex > 317) { - + } else if (cqi_PMI_ConfigIndex > 317) { if (cqi_PMI_ConfigIndex <= 349) { // 32 ms CQI_PMI period - cqirep->Npd = 32; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-318; - } - else if (cqi_PMI_ConfigIndex <= 413) { // 64 ms CQI_PMI period - cqirep->Npd = 64; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-350; - } - else if (cqi_PMI_ConfigIndex <= 541) { // 128 ms CQI_PMI period - cqirep->Npd = 128; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-414; + cqirep->Npd = 32; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-318; + } else if (cqi_PMI_ConfigIndex <= 413) { // 64 ms CQI_PMI period + cqirep->Npd = 64; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-350; + } else if (cqi_PMI_ConfigIndex <= 541) { // 128 ms CQI_PMI period + cqirep->Npd = 128; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-414; } } - } - else { // TDD - if (cqi_PMI_ConfigIndex == 0) { // all UL subframes - cqirep->Npd = 1; - cqirep->N_OFFSET_CQI = 0; - } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period - cqirep->Npd = 5; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-1; - } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period - cqirep->Npd = 10; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-6; - } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period - cqirep->Npd = 20; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-16; - } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period - cqirep->Npd = 40; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-36; - } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period - cqirep->Npd = 80; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-76; - } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period - cqirep->Npd = 160; - cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-156; - } + } else { // TDD + if (cqi_PMI_ConfigIndex == 0) { // all UL subframes + cqirep->Npd = 1; + cqirep->N_OFFSET_CQI = 0; + } else if (cqi_PMI_ConfigIndex <= 6) { // 5 ms CQI_PMI period + cqirep->Npd = 5; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-1; + } else if (cqi_PMI_ConfigIndex <=16) { // 10ms CQI_PMI period + cqirep->Npd = 10; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-6; + } else if (cqi_PMI_ConfigIndex <= 36) { // 20 ms CQI_PMI period + cqirep->Npd = 20; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-16; + } else if (cqi_PMI_ConfigIndex <= 76) { // 40 ms CQI_PMI period + cqirep->Npd = 40; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-36; + } else if (cqi_PMI_ConfigIndex <= 156) { // 80 ms CQI_PMI period + cqirep->Npd = 80; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-76; + } else if (cqi_PMI_ConfigIndex <= 316) { // 160 ms CQI_PMI period + cqirep->Npd = 160; + cqirep->N_OFFSET_CQI = cqi_PMI_ConfigIndex-156; + } } } @@ -645,76 +572,66 @@ PUCCH_FMT_t get_pucch_format(lte_frame_type_t frame_type, uint8_t nb_cw, uint8_t cqi_status, uint8_t ri_status, - uint8_t bundling_flag) -{ - if((cqi_status == 0) && (ri_status==0)) - { - // PUCCH Format 1 1a 1b - // 1- SR only ==> PUCCH format 1 - // 2- 1bit Ack/Nack with/without SR ==> PUCCH format 1a - // 3- 2bits Ack/Nack with/without SR ==> PUCCH format 1b - if((nb_cw == 1)&&(bundling_flag==bundling)) - { - return pucch_format1a; - } - if((nb_cw == 1)&&(bundling_flag==multiplexing)) - { - return pucch_format1b; - } - if(nb_cw == 2) - { - return pucch_format1b; - } - if(SR_payload == 1) - { + uint8_t bundling_flag) { + if((cqi_status == 0) && (ri_status==0)) { + // PUCCH Format 1 1a 1b + // 1- SR only ==> PUCCH format 1 + // 2- 1bit Ack/Nack with/without SR ==> PUCCH format 1a + // 3- 2bits Ack/Nack with/without SR ==> PUCCH format 1b + if((nb_cw == 1)&&(bundling_flag==bundling)) { + return pucch_format1a; + } + + if((nb_cw == 1)&&(bundling_flag==multiplexing)) { + return pucch_format1b; + } + + if(nb_cw == 2) { + return pucch_format1b; + } + + if(SR_payload == 1) { + return pucch_format1; + /* + if (frame_type == FDD) { return pucch_format1; - /* - if (frame_type == FDD) { - return pucch_format1; - } else if (frame_type == TDD) { - return pucch_format1b; - } else { - AssertFatal(1==0,"Unknown frame_type"); - }*/ - } - } - else - { - // PUCCH Format 2 2a 2b - // 1- CQI only or RI only ==> PUCCH format 2 - // 2- CQI or RI + 1bit Ack/Nack for normal CP ==> PUCCH format 2a - // 3- CQI or RI + 2bits Ack/Nack for normal CP ==> PUCCH format 2b - // 4- CQI or RI + Ack/Nack for extended CP ==> PUCCH format 2 - if(nb_cw == 0) - { - return pucch_format2; - } - if(cyclic_prefix_type == NORMAL) - { - if(nb_cw == 1) - { - return pucch_format2a; - } - if(nb_cw == 2) - { - return pucch_format2b; - } + } else if (frame_type == TDD) { + return pucch_format1b; + } else { + AssertFatal(1==0,"Unknown frame_type"); + }*/ + } + } else { + // PUCCH Format 2 2a 2b + // 1- CQI only or RI only ==> PUCCH format 2 + // 2- CQI or RI + 1bit Ack/Nack for normal CP ==> PUCCH format 2a + // 3- CQI or RI + 2bits Ack/Nack for normal CP ==> PUCCH format 2b + // 4- CQI or RI + Ack/Nack for extended CP ==> PUCCH format 2 + if(nb_cw == 0) { + return pucch_format2; + } + + if(cyclic_prefix_type == NORMAL) { + if(nb_cw == 1) { + return pucch_format2a; } - else - { - return pucch_format2; + + if(nb_cw == 2) { + return pucch_format2b; } + } else { + return pucch_format2; + } } + return pucch_format1a; } uint16_t get_n1_pucch(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, + UE_rxtx_proc_t *proc, harq_status_t *harq_ack, uint8_t eNB_id, uint8_t *b, - uint8_t SR) -{ - + uint8_t SR) { LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; uint8_t nCCE0,nCCE1,nCCE2,nCCE3,harq_ack1,harq_ack0,harq_ack3,harq_ack2; ANFBmode_t bundling_flag; @@ -726,7 +643,6 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, uint8_t ack_counter=0; // clear this, important for case where n1_pucch selection is not used int subframe=proc->subframe_tx; - ue->pucch_sel[subframe] = 0; if (frame_parms->frame_type == FDD ) { // FDD @@ -738,10 +654,9 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, else return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); } else { - bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { if (bundling_flag==bundling) { LOG_D(PHY,"[UE%d] Frame %d subframe %d : get_n1_pucch, bundling, SR %d/%d\n",ue->Mod_id,proc->frame_tx,subframe,SR, ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); @@ -751,179 +666,175 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, } } - switch (frame_parms->tdd_config) { - case 1: // DL:S:UL:UL:DL:DL:S:UL:UL:DL - - harq_ack0 = 2; // DTX - M=1; - - // This is the offset for a particular subframe (2,3,4) => (0,2,4) - if (subframe == 2) { // ACK subframes 5,6 - candidate_dl[0] = 6; - candidate_dl[1] = 5; - M=2; - } else if (subframe == 3) { // ACK subframe 9 - candidate_dl[0] = 9; - } else if (subframe == 7) { // ACK subframes 0,1 - candidate_dl[0] = 1; - candidate_dl[1] = 0; - M=2; - } else if (subframe == 8) { // ACK subframes 4 - candidate_dl[0] = 4; - } else { - LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal tx-subframe %d for tdd_config %d\n", - ue->Mod_id,proc->frame_tx,subframe,frame_parms->tdd_config); - return(0); - } - - // checking which downlink candidate is the last downlink with valid DL-DCI - int k; - for (k=0;k<M;k++) { - if (harq_ack[candidate_dl[k]].send_harq_status>0) { - last_dl = candidate_dl[k]; - break; + case 1: // DL:S:UL:UL:DL:DL:S:UL:UL:DL + harq_ack0 = 2; // DTX + M=1; + + // This is the offset for a particular subframe (2,3,4) => (0,2,4) + if (subframe == 2) { // ACK subframes 5,6 + candidate_dl[0] = 6; + candidate_dl[1] = 5; + M=2; + } else if (subframe == 3) { // ACK subframe 9 + candidate_dl[0] = 9; + } else if (subframe == 7) { // ACK subframes 0,1 + candidate_dl[0] = 1; + candidate_dl[1] = 0; + M=2; + } else if (subframe == 8) { // ACK subframes 4 + candidate_dl[0] = 4; + } else { + LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal tx-subframe %d for tdd_config %d\n", + ue->Mod_id,proc->frame_tx,subframe,frame_parms->tdd_config); + return(0); } - } - if (last_dl >= 10) { - LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal rx-subframe %d (tx-subframe %d) for tdd_config %d\n", - ue->Mod_id,proc->frame_tx,last_dl,subframe,frame_parms->tdd_config); - return (0); - } - LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch0 from last_dl=%d\n", - proc->frame_tx%1024, - proc->subframe_tx, - last_dl); + // checking which downlink candidate is the last downlink with valid DL-DCI + int k; - // i=0 - nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[last_dl]; - n1_pucch0 = get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; + for (k=0; k<M; k++) { + if (harq_ack[candidate_dl[k]].send_harq_status>0) { + last_dl = candidate_dl[k]; + break; + } + } - harq_ack0 = b[0]; + if (last_dl >= 10) { + LOG_E(PHY,"[UE%d] : Frame %d phy_procedures_lte.c: get_n1pucch, illegal rx-subframe %d (tx-subframe %d) for tdd_config %d\n", + ue->Mod_id,proc->frame_tx,last_dl,subframe,frame_parms->tdd_config); + return (0); + } - if (harq_ack0!=2) { // DTX - if (frame_parms->frame_type == FDD ) { - if (SR == 0) { // last paragraph pg 68 from 36.213 (v8.6), m=0 - b[0]=(M==2) ? 1-harq_ack0 : harq_ack0; - b[1]=harq_ack0; // in case we use pucch format 1b (subframes 2,7) - ue->pucch_sel[subframe] = 0; - return(n1_pucch0); - } else { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213) - b[0]=harq_ack0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - } else { - if (SR == 0) { - b[0] = harq_ack0; - b[1] = harq_ack0; - ue->pucch_sel[subframe] = 0; - return(n1_pucch0); + LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch0 from last_dl=%d\n", + proc->frame_tx%1024, + proc->subframe_tx, + last_dl); + // i=0 + nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[last_dl]; + n1_pucch0 = get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; + harq_ack0 = b[0]; + + if (harq_ack0!=2) { // DTX + if (frame_parms->frame_type == FDD ) { + if (SR == 0) { // last paragraph pg 68 from 36.213 (v8.6), m=0 + b[0]=(M==2) ? 1-harq_ack0 : harq_ack0; + b[1]=harq_ack0; // in case we use pucch format 1b (subframes 2,7) + ue->pucch_sel[subframe] = 0; + return(n1_pucch0); + } else { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213) + b[0]=harq_ack0; + return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); + } } else { - b[0] = harq_ack0; - b[1] = harq_ack0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); + if (SR == 0) { + b[0] = harq_ack0; + b[1] = harq_ack0; + ue->pucch_sel[subframe] = 0; + return(n1_pucch0); + } else { + b[0] = harq_ack0; + b[1] = harq_ack0; + return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); + } } } - } - - - break; - - case 3: // DL:S:UL:UL:UL:DL:DL:DL:DL:DL - // in this configuration we have M=2 from pg 68 of 36.213 (v8.6) - // Note: this doesn't allow using subframe 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2) - // set ACK/NAKs to DTX - harq_ack1 = 2; // DTX - harq_ack0 = 2; // DTX - // This is the offset for a particular subframe (2,3,4) => (0,2,4) - last_dl = (subframe-2)<<1; - // i=0 - nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[5+last_dl]; - n1_pucch0 = get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; - // i=1 - nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[(6+last_dl)%10]; - n1_pucch1 = get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN; - - // set ACK/NAK to values if not DTX - if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].send_harq_status>0) // n-6 // subframe 6 is to be ACK/NAKed - harq_ack1 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].ack; - - if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[5+last_dl].send_harq_status>0) // n-6 // subframe 5 is to be ACK/NAKed - harq_ack0 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[5+last_dl].ack; - - LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d cce1=%d n1_pucch1=%d\n", - proc->frame_tx%1024, - proc->subframe_tx, - nCCE0,n1_pucch0, - nCCE1,n1_pucch1); - - if (harq_ack1!=2) { // n-6 // subframe 6,8,0 and maybe 5,7,9 is to be ACK/NAKed - - if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR, - // n1_pucch index takes value of smallest element in set {0,1} - // i.e. 0 if harq_ack0 is not DTX, otherwise 1 - b[0] = harq_ack1; - if (harq_ack0!=2) - b[0]=b[0]&harq_ack0; + break; + + case 3: // DL:S:UL:UL:UL:DL:DL:DL:DL:DL + // in this configuration we have M=2 from pg 68 of 36.213 (v8.6) + // Note: this doesn't allow using subframe 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2) + // set ACK/NAKs to DTX + harq_ack1 = 2; // DTX + harq_ack0 = 2; // DTX + // This is the offset for a particular subframe (2,3,4) => (0,2,4) + last_dl = (subframe-2)<<1; + // i=0 + nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[5+last_dl]; + n1_pucch0 = get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; + // i=1 + nCCE1 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[(6+last_dl)%10]; + n1_pucch1 = get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN; + + // set ACK/NAK to values if not DTX + if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].send_harq_status>0) // n-6 // subframe 6 is to be ACK/NAKed + harq_ack1 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(6+last_dl)%10].ack; + + if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[5+last_dl].send_harq_status>0) // n-6 // subframe 5 is to be ACK/NAKed + harq_ack0 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[5+last_dl].ack; + + LOG_D(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d cce1=%d n1_pucch1=%d\n", + proc->frame_tx%1024, + proc->subframe_tx, + nCCE0,n1_pucch0, + nCCE1,n1_pucch1); + + if (harq_ack1!=2) { // n-6 // subframe 6,8,0 and maybe 5,7,9 is to be ACK/NAKed + if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR, + // n1_pucch index takes value of smallest element in set {0,1} + // i.e. 0 if harq_ack0 is not DTX, otherwise 1 + b[0] = harq_ack1; - ue->pucch_sel[subframe] = 1; - return(n1_pucch1); + if (harq_ack0!=2) + b[0]=b[0]&harq_ack0; - } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 - if (harq_ack0 == 2) - harq_ack0 = 0; + ue->pucch_sel[subframe] = 1; + return(n1_pucch1); + } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 + if (harq_ack0 == 2) + harq_ack0 = 0; - b[1] = harq_ack0; - b[0] = (harq_ack0!=harq_ack1)?0:1; + b[1] = harq_ack0; + b[0] = (harq_ack0!=harq_ack1)?0:1; + + if ((harq_ack0 == 1) && (harq_ack1 == 0)) { + ue->pucch_sel[subframe] = 0; + return(n1_pucch0); + } else { + ue->pucch_sel[subframe] = 1; + return(n1_pucch1); + } + } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213) + // this should be number of ACKs (including + if (harq_ack0 == 2) + harq_ack0 = 0; - if ((harq_ack0 == 1) && (harq_ack1 == 0)) { + b[0]= harq_ack1 | harq_ack0; + b[1]= harq_ack1 ^ harq_ack0; + return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); + } + } else if (harq_ack0!=2) { // n-7 // subframe 5,7,9 only is to be ACK/NAKed + if ((bundling_flag==bundling)&&(SR == 0)) { // last paragraph pg 68 from 36.213 (v8.6), m=0 + b[0]=harq_ack0; ue->pucch_sel[subframe] = 0; return(n1_pucch0); - } else { - ue->pucch_sel[subframe] = 1; - return(n1_pucch1); + } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 with i=1 set to DTX + b[0] = harq_ack0; + b[1] = 1-b[0]; + ue->pucch_sel[subframe] = 0; + return(n1_pucch0); + } else if (SR==1) { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213) + b[0]=harq_ack0; + b[1]=b[0]; + return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); } - } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213) - // this should be number of ACKs (including - if (harq_ack0 == 2) - harq_ack0 = 0; - - b[0]= harq_ack1 | harq_ack0; - b[1]= harq_ack1 ^ harq_ack0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); - } - } else if (harq_ack0!=2) { // n-7 // subframe 5,7,9 only is to be ACK/NAKed - if ((bundling_flag==bundling)&&(SR == 0)) { // last paragraph pg 68 from 36.213 (v8.6), m=0 - b[0]=harq_ack0; - ue->pucch_sel[subframe] = 0; - return(n1_pucch0); - } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 with i=1 set to DTX - b[0] = harq_ack0; - b[1] = 1-b[0]; - ue->pucch_sel[subframe] = 0; - return(n1_pucch0); - } else if (SR==1) { // SR and only 0 or 1 ACKs (first 2 entries in Table 7.3-1 of 36.213) - b[0]=harq_ack0; - b[1]=b[0]; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); } - } - break; + break; + + case 4: // DL:S:UL:UL:DL:DL:DL:DL:DL:DL + // in this configuration we have M=4 from pg 68 of 36.213 (v8.6) + // Note: this doesn't allow using subframe 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2) + // set ACK/NAKs to DTX + harq_ack3 = 2; // DTX + harq_ack2 = 2; // DTX + harq_ack1 = 2; // DTX + harq_ack0 = 2; // DTX - case 4: // DL:S:UL:UL:DL:DL:DL:DL:DL:DL - // in this configuration we have M=4 from pg 68 of 36.213 (v8.6) - // Note: this doesn't allow using subframe 1 for PDSCH transmission!!! (i.e. SF 1 cannot be acked in SF 2) - // set ACK/NAKs to DTX - harq_ack3 = 2; // DTX - harq_ack2 = 2; // DTX - harq_ack1 = 2; // DTX - harq_ack0 = 2; // DTX - // This is the offset for a particular subframe (2,3,4) => (0,2,4) - //last_dl = (subframe-2)<<1; - if (subframe == 2) { + // This is the offset for a particular subframe (2,3,4) => (0,2,4) + //last_dl = (subframe-2)<<1; + if (subframe == 2) { // i=0 //nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[2+subframe]; nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[(8+subframe)%10]; @@ -933,8 +844,8 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, n1_pucch1 = get_Np(frame_parms->N_RB_DL,nCCE1,0) + get_Np(frame_parms->N_RB_DL,nCCE1,1) + nCCE1 + frame_parms->pucch_config_common.n1PUCCH_AN; // i=2 nCCE2 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[(8+subframe)%10]; - n1_pucch2 = 2*get_Np(frame_parms->N_RB_DL,nCCE2,1) + nCCE2+ frame_parms->pucch_config_common.n1PUCCH_AN; + // i=3 //nCCE3 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[(9+subframe)%10]; //n1_pucch3 = get_Np(frame_parms->N_RB_DL,nCCE3,1) + nCCE3 + frame_parms->pucch_config_common.n1PUCCH_AN; @@ -950,15 +861,14 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, harq_ack2 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[3+subframe].ack; //if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(9+subframe)%10].send_harq_status>0) // n-6 // subframe 5 is to be ACK/NAKed - //harq_ack3 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(9+subframe)%10].ack; + //harq_ack3 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(9+subframe)%10].ack; //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d cce1=%d n1_pucch1=%d cce2=%d n1_pucch2=%d\n", // proc->frame_tx%1024, // proc->subframe_tx, // nCCE0,n1_pucch0, // nCCE1,n1_pucch1, nCCE2, n1_pucch2); - }else if (subframe == 3) { + } else if (subframe == 3) { // i=0 - nCCE0 = ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->nCCE[4+subframe]; n1_pucch0 = 3*get_Np(frame_parms->N_RB_DL,nCCE0,0) + nCCE0+ frame_parms->pucch_config_common.n1PUCCH_AN; // i=1 @@ -973,236 +883,238 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, // set ACK/NAK to values if not DTX if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[4+subframe].send_harq_status>0) // n-6 // subframe 6 is to be ACK/NAKed - harq_ack0 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[4+subframe].ack; + harq_ack0 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[4+subframe].ack; if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[5+subframe].send_harq_status>0) // n-6 // subframe 5 is to be ACK/NAKed - harq_ack1 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[5+subframe].ack; + harq_ack1 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[5+subframe].ack; if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(6+subframe)].send_harq_status>0) // n-6 // subframe 6 is to be ACK/NAKed - harq_ack2 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(6+subframe)].ack; + harq_ack2 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(6+subframe)].ack; if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(3+subframe)].send_harq_status>0) // n-6 // subframe 5 is to be ACK/NAKed - harq_ack3 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(3+subframe)].ack; + harq_ack3 = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack[(3+subframe)].ack; + } + + //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d harq_ack0=%d cce1=%d n1_pucch1=%d harq_ack1=%d cce2=%d n1_pucch2=%d harq_ack2=%d cce3=%d n1_pucch3=%d harq_ack3=%d bundling_flag=%d\n", + // proc->frame_tx%1024, + // proc->subframe_tx, + // nCCE0,n1_pucch0,harq_ack0, + // nCCE1,n1_pucch1,harq_ack1, nCCE2, n1_pucch2, harq_ack2, + // nCCE3, n1_pucch3, harq_ack3, bundling_flag); + + if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR, + b[0] = 1; + ack_counter = 0; + + if ((harq_ack3!=2) ) { + b[0] = b[0]&harq_ack3; + n1_pucch_inter = n1_pucch3; + ack_counter ++; } - //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch cce0=%d n1_pucch0=%d harq_ack0=%d cce1=%d n1_pucch1=%d harq_ack1=%d cce2=%d n1_pucch2=%d harq_ack2=%d cce3=%d n1_pucch3=%d harq_ack3=%d bundling_flag=%d\n", - // proc->frame_tx%1024, - // proc->subframe_tx, - // nCCE0,n1_pucch0,harq_ack0, - // nCCE1,n1_pucch1,harq_ack1, nCCE2, n1_pucch2, harq_ack2, - // nCCE3, n1_pucch3, harq_ack3, bundling_flag); + if ((harq_ack0!=2) ) { + b[0] = b[0]&harq_ack0; + n1_pucch_inter = n1_pucch0; + ack_counter ++; + } - if ((bundling_flag==bundling)&&(SR == 0)) { // This is for bundling without SR, - b[0] = 1; - ack_counter = 0; - - if ((harq_ack3!=2) ) { - b[0] = b[0]&harq_ack3; - n1_pucch_inter = n1_pucch3; - ack_counter ++; - } - if ((harq_ack0!=2) ) { - b[0] = b[0]&harq_ack0; - n1_pucch_inter = n1_pucch0; - ack_counter ++; - } - if ((harq_ack1!=2) ) { - b[0] = b[0]&harq_ack1; - n1_pucch_inter = n1_pucch1; - ack_counter ++; - } - if ((harq_ack2!=2) ) { - b[0] = b[0]&harq_ack2; - n1_pucch_inter = n1_pucch2; - ack_counter ++; - } - - if (ack_counter == 0) - b[0] = 0; - - /*if (subframe == 3) { - n1_pucch_inter = n1_pucch2; - } else if (subframe == 2) { - n1_pucch_inter = n1_pucch1; - }*/ - - //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch n1_pucch_inter=%d b[0]=%d b[1]=%d \n", - // proc->frame_tx%1024, - // proc->subframe_tx,n1_pucch_inter, - // b[0],b[1]); - - return(n1_pucch_inter); - - } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 - - if (subframe == 3) { - LOG_I(PHY, "sbuframe=%d \n",subframe); - if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch1); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 0) && (harq_ack3 == 2)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if ((harq_ack0 == 0) && (harq_ack1 == 2) && (harq_ack2 == 2) && (harq_ack3 == 2)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch0); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch3); - } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 0)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch3); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch0); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch0); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch3); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 0) && (harq_ack2 == 2) && (harq_ack3 == 2)) { - b[0] = 0; - b[1] = 0; - return(n1_pucch1); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch2); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch3); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch1); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch3); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { - b[0] = 0; - b[1] = 0; - return(n1_pucch2); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack3 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 0; - b[1] = 0; - return(n1_pucch3); - } - } else if (subframe == 2) { - if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 1; - b[1] = 1; - return(n1_pucch1); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) { - b[0] = 1; - b[1] = 1; - return(n1_pucch0); - } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 0; - b[1] = 1; - return(n1_pucch0); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1)) { - b[0] = 1; - b[1] = 0; - return(n1_pucch2); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[1] = 0; - b[0] = 0; - return(n1_pucch1); - } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) { - b[0] = 0; - b[1] = 0; - return(n1_pucch2); - } else if ((harq_ack0 == 2) && (harq_ack1 == 2) && (harq_ack2 == 0)) { - b[0] = 0; - b[1] = 1; - return(n1_pucch2); - } else if ((harq_ack0 == 2) && (harq_ack1 == 0) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch1); - } else if ((harq_ack0 == 0) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { - b[0] = 1; - b[1] = 0; - return(n1_pucch0); - } - - } - } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213) - // this should be number of ACKs (including - ack_counter = 0; - if (harq_ack0==1) - ack_counter ++; - if (harq_ack1==1) - ack_counter ++; - if (harq_ack2==1) - ack_counter ++; - if (harq_ack3==1) - ack_counter ++; - - switch (ack_counter) { - case 0: - b[0] = 0; - b[1] = 0; - break; - - case 1: - b[0] = 1; - b[1] = 1; - break; - - case 2: - b[0] = 1; - b[1] = 0; - break; - - case 3: - b[0] = 0; - b[1] = 1; - break; - - case 4: - b[0] = 1; - b[1] = 1; - break; + if ((harq_ack1!=2) ) { + b[0] = b[0]&harq_ack1; + n1_pucch_inter = n1_pucch1; + ack_counter ++; + } + + if ((harq_ack2!=2) ) { + b[0] = b[0]&harq_ack2; + n1_pucch_inter = n1_pucch2; + ack_counter ++; + } + + if (ack_counter == 0) + b[0] = 0; + + /*if (subframe == 3) { + n1_pucch_inter = n1_pucch2; + } else if (subframe == 2) { + n1_pucch_inter = n1_pucch1; + }*/ + //LOG_I(PHY,"SFN/SF %d/%d calculating n1_pucch n1_pucch_inter=%d b[0]=%d b[1]=%d \n", + // proc->frame_tx%1024, + // proc->subframe_tx,n1_pucch_inter, + // b[0],b[1]); + return(n1_pucch_inter); + } else if ((bundling_flag==multiplexing)&&(SR==0)) { // Table 10.1 + if (subframe == 3) { + LOG_I(PHY, "sbuframe=%d \n",subframe); + + if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) { + b[0] = 1; + b[1] = 1; + return(n1_pucch1); + } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { + b[0] = 1; + b[1] = 0; + return(n1_pucch1); + } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 0) && (harq_ack3 == 2)) { + b[0] = 1; + b[1] = 1; + return(n1_pucch2); + } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { + b[0] = 1; + b[1] = 0; + return(n1_pucch1); + } else if ((harq_ack0 == 0) && (harq_ack1 == 2) && (harq_ack2 == 2) && (harq_ack3 == 2)) { + b[0] = 1; + b[1] = 0; + return(n1_pucch0); + } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { + b[0] = 1; + b[1] = 0; + return(n1_pucch1); + } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) { + b[0] = 0; + b[1] = 1; + return(n1_pucch3); + } else if (((harq_ack0 == 0) || (harq_ack0 == 2)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 0)) { + b[0] = 1; + b[1] = 1; + return(n1_pucch3); + } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { + b[0] = 0; + b[1] = 1; + return(n1_pucch2); + } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { + b[0] = 0; + b[1] = 1; + return(n1_pucch0); + } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { + b[0] = 0; + b[1] = 1; + return(n1_pucch0); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && (harq_ack3 == 1)) { + b[0] = 0; + b[1] = 1; + return(n1_pucch3); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 0) && (harq_ack2 == 2) && (harq_ack3 == 2)) { + b[0] = 0; + b[1] = 0; + return(n1_pucch1); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { + b[0] = 1; + b[1] = 0; + return(n1_pucch2); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && (harq_ack3 == 1)) { + b[0] = 1; + b[1] = 0; + return(n1_pucch3); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0)) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { + b[0] = 0; + b[1] = 1; + return(n1_pucch1); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && (harq_ack3 == 1)) { + b[0] = 0; + b[1] = 1; + return(n1_pucch3); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1) && ((harq_ack3 == 2) || (harq_ack3 == 0))) { + b[0] = 0; + b[1] = 0; + return(n1_pucch2); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack3 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { + b[0] = 0; + b[1] = 0; + return(n1_pucch3); + } + } else if (subframe == 2) { + if ((harq_ack0 == 1) && (harq_ack1 == 1) && (harq_ack2 == 1)) { + b[0] = 1; + b[1] = 1; + return(n1_pucch2); + } else if ((harq_ack0 == 1) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { + b[0] = 1; + b[1] = 1; + return(n1_pucch1); + } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) { + b[0] = 1; + b[1] = 1; + return(n1_pucch0); + } else if ((harq_ack0 == 1) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { + b[0] = 0; + b[1] = 1; + return(n1_pucch0); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && (harq_ack2 == 1)) { + b[0] = 1; + b[1] = 0; + return(n1_pucch2); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && (harq_ack1 == 1) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { + b[1] = 0; + b[0] = 0; + return(n1_pucch1); + } else if (((harq_ack0 == 2) || (harq_ack0 == 0)) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && (harq_ack2 == 1)) { + b[0] = 0; + b[1] = 0; + return(n1_pucch2); + } else if ((harq_ack0 == 2) && (harq_ack1 == 2) && (harq_ack2 == 0)) { + b[0] = 0; + b[1] = 1; + return(n1_pucch2); + } else if ((harq_ack0 == 2) && (harq_ack1 == 0) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { + b[0] = 1; + b[1] = 0; + return(n1_pucch1); + } else if ((harq_ack0 == 0) && ((harq_ack1 == 2) || (harq_ack1 == 0)) && ((harq_ack2 == 2) || (harq_ack2 == 0))) { + b[0] = 1; + b[1] = 0; + return(n1_pucch0); } + } + } else if (SR==1) { // SR and 0,1,or 2 ACKS, (first 3 entries in Table 7.3-1 of 36.213) + // this should be number of ACKs (including + ack_counter = 0; - ack_counter = 0; - return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); + if (harq_ack0==1) + ack_counter ++; + + if (harq_ack1==1) + ack_counter ++; + + if (harq_ack2==1) + ack_counter ++; + + if (harq_ack3==1) + ack_counter ++; + + switch (ack_counter) { + case 0: + b[0] = 0; + b[1] = 0; + break; + + case 1: + b[0] = 1; + b[1] = 1; + break; + + case 2: + b[0] = 1; + b[1] = 0; + break; + + case 3: + b[0] = 0; + b[1] = 1; + break; + + case 4: + b[0] = 1; + b[1] = 1; + break; } - break; + ack_counter = 0; + return(ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex); + } + break; } // switch tdd_config } @@ -1212,10 +1124,8 @@ uint16_t get_n1_pucch(PHY_VARS_UE *ue, void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empty_subframe) { - int aa; LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - int nsymb; int subframe_tx = proc->subframe_tx; int ulsch_start; @@ -1224,46 +1134,43 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt int k,l; int dummy_tx_buffer[frame_parms->samples_per_tti] __attribute__((aligned(16))); #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_COMMON,VCD_FUNCTION_IN); + if ( LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->ofdm_mod_stats); } - nsymb = (frame_parms->Ncp == 0) ? 14 : 12; + nsymb = (frame_parms->Ncp == 0) ? 14 : 12; #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR)//this is the EXPRESS MIMO case ulsch_start = (ue->rx_offset+subframe_tx*frame_parms->samples_per_tti- - ue->hw_timing_advance- - ue->timing_advance- - ue->N_TA_offset+5); + ue->hw_timing_advance- + ue->timing_advance- + ue->N_TA_offset+5); //LOG_E(PHY,"ul-signal [subframe: %d, ulsch_start %d]\n",subframe_tx, ulsch_start); if(ulsch_start < 0) - ulsch_start = ulsch_start + (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); + ulsch_start = ulsch_start + (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); if (ulsch_start > (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti)) - ulsch_start = ulsch_start % (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); + ulsch_start = ulsch_start % (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti); //LOG_E(PHY,"ul-signal [subframe: %d, ulsch_start %d]\n",subframe_tx, ulsch_start); #else //this is the normal case ulsch_start = (frame_parms->samples_per_tti*subframe_tx)-ue->N_TA_offset; //-ue->timing_advance; #endif //else EXMIMO - if (empty_subframe) - { + if (empty_subframe) { overflow = ulsch_start - 9*frame_parms->samples_per_tti; + for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) { - - if (overflow > 0) - { - memset(&ue->common_vars.txdata[aa][ulsch_start],0,4*(frame_parms->samples_per_tti-overflow)); - memset(&ue->common_vars.txdata[aa][0],0,4*overflow); - } - else - { - memset(&ue->common_vars.txdata[aa][ulsch_start],0,4*frame_parms->samples_per_tti); - } + if (overflow > 0) { + memset(&ue->common_vars.txdata[aa][ulsch_start],0,4*(frame_parms->samples_per_tti-overflow)); + memset(&ue->common_vars.txdata[aa][0],0,4*overflow); + } else { + memset(&ue->common_vars.txdata[aa][ulsch_start],0,4*frame_parms->samples_per_tti); + } } + return; } @@ -1271,32 +1178,31 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt if (frame_parms->Ncp == 1) PHY_ofdm_mod(&ue->common_vars.txdataF[aa][subframe_tx*nsymb*frame_parms->ofdm_symbol_size], #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - dummy_tx_buffer, + dummy_tx_buffer, #else - &ue->common_vars.txdata[aa][ulsch_start], + &ue->common_vars.txdata[aa][ulsch_start], #endif - frame_parms->ofdm_symbol_size, - nsymb, - frame_parms->nb_prefix_samples, - CYCLIC_PREFIX); + frame_parms->ofdm_symbol_size, + nsymb, + frame_parms->nb_prefix_samples, + CYCLIC_PREFIX); else { normal_prefix_mod(&ue->common_vars.txdataF[aa][subframe_tx*nsymb*frame_parms->ofdm_symbol_size], #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - dummy_tx_buffer, + dummy_tx_buffer, #else - &ue->common_vars.txdata[aa][ulsch_start], + &ue->common_vars.txdata[aa][ulsch_start], #endif - nsymb>>1, - &ue->frame_parms); - + nsymb>>1, + &ue->frame_parms); normal_prefix_mod(&ue->common_vars.txdataF[aa][((subframe_tx*nsymb)+(nsymb>>1))*frame_parms->ofdm_symbol_size], #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - dummy_tx_buffer+(frame_parms->samples_per_tti>>1), + dummy_tx_buffer+(frame_parms->samples_per_tti>>1), #else - &ue->common_vars.txdata[aa][ulsch_start+(frame_parms->samples_per_tti>>1)], + &ue->common_vars.txdata[aa][ulsch_start+(frame_parms->samples_per_tti>>1)], #endif - nsymb>>1, - &ue->frame_parms); + nsymb>>1, + &ue->frame_parms); } #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) @@ -1306,31 +1212,31 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt apply_7_5_kHz(ue,&ue->common_vars.txdata[aa][ulsch_start],0); apply_7_5_kHz(ue,&ue->common_vars.txdata[aa][ulsch_start],1); #endif - - #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) overflow = ulsch_start - 9*frame_parms->samples_per_tti; - for (k=ulsch_start,l=0; k<cmin(frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME,ulsch_start+frame_parms->samples_per_tti); k++,l++) { - ((short*)ue->common_vars.txdata[aa])[2*k] = ((short*)dummy_tx_buffer)[2*l]; - ((short*)ue->common_vars.txdata[aa])[2*k+1] = ((short*)dummy_tx_buffer)[2*l+1]; + ((short *)ue->common_vars.txdata[aa])[2*k] = ((short *)dummy_tx_buffer)[2*l]; + ((short *)ue->common_vars.txdata[aa])[2*k+1] = ((short *)dummy_tx_buffer)[2*l+1]; } for (k=0; k<overflow; k++,l++) { - ((short*)ue->common_vars.txdata[aa])[2*k] = ((short*)dummy_tx_buffer)[2*l]; - ((short*)ue->common_vars.txdata[aa])[2*k+1] = ((short*)dummy_tx_buffer)[2*l+1]; + ((short *)ue->common_vars.txdata[aa])[2*k] = ((short *)dummy_tx_buffer)[2*l]; + ((short *)ue->common_vars.txdata[aa])[2*k+1] = ((short *)dummy_tx_buffer)[2*l+1]; } + #if defined(EXMIMO) + // handle switch before 1st TX subframe, guarantee that the slot prior to transmission is switch on for (k=ulsch_start - (frame_parms->samples_per_tti>>1) ; k<ulsch_start ; k++) { if (k<0) - ue->common_vars.txdata[aa][k+frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + ue->common_vars.txdata[aa][k+frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; else if (k>(frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME)) - ue->common_vars.txdata[aa][k-frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; + ue->common_vars.txdata[aa][k-frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME] &= 0xFFFEFFFE; else - ue->common_vars.txdata[aa][k] &= 0xFFFEFFFE; + ue->common_vars.txdata[aa][k] &= 0xFFFEFFFE; } + #endif #endif /* @@ -1342,7 +1248,6 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt LOG_M("txBuff.m","txSignal",&ue->common_vars.txdata[aa][ulsch_start],frame_parms->samples_per_tti,1,1); } */ - } //nb_antennas_tx if ( LOG_DEBUGFLAG(UE_TIMING)) { @@ -1350,133 +1255,119 @@ void ulsch_common_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, uint8_t empt } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_COMMON,VCD_FUNCTION_OUT); - } void ue_prach_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) { - int frame_tx = proc->frame_tx; int subframe_tx = proc->subframe_tx; LOG_USEDINLOG_VAR(int, prach_power); PRACH_RESOURCES_t prach_resources_local; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_IN); - ue->generate_prach=0; - if (ue->mac_enabled==0){ + if (ue->mac_enabled==0) { ue->prach_resources[eNB_id] = &prach_resources_local; prach_resources_local.ra_RNTI = 0xbeef; prach_resources_local.ra_PreambleIndex = 0; } - if (ue->mac_enabled==1){ + if (ue->mac_enabled==1) { // ask L2 for RACH transport if ((mode != rx_calib_ue) && (mode != rx_calib_ue_med) && (mode != rx_calib_ue_byp) && (mode != no_L2_connect) ) { //LOG_D(PHY,"Getting PRACH resources\n"); - ue->prach_resources[eNB_id] = ue_get_rach(ue->Mod_id, - ue->CC_id, - frame_tx, - eNB_id, - subframe_tx); + ue->CC_id, + frame_tx, + eNB_id, + subframe_tx); LOG_D(PHY,"Prach resources %p\n",ue->prach_resources[eNB_id]); } } if (ue->prach_resources[eNB_id]!=NULL) { - ue->generate_prach=1; ue->prach_cnt=0; #ifdef SMBV ue->prach_resources[eNB_id]->ra_PreambleIndex = 19; #endif LOG_I(PHY,"mode %d\n",mode); - + if ((ue->mac_enabled==1) && (mode != calib_prach_tx)) { ue->tx_power_dBm[subframe_tx] = ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_PL(ue->Mod_id,ue->CC_id,eNB_id); - } - else { + } else { ue->tx_power_dBm[subframe_tx] = ue->tx_power_max_dBm; ue->prach_resources[eNB_id]->ra_PreambleIndex = 19; } - + LOG_D(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d : Generating PRACH, preamble %d,PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, PRACH TDD Resource index %d, RA-RNTI %d\n", - ue->Mod_id, - frame_tx, - subframe_tx, - ue->prach_resources[eNB_id]->ra_PreambleIndex, - get_PL(ue->Mod_id,ue->CC_id,eNB_id), - ue->tx_power_dBm[subframe_tx], - ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER, - ue->prach_resources[eNB_id]->ra_TDD_map_index, - ue->prach_resources[eNB_id]->ra_RNTI); - + ue->Mod_id, + frame_tx, + subframe_tx, + ue->prach_resources[eNB_id]->ra_PreambleIndex, + get_PL(ue->Mod_id,ue->CC_id,eNB_id), + ue->tx_power_dBm[subframe_tx], + ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER, + ue->prach_resources[eNB_id]->ra_TDD_map_index, + ue->prach_resources[eNB_id]->ra_RNTI); ue->tx_total_RE[subframe_tx] = 96; - #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) ue->prach_vars[eNB_id]->amp = get_tx_amp(ue->tx_power_dBm[subframe_tx], - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 6); - + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 6); #else ue->prach_vars[eNB_id]->amp = AMP; #endif if ((mode == calib_prach_tx) && (((proc->frame_tx&0xfffe)%100)==0)) LOG_D(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d : PRACH TX power %d dBm, amp %d\n", - ue->Mod_id, - proc->frame_rx, - proc->subframe_tx, - ue->tx_power_dBm[subframe_tx], - ue->prach_vars[eNB_id]->amp); - - + ue->Mod_id, + proc->frame_rx, + proc->subframe_tx, + ue->tx_power_dBm[subframe_tx], + ue->prach_vars[eNB_id]->amp); + // start_meas(&ue->tx_prach); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_IN); prach_power = generate_prach(ue,eNB_id,subframe_tx,frame_tx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GENERATE_PRACH, VCD_FUNCTION_OUT); // stop_meas(&ue->tx_prach); LOG_D(PHY,"[UE %d][RAPROC] PRACH PL %d dB, power %d dBm, digital power %d dB (amp %d)\n", - ue->Mod_id, - get_PL(ue->Mod_id,ue->CC_id,eNB_id), - ue->tx_power_dBm[subframe_tx], - dB_fixed(prach_power), - ue->prach_vars[eNB_id]->amp); + ue->Mod_id, + get_PL(ue->Mod_id,ue->CC_id,eNB_id), + ue->tx_power_dBm[subframe_tx], + dB_fixed(prach_power), + ue->prach_vars[eNB_id]->amp); - if (ue->mac_enabled==1){ + if (ue->mac_enabled==1) { Msg1_transmitted(ue->Mod_id, - ue->CC_id, - frame_tx, - eNB_id); + ue->CC_id, + frame_tx, + eNB_id); } - + LOG_I(PHY,"[UE %d][RAPROC] Frame %d, subframe %d: Generating PRACH (eNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB), l3msg \n", - ue->Mod_id,frame_tx,subframe_tx,eNB_id, - ue->prach_resources[eNB_id]->ra_PreambleIndex, - ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_PL(ue->Mod_id,ue->CC_id,eNB_id), - get_PL(ue->Mod_id,ue->CC_id,eNB_id)); - - - + ue->Mod_id,frame_tx,subframe_tx,eNB_id, + ue->prach_resources[eNB_id]->ra_PreambleIndex, + ue->prach_resources[eNB_id]->ra_PREAMBLE_RECEIVED_TARGET_POWER+get_PL(ue->Mod_id,ue->CC_id,eNB_id), + get_PL(ue->Mod_id,ue->CC_id,eNB_id)); + // if we're calibrating the PRACH kill the pointer to its resources so that the RA protocol doesn't continue if (mode == calib_prach_tx) ue->prach_resources[eNB_id]=NULL; LOG_D(PHY,"[UE %d] frame %d subframe %d : generate_prach %d, prach_cnt %d\n", - ue->Mod_id,frame_tx,subframe_tx,ue->generate_prach,ue->prach_cnt); - + ue->Mod_id,frame_tx,subframe_tx,ue->generate_prach,ue->prach_cnt); ue->prach_cnt++; if (ue->prach_cnt==3) ue->generate_prach=0; } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT); } void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { - int harq_pid; int frame_tx=proc->frame_tx; int subframe_tx=proc->subframe_tx; @@ -1497,76 +1388,76 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB uint8_t cqi_status = 0; uint8_t ri_status = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_IN); - // get harq_pid from subframe relationship harq_pid = subframe2harq_pid(&ue->frame_parms, - frame_tx, - subframe_tx); - + frame_tx, + subframe_tx); LOG_D(PHY,"Frame %d, Subframe %d : ue_uespec_procedures, harq_pid %d => subframe_scheduling %d\n", - frame_tx,subframe_tx,harq_pid, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag); + frame_tx,subframe_tx,harq_pid, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag); if (ue->mac_enabled == 1) { if ((ue->ulsch_Msg3_active[eNB_id] == 1) && - (ue->ulsch_Msg3_frame[eNB_id] == frame_tx) && - (ue->ulsch_Msg3_subframe[eNB_id] == subframe_tx)) { // Initial Transmission of Msg3 - + (ue->ulsch_Msg3_frame[eNB_id] == frame_tx) && + (ue->ulsch_Msg3_subframe[eNB_id] == subframe_tx)) { // Initial Transmission of Msg3 ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) - generate_ue_ulsch_params_from_rar(ue, - proc, - eNB_id); + generate_ue_ulsch_params_from_rar(ue, + proc, + eNB_id); ue->ulsch[eNB_id]->power_offset = 14; LOG_D(PHY,"[UE %d][RAPROC] Frame %d: Setting Msg3_flag in subframe %d, for harq_pid %d\n", - Mod_id, - frame_tx, - subframe_tx, - harq_pid); + Mod_id, + frame_tx, + subframe_tx, + harq_pid); Msg3_flag = 1; } else { - - AssertFatal(harq_pid!=255,"[UE%d] Frame %d subframe %d ulsch_decoding.c: FATAL ERROR: illegal harq_pid, exiting\n", - Mod_id,frame_tx, subframe_tx); + Mod_id,frame_tx, subframe_tx); Msg3_flag=0; } } if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) { - uint8_t isBad = 0; + if (ue->frame_parms.N_RB_UL <= ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb) { LOG_D(PHY,"Invalid PUSCH first_RB=%d for N_RB_UL=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, - ue->frame_parms.N_RB_UL); + ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, + ue->frame_parms.N_RB_UL); isBad = 1; } + if (ue->frame_parms.N_RB_UL < ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb) { LOG_D(PHY,"Invalid PUSCH num_RB=%d for N_RB_UL=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, - ue->frame_parms.N_RB_UL); + ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, + ue->frame_parms.N_RB_UL); isBad = 1; } + if (0 > ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb) { LOG_D(PHY,"Invalid PUSCH first_RB=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb); + ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb); isBad = 1; } + if (0 >= ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb) { LOG_D(PHY,"Invalid PUSCH num_RB=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb); + ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb); isBad = 1; } + if (ue->frame_parms.N_RB_UL < (ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb + ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb)) { LOG_D(PHY,"Invalid PUSCH num_RB=%d + first_RB=%d for N_RB_UL=%d\n", - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, - ue->frame_parms.N_RB_UL); + ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, + ue->frame_parms.N_RB_UL); isBad = 1; } + if ((0 > ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx) || (3 < ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx)) { LOG_D(PHY,"Invalid PUSCH RV index=%d\n", ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx); @@ -1578,273 +1469,254 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; } } - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) { + if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag == 1) { ue->generate_ul_signal[eNB_id] = 1; - // deactivate service request // ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - LOG_D(PHY,"Generating PUSCH (Abssubframe: %d.%d): harq-Id: %d, round: %d, MaxReTrans: %d \n",frame_tx,subframe_tx,harq_pid,ue->ulsch[eNB_id]->harq_processes[harq_pid]->round,ue->ulsch[eNB_id]->Mlimit); - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round >= (ue->ulsch[eNB_id]->Mlimit - 1)) - { + LOG_D(PHY,"Generating PUSCH (Abssubframe: %d.%d): harq-Id: %d, round: %d, MaxReTrans: %d \n",frame_tx,subframe_tx,harq_pid,ue->ulsch[eNB_id]->harq_processes[harq_pid]->round, + ue->ulsch[eNB_id]->Mlimit); + + if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round >= (ue->ulsch[eNB_id]->Mlimit - 1)) { // LOG_D(PHY,"PUSCH MAX Retransmission achieved ==> send last pusch\n"); - ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; - ue->ulsch[eNB_id]->harq_processes[harq_pid]->round = 0; + ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 0; + ue->ulsch[eNB_id]->harq_processes[harq_pid]->round = 0; } ack_status_cw0 = reset_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, - subframe_tx, - proc->subframe_rx, - ue->ulsch[eNB_id]->o_ACK, - &Nbundled, - 0); + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, + subframe_tx, + proc->subframe_rx, + ue->ulsch[eNB_id]->o_ACK, + &Nbundled, + 0); ack_status_cw1 = reset_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][1]->harq_ack, - subframe_tx, - proc->subframe_rx, - ue->ulsch[eNB_id]->o_ACK, - &NbundledCw1, - 1); - + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][1]->harq_ack, + subframe_tx, + proc->subframe_rx, + ue->ulsch[eNB_id]->o_ACK, + &NbundledCw1, + 1); //Nbundled = ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack; //ue->ulsch[eNB_id]->bundling = Nbundled; - first_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb; nb_rb = ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb; - - // check Periodic CQI/RI reporting cqi_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0)&& - (is_cqi_TXOp(ue,proc,eNB_id)==1)); - + (is_cqi_TXOp(ue,proc,eNB_id)==1)); ri_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0) && - (is_ri_TXOp(ue,proc,eNB_id)==1)); - + (is_ri_TXOp(ue,proc,eNB_id)==1)); // compute CQI/RI resources compute_cqi_ri_resources(ue, ue->ulsch[eNB_id], eNB_id, ue->ulsch[eNB_id]->rnti, P_RNTI, CBA_RNTI, cqi_status, ri_status); if (ack_status_cw0 > 0) { - // check if we received a PDSCH at subframe_tx - 4 // ==> send ACK/NACK on PUSCH - if (ue->frame_parms.frame_type == FDD) - { + if (ue->frame_parms.frame_type == FDD) { ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK = ack_status_cw0 + ack_status_cw1; } + if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + if(ue->ulsch[eNB_id]->o_ACK[0]) { + LOG_I(PHY,"PUSCH ACK\n"); + T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), + T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); + } else { + LOG_I(PHY,"PUSCH NACK\n"); + T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), + T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); + } - if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - if(ue->ulsch[eNB_id]->o_ACK[0]) - { - LOG_I(PHY,"PUSCH ACK\n"); - T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); - } - else - { - LOG_I(PHY,"PUSCH NACK\n"); - T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); + LOG_I(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d Generating ACK (%d,%d) for %d bits on PUSCH\n", + Mod_id, + ue->ulsch[eNB_id]->rnti, + frame_tx%1024,subframe_tx, + ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], + ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK); } - LOG_I(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d Generating ACK (%d,%d) for %d bits on PUSCH\n", - Mod_id, - ue->ulsch[eNB_id]->rnti, - frame_tx%1024,subframe_tx, - ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK); } - } - - - if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)){ - LOG_D(PHY, - "[UE %d][PUSCH %d] AbsSubframe %d.%d Generating PUSCH : first_rb %d, nb_rb %d, round %d, mcs %d, rv %d, " - "cyclic_shift %d (cyclic_shift_common %d,n_DMRS2 %d,n_PRS %d), ACK (%d,%d), O_ACK %d, ack_status_cw0 %d ack_status_cw1 %d bundling %d, Nbundled %d, CQI %d, RI %d\n", - Mod_id,harq_pid,frame_tx%1024,subframe_tx, - first_rb,nb_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->round, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx, - (ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift+ - ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2+ - ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe_tx<<1])%12, - ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2, - ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe_tx<<1], - ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], - ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK, - ack_status_cw0, - ack_status_cw1, - ue->ulsch[eNB_id]->bundling, Nbundled, - cqi_status, - ri_status); - } - - - + if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY, + "[UE %d][PUSCH %d] AbsSubframe %d.%d Generating PUSCH : first_rb %d, nb_rb %d, round %d, mcs %d, rv %d, " + "cyclic_shift %d (cyclic_shift_common %d,n_DMRS2 %d,n_PRS %d), ACK (%d,%d), O_ACK %d, ack_status_cw0 %d ack_status_cw1 %d bundling %d, Nbundled %d, CQI %d, RI %d\n", + Mod_id,harq_pid,frame_tx%1024,subframe_tx, + first_rb,nb_rb, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->round, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx, + (ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift+ + ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2+ + ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe_tx<<1])%12, + ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2, + ue->frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe_tx<<1], + ue->ulsch[eNB_id]->o_ACK[0],ue->ulsch[eNB_id]->o_ACK[1], + ue->ulsch[eNB_id]->harq_processes[harq_pid]->O_ACK, + ack_status_cw0, + ack_status_cw1, + ue->ulsch[eNB_id]->bundling, Nbundled, + cqi_status, + ri_status); + } if (Msg3_flag == 1) { LOG_I(PHY,"[UE %d][RAPROC] Frame %d, Subframe %d Generating (RRCConnectionRequest) Msg3 (nb_rb %d, first_rb %d, round %d, rvidx %d) Msg3: %x.%x.%x|%x.%x.%x.%x.%x.%x\n",Mod_id,frame_tx, - subframe_tx, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->round, - ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx, - ue->prach_resources[eNB_id]->Msg3[0], - ue->prach_resources[eNB_id]->Msg3[1], - ue->prach_resources[eNB_id]->Msg3[2], - ue->prach_resources[eNB_id]->Msg3[3], - ue->prach_resources[eNB_id]->Msg3[4], - ue->prach_resources[eNB_id]->Msg3[5], - ue->prach_resources[eNB_id]->Msg3[6], - ue->prach_resources[eNB_id]->Msg3[7], - ue->prach_resources[eNB_id]->Msg3[8]); - if ( LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ulsch_encoding_stats); - } - + subframe_tx, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->round, + ue->ulsch[eNB_id]->harq_processes[harq_pid]->rvidx, + ue->prach_resources[eNB_id]->Msg3[0], + ue->prach_resources[eNB_id]->Msg3[1], + ue->prach_resources[eNB_id]->Msg3[2], + ue->prach_resources[eNB_id]->Msg3[3], + ue->prach_resources[eNB_id]->Msg3[4], + ue->prach_resources[eNB_id]->Msg3[5], + ue->prach_resources[eNB_id]->Msg3[6], + ue->prach_resources[eNB_id]->Msg3[7], + ue->prach_resources[eNB_id]->Msg3[8]); + + if ( LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ulsch_encoding_stats); + } + AssertFatal(ulsch_encoding(ue->prach_resources[eNB_id]->Msg3, - ue, - harq_pid, - eNB_id, - proc->subframe_rx, - ue->transmission_mode[eNB_id],0,0)==0, - "ulsch_coding.c: FATAL ERROR: returning\n"); - - if ( LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->phy_proc_tx); - LOG_I(PHY,"------FULL TX PROC : %5.2f ------\n",ue->phy_proc_tx.p_time/(cpuf*1000.0)); - stop_meas(&ue->ulsch_encoding_stats); - } + ue, + harq_pid, + eNB_id, + proc->subframe_rx, + ue->transmission_mode[eNB_id],0,0)==0, + "ulsch_coding.c: FATAL ERROR: returning\n"); + + if ( LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->phy_proc_tx); + LOG_I(PHY,"------FULL TX PROC : %5.2f ------\n",ue->phy_proc_tx.p_time/(cpuf*1000.0)); + stop_meas(&ue->ulsch_encoding_stats); + } if (ue->mac_enabled == 1) { - - // signal MAC that Msg3 was sent - Msg3_transmitted(Mod_id, - CC_id, - frame_tx, - eNB_id); + // signal MAC that Msg3 was sent + Msg3_transmitted(Mod_id, + CC_id, + frame_tx, + eNB_id); } + LOG_I(PHY,"Done Msg3 encoding\n"); } // Msg3_flag==1 else {// Msg3_flag==0 input_buffer_length = ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS/8; if (ue->mac_enabled==1) { + // LOG_D(PHY,"[UE %d] ULSCH : Searching for MAC SDUs\n",Mod_id); + if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) { + //if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->calibration_flag == 0) { + access_mode=SCHEDULED_ACCESS; + ue_get_sdu(Mod_id, + CC_id, + frame_tx, + subframe_tx, + eNB_id, + ulsch_input_buffer, + input_buffer_length, + &access_mode); + } - // LOG_D(PHY,"[UE %d] ULSCH : Searching for MAC SDUs\n",Mod_id); - if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) { - //if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->calibration_flag == 0) { - access_mode=SCHEDULED_ACCESS; - - ue_get_sdu(Mod_id, - CC_id, - frame_tx, - subframe_tx, - eNB_id, - ulsch_input_buffer, - input_buffer_length, - &access_mode); - } - - - - - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE] Frame %d, subframe %d : ULSCH SDU (TX harq_pid %d) (%d bytes) : \n",frame_tx,subframe_tx,harq_pid, ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3); - - for (i=0; i<ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++) - LOG_T(PHY,"%x.",ulsch_input_buffer[i]); - - LOG_T(PHY,"\n"); + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY,"[UE] Frame %d, subframe %d : ULSCH SDU (TX harq_pid %d) (%d bytes) : \n",frame_tx,subframe_tx,harq_pid, ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3); + + for (i=0; i<ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS>>3; i++) + LOG_T(PHY,"%x.",ulsch_input_buffer[i]); + + LOG_T(PHY,"\n"); + } + } else { + unsigned int taus(void); + + for (i=0; i<input_buffer_length; i++) + ulsch_input_buffer[i]= (uint8_t)(taus()&0xff); } - } else { - unsigned int taus(void); - - for (i=0; i<input_buffer_length; i++) - ulsch_input_buffer[i]= (uint8_t)(taus()&0xff); - - } - - if ( LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ulsch_encoding_stats); - } + + if ( LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ulsch_encoding_stats); + } + if (abstraction_flag==0) { - - if (ulsch_encoding(ulsch_input_buffer, - ue, - harq_pid, - eNB_id, - proc->subframe_rx, - ue->transmission_mode[eNB_id],0, - Nbundled)!=0) { - LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n"); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); + if (ulsch_encoding(ulsch_input_buffer, + ue, + harq_pid, + eNB_id, + proc->subframe_rx, + ue->transmission_mode[eNB_id],0, + Nbundled)!=0) { + LOG_E(PHY,"ulsch_coding.c: FATAL ERROR: returning\n"); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); + if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->phy_proc_tx); + stop_meas(&ue->phy_proc_tx); } - return; - } + + return; + } } - + if(LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->ulsch_encoding_stats); } } - + if (abstraction_flag == 0) { if (ue->mac_enabled==1) { - pusch_power_cntl(ue,proc,eNB_id,1, abstraction_flag); - ue->tx_power_dBm[subframe_tx] = ue->ulsch[eNB_id]->Po_PUSCH; - } - else { - ue->tx_power_dBm[subframe_tx] = ue->tx_power_max_dBm; + pusch_power_cntl(ue,proc,eNB_id,1, abstraction_flag); + ue->tx_power_dBm[subframe_tx] = ue->ulsch[eNB_id]->Po_PUSCH; + } else { + ue->tx_power_dBm[subframe_tx] = ue->tx_power_max_dBm; } + ue->tx_total_RE[subframe_tx] = nb_rb*12; - #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) tx_amp = get_tx_amp(ue->tx_power_dBm[subframe_tx], - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - nb_rb); + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + nb_rb); #else - tx_amp = AMP; + tx_amp = AMP; #endif + T(T_UE_PHY_PUSCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), + T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_PL(Mod_id,0,eNB_id)),T_INT(nb_rb)); + + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", + Mod_id,harq_pid,frame_tx%1024,subframe_tx,ue->tx_power_dBm[subframe_tx],ue->tx_power_max_dBm, tx_amp); + } - T(T_UE_PHY_PUSCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), - T_INT(tx_amp),T_INT(ue->ulsch[eNB_id]->f_pusch),T_INT(get_PL(Mod_id,0,eNB_id)),T_INT(nb_rb)); + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ulsch_modulation_stats); + } - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d][PUSCH %d] AbsSubFrame %d.%d, generating PUSCH, Po_PUSCH: %d dBm (max %d dBm), amp %d\n", - Mod_id,harq_pid,frame_tx%1024,subframe_tx,ue->tx_power_dBm[subframe_tx],ue->tx_power_max_dBm, tx_amp); - } - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ulsch_modulation_stats); - } - ulsch_modulation(ue->common_vars.txdataF, - tx_amp, - frame_tx, - subframe_tx, - &ue->frame_parms, - ue->ulsch[eNB_id]); - for (aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) - generate_drs_pusch(ue, - proc, - eNB_id, - tx_amp, - subframe_tx, - first_rb, - nb_rb, - aa); + ulsch_modulation(ue->common_vars.txdataF, + tx_amp, + frame_tx, + subframe_tx, + &ue->frame_parms, + ue->ulsch[eNB_id]); + + for (aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) + generate_drs_pusch(ue, + proc, + eNB_id, + tx_amp, + subframe_tx, + first_rb, + nb_rb, + aa); - if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->ulsch_modulation_stats); + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->ulsch_modulation_stats); + } } - } - if (abstraction_flag==1) { // clear SR ue->sr[subframe_tx]=0; @@ -1852,84 +1724,72 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB } // subframe_scheduling_flag==1 VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_OUT); - } -void ue_srs_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) -{ - +void ue_srs_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { //LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; //int8_t frame_tx = proc->frame_tx; int8_t subframe_tx = proc->subframe_tx; int16_t tx_amp; int16_t Po_SRS; uint8_t nb_rb_srs; - SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; uint8_t isSrsTxOccasion = pSoundingrs_ul_config_dedicated->srsUeSubframe; - if(isSrsTxOccasion) - { + if(isSrsTxOccasion) { ue->generate_ul_signal[eNB_id] = 1; - if (ue->mac_enabled==1) - { - srs_power_cntl(ue,proc,eNB_id, (uint8_t*)(&nb_rb_srs), abstraction_flag); + + if (ue->mac_enabled==1) { + srs_power_cntl(ue,proc,eNB_id, (uint8_t *)(&nb_rb_srs), abstraction_flag); Po_SRS = ue->ulsch[eNB_id]->Po_SRS; - } - else - { + } else { Po_SRS = ue->tx_power_max_dBm; } #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - if (ue->mac_enabled==1) - { - tx_amp = get_tx_amp(Po_SRS, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - nb_rb_srs); - } - else - { - tx_amp = AMP; + + if (ue->mac_enabled==1) { + tx_amp = get_tx_amp(Po_SRS, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + nb_rb_srs); + } else { + tx_amp = AMP; } + #else - tx_amp = AMP; + tx_amp = AMP; #endif LOG_D(PHY,"SRS PROC; TX_MAX_POWER %d, Po_SRS %d, NB_RB_UL %d, NB_RB_SRS %d TX_AMPL %d\n",ue->tx_power_max_dBm, - Po_SRS, - ue->frame_parms.N_RB_UL, - nb_rb_srs, - tx_amp); - + Po_SRS, + ue->frame_parms.N_RB_UL, + nb_rb_srs, + tx_amp); uint16_t nsymb = (ue->frame_parms.Ncp==0) ? 14:12; uint16_t symbol_offset = (int)ue->frame_parms.ofdm_symbol_size*((subframe_tx*nsymb)+(nsymb-1)); generate_srs(&ue->frame_parms, - &ue->soundingrs_ul_config_dedicated[eNB_id], - &ue->common_vars.txdataF[eNB_id][symbol_offset], - tx_amp, - subframe_tx); + &ue->soundingrs_ul_config_dedicated[eNB_id], + &ue->common_vars.txdataF[eNB_id][symbol_offset], + tx_amp, + subframe_tx); } } int16_t get_pucch2_cqi(PHY_VARS_UE *ue,int eNB_id,int *len) { - if ((ue->transmission_mode[eNB_id]<4)|| (ue->transmission_mode[eNB_id]==7)) { // Mode 1-0 feedback // 4-bit CQI message - /*LOG_I(PHY,"compute CQI value, TM %d, length 4, Cqi Avg %d, value %d \n", ue->transmission_mode[eNB_id], - ue->measurements.wideband_cqi_avg[eNB_id], - sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id], - ue->transmission_mode[eNB_id]));*/ + /*LOG_I(PHY,"compute CQI value, TM %d, length 4, Cqi Avg %d, value %d \n", ue->transmission_mode[eNB_id], + ue->measurements.wideband_cqi_avg[eNB_id], + sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id], + ue->transmission_mode[eNB_id]));*/ *len=4; return(sinr2cqi((double)ue->measurements.wideband_cqi_avg[eNB_id], - ue->transmission_mode[eNB_id])); - } - else { // Mode 1-1 feedback, later - //LOG_I(PHY,"compute CQI value, TM %d, length 0, Cqi Avg 0 \n", ue->transmission_mode[eNB_id]); + ue->transmission_mode[eNB_id])); + } else { // Mode 1-1 feedback, later + //LOG_I(PHY,"compute CQI value, TM %d, length 0, Cqi Avg 0 \n", ue->transmission_mode[eNB_id]); *len=0; // 2-antenna ports RI=1, 6 bits (2 PMI, 4 CQI) - // 2-antenna ports RI=2, 8 bits (1 PMI, 7 CQI/DIFF CQI) return(0); } @@ -1937,7 +1797,6 @@ int16_t get_pucch2_cqi(PHY_VARS_UE *ue,int eNB_id,int *len) { int16_t get_pucch2_ri(PHY_VARS_UE *ue,int eNB_id) { - return(1); } @@ -1951,15 +1810,12 @@ void get_pucch_param(PHY_VARS_UE *ue, uint8_t cqi_report, uint16_t *pucch_resource, uint8_t *pucch_payload, - uint16_t *plength) -{ - - switch (format) { - case pucch_format1: - { - pucch_resource[0] = ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex; - pucch_payload[0] = 0; // payload is ignored in case of format1 - pucch_payload[1] = 0; // payload is ignored in case of format1 + uint16_t *plength) { + switch (format) { + case pucch_format1: { + pucch_resource[0] = ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex; + pucch_payload[0] = 0; // payload is ignored in case of format1 + pucch_payload[1] = 0; // payload is ignored in case of format1 } break; @@ -1967,58 +1823,50 @@ void get_pucch_param(PHY_VARS_UE *ue, case pucch_format1b: case pucch_format1b_csA2: case pucch_format1b_csA3: - case pucch_format1b_csA4: - { - pucch_resource[0] = get_n1_pucch(ue, - proc, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, - eNB_id, - ack_payload, - SR); - pucch_payload[0] = ack_payload[0]; - pucch_payload[1] = ack_payload[1]; - //pucch_payload[1] = 1; + case pucch_format1b_csA4: { + pucch_resource[0] = get_n1_pucch(ue, + proc, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, + eNB_id, + ack_payload, + SR); + pucch_payload[0] = ack_payload[0]; + pucch_payload[1] = ack_payload[1]; + //pucch_payload[1] = 1; } break; - case pucch_format2: - { - pucch_resource[0] = ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex; - if(cqi_report) - { - pucch_payload[0] = get_pucch2_cqi(ue,eNB_id,(int*)plength); - } - else - { - *plength = 1; - pucch_payload[0] = get_pucch2_ri(ue,eNB_id); - } + case pucch_format2: { + pucch_resource[0] = ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PUCCH_ResourceIndex; + + if(cqi_report) { + pucch_payload[0] = get_pucch2_cqi(ue,eNB_id,(int *)plength); + } else { + *plength = 1; + pucch_payload[0] = get_pucch2_ri(ue,eNB_id); + } } break; case pucch_format2a: case pucch_format2b: - LOG_E(PHY,"NO Resource available for PUCCH 2a/2b \n"); - break; + LOG_E(PHY,"NO Resource available for PUCCH 2a/2b \n"); + break; case pucch_format3: fprintf(stderr, "PUCCH format 3 not handled\n"); abort(); - } + } } void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { - - uint8_t pucch_ack_payload[2]; uint16_t pucch_resource; ANFBmode_t bundling_flag; PUCCH_FMT_t format; - uint8_t SR_payload; uint8_t pucch_payload[2]; uint16_t len; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; int frame_tx=proc->frame_tx; int subframe_tx=proc->subframe_tx; @@ -2031,30 +1879,24 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin uint8_t nb_cw=0; uint8_t cqi_status=0; uint8_t ri_status=0; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_IN); - SOUNDINGRS_UL_CONFIG_DEDICATED *pSoundingrs_ul_config_dedicated=&ue->soundingrs_ul_config_dedicated[eNB_id]; - // 36.213 8.2 /*if ackNackSRS_SimultaneousTransmission == TRUE and in the cell specific SRS subframes UE shall transmit ACK/NACK and SR using the shortened PUCCH format. This shortened PUCCH format shall be used in a cell specific SRS subframe even if the UE does not transmit SRS in that subframe */ - int harq_pid = subframe2harq_pid(&ue->frame_parms, frame_tx, subframe_tx); - if(ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag) - { - LOG_D(PHY,"PUSCH is programmed on this subframe [pid %d] AbsSuframe %d.%d ==> Skip PUCCH transmission \n",harq_pid,frame_tx,subframe_tx); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_OUT); - return; + if(ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag) { + LOG_D(PHY,"PUSCH is programmed on this subframe [pid %d] AbsSuframe %d.%d ==> Skip PUCCH transmission \n",harq_pid,frame_tx,subframe_tx); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_OUT); + return; } uint8_t isShortenPucch = (pSoundingrs_ul_config_dedicated->srsCellSubframe && frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission); - bundling_flag = ue->pucch_config_dedicated[eNB_id].tdd_AckNackFeedbackMode; if ((frame_parms->frame_type==FDD) || @@ -2073,52 +1915,45 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin // - ACK/NACK // - CQI // - RI - SR_payload = 0; - if (is_SR_TXOp(ue,proc,eNB_id)==1) - { - if (ue->mac_enabled==1) { - SR_payload = ue_get_SR(Mod_id, - CC_id, - frame_tx, - eNB_id, - ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->crnti, - subframe_tx); // subframe used for meas gap - } - else { - SR_payload = 1; - } + + if (is_SR_TXOp(ue,proc,eNB_id)==1) { + if (ue->mac_enabled==1) { + SR_payload = ue_get_SR(Mod_id, + CC_id, + frame_tx, + eNB_id, + ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->crnti, + subframe_tx); // subframe used for meas gap + } else { + SR_payload = 1; + } } ack_status_cw0 = get_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, - subframe_tx, - proc->subframe_rx, - pucch_ack_payload, - 0); - + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, + subframe_tx, + proc->subframe_rx, + pucch_ack_payload, + 0); ack_status_cw1 = get_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][1]->harq_ack, - subframe_tx, - proc->subframe_rx, - pucch_ack_payload, - 1); - + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][1]->harq_ack, + subframe_tx, + proc->subframe_rx, + pucch_ack_payload, + 1); nb_cw = ( (ack_status_cw0 != 0) ? 1:0) + ( (ack_status_cw1 != 0) ? 1:0); - cqi_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.cqi_PMI_ConfigIndex>0)&& - (is_cqi_TXOp(ue,proc,eNB_id)==1)); - + (is_cqi_TXOp(ue,proc,eNB_id)==1)); ri_status = ((ue->cqi_report_config[eNB_id].CQI_ReportPeriodic.ri_ConfigIndex>0) && - (is_ri_TXOp(ue,proc,eNB_id)==1)); + (is_ri_TXOp(ue,proc,eNB_id)==1)); // Part - II // if nothing to report ==> exit function - if( (nb_cw==0) && (SR_payload==0) && (cqi_status==0) && (ri_status==0) ) - { - LOG_D(PHY,"PUCCH No feedback AbsSubframe %d.%d SR_payload %d nb_cw %d pucch_ack_payload[0] %d pucch_ack_payload[1] %d cqi_status %d Return \n", - frame_tx%1024, subframe_tx, SR_payload, nb_cw, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status); - return; + if( (nb_cw==0) && (SR_payload==0) && (cqi_status==0) && (ri_status==0) ) { + LOG_D(PHY,"PUCCH No feedback AbsSubframe %d.%d SR_payload %d nb_cw %d pucch_ack_payload[0] %d pucch_ack_payload[1] %d cqi_status %d Return \n", + frame_tx%1024, subframe_tx, SR_payload, nb_cw, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status); + return; } // Part - III @@ -2141,184 +1976,169 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin &pucch_resource, (uint8_t *)&pucch_payload, &len); - - LOG_D(PHY,"PUCCH feedback AbsSubframe %d.%d SR %d NbCW %d (%d %d) AckNack %d.%d CQI %d RI %d format %d pucch_resource %d pucch_payload %d %d \n", - frame_tx%1024, subframe_tx, SR_payload, nb_cw, ack_status_cw0, ack_status_cw1, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status, ri_status, format, pucch_resource,pucch_payload[0],pucch_payload[1]); - + frame_tx%1024, subframe_tx, SR_payload, nb_cw, ack_status_cw0, ack_status_cw1, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status, ri_status, format, pucch_resource,pucch_payload[0], + pucch_payload[1]); // Part - IV // Generate PUCCH signal ue->generate_ul_signal[eNB_id] = 1; switch (format) { - case pucch_format1: - case pucch_format1a: - case pucch_format1b: - { - if (ue->mac_enabled == 1) { - Po_PUCCH = pucch_power_cntl(ue,proc,subframe_tx,eNB_id,format); - } - else { - Po_PUCCH = ue->tx_power_max_dBm; - } - ue->tx_power_dBm[subframe_tx] = Po_PUCCH; - ue->tx_total_RE[subframe_tx] = 12; - + case pucch_format1: + case pucch_format1a: + case pucch_format1b: { + if (ue->mac_enabled == 1) { + Po_PUCCH = pucch_power_cntl(ue,proc,subframe_tx,eNB_id,format); + } else { + Po_PUCCH = ue->tx_power_max_dBm; + } + + ue->tx_power_dBm[subframe_tx] = Po_PUCCH; + ue->tx_total_RE[subframe_tx] = 12; #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) - tx_amp = get_tx_amp(Po_PUCCH, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 1); + tx_amp = get_tx_amp(Po_PUCCH, + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 1); #else - tx_amp = AMP; + tx_amp = AMP; #endif + T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), + T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch),T_INT(get_PL(ue->Mod_id,ue->CC_id,eNB_id))); - T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), - T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch),T_INT(get_PL(ue->Mod_id,ue->CC_id,eNB_id))); - - if(format == pucch_format1) - { - LOG_D(PHY,"[UE %d][SR %x] AbsSubframe %d.%d Generating PUCCH 1 (SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, - frame_tx%1024, subframe_tx, - frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, - isShortenPucch, - ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, - Po_PUCCH); - } - else - { - if (SR_payload>0) { - LOG_D(PHY,"[UE %d][SR %x] AbsSubFrame %d.%d Generating PUCCH %s payload %d,%d (with SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d, amp %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, - frame_tx % 1024, subframe_tx, - (format == pucch_format1a? "1a": ( - format == pucch_format1b? "1b" : "??")), - pucch_ack_payload[0],pucch_ack_payload[1], - frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, - isShortenPucch, - pucch_resource, - Po_PUCCH, - tx_amp); - } else { - LOG_D(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d rx_offset_diff: %d, Generating PUCCH %s, an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, - frame_tx%1024, subframe_tx,ue->rx_offset_diff, - (format == pucch_format1a? "1a": ( - format == pucch_format1b? "1b" : "??")), - frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, - isShortenPucch, - pucch_resource,pucch_payload[0],pucch_payload[1],SR_payload, - Po_PUCCH, - tx_amp); - } + if(format == pucch_format1) { + LOG_D(PHY,"[UE %d][SR %x] AbsSubframe %d.%d Generating PUCCH 1 (SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d\n", + Mod_id, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, + frame_tx%1024, subframe_tx, + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, + isShortenPucch, + ue->scheduling_request_config[eNB_id].sr_PUCCH_ResourceIndex, + Po_PUCCH); + } else { + if (SR_payload>0) { + LOG_D(PHY,"[UE %d][SR %x] AbsSubFrame %d.%d Generating PUCCH %s payload %d,%d (with SR for PUSCH), an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, Po_PUCCH %d, amp %d\n", + Mod_id, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, + frame_tx % 1024, subframe_tx, + (format == pucch_format1a? "1a": ( + format == pucch_format1b? "1b" : "??")), + pucch_ack_payload[0],pucch_ack_payload[1], + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, + isShortenPucch, + pucch_resource, + Po_PUCCH, + tx_amp); + } else { + LOG_D(PHY,"[UE %d][PDSCH %x] AbsSubFrame %d.%d rx_offset_diff: %d, Generating PUCCH %s, an_srs_simultanous %d, shorten_pucch %d, n1_pucch %d, b[0]=%d,b[1]=%d (SR_Payload %d), Po_PUCCH %d, amp %d\n", + Mod_id, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, + frame_tx%1024, subframe_tx,ue->rx_offset_diff, + (format == pucch_format1a? "1a": ( + format == pucch_format1b? "1b" : "??")), + frame_parms->soundingrs_ul_config_common.ackNackSRS_SimultaneousTransmission, + isShortenPucch, + pucch_resource,pucch_payload[0],pucch_payload[1],SR_payload, + Po_PUCCH, + tx_amp); + } } - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - if(pucch_payload[0]) - { - T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); - } - else - { - T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), - T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); - } + if(pucch_payload[0]) { + T(T_UE_PHY_DLSCH_UE_ACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), + T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); + } else { + T(T_UE_PHY_DLSCH_UE_NACK, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx), T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti), + T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->current_harq_pid)); + } } generate_pucch1x(ue->common_vars.txdataF, - &ue->frame_parms, - ue->ncs_cell, - format, - &ue->pucch_config_dedicated[eNB_id], - pucch_resource, - isShortenPucch, // shortened format - pucch_payload, - tx_amp, - subframe_tx); - - } - break; - + &ue->frame_parms, + ue->ncs_cell, + format, + &ue->pucch_config_dedicated[eNB_id], + pucch_resource, + isShortenPucch, // shortened format + pucch_payload, + tx_amp, + subframe_tx); + } + break; - case pucch_format2: - { + case pucch_format2: { if (ue->mac_enabled == 1) { - Po_PUCCH = pucch_power_cntl(ue,proc,subframe_tx,eNB_id,format); - } - else { - Po_PUCCH = ue->tx_power_max_dBm; + Po_PUCCH = pucch_power_cntl(ue,proc,subframe_tx,eNB_id,format); + } else { + Po_PUCCH = ue->tx_power_max_dBm; } + ue->tx_power_dBm[subframe_tx] = Po_PUCCH; ue->tx_total_RE[subframe_tx] = 12; - #if defined(EXMIMO) || defined(OAI_USRP) || defined(OAI_BLADERF) || defined(OAI_LMSSDR) tx_amp = get_tx_amp(Po_PUCCH, - ue->tx_power_max_dBm, - ue->frame_parms.N_RB_UL, - 1); + ue->tx_power_max_dBm, + ue->frame_parms.N_RB_UL, + 1); #else tx_amp = AMP; #endif T(T_UE_PHY_PUCCH_TX_POWER, T_INT(eNB_id), T_INT(frame_tx%1024), T_INT(subframe_tx),T_INT(ue->tx_power_dBm[subframe_tx]), - T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch),T_INT(get_PL(ue->Mod_id,ue->CC_id,eNB_id))); + T_INT(tx_amp),T_INT(ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->g_pucch),T_INT(get_PL(ue->Mod_id,ue->CC_id,eNB_id))); + if( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2 (RI or CQI), Po_PUCCH %d, isShortenPucch %d, amp %d\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, - frame_tx%1024, subframe_tx, - Po_PUCCH, - isShortenPucch, - tx_amp); + LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2 (RI or CQI), Po_PUCCH %d, isShortenPucch %d, amp %d\n", + Mod_id, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, + frame_tx%1024, subframe_tx, + Po_PUCCH, + isShortenPucch, + tx_amp); } + generate_pucch2x(ue->common_vars.txdataF, - &ue->frame_parms, - ue->ncs_cell, - format, - &ue->pucch_config_dedicated[eNB_id], - pucch_resource, - pucch_payload, - len, // A - 0, // B2 not needed - tx_amp, - subframe_tx, - ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->crnti); - } - break; + &ue->frame_parms, + ue->ncs_cell, + format, + &ue->pucch_config_dedicated[eNB_id], + pucch_resource, + pucch_payload, + len, // A + 0, // B2 not needed + tx_amp, + subframe_tx, + ue->pdcch_vars[ue->current_thread_id[proc->subframe_rx]][eNB_id]->crnti); + } + break; - case pucch_format2a: + case pucch_format2a: LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2a (RI or CQI) Ack/Nack 1bit \n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, - frame_tx%1024, subframe_tx); + Mod_id, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, + frame_tx%1024, subframe_tx); break; - case pucch_format2b: + + case pucch_format2b: LOG_D(PHY,"[UE %d][RNTI %x] AbsSubFrame %d.%d Generating PUCCH 2b (RI or CQI) Ack/Nack 2bits\n", - Mod_id, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, - frame_tx%1024, subframe_tx); + Mod_id, + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->rnti, + frame_tx%1024, subframe_tx); break; - default: + + default: break; } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PUCCH,VCD_FUNCTION_OUT); - } void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) { - int subframe_tx = proc->subframe_tx; int frame_tx = proc->frame_tx; SLSS_t *slss; SLDCH_t *sldch; SLSCH_t *slsch; - LOG_D(PHY,"****** start Sidelink TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx); // check for SLBCH/SLSS @@ -2329,78 +2149,61 @@ void phy_procedures_UE_SL_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) { // check for SLSCH if ((slsch = ue_get_slsch(ue->Mod_id,ue->CC_id,frame_tx,subframe_tx)) != NULL) generate_slsch(ue,slsch,frame_tx,subframe_tx); - } void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,runmode_t mode) { - - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; //int32_t ulsch_start=0; int subframe_tx = proc->subframe_tx; int frame_tx = proc->frame_tx; unsigned int aa; uint8_t isSubframeSRS; - uint8_t next1_thread_id = ue->current_thread_id[proc->subframe_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[proc->subframe_rx]+1); uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX,VCD_FUNCTION_IN); - LOG_D(PHY,"****** start TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx); - T(T_UE_PHY_UL_TICK, T_INT(ue->Mod_id), T_INT(frame_tx%1024), T_INT(subframe_tx)); - - ue->generate_ul_signal[eNB_id] = 0; + if ( LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->phy_proc_tx); } ue->tx_power_dBm[subframe_tx]=-127; - for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) { memset(&ue->common_vars.txdataF[aa][subframe_tx*frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti], - 0, - frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*sizeof(int32_t)); + 0, + frame_parms->ofdm_symbol_size*frame_parms->symbols_per_tti*sizeof(int32_t)); } - + if (subframe_select(&ue->frame_parms,proc->subframe_tx) == SF_UL || - ue->frame_parms.frame_type == FDD) { + ue->frame_parms.frame_type == FDD) { if (ue->UE_mode[eNB_id] != PRACH ) { // check cell srs subframe and ue srs subframe. This has an impact on pusch encoding isSubframeSRS = is_srs_occasion_common(&ue->frame_parms,proc->frame_tx,proc->subframe_tx); - ue_compute_srs_occasion(ue,proc,eNB_id,isSubframeSRS); - ue_ulsch_uespec_procedures(ue,proc,eNB_id,abstraction_flag); - LOG_D(PHY,"ULPOWERS After ulsch_uespec_procedures : ue->tx_power_dBm[%d]=%d, NPRB %d\n", - subframe_tx,ue->tx_power_dBm[subframe_tx],ue->tx_total_RE[subframe_tx]); + subframe_tx,ue->tx_power_dBm[subframe_tx],ue->tx_total_RE[subframe_tx]); } - + if (ue->UE_mode[eNB_id] == PUSCH) { // check if we need to use PUCCH 1a/1b ue_pucch_procedures(ue,proc,eNB_id,abstraction_flag); // check if we need to use SRS ue_srs_procedures(ue,proc,eNB_id,abstraction_flag); } // UE_mode==PUSCH - } - LOG_D(PHY,"doing ulsch_common_procedures (%d.%d): generate_ul_signal %d\n",frame_tx,subframe_tx, - ue->generate_ul_signal[eNB_id]); + ue->generate_ul_signal[eNB_id]); ulsch_common_procedures(ue,proc, (ue->generate_ul_signal[eNB_id] == 0)); - - if ((ue->UE_mode[eNB_id] == PRACH) && - (ue->frame_parms.prach_config_common.prach_Config_enabled==1)) { + if ((ue->UE_mode[eNB_id] == PRACH) && + (ue->frame_parms.prach_config_common.prach_Config_enabled==1)) { // check if we have PRACH opportunity - if (is_prach_subframe(&ue->frame_parms,frame_tx,subframe_tx)) { - ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode); } } // mode is PRACH @@ -2410,131 +2213,113 @@ void phy_procedures_UE_TX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,ui // reset DL ACK/NACK status uint8_t N_bundled = 0; - if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0] != NULL) - { + + if (ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0] != NULL) { reset_ack(&ue->frame_parms, - ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, - subframe_tx, - proc->subframe_rx, - ue->ulsch[eNB_id]->o_ACK, - &N_bundled, - 0); + ue->dlsch[ue->current_thread_id[proc->subframe_rx]][eNB_id][0]->harq_ack, + subframe_tx, + proc->subframe_rx, + ue->ulsch[eNB_id]->o_ACK, + &N_bundled, + 0); reset_ack(&ue->frame_parms, - ue->dlsch[next1_thread_id][eNB_id][0]->harq_ack, - subframe_tx, - proc->subframe_rx, - ue->ulsch[eNB_id]->o_ACK, - &N_bundled, - 0); + ue->dlsch[next1_thread_id][eNB_id][0]->harq_ack, + subframe_tx, + proc->subframe_rx, + ue->ulsch[eNB_id]->o_ACK, + &N_bundled, + 0); reset_ack(&ue->frame_parms, - ue->dlsch[next2_thread_id][eNB_id][0]->harq_ack, - subframe_tx, - proc->subframe_rx, - ue->ulsch[eNB_id]->o_ACK, - &N_bundled, - 0); + ue->dlsch[next2_thread_id][eNB_id][0]->harq_ack, + subframe_tx, + proc->subframe_rx, + ue->ulsch[eNB_id]->o_ACK, + &N_bundled, + 0); } if (ue->dlsch_SI[eNB_id] != NULL) reset_ack(&ue->frame_parms, - ue->dlsch_SI[eNB_id]->harq_ack, - subframe_tx, - proc->subframe_rx, - ue->ulsch[eNB_id]->o_ACK, - &N_bundled, - 0); - + ue->dlsch_SI[eNB_id]->harq_ack, + subframe_tx, + proc->subframe_rx, + ue->ulsch[eNB_id]->o_ACK, + &N_bundled, + 0); LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", frame_tx, subframe_tx); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); + if ( LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->phy_proc_tx); } } -void phy_procedures_UE_S_TX(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag) -{ +void phy_procedures_UE_S_TX(PHY_VARS_UE *ue,uint8_t eNB_id,uint8_t abstraction_flag) { int aa;//i,aa; LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - for (aa=0; aa<frame_parms->nb_antennas_tx; aa++) { #if defined(EXMIMO) //this is the EXPRESS MIMO case int i; + // set the whole tx buffer to RX for (i=0; i<LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti; i++) ue->common_vars.txdata[aa][i] = 0x00010001; - + #else //this is the normal case // memset(&ue->common_vars.txdata[aa][0],0, - // (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti)*sizeof(int32_t)); + // (LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti)*sizeof(int32_t)); #endif //else EXMIMO - } - } void ue_measurement_procedures( - uint16_t l, // symbol index of each slot [0..6] - PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uint8_t eNB_id, - uint16_t slot, // slot index of each radio frame [0..19] - uint8_t abstraction_flag,runmode_t mode) -{ - + uint16_t l, // symbol index of each slot [0..6] + PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uint8_t eNB_id, + uint16_t slot, // slot index of each radio frame [0..19] + uint8_t abstraction_flag,runmode_t mode) { //LOG_I(PHY,"ue_measurement_procedures l %d Ncp %d\n",l,ue->frame_parms.Ncp); - LTE_DL_FRAME_PARMS *frame_parms=&ue->frame_parms; - int subframe_rx = proc->subframe_rx; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_IN); if (l==0) { // UE measurements on symbol 0 - LOG_D(PHY,"Calling measurements subframe %d, rxdata %p\n",subframe_rx,ue->common_vars.rxdata); - LOG_D(PHY,"Calling measurements subframe %d, rxdata %p\n",subframe_rx,ue->common_vars.rxdata); - - lte_ue_measurements(ue, - (subframe_rx*frame_parms->samples_per_tti+ue->rx_offset)%(frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME), - (subframe_rx == 1) ? 1 : 0, - 0, - 0, - subframe_rx); - - - if(slot == 0) - T(T_UE_PHY_MEAS, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx), - T_INT((int)(10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB)), - T_INT((int)ue->measurements.rx_rssi_dBm[0]), - T_INT((int)(ue->measurements.rx_power_avg_dB[0] - ue->measurements.n0_power_avg_dB)), - T_INT((int)ue->measurements.rx_power_avg_dB[0]), - T_INT((int)ue->measurements.n0_power_avg_dB), - T_INT((int)ue->measurements.wideband_cqi_avg[0]), - T_INT((int)ue->common_vars.freq_offset)); + LOG_D(PHY,"Calling measurements subframe %d, rxdata %p\n",subframe_rx,ue->common_vars.rxdata); + lte_ue_measurements(ue, + (subframe_rx*frame_parms->samples_per_tti+ue->rx_offset)%(frame_parms->samples_per_tti*LTE_NUMBER_OF_SUBFRAMES_PER_FRAME), + (subframe_rx == 1) ? 1 : 0, + 0, + 0, + subframe_rx); + + if(slot == 0) + T(T_UE_PHY_MEAS, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx), + T_INT((int)(10*log10(ue->measurements.rsrp[0])-ue->rx_total_gain_dB)), + T_INT((int)ue->measurements.rx_rssi_dBm[0]), + T_INT((int)(ue->measurements.rx_power_avg_dB[0] - ue->measurements.n0_power_avg_dB)), + T_INT((int)ue->measurements.rx_power_avg_dB[0]), + T_INT((int)ue->measurements.n0_power_avg_dB), + T_INT((int)ue->measurements.wideband_cqi_avg[0]), + T_INT((int)ue->common_vars.freq_offset)); } if (( (slot%2) == 0) && (l==(6-ue->frame_parms.Ncp))) { - // make sure we have signal from PSS/SSS for N0 measurement - // LOG_I(PHY," l==(6-ue->frame_parms.Ncp) ue_rrc_measurements\n"); - + // LOG_I(PHY," l==(6-ue->frame_parms.Ncp) ue_rrc_measurements\n"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_RRC_MEASUREMENTS, VCD_FUNCTION_IN); ue_rrc_measurements(ue, - slot, - abstraction_flag); + slot, + abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_RRC_MEASUREMENTS, VCD_FUNCTION_OUT); - } // accumulate and filter timing offset estimation every subframe (instead of every frame) if (( (slot%2) == 0) && (l==(4-frame_parms->Ncp))) { - // AGC - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL, VCD_FUNCTION_IN); - #ifndef OAI_USRP #ifndef OAI_BLADERF #ifndef OAI_LMSSDR @@ -2542,20 +2327,16 @@ void ue_measurement_procedures( #endif #endif #endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL, VCD_FUNCTION_OUT); - eNB_id = 0; - if (ue->no_timing_correction==0) lte_adjust_synch(&ue->frame_parms, - ue, - eNB_id, - subframe_rx, - 0, - 16384); - + ue, + eNB_id, + subframe_rx, + 0, + 16384); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT); @@ -2563,23 +2344,17 @@ void ue_measurement_procedures( -void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uint8_t abstraction_flag) -{ - +void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uint8_t abstraction_flag) { // int i; int pbch_tx_ant=0; uint8_t pbch_phase; uint16_t frame_tx; static uint8_t first_run = 1; uint8_t pbch_trials = 0; - DevAssert(ue); - int frame_rx = proc->frame_rx; int subframe_rx = proc->subframe_rx; - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_IN); - pbch_phase=(frame_rx%4); if (pbch_phase>=4) @@ -2588,15 +2363,14 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin for (pbch_trials=0; pbch_trials<4; pbch_trials++) { //for (pbch_phase=0;pbch_phase<4;pbch_phase++) { //LOG_I(PHY,"[UE %d] Frame %d, Trying PBCH %d (NidCell %d, eNB_id %d)\n",ue->Mod_id,frame_rx,pbch_phase,ue->frame_parms.Nid_cell,eNB_id); - pbch_tx_ant = rx_pbch(&ue->common_vars, - ue->pbch_vars[eNB_id], - &ue->frame_parms, - eNB_id, - ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI, - ue->high_speed_flag, - pbch_phase); - + ue->pbch_vars[eNB_id], + &ue->frame_parms, + eNB_id, + ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI, + ue->high_speed_flag, + pbch_phase); + if ((pbch_tx_ant>0) && (pbch_tx_ant<=4)) { break; } @@ -2607,19 +2381,16 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin pbch_phase=0; } - - if ((pbch_tx_ant>0) && (pbch_tx_ant<=4)) { - if (opt_enabled) { static uint8_t dummy[3]; dummy[0] = ue->pbch_vars[eNB_id]->decoded_output[2]; dummy[1] = ue->pbch_vars[eNB_id]->decoded_output[1]; dummy[2] = ue->pbch_vars[eNB_id]->decoded_output[0]; trace_pdu( DIRECTION_DOWNLINK, dummy, WS_C_RNTI, ue->Mod_id, 0, 0, - frame_rx, subframe_rx, 0, 0); + frame_rx, subframe_rx, 0, 0); LOG_D(OPT,"[UE %d][PBCH] Frame %d trace pdu for PBCH\n", - ue->Mod_id, subframe_rx); + ue->Mod_id, subframe_rx); } if (pbch_tx_ant>2) { @@ -2628,16 +2399,14 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin return; } - ue->pbch_vars[eNB_id]->pdu_errors_conseq = 0; frame_tx = (((int)(ue->pbch_vars[eNB_id]->decoded_output[2]&0x03))<<8); frame_tx += ((int)(ue->pbch_vars[eNB_id]->decoded_output[1]&0xfc)); frame_tx += pbch_phase; if (ue->mac_enabled==1) { - dl_phy_sync_success(ue->Mod_id,frame_rx,eNB_id, - ue->UE_mode[eNB_id]==NOT_SYNCHED ? 1 : 0); + ue->UE_mode[eNB_id]==NOT_SYNCHED ? 1 : 0); } // if this is the first PBCH after initial synchronization, make L1 state = PRACH @@ -2645,78 +2414,62 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin if (first_run) { first_run = 0; - proc->frame_rx = (proc->frame_rx & 0xFFFFFC00) | (frame_tx & 0x000003FF); proc->frame_tx = proc->frame_rx; - for(int th_id=0; th_id<RX_NB_TH; th_id++) - { + for(int th_id=0; th_id<RX_NB_TH; th_id++) { ue->proc.proc_rxtx[th_id].frame_rx = proc->frame_rx; ue->proc.proc_rxtx[th_id].frame_tx = proc->frame_tx; - printf("[UE %d] frame %d, subframe %d: Adjusting frame counter (PBCH ant_tx=%d, frame_tx=%d, phase %d, rx_offset %d) => new frame %d\n", - ue->Mod_id, - ue->proc.proc_rxtx[th_id].frame_rx, - subframe_rx, - pbch_tx_ant, - frame_tx, - pbch_phase, - ue->rx_offset, - proc->frame_rx); + ue->Mod_id, + ue->proc.proc_rxtx[th_id].frame_rx, + subframe_rx, + pbch_tx_ant, + frame_tx, + pbch_phase, + ue->rx_offset, + proc->frame_rx); } - frame_rx = proc->frame_rx; - } else if (((frame_tx & 0x03FF) != (proc->frame_rx & 0x03FF))) { //(pbch_tx_ant != ue->frame_parms.nb_antennas_tx)) { LOG_D(PHY,"[UE %d] frame %d, subframe %d: Re-adjusting frame counter (PBCH ant_tx=%d, frame_rx=%d, frame%%1024=%d, phase %d).\n", - ue->Mod_id, - proc->frame_rx, - subframe_rx, - pbch_tx_ant, - frame_tx, - frame_rx & 0x03FF, - pbch_phase); - - + ue->Mod_id, + proc->frame_rx, + subframe_rx, + pbch_tx_ant, + frame_tx, + frame_rx & 0x03FF, + pbch_phase); proc->frame_rx = (proc->frame_rx & 0xFFFFFC00) | (frame_tx & 0x000003FF); proc->frame_tx = proc->frame_rx; frame_rx = proc->frame_rx; - - for(int th_id=0; th_id<RX_NB_TH; th_id++) - { + + for(int th_id=0; th_id<RX_NB_TH; th_id++) { ue->proc.proc_rxtx[th_id].frame_rx = (proc->frame_rx & 0xFFFFFC00) | (frame_tx & 0x000003FF); ue->proc.proc_rxtx[th_id].frame_tx = proc->frame_rx; } - } if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_UI(PHY,"[UE %d] frame %d, subframe %d, Received PBCH (MIB): nb_antenna_ports_eNB %d, tx_ant %d, frame_tx %d. N_RB_DL %d, phich_duration %d, phich_resource %d/6!\n", - ue->Mod_id, - frame_rx, - subframe_rx, - ue->frame_parms.nb_antenna_ports_eNB, - pbch_tx_ant, - frame_tx, - ue->frame_parms.N_RB_DL, - ue->frame_parms.phich_config_common.phich_duration, - ue->frame_parms.phich_config_common.phich_resource); + ue->Mod_id, + frame_rx, + subframe_rx, + ue->frame_parms.nb_antenna_ports_eNB, + pbch_tx_ant, + frame_tx, + ue->frame_parms.N_RB_DL, + ue->frame_parms.phich_config_common.phich_duration, + ue->frame_parms.phich_config_common.phich_resource); } - - } else { - + } else { if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)) { LOG_E(PHY,"[UE %d] frame %d, subframe %d, Error decoding PBCH!\n", - ue->Mod_id,frame_rx, subframe_rx); - + ue->Mod_id,frame_rx, subframe_rx); LOG_I(PHY,"[UE %d] rx_offset %d\n",ue->Mod_id,ue->rx_offset); - - LOG_M("rxsig0.m","rxs0", ue->common_vars.rxdata[0],ue->frame_parms.samples_per_tti,1,1); - LOG_M("PBCH_rxF0_ext.m","pbch0_ext",ue->pbch_vars[0]->rxdataF_ext[0],12*4*6,1,1); LOG_M("PBCH_rxF0_comp.m","pbch0_comp",ue->pbch_vars[0]->rxdataF_comp[0],12*4*6,1,1); LOG_M("PBCH_rxF_llr.m","pbch_llr",ue->pbch_vars[0]->llr,(ue->frame_parms.Ncp==0) ? 1920 : 1728,1,4); @@ -2728,9 +2481,8 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin if (ue->mac_enabled == 1) rrc_out_of_sync_ind(ue->Mod_id,frame_rx,eNB_id); else AssertFatal(ue->pbch_vars[eNB_id]->pdu_errors_conseq<100, - "More that 100 consecutive PBCH errors! Exiting!\n"); + "More that 100 consecutive PBCH errors! Exiting!\n"); } - if (frame_rx % 100 == 0) { ue->pbch_vars[eNB_id]->pdu_fer = ue->pbch_vars[eNB_id]->pdu_errors - ue->pbch_vars[eNB_id]->pdu_errors_last; @@ -2739,277 +2491,242 @@ void ue_pbch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc, uin if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_UI(PHY,"[UE %d] frame %d, slot %d, PBCH errors = %d, consecutive errors = %d!\n", - ue->Mod_id,frame_rx, subframe_rx, - ue->pbch_vars[eNB_id]->pdu_errors, - ue->pbch_vars[eNB_id]->pdu_errors_conseq); + ue->Mod_id,frame_rx, subframe_rx, + ue->pbch_vars[eNB_id]->pdu_errors, + ue->pbch_vars[eNB_id]->pdu_errors_conseq); } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_OUT); } -int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t abstraction_flag) -{ - +int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t abstraction_flag) { unsigned int dci_cnt=0, i; - int frame_rx = proc->frame_rx; int subframe_rx = proc->subframe_rx; DCI_ALLOC_t dci_alloc_rx[8]; - uint8_t next1_thread_id = ue->current_thread_id[subframe_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[subframe_rx]+1); uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); - LOG_D(PHY,"DCI Decoding procedure in %d.%d\n",frame_rx,subframe_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_IN); + if (LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->dlsch_rx_pdcch_stats); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_IN); rx_pdcch(ue, - proc->frame_rx, - subframe_rx, - eNB_id, - ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI, - ue->high_speed_flag); - + proc->frame_rx, + subframe_rx, + eNB_id, + ue->frame_parms.nb_antenna_ports_eNB==1?SISO:ALAMOUTI, + ue->high_speed_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PDCCH, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_IN); - - + /*printf("Decode SIB frame param aggregation + DCI %d %d, num_pdcch_symbols %d\n", - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dciFormat, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dciFormat, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); */ //agregation level == FF means no configuration on - if(ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel == 0xFF || ue->decode_SIB) - { - // search all possible dcis - dci_cnt = dci_decoding_procedure(ue, - dci_alloc_rx, - (ue->UE_mode[eNB_id] < PUSCH)? 1 : 0, // if we're in PUSCH don't listen to common search space, - // later when we need paging or RA during connection, update this ... - eNB_id,subframe_rx); - } - else - { - // search only preconfigured dcis - // search C RNTI dci - dci_cnt = dci_CRNTI_decoding_procedure(ue, - dci_alloc_rx, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dciFormat, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel, - eNB_id, - subframe_rx); - } - + if(ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel == 0xFF || ue->decode_SIB) { + // search all possible dcis + dci_cnt = dci_decoding_procedure(ue, + dci_alloc_rx, + (ue->UE_mode[eNB_id] < PUSCH)? 1 : 0, // if we're in PUSCH don't listen to common search space, + // later when we need paging or RA during connection, update this ... + eNB_id,subframe_rx); + } else { + // search only preconfigured dcis + // search C RNTI dci + dci_cnt = dci_CRNTI_decoding_procedure(ue, + dci_alloc_rx, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dciFormat, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->agregationLevel, + eNB_id, + subframe_rx); + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DCI_DECODING, VCD_FUNCTION_OUT); //LOG_D(PHY,"[UE %d][PUSCH] Frame %d subframe %d PHICH RX\n",ue->Mod_id,frame_rx,subframe_rx); - + if (is_phich_subframe(&ue->frame_parms,subframe_rx)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PHICH, VCD_FUNCTION_IN); rx_phich(ue,proc, - subframe_rx,eNB_id); + subframe_rx,eNB_id); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_PHICH, VCD_FUNCTION_OUT); } - + uint8_t *nCCE_current = &ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->nCCE[subframe_rx]; uint8_t *nCCE_dest = &ue->pdcch_vars[next1_thread_id][eNB_id]->nCCE[subframe_rx]; uint8_t *nCCE_dest1 = &ue->pdcch_vars[next2_thread_id][eNB_id]->nCCE[subframe_rx]; memcpy(nCCE_dest, nCCE_current, sizeof(uint8_t)); memcpy(nCCE_dest1, nCCE_current, sizeof(uint8_t)); - LOG_D(PHY,"current_thread %d next1_thread %d next2_thread %d \n", ue->current_thread_id[subframe_rx], next1_thread_id, next2_thread_id); - LOG_D(PHY,"[UE %d] AbsSubFrame %d.%d, Mode %s: DCI found %i --> rnti %x / crnti %x : format %d\n", - ue->Mod_id,frame_rx%1024,subframe_rx,mode_string[ue->UE_mode[eNB_id]], - dci_cnt, - dci_alloc_rx[0].rnti, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, - dci_alloc_rx[0].format ); - + ue->Mod_id,frame_rx%1024,subframe_rx,mode_string[ue->UE_mode[eNB_id]], + dci_cnt, + dci_alloc_rx[0].rnti, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, + dci_alloc_rx[0].format ); ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->dci_received += dci_cnt; for (i=0; i<dci_cnt; i++) { - - - if ((ue->UE_mode[eNB_id]>PRACH) && - (dci_alloc_rx[i].rnti == ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti) && - (dci_alloc_rx[i].format != format0)) { - + (dci_alloc_rx[i].rnti == ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti) && + (dci_alloc_rx[i].format != format0)) { LOG_D(PHY,"[UE %d][DCI][PDSCH %x] AbsSubframe %d.%d: format %d, num_pdcch_symbols %d, nCCE %d, total CCEs %d\n", - ue->Mod_id,dci_alloc_rx[i].rnti, - frame_rx%1024,subframe_rx, - dci_alloc_rx[i].format, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->nCCE[subframe_rx], - get_nCCE(3,&ue->frame_parms,get_mi(&ue->frame_parms,0))); - + ue->Mod_id,dci_alloc_rx[i].rnti, + frame_rx%1024,subframe_rx, + dci_alloc_rx[i].format, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->nCCE[subframe_rx], + get_nCCE(3,&ue->frame_parms,get_mi(&ue->frame_parms,0))); + //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - + if ((ue->UE_mode[eNB_id] > PRACH) && - (generate_ue_dlsch_params_from_dci(frame_rx, - subframe_rx, - (void *)&dci_alloc_rx[i].dci_pdu, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, - dci_alloc_rx[i].format, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], - ue->pdsch_vars[ue->current_thread_id[subframe_rx]][eNB_id], - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id], - &ue->frame_parms, - ue->pdsch_config_dedicated, - SI_RNTI, - 0, - P_RNTI, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], - ue->pdcch_vars[0%RX_NB_TH][eNB_id]->crnti_is_temporary? ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti: 0)==0)) { - - // update TPC for PUCCH - if((dci_alloc_rx[i].format == format1) || - (dci_alloc_rx[i].format == format1A) || - (dci_alloc_rx[i].format == format1B) || - (dci_alloc_rx[i].format == format2) || - (dci_alloc_rx[i].format == format2A) || - (dci_alloc_rx[i].format == format2B)) - { - //ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->g_pucch += ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid]->delta_PUCCH; - int32_t delta_pucch = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid]->delta_PUCCH; - for(int th_id=0; th_id<RX_NB_TH; th_id++) - { - ue->dlsch[th_id][eNB_id][0]->g_pucch += delta_pucch; - } - LOG_D(PHY,"update TPC for PUCCH %d.%d / pid %d delta_PUCCH %d g_pucch %d %d \n",frame_rx, subframe_rx,ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid, - delta_pucch, - ue->dlsch[0][eNB_id][0]->g_pucch, - ue->dlsch[1][eNB_id][0]->g_pucch - //ue->dlsch[2][eNB_id][0]->g_pucch - ); + (generate_ue_dlsch_params_from_dci(frame_rx, + subframe_rx, + (void *)&dci_alloc_rx[i].dci_pdu, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, + dci_alloc_rx[i].format, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], + ue->pdsch_vars[ue->current_thread_id[subframe_rx]][eNB_id], + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id], + &ue->frame_parms, + ue->pdsch_config_dedicated, + SI_RNTI, + 0, + P_RNTI, + ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], + ue->pdcch_vars[0%RX_NB_TH][eNB_id]->crnti_is_temporary? ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti: 0)==0)) { + // update TPC for PUCCH + if((dci_alloc_rx[i].format == format1) || + (dci_alloc_rx[i].format == format1A) || + (dci_alloc_rx[i].format == format1B) || + (dci_alloc_rx[i].format == format2) || + (dci_alloc_rx[i].format == format2A) || + (dci_alloc_rx[i].format == format2B)) { + //ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->g_pucch += ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid]->delta_PUCCH; + int32_t delta_pucch = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid]->delta_PUCCH; + + for(int th_id=0; th_id<RX_NB_TH; th_id++) { + ue->dlsch[th_id][eNB_id][0]->g_pucch += delta_pucch; } - - ue->dlsch_received[eNB_id]++; - - if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d] Generated UE DLSCH C_RNTI format %d\n",ue->Mod_id,dci_alloc_rx[i].format); - dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - LOG_D(PHY,"[UE %d] *********** dlsch->active in subframe %d=> %d\n",ue->Mod_id,subframe_rx,ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active); + + LOG_D(PHY,"update TPC for PUCCH %d.%d / pid %d delta_PUCCH %d g_pucch %d %d \n",frame_rx, subframe_rx,ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid, + delta_pucch, + ue->dlsch[0][eNB_id][0]->g_pucch, + ue->dlsch[1][eNB_id][0]->g_pucch + //ue->dlsch[2][eNB_id][0]->g_pucch + ); } - - // we received a CRNTI, so we're in PUSCH - if (ue->UE_mode[eNB_id] != PUSCH) { - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d] Frame %d, subframe %d: Received DCI with CRNTI %x => Mode PUSCH\n",ue->Mod_id,frame_rx,subframe_rx,ue->pdcch_vars[subframe_rx&1][eNB_id]->crnti); - } - - //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - ue->UE_mode[eNB_id] = PUSCH; - } - } else { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Problem in DCI!\n",ue->Mod_id,frame_rx,subframe_rx); - dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - } - } - - else if ((dci_alloc_rx[i].rnti == SI_RNTI) && - ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { + ue->dlsch_received[eNB_id]++; - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); + if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY,"[UE %d] Generated UE DLSCH C_RNTI format %d\n",ue->Mod_id,dci_alloc_rx[i].format); + dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); + LOG_D(PHY,"[UE %d] *********** dlsch->active in subframe %d=> %d\n",ue->Mod_id,subframe_rx,ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active); } - - if (generate_ue_dlsch_params_from_dci(frame_rx, - subframe_rx, - (void *)&dci_alloc_rx[i].dci_pdu, - SI_RNTI, - dci_alloc_rx[i].format, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], - ue->pdsch_vars_SI[eNB_id], - &ue->dlsch_SI[eNB_id], - &ue->frame_parms, - ue->pdsch_config_dedicated, - SI_RNTI, - 0, - P_RNTI, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], - 0)==0) { - - ue->dlsch_SI_received[eNB_id]++; - - LOG_D(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); - //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - - } - } - else if ((dci_alloc_rx[i].rnti == P_RNTI) && - ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { + // we received a CRNTI, so we're in PUSCH + if (ue->UE_mode[eNB_id] != PUSCH) { + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY,"[UE %d] Frame %d, subframe %d: Received DCI with CRNTI %x => Mode PUSCH\n",ue->Mod_id,frame_rx,subframe_rx,ue->pdcch_vars[subframe_rx&1][eNB_id]->crnti); + } + //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); + ue->UE_mode[eNB_id] = PUSCH; + } + } else { + LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Problem in DCI!\n",ue->Mod_id,frame_rx,subframe_rx); + dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); + } + } else if ((dci_alloc_rx[i].rnti == SI_RNTI) && + ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); } - if (generate_ue_dlsch_params_from_dci(frame_rx, - subframe_rx, - (void *)&dci_alloc_rx[i].dci_pdu, - P_RNTI, - dci_alloc_rx[i].format, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], - ue->pdsch_vars_p[eNB_id], - &ue->dlsch_SI[eNB_id], - &ue->frame_parms, - ue->pdsch_config_dedicated, - SI_RNTI, - 0, - P_RNTI, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], + subframe_rx, + (void *)&dci_alloc_rx[i].dci_pdu, + SI_RNTI, + dci_alloc_rx[i].format, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], + ue->pdsch_vars_SI[eNB_id], + &ue->dlsch_SI[eNB_id], + &ue->frame_parms, + ue->pdsch_config_dedicated, + SI_RNTI, + 0, + P_RNTI, + ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], 0)==0) { - - ue->dlsch_p_received[eNB_id]++; - LOG_D(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH P_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); - //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - + ue->dlsch_SI_received[eNB_id]++; + LOG_D(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH SI_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); + //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); + } + } else if ((dci_alloc_rx[i].rnti == P_RNTI) && + ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY,"[UE %d] subframe %d: Found rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); } - } - - else if ((ue->prach_resources[eNB_id]) && - (dci_alloc_rx[i].rnti == ue->prach_resources[eNB_id]->ra_RNTI) && - ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { + if (generate_ue_dlsch_params_from_dci(frame_rx, + subframe_rx, + (void *)&dci_alloc_rx[i].dci_pdu, + P_RNTI, + dci_alloc_rx[i].format, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], + ue->pdsch_vars_p[eNB_id], + &ue->dlsch_SI[eNB_id], + &ue->frame_parms, + ue->pdsch_config_dedicated, + SI_RNTI, + 0, + P_RNTI, + ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], + 0)==0) { + ue->dlsch_p_received[eNB_id]++; + LOG_D(PHY,"[UE %d] Frame %d, subframe %d : Generate UE DLSCH P_RNTI format 1%s\n",ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].format==format1A?"A":"C"); + //dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); + } + } else if ((ue->prach_resources[eNB_id]) && + (dci_alloc_rx[i].rnti == ue->prach_resources[eNB_id]->ra_RNTI) && + ((dci_alloc_rx[i].format == format1A) || (dci_alloc_rx[i].format == format1C))) { if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_D(PHY,"[UE %d][RAPROC] subframe %d: Found RA rnti %x, format 1%s, dci_cnt %d\n",ue->Mod_id,subframe_rx,dci_alloc_rx[i].rnti,dci_alloc_rx[i].format==format1A?"A":"C",i); } - if (generate_ue_dlsch_params_from_dci(frame_rx, - subframe_rx, - (void *)&dci_alloc_rx[i].dci_pdu, - ue->prach_resources[eNB_id]->ra_RNTI, - dci_alloc_rx[i].format, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], - ue->pdsch_vars_ra[eNB_id], - &ue->dlsch_ra[eNB_id], - &ue->frame_parms, - ue->pdsch_config_dedicated, - SI_RNTI, - ue->prach_resources[eNB_id]->ra_RNTI, - P_RNTI, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], + subframe_rx, + (void *)&dci_alloc_rx[i].dci_pdu, + ue->prach_resources[eNB_id]->ra_RNTI, + dci_alloc_rx[i].format, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id], + ue->pdsch_vars_ra[eNB_id], + &ue->dlsch_ra[eNB_id], + &ue->frame_parms, + ue->pdsch_config_dedicated, + SI_RNTI, + ue->prach_resources[eNB_id]->ra_RNTI, + P_RNTI, + ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id], 0)==0) { - - ue->dlsch_ra_received[eNB_id]++; + ue->dlsch_ra_received[eNB_id]++; - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d] Generate UE DLSCH RA_RNTI format 1A, rb_alloc %x, dlsch_ra[eNB_id] %p\n", - ue->Mod_id,ue->dlsch_ra[eNB_id]->harq_processes[0]->rb_alloc_even[0],ue->dlsch_ra[eNB_id]); - } + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY,"[UE %d] Generate UE DLSCH RA_RNTI format 1A, rb_alloc %x, dlsch_ra[eNB_id] %p\n", + ue->Mod_id,ue->dlsch_ra[eNB_id]->harq_processes[0]->rb_alloc_even[0],ue->dlsch_ra[eNB_id]); + } } } else if( (dci_alloc_rx[i].rnti == ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti) && - (dci_alloc_rx[i].format == format0)) { - + (dci_alloc_rx[i].format == format0)) { if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_D(PHY,"[UE %d][PUSCH] Frame %d subframe %d: Found rnti %x, format 0, dci_cnt %d\n", ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].rnti,i); @@ -3017,48 +2734,46 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint ue->ulsch_no_allocation_counter[eNB_id] = 0; //dump_dci(&ue->frame_parms,&dci_alloc_rx[i]); - + if ((ue->UE_mode[eNB_id] > PRACH) && - (generate_ue_ulsch_params_from_dci((void *)&dci_alloc_rx[i].dci_pdu, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, - subframe_rx, - format0, - ue, - proc, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - eNB_id, - 0)==0)) { - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - - LOG_USEDINLOG_VAR(int8_t,harq_pid) = subframe2harq_pid(&ue->frame_parms, - pdcch_alloc2ul_frame(&ue->frame_parms,proc->frame_rx,proc->subframe_rx), - pdcch_alloc2ul_subframe(&ue->frame_parms,proc->subframe_rx)); - T(T_UE_PHY_ULSCH_UE_DCI, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx), - T_INT(dci_alloc_rx[i].rnti), - T_INT(harq_pid), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->round), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb), - T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS)); - - LOG_D(PHY,"[UE %d] Generate UE ULSCH C_RNTI format 0 (subframe %d)\n",ue->Mod_id,subframe_rx); - } + (generate_ue_ulsch_params_from_dci((void *)&dci_alloc_rx[i].dci_pdu, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, + subframe_rx, + format0, + ue, + proc, + SI_RNTI, + 0, + P_RNTI, + CBA_RNTI, + eNB_id, + 0)==0)) { + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_USEDINLOG_VAR(int8_t,harq_pid) = subframe2harq_pid(&ue->frame_parms, + pdcch_alloc2ul_frame(&ue->frame_parms,proc->frame_rx,proc->subframe_rx), + pdcch_alloc2ul_subframe(&ue->frame_parms,proc->subframe_rx)); + T(T_UE_PHY_ULSCH_UE_DCI, T_INT(eNB_id), T_INT(proc->frame_rx%1024), T_INT(proc->subframe_rx), + T_INT(dci_alloc_rx[i].rnti), + T_INT(harq_pid), + T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->mcs), + T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->round), + T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->first_rb), + T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->nb_rb), + T_INT(ue->ulsch[eNB_id]->harq_processes[harq_pid]->TBS)); + LOG_D(PHY,"[UE %d] Generate UE ULSCH C_RNTI format 0 (subframe %d)\n",ue->Mod_id,subframe_rx); + } } } else if( (dci_alloc_rx[i].rnti == ue->ulsch[eNB_id]->cba_rnti[0]) && - (dci_alloc_rx[i].format == format0)) { + (dci_alloc_rx[i].format == format0)) { // UE could belong to more than one CBA group // ue->Mod_id%ue->ulsch[eNB_id]->num_active_cba_groups] if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_D(PHY,"[UE %d][PUSCH] Frame %d subframe %d: Found cba rnti %x, format 0, dci_cnt %d\n", - ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].rnti,i); - /* - if (((frame_rx%100) == 0) || (frame_rx < 20)) - dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); - */ + ue->Mod_id,frame_rx,subframe_rx,dci_alloc_rx[i].rnti,i); + /* + if (((frame_rx%100) == 0) || (frame_rx < 20)) + dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); + */ } ue->ulsch_no_allocation_counter[eNB_id] = 0; @@ -3066,47 +2781,44 @@ int ue_pdcch_procedures(uint8_t eNB_id,PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint if ((ue->UE_mode[eNB_id] > PRACH) && (generate_ue_ulsch_params_from_dci((void *)&dci_alloc_rx[i].dci_pdu, - ue->ulsch[eNB_id]->cba_rnti[0], - subframe_rx, - format0, - ue, - proc, - SI_RNTI, - 0, - P_RNTI, - CBA_RNTI, - eNB_id, - 0)==0)) { - + ue->ulsch[eNB_id]->cba_rnti[0], + subframe_rx, + format0, + ue, + proc, + SI_RNTI, + 0, + P_RNTI, + CBA_RNTI, + eNB_id, + 0)==0)) { if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_D(PHY,"[UE %d] Generate UE ULSCH CBA_RNTI format 0 (subframe %d)\n",ue->Mod_id,subframe_rx); } + ue->ulsch[eNB_id]->num_cba_dci[(subframe_rx+4)%10]++; } - } - - else { + } else { if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_D(PHY,"[UE %d] frame %d, subframe %d: received DCI %d with RNTI=%x (C-RNTI:%x, CBA_RNTI %x) and format %d!\n",ue->Mod_id,frame_rx,subframe_rx,i,dci_alloc_rx[i].rnti, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, - ue->ulsch[eNB_id]->cba_rnti[0], - dci_alloc_rx[i].format); - - // dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, + ue->ulsch[eNB_id]->cba_rnti[0], + dci_alloc_rx[i].format); + // dump_dci(&ue->frame_parms, &dci_alloc_rx[i]); } } - } + if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->dlsch_rx_pdcch_stats); + stop_meas(&ue->dlsch_rx_pdcch_stats); } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PDCCH_PROCEDURES, VCD_FUNCTION_OUT); return(0); } void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abstraction_flag) { - int subframe_rx = proc->subframe_rx; int frame_rx = proc->frame_rx; int pmch_mcs=-1; @@ -3120,19 +2832,16 @@ void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abs if (is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms)) { // LOG_D(PHY,"ue calling pmch subframe ..\n "); - LOG_D(PHY,"[UE %d] Frame %d, subframe %d: Querying for PMCH demodulation\n", - ue->Mod_id,frame_rx,subframe_rx); + ue->Mod_id,frame_rx,subframe_rx); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - pmch_mcs = ue_query_mch(ue->Mod_id, - CC_id, - frame_rx, - subframe_rx, - eNB_id, - &sync_area, - &mcch_active); - + CC_id, + frame_rx, + subframe_rx, + eNB_id, + &sync_area, + &mcch_active); #else pmch_mcs=-1; #endif @@ -3142,107 +2851,100 @@ void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abs fill_UE_dlsch_MCH(ue,pmch_mcs,1,0,0); for (l=2; l<12; l++) { - slot_fep_mbsfn(ue, - l, - subframe_rx, - 0,0);//ue->rx_offset,0); + slot_fep_mbsfn(ue, + l, + subframe_rx, + 0,0);//ue->rx_offset,0); } - + for (l=2; l<12; l++) { - rx_pmch(ue, - 0, - subframe_rx, - l); + rx_pmch(ue, + 0, + subframe_rx, + l); } - - - ue->dlsch_MCH[0]->harq_processes[0]->Qm = get_Qm(pmch_mcs); + ue->dlsch_MCH[0]->harq_processes[0]->Qm = get_Qm(pmch_mcs); ue->dlsch_MCH[0]->harq_processes[0]->G = get_G(&ue->frame_parms, - ue->dlsch_MCH[0]->harq_processes[0]->nb_rb, - ue->dlsch_MCH[0]->harq_processes[0]->rb_alloc_even, - ue->dlsch_MCH[0]->harq_processes[0]->Qm, - 1, - 2, - frame_rx, - subframe_rx, - 0); - + ue->dlsch_MCH[0]->harq_processes[0]->nb_rb, + ue->dlsch_MCH[0]->harq_processes[0]->rb_alloc_even, + ue->dlsch_MCH[0]->harq_processes[0]->Qm, + 1, + 2, + frame_rx, + subframe_rx, + 0); dlsch_unscrambling(&ue->frame_parms,1,ue->dlsch_MCH[0], - ue->dlsch_MCH[0]->harq_processes[0]->G, - ue->pdsch_vars_MCH[0]->llr[0],0,subframe_rx<<1); - + ue->dlsch_MCH[0]->harq_processes[0]->G, + ue->pdsch_vars_MCH[0]->llr[0],0,subframe_rx<<1); LOG_D(PHY,"start turbo decode for MCH %d.%d --> nb_rb %d \n", frame_rx, subframe_rx, ue->dlsch_MCH[0]->harq_processes[0]->nb_rb); LOG_D(PHY,"start turbo decode for MCH %d.%d --> rb_alloc_even %x \n", frame_rx, subframe_rx, (unsigned int)((intptr_t)ue->dlsch_MCH[0]->harq_processes[0]->rb_alloc_even)); LOG_D(PHY,"start turbo decode for MCH %d.%d --> Qm %d \n", frame_rx, subframe_rx, ue->dlsch_MCH[0]->harq_processes[0]->Qm); LOG_D(PHY,"start turbo decode for MCH %d.%d --> Nl %d \n", frame_rx, subframe_rx, ue->dlsch_MCH[0]->harq_processes[0]->Nl); LOG_D(PHY,"start turbo decode for MCH %d.%d --> G %d \n", frame_rx, subframe_rx, ue->dlsch_MCH[0]->harq_processes[0]->G); LOG_D(PHY,"start turbo decode for MCH %d.%d --> Kmimo %d \n", frame_rx, subframe_rx, ue->dlsch_MCH[0]->Kmimo); - ret = dlsch_decoding(ue, - ue->pdsch_vars_MCH[0]->llr[0], - &ue->frame_parms, - ue->dlsch_MCH[0], - ue->dlsch_MCH[0]->harq_processes[0], - frame_rx, - subframe_rx, - 0, - 0,1); + ue->pdsch_vars_MCH[0]->llr[0], + &ue->frame_parms, + ue->dlsch_MCH[0], + ue->dlsch_MCH[0]->harq_processes[0], + frame_rx, + subframe_rx, + 0, + 0,1); + if (mcch_active == 1) - ue->dlsch_mcch_trials[sync_area][0]++; + ue->dlsch_mcch_trials[sync_area][0]++; else - ue->dlsch_mtch_trials[sync_area][0]++; - + ue->dlsch_mtch_trials[sync_area][0]++; + if (ret == (1+ue->dlsch_MCH[0]->max_turbo_iterations)) { - if (mcch_active == 1) - ue->dlsch_mcch_errors[sync_area][0]++; - else - ue->dlsch_mtch_errors[sync_area][0]++; - - LOG_D(PHY,"[UE %d] Frame %d, subframe %d: PMCH in error (%d,%d), not passing to L2 (TBS %d, iter %d,G %d)\n", - ue->Mod_id, + if (mcch_active == 1) + ue->dlsch_mcch_errors[sync_area][0]++; + else + ue->dlsch_mtch_errors[sync_area][0]++; + + LOG_D(PHY,"[UE %d] Frame %d, subframe %d: PMCH in error (%d,%d), not passing to L2 (TBS %d, iter %d,G %d)\n", + ue->Mod_id, frame_rx,subframe_rx, - ue->dlsch_mcch_errors[sync_area][0], - ue->dlsch_mtch_errors[sync_area][0], - ue->dlsch_MCH[0]->harq_processes[0]->TBS>>3, - ue->dlsch_MCH[0]->max_turbo_iterations, - ue->dlsch_MCH[0]->harq_processes[0]->G); - // dump_mch(ue,0,ue->dlsch_MCH[0]->harq_processes[0]->G,subframe_rx); + ue->dlsch_mcch_errors[sync_area][0], + ue->dlsch_mtch_errors[sync_area][0], + ue->dlsch_MCH[0]->harq_processes[0]->TBS>>3, + ue->dlsch_MCH[0]->max_turbo_iterations, + ue->dlsch_MCH[0]->harq_processes[0]->G); + // dump_mch(ue,0,ue->dlsch_MCH[0]->harq_processes[0]->G,subframe_rx); if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - for (int i=0; i<ue->dlsch_MCH[0]->harq_processes[0]->TBS>>3; i++) { - LOG_T(PHY,"%02x.",ue->dlsch_MCH[0]->harq_processes[0]->c[0][i]); - } - - LOG_T(PHY,"\n"); + LOG_T(PHY,"%02x.",ue->dlsch_MCH[0]->harq_processes[0]->c[0][i]); + } + + LOG_T(PHY,"\n"); } - - - // if (subframe_rx==9) - // mac_xface->macphy_exit("Why are we exiting here?"); + + // if (subframe_rx==9) + // mac_xface->macphy_exit("Why are we exiting here?"); } else { // decoding successful #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - - ue_send_mch_sdu(ue->Mod_id, - CC_id, - frame_rx, - ue->dlsch_MCH[0]->harq_processes[0]->b, - ue->dlsch_MCH[0]->harq_processes[0]->TBS>>3, - eNB_id,// not relevant in eMBMS context - sync_area); - - if (mcch_active == 1) - ue->dlsch_mcch_received[sync_area][0]++; - else - ue->dlsch_mtch_received[sync_area][0]++; - - if (ue->dlsch_mch_received_sf[subframe_rx%5][0] == 1 ) { - ue->dlsch_mch_received_sf[subframe_rx%5][0]=0; - } else { - ue->dlsch_mch_received[0]+=1; - ue->dlsch_mch_received_sf[subframe_rx][0]=1; - } + ue_send_mch_sdu(ue->Mod_id, + CC_id, + frame_rx, + ue->dlsch_MCH[0]->harq_processes[0]->b, + ue->dlsch_MCH[0]->harq_processes[0]->TBS>>3, + eNB_id,// not relevant in eMBMS context + sync_area); + + if (mcch_active == 1) + ue->dlsch_mcch_received[sync_area][0]++; + else + ue->dlsch_mtch_received[sync_area][0]++; + + if (ue->dlsch_mch_received_sf[subframe_rx%5][0] == 1 ) { + ue->dlsch_mch_received_sf[subframe_rx%5][0]=0; + } else { + ue->dlsch_mch_received[0]+=1; + ue->dlsch_mch_received_sf[subframe_rx][0]=1; + } #endif // #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) } // decoding sucessful @@ -3250,50 +2952,47 @@ void ue_pmch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc,int eNB_id,int abs } // is_pmch_subframe=true } -void copy_harq_proc_struct(LTE_DL_UE_HARQ_t *harq_processes_dest, LTE_DL_UE_HARQ_t *current_harq_processes) -{ - harq_processes_dest->B = current_harq_processes->B ; - harq_processes_dest->C = current_harq_processes->C ; - harq_processes_dest->Cminus = current_harq_processes->Cminus ; - harq_processes_dest->Cplus = current_harq_processes->Cplus ; - harq_processes_dest->DCINdi = current_harq_processes->DCINdi ; - harq_processes_dest->F = current_harq_processes->F ; - harq_processes_dest->G = current_harq_processes->G ; - harq_processes_dest->Kminus = current_harq_processes->Kminus ; - harq_processes_dest->Kplus = current_harq_processes->Kplus ; - harq_processes_dest->Nl = current_harq_processes->Nl ; - harq_processes_dest->Qm = current_harq_processes->Qm ; - harq_processes_dest->TBS = current_harq_processes->TBS ; - harq_processes_dest->b = current_harq_processes->b ; - harq_processes_dest->codeword = current_harq_processes->codeword ; - harq_processes_dest->delta_PUCCH = current_harq_processes->delta_PUCCH ; - harq_processes_dest->dl_power_off = current_harq_processes->dl_power_off ; - harq_processes_dest->first_tx = current_harq_processes->first_tx ; - harq_processes_dest->mcs = current_harq_processes->mcs ; - harq_processes_dest->mimo_mode = current_harq_processes->mimo_mode ; - harq_processes_dest->nb_rb = current_harq_processes->nb_rb ; - harq_processes_dest->pmi_alloc = current_harq_processes->pmi_alloc ; - harq_processes_dest->rb_alloc_even[0] = current_harq_processes->rb_alloc_even[0] ; - harq_processes_dest->rb_alloc_even[1] = current_harq_processes->rb_alloc_even[1] ; - harq_processes_dest->rb_alloc_even[2] = current_harq_processes->rb_alloc_even[2] ; - harq_processes_dest->rb_alloc_even[3] = current_harq_processes->rb_alloc_even[3] ; - harq_processes_dest->rb_alloc_odd[0] = current_harq_processes->rb_alloc_odd[0] ; - harq_processes_dest->rb_alloc_odd[1] = current_harq_processes->rb_alloc_odd[1] ; - harq_processes_dest->rb_alloc_odd[2] = current_harq_processes->rb_alloc_odd[2] ; - harq_processes_dest->rb_alloc_odd[3] = current_harq_processes->rb_alloc_odd[3] ; - harq_processes_dest->round = current_harq_processes->round ; - harq_processes_dest->rvidx = current_harq_processes->rvidx ; - harq_processes_dest->status = current_harq_processes->status ; - harq_processes_dest->vrb_type = current_harq_processes->vrb_type ; +void copy_harq_proc_struct(LTE_DL_UE_HARQ_t *harq_processes_dest, LTE_DL_UE_HARQ_t *current_harq_processes) { + harq_processes_dest->B = current_harq_processes->B ; + harq_processes_dest->C = current_harq_processes->C ; + harq_processes_dest->Cminus = current_harq_processes->Cminus ; + harq_processes_dest->Cplus = current_harq_processes->Cplus ; + harq_processes_dest->DCINdi = current_harq_processes->DCINdi ; + harq_processes_dest->F = current_harq_processes->F ; + harq_processes_dest->G = current_harq_processes->G ; + harq_processes_dest->Kminus = current_harq_processes->Kminus ; + harq_processes_dest->Kplus = current_harq_processes->Kplus ; + harq_processes_dest->Nl = current_harq_processes->Nl ; + harq_processes_dest->Qm = current_harq_processes->Qm ; + harq_processes_dest->TBS = current_harq_processes->TBS ; + harq_processes_dest->b = current_harq_processes->b ; + harq_processes_dest->codeword = current_harq_processes->codeword ; + harq_processes_dest->delta_PUCCH = current_harq_processes->delta_PUCCH ; + harq_processes_dest->dl_power_off = current_harq_processes->dl_power_off ; + harq_processes_dest->first_tx = current_harq_processes->first_tx ; + harq_processes_dest->mcs = current_harq_processes->mcs ; + harq_processes_dest->mimo_mode = current_harq_processes->mimo_mode ; + harq_processes_dest->nb_rb = current_harq_processes->nb_rb ; + harq_processes_dest->pmi_alloc = current_harq_processes->pmi_alloc ; + harq_processes_dest->rb_alloc_even[0] = current_harq_processes->rb_alloc_even[0] ; + harq_processes_dest->rb_alloc_even[1] = current_harq_processes->rb_alloc_even[1] ; + harq_processes_dest->rb_alloc_even[2] = current_harq_processes->rb_alloc_even[2] ; + harq_processes_dest->rb_alloc_even[3] = current_harq_processes->rb_alloc_even[3] ; + harq_processes_dest->rb_alloc_odd[0] = current_harq_processes->rb_alloc_odd[0] ; + harq_processes_dest->rb_alloc_odd[1] = current_harq_processes->rb_alloc_odd[1] ; + harq_processes_dest->rb_alloc_odd[2] = current_harq_processes->rb_alloc_odd[2] ; + harq_processes_dest->rb_alloc_odd[3] = current_harq_processes->rb_alloc_odd[3] ; + harq_processes_dest->round = current_harq_processes->round ; + harq_processes_dest->rvidx = current_harq_processes->rvidx ; + harq_processes_dest->status = current_harq_processes->status ; + harq_processes_dest->vrb_type = current_harq_processes->vrb_type ; } -void copy_ack_struct(harq_status_t *harq_ack_dest, harq_status_t *current_harq_ack) -{ - memcpy(harq_ack_dest, current_harq_ack, sizeof(harq_status_t)); +void copy_ack_struct(harq_status_t *harq_ack_dest, harq_status_t *current_harq_ack) { + memcpy(harq_ack_dest, current_harq_ack, sizeof(harq_status_t)); } void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSCH_t pdsch, LTE_UE_DLSCH_t *dlsch0, LTE_UE_DLSCH_t *dlsch1, int s0, int s1, int abstraction_flag) { - int subframe_rx = proc->subframe_rx; int m; int harq_pid; @@ -3303,8 +3002,7 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC if (dlsch0->active == 0) return; - for (m=s0;m<=s1;m++) { - + for (m=s0; m<=s1; m++) { if (dlsch0 && (!dlsch1)) { harq_pid = dlsch0->current_harq_pid; LOG_D(PHY,"[UE %d] PDSCH active in subframe %d, harq_pid %d Symbol %d\n",ue->Mod_id,subframe_rx,harq_pid,m); @@ -3316,15 +3014,11 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC dual_stream_UE = 1; eNB_id_i = ue->n_connected_eNB; i_mod = dlsch0->harq_processes[harq_pid]->Qm; - - } - else if((pdsch==PDSCH) && (ue->transmission_mode[eNB_id]==3)) - { - dual_stream_UE = rx_IC_dual_stream; - eNB_id_i = eNB_id; - i_mod = 0; - } - else { + } else if((pdsch==PDSCH) && (ue->transmission_mode[eNB_id]==3)) { + dual_stream_UE = rx_IC_dual_stream; + eNB_id_i = eNB_id; + i_mod = 0; + } else { dual_stream_UE = 0; eNB_id_i = eNB_id+1; i_mod = 0; @@ -3342,48 +3036,50 @@ void ue_pdsch_procedures(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, PDSC } if ((m==s0) && (m<4)) - first_symbol_flag = 1; + first_symbol_flag = 1; else - first_symbol_flag = 0; + first_symbol_flag = 0; if (LOG_DEBUGFLAG(UE_TIMING)) { uint8_t slot = 0; + if(m >= ue->frame_parms.symbols_per_tti>>1) - slot = 1; + slot = 1; + start_meas(&ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot]); } + // process DLSCH received in first slot rx_pdsch(ue, - pdsch, - eNB_id, - eNB_id_i, - proc->frame_rx, - subframe_rx, // subframe, - m, - first_symbol_flag, - dual_stream_UE, - i_mod, - dlsch0->current_harq_pid); + pdsch, + eNB_id, + eNB_id_i, + proc->frame_rx, + subframe_rx, // subframe, + m, + first_symbol_flag, + dual_stream_UE, + i_mod, + dlsch0->current_harq_pid); + if (LOG_DEBUGFLAG(UE_TIMING)) { - uint8_t slot = 0; - if(m >= ue->frame_parms.symbols_per_tti>>1) - slot = 1; - stop_meas(&ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot]); - LOG_I(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot].p_time/(cpuf*1000.0)); - } + uint8_t slot = 0; + if(m >= ue->frame_parms.symbols_per_tti>>1) + slot = 1; + stop_meas(&ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot]); + LOG_I(PHY, "[AbsSFN %d.%d] LLR Computation Symbol %d %5.2f \n",proc->frame_rx,subframe_rx,m,ue->dlsch_llr_stats_parallelization[ue->current_thread_id[subframe_rx]][slot].p_time/(cpuf*1000.0)); + } - if(first_symbol_flag) - { - proc->first_symbol_available = 1; + if(first_symbol_flag) { + proc->first_symbol_available = 1; } } // CRNTI active } } void process_rar(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, runmode_t mode, int abstraction_flag) { - int frame_rx = proc->frame_rx; int subframe_rx = proc->subframe_rx; int timing_advance; @@ -3392,99 +3088,85 @@ void process_rar(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, int eNB_id, runmode_t mo uint8_t *rar; uint8_t next1_thread_id = ue->current_thread_id[subframe_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[subframe_rx]+1); uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); - LOG_D(PHY,"[UE %d][RAPROC] Frame %d subframe %d Received RAR mode %d\n", - ue->Mod_id, - frame_rx, - subframe_rx, ue->UE_mode[eNB_id]); - + ue->Mod_id, + frame_rx, + subframe_rx, ue->UE_mode[eNB_id]); if (ue->mac_enabled == 1) { if ((ue->UE_mode[eNB_id] != PUSCH) && - (ue->prach_resources[eNB_id]->Msg3!=NULL)) { + (ue->prach_resources[eNB_id]->Msg3!=NULL)) { LOG_D(PHY,"[UE %d][RAPROC] Frame %d subframe %d Invoking MAC for RAR (current preamble %d)\n", - ue->Mod_id,frame_rx, - subframe_rx, - ue->prach_resources[eNB_id]->ra_PreambleIndex); - + ue->Mod_id,frame_rx, + subframe_rx, + ue->prach_resources[eNB_id]->ra_PreambleIndex); timing_advance = ue_process_rar(ue->Mod_id, - ue->CC_id, - frame_rx, - ue->prach_resources[eNB_id]->ra_RNTI, - dlsch0->harq_processes[0]->b, - &ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, - ue->prach_resources[eNB_id]->ra_PreambleIndex, - dlsch0->harq_processes[0]->b); // alter the 'b' buffer so it contains only the selected RAR header and RAR payload - + ue->CC_id, + frame_rx, + ue->prach_resources[eNB_id]->ra_RNTI, + dlsch0->harq_processes[0]->b, + &ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, + ue->prach_resources[eNB_id]->ra_PreambleIndex, + dlsch0->harq_processes[0]->b); // alter the 'b' buffer so it contains only the selected RAR header and RAR payload ue->pdcch_vars[next1_thread_id][eNB_id]->crnti = ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti; ue->pdcch_vars[next2_thread_id][eNB_id]->crnti = ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti; - if (timing_advance!=0xffff) { - - LOG_D(PHY,"[UE %d][RAPROC] Frame %d subframe %d Got rnti %x and timing advance %d from RAR\n", + LOG_D(PHY,"[UE %d][RAPROC] Frame %d subframe %d Got rnti %x and timing advance %d from RAR\n", ue->Mod_id, frame_rx, subframe_rx, ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti, timing_advance); - - // remember this c-rnti is still a tc-rnti - - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti_is_temporary = 1; - - //timing_advance = 0; - process_timing_advance_rar(ue,proc,timing_advance); - - if (mode!=debug_prach) { - ue->ulsch_Msg3_active[eNB_id]=1; - get_Msg3_alloc(&ue->frame_parms, - subframe_rx, - frame_rx, - &ue->ulsch_Msg3_frame[eNB_id], - &ue->ulsch_Msg3_subframe[eNB_id]); - - LOG_D(PHY,"[UE %d][RAPROC] Got Msg3_alloc Frame %d subframe %d: Msg3_frame %d, Msg3_subframe %d\n", - ue->Mod_id, - frame_rx, - subframe_rx, - ue->ulsch_Msg3_frame[eNB_id], - ue->ulsch_Msg3_subframe[eNB_id]); - harq_pid = subframe2harq_pid(&ue->frame_parms, - ue->ulsch_Msg3_frame[eNB_id], - ue->ulsch_Msg3_subframe[eNB_id]); - ue->ulsch[eNB_id]->harq_processes[harq_pid]->round = 0; - - ue->UE_mode[eNB_id] = RA_RESPONSE; - // ue->Msg3_timer[eNB_id] = 10; - ue->ulsch[eNB_id]->power_offset = 6; - ue->ulsch_no_allocation_counter[eNB_id] = 0; - } + // remember this c-rnti is still a tc-rnti + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->crnti_is_temporary = 1; + //timing_advance = 0; + process_timing_advance_rar(ue,proc,timing_advance); + + if (mode!=debug_prach) { + ue->ulsch_Msg3_active[eNB_id]=1; + get_Msg3_alloc(&ue->frame_parms, + subframe_rx, + frame_rx, + &ue->ulsch_Msg3_frame[eNB_id], + &ue->ulsch_Msg3_subframe[eNB_id]); + LOG_D(PHY,"[UE %d][RAPROC] Got Msg3_alloc Frame %d subframe %d: Msg3_frame %d, Msg3_subframe %d\n", + ue->Mod_id, + frame_rx, + subframe_rx, + ue->ulsch_Msg3_frame[eNB_id], + ue->ulsch_Msg3_subframe[eNB_id]); + harq_pid = subframe2harq_pid(&ue->frame_parms, + ue->ulsch_Msg3_frame[eNB_id], + ue->ulsch_Msg3_subframe[eNB_id]); + ue->ulsch[eNB_id]->harq_processes[harq_pid]->round = 0; + ue->UE_mode[eNB_id] = RA_RESPONSE; + // ue->Msg3_timer[eNB_id] = 10; + ue->ulsch[eNB_id]->power_offset = 6; + ue->ulsch_no_allocation_counter[eNB_id] = 0; + } } else { // PRACH preamble doesn't match RAR - LOG_W(PHY,"[UE %d][RAPROC] Received RAR preamble (%d) doesn't match !!!\n", - ue->Mod_id, - ue->prach_resources[eNB_id]->ra_PreambleIndex); + LOG_W(PHY,"[UE %d][RAPROC] Received RAR preamble (%d) doesn't match !!!\n", + ue->Mod_id, + ue->prach_resources[eNB_id]->ra_PreambleIndex); } } // mode != PUSCH - } - else { + } else { rar = dlsch0->harq_processes[0]->b+1; timing_advance = ((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); process_timing_advance_rar(ue,proc,timing_advance); } - } void ue_dlsch_procedures(PHY_VARS_UE *ue, - UE_rxtx_proc_t *proc, - int eNB_id, - PDSCH_t pdsch, - LTE_UE_DLSCH_t *dlsch0, - LTE_UE_DLSCH_t *dlsch1, - int *dlsch_errors, - runmode_t mode, - int abstraction_flag) { - + UE_rxtx_proc_t *proc, + int eNB_id, + PDSCH_t pdsch, + LTE_UE_DLSCH_t *dlsch0, + LTE_UE_DLSCH_t *dlsch1, + int *dlsch_errors, + runmode_t mode, + int abstraction_flag) { int harq_pid; int frame_rx = proc->frame_rx; int subframe_rx = proc->subframe_rx; @@ -3495,7 +3177,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, uint8_t is_cw1_active = 0; if (dlsch0==NULL) - AssertFatal(0,"dlsch0 should be defined at this level \n"); + AssertFatal(0,"dlsch0 should be defined at this level \n"); harq_pid = dlsch0->current_harq_pid; is_cw0_active = dlsch0->harq_processes[harq_pid]->status; @@ -3506,329 +3188,332 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, LOG_D(PHY,"AbsSubframe %d.%d Start Turbo Decoder for CW0 [harq_pid %d] ? %d \n", frame_rx%1024, subframe_rx, harq_pid, is_cw0_active); LOG_D(PHY,"AbsSubframe %d.%d Start Turbo Decoder for CW1 [harq_pid %d] ? %d \n", frame_rx%1024, subframe_rx, harq_pid, is_cw1_active); - if(is_cw0_active && is_cw1_active) - { - dlsch0->Kmimo = 2; - dlsch1->Kmimo = 2; - } - else - { - dlsch0->Kmimo = 1; + if(is_cw0_active && is_cw1_active) { + dlsch0->Kmimo = 2; + dlsch1->Kmimo = 2; + } else { + dlsch0->Kmimo = 1; } + if (1) { switch (pdsch) { - case SI_PDSCH: - pdsch_vars = ue->pdsch_vars_SI[eNB_id]; - break; - case RA_PDSCH: - pdsch_vars = ue->pdsch_vars_ra[eNB_id]; - break; - case P_PDSCH: - pdsch_vars = ue->pdsch_vars_p[eNB_id]; - break; - case PDSCH: - pdsch_vars = ue->pdsch_vars[ue->current_thread_id[subframe_rx]][eNB_id]; - break; - case PMCH: - case PDSCH1: - LOG_E(PHY,"Illegal PDSCH %d for ue_pdsch_procedures\n",pdsch); - pdsch_vars = NULL; - return; - break; - default: - pdsch_vars = NULL; - return; - break; + case SI_PDSCH: + pdsch_vars = ue->pdsch_vars_SI[eNB_id]; + break; + case RA_PDSCH: + pdsch_vars = ue->pdsch_vars_ra[eNB_id]; + break; + + case P_PDSCH: + pdsch_vars = ue->pdsch_vars_p[eNB_id]; + break; + + case PDSCH: + pdsch_vars = ue->pdsch_vars[ue->current_thread_id[subframe_rx]][eNB_id]; + break; + + case PMCH: + case PDSCH1: + LOG_E(PHY,"Illegal PDSCH %d for ue_pdsch_procedures\n",pdsch); + pdsch_vars = NULL; + return; + break; + + default: + pdsch_vars = NULL; + return; + break; } + if (frame_rx < *dlsch_errors) *dlsch_errors=0; if (pdsch==RA_PDSCH) { - if (ue->prach_resources[eNB_id]!=NULL) - dlsch0->rnti = ue->prach_resources[eNB_id]->ra_RNTI; + dlsch0->rnti = ue->prach_resources[eNB_id]->ra_RNTI; else { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d: FATAL, prach_resources is NULL\n",ue->Mod_id,frame_rx,subframe_rx); - AssertFatal(1==0,"prach_resources is NULL"); + LOG_E(PHY,"[UE %d] Frame %d, subframe %d: FATAL, prach_resources is NULL\n",ue->Mod_id,frame_rx,subframe_rx); + AssertFatal(1==0,"prach_resources is NULL"); } } - - - // start turbo decode for CW 0 - dlsch0->harq_processes[harq_pid]->G = get_G(&ue->frame_parms, - dlsch0->harq_processes[harq_pid]->nb_rb, - dlsch0->harq_processes[harq_pid]->rb_alloc_even, - dlsch0->harq_processes[harq_pid]->Qm, - dlsch0->harq_processes[harq_pid]->Nl, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - frame_rx, - subframe_rx, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id]); + + // start turbo decode for CW 0 + dlsch0->harq_processes[harq_pid]->G = get_G(&ue->frame_parms, + dlsch0->harq_processes[harq_pid]->nb_rb, + dlsch0->harq_processes[harq_pid]->rb_alloc_even, + dlsch0->harq_processes[harq_pid]->Qm, + dlsch0->harq_processes[harq_pid]->Nl, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + frame_rx, + subframe_rx, + ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id]); + + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->dlsch_unscrambling_stats); + } + + dlsch_unscrambling(&ue->frame_parms, + 0, + dlsch0, + dlsch0->harq_processes[harq_pid]->G, + pdsch_vars->llr[0], + 0, + subframe_rx<<1); + + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->dlsch_unscrambling_stats); + } + + LOG_D(PHY," ------ start turbo decoder for AbsSubframe %d.%d / %d ------ \n", frame_rx, subframe_rx, harq_pid); + LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> nb_rb %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->nb_rb); + LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> rb_alloc_even %x \n", frame_rx, subframe_rx, harq_pid, + (unsigned int)((intptr_t)dlsch0->harq_processes[harq_pid]->rb_alloc_even)); + LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Qm %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->Qm); + LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Nl %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->Nl); + LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> G %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->G); + LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Kmimo %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->Kmimo); + LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, subframe_rx, harq_pid, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); + + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]]); + } + + ret = dlsch_decoding(ue, + pdsch_vars->llr[0], + &ue->frame_parms, + dlsch0, + dlsch0->harq_processes[harq_pid], + frame_rx, + subframe_rx, + harq_pid, + pdsch==PDSCH?1:0, + dlsch0->harq_processes[harq_pid]->TBS>256?1:0); + + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]]); + LOG_I(PHY, " --> Unscrambling for CW0 %5.3f\n", + (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); + LOG_I(PHY, "AbsSubframe %d.%d --> Turbo Decoding for CW0 %5.3f\n", + frame_rx%1024, subframe_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); + } + + if(is_cw1_active) { + // start turbo decode for CW 1 + dlsch1->harq_processes[harq_pid]->G = get_G(&ue->frame_parms, + dlsch1->harq_processes[harq_pid]->nb_rb, + dlsch1->harq_processes[harq_pid]->rb_alloc_even, + dlsch1->harq_processes[harq_pid]->Qm, + dlsch1->harq_processes[harq_pid]->Nl, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + frame_rx, + subframe_rx, + ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id]); + if (LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->dlsch_unscrambling_stats); } + dlsch_unscrambling(&ue->frame_parms, - 0, - dlsch0, - dlsch0->harq_processes[harq_pid]->G, - pdsch_vars->llr[0], - 0, - subframe_rx<<1); + 0, + dlsch1, + dlsch1->harq_processes[harq_pid]->G, + pdsch_vars->llr[1], + 1, + subframe_rx<<1); + if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->dlsch_unscrambling_stats); } - - LOG_D(PHY," ------ start turbo decoder for AbsSubframe %d.%d / %d ------ \n", frame_rx, subframe_rx, harq_pid); - LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> nb_rb %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> rb_alloc_even %x \n", frame_rx, subframe_rx, harq_pid, (unsigned int)((intptr_t)dlsch0->harq_processes[harq_pid]->rb_alloc_even)); - LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Qm %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->Qm); - LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Nl %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->Nl); - LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> G %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->harq_processes[harq_pid]->G); - LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Kmimo %d \n", frame_rx, subframe_rx, harq_pid, dlsch0->Kmimo); - LOG_D(PHY,"start turbo decode for CW 0 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, subframe_rx, harq_pid, ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); - + + LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> nb_rb %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->nb_rb); + LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> rb_alloc_even %x \n", frame_rx, subframe_rx, harq_pid, (uint16_t)((intptr_t)dlsch1->harq_processes[harq_pid]->rb_alloc_even)); + LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Qm %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->Qm); + LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Nl %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->Nl); + LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> G %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->G); + LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Kmimo %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->Kmimo); + LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, subframe_rx, harq_pid, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); + if (LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]]); } - ret = dlsch_decoding(ue, - pdsch_vars->llr[0], - &ue->frame_parms, - dlsch0, - dlsch0->harq_processes[harq_pid], - frame_rx, - subframe_rx, - harq_pid, - pdsch==PDSCH?1:0, - dlsch0->harq_processes[harq_pid]->TBS>256?1:0); - + + ret1 = dlsch_decoding(ue, + pdsch_vars->llr[1], + &ue->frame_parms, + dlsch1, + dlsch1->harq_processes[harq_pid], + frame_rx, + subframe_rx, + harq_pid, + pdsch==PDSCH?1:0, + dlsch1->harq_processes[harq_pid]->TBS>256?1:0); + if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, " --> Unscrambling for CW0 %5.3f\n", - (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); - LOG_I(PHY, "AbsSubframe %d.%d --> Turbo Decoding for CW0 %5.3f\n", - frame_rx%1024, subframe_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); - + LOG_I(PHY, " --> Unscrambling for CW1 %5.3f\n", + (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); + LOG_I(PHY, "AbsSubframe %d.%d --> Turbo Decoding for CW1 %5.3f\n", + frame_rx%1024, subframe_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); } - if(is_cw1_active) - { - // start turbo decode for CW 1 - dlsch1->harq_processes[harq_pid]->G = get_G(&ue->frame_parms, - dlsch1->harq_processes[harq_pid]->nb_rb, - dlsch1->harq_processes[harq_pid]->rb_alloc_even, - dlsch1->harq_processes[harq_pid]->Qm, - dlsch1->harq_processes[harq_pid]->Nl, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - frame_rx, - subframe_rx, - ue->transmission_mode[eNB_id]<7?0:ue->transmission_mode[eNB_id]); - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->dlsch_unscrambling_stats); - } - dlsch_unscrambling(&ue->frame_parms, - 0, - dlsch1, - dlsch1->harq_processes[harq_pid]->G, - pdsch_vars->llr[1], - 1, - subframe_rx<<1); - if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->dlsch_unscrambling_stats); - } - - LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> nb_rb %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->nb_rb); - LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> rb_alloc_even %x \n", frame_rx, subframe_rx, harq_pid, (uint16_t)((intptr_t)dlsch1->harq_processes[harq_pid]->rb_alloc_even)); - LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Qm %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->Qm); - LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Nl %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->Nl); - LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> G %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->harq_processes[harq_pid]->G); - LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Kmimo %d \n", frame_rx, subframe_rx, harq_pid, dlsch1->Kmimo); - LOG_D(PHY,"start turbo decode for CW 1 for AbsSubframe %d.%d / %d --> Pdcch Sym %d \n", frame_rx, subframe_rx, harq_pid, ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); - - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]]); - } - - ret1 = dlsch_decoding(ue, - pdsch_vars->llr[1], - &ue->frame_parms, - dlsch1, - dlsch1->harq_processes[harq_pid], - frame_rx, - subframe_rx, - harq_pid, - pdsch==PDSCH?1:0, - dlsch1->harq_processes[harq_pid]->TBS>256?1:0); - - if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, " --> Unscrambling for CW1 %5.3f\n", - (ue->dlsch_unscrambling_stats.p_time)/(cpuf*1000.0)); - LOG_I(PHY, "AbsSubframe %d.%d --> Turbo Decoding for CW1 %5.3f\n", - frame_rx%1024, subframe_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); - } - LOG_D(PHY,"AbsSubframe %d.%d --> Turbo Decoding for CW1 %5.3f\n", - frame_rx%1024, subframe_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); - } - - LOG_D(PHY," ------ end turbo decoder for AbsSubframe %d.%d ------ \n", frame_rx, subframe_rx); - - + LOG_D(PHY,"AbsSubframe %d.%d --> Turbo Decoding for CW1 %5.3f\n", + frame_rx%1024, subframe_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); + } + + LOG_D(PHY," ------ end turbo decoder for AbsSubframe %d.%d ------ \n", frame_rx, subframe_rx); // Check CRC for CW 0 if (ret == (1+dlsch0->max_turbo_iterations)) { *dlsch_errors=*dlsch_errors+1; - if(dlsch0->rnti != 0xffff) - { - - LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : DLSCH CW0 in error (rv %d,round %d, mcs %d,TBS %d)\n", - ue->Mod_id,dlsch0->rnti, - harq_pid,frame_rx,subframe_rx, - dlsch0->harq_processes[harq_pid]->rvidx, - dlsch0->harq_processes[harq_pid]->round, - dlsch0->harq_processes[harq_pid]->mcs, - dlsch0->harq_processes[harq_pid]->TBS); + if(dlsch0->rnti != 0xffff) { + LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : DLSCH CW0 in error (rv %d,round %d, mcs %d,TBS %d)\n", + ue->Mod_id,dlsch0->rnti, + harq_pid,frame_rx,subframe_rx, + dlsch0->harq_processes[harq_pid]->rvidx, + dlsch0->harq_processes[harq_pid]->round, + dlsch0->harq_processes[harq_pid]->mcs, + dlsch0->harq_processes[harq_pid]->TBS); + } + } else { + if(dlsch0->rnti != 0xffff) { + LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : Received DLSCH CW0 (rv %d,round %d, mcs %d,TBS %d)\n", + ue->Mod_id,dlsch0->rnti, + harq_pid,frame_rx,subframe_rx, + dlsch0->harq_processes[harq_pid]->rvidx, + dlsch0->harq_processes[harq_pid]->round, + dlsch0->harq_processes[harq_pid]->mcs, + dlsch0->harq_processes[harq_pid]->TBS); } - - } else { - if(dlsch0->rnti != 0xffff) - { - LOG_D(PHY,"[UE %d][PDSCH %x/%d] AbsSubframe %d.%d : Received DLSCH CW0 (rv %d,round %d, mcs %d,TBS %d)\n", - ue->Mod_id,dlsch0->rnti, - harq_pid,frame_rx,subframe_rx, - dlsch0->harq_processes[harq_pid]->rvidx, - dlsch0->harq_processes[harq_pid]->round, - dlsch0->harq_processes[harq_pid]->mcs, - dlsch0->harq_processes[harq_pid]->TBS); - } - - if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)){ - int j; - LOG_D(PHY,"dlsch harq_pid %d (rx): \n",dlsch0->current_harq_pid); + if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + int j; + LOG_D(PHY,"dlsch harq_pid %d (rx): \n",dlsch0->current_harq_pid); for (j=0; j<dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS>>3; j++) - LOG_T(PHY,"%x.",dlsch0->harq_processes[dlsch0->current_harq_pid]->b[j]); + LOG_T(PHY,"%x.",dlsch0->harq_processes[dlsch0->current_harq_pid]->b[j]); LOG_T(PHY,"\n"); } - if (ue->mac_enabled == 1) { - - switch (pdsch) { - case PDSCH: - ue_send_sdu(ue->Mod_id, - CC_id, - frame_rx, - subframe_rx, - dlsch0->harq_processes[dlsch0->current_harq_pid]->b, - dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS>>3, - eNB_id); - break; - case SI_PDSCH: - ue_decode_si(ue->Mod_id, - CC_id, - frame_rx, - eNB_id, - ue->dlsch_SI[eNB_id]->harq_processes[0]->b, - ue->dlsch_SI[eNB_id]->harq_processes[0]->TBS>>3); - break; - case P_PDSCH: - ue_decode_p(ue->Mod_id, - CC_id, - frame_rx, - eNB_id, - ue->dlsch_SI[eNB_id]->harq_processes[0]->b, - ue->dlsch_SI[eNB_id]->harq_processes[0]->TBS>>3); - break; - case RA_PDSCH: - process_rar(ue,proc,eNB_id,mode,abstraction_flag); - break; - case PDSCH1: - LOG_E(PHY,"Shouldn't have PDSCH1 yet, come back later\n"); - AssertFatal(1==0,"exiting"); - break; - case PMCH: - LOG_E(PHY,"Shouldn't have PMCH here\n"); - AssertFatal(1==0,"exiting"); - break; - } + switch (pdsch) { + case PDSCH: + ue_send_sdu(ue->Mod_id, + CC_id, + frame_rx, + subframe_rx, + dlsch0->harq_processes[dlsch0->current_harq_pid]->b, + dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS>>3, + eNB_id); + break; + + case SI_PDSCH: + ue_decode_si(ue->Mod_id, + CC_id, + frame_rx, + eNB_id, + ue->dlsch_SI[eNB_id]->harq_processes[0]->b, + ue->dlsch_SI[eNB_id]->harq_processes[0]->TBS>>3); + break; + + case P_PDSCH: + ue_decode_p(ue->Mod_id, + CC_id, + frame_rx, + eNB_id, + ue->dlsch_SI[eNB_id]->harq_processes[0]->b, + ue->dlsch_SI[eNB_id]->harq_processes[0]->TBS>>3); + break; + + case RA_PDSCH: + process_rar(ue,proc,eNB_id,mode,abstraction_flag); + break; + + case PDSCH1: + LOG_E(PHY,"Shouldn't have PDSCH1 yet, come back later\n"); + AssertFatal(1==0,"exiting"); + break; + + case PMCH: + LOG_E(PHY,"Shouldn't have PMCH here\n"); + AssertFatal(1==0,"exiting"); + break; + } } + ue->total_TBS[eNB_id] = ue->total_TBS[eNB_id] + - dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS; + dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS; ue->total_received_bits[eNB_id] = ue->total_TBS[eNB_id] + - dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS; + dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS; } + // Check CRC for CW 1 - if(is_cw1_active) - { - if (ret1 == (1+dlsch0->max_turbo_iterations)) { - LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d DLSCH CW1 in error (rv %d,mcs %d,TBS %d)\n", - ue->Mod_id,dlsch0->rnti, - harq_pid,frame_rx,subframe_rx, - dlsch0->harq_processes[harq_pid]->rvidx, - dlsch0->harq_processes[harq_pid]->mcs, - dlsch0->harq_processes[harq_pid]->TBS); - - } else { - LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: Received DLSCH CW1 (rv %d,mcs %d,TBS %d)\n", - ue->Mod_id,dlsch0->rnti, - harq_pid,frame_rx,subframe_rx, - dlsch0->harq_processes[harq_pid]->rvidx, - dlsch0->harq_processes[harq_pid]->mcs, - dlsch0->harq_processes[harq_pid]->TBS); - - - if (ue->mac_enabled == 1) { - switch (pdsch) { - case PDSCH: - if(is_cw1_active) - ue_send_sdu(ue->Mod_id, - CC_id, - frame_rx, - subframe_rx, - dlsch1->harq_processes[dlsch1->current_harq_pid]->b, - dlsch1->harq_processes[dlsch1->current_harq_pid]->TBS>>3, - eNB_id); - break; - case SI_PDSCH: - case P_PDSCH: - case RA_PDSCH: - case PDSCH1: - case PMCH: - AssertFatal(0,"exiting"); - break; - } - } + if(is_cw1_active) { + if (ret1 == (1+dlsch0->max_turbo_iterations)) { + LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d DLSCH CW1 in error (rv %d,mcs %d,TBS %d)\n", + ue->Mod_id,dlsch0->rnti, + harq_pid,frame_rx,subframe_rx, + dlsch0->harq_processes[harq_pid]->rvidx, + dlsch0->harq_processes[harq_pid]->mcs, + dlsch0->harq_processes[harq_pid]->TBS); + } else { + LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: Received DLSCH CW1 (rv %d,mcs %d,TBS %d)\n", + ue->Mod_id,dlsch0->rnti, + harq_pid,frame_rx,subframe_rx, + dlsch0->harq_processes[harq_pid]->rvidx, + dlsch0->harq_processes[harq_pid]->mcs, + dlsch0->harq_processes[harq_pid]->TBS); + + if (ue->mac_enabled == 1) { + switch (pdsch) { + case PDSCH: + if(is_cw1_active) + ue_send_sdu(ue->Mod_id, + CC_id, + frame_rx, + subframe_rx, + dlsch1->harq_processes[dlsch1->current_harq_pid]->b, + dlsch1->harq_processes[dlsch1->current_harq_pid]->TBS>>3, + eNB_id); + + break; + + case SI_PDSCH: + case P_PDSCH: + case RA_PDSCH: + case PDSCH1: + case PMCH: + AssertFatal(0,"exiting"); + break; + } } } - + } + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_D(PHY,"[UE %d][PDSCH %x/%d] Frame %d subframe %d: PDSCH/DLSCH decoding iter %d (mcs %d, rv %d, TBS %d)\n", - ue->Mod_id, - dlsch0->rnti,harq_pid, - frame_rx,subframe_rx,ret, - dlsch0->harq_processes[harq_pid]->mcs, - dlsch0->harq_processes[harq_pid]->rvidx, - dlsch0->harq_processes[harq_pid]->TBS); - + ue->Mod_id, + dlsch0->rnti,harq_pid, + frame_rx,subframe_rx,ret, + dlsch0->harq_processes[harq_pid]->mcs, + dlsch0->harq_processes[harq_pid]->rvidx, + dlsch0->harq_processes[harq_pid]->TBS); + if (frame_rx%100==0) { - LOG_D(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d dlsch_errors %d, dlsch_received %d, dlsch_fer %d, current_dlsch_cqi %d\n", - ue->Mod_id,dlsch0->rnti, - frame_rx,subframe_rx, - ue->dlsch_errors[eNB_id], - ue->dlsch_received[eNB_id], - ue->dlsch_fer[eNB_id], - ue->measurements.wideband_cqi_tot[eNB_id]); + LOG_D(PHY,"[UE %d][PDSCH %x] Frame %d subframe %d dlsch_errors %d, dlsch_received %d, dlsch_fer %d, current_dlsch_cqi %d\n", + ue->Mod_id,dlsch0->rnti, + frame_rx,subframe_rx, + ue->dlsch_errors[eNB_id], + ue->dlsch_received[eNB_id], + ue->dlsch_fer[eNB_id], + ue->measurements.wideband_cqi_tot[eNB_id]); } - } /*LOG_DEBUGFLAG(DEBUG_UE_PHYPROC) */ - } - - } /*! @@ -3840,258 +3525,256 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue, #ifdef UE_SLOT_PARALLELISATION #define FIFO_PRIORITY 40 void *UE_thread_slot1_dl_processing(void *arg) { + static __thread int UE_dl_slot1_processing_retval; + struct rx_tx_thread_data *rtd = arg; + UE_rxtx_proc_t *proc = rtd->proc; + PHY_VARS_UE *ue = rtd->UE; + int frame_rx; + uint8_t subframe_rx; + uint8_t pilot0; + uint8_t pilot1; + uint8_t slot1; + uint8_t next_subframe_rx; + uint8_t next_subframe_slot0; + proc->instance_cnt_slot1_dl_processing=-1; + proc->subframe_rx=proc->sub_frame_start; + char threadname[256]; + sprintf(threadname,"UE_thread_slot1_dl_processing_%d", proc->sub_frame_start); + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.slot1_proc_one != -1 ) + CPU_SET(threads.slot1_proc_one, &cpuset); + + if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.slot1_proc_two != -1 ) + CPU_SET(threads.slot1_proc_two, &cpuset); + + if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.slot1_proc_three != -1 ) + CPU_SET(threads.slot1_proc_three, &cpuset); + + init_thread(900000,1000000, FIFO_PRIORITY-1, &cpuset, + threadname); + + while (!oai_exit) { + if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE slot1 dl processing\n" ); + exit_fun("nothing to add"); + } - static __thread int UE_dl_slot1_processing_retval; - struct rx_tx_thread_data *rtd = arg; - UE_rxtx_proc_t *proc = rtd->proc; - PHY_VARS_UE *ue = rtd->UE; - - int frame_rx; - uint8_t subframe_rx; - uint8_t pilot0; - uint8_t pilot1; - uint8_t slot1; - - uint8_t next_subframe_rx; - uint8_t next_subframe_slot0; - - proc->instance_cnt_slot1_dl_processing=-1; - proc->subframe_rx=proc->sub_frame_start; - - char threadname[256]; - sprintf(threadname,"UE_thread_slot1_dl_processing_%d", proc->sub_frame_start); - - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - if ( (proc->sub_frame_start+1)%RX_NB_TH == 0 && threads.slot1_proc_one != -1 ) - CPU_SET(threads.slot1_proc_one, &cpuset); - if ( (proc->sub_frame_start+1)%RX_NB_TH == 1 && threads.slot1_proc_two != -1 ) - CPU_SET(threads.slot1_proc_two, &cpuset); - if ( (proc->sub_frame_start+1)%RX_NB_TH == 2 && threads.slot1_proc_three != -1 ) - CPU_SET(threads.slot1_proc_three, &cpuset); - - init_thread(900000,1000000 , FIFO_PRIORITY-1, &cpuset, - threadname); - - while (!oai_exit) { - if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE slot1 dl processing\n" ); - exit_fun("nothing to add"); - } - while (proc->instance_cnt_slot1_dl_processing < 0) { - // most of the time, the thread is waiting here - pthread_cond_wait( &proc->cond_slot1_dl_processing, &proc->mutex_slot1_dl_processing ); - } - if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE slot1 dl processing \n" ); - exit_fun("nothing to add"); - } + while (proc->instance_cnt_slot1_dl_processing < 0) { + // most of the time, the thread is waiting here + pthread_cond_wait( &proc->cond_slot1_dl_processing, &proc->mutex_slot1_dl_processing ); + } - /*for(int th_idx=0; th_idx< RX_NB_TH; th_idx++) - { - frame_rx = ue->proc.proc_rxtx[0].frame_rx; - subframe_rx = ue->proc.proc_rxtx[0].subframe_rx; - printf("AbsSubframe %d.%d execute dl slot1 processing \n", frame_rx, subframe_rx); - }*/ - frame_rx = proc->frame_rx; - subframe_rx = proc->subframe_rx; - next_subframe_rx = (1+subframe_rx)%10; - next_subframe_slot0 = next_subframe_rx<<1; - - slot1 = (subframe_rx<<1) + 1; - pilot0 = 0; - - //printf("AbsSubframe %d.%d execute dl slot1 processing \n", frame_rx, subframe_rx); - - if (ue->frame_parms.Ncp == 0) { // normal prefix - pilot1 = 4; - } else { // extended prefix - pilot1 = 3; - } + if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE slot1 dl processing \n" ); + exit_fun("nothing to add"); + } - /**** Slot1 FE Processing ****/ - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1]); - } - // I- start dl slot1 processing - // do first symbol of next downlink subframe for channel estimation - /* - // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) - if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) - { - front_end_fft(ue, - pilot0, - next_subframe_slot0, - 0, - 0); - } + /*for(int th_idx=0; th_idx< RX_NB_TH; th_idx++) + { + frame_rx = ue->proc.proc_rxtx[0].frame_rx; + subframe_rx = ue->proc.proc_rxtx[0].subframe_rx; + printf("AbsSubframe %d.%d execute dl slot1 processing \n", frame_rx, subframe_rx); + }*/ + frame_rx = proc->frame_rx; + subframe_rx = proc->subframe_rx; + next_subframe_rx = (1+subframe_rx)%10; + next_subframe_slot0 = next_subframe_rx<<1; + slot1 = (subframe_rx<<1) + 1; + pilot0 = 0; + + //printf("AbsSubframe %d.%d execute dl slot1 processing \n", frame_rx, subframe_rx); + + if (ue->frame_parms.Ncp == 0) { // normal prefix + pilot1 = 4; + } else { // extended prefix + pilot1 = 3; + } + /**** Slot1 FE Processing ****/ + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1]); + } + + // I- start dl slot1 processing + // do first symbol of next downlink subframe for channel estimation + /* + // 1- perform FFT for pilot ofdm symbols first (ofdmSym0 next subframe ofdmSym11) + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) + { front_end_fft(ue, - pilot1, - slot1, + pilot0, + next_subframe_slot0, 0, 0); - */ - // 1- perform FFT - for (int l=1; l<ue->frame_parms.symbols_per_tti>>1; l++) - { - //if( (l != pilot0) && (l != pilot1)) - { - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ofdm_demod_stats); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,l); - front_end_fft(ue, - l, - slot1, - 0, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); - if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->ofdm_demod_stats); - } - } - } // for l=1..l2 + } + + front_end_fft(ue, + pilot1, + slot1, + 0, + 0); + */ + // 1- perform FFT + for (int l=1; l<ue->frame_parms.symbols_per_tti>>1; l++) { + //if( (l != pilot0) && (l != pilot1)) + { + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ofdm_demod_stats); + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,l); + front_end_fft(ue, + l, + slot1, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); - if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) - { - //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,next_subframe_slot0,pilot0); - front_end_fft(ue, + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->ofdm_demod_stats); + } + } + } // for l=1..l2 + + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) { + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,next_subframe_slot0,pilot0); + front_end_fft(ue, pilot0, next_subframe_slot0, 0, 0); - } + } - // 2- perform Channel Estimation for slot1 - for (int l=1; l<ue->frame_parms.symbols_per_tti>>1; l++) - { - if(l == pilot1) - { - //wait until channel estimation for pilot0/slot1 is available - uint32_t wait = 0; - while(proc->chan_est_pilot0_slot1_available == 0) - { - usleep(1); - wait++; - } - //printf("[slot1 dl processing] ChanEst symbol %d slot %d wait%d\n",l,slot1,wait); - } - //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,l); - front_end_chanEst(ue, - l, - slot1, - 0); - ue_measurement_procedures(l-1,ue,proc,0,1+(subframe_rx<<1),0,ue->mode); - } - //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,next_subframe_slot0,pilot0); - front_end_chanEst(ue, - pilot0, - next_subframe_slot0, - 0); + // 2- perform Channel Estimation for slot1 + for (int l=1; l<ue->frame_parms.symbols_per_tti>>1; l++) { + if(l == pilot1) { + //wait until channel estimation for pilot0/slot1 is available + uint32_t wait = 0; - if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) - { - ue_pbch_procedures(0,ue,proc,0); + while(proc->chan_est_pilot0_slot1_available == 0) { + usleep(1); + wait++; } - proc->chan_est_slot1_available = 1; - //printf("Set available slot 1channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); - //printf(" [slot1 dl processing] ==> FFT/CHanEst Done for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + //printf("[slot1 dl processing] ChanEst symbol %d slot %d wait%d\n",l,slot1,wait); + } - //printf(" [slot1 dl processing] ==> Start LLR Comuptation slot1 for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,l); + front_end_chanEst(ue, + l, + slot1, + 0); + ue_measurement_procedures(l-1,ue,proc,0,1+(subframe_rx<<1),0,ue->mode); + } + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,next_subframe_slot0,pilot0); + front_end_chanEst(ue, + pilot0, + next_subframe_slot0, + 0); - if ( LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1].p_time/(cpuf*1000.0)); - } + if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) { + ue_pbch_procedures(0,ue,proc,0); + } + proc->chan_est_slot1_available = 1; + //printf("Set available slot 1channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + //printf(" [slot1 dl processing] ==> FFT/CHanEst Done for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + //printf(" [slot1 dl processing] ==> Start LLR Comuptation slot1 for AbsSubframe %d.%d \n", proc->frame_rx, proc->subframe_rx); + + if ( LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1]); + LOG_I(PHY, "[AbsSFN %d.%d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][1].p_time/(cpuf*1000.0)); + } //wait until pdcch is decoded uint32_t wait = 0; - while(proc->dci_slot0_available == 0) - { - usleep(1); - wait++; + + while(proc->dci_slot0_available == 0) { + usleep(1); + wait++; } - //printf("[slot1 dl processing] AbsSubframe %d.%d LLR Computation Start wait DCI %d\n",frame_rx,subframe_rx,wait); + //printf("[slot1 dl processing] AbsSubframe %d.%d LLR Computation Start wait DCI %d\n",frame_rx,subframe_rx,wait); /**** Pdsch Procedure Slot1 ****/ // start slot1 thread for Pdsch Procedure (slot1) // do procedures for C-RNTI //printf("AbsSubframe %d.%d Pdsch Procedure (slot1)\n",frame_rx,subframe_rx); - if ( LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][1]); } + // start slave thread for Pdsch Procedure (slot1) // do procedures for C-RNTI uint8_t eNB_id = 0; uint8_t abstraction_flag = 0; + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active == 1) { - //wait until first ofdm symbol is processed - //wait = 0; - //while(proc->first_symbol_available == 0) - //{ - // usleep(1); - // wait++; - //} - //printf("[slot1 dl processing] AbsSubframe %d.%d LLR Computation Start wait First Ofdm Sym %d\n",frame_rx,subframe_rx,wait); - - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], - NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + //wait until first ofdm symbol is processed + //wait = 0; + //while(proc->first_symbol_available == 0) + //{ + // usleep(1); + // wait++; + //} + //printf("[slot1 dl processing] AbsSubframe %d.%d LLR Computation Start wait First Ofdm Sym %d\n",frame_rx,subframe_rx,wait); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); + LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); } // do procedures for SI-RNTI if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); + ue_pdsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); } // do procedures for P-RNTI if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); + ue_pdsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); } + // do procedures for RA-RNTI if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - ue_pdsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - (ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); + ue_pdsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + (ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); } proc->llr_slot1_available=1; @@ -4102,529 +3785,518 @@ void *UE_thread_slot1_dl_processing(void *arg) { LOG_I(PHY, "[AbsSFN %d.%d] Slot1: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][1].p_time/(cpuf*1000.0)); } + if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); + exit_fun("noting to add"); + } - if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { - LOG_E( PHY, "[SCHED][UE] error locking mutex for UE RXTX\n" ); - exit_fun("noting to add"); - } - proc->instance_cnt_slot1_dl_processing--; - if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { - LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); - exit_fun("noting to add"); - } + proc->instance_cnt_slot1_dl_processing--; + + if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE] error unlocking mutex for UE FEP Slo1\n" ); + exit_fun("noting to add"); } - // thread finished - free(arg); - return &UE_dl_slot1_processing_retval; + } + + // thread finished + free(arg); + return &UE_dl_slot1_processing_retval; } #endif #ifdef UE_SLOT_PARALLELISATION int phy_procedures_slot_parallelization_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { + int l,l2; + int pmch_flag=0; + int frame_rx = proc->frame_rx; + int subframe_rx = proc->subframe_rx; + uint8_t pilot0; + uint8_t pilot1; + uint8_t slot0; + uint8_t slot1; + uint8_t first_ofdm_sym; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); + T(T_UE_PHY_DL_TICK, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx)); + T(T_UE_PHY_INPUT_SIGNAL, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx), T_INT(0), + T_BUFFER(&ue->common_vars.rxdata[0][subframe_rx*ue->frame_parms.samples_per_tti], + ue->frame_parms.samples_per_tti * 4)); - int l,l2; - int pmch_flag=0; - int frame_rx = proc->frame_rx; - int subframe_rx = proc->subframe_rx; - uint8_t pilot0; - uint8_t pilot1; - uint8_t slot0; - uint8_t slot1; - uint8_t first_ofdm_sym; + // start timers + if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); + } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->phy_proc_rx[ue->current_thread_id[subframe_rx]]); + start_meas(&ue->ue_front_end_stat[ue->current_thread_id[subframe_rx]]); + } + pmch_flag = is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms) ? 1 : 0; - T(T_UE_PHY_DL_TICK, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx)); + if (do_pdcch_flag) { + // deactivate reception until we scan pdcch + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]) + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active = 0; - T(T_UE_PHY_INPUT_SIGNAL, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx), T_INT(0), - T_BUFFER(&ue->common_vars.rxdata[0][subframe_rx*ue->frame_parms.samples_per_tti], - ue->frame_parms.samples_per_tti * 4)); + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]) + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]->active = 0; + if (ue->dlsch_SI[eNB_id]) + ue->dlsch_SI[eNB_id]->active = 0; - // start timers - if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); - } + if (ue->dlsch_p[eNB_id]) + ue->dlsch_p[eNB_id]->active = 0; - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->phy_proc_rx[ue->current_thread_id[subframe_rx]]); - start_meas(&ue->ue_front_end_stat[ue->current_thread_id[subframe_rx]]); - } + if (ue->dlsch_ra[eNB_id]) + ue->dlsch_ra[eNB_id]->active = 0; + } - pmch_flag = is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms) ? 1 : 0; + if ( LOG_DEBUG_FLAG(DEBUG_UE_PHYPROC)) { + LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", + ue->Mod_id,frame_rx, subframe_rx); + } - if (do_pdcch_flag) { - // deactivate reception until we scan pdcch - if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]) - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active = 0; - if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]) - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]->active = 0; - - if (ue->dlsch_SI[eNB_id]) - ue->dlsch_SI[eNB_id]->active = 0; - if (ue->dlsch_p[eNB_id]) - ue->dlsch_p[eNB_id]->active = 0; - if (ue->dlsch_ra[eNB_id]) - ue->dlsch_ra[eNB_id]->active = 0; - } + if (subframe_select(&ue->frame_parms,subframe_rx) == SF_S) { // S-subframe, do first 5 symbols only + l2 = 4; + } else if (pmch_flag == 1) { // do first 2 symbols only + l2 = 1; + } else { // normal subframe, last symbol to be processed is the first of the second slot + l2 = (ue->frame_parms.symbols_per_tti/2)-1; + } - if ( LOG_DEBUG_FLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", - ue->Mod_id,frame_rx, subframe_rx); - } + int prev_subframe_rx = (subframe_rx - 1)<0? 9: (subframe_rx - 1); + if (subframe_select(&ue->frame_parms,prev_subframe_rx) != SF_DL) { + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // RX processing of symbols l=0...l2 + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + first_ofdm_sym = 0; + } else { + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // RX processing of symbols l=1...l2 (l=0 is done in last scheduling epoch) + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + first_ofdm_sym = 1; + } + slot0 = (subframe_rx<<1); + slot1 = (subframe_rx<<1) + 1; + pilot0 = 0; + if (ue->frame_parms.Ncp == 0) { // normal prefix + pilot1 = 4; + } else { // extended prefix + pilot1 = 3; + } - if (subframe_select(&ue->frame_parms,subframe_rx) == SF_S) { // S-subframe, do first 5 symbols only - l2 = 4; - } else if (pmch_flag == 1) { // do first 2 symbols only - l2 = 1; - } else { // normal subframe, last symbol to be processed is the first of the second slot - l2 = (ue->frame_parms.symbols_per_tti/2)-1; - } + //LOG_I(PHY,"Set available channelEst to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + //LOG_I(PHY,"Set available llrs slot1 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + //LOG_I(PHY,"Set available dci info slot0 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + proc->chan_est_pilot0_slot1_available=0; + proc->llr_slot1_available=0; + proc->dci_slot0_available=0; + proc->first_symbol_available=0; + proc->chan_est_slot1_available=0; + //proc->channel_level=0; + + if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error locking mutex for UE slot1 dl processing\n",ue->Mod_id ); + exit_fun("nothing to add"); + } - int prev_subframe_rx = (subframe_rx - 1)<0? 9: (subframe_rx - 1); - if (subframe_select(&ue->frame_parms,prev_subframe_rx) != SF_DL) { - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // RX processing of symbols l=0...l2 - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - first_ofdm_sym = 0; - } else { - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // RX processing of symbols l=1...l2 (l=0 is done in last scheduling epoch) - //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - first_ofdm_sym = 1; - } - slot0 = (subframe_rx<<1); - slot1 = (subframe_rx<<1) + 1; - pilot0 = 0; - if (ue->frame_parms.Ncp == 0) { // normal prefix - pilot1 = 4; - } else { // extended prefix - pilot1 = 3; - } + proc->instance_cnt_slot1_dl_processing++; - //LOG_I(PHY,"Set available channelEst to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); - //LOG_I(PHY,"Set available llrs slot1 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); - //LOG_I(PHY,"Set available dci info slot0 to 0 AbsSubframe %d.%d \n",frame_rx,subframe_rx); - proc->chan_est_pilot0_slot1_available=0; - proc->llr_slot1_available=0; - proc->dci_slot0_available=0; - proc->first_symbol_available=0; - proc->chan_est_slot1_available=0; - //proc->channel_level=0; + if (proc->instance_cnt_slot1_dl_processing == 0) { + LOG_D(PHY,"unblock slot1 dl processing thread blocked on instance_cnt_slot1_dl_processing : %d \n", proc->instance_cnt_slot1_dl_processing ); - if (pthread_mutex_lock(&proc->mutex_slot1_dl_processing) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] error locking mutex for UE slot1 dl processing\n",ue->Mod_id ); - exit_fun("nothing to add"); + if (pthread_cond_signal(&proc->cond_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] ERROR pthread_cond_signal for UE slot1 processing thread\n", ue->Mod_id); + exit_fun("nothing to add"); } - proc->instance_cnt_slot1_dl_processing++; - if (proc->instance_cnt_slot1_dl_processing == 0) - { - LOG_D(PHY,"unblock slot1 dl processing thread blocked on instance_cnt_slot1_dl_processing : %d \n", proc->instance_cnt_slot1_dl_processing ); - if (pthread_cond_signal(&proc->cond_slot1_dl_processing) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] ERROR pthread_cond_signal for UE slot1 processing thread\n", ue->Mod_id); - exit_fun("nothing to add"); - } - if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { - LOG_E( PHY, "[SCHED][UE %d][Slot0] error unlocking mutex for UE slot1 dl processing \n",ue->Mod_id ); - exit_fun("nothing to add"); - } - - } else - { - LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", ue->Mod_id, proc->instance_cnt_slot1_dl_processing); - if (proc->instance_cnt_slot1_dl_processing > 2) - exit_fun("instance_cnt_slot1_dl_processing > 2"); + if (pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) != 0) { + LOG_E( PHY, "[SCHED][UE %d][Slot0] error unlocking mutex for UE slot1 dl processing \n",ue->Mod_id ); + exit_fun("nothing to add"); } - //AssertFatal(pthread_cond_signal(&proc->cond_slot1_dl_processing) ==0 ,""); - AssertFatal(pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) ==0,""); + } else { + LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", ue->Mod_id, proc->instance_cnt_slot1_dl_processing); + if (proc->instance_cnt_slot1_dl_processing > 2) + exit_fun("instance_cnt_slot1_dl_processing > 2"); + } - /**** Slot0 FE Processing ****/ - // I- start main thread for FFT/ChanEst symbol: 0/1 --> 7 - if ( LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); - } - // 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) - //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,pilot0); - front_end_fft(ue, - pilot0, - slot1, - 0, - 0); - //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,pilot1); - front_end_fft(ue, - pilot1, - slot0, - 0, - 0); - //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,pilot1); - front_end_chanEst(ue, - pilot1, - slot0, - 0); - //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,pilot0); - front_end_chanEst(ue, - pilot0, - slot1, - 0); - proc->chan_est_pilot0_slot1_available = 1; - //printf("Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); + //AssertFatal(pthread_cond_signal(&proc->cond_slot1_dl_processing) ==0 ,""); + AssertFatal(pthread_mutex_unlock(&proc->mutex_slot1_dl_processing) ==0,""); - // 2- perform FFT for other ofdm symbols other than pilots - for (l=first_ofdm_sym; l<=l2; l++) - { - if( (l != pilot0) && (l != pilot1)) - { - //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,l); - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ofdm_demod_stats); - } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - front_end_fft(ue, - l, + /**** Slot0 FE Processing ****/ + // I- start main thread for FFT/ChanEst symbol: 0/1 --> 7 + if ( LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); + } + + // 1- perform FFT for pilot ofdm symbols first (ofdmSym7 ofdmSym4 or (ofdmSym6 ofdmSym3)) + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,pilot0); + front_end_fft(ue, + pilot0, + slot1, + 0, + 0); + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,pilot1); + front_end_fft(ue, + pilot1, + slot0, + 0, + 0); + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,pilot1); + front_end_chanEst(ue, + pilot1, slot0, - 0, 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); - if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->ofdm_demod_stats); - } - } - } // for l=1..l2 + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot1,pilot0); + front_end_chanEst(ue, + pilot0, + slot1, + 0); + proc->chan_est_pilot0_slot1_available = 1; + //printf("Set available channelEst to 1 AbsSubframe %d.%d \n",frame_rx,subframe_rx); - // 3- perform Channel Estimation for slot0 - for (l=first_ofdm_sym; l<=l2; l++) - { - if( (l != pilot0) && (l != pilot1)) - { - //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,l); - front_end_chanEst(ue, + // 2- perform FFT for other ofdm symbols other than pilots + for (l=first_ofdm_sym; l<=l2; l++) { + if( (l != pilot0) && (l != pilot1)) { + //printf("AbsSubframe %d.%d FFT slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,l); + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ofdm_demod_stats); + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + front_end_fft(ue, l, slot0, + 0, 0); - } - ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); - } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); - if (do_pdcch_flag) { - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]]); - } - if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); - if (LOG_DEBUGFLAG(UE_TIMING)) { - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); - } + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->ofdm_demod_stats); + } + } + } // for l=1..l2 - //proc->dci_slot0_available = 1; - return(-1); - } - //proc->dci_slot0_available=1; - if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); - } + // 3- perform Channel Estimation for slot0 + for (l=first_ofdm_sym; l<=l2; l++) { + if( (l != pilot0) && (l != pilot1)) { + //printf("AbsSubframe %d.%d ChanEst slot %d, symbol %d\n", frame_rx,subframe_rx,slot0,l); + front_end_chanEst(ue, + l, + slot0, + 0); } - //printf("num_pdcch_symbols %d\n",ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); + ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); + } - // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) + if (do_pdcch_flag) { if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); + start_meas(&ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]]); } - //wait until slot1 FE is done - uint32_t wait = 0; - while(proc->chan_est_slot1_available == 0) - { - usleep(1); - wait++; + if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { + LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); + + if (LOG_DEBUGFLAG(UE_TIMING)) { + LOG_I(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); + } + + //proc->dci_slot0_available = 1; + return(-1); } + //proc->dci_slot0_available=1; if (LOG_DEBUGFLAG(UE_TIMING)) { - stop_meas(&ue->ue_front_end_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] FULL FE Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); + stop_meas(&ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]]); + LOG_I(PHY, "[AbsSFN %d.%d] Slot0: PDCCH %5.2f \n",frame_rx,subframe_rx,ue->pdcch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); } - /**** End Subframe FE Processing ****/ + } + //printf("num_pdcch_symbols %d\n",ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); - //Trigger LLR parallelized for Slot 1 - //proc->dci_slot0_available=1; - //printf("Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); + // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); + LOG_I(PHY, "[AbsSFN %d.%d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",frame_rx,subframe_rx, + ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); + } - /**** Pdsch Procedure Slot0 ****/ - // start main thread for Pdsch Procedure (slot0) - // do procedures for C-RNTI - //printf("AbsSubframe %d.%d Pdsch Procedure (slot0)\n",frame_rx%1024,subframe_rx); - //printf("AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[ue->current_thread_id[subframe_rx]][0][0]->active); + //wait until slot1 FE is done + uint32_t wait = 0; - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]]); - } + while(proc->chan_est_slot1_available == 0) { + usleep(1); + wait++; + } - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); - } - if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active == 1) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - (ue->frame_parms.symbols_per_tti>>1)-1, - abstraction_flag); - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); - } + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->ue_front_end_stat[ue->current_thread_id[subframe_rx]]); + LOG_I(PHY, "[AbsSFN %d.%d] FULL FE Processing %5.2f \n",frame_rx,subframe_rx,ue->ue_front_end_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); + } - // do procedures for SI-RNTI - if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - (ue->frame_parms.symbols_per_tti>>1)-1, - abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); - } + /**** End Subframe FE Processing ****/ - // do procedures for SI-RNTI - if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - (ue->frame_parms.symbols_per_tti>>1)-1, - abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); - } + //Trigger LLR parallelized for Slot 1 + //proc->dci_slot0_available=1; + //printf("Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); - // do procedures for RA-RNTI - if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); - ue_pdsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - (ue->frame_parms.symbols_per_tti>>1)-1, - abstraction_flag); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); - } + /**** Pdsch Procedure Slot0 ****/ + // start main thread for Pdsch Procedure (slot0) + // do procedures for C-RNTI + //printf("AbsSubframe %d.%d Pdsch Procedure (slot0)\n",frame_rx%1024,subframe_rx); + //printf("AbsSubframe %d.%d Pdsch Procedure PDSCH Active %d \n",frame_rx%1024,subframe_rx, ue->dlsch[ue->current_thread_id[subframe_rx]][0][0]->active); - // LLR linear - proc->dci_slot0_available=1; - //printf("Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]]); + } + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); + } - if (LOG_DEBUGFLAG(UE_TIMING)){ - stop_meas(&ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); - LOG_I(PHY, "[AbsSFN %d.%d] Slot0: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); - } + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active == 1) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + (ue->frame_parms.symbols_per_tti>>1)-1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + } + // do procedures for SI-RNTI + if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + (ue->frame_parms.symbols_per_tti>>1)-1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); + } - //wait until LLR Slot1 is done - wait = 0; - while(proc->llr_slot1_available == 0) - { - usleep(1); - wait++; - } + // do procedures for SI-RNTI + if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + (ue->frame_parms.symbols_per_tti>>1)-1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); + } + // do procedures for RA-RNTI + if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); + ue_pdsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + (ue->frame_parms.symbols_per_tti>>1)-1, + abstraction_flag); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); + } + // LLR linear + proc->dci_slot0_available=1; + //printf("Set available dci slot0 to 1 AbsSubframe %d.%d \n",frame_rx%1024,subframe_rx); - if (LOG_DEBUGFLAG(UE_TIMING)){ - stop_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] Full LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); - } + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0]); + LOG_I(PHY, "[AbsSFN %d.%d] Slot0: LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_per_slot_stat[ue->current_thread_id[subframe_rx]][0].p_time/(cpuf*1000.0)); + } + //wait until LLR Slot1 is done + wait = 0; - //=====================================================================// - if (LOG_DEBUGFLAG(UE_TIMING)){ - start_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]]); - } + while(proc->llr_slot1_available == 0) { + usleep(1); + wait++; + } - LOG_D(PHY,"==> Start Turbo Decoder active dlsch %d SI %d RA %d \n",ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active, - ue->dlsch_SI[eNB_id]->active, - //ue->dlsch_p[eNB_id]->active, - ue->dlsch_ra[eNB_id]->active); - // Start Turbo decoder - if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active == 1) { - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - ue_dlsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1], - &ue->dlsch_errors[eNB_id], - mode, - abstraction_flag); - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); - } + if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]]); + LOG_I(PHY, "[AbsSFN %d.%d] Full LLR Computation %5.2f \n",frame_rx,subframe_rx,ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); + } - // do procedures for SI-RNTI - if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { - ue_dlsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - &ue->dlsch_SI_errors[eNB_id], - mode, - abstraction_flag); - ue->dlsch_SI[eNB_id]->active = 0; - } + //=====================================================================// + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]]); + } - // do procedures for P-RNTI - if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { - ue_dlsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - &ue->dlsch_p_errors[eNB_id], - mode, - abstraction_flag); - ue->dlsch_p[eNB_id]->active = 0; - } - // do procedures for RA-RNTI - if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { - ue_dlsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - &ue->dlsch_ra_errors[eNB_id], - mode, - abstraction_flag); - ue->dlsch_ra[eNB_id]->active = 0; - } + LOG_D(PHY,"==> Start Turbo Decoder active dlsch %d SI %d RA %d \n",ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active, + ue->dlsch_SI[eNB_id]->active, + //ue->dlsch_p[eNB_id]->active, + ue->dlsch_ra[eNB_id]->active); - if (LOG_DEBUGFLAG(UE_TIMING) - stop_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "[AbsSFN %d.%d] Channel Decoder: %5.2f \n",frame_rx,subframe_rx,ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); - } + // Start Turbo decoder + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active == 1) { + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); + ue_dlsch_procedures(ue, + proc, + eNB_id, + PDSCH, + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1], + &ue->dlsch_errors[eNB_id], + mode, + abstraction_flag); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); + } - // duplicate harq structure - uint8_t current_harq_pid = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid; - LTE_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[current_harq_pid]; - harq_status_t *current_harq_ack = &ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_ack[subframe_rx]; + // do procedures for SI-RNTI + if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + &ue->dlsch_SI_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_SI[eNB_id]->active = 0; + } - // For Debug parallelisation - //if (current_harq_ack->ack == 0) { - //printf("[slot0 dl processing][End of Channel Decoding] AbsSubframe %d.%d Decode Fail for HarqId%d Round%d\n",frame_rx,subframe_rx,current_harq_pid,current_harq_processes->round); - //} - for(uint8_t rx_th_idx=1; rx_th_idx<RX_NB_TH; rx_th_idx++) - { - LTE_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[ue->current_thread_id[(subframe_rx+rx_th_idx)%10]][eNB_id][0]->harq_processes[current_harq_pid]; - harq_status_t *harq_ack_dest = &ue->dlsch[ue->current_thread_id[(subframe_rx+rx_th_idx)%10]][eNB_id][0]->harq_ack[subframe_rx]; + // do procedures for P-RNTI + if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + &ue->dlsch_p_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_p[eNB_id]->active = 0; + } - copy_harq_proc_struct(harq_processes_dest, current_harq_processes); - copy_ack_struct(harq_ack_dest, current_harq_ack); + // do procedures for RA-RNTI + if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { + ue_dlsch_procedures(ue, + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + &ue->dlsch_ra_errors[eNB_id], + mode, + abstraction_flag); + ue->dlsch_ra[eNB_id]->active = 0; + } - } - /* - LTE_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[(subframe_rx+1)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; - LTE_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[(subframe_rx+2)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; + if (LOG_DEBUGFLAG(UE_TIMING) + stop_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]]); + LOG_I(PHY, "[AbsSFN %d.%d] Channel Decoder: %5.2f \n",frame_rx,subframe_rx,ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); +} - harq_status_t *current_harq_ack = &ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; - harq_status_t *harq_ack_dest = &ue->dlsch[(subframe_rx+1)%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; - harq_status_t *harq_ack_dest1 = &ue->dlsch[(subframe_rx+2)%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; +// duplicate harq structure +uint8_t current_harq_pid = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid; +LTE_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[current_harq_pid]; +harq_status_t *current_harq_ack = &ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_ack[subframe_rx]; + +// For Debug parallelisation +//if (current_harq_ack->ack == 0) { +//printf("[slot0 dl processing][End of Channel Decoding] AbsSubframe %d.%d Decode Fail for HarqId%d Round%d\n",frame_rx,subframe_rx,current_harq_pid,current_harq_processes->round); +//} +for(uint8_t rx_th_idx=1; rx_th_idx<RX_NB_TH; rx_th_idx++) { + LTE_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[ue->current_thread_id[(subframe_rx+rx_th_idx)%10]][eNB_id][0]->harq_processes[current_harq_pid]; + harq_status_t *harq_ack_dest = &ue->dlsch[ue->current_thread_id[(subframe_rx+rx_th_idx)%10]][eNB_id][0]->harq_ack[subframe_rx]; + copy_harq_proc_struct(harq_processes_dest, current_harq_processes); + copy_ack_struct(harq_ack_dest, current_harq_ack); +} - copy_harq_proc_struct(harq_processes_dest, current_harq_processes); - copy_ack_struct(harq_ack_dest, current_harq_ack); +/* +LTE_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[(subframe_rx+1)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; +LTE_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[(subframe_rx+2)%RX_NB_TH][eNB_id][0]->harq_processes[current_harq_pid]; - copy_harq_proc_struct(harq_processes_dest1, current_harq_processes); - copy_ack_struct(harq_ack_dest1, current_harq_ack); - */ - if (subframe_rx==9) { - if (frame_rx % 10 == 0) { - if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) - ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); +harq_status_t *current_harq_ack = &ue->dlsch[subframe_rx%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; +harq_status_t *harq_ack_dest = &ue->dlsch[(subframe_rx+1)%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; +harq_status_t *harq_ack_dest1 = &ue->dlsch[(subframe_rx+2)%RX_NB_TH][eNB_id][0]->harq_ack[subframe_rx]; - ue->dlsch_errors_last[eNB_id] = ue->dlsch_errors[eNB_id]; - ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_id]; - } +copy_harq_proc_struct(harq_processes_dest, current_harq_processes); +copy_ack_struct(harq_ack_dest, current_harq_ack); +copy_harq_proc_struct(harq_processes_dest1, current_harq_processes); +copy_ack_struct(harq_ack_dest1, current_harq_ack); +*/ +if (subframe_rx==9) { + if (frame_rx % 10 == 0) { + if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) + ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); - ue->bitrate[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100; - ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_id]; - LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", - ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], - ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); + ue->dlsch_errors_last[eNB_id] = ue->dlsch_errors[eNB_id]; + ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_id]; + } + ue->bitrate[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100; + ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_id]; + LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", + ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], + ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); #if UE_AUTOTEST_TRACE - if ((frame_rx % 100 == 0)) { - LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx); - } -#endif - } + if ((frame_rx % 100 == 0)) { + LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx); + } + +#endif +} - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); +VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_OUT); - if (LOG_DEBUGFLAG(UE_TIMING)){ - stop_meas(&ue->phy_proc_rx[ue->current_thread_id[subframe_rx]]); - LOG_I(PHY, "------FULL RX PROC [AbsSFN %d.%d]: %5.2f ------\n",frame_rx,subframe_rx,ue->phy_proc_rx[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); - } +if (LOG_DEBUGFLAG(UE_TIMING)) { + stop_meas(&ue->phy_proc_rx[ue->current_thread_id[subframe_rx]]); + LOG_I(PHY, "------FULL RX PROC [AbsSFN %d.%d]: %5.2f ------\n",frame_rx,subframe_rx,ue->phy_proc_rx[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); +} - LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); - return (0); +LOG_D(PHY," ****** end RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); +return (0); } #endif /*UE_SLOT_PARALLELISATION */ void phy_procedures_UE_SL_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc) { - - } int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, - uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { - + uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { int l,l2; int pilot1; int pmch_flag=0; int frame_rx = proc->frame_rx; int subframe_rx = proc->subframe_rx; - uint8_t next1_thread_id = ue->current_thread_id[subframe_rx]== (RX_NB_TH-1) ? 0:(ue->current_thread_id[subframe_rx]+1); uint8_t next2_thread_id = next1_thread_id== (RX_NB_TH-1) ? 0:(next1_thread_id+1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_FUNCTION_IN); - - T(T_UE_PHY_DL_TICK, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx)); - T(T_UE_PHY_INPUT_SIGNAL, T_INT(ue->Mod_id), T_INT(frame_rx%1024), T_INT(subframe_rx), T_INT(0), T_BUFFER(&ue->common_vars.rxdata[0][subframe_rx*ue->frame_parms.samples_per_tti], ue->frame_parms.samples_per_tti * 4)); - // start timers if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { LOG_I(PHY," ****** start RX-Chain for AbsSubframe %d.%d ****** \n", frame_rx%1024, subframe_rx); @@ -4638,23 +4310,26 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, pmch_flag = is_pmch_subframe(frame_rx,subframe_rx,&ue->frame_parms) ? 1 : 0; if (do_pdcch_flag) { - // deactivate reception until we scan pdcch - if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]) - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active = 0; - if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]) - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]->active = 0; + // deactivate reception until we scan pdcch + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]) + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active = 0; - if (ue->dlsch_SI[eNB_id]) - ue->dlsch_SI[eNB_id]->active = 0; - if (ue->dlsch_p[eNB_id]) - ue->dlsch_p[eNB_id]->active = 0; - if (ue->dlsch_ra[eNB_id]) - ue->dlsch_ra[eNB_id]->active = 0; + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]) + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1]->active = 0; + + if (ue->dlsch_SI[eNB_id]) + ue->dlsch_SI[eNB_id]->active = 0; + + if (ue->dlsch_p[eNB_id]) + ue->dlsch_p[eNB_id]->active = 0; + + if (ue->dlsch_ra[eNB_id]) + ue->dlsch_ra[eNB_id]->active = 0; } if (LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { - LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", - ue->Mod_id,frame_rx, subframe_rx); + LOG_D(PHY,"[UE %d] Frame %d subframe %d: Doing phy_procedures_UE_RX\n", + ue->Mod_id,frame_rx, subframe_rx); } if (ue->frame_parms.Ncp == 0) { // normal prefix @@ -4663,7 +4338,6 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, pilot1 = 3; } - if (subframe_select(&ue->frame_parms,subframe_rx) == SF_S) { // S-subframe, do first 5 symbols only l2 = 4; } else if (pmch_flag == 1) { // do first 2 symbols only @@ -4673,6 +4347,7 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, } int prev_subframe_rx = (subframe_rx - 1)<0? 9: (subframe_rx - 1); + if (subframe_select(&ue->frame_parms,prev_subframe_rx) != SF_DL) { //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // RX processing of symbols l=0...l2 @@ -4687,73 +4362,75 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LOG_D(PHY," ------ slot 0 Processing: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); LOG_D(PHY," ------ --> FFT/ChannelEst/PDCCH slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + for (; l<=l2; l++) { if (abstraction_flag == 0) { - if (LOG_DEBUGFLAG(UE_TIMING)) { - start_meas(&ue->ofdm_demod_stats); - } + if (LOG_DEBUGFLAG(UE_TIMING)) { + start_meas(&ue->ofdm_demod_stats); + } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); slot_fep(ue, - l, - (subframe_rx<<1), - 0, - 0, - 0); + l, + (subframe_rx<<1), + 0, + 0, + 0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->ofdm_demod_stats); - } + } } ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); if (do_pdcch_flag) { if ((l==pilot1) || - ((pmch_flag==1)&&(l==l2))) { - LOG_D(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); - - //start_meas(&ue->rx_pdcch_stats[ue->current_thread_id[subframe_rx]]); - if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); - return(-1); - } - //stop_meas(&ue->rx_pdcch_stats[ue->current_thread_id[subframe_rx]]); - //printf("subframe %d n_pdcch_sym %d pdcch procedures %5.3f \n", - // subframe_rx, ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - // (ue->rx_pdcch_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); - LOG_D(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); + ((pmch_flag==1)&&(l==l2))) { + LOG_D(PHY,"[UE %d] Frame %d: Calling pdcch procedures (eNB %d)\n",ue->Mod_id,frame_rx,eNB_id); + + //start_meas(&ue->rx_pdcch_stats[ue->current_thread_id[subframe_rx]]); + if (ue_pdcch_procedures(eNB_id,ue,proc,abstraction_flag) == -1) { + LOG_E(PHY,"[UE %d] Frame %d, subframe %d: Error in pdcch procedures\n",ue->Mod_id,frame_rx,subframe_rx); + return(-1); + } + + //stop_meas(&ue->rx_pdcch_stats[ue->current_thread_id[subframe_rx]]); + //printf("subframe %d n_pdcch_sym %d pdcch procedures %5.3f \n", + // subframe_rx, ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + // (ue->rx_pdcch_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0)); + LOG_D(PHY,"num_pdcch_symbols %d\n",ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols); } } - } // for l=1..l2 - ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); + ue_measurement_procedures(l-1,ue,proc,eNB_id,(subframe_rx<<1),abstraction_flag,mode); LOG_D(PHY," ------ end FFT/ChannelEst/PDCCH slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); // If this is PMCH, call procedures, do channel estimation for first symbol of next DL subframe and return if (pmch_flag == 1) { ue_pmch_procedures(ue,proc,eNB_id,abstraction_flag); - int next_subframe_rx = (1+subframe_rx)%10; - if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) - { + + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) { slot_fep(ue, - 0, - (next_subframe_rx<<1), - 0, - 0, - 0); + 0, + (next_subframe_rx<<1), + 0, + 0, + 0); } return 0; } slot_fep(ue, - 0, - 1+(subframe_rx<<1), - 0, - 0, - 0); + 0, + 1+(subframe_rx<<1), + 0, + 0, + 0); // first slot has been processed (FFTs + Channel Estimation, PCFICH/PHICH/PDCCH) if (LOG_DEBUGFLAG(UE_TIMING)) { @@ -4761,8 +4438,8 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LOG_I(PHY, "[SFN %d] Slot0: FFT + Channel Estimate + PCFICH/PHICH/PDCCH %5.2f \n",subframe_rx,ue->ue_front_end_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); } - LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + if (LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->generic_stat); start_meas(&ue->crnti_procedures_stats); @@ -4772,34 +4449,35 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active == 1) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); - + proc, + eNB_id, + PDSCH, + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->crnti_procedures_stats); } + LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + // do procedures for SI-RNTI if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_SI, VCD_FUNCTION_OUT); } @@ -4807,14 +4485,14 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_P, VCD_FUNCTION_OUT); } @@ -4822,14 +4500,14 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_IN); ue_pdsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, - ue->frame_parms.symbols_per_tti>>1, - abstraction_flag); + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + ue->pdcch_vars[ue->current_thread_id[subframe_rx]][eNB_id]->num_pdcch_symbols, + ue->frame_parms.symbols_per_tti>>1, + abstraction_flag); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC_RA, VCD_FUNCTION_OUT); } @@ -4842,36 +4520,38 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, if (LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->ofdm_demod_stats); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); - slot_fep(ue, - l, - 1+(subframe_rx<<1), - 0, - 0, - 0); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_IN); + slot_fep(ue, + l, + 1+(subframe_rx<<1), + 0, + 0, + 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP, VCD_FUNCTION_OUT); + if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->ofdm_demod_stats); } } ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); - } // for l=1..l2 - ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); + ue_measurement_procedures(l-1,ue,proc,eNB_id,1+(subframe_rx<<1),abstraction_flag,mode); // do first symbol of next downlink subframe for channel estimation int next_subframe_rx = (1+subframe_rx)%10; - if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) - { + + if (subframe_select(&ue->frame_parms,next_subframe_rx) != SF_UL) { slot_fep(ue, - 0, - (next_subframe_rx<<1), - 0, - 0, - 0); + 0, + (next_subframe_rx<<1), + 0, + 0, + 0); } } // not an S-subframe + if(LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->generic_stat); LOG_I(PHY, "[SFN %d] Slot1: FFT + Channel Estimate + Pdsch Proc Slot0 %5.2f \n",subframe_rx,ue->generic_stat.p_time/(cpuf*1000.0)); @@ -4879,186 +4559,179 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, LOG_D(PHY," ------ end FFT/ChannelEst/PDCCH slot 1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) - { + if ( (subframe_rx == 0) && (ue->decode_MIB == 1)) { ue_pbch_procedures(eNB_id,ue,proc,abstraction_flag); } - - // do procedures for C-RNTI LOG_D(PHY," ------ --> PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); + if (ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->active == 1) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_IN); - if (LOG_DEBUGFLAG(UE_TIMING)) { + + if (LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]]); } + ue_pdsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); + proc, + eNB_id, + PDSCH, + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); LOG_D(PHY," ------ end PDSCH ChannelComp/LLR slot 0: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); LOG_D(PHY," ------ --> PDSCH Turbo Decoder slot 0/1: AbsSubframe %d.%d ------ \n", frame_rx%1024, subframe_rx); - if (LOG_DEBUGFLAG(UE_TIMING)) { + + if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]]); start_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]]); } + ue_dlsch_procedures(ue, - proc, - eNB_id, - PDSCH, - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], - ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1], - &ue->dlsch_errors[eNB_id], - mode, - abstraction_flag); - if (LOG_DEBUGFLAG(UE_TIMING)) { + proc, + eNB_id, + PDSCH, + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0], + ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][1], + &ue->dlsch_errors[eNB_id], + mode, + abstraction_flag); + + if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]]); LOG_I(PHY, "[SFN %d] Slot1: Pdsch Proc %5.2f\n",subframe_rx,ue->pdsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); LOG_I(PHY, "[SFN %d] Slot0 Slot1: Dlsch Proc %5.2f\n",subframe_rx,ue->dlsch_procedures_stat[ue->current_thread_id[subframe_rx]].p_time/(cpuf*1000.0)); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); - } + if (LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->generic_stat); } if (LOG_DUMPFLAG(DEBUG_UE_PHYPROC)) { - if(subframe_rx==5 && ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid]->nb_rb > 20){ - //LOG_M("decoder_llr.m","decllr",dlsch_llr,G,1,0); - //LOG_M("llr.m","llr", &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); - - LOG_M("rxdataF0_current.m" , "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - //LOG_M("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - - //LOG_M("rxdataF0_previous.m" , "rxdataF0_prev", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - - LOG_M("dl_ch_estimates.m", "dl_ch_estimates_sfn5", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].dl_ch_estimates[0][0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); - LOG_M("dl_ch_estimates_ext.m", "dl_ch_estimatesExt_sfn5", &ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->dl_ch_estimates_ext[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); - LOG_M("rxdataF_comp00.m","rxdataF_comp00", &ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->rxdataF_comp0[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); - //LOG_M("magDLFirst.m", "magDLFirst", &phy_vars_ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->dl_ch_mag0[0][0],14*frame_parms->N_RB_DL*12,1,1); - //LOG_M("magDLSecond.m", "magDLSecond", &phy_vars_ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->dl_ch_magb0[0][0],14*frame_parms->N_RB_DL*12,1,1); - - AssertFatal (0,""); + if(subframe_rx==5 && ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid]->nb_rb > 20) { + //LOG_M("decoder_llr.m","decllr",dlsch_llr,G,1,0); + //LOG_M("llr.m","llr", &ue->pdsch_vars[eNB_id]->llr[0][0],(14*nb_rb*12*dlsch1_harq->Qm) - 4*(nb_rb*4*dlsch1_harq->Qm),1,0); + LOG_M("rxdataF0_current.m", "rxdataF0", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); + //LOG_M("rxdataF0_previous.m" , "rxdataF0_prev_sss", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); + //LOG_M("rxdataF0_previous.m" , "rxdataF0_prev", &ue->common_vars.common_vars_rx_data_per_thread[next_thread_id].rxdataF[0][0],14*ue->frame_parms.ofdm_symbol_size,1,1); + LOG_M("dl_ch_estimates.m", "dl_ch_estimates_sfn5", &ue->common_vars.common_vars_rx_data_per_thread[ue->current_thread_id[subframe_rx]].dl_ch_estimates[0][0][0],14*ue->frame_parms.ofdm_symbol_size,1, + 1); + LOG_M("dl_ch_estimates_ext.m", "dl_ch_estimatesExt_sfn5", &ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->dl_ch_estimates_ext[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); + LOG_M("rxdataF_comp00.m","rxdataF_comp00", &ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->rxdataF_comp0[0][0],14*ue->frame_parms.N_RB_DL*12,1,1); + //LOG_M("magDLFirst.m", "magDLFirst", &phy_vars_ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->dl_ch_mag0[0][0],14*frame_parms->N_RB_DL*12,1,1); + //LOG_M("magDLSecond.m", "magDLSecond", &phy_vars_ue->pdsch_vars[ue->current_thread_id[subframe_rx]][0]->dl_ch_magb0[0][0],14*frame_parms->N_RB_DL*12,1,1); + AssertFatal (0,""); } } // do procedures for SI-RNTI if ((ue->dlsch_SI[eNB_id]) && (ue->dlsch_SI[eNB_id]->active == 1)) { ue_pdsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); ue_dlsch_procedures(ue, - proc, - eNB_id, - SI_PDSCH, - ue->dlsch_SI[eNB_id], - NULL, - &ue->dlsch_SI_errors[eNB_id], - mode, - abstraction_flag); + proc, + eNB_id, + SI_PDSCH, + ue->dlsch_SI[eNB_id], + NULL, + &ue->dlsch_SI_errors[eNB_id], + mode, + abstraction_flag); ue->dlsch_SI[eNB_id]->active = 0; } // do procedures for P-RNTI if ((ue->dlsch_p[eNB_id]) && (ue->dlsch_p[eNB_id]->active == 1)) { ue_pdsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); - + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); ue_dlsch_procedures(ue, - proc, - eNB_id, - P_PDSCH, - ue->dlsch_p[eNB_id], - NULL, - &ue->dlsch_p_errors[eNB_id], - mode, - abstraction_flag); + proc, + eNB_id, + P_PDSCH, + ue->dlsch_p[eNB_id], + NULL, + &ue->dlsch_p_errors[eNB_id], + mode, + abstraction_flag); ue->dlsch_p[eNB_id]->active = 0; } + // do procedures for RA-RNTI if ((ue->dlsch_ra[eNB_id]) && (ue->dlsch_ra[eNB_id]->active == 1)) { ue_pdsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - 1+(ue->frame_parms.symbols_per_tti>>1), - ue->frame_parms.symbols_per_tti-1, - abstraction_flag); + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + 1+(ue->frame_parms.symbols_per_tti>>1), + ue->frame_parms.symbols_per_tti-1, + abstraction_flag); ue_dlsch_procedures(ue, - proc, - eNB_id, - RA_PDSCH, - ue->dlsch_ra[eNB_id], - NULL, - &ue->dlsch_ra_errors[eNB_id], - mode, - abstraction_flag); + proc, + eNB_id, + RA_PDSCH, + ue->dlsch_ra[eNB_id], + NULL, + &ue->dlsch_ra_errors[eNB_id], + mode, + abstraction_flag); ue->dlsch_ra[eNB_id]->active = 0; } // duplicate harq structure - uint8_t current_harq_pid = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->current_harq_pid; LTE_DL_UE_HARQ_t *current_harq_processes = ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_processes[current_harq_pid]; LTE_DL_UE_HARQ_t *harq_processes_dest = ue->dlsch[next1_thread_id][eNB_id][0]->harq_processes[current_harq_pid]; LTE_DL_UE_HARQ_t *harq_processes_dest1 = ue->dlsch[next2_thread_id][eNB_id][0]->harq_processes[current_harq_pid]; - harq_status_t *current_harq_ack = &ue->dlsch[ue->current_thread_id[subframe_rx]][eNB_id][0]->harq_ack[subframe_rx]; harq_status_t *harq_ack_dest = &ue->dlsch[next1_thread_id][eNB_id][0]->harq_ack[subframe_rx]; harq_status_t *harq_ack_dest1 = &ue->dlsch[next2_thread_id][eNB_id][0]->harq_ack[subframe_rx]; - copy_harq_proc_struct(harq_processes_dest, current_harq_processes); copy_ack_struct(harq_ack_dest, current_harq_ack); - copy_harq_proc_struct(harq_processes_dest1, current_harq_processes); copy_ack_struct(harq_ack_dest1, current_harq_ack); if (subframe_rx==9) { if (frame_rx % 10 == 0) { if ((ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]) != 0) - ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); + ue->dlsch_fer[eNB_id] = (100*(ue->dlsch_errors[eNB_id] - ue->dlsch_errors_last[eNB_id]))/(ue->dlsch_received[eNB_id] - ue->dlsch_received_last[eNB_id]); ue->dlsch_errors_last[eNB_id] = ue->dlsch_errors[eNB_id]; ue->dlsch_received_last[eNB_id] = ue->dlsch_received[eNB_id]; } - ue->bitrate[eNB_id] = (ue->total_TBS[eNB_id] - ue->total_TBS_last[eNB_id])*100; ue->total_TBS_last[eNB_id] = ue->total_TBS[eNB_id]; LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n", - ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], - ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); + ue->Mod_id,frame_rx,ue->total_TBS[eNB_id], + ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0); if ( LOG_DEBUGFLAG(DEBUG_UE_PHYPROC)) { if ((frame_rx % 100 == 0)) { LOG_UI(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx); } } - } if ( LOG_DEBUGFLAG(UE_TIMING)) { @@ -5079,19 +4752,15 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id, -void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) -{ +void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag,uint8_t do_pdcch_flag,runmode_t mode) { #if defined(ENABLE_ITTI) MessageDef *msg_p; int result; #endif - int frame_rx = proc->frame_rx; int frame_tx = proc->frame_tx; int subframe_rx = proc->subframe_rx; int subframe_tx = proc->subframe_tx; - - UE_L2_STATE_t ret; int slot; @@ -5099,8 +4768,8 @@ void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,u ue->UE_mode[eNB_id]=PUSCH; } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,1); + if ( LOG_DEBUGFLAG(UE_TIMING)) { start_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]); } @@ -5113,15 +4782,14 @@ void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,u if (msg_p != NULL) { switch (ITTI_MSG_ID(msg_p)) { - case PHY_FIND_CELL_REQ: - LOG_I(PHY, "[UE %d] Received %s\n", ITTI_MSG_INSTANCE (msg_p) - NB_eNB_INST, ITTI_MSG_NAME (msg_p)); - - /* TODO process the message */ - break; + case PHY_FIND_CELL_REQ: + LOG_I(PHY, "[UE %d] Received %s\n", ITTI_MSG_INSTANCE (msg_p) - NB_eNB_INST, ITTI_MSG_NAME (msg_p)); + /* TODO process the message */ + break; - default: - LOG_E(PHY, "[UE %d] Received unexpected message %s\n", ITTI_MSG_INSTANCE (msg_p) - NB_eNB_INST, ITTI_MSG_NAME (msg_p)); - break; + default: + LOG_E(PHY, "[UE %d] Received unexpected message %s\n", ITTI_MSG_INSTANCE (msg_p) - NB_eNB_INST, ITTI_MSG_NAME (msg_p)); + break; } result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); @@ -5131,62 +4799,61 @@ void phy_procedures_UE_lte(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,u #endif - for (slot=0;slot<2;slot++) { - + for (slot=0; slot<2; slot++) { if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_UL)|| - (ue->frame_parms.frame_type == FDD)) { + (ue->frame_parms.frame_type == FDD)) { phy_procedures_UE_TX(ue,proc,eNB_id,abstraction_flag,mode); } if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_DL) || - (ue->frame_parms.frame_type == FDD)) { + (ue->frame_parms.frame_type == FDD)) { phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); } if ((subframe_select(&ue->frame_parms,subframe_tx)==SF_S) && - (slot==1)) { + (slot==1)) { phy_procedures_UE_S_TX(ue,eNB_id,abstraction_flag); } if ((subframe_select(&ue->frame_parms,subframe_rx)==SF_S) && - (slot==0)) { - phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); + (slot==0)) { + phy_procedures_UE_RX(ue,proc,eNB_id,abstraction_flag,do_pdcch_flag,mode); } if (ue->mac_enabled==1) { if (slot==0) { - - //LOG_I(PHY,"[UE %d] Frame %d, subframe %d, star ue_scheduler\n", ue->Mod_id,frame_rx,subframe_tx); + //LOG_I(PHY,"[UE %d] Frame %d, subframe %d, star ue_scheduler\n", ue->Mod_id,frame_rx,subframe_tx); ret = ue_scheduler(ue->Mod_id, - frame_rx, - subframe_rx, - frame_tx, - subframe_tx, - subframe_select(&ue->frame_parms,subframe_tx), - eNB_id, - 0/*FIXME CC_id*/); - - if (ret == CONNECTION_LOST) { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, returning to PRACH\n",ue->Mod_id, - frame_rx,subframe_tx); - ue->UE_mode[eNB_id] = PRACH; - // mac_xface->macphy_exit("Connection lost"); - } else if (ret == PHY_RESYNCH) { - LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, trying to resynch\n", - ue->Mod_id, - frame_rx,subframe_tx); - ue->UE_mode[eNB_id] = RESYNCH; - // mac_xface->macphy_exit("Connection lost"); - } else if (ret == PHY_HO_PRACH) { - LOG_I(PHY,"[UE %d] Frame %d, subframe %d, return to PRACH and perform a contention-free access\n", - ue->Mod_id,frame_rx,subframe_tx); - ue->UE_mode[eNB_id] = PRACH; - } + frame_rx, + subframe_rx, + frame_tx, + subframe_tx, + subframe_select(&ue->frame_parms,subframe_tx), + eNB_id, + 0/*FIXME CC_id*/); + + if (ret == CONNECTION_LOST) { + LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, returning to PRACH\n",ue->Mod_id, + frame_rx,subframe_tx); + ue->UE_mode[eNB_id] = PRACH; + // mac_xface->macphy_exit("Connection lost"); + } else if (ret == PHY_RESYNCH) { + LOG_E(PHY,"[UE %d] Frame %d, subframe %d RRC Connection lost, trying to resynch\n", + ue->Mod_id, + frame_rx,subframe_tx); + ue->UE_mode[eNB_id] = RESYNCH; + // mac_xface->macphy_exit("Connection lost"); + } else if (ret == PHY_HO_PRACH) { + LOG_I(PHY,"[UE %d] Frame %d, subframe %d, return to PRACH and perform a contention-free access\n", + ue->Mod_id,frame_rx,subframe_tx); + ue->UE_mode[eNB_id] = PRACH; + } } } - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_LTE,0); - if (LOG_DEBUGFLAG(UE_TIMING)) { + + if (LOG_DEBUGFLAG(UE_TIMING)) { stop_meas(&ue->phy_proc[ue->current_thread_id[subframe_rx]]); } } // slot diff --git a/openair1/SIMULATION/LTE_PHY/common_sim.h b/openair1/SIMULATION/LTE_PHY/common_sim.h index 46f4cdf1611de6aecebbbcaeaa09d9ba01e5956d..e9ad4dc888f8573874d8aa1f8d4bf271978d8196 100644 --- a/openair1/SIMULATION/LTE_PHY/common_sim.h +++ b/openair1/SIMULATION/LTE_PHY/common_sim.h @@ -49,38 +49,46 @@ void sumUpStatsSlot(time_stats_t *res, time_stats_t src[RX_NB_TH][2], int lastAc res->p_time=src[lastActive][last].p_time; } -void printStatIndent(time_stats_t *ptr, char *txt) { - printf("|__ %-50s %.2f us (%d trials)\n", +double squareRoot(time_stats_t *ptr) { + double timeBase=1/(1000*cpu_freq_GHz); + return sqrt((double)ptr->diff_square*pow(timeBase,2)/ptr->trials - + pow((double)ptr->diff/ptr->trials*timeBase,2)); +} + +void printDistribution(time_stats_t *ptr, varArray_t *sortedList, char *txt) { + double timeBase=1/(1000*cpu_freq_GHz); + printf("%-43s %6.2f us (%d trials)\n", txt, - ptr->trials?inMicroS(ptr->diff/ptr->trials):0, + (double)ptr->diff/ptr->trials*timeBase, ptr->trials); + printf(" Statistics std=%.2f, median=%.2f, q1=%.2f, q3=%.2f µs (on %ld trials)\n", + squareRoot(ptr), median(sortedList),q1(sortedList),q3(sortedList), sortedList->size); } -void printStatIndent2(time_stats_t *ptr, char *txt, int turbo_iter) { - double timeBase=1/(1000*cpu_freq_GHz); - printf(" |__ %-45s %.2f us (cycles/block %ld, %5d trials)\n", +void printStatIndent(time_stats_t *ptr, char *txt) { + printf("|__ %-38s %6.2f us (%3d trials)\n", txt, - ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, - turbo_iter?(uint64_t)round(((double)ptr->diff)/turbo_iter):0, + ptr->trials?inMicroS(ptr->diff/ptr->trials):0, ptr->trials); } -double squareRoot(time_stats_t *ptr) { +void printStatIndent2(time_stats_t *ptr, char *txt) { double timeBase=1/(1000*cpu_freq_GHz); - return sqrt((double)ptr->diff_square*pow(timeBase,2)/ptr->trials - - pow((double)ptr->diff/ptr->trials*timeBase,2)); + printf(" |__ %-34s %6.2f us (%3d trials)\n", + txt, + ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, + ptr->trials); } -void printDistribution(time_stats_t *ptr, varArray_t *sortedList, char *txt) { +void printStatIndent3(time_stats_t *ptr, char *txt) { double timeBase=1/(1000*cpu_freq_GHz); - printf("%-50s :%.2f us (%d trials)\n", + printf(" |__ %-30s %6.2f us (%3d trials)\n", txt, - (double)ptr->diff/ptr->trials*timeBase, - ptr->trials); - printf("|__ Statistics std=%.2f, median=%.2f, q1=%.2f, q3=%.2f µs (on %ld trials)\n", - squareRoot(ptr), median(sortedList),q1(sortedList),q3(sortedList), sortedList->size); + ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, + ptr->trials); } + void logDistribution(FILE* fd, time_stats_t *ptr, varArray_t *sortedList, int dropped) { fprintf(fd,"%f;%f;%f;%f;%f;%f;%d;", squareRoot(ptr), diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 246bdd70078dd2d761199c640e17ed5dbdf8c39f..faf1b5b87a583ae9bb126343a0f888edcf9a5d0b 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -85,30 +85,7 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ -char *parallel_config = NULL; -char *worker_config = NULL; -static THREAD_STRUCT thread_struct; -void set_parallel_conf(char *parallel_conf) -{ - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) -{ - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) -{ - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) -{ - return thread_struct.worker_conf; -} +THREAD_STRUCT thread_struct; int emulate_rf = 0; @@ -715,7 +692,7 @@ int main(int argc, char **argv) DL_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdu_list; TX_req.tx_request_body.tx_pdu_list = tx_pdu_list; - + set_parallel_conf("PARALLEL_SINGLE_THREAD"); cpuf = cpu_freq_GHz; //signal(SIGSEGV, handler); @@ -758,6 +735,7 @@ int main(int argc, char **argv) { "Subframe", "subframe ",0, iptr:&subframe, defintval:7, TYPE_INT, 0 }, { "Trnti", "rnti",0, u16ptr:&n_rnti, defuintval:0x1234, TYPE_UINT16, 0 }, { "vi_mod", "i_mod",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, + { "Qparallel", "Enable parallel execution",0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0 }, { "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:&print_perf, defintval:0, TYPE_INT, 0 }, { "q_tx_port", "Number of TX antennas ports used in eNB",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "uEdual", "Enables the Interference Aware Receiver for TM5 (default is normal receiver)",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, @@ -965,6 +943,10 @@ int main(int argc, char **argv) break; + case 'Q': + set_parallel_conf(optarg); + break; + default: printf("Wrong option: %s\n",long_options[option_index].name); exit(1); @@ -982,8 +964,8 @@ int main(int argc, char **argv) if (help) exit(0); - set_parallel_conf("PARALLEL_RU_L1_TRX_SPLIT"); - set_worker_conf("WORKER_ENABLE"); + if (thread_struct.parallel_conf != PARALLEL_SINGLE_THREAD) + set_worker_conf("WORKER_ENABLE"); if (transmission_mode>1) pa=dBm3; printf("dlsim: tmode %d, pa %d\n",transmission_mode,pa); @@ -1079,11 +1061,7 @@ int main(int argc, char **argv) ru->do_precoding=1; eNB->mac_enabled=1; - if (two_thread_flag == 0) { - eNB->te = dlsch_encoding; - } - else { - eNB->te = dlsch_encoding_2threads; + if(get_thread_worker_conf() == WORKER_ENABLE) { extern void init_td_thread(PHY_VARS_eNB *); extern void init_te_thread(PHY_VARS_eNB *); init_td_thread(eNB); @@ -1442,6 +1420,8 @@ int main(int argc, char **argv) reset_meas(&eNB->dlsch_interleaving_stats); reset_meas(&eNB->dlsch_rate_matching_stats); reset_meas(&eNB->dlsch_turbo_encoding_stats); + reset_meas(&eNB->dlsch_common_and_dci); + reset_meas(&eNB->dlsch_ue_specific); for (int i=0; i<RX_NB_TH; i++) { reset_meas(&UE->phy_proc_rx[i]); // total UE rx reset_meas(&UE->ue_front_end_stat[i]); @@ -1783,9 +1763,6 @@ int main(int argc, char **argv) } - - - if (UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->harq_ack[subframe].ack == 1) { avg_iter += UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->last_iteration_cnt; @@ -2011,21 +1988,22 @@ int main(int argc, char **argv) printf("\neNB TX function statistics (per 1ms subframe)\n"); printDistribution(&eNB->phy_proc_tx,table_tx,"PHY proc tx"); printStatIndent(&eNB->dlsch_common_and_dci,"DL common channels and dci time"); - printStatIndent(&eNB->dlsch_encoding_stats,"DLSCH encoding time"); - printStatIndent2(&eNB->dlsch_rate_matching_stats,"DLSCH rate matching time",eNB->dlsch_rate_matching_stats.trials); - printStatIndent2(&eNB->dlsch_turbo_encoding_stats,"DLSCH turbo encoding time", eNB->dlsch_turbo_encoding_stats.trials); - printStatIndent2(&eNB->dlsch_interleaving_stats,"DLSCH interleaving time", eNB->dlsch_interleaving_stats.trials); - printStatIndent(&eNB->dlsch_scrambling_stats, "DLSCH scrambling time"); - printStatIndent(&eNB->dlsch_modulation_stats, "DLSCH modulation time"); + printStatIndent(&eNB->dlsch_ue_specific,"DL per ue part time"); + printStatIndent2(&eNB->dlsch_encoding_stats,"DLSCH encoding time"); + printStatIndent3(&eNB->dlsch_rate_matching_stats,"DLSCH rate matching time"); + printStatIndent3(&eNB->dlsch_turbo_encoding_stats,"DLSCH turbo encoding time"); + printStatIndent3(&eNB->dlsch_interleaving_stats,"DLSCH interleaving time"); + printStatIndent2(&eNB->dlsch_scrambling_stats, "DLSCH scrambling time"); + printStatIndent2(&eNB->dlsch_modulation_stats, "DLSCH modulation time"); printDistribution(&eNB->ofdm_mod_stats,table_tx_ifft,"OFDM_mod (idft) time"); printf("\nUE RX function statistics (per 1ms subframe)\n"); printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx"); printStatIndent(&ue_front_end_tot,"Front end processing"); printStatIndent(&dlsch_llr_tot,"rx_pdsch processing"); - printStatIndent2(&pdsch_procedures_tot,"pdsch processing", pdsch_procedures_tot.trials); - printStatIndent2(&dlsch_procedures_tot,"dlsch processing", dlsch_procedures_tot.trials); - printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing", UE->crnti_procedures_stats.trials); + printStatIndent2(&pdsch_procedures_tot,"pdsch processing"); + printStatIndent2(&dlsch_procedures_tot,"dlsch processing"); + printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing"); printStatIndent(&UE->ofdm_demod_stats,"ofdm demodulation"); printStatIndent(&UE->dlsch_channel_estimation_stats,"DLSCH channel estimation time"); printStatIndent(&UE->dlsch_freq_offset_estimation_stats,"DLSCH frequency offset estimation time"); @@ -2041,13 +2019,13 @@ int main(int argc, char **argv) (double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials*timeBase, (int)((double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials), UE->dlsch_turbo_decoding_stats.trials); - printStatIndent2(&UE->dlsch_tc_init_stats,"init", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_beta_stats,"beta", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_ext_stats,"ext", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver", UE->dlsch_tc_init_stats.trials); - printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC", UE->dlsch_tc_init_stats.trials); + printStatIndent2(&UE->dlsch_tc_init_stats,"init"); + printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha"); + printStatIndent2(&UE->dlsch_tc_beta_stats,"beta"); + printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma"); + printStatIndent2(&UE->dlsch_tc_ext_stats,"ext"); + printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver"); + printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC"); } diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 53a2c22f15d0378200d696abcdfabd28d539e506..75b3486f240f1200376eb2df81054b5e5a06440c 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -96,30 +96,7 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU]; nfapi_tx_request_t TX_req; Sched_Rsp_t sched_resp; -char *parallel_config = NULL; -char *worker_config = NULL; -static THREAD_STRUCT thread_struct; -void set_parallel_conf(char *parallel_conf) -{ - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) -{ - if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE; - printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) -{ - return thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) -{ - return thread_struct.worker_conf; -} +THREAD_STRUCT thread_struct; void fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu, @@ -410,7 +387,6 @@ int main(int argc, char **argv) { double effective_rate=0.0; char channel_model_input[10]= {0}; static int max_turbo_iterations=4; - static int parallel_flag=0; int nb_rb_set = 0; int sf; static int threequarter_fs=0; @@ -428,6 +404,8 @@ int main(int argc, char **argv) { TX_req.tx_request_body.tx_pdu_list = tx_pdu_list; cpu_freq_GHz = (double)get_cpu_freq_GHz(); cpuf = cpu_freq_GHz; + set_parallel_conf("PARALLEL_SINGLE_THREAD"); + printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz); AssertFatal(load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) != NULL, "cannot load configuration module, exiting\n"); @@ -455,7 +433,7 @@ int main(int argc, char **argv) { { "Doppler", "Maximum doppler shift",0, dblptr:&maxDoppler, defdblval:0.0, TYPE_DOUBLE, 0 }, { "Zdump", "dump table",PARAMFLAG_BOOL, iptr:&dump_table, defintval:0, TYPE_INT, 0 }, { "Forms", "Display the soft scope", PARAMFLAG_BOOL, iptr:&xforms, defintval:0, TYPE_INT, 0 }, - { "Lparallel", "Enable parallel execution", PARAMFLAG_BOOL, iptr:¶llel_flag, defintval:0, TYPE_INT, 0 }, + { "Lparallel", "Enable parallel execution",0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0 }, { "Iterations", "Number of iterations of turbo decoder", 0, iptr:&max_turbo_iterations, defintval:4, TYPE_INT, 0 }, { "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "Q_cqi", "Enable CQI", PARAMFLAG_BOOL, iptr:&cqi_flag, defintval:0, TYPE_INT, 0 }, @@ -600,6 +578,10 @@ int main(int argc, char **argv) { opp_enabled=1; break; + case 'L': + set_parallel_conf(optarg); + break; + default: printf("Wrong option: %s\n",long_options[option_index].name); exit(1); @@ -618,8 +600,8 @@ int main(int argc, char **argv) { if (help) exit(0); - set_parallel_conf("PARALLEL_RU_L1_TRX_SPLIT"); - set_worker_conf("WORKER_ENABLE"); + if (thread_struct.parallel_conf != PARALLEL_SINGLE_THREAD) + set_worker_conf("WORKER_ENABLE"); RC.nb_L1_inst = 1; RC.nb_RU = 1; lte_param_init(&eNB,&UE,&ru, @@ -767,7 +749,7 @@ int main(int argc, char **argv) { UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0); printf("ULSCH %p\n",UE->ulsch[0]); - if (parallel_flag == 1) { + if(get_thread_worker_conf() == WORKER_ENABLE) { extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_td_thread(PHY_VARS_eNB *); init_fep_thread(eNB,NULL); @@ -1175,8 +1157,7 @@ int main(int argc, char **argv) { } start_meas(&eNB->phy_proc_rx); - ru->feprx = (parallel_flag == 1) ? ru_fep_full_2thread : fep_full; - eNB->td = (parallel_flag == 1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; + ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full; ru->feprx(ru); phy_procedures_eNB_uespec_RX(eNB,proc_rxtx); stop_meas(&eNB->phy_proc_rx); @@ -1377,20 +1358,18 @@ int main(int argc, char **argv) { printStatIndent(&UE->ulsch_rate_matching_stats,"ULSCH rate-matching time"); printStatIndent(&UE->ulsch_interleaving_stats,"ULSCH sub-block interleaving"); printStatIndent(&UE->ulsch_multiplexing_stats,"ULSCH multiplexing time"); - printDistribution(&eNB->phy_proc_rx,table_rx,"\nTotal PHY proc rx subframe"); - printDistribution(&ru->ofdm_demod_stats,table_rx_fft,"OFDM_demod time"); - printDistribution(&eNB->ulsch_demodulation_stats,table_rx_demod,"ULSCH demodulation time"); - printf("ULSCH Decoding time (%.2f Mbit/s, avg iter %.2f) :%.2f us (%d trials, max %.2f)\n", - UE->ulsch[0]->harq_processes[harq_pid]->TBS/1000.0,(double)iter_trials, - (double)eNB->ulsch_decoding_stats.diff/eNB->ulsch_decoding_stats.trials*timeBase, - eNB->ulsch_decoding_stats.trials, - (double)eNB->ulsch_decoding_stats.max*timeBase); - printf("|__ Statistics std: %.2fus median %.2fus q1 %.2fus q3 %.2fus \n", - squareRoot(&eNB->ulsch_decoding_stats), - median(table_rx_dec), q1(table_rx_dec), q3(table_rx_dec)); - printStatIndent(&eNB->ulsch_deinterleaving_stats,"sub-block interleaving" ); - printStatIndent(&eNB->ulsch_demultiplexing_stats,"sub-block demultiplexing" ); - printStatIndent(&eNB->ulsch_rate_unmatching_stats,"sub-block rate-matching" ); + printf("\n"); + printDistribution(&eNB->phy_proc_rx,table_rx,"Total PHY proc rx subframe"); + printDistribution(&ru->ofdm_demod_stats,table_rx_fft,"|__ OFDM_demod time"); + printDistribution(&eNB->ulsch_demodulation_stats,table_rx_demod,"|__ ULSCH demodulation time"); + printDistribution(&eNB->ulsch_decoding_stats,table_rx_dec,"|__ ULSCH Decoding time"); + printf(" (%.2f Mbit/s, avg iter %.2f, max %.2f)\n", + UE->ulsch[0]->harq_processes[harq_pid]->TBS/1000.0, + (double)iter_trials, + (double)eNB->ulsch_decoding_stats.max*timeBase); + printStatIndent2(&eNB->ulsch_deinterleaving_stats,"sub-block interleaving" ); + printStatIndent2(&eNB->ulsch_demultiplexing_stats,"sub-block demultiplexing" ); + printStatIndent2(&eNB->ulsch_rate_unmatching_stats,"sub-block rate-matching" ); printf("|__ turbo_decoder(%d bits), avg iterations: %.1f %.2f us (%d cycles, %d trials)\n", eNB->ulsch[0]->harq_processes[harq_pid]->Cminus ? eNB->ulsch[0]->harq_processes[harq_pid]->Kminus : @@ -1399,13 +1378,13 @@ int main(int argc, char **argv) { (double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials*timeBase, (int)((double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials), eNB->ulsch_turbo_decoding_stats.trials); - printStatIndent2(&eNB->ulsch_tc_init_stats,"init", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_alpha_stats,"alpha", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_beta_stats,"beta", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_gamma_stats,"gamma", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_ext_stats,"ext", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_intl1_stats,"turbo internal interleaver", eNB->ulsch_tc_init_stats.trials); - printStatIndent2(&eNB->ulsch_tc_intl2_stats,"intl2+HardDecode+CRC", eNB->ulsch_tc_init_stats.trials); + printStatIndent3(&eNB->ulsch_tc_init_stats,"init"); + printStatIndent3(&eNB->ulsch_tc_alpha_stats,"alpha"); + printStatIndent3(&eNB->ulsch_tc_beta_stats,"beta"); + printStatIndent3(&eNB->ulsch_tc_gamma_stats,"gamma"); + printStatIndent3(&eNB->ulsch_tc_ext_stats,"ext"); + printStatIndent3(&eNB->ulsch_tc_intl1_stats,"turbo internal interleaver"); + printStatIndent3(&eNB->ulsch_tc_intl2_stats,"intl2+HardDecode+CRC"); } if(abstx) { //ABSTRACTION diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 843f6458164472eb52776c7b416682f46d069e4c..d24be0575e2bba1e3d234d743cf7ab612950d144 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -31,7 +31,7 @@ # define __PLATFORM_TYPES_H__ #if !defined(NAS_NETLINK) -#include <stdint.h> + #include <stdint.h> #endif //----------------------------------------------------------------------------- @@ -42,19 +42,19 @@ * let's protect potential redefinition */ #ifndef _BOOLEAN_T_DEFINED_ -#define _BOOLEAN_T_DEFINED_ + #define _BOOLEAN_T_DEFINED_ -typedef signed char boolean_t; + typedef signed char boolean_t; -#if !defined(TRUE) -#define TRUE (boolean_t)0x01 -#endif + #if !defined(TRUE) + #define TRUE (boolean_t)0x01 + #endif -#if !defined(FALSE) -#define FALSE (boolean_t)0x00 -#endif + #if !defined(FALSE) + #define FALSE (boolean_t)0x00 + #endif -#define BOOL_NOT(b) (b^TRUE) + #define BOOL_NOT(b) (b^TRUE) #endif /* _BOOLEAN_T_DEFINED_ */ @@ -65,7 +65,7 @@ typedef int32_t sdu_size_t; typedef uint32_t frame_t; typedef int32_t sframe_t; typedef uint32_t sub_frame_t; -typedef uint16_t module_id_t; +typedef uint16_t module_id_t; typedef uint8_t slice_id_t; typedef uint8_t eNB_index_t; typedef uint16_t ue_id_t; @@ -102,19 +102,19 @@ typedef enum rb_type_e { } rb_type_t; typedef enum { - CR_ROUND = 0, - CR_SRB12 = 1, - CR_HOL = 2, - CR_LC = 3, - CR_CQI = 4, - CR_LCP = 5, - CR_NUM = 6 + CR_ROUND = 0, + CR_SRB12 = 1, + CR_HOL = 2, + CR_LC = 3, + CR_CQI = 4, + CR_LCP = 5, + CR_NUM = 6 } sorting_criterion_t; typedef enum { - POL_FAIR = 0, - POL_GREEDY = 1, - POL_NUM = 2 + POL_FAIR = 0, + POL_GREEDY = 1, + POL_NUM = 2 } accounting_policy_t; //----------------------------------------------------------------------------- // PHY TYPES @@ -188,19 +188,19 @@ typedef uint32_t m_tmsi_t; //Random UE identity length = 40 bits #if ! defined(NOT_A_RANDOM_UE_IDENTITY) -#define NOT_A_RANDOM_UE_IDENTITY (uint64_t)0xFFFFFFFF + #define NOT_A_RANDOM_UE_IDENTITY (uint64_t)0xFFFFFFFF #endif #if ! defined(NOT_A_RNTI) -#define NOT_A_RNTI (rnti_t)0 + #define NOT_A_RNTI (rnti_t)0 #endif #if ! defined(M_RNTI) -#define M_RNTI (rnti_t)0xFFFD + #define M_RNTI (rnti_t)0xFFFD #endif #if ! defined(P_RNTI) -#define P_RNTI (rnti_t)0xFFFE + #define P_RNTI (rnti_t)0xFFFE #endif #if ! defined(SI_RNTI) -#define SI_RNTI (rnti_t)0xFFFF + #define SI_RNTI (rnti_t)0xFFFF #endif typedef enum config_action_e { CONFIG_ACTION_NULL = 0, @@ -225,7 +225,7 @@ typedef uint8_t ebi_t; // eps bearer id //----------------------------------------------------------------------------- // may be ITTI not enabled, but type instance is useful also for OTG, #if !defined(instance_t) -typedef uint16_t instance_t; + typedef uint16_t instance_t; #endif typedef struct protocol_ctxt_s { module_id_t module_id; /*!< \brief Virtualized module identifier */ @@ -247,51 +247,51 @@ typedef struct protocol_ctxt_s { #define MODULE_ID_TO_INSTANCE(mODULE_iD, iNSTANCE, eNB_fLAG) \ - if(eNB_fLAG == ENB_FLAG_YES) \ - iNSTANCE = ENB_MODULE_ID_TO_INSTANCE(mODULE_iD); \ - else \ - iNSTANCE = UE_MODULE_ID_TO_INSTANCE(mODULE_iD) + if(eNB_fLAG == ENB_FLAG_YES) \ + iNSTANCE = ENB_MODULE_ID_TO_INSTANCE(mODULE_iD); \ + else \ + iNSTANCE = UE_MODULE_ID_TO_INSTANCE(mODULE_iD) #define INSTANCE_TO_MODULE_ID(iNSTANCE, mODULE_iD, eNB_fLAG) \ - if(eNB_fLAG == ENB_FLAG_YES) \ - mODULE_iD = ENB_INSTANCE_TO_MODULE_ID(iNSTANCE); \ - else \ - mODULE_iD = UE_INSTANCE_TO_MODULE_ID(iNSTANCE) + if(eNB_fLAG == ENB_FLAG_YES) \ + mODULE_iD = ENB_INSTANCE_TO_MODULE_ID(iNSTANCE); \ + else \ + mODULE_iD = UE_INSTANCE_TO_MODULE_ID(iNSTANCE) #define PROTOCOL_CTXT_COMPUTE_MODULE_ID(CtXt_h) \ - INSTANCE_TO_MODULE_ID( (CtXt_h)->instance , (CtXt_h)->module_id , (CtXt_h)->enb_flag ) + INSTANCE_TO_MODULE_ID( (CtXt_h)->instance , (CtXt_h)->module_id , (CtXt_h)->enb_flag ) #define PROTOCOL_CTXT_COMPUTE_INSTANCE(CtXt_h) \ - MODULE_ID_TO_INSTANCE( (CtXt_h)->module_id , (CtXt_h)->instance , (CtXt_h)->enb_flag ) + MODULE_ID_TO_INSTANCE( (CtXt_h)->module_id , (CtXt_h)->instance , (CtXt_h)->enb_flag ) #define PROTOCOL_CTXT_SET_BY_MODULE_ID(Ctxt_Pp, mODULE_iD, eNB_fLAG, rNTI, fRAME, sUBfRAME, eNB_iNDEX) \ - (Ctxt_Pp)->module_id = mODULE_iD; \ - (Ctxt_Pp)->enb_flag = eNB_fLAG; \ - (Ctxt_Pp)->rnti = rNTI; \ - (Ctxt_Pp)->frame = fRAME; \ - (Ctxt_Pp)->subframe = sUBfRAME; \ - (Ctxt_Pp)->eNB_index = eNB_iNDEX; \ - PROTOCOL_CTXT_COMPUTE_INSTANCE(Ctxt_Pp) + (Ctxt_Pp)->module_id = mODULE_iD; \ + (Ctxt_Pp)->enb_flag = eNB_fLAG; \ + (Ctxt_Pp)->rnti = rNTI; \ + (Ctxt_Pp)->frame = fRAME; \ + (Ctxt_Pp)->subframe = sUBfRAME; \ + (Ctxt_Pp)->eNB_index = eNB_iNDEX; \ + PROTOCOL_CTXT_COMPUTE_INSTANCE(Ctxt_Pp) #define PROTOCOL_CTXT_SET_BY_INSTANCE(Ctxt_Pp, iNSTANCE, eNB_fLAG, rNTI, fRAME, sUBfRAME) \ - (Ctxt_Pp)->instance = iNSTANCE; \ - (Ctxt_Pp)->enb_flag = eNB_fLAG; \ - (Ctxt_Pp)->rnti = rNTI; \ - (Ctxt_Pp)->frame = fRAME; \ - (Ctxt_Pp)->subframe = sUBfRAME; \ - PROTOCOL_CTXT_COMPUTE_MODULE_ID(Ctxt_Pp) + (Ctxt_Pp)->instance = iNSTANCE; \ + (Ctxt_Pp)->enb_flag = eNB_fLAG; \ + (Ctxt_Pp)->rnti = rNTI; \ + (Ctxt_Pp)->frame = fRAME; \ + (Ctxt_Pp)->subframe = sUBfRAME; \ + PROTOCOL_CTXT_COMPUTE_MODULE_ID(Ctxt_Pp) #define PROTOCOL_CTXT_FMT "[FRAME %05u][%s][MOD %02u][RNTI %" PRIx16 "]" #define PROTOCOL_CTXT_ARGS(CTXT_Pp) \ - (CTXT_Pp)->frame, \ - ((CTXT_Pp)->enb_flag == ENB_FLAG_YES) ? "eNB":" UE", \ - (CTXT_Pp)->module_id, \ - (CTXT_Pp)->rnti + (CTXT_Pp)->frame, \ + ((CTXT_Pp)->enb_flag == ENB_FLAG_YES) ? "eNB":" UE", \ + (CTXT_Pp)->module_id, \ + (CTXT_Pp)->rnti #define CHECK_CTXT_ARGS(CTXT_Pp) #define exit_fun(msg) exit_function(__FILE__,__FUNCTION__,__LINE__,msg) -void exit_function(const char* file, const char* function, const int line, const char* s); +void exit_function(const char *file, const char *function, const int line, const char *s); #endif diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index aeacd09fdee771c23e090cd09b4a776cc3edeaf0..c1b554c216d255bd9429ad6db2366cfd17669a27 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -33,9 +33,9 @@ #include "rrc_types.h" #include "s1ap_messages_types.h" #ifdef CMAKER -#include "LTE_SystemInformationBlockType2.h" + #include "LTE_SystemInformationBlockType2.h" #else -#include "RRC/LTE/MESSAGES/LTE_SystemInformationBlockType2.h" + #include "RRC/LTE/MESSAGES/LTE_SystemInformationBlockType2.h" #endif #include "LTE_SL-OffsetIndicator-r12.h" #include "LTE_SubframeBitmapSL-r12.h" @@ -47,19 +47,19 @@ //-------------------------------------------------------------------------------------------// // Messages for RRC logging #if defined(DISABLE_ITTI_XER_PRINT) -#include "LTE_BCCH-DL-SCH-Message.h" -#include "LTE_DL-CCCH-Message.h" -#include "LTE_DL-DCCH-Message.h" -#include "LTE_UE-EUTRA-Capability.h" -#include "LTE_UL-CCCH-Message.h" -#include "LTE_UL-DCCH-Message.h" + #include "LTE_BCCH-DL-SCH-Message.h" + #include "LTE_DL-CCCH-Message.h" + #include "LTE_DL-DCCH-Message.h" + #include "LTE_UE-EUTRA-Capability.h" + #include "LTE_UL-CCCH-Message.h" + #include "LTE_UL-DCCH-Message.h" -typedef BCCH_DL_SCH_Message_t RrcDlBcchMessage; -typedef DL_CCCH_Message_t RrcDlCcchMessage; -typedef DL_DCCH_Message_t RrcDlDcchMessage; -typedef UE_EUTRA_Capability_t RrcUeEutraCapability; -typedef UL_CCCH_Message_t RrcUlCcchMessage; -typedef UL_DCCH_Message_t RrcUlDcchMessage; + typedef BCCH_DL_SCH_Message_t RrcDlBcchMessage; + typedef DL_CCCH_Message_t RrcDlCcchMessage; + typedef DL_DCCH_Message_t RrcDlDcchMessage; + typedef UE_EUTRA_Capability_t RrcUeEutraCapability; + typedef UL_CCCH_Message_t RrcUlCcchMessage; + typedef UL_DCCH_Message_t RrcUlDcchMessage; #endif //-------------------------------------------------------------------------------------------// @@ -102,7 +102,8 @@ typedef struct RrcConfigurationReq_s { uint8_t mnc_digit_length[PLMN_LIST_MAX_SIZE]; uint8_t num_plmn; - + uint32_t rrc_inactivity_timer_thres; // for testing, maybe change later + paging_drx_t default_drx; int16_t nb_cc; lte_frame_type_t frame_type[MAX_NUM_CCs]; @@ -124,9 +125,9 @@ typedef struct RrcConfigurationReq_s { long pucch_delta_shift[MAX_NUM_CCs]; long pucch_nRB_CQI[MAX_NUM_CCs]; long pucch_nCS_AN[MAX_NUM_CCs]; -//#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) + //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) long pucch_n1_AN[MAX_NUM_CCs]; -//#endif + //#endif long pdsch_referenceSignalPower[MAX_NUM_CCs]; long pdsch_p_b[MAX_NUM_CCs]; long pusch_n_SB[MAX_NUM_CCs]; @@ -188,7 +189,7 @@ typedef struct RrcConfigurationReq_s { LTE_SL_OffsetIndicator_r12_PR rxPool_ResourceConfig_offsetIndicator_present[MAX_NUM_CCs]; long rxPool_ResourceConfig_offsetIndicator_choice[MAX_NUM_CCs]; LTE_SubframeBitmapSL_r12_PR rxPool_ResourceConfig_subframeBitmap_present[MAX_NUM_CCs]; - char* rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; + char *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; long rxPool_ResourceConfig_subframeBitmap_choice_bs_size[MAX_NUM_CCs]; long rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[MAX_NUM_CCs]; @@ -204,7 +205,7 @@ typedef struct RrcConfigurationReq_s { LTE_SL_OffsetIndicator_r12_PR discRxPool_ResourceConfig_offsetIndicator_present[MAX_NUM_CCs]; long discRxPool_ResourceConfig_offsetIndicator_choice[MAX_NUM_CCs]; LTE_SubframeBitmapSL_r12_PR discRxPool_ResourceConfig_subframeBitmap_present[MAX_NUM_CCs]; - char* discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; + char *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; long discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[MAX_NUM_CCs]; long discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[MAX_NUM_CCs]; //for discRxPoolPS @@ -218,7 +219,7 @@ typedef struct RrcConfigurationReq_s { LTE_SL_OffsetIndicator_r12_PR discRxPoolPS_ResourceConfig_offsetIndicator_present[MAX_NUM_CCs]; long discRxPoolPS_ResourceConfig_offsetIndicator_choice[MAX_NUM_CCs]; LTE_SubframeBitmapSL_r12_PR discRxPoolPS_ResourceConfig_subframeBitmap_present[MAX_NUM_CCs]; - char* discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; + char *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[MAX_NUM_CCs]; long discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[MAX_NUM_CCs]; long discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[MAX_NUM_CCs]; } RrcConfigurationReq; @@ -230,69 +231,69 @@ typedef struct NbIoTRrcConfigurationReq_s { uint16_t tac; - uint16_t mcc; - uint16_t mnc; - uint8_t mnc_digit_length; - lte_frame_type_t frame_type; + uint16_t mcc; + uint16_t mnc; + uint8_t mnc_digit_length; + lte_frame_type_t frame_type; uint8_t tdd_config; uint8_t tdd_config_s; lte_prefix_type_t prefix_type; - lte_prefix_type_t prefix_type_UL; + lte_prefix_type_t prefix_type_UL; int16_t eutra_band; uint32_t downlink_frequency; int32_t uplink_frequency_offset; int16_t Nid_cell;// for testing, change later int16_t N_RB_DL;// for testing, change later //RACH - long rach_raResponseWindowSize_NB; - long rach_macContentionResolutionTimer_NB; - long rach_powerRampingStep_NB; - long rach_preambleInitialReceivedTargetPower_NB; - long rach_preambleTransMax_CE_NB; + long rach_raResponseWindowSize_NB; + long rach_macContentionResolutionTimer_NB; + long rach_powerRampingStep_NB; + long rach_preambleInitialReceivedTargetPower_NB; + long rach_preambleTransMax_CE_NB; //BCCH - long bcch_modificationPeriodCoeff_NB; + long bcch_modificationPeriodCoeff_NB; //PCCH - long pcch_defaultPagingCycle_NB; - long pcch_nB_NB; - long pcch_npdcch_NumRepetitionPaging_NB; + long pcch_defaultPagingCycle_NB; + long pcch_nB_NB; + long pcch_npdcch_NumRepetitionPaging_NB; //NPRACH - long nprach_CP_Length; - long nprach_rsrp_range; - long nprach_Periodicity[MAX_NUM_NBIOT_CELEVELS]; - long nprach_StartTime[MAX_NUM_NBIOT_CELEVELS]; - long nprach_SubcarrierOffset[MAX_NUM_NBIOT_CELEVELS]; - long nprach_NumSubcarriers[MAX_NUM_NBIOT_CELEVELS]; - long numRepetitionsPerPreambleAttempt_NB[MAX_NUM_NBIOT_CELEVELS]; - long nprach_SubcarrierMSG3_RangeStart; - long maxNumPreambleAttemptCE_NB; - long npdcch_NumRepetitions_RA[MAX_NUM_NBIOT_CELEVELS]; - long npdcch_StartSF_CSS_RA[MAX_NUM_NBIOT_CELEVELS]; - long npdcch_Offset_RA[MAX_NUM_NBIOT_CELEVELS]; + long nprach_CP_Length; + long nprach_rsrp_range; + long nprach_Periodicity[MAX_NUM_NBIOT_CELEVELS]; + long nprach_StartTime[MAX_NUM_NBIOT_CELEVELS]; + long nprach_SubcarrierOffset[MAX_NUM_NBIOT_CELEVELS]; + long nprach_NumSubcarriers[MAX_NUM_NBIOT_CELEVELS]; + long numRepetitionsPerPreambleAttempt_NB[MAX_NUM_NBIOT_CELEVELS]; + long nprach_SubcarrierMSG3_RangeStart; + long maxNumPreambleAttemptCE_NB; + long npdcch_NumRepetitions_RA[MAX_NUM_NBIOT_CELEVELS]; + long npdcch_StartSF_CSS_RA[MAX_NUM_NBIOT_CELEVELS]; + long npdcch_Offset_RA[MAX_NUM_NBIOT_CELEVELS]; //NPDSCH - long npdsch_nrs_Power; + long npdsch_nrs_Power; //NPUSCH - long npusch_ack_nack_numRepetitions_NB; - long npusch_srs_SubframeConfig_NB; - long npusch_threeTone_CyclicShift_r13; - long npusch_sixTone_CyclicShift_r13; - BOOLEAN_t npusch_groupHoppingEnabled; - long npusch_groupAssignmentNPUSCH_r13; + long npusch_ack_nack_numRepetitions_NB; + long npusch_srs_SubframeConfig_NB; + long npusch_threeTone_CyclicShift_r13; + long npusch_sixTone_CyclicShift_r13; + BOOLEAN_t npusch_groupHoppingEnabled; + long npusch_groupAssignmentNPUSCH_r13; //DL_GapConfig - long dl_GapThreshold_NB; - long dl_GapPeriodicity_NB; - long dl_GapDurationCoeff_NB; + long dl_GapThreshold_NB; + long dl_GapPeriodicity_NB; + long dl_GapDurationCoeff_NB; //Uplink power control Common - long npusch_p0_NominalNPUSCH; - long npusch_alpha; - long deltaPreambleMsg3; + long npusch_p0_NominalNPUSCH; + long npusch_alpha; + long deltaPreambleMsg3; //UE timers and constants - long ue_TimersAndConstants_t300_NB; - long ue_TimersAndConstants_t301_NB; - long ue_TimersAndConstants_t310_NB; - long ue_TimersAndConstants_t311_NB; - long ue_TimersAndConstants_n310_NB; - long ue_TimersAndConstants_n311_NB; + long ue_TimersAndConstants_t300_NB; + long ue_TimersAndConstants_t301_NB; + long ue_TimersAndConstants_t310_NB; + long ue_TimersAndConstants_t311_NB; + long ue_TimersAndConstants_n310_NB; + long ue_TimersAndConstants_n311_NB; } NbIoTRrcConfigurationReq; diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 9cbfb8741e277d7b07130926cb1db494c6337b6b..faee587fa99c5e893e1cde81d1799cb4c424698c 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -36,13 +36,13 @@ #include "UTIL/OTG/otg.h" #include "UTIL/OTG/otg_externs.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" -#if defined(ENABLE_USE_MME) -#include "s1ap_eNB.h" -#include "sctp_eNB_task.h" -#else -#define EPC_MODE_ENABLED 0 -#endif + #include "intertask_interface.h" + #if defined(ENABLE_USE_MME) + #include "s1ap_eNB.h" + #include "sctp_eNB_task.h" + #else + #define EPC_MODE_ENABLED 0 + #endif #endif #include "sctp_default_values.h" #include "LTE_SystemInformationBlockType2.h" @@ -60,6 +60,8 @@ #include "RRC_config_tools.h" #include "enb_paramdef.h" +#define RRC_INACTIVITY_THRESH 0 + extern uint16_t sf_ahead; extern void set_parallel_conf(char *parallel_conf); extern void set_worker_conf(char *worker_conf); @@ -67,6 +69,8 @@ extern PARALLEL_CONF_t get_thread_parallel_conf(void); extern WORKER_CONF_t get_thread_worker_conf(void); extern uint32_t to_earfcn_DL(int eutra_bandP, uint32_t dl_CarrierFreq, uint32_t bw); extern uint32_t to_earfcn_UL(int eutra_bandP, uint32_t ul_CarrierFreq, uint32_t bw); +extern char *parallel_config; +extern char *worker_config; void RCconfig_flexran() { uint16_t i; @@ -579,8 +583,9 @@ int RCconfig_RRC(MessageDef *msg_p, uint32_t i, eNB_RRC_INST *rrc) { for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); + RRC_CONFIGURATION_REQ (msg_p).rrc_inactivity_timer_thres = RRC_INACTIVITY_THRESH; // set to 0 to deactivate RRC_CONFIGURATION_REQ (msg_p).cell_identity = enb_id; - RRC_CONFIGURATION_REQ(msg_p).tac = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr; + RRC_CONFIGURATION_REQ (msg_p).tac = *ENBParamList.paramarray[i][ENB_TRACKING_AREA_CODE_IDX].uptr; AssertFatal(!ENBParamList.paramarray[i][ENB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr && !ENBParamList.paramarray[i][ENB_MOBILE_NETWORK_CODE_IDX_OLD].strptr, "It seems that you use an old configuration file. Please change the existing\n" @@ -2041,37 +2046,162 @@ int RCconfig_gtpu(void ) { return 0; } - -int RCconfig_S1(MessageDef *msg_p, uint32_t i) { - int j,k = 0; - int enb_id; - int32_t my_int; - const char *active_enb[MAX_ENB]; - char *address = NULL; - char *cidr = NULL; +//----------------------------------------------------------------------------- +/* +* Configure the s1ap_register_enb_req in itti message for future +* communications between eNB(s) and MME. +*/ +int RCconfig_S1( + MessageDef *msg_p, + uint32_t i) +//----------------------------------------------------------------------------- +{ + int enb_id = 0; + int32_t my_int = 0; + const char *active_enb[MAX_ENB]; + char *address = NULL; + char *cidr = NULL; + /*------------------------------------------------------------------------------*/ + /* + * the only reason for all these variables is, that they are "hard-encoded" into + * the CCPARAMS_DESC macro and we need it for the default_DRX value ... + */ + char *frame_type = NULL; + int32_t tdd_config = 0; + int32_t tdd_config_s = 0; + char *prefix_type = NULL; + char *pbch_repetition = NULL; + int32_t eutra_band = 0; + long long int downlink_frequency = 0; + int32_t uplink_frequency_offset = 0; + int32_t Nid_cell = 0; + int32_t Nid_cell_mbsfn = 0; + int32_t N_RB_DL = 0; + int32_t nb_antenna_ports = 0; + int32_t prach_root = 0; + int32_t prach_config_index = 0; + char *prach_high_speed = NULL; + int32_t prach_zero_correlation = 0; + int32_t prach_freq_offset = 0; + int32_t pucch_delta_shift = 0; + int32_t pucch_nRB_CQI = 0; + int32_t pucch_nCS_AN = 0; + int32_t pucch_n1_AN = 0; + int32_t pdsch_referenceSignalPower = 0; + int32_t pdsch_p_b = 0; + int32_t pusch_n_SB = 0; + char *pusch_hoppingMode = NULL; + int32_t pusch_hoppingOffset = 0; + char *pusch_enable64QAM = NULL; + char *pusch_groupHoppingEnabled = NULL; + int32_t pusch_groupAssignment = 0; + char *pusch_sequenceHoppingEnabled = NULL; + int32_t pusch_nDMRS1 = 0; + char *phich_duration = NULL; + char *phich_resource = NULL; + char *srs_enable = NULL; + int32_t srs_BandwidthConfig = 0; + int32_t srs_SubframeConfig = 0; + char *srs_ackNackST = NULL; + char *srs_MaxUpPts = NULL; + int32_t pusch_p0_Nominal = 0; + char *pusch_alpha = NULL; + int32_t pucch_p0_Nominal = 0; + int32_t msg3_delta_Preamble = 0; + char *pucch_deltaF_Format1 = NULL; + char *pucch_deltaF_Format1b = NULL; + char *pucch_deltaF_Format2 = NULL; + char *pucch_deltaF_Format2a = NULL; + char *pucch_deltaF_Format2b = NULL; + int32_t rach_numberOfRA_Preambles = 0; + char *rach_preamblesGroupAConfig = NULL; + int32_t rach_sizeOfRA_PreamblesGroupA = 0; + int32_t rach_messageSizeGroupA = 0; + char *rach_messagePowerOffsetGroupB = NULL; + int32_t rach_powerRampingStep = 0; + int32_t rach_preambleInitialReceivedTargetPower = 0; + int32_t rach_preambleTransMax = 0; + int32_t rach_raResponseWindowSize = 10; + int32_t rach_macContentionResolutionTimer = 0; + int32_t rach_maxHARQ_Msg3Tx = 0; + int32_t pcch_defaultPagingCycle = 0; + char *pcch_nB = NULL; + int32_t bcch_modificationPeriodCoeff = 0; + int32_t ue_TimersAndConstants_t300 = 0; + int32_t ue_TimersAndConstants_t301 = 0; + int32_t ue_TimersAndConstants_t310 = 0; + int32_t ue_TimersAndConstants_t311 = 0; + int32_t ue_TimersAndConstants_n310 = 0; + int32_t ue_TimersAndConstants_n311 = 0; + int32_t ue_TransmissionMode = 0; + int32_t ue_multiple_max = 0; + //TTN - for D2D + //SIB18 + const char *rxPool_sc_CP_Len = NULL; + const char *rxPool_sc_Period = NULL; + const char *rxPool_data_CP_Len = NULL; + libconfig_int rxPool_ResourceConfig_prb_Num = 0; + libconfig_int rxPool_ResourceConfig_prb_Start = 0; + libconfig_int rxPool_ResourceConfig_prb_End = 0; + const char *rxPool_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int rxPool_ResourceConfig_offsetIndicator_choice = 0; + const char *rxPool_ResourceConfig_subframeBitmap_present = NULL; + char *rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + //SIB19 + //For discRxPool + const char *discRxPool_cp_Len = NULL; + const char *discRxPool_discPeriod = NULL; + libconfig_int discRxPool_numRetx = 0; + libconfig_int discRxPool_numRepetition = 0; + libconfig_int discRxPool_ResourceConfig_prb_Num = 0; + libconfig_int discRxPool_ResourceConfig_prb_Start = 0; + libconfig_int discRxPool_ResourceConfig_prb_End = 0; + const char *discRxPool_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int discRxPool_ResourceConfig_offsetIndicator_choice = 0; + const char *discRxPool_ResourceConfig_subframeBitmap_present = NULL; + char *discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int discRxPool_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + //For discRxPoolPS + const char *discRxPoolPS_cp_Len = NULL; + const char *discRxPoolPS_discPeriod = NULL; + libconfig_int discRxPoolPS_numRetx = 0; + libconfig_int discRxPoolPS_numRepetition = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_Num = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_Start = 0; + libconfig_int discRxPoolPS_ResourceConfig_prb_End = 0; + const char *discRxPoolPS_ResourceConfig_offsetIndicator_present = NULL; + libconfig_int discRxPoolPS_ResourceConfig_offsetIndicator_choice = 0; + const char *discRxPoolPS_ResourceConfig_subframeBitmap_present = NULL; + char *discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf = NULL; + libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size = 0; + libconfig_int discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; + /*------------------------------------------------------------------------------*/ // for no gcc warnings (void)my_int; - memset((char *)active_enb, 0, MAX_ENB * sizeof(char *)); + memset((char *)active_enb, 0, MAX_ENB * sizeof(char *)); paramdef_t ENBSParams[] = ENBSPARAMS_DESC; - paramdef_t ENBParams[] = ENBPARAMS_DESC; - paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST,NULL,0}; + paramdef_t ENBParams[] = ENBPARAMS_DESC; + paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST, NULL, 0}; /* get global parameters, defined outside any section in the config file */ - config_get( ENBSParams,sizeof(ENBSParams)/sizeof(paramdef_t),NULL); - AssertFatal (i<ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt, + config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL); + AssertFatal (i < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt, "Failed to parse config file %s, %uth attribute %s \n", RC.config_file_name, i, ENB_CONFIG_STRING_ACTIVE_ENBS); - if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt>0) { + if (ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt > 0) { // Output a list of all eNBs. - config_getlist( &ENBParamList,ENBParams,sizeof(ENBParams)/sizeof(paramdef_t),NULL); + config_getlist(&ENBParamList, ENBParams, sizeof(ENBParams)/sizeof(paramdef_t), NULL); if (ENBParamList.numelt > 0) { - for (k = 0; k < ENBParamList.numelt; k++) { + for (int k = 0; k < ENBParamList.numelt; k++) { if (ENBParamList.paramarray[k][ENB_ENB_ID_IDX].uptr == NULL) { // Calculate a default eNB ID if (EPC_MODE_ENABLED) { - uint32_t hash; - hash = s1ap_generate_eNB_id (); + uint32_t hash = 0; + hash = s1ap_generate_eNB_id(); enb_id = k + (hash & 0xFFFF8); } else { enb_id = k; @@ -2081,22 +2211,31 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { } // search if in active list - for (j=0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { + for (int j = 0; j < ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; j++) { if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[j], *(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)) == 0) { paramdef_t PLMNParams[] = PLMNPARAMS_DESC; paramlist_def_t PLMNParamList = {ENB_CONFIG_STRING_PLMN_LIST, NULL, 0}; + paramdef_t CCsParams[] = CCPARAMS_DESC; + /* map parameter checking array instances to parameter definition array instances */ + checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK; + + for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) { + CCsParams[I].chkPptr = &(config_check_CCparams[I]); + } + /* map parameter checking array instances to parameter definition array instances */ checkedparam_t config_check_PLMNParams [] = PLMNPARAMS_CHECK; - for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) + for (int I = 0; I < sizeof(PLMNParams) / sizeof(paramdef_t); ++I) { PLMNParams[I].chkPptr = &(config_check_PLMNParams[I]); + } - paramdef_t S1Params[] = S1PARAMS_DESC; - paramlist_def_t S1ParamList = {ENB_CONFIG_STRING_MME_IP_ADDRESS,NULL,0}; - paramdef_t SCTPParams[] = SCTPPARAMS_DESC; - paramdef_t NETParams[] = NETPARAMS_DESC; + paramdef_t S1Params[] = S1PARAMS_DESC; + paramlist_def_t S1ParamList = {ENB_CONFIG_STRING_MME_IP_ADDRESS, NULL, 0}; + paramdef_t SCTPParams[] = SCTPPARAMS_DESC; + paramdef_t NETParams[] = NETPARAMS_DESC; char aprefix[MAX_OPTNAME_SIZE*2 + 8]; - sprintf(aprefix,"%s.[%i]",ENB_CONFIG_STRING_ENB_LIST,k); + sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k); S1AP_REGISTER_ENB_REQ (msg_p).eNB_id = enb_id; if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_MACRO_ENB") == 0) { @@ -2104,13 +2243,15 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { } else if (strcmp(*(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr), "CELL_HOME_ENB") == 0) { S1AP_REGISTER_ENB_REQ (msg_p).cell_type = CELL_HOME_ENB; } else { - AssertFatal (0, - "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", - RC.config_file_name, i, *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); + AssertFatal(0, + "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n", + RC.config_file_name, + i, + *(ENBParamList.paramarray[k][ENB_CELL_TYPE_IDX].strptr)); } - S1AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); - S1AP_REGISTER_ENB_REQ(msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; + S1AP_REGISTER_ENB_REQ (msg_p).eNB_name = strdup(*(ENBParamList.paramarray[k][ENB_ENB_NAME_IDX].strptr)); + S1AP_REGISTER_ENB_REQ(msg_p).tac = *ENBParamList.paramarray[k][ENB_TRACKING_AREA_CODE_IDX].uptr; AssertFatal(!ENBParamList.paramarray[k][ENB_MOBILE_COUNTRY_CODE_IDX_OLD].strptr && !ENBParamList.paramarray[k][ENB_MOBILE_NETWORK_CODE_IDX_OLD].strptr, "It seems that you use an old configuration file. Please change the existing\n" @@ -2122,9 +2263,10 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { " plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n"); config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); - if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) + if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) { AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", PLMNParamList.numelt); + } S1AP_REGISTER_ENB_REQ(msg_p).num_plmn = PLMNParamList.numelt; @@ -2138,8 +2280,48 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { S1AP_REGISTER_ENB_REQ(msg_p).mnc[l]); } - S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; - config_getlist( &S1ParamList,S1Params,sizeof(S1Params)/sizeof(paramdef_t),aprefix); + /* Default DRX param */ + /* + * Here we get the config of the first CC, since the s1ap_register_enb_req_t doesn't support multiple CC. + * There is a unique value of defaultPagingCycle per eNB (same for multiple cells). + * Hence, it should be stated somewhere that the value should be the same for every CC, or put the value outside the CC + * in the conf file. + */ + sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k, ENB_CONFIG_STRING_COMPONENT_CARRIERS, 0); + config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); + + switch (pcch_defaultPagingCycle) { + case 32: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; + break; + } + + case 64: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 1; + break; + } + + case 128: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 2; + break; + } + + case 256: { + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 3; + break; + } + + default: { + LOG_E(S1AP, "Default I-DRX value in conf file is invalid (%i). Should be 32, 64, 128 or 256. \ + Default DRX set to 32 in MME configuration\n", + pcch_defaultPagingCycle); + S1AP_REGISTER_ENB_REQ(msg_p).default_drx = 0; + } + } + + /* MME connection params */ + sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, k); + config_getlist(&S1ParamList, S1Params, sizeof(S1Params)/sizeof(paramdef_t), aprefix); S1AP_REGISTER_ENB_REQ (msg_p).nb_mme = 0; for (int l = 0; l < S1ParamList.numelt; l++) { @@ -2156,10 +2338,11 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { S1AP_REGISTER_ENB_REQ (msg_p).mme_ip_address[l].ipv6 = 1; } - if (S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr) + if (S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].iptr) { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = S1ParamList.paramarray[l][ENB_MME_BROADCAST_PLMN_INDEX].numelt; - else + } else { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = 0; + } AssertFatal(S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] <= S1AP_REGISTER_ENB_REQ(msg_p).num_plmn, "List of broadcast PLMN to be sent to MME can not be longer than actual " @@ -2181,8 +2364,9 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { if (S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] == 0) { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_num[l] = S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; - for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; ++el) + for (int el = 0; el < S1AP_REGISTER_ENB_REQ(msg_p).num_plmn; ++el) { S1AP_REGISTER_ENB_REQ(msg_p).broadcast_plmn_index[l][el] = el; + } } } @@ -2200,7 +2384,6 @@ int RCconfig_S1(MessageDef *msg_p, uint32_t i) { sprintf(aprefix,"%s.[%i].%s",ENB_CONFIG_STRING_ENB_LIST,k,ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG); // NETWORK_INTERFACES config_get( NETParams,sizeof(NETParams)/sizeof(paramdef_t),aprefix); - // S1AP_REGISTER_ENB_REQ (msg_p).enb_interface_name_for_S1U = strdup(enb_interface_name_for_S1U); cidr = *(NETParams[ENB_IPV4_ADDRESS_FOR_S1_MME_IDX].strptr); address = strtok(cidr, "/"); S1AP_REGISTER_ENB_REQ (msg_p).enb_ip_address.ipv6 = 0; @@ -2390,10 +2573,8 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { || X2AP_REGISTER_ENB_REQ(msg_p).mnc < 100, "MNC %d cannot be encoded in two digits as requested (change mnc_digit_length to 3)\n", X2AP_REGISTER_ENB_REQ(msg_p).mnc); - /* CC params */ config_getlist(&CCsParamList, NULL, 0, aprefix); - X2AP_REGISTER_ENB_REQ (msg_p).num_cc = CCsParamList.numelt; if (CCsParamList.numelt > 0) { @@ -2440,7 +2621,6 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { AssertFatal(X2ParamList.numelt <= X2AP_MAX_NB_ENB_IP_ADDRESS, "value of X2ParamList.numelt %d must be lower than X2AP_MAX_NB_ENB_IP_ADDRESS %d value: reconsider to increase X2AP_MAX_NB_ENB_IP_ADDRESS\n", X2ParamList.numelt,X2AP_MAX_NB_ENB_IP_ADDRESS); - X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 = 0; for (l = 0; l < X2ParamList.numelt; l++) { @@ -2494,29 +2674,33 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { int RCconfig_parallel(void) { char *parallel_conf = NULL; char *worker_conf = NULL; + paramdef_t ThreadParams[] = THREAD_CONF_DESC; paramlist_def_t THREADParamList = {THREAD_CONFIG_STRING_THREAD_STRUCT,NULL,0}; config_getlist( &THREADParamList,NULL,0,NULL); - if(THREADParamList.numelt>0) { - config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL); - parallel_conf = strdup(*(THREADParamList.paramarray[0][THREAD_PARALLEL_IDX].strptr)); - } else { - parallel_conf = strdup("PARALLEL_RU_L1_TRX_SPLIT"); + if(parallel_config == NULL){ + if(THREADParamList.numelt>0) { + config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL); + parallel_conf = strdup(*(THREADParamList.paramarray[0][THREAD_PARALLEL_IDX].strptr)); + } else { + parallel_conf = strdup("PARALLEL_RU_L1_TRX_SPLIT"); + } + set_parallel_conf(parallel_conf); } - if(THREADParamList.numelt>0) { - config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL); - worker_conf = strdup(*(THREADParamList.paramarray[0][THREAD_WORKER_IDX].strptr)); - } else { - worker_conf = strdup("WORKER_ENABLE"); + if(worker_config == NULL){ + if(THREADParamList.numelt>0) { + config_getlist( &THREADParamList,ThreadParams,sizeof(ThreadParams)/sizeof(paramdef_t),NULL); + worker_conf = strdup(*(THREADParamList.paramarray[0][THREAD_WORKER_IDX].strptr)); + } else { + worker_conf = strdup("WORKER_ENABLE"); + } + set_worker_conf(worker_conf); } - set_parallel_conf(parallel_conf); - set_worker_conf(worker_conf); - return 0; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 6175005b44ceb8f8abecec335a57fc8a4ba4686b..9a26460fa3662c63c50e0cc79afb8e20c5f11aec 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -47,12 +47,12 @@ //#include "LAYER2/MAC/pre_processor.c" #include "pdcp.h" -#include "SIMULATION/TOOLS/sim.h" // for taus +#include "SIMULATION/TOOLS/sim.h" // for taus #include "assertions.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" + #include "intertask_interface.h" #endif #include <dlfcn.h> @@ -74,15 +74,12 @@ add_ue_dlsch_info(module_id_t module_idP, //------------------------------------------------------------------------------ { //LOG_D(MAC, "%s(module_idP:%d, CC_id:%d, UE_id:%d, subframeP:%d, status:%d) serving_num:%d rnti:%x\n", __FUNCTION__, module_idP, CC_id, UE_id, subframeP, status, eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num, UE_RNTI(module_idP,UE_id)); - eNB_dlsch_info[module_idP][CC_id][UE_id].rnti = - UE_RNTI(module_idP, UE_id); + UE_RNTI(module_idP, UE_id); // eNB_dlsch_info[module_idP][CC_id][ue_mod_idP].weight = weight; eNB_dlsch_info[module_idP][CC_id][UE_id].subframe = subframeP; eNB_dlsch_info[module_idP][CC_id][UE_id].status = status; - eNB_dlsch_info[module_idP][CC_id][UE_id].serving_num++; - } //------------------------------------------------------------------------------ @@ -91,7 +88,6 @@ schedule_next_dlue(module_id_t module_idP, int CC_id, sub_frame_t subframeP) //------------------------------------------------------------------------------ { - int next_ue; UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; @@ -111,7 +107,6 @@ schedule_next_dlue(module_id_t module_idP, int CC_id, } return (-1); //next_ue; - } //------------------------------------------------------------------------------ @@ -127,11 +122,9 @@ generate_dlsch_header(unsigned char *mac_header, unsigned short post_padding) //------------------------------------------------------------------------------ { - SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *) mac_header; uint8_t first_element = 0, last_size = 0, i; uint8_t mac_header_control_elements[16], *ce_ptr; - ce_ptr = &mac_header_control_elements[0]; // compute header components @@ -194,10 +187,10 @@ generate_dlsch_header(unsigned char *mac_header, if (first_element > 0) { mac_header_ptr->E = 1; /* - printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); */ mac_header_ptr++; } else { @@ -208,16 +201,15 @@ generate_dlsch_header(unsigned char *mac_header, mac_header_ptr->E = 0; mac_header_ptr->LCID = UE_CONT_RES; last_size = 1; - LOG_T(MAC, "[eNB ][RAPROC] Generate contention resolution msg: %x.%x.%x.%x.%x.%x\n", ue_cont_res_id[0], ue_cont_res_id[1], ue_cont_res_id[2], ue_cont_res_id[3], ue_cont_res_id[4], ue_cont_res_id[5]); - memcpy(ce_ptr, ue_cont_res_id, 6); ce_ptr += 6; // msg("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } + //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); for (i = 0; i < num_sdus; i++) { @@ -227,9 +219,9 @@ generate_dlsch_header(unsigned char *mac_header, if (first_element > 0) { mac_header_ptr->E = 1; /*msg("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); */ mac_header_ptr += last_size; //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); @@ -255,10 +247,10 @@ generate_dlsch_header(unsigned char *mac_header, last_size = 3; #ifdef DEBUG_HEADER_PARSING LOG_D(MAC, - "[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", - sdu_lengths[i], - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB, - ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB); + "[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", + sdu_lengths[i], + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB, + ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB); #endif } } @@ -300,10 +292,10 @@ generate_dlsch_header(unsigned char *mac_header, memcpy((void *) mac_header_ptr, mac_header_control_elements, ce_ptr - mac_header_control_elements); mac_header_ptr += - (unsigned char) (ce_ptr - mac_header_control_elements); + (unsigned char) (ce_ptr - mac_header_control_elements); } - //msg("After CEs %d\n",(uint8_t*)mac_header_ptr - mac_header); + //msg("After CEs %d\n",(uint8_t*)mac_header_ptr - mac_header); return ((unsigned char *) mac_header_ptr - mac_header); } @@ -313,11 +305,11 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, int subframeP) //------------------------------------------------------------------------------ { - eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list = &eNB->UE_list; unsigned char DAI; COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; + if (cc->tdd_Config != NULL) { //TDD DAI = (UE_list->UE_template[CC_idP][UE_idP].DAI - 1) & 3; LOG_D(MAC, @@ -332,24 +324,25 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, case 1: switch (subframeP) { - case 0: - case 1: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI; - break; + case 0: + case 1: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[7] = DAI; + break; - case 4: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI; - break; + case 4: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[8] = DAI; + break; - case 5: - case 6: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; - break; + case 5: + case 6: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[2] = DAI; + break; - case 9: - UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; - break; + case 9: + UE_list->UE_template[CC_idP][UE_idP].DAI_ul[3] = DAI; + break; } + break; case 2: @@ -410,7 +403,6 @@ set_ul_DAI(int module_idP, int UE_idP, int CC_idP, int frameP, //------------------------------------------------------------------------------ void schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) { - int i = 0; slice_info_t *sli = &RC.mac[module_idP]->slice_info; memset(sli->rballoc_sub, 0, sizeof(sli->rballoc_sub)); @@ -419,7 +411,6 @@ schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, in // Run each enabled slice-specific schedulers one by one sli->dl[i].sched_cb(module_idP, i, frameP, subframeP, mbsfn_flag/*, dl_info*/); } - } // changes to pre-processor for eMTC @@ -445,7 +436,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, int harq_pid = 0; eNB_UE_STATS *eNB_UE_stats = NULL; int sdu_length_total = 0; - eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = eNB->common_channels; UE_list_t *UE_list = &eNB->UE_list; @@ -465,63 +455,79 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, int ta_update; int header_length_last; int header_length_total; - + rrc_eNB_ue_context_t *ue_contextP = NULL; start_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); // for TDD: check that we have to act here, otherwise return if (cc[0].tdd_Config) { tdd_sfa = cc[0].tdd_Config->subframeAssignment; + switch (subframeP) { case 0: // always continue break; + case 1: return; break; + case 2: return; break; + case 3: if ((tdd_sfa != 2) && (tdd_sfa != 5)) return; + break; + case 4: if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) && (tdd_sfa != 5)) return; + break; + case 5: break; + case 6: case 7: if ((tdd_sfa != 3) && (tdd_sfa != 4) && (tdd_sfa != 5)) return; + break; + case 8: if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) && (tdd_sfa != 5)) return; + break; + case 9: if (tdd_sfa == 0) return; + break; } } + //weight = get_ue_weight(module_idP,UE_id); aggregation = 2; + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); // get number of PRBs less those used by common channels total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; + for (i = 0; i < N_RB_DL[CC_id]; i++) if (cc[CC_id].vrb_map[i] != 0) total_nb_available_rb[CC_id]--; N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); - // store the global enb stats: eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; eNB->eNB_stats[CC_id].available_prbs = total_nb_available_rb[CC_id]; @@ -533,7 +539,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, // CALLING Pre_Processor for downlink scheduling // (Returns estimation of RBs required by each UE and the allocation on sub-band) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_IN); - start_meas(&eNB->schedule_dlsch_preprocessor); dlsch_scheduler_pre_processor(module_idP, slice_idxP, @@ -542,15 +547,14 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, mbsfn_flag, eNB->slice_info.rballoc_sub); stop_meas(&eNB->schedule_dlsch_preprocessor); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR, VCD_FUNCTION_OUT); //RC.mac[module_idP]->slice_info.slice_counter--; // Do the multiplexing and actual allocation only when all slices have been pre-processed. //if (RC.mac[module_idP]->slice_info.slice_counter > 0) { - //stop_meas(&eNB->schedule_dlsch); - //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); - //return; + //stop_meas(&eNB->schedule_dlsch); + //VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); + //return; //} if (RC.mac[module_idP]->slice_info.interslice_share_active) { @@ -562,7 +566,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n", CC_id); - dl_req = &eNB->DL_req[CC_id].dl_config_request_body; if (mbsfn_flag[CC_id] > 0) @@ -602,11 +605,13 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, ue_sched_ctl->dl_cqi[CC_id], format1); break; + case 3: aggregation = get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format2A); break; + default: LOG_W(MAC, "Unsupported transmission mode %d\n", get_tmode(module_idP, CC_id, UE_id)); aggregation = 2; @@ -614,13 +619,13 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } /* if (continue_flag != 1 */ - if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated - CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, - aggregation, rnti)) { - LOG_D(MAC, - "[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", - module_idP, frameP, UE_id, CC_id); - continue_flag = 1; //to next user (there might be rbs availiable for other UEs in TM5 + if ((ue_sched_ctl->pre_nb_available_rbs[CC_id] == 0) || // no RBs allocated + CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, + aggregation, rnti)) { + LOG_D(MAC, + "[eNB %d] Frame %d : no RB allocated for UE %d on CC_id %d: continue \n", + module_idP, frameP, UE_id, CC_id); + continue_flag = 1; //to next user (there might be rbs availiable for other UEs in TM5 } // If TDD @@ -640,10 +645,8 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); - + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = mac_eNB_get_rrc_status(module_idP, rnti); UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; @@ -687,21 +690,20 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, /* process retransmission */ if (round != 8) { - // get freq_allocation nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; TBS = get_TBS_DL(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid], nb_rb); - if (nb_rb <= nb_available_rb) { - if (cc[CC_id].tdd_Config != NULL) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP, CC_id, rnti, - UE_list->UE_template[CC_id][UE_id].DAI, subframeP); - LOG_D(MAC, - "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframeP, UE_id, - UE_list->UE_template[CC_id][UE_id].DAI); - } + if (nb_rb <= nb_available_rb) { + if (cc[CC_id].tdd_Config != NULL) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id].DAI, subframeP); + LOG_D(MAC, + "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframeP, UE_id, + UE_list->UE_template[CC_id][UE_id].DAI); + } if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { for (j = 0; j < N_RBG[CC_id]; ++j) { // for indicating the rballoc for each sub-band @@ -715,6 +717,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == 1) { if (UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]) printf("WARN: rballoc_subband not free for retrans?\n"); + UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] = ue_sched_ctl->rballoc_sub_UE[CC_id][j]; if ((j == N_RBG[CC_id] - 1) && ((N_RB_DL[CC_id] == 25) || (N_RB_DL[CC_id] == 50))) { @@ -744,7 +747,6 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, case 7: default: LOG_D(MAC, "retransmission DL_REQ: rnti:%x\n", rnti); - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; @@ -752,13 +754,12 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = - get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); + get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI: see Table 4-10 from SCF082 - nFAPI specifications dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // Don't adjust power when retransmitting dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; @@ -768,7 +769,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, // TDD if (cc[CC_id].tdd_Config != NULL) { dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = - (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; + (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; LOG_D(MAC, "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", module_idP, CC_id, harq_pid, round, @@ -779,17 +780,15 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", module_idP, CC_id, harq_pid, round, UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]); + } - } - if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, rnti)) { - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - + if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, rnti)) { + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1, /* retransmission, no pdu_index */ rnti, 0, // type 0 allocation from 7.1.6 in 36.213 @@ -802,7 +801,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme 1, // number of layers 1, // number of subbands - // uint8_t codebook_index, + // uint8_t codebook_index, 4, // UE category capacity UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 @@ -811,12 +810,10 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode 0, //number of PRBs treated as one subband, not used here 0 // number of beamforming vectors, not used here - ); - + ); LOG_D(MAC, "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", eNB->pdu_index[CC_id], round); - program_dlsch_acknak(module_idP, CC_id, UE_id, frameP, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); // No TX request for retransmission (check if null request for FAPI) @@ -828,32 +825,32 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_SCHEDULED); + //eNB_UE_stats->dlsch_trials[round]++; + UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = eNB_UE_stats->dlsch_mcs1; + } else { + LOG_D(MAC, + "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", + module_idP, frameP, CC_id, UE_id); + } + } else { /* This is a potentially new SDU opportunity */ + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - //eNB_UE_stats->dlsch_trials[round]++; - UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = eNB_UE_stats->dlsch_mcs1; - } else { - LOG_D(MAC, - "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", - module_idP, frameP, CC_id, UE_id); - } - } else { /* This is a potentially new SDU opportunity */ - rlc_status.bytes_in_buffer = 0; - - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - - // add the length for all the control elements (timing adv, drx, etc) : header + payload + // add the length for all the control elements (timing adv, drx, etc) : header + payload if (ue_sched_ctl->ta_timer == 0) { ta_update = ue_sched_ctl->ta_update; + /* if we send TA then set timer to not send it for a while */ if (ta_update != 31) ue_sched_ctl->ta_timer = 20; + /* reset ta_update */ ue_sched_ctl->ta_update = 31; } else { @@ -862,44 +859,43 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, ta_len = (ta_update != 31) ? 2 : 0; - // RLC data on DCCH - if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, + // RLC data on DCCH + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS - ta_len - header_length_total - sdu_length_total - 3 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - + ); sdu_lengths[0] = 0; - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, subframeP, CC_id, - TBS - ta_len - header_length_total - sdu_length_total - 3); - - sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, subframeP, CC_id, + TBS - ta_len - header_length_total - sdu_length_total - 3); + sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used - (char *)&dlsch_buffer[0] + (char *)&dlsch_buffer[0] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - + ); pthread_mutex_lock(&rrc_release_freelist); - if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)){ + + if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)) { uint16_t release_total = 0; - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + + for(uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0) { release_total++; - }else{ + } else { continue; } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { rrc_release_info.RRC_release_ctrl[release_num].flag = 3; LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 1->3\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); break; @@ -907,10 +903,11 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } } } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { rrc_release_info.RRC_release_ctrl[release_num].flag = 4; LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); break; @@ -918,17 +915,19 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } } } + if(release_total >= rrc_release_info.num_UEs) break; } } - pthread_mutex_unlock(&rrc_release_freelist); + pthread_mutex_unlock(&rrc_release_freelist); RA_t *ra = &eNB->common_channels[CC_id].ra[0]; + for (uint8_t ra_ii = 0; ra_ii < NB_RA_PROC_MAX; ra_ii++) { - if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]){ + if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]) { ra[ra_ii].crnti_harq_pid = harq_pid; ra[ra_ii].state = MSGCRNTI_ACK; break; @@ -941,26 +940,21 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), T_INT(sdu_lengths[0])); - - LOG_D(MAC, "[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", - module_idP, CC_id, sdu_lengths[0]); - - sdu_length_total = sdu_lengths[0]; - sdu_lcids[0] = DCCH; + LOG_D(MAC, "[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n", + module_idP, CC_id, sdu_lengths[0]); + sdu_length_total = sdu_lengths[0]; + sdu_lcids[0] = DCCH; UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[0] = DCCH; UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[DCCH] = sdu_lengths[0]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH] += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] += sdu_lengths[0]; - + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH] += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] += sdu_lengths[0]; header_length_last = 1 + 1 + (sdu_lengths[0] >= 128); header_length_total += header_length_last; - - num_sdus = 1; - + num_sdus = 1; #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC, - "[eNB %d][DCCH] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[0]); + "[eNB %d][DCCH] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[0]); for (j = 0; j < sdu_lengths[0]; ++j) { LOG_T(MAC, "%x ", dlsch_buffer[j]); @@ -968,55 +962,48 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_T(MAC, "\n"); #endif - } - } + } + } - // RLC data on DCCH1 - if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, + // RLC data on DCCH1 + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS - ta_len - header_length_total - sdu_length_total - 3 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif ); - - // DCCH SDU - sdu_lengths[num_sdus] = 0; - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, CC_id, - TBS - ta_len - header_length_total - sdu_length_total - 3); - - sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total] + // DCCH SDU + sdu_lengths[num_sdus] = 0; + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, CC_id, + TBS - ta_len - header_length_total - sdu_length_total - 3); + sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - + ); T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); - - sdu_lcids[num_sdus] = DCCH1; - sdu_length_total += sdu_lengths[num_sdus]; + sdu_lcids[num_sdus] = DCCH1; + sdu_length_total += sdu_lengths[num_sdus]; UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = DCCH1; UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[DCCH1] = sdu_lengths[num_sdus]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus]; - + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus]; header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); header_length_total += header_length_last; - - num_sdus++; - + num_sdus++; #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC, - "[eNB %d][DCCH1] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[num_sdus]); + "[eNB %d][DCCH1] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[num_sdus]); for (j = 0; j < sdu_lengths[num_sdus]; ++j) { LOG_T(MAC, "%x ", dlsch_buffer[j]); @@ -1024,79 +1011,92 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_T(MAC, "\n"); #endif + } + } - } - } - - // TODO: lcid has to be sorted before the actual allocation (similar struct as ue_list). - for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { - // TODO: check if the lcid is active - - LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP, frameP, lcid, TBS, + // TODO: lcid has to be sorted before the actual allocation (similar struct as ue_list). + for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) { + // TODO: check if the lcid is active + LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, + frameP, + lcid, + TBS, TBS - ta_len - header_length_total - sdu_length_total - 3); - if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - header_length_total - sdu_length_total - 3 + if (TBS - ta_len - header_length_total - sdu_length_total - 3 > 0) { + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_length_total - sdu_length_total - 3 #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + , 0, 0 #endif ); - - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP, frameP, + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, + frameP, TBS - ta_len - header_length_total - sdu_length_total - 3, - lcid, - header_length_total); - - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, - TBS, //not used - (char *)&dlsch_buffer[sdu_length_total] + lcid, + header_length_total); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + , 0, 0 #endif - ); - - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_INT(lcid), T_INT(sdu_lengths[num_sdus])); - - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_idP, sdu_lengths[num_sdus], lcid); - - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid]++; + ); + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(lcid), + T_INT(sdu_lengths[num_sdus])); + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, + sdu_lengths[num_sdus], + lcid); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid]++; UE_list->eNB_UE_stats[CC_id][UE_id].lcid_sdu[num_sdus] = lcid; UE_list->eNB_UE_stats[CC_id][UE_id].sdu_length_tx[lcid] = sdu_lengths[num_sdus]; - UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; - + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; header_length_last = 1 + 1 + (sdu_lengths[num_sdus] >= 128); header_length_total += header_length_last; - - num_sdus++; - - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - } - } else { - // no TBS left - break; - } - } + num_sdus++; + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + // reset RRC inactivity timer after uplane activity + ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti); + if (ue_contextP != NULL) { + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + } else { + LOG_E(MAC, "[eNB %d] CC_id %d Couldn't find the context associated to UE (RNTI %d) and reset RRC inactivity timer\n", + module_idP, + CC_id, + rnti); + } + } // end if (rlc_status.bytes_in_buffer > 0) + } else { // no TBS left + break; // break for (lcid = NB_RB_MAX - 1; lcid >= DTCH; lcid--) + } + } /* last header does not have length field */ if (header_length_total) { @@ -1104,13 +1104,11 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, header_length_total++; } - // there is at least one SDU or TA command - // if (num_sdus > 0 ){ - if (ta_len + sdu_length_total + header_length_total > 0) { - - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - + // there is at least one SDU or TA command + // if (num_sdus > 0 ){ + if (ta_len + sdu_length_total + header_length_total > 0) { + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 mcs = eNB_UE_stats->dlsch_mcs1; if (mcs == 0) { @@ -1118,17 +1116,18 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } else { nb_rb = min_rb_unit[CC_id]; } + TBS = get_TBS_DL(mcs, nb_rb); - while (TBS < sdu_length_total + header_length_total + ta_len) { - nb_rb += min_rb_unit[CC_id]; // + while (TBS < sdu_length_total + header_length_total + ta_len) { + nb_rb += min_rb_unit[CC_id]; // - if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - nb_rb = nb_available_rb; - break; - } + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); + nb_rb = nb_available_rb; + break; + } TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); } @@ -1156,41 +1155,40 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, } } - // decrease mcs until TBS falls below required length - while ((TBS > sdu_length_total + header_length_total + ta_len) && (mcs > 0)) { - mcs--; - TBS = get_TBS_DL(mcs, nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < sdu_length_total + header_length_total + ta_len) - && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) - && (mcs < 28)) - || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) - && (mcs <= 15)))) { - mcs++; - TBS = get_TBS_DL(mcs, nb_rb); - } + // decrease mcs until TBS falls below required length + while ((TBS > sdu_length_total + header_length_total + ta_len) && (mcs > 0)) { + mcs--; + TBS = get_TBS_DL(mcs, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < sdu_length_total + header_length_total + ta_len) + && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) + && (mcs < 28)) + || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) + && (mcs <= 15)))) { + mcs++; + TBS = get_TBS_DL(mcs, nb_rb); + } LOG_D(MAC, "dlsch_mcs before and after the rate matching = (%d, %d)\n", eNB_UE_stats->dlsch_mcs1, mcs); - #ifdef DEBUG_eNB_SCHEDULER LOG_D(MAC, - "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", - module_idP, CC_id, mcs, TBS, nb_rb); + "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP, CC_id, mcs, TBS, nb_rb); // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); #endif - if (TBS - header_length_total - sdu_length_total - ta_len <= 2) { - padding = TBS - header_length_total - sdu_length_total - ta_len; - post_padding = 0; - } else { - padding = 0; - post_padding = 1; - } + if (TBS - header_length_total - sdu_length_total - ta_len <= 2) { + padding = TBS - header_length_total - sdu_length_total - ta_len; + post_padding = 0; + } else { + padding = 0; + post_padding = 1; + } offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus @@ -1200,17 +1198,18 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, NULL, // contention res id padding, post_padding); - //#ifdef DEBUG_eNB_SCHEDULER - if (ta_update != 31) { - LOG_D(MAC, - "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_length %d\n", - module_idP, frameP, UE_id, CC_id, - sdu_length_total, num_sdus, sdu_lengths[0], - sdu_lcids[0], offset, ta_update, padding, - post_padding, mcs, TBS, nb_rb, - header_length_total); - } - //#endif + //#ifdef DEBUG_eNB_SCHEDULER + if (ta_update != 31) { + LOG_D(MAC, + "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_length %d\n", + module_idP, frameP, UE_id, CC_id, + sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], offset, ta_update, padding, + post_padding, mcs, TBS, nb_rb, + header_length_total); + } + + //#endif #ifdef DEBUG_eNB_SCHEDULER LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n"); @@ -1220,98 +1219,91 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_T(MAC, "\n"); #endif - // cycle through SDUs and place in dlsch_buffer memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total); // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); - // fill remainder of DLSCH with 0 - for (j = 0; j < (TBS - sdu_length_total - offset); j++) { - UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = 0; - } - - if (opt_enabled == 1) { - trace_pdu(DIRECTION_DOWNLINK, - (uint8_t *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], - TBS, module_idP, WS_C_RNTI, - UE_RNTI(module_idP, UE_id), eNB->frame, - eNB->subframe, 0, 0); - LOG_D(OPT, - "[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", - module_idP, CC_id, frameP, - UE_RNTI(module_idP, UE_id), TBS); - } - - T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); + // fill remainder of DLSCH with 0 + for (j = 0; j < (TBS - sdu_length_total - offset); j++) { + UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = 0; + } - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; + if (opt_enabled == 1) { + trace_pdu(DIRECTION_DOWNLINK, + (uint8_t *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], + TBS, module_idP, WS_C_RNTI, + UE_RNTI(module_idP, UE_id), eNB->frame, + eNB->subframe, 0, 0); + LOG_D(OPT, + "[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n", + module_idP, CC_id, frameP, + UE_RNTI(module_idP, UE_id), TBS); + } + T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_SCHEDULED); // store stats eNB->eNB_stats[CC_id].dlsch_bytes_tx += sdu_length_total; eNB->eNB_stats[CC_id].dlsch_pdus_tx += 1; - - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; UE_list->eNB_UE_stats[CC_id][UE_id].num_mac_sdu_tx = num_sdus; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = mcs; - UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; - + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = mcs; + UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes = TBS - sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes += sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes += TBS; UE_list->eNB_UE_stats[CC_id][UE_id].total_num_pdus += 1; - if (cc[CC_id].tdd_Config != NULL) { // TDD - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP, CC_id, rnti, - UE_list->UE_template[CC_id][UE_id].DAI, + if (cc[CC_id].tdd_Config != NULL) { // TDD + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id].DAI, subframeP); - } - - // do PUCCH power control - // this is the normalized RX power - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - - /* unit is not dBm, it's special from nfapi */ - // converting to dBm: ToDo: Noise power hard coded to 30 - normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30; - target_rx_power= eNB->puCch10xSnr/10 + 30; - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; - if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case - ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around - if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { - ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP; - - if (normalized_rx_power > (target_rx_power + 4)) { - tpc = 0; //-1 - } else if (normalized_rx_power < (target_rx_power - 4)) { - tpc = 2; //+1 - } else { - tpc = 1; //0 - } - - LOG_D(MAC, - "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n", - module_idP, frameP, subframeP, harq_pid, tpc, - normalized_rx_power, target_rx_power); - - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } + } + + // do PUCCH power control + // this is the normalized RX power + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; + /* unit is not dBm, it's special from nfapi */ + // converting to dBm: ToDo: Noise power hard coded to 30 + normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30; + target_rx_power= eNB->puCch10xSnr/10 + 30; + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + + if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case + ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP; + + if (normalized_rx_power > (target_rx_power + 4)) { + tpc = 0; //-1 + } else if (normalized_rx_power < (target_rx_power - 4)) { + tpc = 2; //+1 + } else { + tpc = 1; //0 + } + + LOG_D(MAC, + "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n", + module_idP, frameP, subframeP, harq_pid, tpc, + normalized_rx_power, target_rx_power); + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); @@ -1319,16 +1311,15 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = - get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format1); + get_aggregation(get_bw_index(module_idP, CC_id), ue_sched_ctl->dl_cqi[CC_id], format1); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = - 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; //deactivate second codeword @@ -1337,7 +1328,7 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, if (cc[CC_id].tdd_Config != NULL) { //TDD dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = - (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; + (UE_list->UE_template[CC_id][UE_id].DAI - 1) & 3; LOG_D(MAC, "[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", module_idP, CC_id, harq_pid, @@ -1347,115 +1338,102 @@ schedule_ue_spec(module_id_t module_idP, int slice_idxP, LOG_D(MAC, "[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", module_idP, CC_id, harq_pid, mcs); + } - } - - LOG_D(MAC, "Checking feasibility pdu %d (new sdu)\n", - dl_req->number_pdu); - - if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.aggregation_level, rnti)) { - ue_sched_ctl->round[CC_id][harq_pid] = 0; - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + LOG_D(MAC, "Checking feasibility pdu %d (new sdu)\n", + dl_req->number_pdu); + if (!CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, rnti)) { + ue_sched_ctl->round[CC_id][harq_pid] = 0; + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; eNB->DL_req[CC_id].sfn_sf = frameP << 4 | subframeP; eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - // Toggle NDI for next time LOG_D(MAC, "CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", CC_id, frameP, subframeP, UE_id, rnti, harq_pid, UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); - - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, - "physicalConfigDedicated is NULL\n"); - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated != NULL, - "physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); - - fill_nfapi_dlsch_config(eNB, dl_req, TBS, eNB->pdu_index[CC_id], rnti, 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(mcs), 0, // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, - (frameP * 10) + subframeP, - TBS, eNB->pdu_index[CC_id], - eNB->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0]); - - LOG_D(MAC, - "Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n", - eNB->pdu_index[CC_id]); - - eNB->pdu_index[CC_id]++; - program_dlsch_acknak(module_idP, CC_id, UE_id, - frameP, subframeP, - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - } else { - LOG_W(MAC, - "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", - frameP, subframeP, UE_id, rnti); - } - } else { // There is no data from RLC or MAC header, so don't schedule - - } + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid] = 1 - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated != NULL, + "physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated != NULL, + "physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + fill_nfapi_dlsch_config(eNB, dl_req, TBS, eNB->pdu_index[CC_id], rnti, 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(mcs), 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, + (frameP * 10) + subframeP, + TBS, eNB->pdu_index[CC_id], + eNB->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0]); + LOG_D(MAC, + "Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n", + eNB->pdu_index[CC_id]); + eNB->pdu_index[CC_id]++; + program_dlsch_acknak(module_idP, CC_id, UE_id, + frameP, subframeP, + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + } else { + LOG_W(MAC, + "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", + frameP, subframeP, UE_id, rnti); + } + } else { // There is no data from RLC or MAC header, so don't schedule + } } if (cc[CC_id].tdd_Config != NULL) { // TDD set_ul_DAI(module_idP, UE_id, CC_id, frameP, subframeP); } - } // UE_id loop - } // CC_id loop + } // UE_id loop + } // CC_id loop fill_DLSCH_dci(module_idP, frameP, subframeP, mbsfn_flag); - stop_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_OUT); } //------------------------------------------------------------------------------ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, - int frameP, - sub_frame_t subframeP, - uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX]) + int frameP, + sub_frame_t subframeP, + uint8_t rballoc_sub[NFAPI_CC_MAX][N_RBG_MAX]) //------------------------------------------------------------------------------ { // FIXME: I'm prototyping the algorithm, so there may be arrays and variables that carry redundant information here and in pre_processor_results struct. - int UE_id, CC_id, rbg, i; int N_RB_DL, min_rb_unit, tm; int owned, used; - UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; slice_info_t *sli = &RC.mac[Mod_id]->slice_info; UE_sched_ctrl *ue_sched_ctl; COMMON_channels_t *cc; int N_RBG[NFAPI_CC_MAX]; - int slice_sorted_list[MAX_NUM_SLICES]; int slice_idx; int8_t free_rbgs_map[NFAPI_CC_MAX][N_RBG_MAX]; int has_traffic[NFAPI_CC_MAX][MAX_NUM_SLICES]; uint8_t allocation_mask[NFAPI_CC_MAX][N_RBG_MAX]; - uint16_t (*nb_rbs_remaining)[MAX_MOBILES_PER_ENB]; uint16_t (*nb_rbs_required)[MAX_MOBILES_PER_ENB]; uint8_t (*MIMO_mode_indicator)[N_RBG_MAX]; @@ -1468,9 +1446,11 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { cc = &RC.mac[Mod_id]->common_channels[CC_id]; N_RBG[CC_id] = to_rbg(cc->mib->message.dl_Bandwidth); + for (rbg = 0; rbg < N_RBG[CC_id]; ++rbg) { for (i = 0; i < sli->n_dl; ++i) { owned = sli->pre_processor_results[i].slice_allocation_mask[CC_id][rbg]; + if (owned) { used = rballoc_sub[CC_id][rbg]; free_rbgs_map[CC_id][rbg] = used ? -1 : i; @@ -1485,6 +1465,7 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { for (i = 0; i < sli->n_dl; ++i) { has_traffic[CC_id][i] = 0; + for (UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; ++UE_id) { if (sli->pre_processor_results[i].nb_rbs_remaining[CC_id][UE_id] > 0) { has_traffic[CC_id][i] = 1; @@ -1499,7 +1480,6 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, // MULTIPLEXING // This part is an adaptation of dlsch_scheduler_pre_processor_allocate() code for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { - N_RB_DL = to_prb(RC.mac[Mod_id]->common_channels[CC_id].mib->message.dl_Bandwidth); min_rb_unit = get_min_rb_unit(Mod_id, CC_id); @@ -1515,11 +1495,13 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, allocation_mask[CC_id][rbg] = 0; continue; } + if (sli->dl[free_rbgs_map[CC_id][rbg]].isol == 1) { // RBG belongs to an isolated slice allocation_mask[CC_id][rbg] = 0; continue; } + // RBG is free allocation_mask[CC_id][rbg] = 1; } @@ -1528,7 +1510,6 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, // (UE list gets sorted every time pre_processor is called so it is probably dirty at this point) // FIXME: There is only one UE_list for all slices, so it must be sorted again each time we use it sort_UEs(Mod_id, slice_idx, frameP, subframeP); - nb_rbs_remaining = sli->pre_processor_results[slice_idx].nb_rbs_remaining; nb_rbs_required = sli->pre_processor_results[slice_idx].nb_rbs_required; MIMO_mode_indicator = sli->pre_processor_results[slice_idx].MIMO_mode_indicator; @@ -1539,13 +1520,17 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, tm = get_tmode(Mod_id, CC_id, UE_id); for (rbg = 0; rbg < N_RBG[CC_id]; ++rbg) { - // FIXME: I think that some of these checks are redundant if (allocation_mask[CC_id][rbg] == 0) continue; + if (rballoc_sub[CC_id][rbg] != 0) continue; + if (ue_sched_ctl->rballoc_sub_UE[CC_id][rbg] != 0) continue; + if (nb_rbs_remaining[CC_id][UE_id] <= 0) continue; + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] >= nb_rbs_required[CC_id][UE_id]) continue; + if (ue_sched_ctl->dl_pow_off[CC_id] == 0) continue; if ((rbg == N_RBG[CC_id] - 1) && ((N_RB_DL == 25) || (N_RB_DL == 50))) { @@ -1555,9 +1540,11 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, free_rbgs_map[CC_id][rbg] = -1; ue_sched_ctl->rballoc_sub_UE[CC_id][rbg] = 1; MIMO_mode_indicator[CC_id][rbg] = 1; + if (tm == 5) { ue_sched_ctl->dl_pow_off[CC_id] = 1; } + nb_rbs_remaining[CC_id][UE_id] = nb_rbs_remaining[CC_id][UE_id] - min_rb_unit + 1; ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit - 1; } @@ -1568,9 +1555,11 @@ void dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id, free_rbgs_map[CC_id][rbg] = -1; ue_sched_ctl->rballoc_sub_UE[CC_id][rbg] = 1; MIMO_mode_indicator[CC_id][rbg] = 1; + if (tm == 5) { ue_sched_ctl->dl_pow_off[CC_id] = 1; } + nb_rbs_remaining[CC_id][UE_id] = nb_rbs_remaining[CC_id][UE_id] - min_rb_unit; ue_sched_ctl->pre_nb_available_rbs[CC_id] = ue_sched_ctl->pre_nb_available_rbs[CC_id] + min_rb_unit; } @@ -1592,14 +1581,12 @@ void dlsch_scheduler_qos_multiplexing(module_id_t Mod_id, int frameP, sub_frame_ for (CC_id = 0; CC_id < RC.nb_mac_CC[Mod_id]; ++CC_id) { for (i = 0; i < sli->n_dl; ++i) { - // Sort UE again // FIXME: There is only one UE_list for all slices, so it must be sorted again each time we use it sort_UEs(Mod_id, (uint8_t)i, frameP, subframeP); for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { //ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - // TODO: Do something here // ue_sched_ctl->pre_nb_available_rbs[CC_id]; } @@ -1614,7 +1601,6 @@ fill_DLSCH_dci(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, int *mbsfn_flagP) //------------------------------------------------------------------------------ { - // loop over all allocated UEs and compute frequency allocations for PDSCH int UE_id = -1; uint8_t /* first_rb, */ nb_rb = 3; @@ -1622,7 +1608,6 @@ fill_DLSCH_dci(module_id_t module_idP, //unsigned char *vrb_map; uint8_t rballoc_sub[25]; //uint8_t number_of_subbands=13; - //unsigned char round; unsigned char harq_pid; int i; @@ -1632,7 +1617,6 @@ fill_DLSCH_dci(module_id_t module_idP, int N_RBG; int N_RB_DL; COMMON_channels_t *cc; - start_meas(&eNB->fill_DLSCH_dci); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_IN); @@ -1654,11 +1638,10 @@ fill_DLSCH_dci(module_id_t module_idP, eNB_dlsch_info[module_idP][CC_id][UE_id].status); if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) { - // clear scheduling flag eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING; rnti = UE_RNTI(module_idP, UE_id); - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; /// Synchronizing rballoc with rballoc_sub @@ -1673,22 +1656,22 @@ fill_DLSCH_dci(module_id_t module_idP, i < DL_req[CC_id].dl_config_request_body.number_pdu; i++) { dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[i]; + if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE) && (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb, N_RB_DL, N_RBG, - rballoc_sub); + rballoc_sub); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; } else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE) && (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type == 0)) { dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb, N_RB_DL, N_RBG, - rballoc_sub); + rballoc_sub); } } } } - } stop_meas(&eNB->fill_DLSCH_dci); @@ -1701,20 +1684,17 @@ unsigned char *get_dlsch_sdu(module_id_t module_idP, uint8_t TBindex) //------------------------------------------------------------------------------ { - int UE_id; eNB_MAC_INST *eNB = RC.mac[module_idP]; if (rntiP == SI_RNTI) { LOG_D(MAC, "[eNB %d] CC_id %d Frame %d Get DLSCH sdu for BCCH \n", module_idP, CC_id, frameP); - return ((unsigned char *) &eNB->common_channels[CC_id].BCCH_pdu.payload[0]); } if (rntiP == P_RNTI) { LOG_D(MAC, "[eNB %d] CC_id %d Frame %d Get PCH sdu for PCCH \n", module_idP, CC_id, frameP); - return ((unsigned char *) &eNB->common_channels[CC_id].PCCH_pdu.payload[0]); } @@ -1731,34 +1711,29 @@ unsigned char *get_dlsch_sdu(module_id_t module_idP, module_idP, frameP, CC_id, rntiP); return NULL; } - } //------------------------------------------------------------------------------ void update_ul_dci(module_id_t module_idP, - uint8_t CC_idP, rnti_t rntiP, uint8_t daiP, sub_frame_t subframe) + uint8_t CC_idP, rnti_t rntiP, uint8_t daiP, sub_frame_t subframe) //------------------------------------------------------------------------------ { - nfapi_hi_dci0_request_t *HI_DCI0_req = &RC.mac[module_idP]->HI_DCI0_req[CC_idP][subframe]; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = - &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; + &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0]; COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_idP]; int i; - - if (cc->tdd_Config != NULL) { // TDD + if (cc->tdd_Config != NULL) { // TDD for (i = 0; - i <HI_DCI0_req->hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_hi; - i++) { - + i <HI_DCI0_req->hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_hi; + i++) { if ((hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) && (hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti == rntiP)) hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.dl_assignment_index = (daiP - 1) & 3; - } } } @@ -1864,7 +1839,6 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) uint8_t Lcrbs = 0; uint16_t rb_bit = 168; /* RB bit number value is unsure */ #endif - start_meas(&eNB->schedule_pch); for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) { @@ -1872,10 +1846,12 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) vrb_map = (void *) &cc->vrb_map; n_rb_dl = to_prb(cc->mib->message.dl_Bandwidth); dl_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (uint16_t i = 0; i < MAX_MOBILES_PER_ENB; i++) { if (UE_PF_PO[CC_id][i].enable_flag != TRUE) { continue; } + if (frameP % UE_PF_PO[CC_id][i].T == UE_PF_PO[CC_id][i].PF_min && subframeP == UE_PF_PO[CC_id][i].PO) { pcch_sdu_length = mac_rrc_data_req(module_idP, CC_id, @@ -1883,140 +1859,166 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) PCCH, 1, &cc->PCCH_pdu.payload[0], i); // used for ue index + if (pcch_sdu_length == 0) { LOG_D(MAC, "[eNB %d] Frame %d subframe %d: PCCH not active(size = 0 byte)\n", module_idP, frameP, subframeP); continue; } + LOG_D(MAC, "[eNB %d] Frame %d subframe %d: PCCH->PCH CC_id %d UE_id %d, Received %d bytes \n", module_idP, frameP, subframeP, CC_id, i, pcch_sdu_length); #ifdef FORMAT1C - //NO SIB - if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || - (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { - switch (n_rb_dl) { - case 25: - n_gap = GAP_MAP[3][0]; /* expect: 12 */ - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ - first_rb = 10; - break; - case 50: - n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ - } - first_rb = 24; - break; - case 100: - n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ - } - first_rb = 48; - break; - } - } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging - switch (n_rb_dl) { - case 25: - n_gap = GAP_MAP[3][0]; /* expect: 12 */ - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ - first_rb = 14; - break; - case 50: - n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ - } - first_rb = 28; - break; - case 100: - n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ - if (gap_index > 0) { - n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ - } else { - n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ - } - first_rb = 52; - break; - } - } - /* Get MCS for length of PCH */ - if (pcch_sdu_length <= TBStable1C[0]) { - mcs=0; - } else if (pcch_sdu_length <= TBStable1C[1]) { - mcs=1; - } else if (pcch_sdu_length <= TBStable1C[2]) { - mcs=2; - } else if (pcch_sdu_length <= TBStable1C[3]) { - mcs=3; - } else if (pcch_sdu_length <= TBStable1C[4]) { - mcs=4; - } else if (pcch_sdu_length <= TBStable1C[5]) { - mcs=5; - } else if (pcch_sdu_length <= TBStable1C[6]) { - mcs=6; - } else if (pcch_sdu_length <= TBStable1C[7]) { - mcs=7; - } else if (pcch_sdu_length <= TBStable1C[8]) { - mcs=8; - } else if (pcch_sdu_length <= TBStable1C[9]) { - mcs=9; - } else { - /* unexpected: pcch sdb size is over max value*/ - LOG_E(MAC,"[eNB %d] Frame %d : PCCH->PCH CC_id %d, Received %d bytes is over max length(256) \n", - module_idP, frameP,CC_id, pcch_sdu_length); - return; - } - rb_num = TBStable1C[mcs] / rb_bit + ( (TBStable1C[mcs] % rb_bit == 0)? 0: 1) + 1; - /* calculate N_RB_STEP and Lcrbs */ - if (n_rb_dl < 50) { - n_rb_step = 2; - Lcrbs = rb_num / 2 + ((rb_num % 2 == 0) ? 0:2); - } else { - n_rb_step = 4; - Lcrbs = rb_num / 4 + ((rb_num % 4 == 0) ? 0:4); - } - for(i = 0;i < Lcrbs ;i++){ - vrb_map[first_rb+i] = 1; - } + + //NO SIB + if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { + switch (n_rb_dl) { + case 25: + n_gap = GAP_MAP[3][0]; /* expect: 12 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ + first_rb = 10; + break; + + case 50: + n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ + } + + first_rb = 24; + break; + + case 100: + n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ + } + + first_rb = 48; + break; + } + } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging + switch (n_rb_dl) { + case 25: + n_gap = GAP_MAP[3][0]; /* expect: 12 */ + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 24 */ + first_rb = 14; + break; + + case 50: + n_gap = GAP_MAP[6][gap_index]; /* expect: 27 or 9 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* 36 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 46 */ + } + + first_rb = 28; + break; + + case 100: + n_gap = GAP_MAP[8][gap_index]; /* expect: 48 or 16 */ + + if (gap_index > 0) { + n_vrb_dl = (n_rb_dl / (2*n_gap)) * (2*n_gap); /* expect: 96 */ + } else { + n_vrb_dl = 2*((n_gap < (n_rb_dl - n_gap)) ? n_gap : (n_rb_dl - n_gap)); /* expect: 96 */ + } + + first_rb = 52; + break; + } + } + + /* Get MCS for length of PCH */ + if (pcch_sdu_length <= TBStable1C[0]) { + mcs=0; + } else if (pcch_sdu_length <= TBStable1C[1]) { + mcs=1; + } else if (pcch_sdu_length <= TBStable1C[2]) { + mcs=2; + } else if (pcch_sdu_length <= TBStable1C[3]) { + mcs=3; + } else if (pcch_sdu_length <= TBStable1C[4]) { + mcs=4; + } else if (pcch_sdu_length <= TBStable1C[5]) { + mcs=5; + } else if (pcch_sdu_length <= TBStable1C[6]) { + mcs=6; + } else if (pcch_sdu_length <= TBStable1C[7]) { + mcs=7; + } else if (pcch_sdu_length <= TBStable1C[8]) { + mcs=8; + } else if (pcch_sdu_length <= TBStable1C[9]) { + mcs=9; + } else { + /* unexpected: pcch sdb size is over max value*/ + LOG_E(MAC,"[eNB %d] Frame %d : PCCH->PCH CC_id %d, Received %d bytes is over max length(256) \n", + module_idP, frameP,CC_id, pcch_sdu_length); + return; + } + + rb_num = TBStable1C[mcs] / rb_bit + ( (TBStable1C[mcs] % rb_bit == 0)? 0: 1) + 1; + + /* calculate N_RB_STEP and Lcrbs */ + if (n_rb_dl < 50) { + n_rb_step = 2; + Lcrbs = rb_num / 2 + ((rb_num % 2 == 0) ? 0:2); + } else { + n_rb_step = 4; + Lcrbs = rb_num / 4 + ((rb_num % 4 == 0) ? 0:4); + } + + for(i = 0; i < Lcrbs ; i++) { + vrb_map[first_rb+i] = 1; + } + #else - //NO SIB - if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || - (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { - switch (n_rb_dl) { - case 25: - first_rb = 10; - break; - case 50: - first_rb = 24; - break; - case 100: - first_rb = 48; - break; - } - } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging - switch (n_rb_dl) { - case 25: - first_rb = 14; - break; - case 50: - first_rb = 28; - break; - case 100: - first_rb = 52; - break; - } - } + + //NO SIB + if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) || + (subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) { + switch (n_rb_dl) { + case 25: + first_rb = 10; + break; + + case 50: + first_rb = 24; + break; + + case 100: + first_rb = 48; + break; + } + } else if (subframeP == 5 && ((frameP % 2) == 0 || (frameP % 8) == 1)) { // SIB + paging + switch (n_rb_dl) { + case 25: + first_rb = 14; + break; + + case 50: + first_rb = 28; + break; + + case 100: + first_rb = 52; + break; + } + } vrb_map[first_rb] = 1; vrb_map[first_rb + 1] = 1; vrb_map[first_rb + 2] = 1; vrb_map[first_rb + 3] = 1; + /* Get MCS for length of PCH */ if (pcch_sdu_length <= get_TBS_DL(0, 3)) { mcs = 0; @@ -2039,6 +2041,7 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) } else if (pcch_sdu_length <= get_TBS_DL(9, 3)) { mcs = 9; } + #endif dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t)); @@ -2063,20 +2066,19 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; - if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, P_RNTI)) { - LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for P_RNTI\n", frameP,subframeP); - dl_req->number_dci++; - dl_req->number_pdu++; + if (!CCE_allocation_infeasible(module_idP, CC_id, 0, subframeP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, P_RNTI)) { + LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for P_RNTI\n", frameP,subframeP); + dl_req->number_dci++; + dl_req->number_pdu++; dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFE; + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dlsch_pdu)); + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = eNB->pdu_index[CC_id]; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = 0xFFFE; #ifdef FORMAT1C dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 3; // format 1C dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_vrb_dl/n_rb_step, first_rb/n_rb_step, Lcrbs/n_rb_step); @@ -2085,86 +2087,83 @@ void schedule_PCH(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_rb_dl, first_rb, 4); dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized #endif - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; - // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; - - // Rel10 fields + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1;// first block + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB==1 ) ? 0 : 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB==1 ) ? 1 : 2; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1; + // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ; + // Rel10 fields #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = 3; #endif - // Rel13 fields + // Rel13 fields #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 0; // regular UE - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not BR - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = 0; // regular UE + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not BR + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = 0xFFFF; #endif + dl_req->number_pdu++; + eNB->TX_req[CC_id].sfn_sf = (frameP<<4)+subframeP; + TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; + TX_req->pdu_length = pcch_sdu_length; + TX_req->pdu_index = eNB->pdu_index[CC_id]++; + TX_req->num_segments = 1; + TX_req->segments[0].segment_length = pcch_sdu_length; + TX_req->segments[0].segment_data = cc[CC_id].PCCH_pdu.payload; + eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; + eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; + } else { + LOG_E(MAC,"[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A/1C for Paging\n",module_idP, CC_id, frameP, subframeP); + continue; + } - dl_req->number_pdu++; + if (opt_enabled == 1) { + trace_pdu(DIRECTION_DOWNLINK, + &eNB->common_channels[CC_id].PCCH_pdu.payload[0], + pcch_sdu_length, + 0xffff, + PCCH, + P_RNTI, + eNB->frame, + eNB->subframe, + 0, + 0); + LOG_D(OPT,"[eNB %d][PCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", + module_idP, frameP, CC_id, 0xffff, pcch_sdu_length); + } - eNB->TX_req[CC_id].sfn_sf = (frameP<<4)+subframeP; - TX_req = &eNB->TX_req[CC_id].tx_request_body.tx_pdu_list[eNB->TX_req[CC_id].tx_request_body.number_of_pdus]; - TX_req->pdu_length = pcch_sdu_length; - TX_req->pdu_index = eNB->pdu_index[CC_id]++; - TX_req->num_segments = 1; - TX_req->segments[0].segment_length = pcch_sdu_length; - TX_req->segments[0].segment_data = cc[CC_id].PCCH_pdu.payload; - eNB->TX_req[CC_id].tx_request_body.tl.tag = NFAPI_TX_REQUEST_BODY_TAG; - eNB->TX_req[CC_id].tx_request_body.number_of_pdus++; - } else { - LOG_E(MAC,"[eNB %d] CCid %d Frame %d, subframe %d : Cannot add DCI 1A/1C for Paging\n",module_idP, CC_id, frameP, subframeP); - continue; - } - - if (opt_enabled == 1) { - trace_pdu(DIRECTION_DOWNLINK, - &eNB->common_channels[CC_id].PCCH_pdu.payload[0], - pcch_sdu_length, - 0xffff, - PCCH, - P_RNTI, - eNB->frame, - eNB->subframe, - 0, - 0); - LOG_D(OPT,"[eNB %d][PCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n", - module_idP, frameP, CC_id, 0xffff, pcch_sdu_length); - } - eNB->eNB_stats[CC_id].total_num_pcch_pdu+=1; - eNB->eNB_stats[CC_id].pcch_buffer=pcch_sdu_length; - eNB->eNB_stats[CC_id].total_pcch_buffer+=pcch_sdu_length; - eNB->eNB_stats[CC_id].pcch_mcs=mcs; - //paging first_rb log - LOG_D(MAC,"[eNB %d] Frame %d subframe %d PCH: paging_ue_index %d pcch_sdu_length %d mcs %d first_rb %d\n", - module_idP, frameP, subframeP, UE_PF_PO[CC_id][i].ue_index_value, pcch_sdu_length, mcs, first_rb); - - pthread_mutex_lock(&ue_pf_po_mutex); - memset(&UE_PF_PO[CC_id][i], 0, sizeof(UE_PF_PO_t)); - pthread_mutex_unlock(&ue_pf_po_mutex); + eNB->eNB_stats[CC_id].total_num_pcch_pdu+=1; + eNB->eNB_stats[CC_id].pcch_buffer=pcch_sdu_length; + eNB->eNB_stats[CC_id].total_pcch_buffer+=pcch_sdu_length; + eNB->eNB_stats[CC_id].pcch_mcs=mcs; + //paging first_rb log + LOG_D(MAC,"[eNB %d] Frame %d subframe %d PCH: paging_ue_index %d pcch_sdu_length %d mcs %d first_rb %d\n", + module_idP, frameP, subframeP, UE_PF_PO[CC_id][i].ue_index_value, pcch_sdu_length, mcs, first_rb); + pthread_mutex_lock(&ue_pf_po_mutex); + memset(&UE_PF_PO[CC_id][i], 0, sizeof(UE_PF_PO_t)); + pthread_mutex_unlock(&ue_pf_po_mutex); } } } + /* this might be misleading when pcch is inactive */ stop_meas(&eNB->schedule_pch); return; } -static int slice_priority_compare(const void *_a, const void *_b, void *_c) -{ +static int slice_priority_compare(const void *_a, const void *_b, void *_c) { const int slice_id1 = *(const int *) _a; const int slice_id2 = *(const int *) _b; const module_id_t Mod_id = *(int *) _c; @@ -2173,12 +2172,13 @@ static int slice_priority_compare(const void *_a, const void *_b, void *_c) if (sli->dl[slice_id1].prio > sli->dl[slice_id2].prio) { return -1; } + return 1; } -void slice_priority_sort(module_id_t Mod_id, int slice_list[MAX_NUM_SLICES]) -{ +void slice_priority_sort(module_id_t Mod_id, int slice_list[MAX_NUM_SLICES]) { int i; + for (i = 0; i < RC.mac[Mod_id]->slice_info.n_dl; ++i) { slice_list[i] = i; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index 7d87f92ecec75d5d1ac90037973456f3c1624e36..61617f1bb9babb9da243585f09ee63b4bcb81bc5 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -51,8 +51,8 @@ extern uint8_t nfapi_mode; #ifdef PHY_TX_THREAD -extern volatile int16_t phy_tx_txdataF_end; -extern int oai_exit; + extern volatile int16_t phy_tx_txdataF_end; + extern int oai_exit; #endif extern uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset); extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset); @@ -63,11 +63,11 @@ int last_dlsch_ue_id[MAX_NUM_CCs] = {-1}; int last_ulsch_ue_id[MAX_NUM_CCs] = {-1}; #if defined(PRE_SCD_THREAD) -uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -uint8_t dlsch_ue_select_tbl_in_use; -uint8_t new_dlsch_ue_select_tbl_in_use; -boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; -eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint16_t pre_nb_rbs_required[2][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + uint8_t dlsch_ue_select_tbl_in_use; + uint8_t new_dlsch_ue_select_tbl_in_use; + boolean_t pre_scd_activeUE[NUMBER_OF_UE_MAX]; + eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; #endif #define DEBUG_eNB_SCHEDULER 1 @@ -89,92 +89,92 @@ void set_dl_ue_select_msg4(int CC_idP, uint16_t nb_rb, int UE_id, rnti_t rnti) { dlsch_ue_select[CC_idP].ue_num++; } #if defined(PRE_SCD_THREAD) -inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size){ +inline uint16_t search_rbs_required(uint16_t mcs, uint16_t TBS,uint16_t NB_RB, uint16_t step_size) { uint16_t nb_rb,i_TBS,tmp_TBS; i_TBS=get_I_TBS(mcs); - for(nb_rb=step_size;nb_rb<NB_RB;nb_rb+=step_size){ + + for(nb_rb=step_size; nb_rb<NB_RB; nb_rb+=step_size) { tmp_TBS = TBStable[i_TBS][nb_rb-1]>>3; + if(TBS<tmp_TBS)return(nb_rb); } + return NB_RB; } void pre_scd_nb_rbs_required( module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, int min_rb_unit[MAX_NUM_CCs], - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]) -{ - int CC_id=0,UE_id, lc_id, N_RB_DL; - UE_TEMPLATE UE_template; - eNB_UE_STATS *eNB_UE_stats; - rnti_t rnti; - mac_rlc_status_resp_t rlc_status; - uint16_t step_size=2; - - N_RB_DL = to_prb(RC.mac[module_idP]->common_channels[CC_id].mib->message.dl_Bandwidth); - if(N_RB_DL==50) step_size=3; - if(N_RB_DL==100) step_size=4; - memset(nb_rbs_required, 0, sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); - UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - - for (UE_id = 0; UE_id <NUMBER_OF_UE_MAX; UE_id++) { - if (pre_scd_activeUE[UE_id] != TRUE) - continue; + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]) { + int CC_id=0,UE_id, lc_id, N_RB_DL; + UE_TEMPLATE UE_template; + eNB_UE_STATS *eNB_UE_stats; + rnti_t rnti; + mac_rlc_status_resp_t rlc_status; + uint16_t step_size=2; + N_RB_DL = to_prb(RC.mac[module_idP]->common_channels[CC_id].mib->message.dl_Bandwidth); - // store dlsch buffer + if(N_RB_DL==50) step_size=3; - // clear logical channel interface variables - UE_template.dl_buffer_total = 0; + if(N_RB_DL==100) step_size=4; - rnti = UE_RNTI(module_idP, UE_id); + memset(nb_rbs_required, 0, sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); + UE_list_t *UE_list = &RC.mac[module_idP]->UE_list; - for (lc_id = DCCH; lc_id <= DTCH; lc_id++) { - rlc_status = - mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, - ENB_FLAG_YES, MBMS_FLAG_NO, lc_id, 0 -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 -#endif - ); - UE_template.dl_buffer_total += rlc_status.bytes_in_buffer; //storing the total dlsch buffer - } - // end of store dlsch buffer + for (UE_id = 0; UE_id <NUMBER_OF_UE_MAX; UE_id++) { + if (pre_scd_activeUE[UE_id] != TRUE) + continue; - // assgin rbs required - // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - //update CQI information across component carriers - eNB_UE_stats = &pre_scd_eNB_UE_stats[CC_id][UE_id]; + // store dlsch buffer + // clear logical channel interface variables + UE_template.dl_buffer_total = 0; + rnti = UE_RNTI(module_idP, UE_id); - eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; + for (lc_id = DCCH; lc_id <= DTCH; lc_id++) { + rlc_status = + mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, + ENB_FLAG_YES, MBMS_FLAG_NO, lc_id, 0 +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + ,0, 0 +#endif + ); + UE_template.dl_buffer_total += rlc_status.bytes_in_buffer; //storing the total dlsch buffer + } + // end of store dlsch buffer + // assgin rbs required + // Calculate the number of RBs required by each UE on the basis of logical channel's buffer + //update CQI information across component carriers + eNB_UE_stats = &pre_scd_eNB_UE_stats[CC_id][UE_id]; + eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[UE_list->UE_sched_ctrl[UE_id].dl_cqi[CC_id]]; - if (UE_template.dl_buffer_total > 0) { - nb_rbs_required[CC_id][UE_id] = search_rbs_required(eNB_UE_stats->dlsch_mcs1, UE_template.dl_buffer_total, N_RB_DL, step_size); - } + if (UE_template.dl_buffer_total > 0) { + nb_rbs_required[CC_id][UE_id] = search_rbs_required(eNB_UE_stats->dlsch_mcs1, UE_template.dl_buffer_total, N_RB_DL, step_size); } + } } #endif -int cc_id_end(uint8_t *cc_id_flag ) -{ +int cc_id_end(uint8_t *cc_id_flag ) { int end_flag = 1; - for (int CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { + + for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { if (cc_id_flag[CC_id]==0) { end_flag = 0; break; } } + return end_flag; } void dlsch_scheduler_pre_ue_select_fairRR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - int* mbsfn_flag, - uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], - DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]) -{ + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int *mbsfn_flag, + uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], + DLSCH_UE_SELECT dlsch_ue_select[MAX_NUM_CCs]) { eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = eNB->common_channels; UE_list_t *UE_list = &eNB->UE_list; @@ -196,7 +196,6 @@ void dlsch_scheduler_pre_ue_select_fairRR( // Initialization for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { dlsch_ue_max_num[CC_id] = (uint16_t)RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; - // save origin DL PDU number DL_req = &eNB->DL_req[CC_id].dl_config_request_body; saved_dlsch_dci[CC_id] = DL_req->number_pdu; @@ -209,60 +208,66 @@ void dlsch_scheduler_pre_ue_select_fairRR( } DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { if (UE_list->active[UE_id] == FALSE) { continue; } rnti = UE_RNTI(module_idP, UE_id); + if (rnti == NOT_A_RNTI) { continue; } - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) { continue; } ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); - + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP,subframeP); round = ue_sched_ctl->round[CC_id][harq_pid]; + if (round != 8) { // retransmission - if(UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] == 0){ + if(UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] == 0) { continue; } + switch (get_tmode(module_idP, CC_id, UE_id)) { case 1: case 2: case 7: aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); + ue_sched_ctl->dl_cqi[CC_id], + format1); break; + case 3: aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); + ue_sched_ctl->dl_cqi[CC_id], + format2A); break; + default: LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); aggregation = 2; break; } + format_flag = 1; + if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; DL_req->number_pdu++; - nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; // Insert DLSCH(retransmission) UE into selected UE list dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; @@ -270,6 +275,7 @@ void dlsch_scheduler_pre_ue_select_fairRR( dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; dlsch_ue_select[CC_id].ue_num++; + if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { end_flag[CC_id] = 1; break; @@ -277,10 +283,10 @@ void dlsch_scheduler_pre_ue_select_fairRR( } else { if (cc[CC_id].tdd_Config != NULL) { //TDD set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); // update UL DAI after DLSCH scheduling set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); } @@ -296,227 +302,249 @@ void dlsch_scheduler_pre_ue_select_fairRR( } } } - if(cc_id_end(end_flag) == 1){ + + if(cc_id_end(end_flag) == 1) { for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { DL_req = &eNB->DL_req[CC_id].dl_config_request_body; DL_req->number_pdu = saved_dlsch_dci[CC_id]; } + return; } // Insert DLSCH(first transmission) UE into selected UE list (UE_id > last_dlsch_ue_id[CC_id]) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) { + if (mbsfn_flag[CC_id]>0) { + continue; + } + + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + + for (UE_id = (last_dlsch_ue_id[CC_id]+1); UE_id <NUMBER_OF_UE_MAX; UE_id++) { + if(end_flag[CC_id] == 1) { + break; + } + + if (UE_list->active[UE_id] == FALSE) { continue; } - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (UE_id = (last_dlsch_ue_id[CC_id]+1); UE_id <NUMBER_OF_UE_MAX; UE_id++) { - if(end_flag[CC_id] == 1){ + rnti = UE_RNTI(module_idP,UE_id); + + if (rnti == NOT_A_RNTI) + continue; + + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) { + continue; + } + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + for(i = 0; i<dlsch_ue_select[CC_id].ue_num; i++) { + if(dlsch_ue_select[CC_id].list[i].UE_id == UE_id) { break; } + } - if (UE_list->active[UE_id] == FALSE) { - continue; - } + if(i < dlsch_ue_select[CC_id].ue_num) + continue; - rnti = UE_RNTI(module_idP,UE_id); - if (rnti == NOT_A_RNTI) - continue; + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP,subframeP); + round = ue_sched_ctl->round[CC_id][harq_pid]; - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + if (round == 8) { + if (nb_rbs_required[CC_id][UE_id] == 0) { continue; } - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - for(i = 0;i<dlsch_ue_select[CC_id].ue_num;i++){ - if(dlsch_ue_select[CC_id].list[i].UE_id == UE_id){ - break; - } + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; } - if(i < dlsch_ue_select[CC_id].ue_num) - continue; - harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); + format_flag = 1; - round = ue_sched_ctl->round[CC_id][harq_pid]; - if (round == 8) { - if (nb_rbs_required[CC_id][UE_id] == 0) { - continue; - } - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - format_flag = 1; - if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { - dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - - // Insert DLSCH(first transmission) UE into selected selected UE list - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; - dlsch_ue_select[CC_id].ue_num++; + if (!CCE_allocation_infeasible(module_idP, + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { + dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; + DL_req->number_pdu++; + // Insert DLSCH(first transmission) UE into selected selected UE list + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; + dlsch_ue_select[CC_id].ue_num++; if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { - end_flag[CC_id] = 1; - break; - } - }else { - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } - add_ue_dlsch_info(module_idP, + end_flag[CC_id] = 1; + break; + } + } else { + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } + + add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_NONE); - end_flag[CC_id] = 1; - break; - } + end_flag[CC_id] = 1; + break; + } } } } - if(cc_id_end(end_flag) == 1){ + + if(cc_id_end(end_flag) == 1) { for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { DL_req = &eNB->DL_req[CC_id].dl_config_request_body; DL_req->number_pdu = saved_dlsch_dci[CC_id]; } + return; } // Insert DLSCH(first transmission) UE into selected UE list (UE_id <= last_dlsch_ue_id[CC_id]) for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (mbsfn_flag[CC_id]>0) { + if (mbsfn_flag[CC_id]>0) { + continue; + } + + DL_req = &eNB->DL_req[CC_id].dl_config_request_body; + + for (UE_id = 0; UE_id <= last_dlsch_ue_id[CC_id]; UE_id++) { + if(end_flag[CC_id] == 1) { + break; + } + + if (UE_list->active[UE_id] == FALSE) { continue; } - DL_req = &eNB->DL_req[CC_id].dl_config_request_body; - for (UE_id = 0; UE_id <= last_dlsch_ue_id[CC_id]; UE_id++) { - if(end_flag[CC_id] == 1){ + rnti = UE_RNTI(module_idP,UE_id); + + if (rnti == NOT_A_RNTI) + continue; + + if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) { + continue; + } + + ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + + for(i = 0; i<dlsch_ue_select[CC_id].ue_num; i++) { + if(dlsch_ue_select[CC_id].list[i].UE_id == UE_id) { break; } + } - if (UE_list->active[UE_id] == FALSE) { - continue; - } + if(i < dlsch_ue_select[CC_id].ue_num) + continue; - rnti = UE_RNTI(module_idP,UE_id); - if (rnti == NOT_A_RNTI) - continue; + harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP,subframeP); + round = ue_sched_ctl->round[CC_id][harq_pid]; - if(mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED){ + if (round == 8) { + if (nb_rbs_required[CC_id][UE_id] == 0) { continue; } - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - for(i = 0;i<dlsch_ue_select[CC_id].ue_num;i++){ - if(dlsch_ue_select[CC_id].list[i].UE_id == UE_id){ - break; - } + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; } - if(i < dlsch_ue_select[CC_id].ue_num) - continue; - harq_pid = frame_subframe2_dl_harq_pid(cc[CC_id].tdd_Config,frameP ,subframeP); + format_flag = 1; + + if (!CCE_allocation_infeasible(module_idP, + CC_id, + format_flag, + subframeP, + aggregation, + rnti)) { + dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; + DL_req->number_pdu++; + // Insert DLSCH(first transmission) UE into selected selected UE list + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; + dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; + dlsch_ue_select[CC_id].ue_num++; + + if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { + end_flag[CC_id] = 1; + break; + } + } else { + if (cc[CC_id].tdd_Config != NULL) { //TDD + set_ue_dai (subframeP, + UE_id, + CC_id, + cc[CC_id].tdd_Config->subframeAssignment, + UE_list); + // update UL DAI after DLSCH scheduling + set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); + } - round = ue_sched_ctl->round[CC_id][harq_pid]; - if (round == 8) { - if (nb_rbs_required[CC_id][UE_id] == 0) { - continue; - } - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } - format_flag = 1; - if (!CCE_allocation_infeasible(module_idP, - CC_id, - format_flag, - subframeP, - aggregation, - rnti)) { - dl_config_pdu = &DL_req->dl_config_pdu_list[DL_req->number_pdu]; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = (format_flag == 0)?2:1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = aggregation; - DL_req->number_pdu++; - - // Insert DLSCH(first transmission) UE into selected selected UE list - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].ue_priority = SCH_DL_FIRST; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].nb_rb = nb_rbs_required[CC_id][UE_id]; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].UE_id = UE_id; - dlsch_ue_select[CC_id].list[dlsch_ue_select[CC_id].ue_num].rnti = rnti; - dlsch_ue_select[CC_id].ue_num++; - - if (dlsch_ue_select[CC_id].ue_num == dlsch_ue_max_num[CC_id]) { - end_flag[CC_id] = 1; - break; - } - } else { - if (cc[CC_id].tdd_Config != NULL) { //TDD - set_ue_dai (subframeP, - UE_id, - CC_id, - cc[CC_id].tdd_Config->subframeAssignment, - UE_list); - // update UL DAI after DLSCH scheduling - set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); - } add_ue_dlsch_info(module_idP, CC_id, UE_id, subframeP, S_DL_NONE); - end_flag[CC_id] = 1; - break; - } + end_flag[CC_id] = 1; + break; + } } } } @@ -525,6 +553,7 @@ void dlsch_scheduler_pre_ue_select_fairRR( DL_req = &eNB->DL_req[CC_id].dl_config_request_body; DL_req->number_pdu = saved_dlsch_dci[CC_id]; } + return; } @@ -532,88 +561,74 @@ void dlsch_scheduler_pre_ue_select_fairRR( // This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, - frame_t frameP, - sub_frame_t subframeP, - int N_RBG[MAX_NUM_CCs], - int *mbsfn_flag) -{ - + frame_t frameP, + sub_frame_t subframeP, + int N_RBG[MAX_NUM_CCs], + int *mbsfn_flag) { unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX],harq_pid=0,Round=0; uint16_t temp_total_rbs_count; unsigned char temp_total_ue_count; unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; uint8_t slice_allocation[MAX_NUM_CCs][N_RBG_MAX]; - int UE_id, i; + int UE_id, i; uint16_t j,c; uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -// uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + // uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t average_rbs_per_user[MAX_NUM_CCs] = {0}; rnti_t rnti; int min_rb_unit[MAX_NUM_CCs]; -// uint16_t r1=0; + // uint16_t r1=0; uint8_t CC_id; UE_list_t *UE_list = &RC.mac[Mod_id]->UE_list; - UE_sched_ctrl *ue_sched_ctl; // int rrc_status = RRC_IDLE; COMMON_channels_t *cc; - #ifdef TM5 - int harq_pid1 = 0; - int round1 = 0, round2 = 0; - int UE_id2; - uint16_t i1, i2, i3; - rnti_t rnti1, rnti2; - LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; - LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; - UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2; + int harq_pid1 = 0; + int round1 = 0, round2 = 0; + int UE_id2; + uint16_t i1, i2, i3; + rnti_t rnti1, rnti2; + LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; + LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; + UE_sched_ctrl *ue_sched_ctl1, *ue_sched_ctl2; #endif memset(min_rb_unit,0,sizeof(min_rb_unit)); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - - if (mbsfn_flag[CC_id] > 0) // If this CC is allocated for MBSFN skip it here - continue; - - - - min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - if (UE_list->active[i] != TRUE) - continue; - - UE_id = i; - // Initialize scheduling information for all active UEs + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + if (mbsfn_flag[CC_id] > 0) // If this CC is allocated for MBSFN skip it here + continue; + min_rb_unit[CC_id] = get_min_rb_unit(Mod_id, CC_id); - dlsch_scheduler_pre_processor_reset(Mod_id, - 0, - frameP, - subframeP, - min_rb_unit, - (uint16_t (*)[NUMBER_OF_UE_MAX])nb_rbs_required, - rballoc_sub, - MIMO_mode_indicator, - mbsfn_flag); + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + if (UE_list->active[i] != TRUE) + continue; - } + UE_id = i; + // Initialize scheduling information for all active UEs + dlsch_scheduler_pre_processor_reset(Mod_id, + 0, + frameP, + subframeP, + min_rb_unit, + (uint16_t (*)[NUMBER_OF_UE_MAX])nb_rbs_required, + rballoc_sub, + MIMO_mode_indicator, + mbsfn_flag); } + } #if (!defined(PRE_SCD_THREAD)) - // Store the DLSCH buffer for each logical channel - store_dlsch_buffer(Mod_id,0, frameP, subframeP); - - - - // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - assign_rbs_required(Mod_id, 0, frameP, subframeP, nb_rbs_required, - min_rb_unit); + // Store the DLSCH buffer for each logical channel + store_dlsch_buffer(Mod_id,0, frameP, subframeP); + // Calculate the number of RBs required by each UE on the basis of logical channel's buffer + assign_rbs_required(Mod_id, 0, frameP, subframeP, nb_rbs_required, + min_rb_unit); #else - memcpy(nb_rbs_required, pre_nb_rbs_required[dlsch_ue_select_tbl_in_use] , sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); + memcpy(nb_rbs_required, pre_nb_rbs_required[dlsch_ue_select_tbl_in_use], sizeof(uint16_t)*MAX_NUM_CCs*NUMBER_OF_UE_MAX); #endif - dlsch_scheduler_pre_ue_select_fairRR(Mod_id,frameP,subframeP, mbsfn_flag,nb_rbs_required,dlsch_ue_select); for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { @@ -624,19 +639,21 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, temp_total_ue_count = dlsch_ue_select[CC_id].ue_num; for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ - temp_total_ue_count--; - continue; + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2) { + temp_total_ue_count--; + continue; } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ - temp_total_ue_count--; - continue; + + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4) { + temp_total_ue_count--; + continue; } + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; nb_rbs_required[CC_id][UE_id] = dlsch_ue_select[CC_id].list[i].nb_rb; - average_rbs_per_user[CC_id] = (uint16_t)round((double)temp_total_rbs_count/(double)temp_total_ue_count); - if( average_rbs_per_user[CC_id] < min_rb_unit[CC_id] ){ + + if( average_rbs_per_user[CC_id] < min_rb_unit[CC_id] ) { temp_total_ue_count--; dlsch_ue_select[CC_id].ue_num--; i--; @@ -644,9 +661,8 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, } rnti = dlsch_ue_select[CC_id].list[i].rnti; - ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); Round = ue_sched_ctl->round[CC_id][harq_pid]; //if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED || round > 0) { @@ -685,9 +701,11 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, dlsch_ue_select[CC_id].ue_num = i+1; break; } - LOG_D(MAC,"DLSCH UE Select: frame %d subframe %d pre_nb_available_rbs %d(i %d UE_id %d nb_rbs_required %d nb_rbs_required_remaining %d average_rbs_per_user %d (temp_total rbs_count %d ue_num %d) available_prbs %d)\n", - frameP,subframeP,ue_sched_ctl->pre_nb_available_rbs[CC_id],i,UE_id,nb_rbs_required[CC_id][UE_id],nb_rbs_required_remaining[CC_id][UE_id], - average_rbs_per_user[CC_id],temp_total_rbs_count,temp_total_ue_count,RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs); + + LOG_D(MAC, + "DLSCH UE Select: frame %d subframe %d pre_nb_available_rbs %d(i %d UE_id %d nb_rbs_required %d nb_rbs_required_remaining %d average_rbs_per_user %d (temp_total rbs_count %d ue_num %d) available_prbs %d)\n", + frameP,subframeP,ue_sched_ctl->pre_nb_available_rbs[CC_id],i,UE_id,nb_rbs_required[CC_id][UE_id],nb_rbs_required_remaining[CC_id][UE_id], + average_rbs_per_user[CC_id],temp_total_rbs_count,temp_total_ue_count,RC.mac[Mod_id]->eNB_stats[CC_id].available_prbs); #ifdef TM5 // TODO: data channel TM5: to be re-visited #endif @@ -696,231 +714,240 @@ void dlsch_scheduler_pre_processor_fairRR (module_id_t Mod_id, #ifdef TM5 - // This has to be revisited!!!! - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - i1 = 0; - i2 = 0; - i3 = 0; - - for (j = 0; j < N_RBG[CC_id]; j++) { - if (MIMO_mode_indicator[CC_id][j] == 2) { - i1 = i1 + 1; - } else if (MIMO_mode_indicator[CC_id][j] == 1) { - i2 = i2 + 1; - } else if (MIMO_mode_indicator[CC_id][j] == 0) { - i3 = i3 + 1; - } - } - - if ((i1 < N_RBG[CC_id]) && (i2 > 0) && (i3 == 0)) { - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = - PHY_vars_eNB_g[Mod_id][CC_id]-> - check_for_SUMIMO_transmissions + 1; - } - - if (i3 == N_RBG[CC_id] && i1 == 0 && i2 == 0) { - PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = - PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + - 1; - } - - if((i1 < N_RBG[CC_id]) && (i3 > 0)) { - PHY_vars_eNB_g[Mod_id][CC_id]-> - check_for_MUMIMO_transmissions + 1; - } - - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = - PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + - 1; - + // This has to be revisited!!!! + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + i1 = 0; + i2 = 0; + i3 = 0; + + for (j = 0; j < N_RBG[CC_id]; j++) { + if (MIMO_mode_indicator[CC_id][j] == 2) { + i1 = i1 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 1) { + i2 = i2 + 1; + } else if (MIMO_mode_indicator[CC_id][j] == 0) { + i3 = i3 + 1; + } } -#endif - - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ - continue; - } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ - continue; - } - UE_id = dlsch_ue_select[CC_id].list[i].UE_id; - ue_sched_ctl = &RC.mac[Mod_id]->UE_list.UE_sched_ctrl[UE_id]; - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; - - if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { - LOG_D(MAC, - "******************DL Scheduling Information for UE%d ************************\n", - UE_id); - LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, - ue_sched_ctl->dl_pow_off[CC_id]); - LOG_D(MAC, - "***********RB Alloc for every subband for UE%d ***********\n", - UE_id); - - for (j = 0; j < N_RBG[CC_id]; j++) { - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; - LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", - UE_id, j, - ue_sched_ctl->rballoc_sub_UE[CC_id][j]); - } - - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; - LOG_D(MAC, "Total RBs allocated for UE%d = %d\n", UE_id, - ue_sched_ctl->pre_nb_available_rbs[CC_id]); - } - } + if ((i1 < N_RBG[CC_id]) && (i2 > 0) && (i3 == 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_SUMIMO_transmissions + 1; } -} + if (i3 == N_RBG[CC_id] && i1 == 0 && i2 == 0) { + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + + 1; + } -//------------------------------------------------------------------------------ -void -schedule_ue_spec_fairRR(module_id_t module_idP, - frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) -//------------------------------------------------------------------------------ -{ + if((i1 < N_RBG[CC_id]) && (i3 > 0)) { + PHY_vars_eNB_g[Mod_id][CC_id]-> + check_for_MUMIMO_transmissions + 1; + } + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = + PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + + 1; + } - uint8_t CC_id; - int UE_id; -// unsigned char aggregation; - mac_rlc_status_resp_t rlc_status; - unsigned char header_len_dcch = 0, header_len_dcch_tmp = 0; - unsigned char header_len_dtch = 0, header_len_dtch_tmp = 0, header_len_dtch_last = 0; - unsigned char ta_len = 0; - unsigned char sdu_lcids[NB_RB_MAX], lcid, offset, num_sdus = 0; - uint16_t nb_rb, nb_rb_temp, nb_available_rb; - uint16_t TBS, j, sdu_lengths[NB_RB_MAX], rnti, padding = 0, post_padding = 0; - unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - unsigned char round = 0; - unsigned char harq_pid = 0; - eNB_UE_STATS *eNB_UE_stats = NULL; - uint16_t sdu_length_total = 0; - - eNB_MAC_INST *eNB = RC.mac[module_idP]; - COMMON_channels_t *cc = eNB->common_channels; - UE_list_t *UE_list = &eNB->UE_list; - // int continue_flag = 0; - int32_t normalized_rx_power, target_rx_power; - int32_t tpc = 1; - static int32_t tpc_accumulated = 0; - UE_sched_ctrl *ue_sched_ctl; - int mcs; - int i; - int min_rb_unit[MAX_NUM_CCs]; - int N_RB_DL[MAX_NUM_CCs]; - int total_nb_available_rb[MAX_NUM_CCs]; - int N_RBG[MAX_NUM_CCs]; - nfapi_dl_config_request_body_t *dl_req; - nfapi_dl_config_request_pdu_t *dl_config_pdu; - int tdd_sfa; - int ta_update; -#ifdef DEBUG_eNB_SCHEDULER - int k; #endif - - start_meas(&eNB->schedule_dlsch); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); - - - // for TDD: check that we have to act here, otherwise return - if (cc[0].tdd_Config) { - tdd_sfa = cc[0].tdd_Config->subframeAssignment; - switch (subframeP) { - case 0: - // always continue - break; - case 1: - return; - break; - case 2: - return; - break; - case 3: - if ((tdd_sfa != 2) && (tdd_sfa != 5)) - return; - break; - case 4: - if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) - && (tdd_sfa != 5)) - return; - break; - case 5: - break; - case 6: - case 7: - if ((tdd_sfa != 3)&& (tdd_sfa != 4) && (tdd_sfa != 5)) - return; - break; - case 8: - if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) - && (tdd_sfa != 5)) - return; - break; - case 9: - if (tdd_sfa == 0) - return; - break; - - } + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2) { + continue; + } + + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4) { + continue; + } + + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; + ue_sched_ctl = &RC.mac[Mod_id]->UE_list.UE_sched_ctrl[UE_id]; + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; + + if (ue_sched_ctl->pre_nb_available_rbs[CC_id] > 0) { + LOG_D(MAC, + "******************DL Scheduling Information for UE%d ************************\n", + UE_id); + LOG_D(MAC, "dl power offset UE%d = %d \n", UE_id, + ue_sched_ctl->dl_pow_off[CC_id]); + LOG_D(MAC, + "***********RB Alloc for every subband for UE%d ***********\n", + UE_id); + + for (j = 0; j < N_RBG[CC_id]; j++) { + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; + LOG_D(MAC, "RB Alloc for UE%d and Subband%d = %d\n", + UE_id, j, + ue_sched_ctl->rballoc_sub_UE[CC_id][j]); + } + + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; + LOG_D(MAC, "Total RBs allocated for UE%d = %d\n", UE_id, + ue_sched_ctl->pre_nb_available_rbs[CC_id]); + } } + } +} - //weight = get_ue_weight(module_idP,UE_id); -// aggregation = 2; - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); - min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); - // get number of PRBs less those used by common channels - total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; - for (i = 0; i < N_RB_DL[CC_id]; i++) - if (cc[CC_id].vrb_map[i] != 0) - total_nb_available_rb[CC_id]--; - - N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); - - // store the global enb stats: - eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; - eNB->eNB_stats[CC_id].available_prbs = - total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].total_available_prbs += - total_nb_available_rb[CC_id]; - eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; - eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; + +//------------------------------------------------------------------------------ +void +schedule_ue_spec_fairRR(module_id_t module_idP, + frame_t frameP, sub_frame_t subframeP, int *mbsfn_flag) +//------------------------------------------------------------------------------ +{ + uint8_t CC_id; + int UE_id; + // unsigned char aggregation; + mac_rlc_status_resp_t rlc_status; + unsigned char header_len_dcch = 0, header_len_dcch_tmp = 0; + unsigned char header_len_dtch = 0, header_len_dtch_tmp = 0, header_len_dtch_last = 0; + unsigned char ta_len = 0; + unsigned char sdu_lcids[NB_RB_MAX], lcid, offset, num_sdus = 0; + uint16_t nb_rb, nb_rb_temp, nb_available_rb; + uint16_t TBS, j, sdu_lengths[NB_RB_MAX], rnti, padding = 0, post_padding = 0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + unsigned char round = 0; + unsigned char harq_pid = 0; + eNB_UE_STATS *eNB_UE_stats = NULL; + uint16_t sdu_length_total = 0; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + UE_list_t *UE_list = &eNB->UE_list; + // int continue_flag = 0; + int32_t normalized_rx_power, target_rx_power; + int32_t tpc = 1; + static int32_t tpc_accumulated = 0; + UE_sched_ctrl *ue_sched_ctl; + int mcs; + int i; + int min_rb_unit[MAX_NUM_CCs]; + int N_RB_DL[MAX_NUM_CCs]; + int total_nb_available_rb[MAX_NUM_CCs]; + int N_RBG[MAX_NUM_CCs]; + nfapi_dl_config_request_body_t *dl_req; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + int tdd_sfa; + int ta_update; +#ifdef DEBUG_eNB_SCHEDULER + int k; +#endif + start_meas(&eNB->schedule_dlsch); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN); + + // for TDD: check that we have to act here, otherwise return + if (cc[0].tdd_Config) { + tdd_sfa = cc[0].tdd_Config->subframeAssignment; + + switch (subframeP) { + case 0: + // always continue + break; + + case 1: + return; + break; + + case 2: + return; + break; + + case 3: + if ((tdd_sfa != 2) && (tdd_sfa != 5)) + return; + + break; + + case 4: + if ((tdd_sfa != 1) && (tdd_sfa != 2) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + + break; + + case 5: + break; + + case 6: + case 7: + if ((tdd_sfa != 3)&& (tdd_sfa != 4) && (tdd_sfa != 5)) + return; + + break; + + case 8: + if ((tdd_sfa != 2) && (tdd_sfa != 3) && (tdd_sfa != 4) + && (tdd_sfa != 5)) + return; + + break; + + case 9: + if (tdd_sfa == 0) + return; + + break; } + } - /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) + //weight = get_ue_weight(module_idP,UE_id); + // aggregation = 2; + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + N_RB_DL[CC_id] = to_prb(cc[CC_id].mib->message.dl_Bandwidth); + min_rb_unit[CC_id] = get_min_rb_unit(module_idP, CC_id); + // get number of PRBs less those used by common channels + total_nb_available_rb[CC_id] = N_RB_DL[CC_id]; + + for (i = 0; i < N_RB_DL[CC_id]; i++) + if (cc[CC_id].vrb_map[i] != 0) + total_nb_available_rb[CC_id]--; + + N_RBG[CC_id] = to_rbg(cc[CC_id].mib->message.dl_Bandwidth); + // store the global enb stats: + eNB->eNB_stats[CC_id].num_dlactive_UEs = UE_list->num_UEs; + eNB->eNB_stats[CC_id].available_prbs = + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].total_available_prbs += + total_nb_available_rb[CC_id]; + eNB->eNB_stats[CC_id].dlsch_bytes_tx = 0; + eNB->eNB_stats[CC_id].dlsch_pdus_tx = 0; + } + /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_IN); start_meas(&eNB->schedule_dlsch_preprocessor); dlsch_scheduler_pre_processor_fairRR(module_idP, - frameP, - subframeP, - N_RBG, - mbsfn_flag); + frameP, + subframeP, + N_RBG, + mbsfn_flag); stop_meas(&eNB->schedule_dlsch_preprocessor); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_PREPROCESSOR,VCD_FUNCTION_OUT); - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { LOG_D(MAC, "doing schedule_ue_spec for CC_id %d\n",CC_id); - dl_req = &eNB->DL_req[CC_id].dl_config_request_body; if (mbsfn_flag[CC_id]>0) continue; for (i = 0; i < dlsch_ue_select[CC_id].ue_num; i++) { - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2){ + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG2) { continue; } - if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4){ + + if(dlsch_ue_select[CC_id].list[i].ue_priority == SCH_DL_MSG4) { continue; } + UE_id = dlsch_ue_select[CC_id].list[i].UE_id; rnti = UE_RNTI(module_idP,UE_id); + if (rnti==NOT_A_RNTI) { LOG_E(MAC,"Cannot find rnti for UE_id %d (num_UEs %d)\n",UE_id,UE_list->num_UEs); continue; @@ -928,387 +955,377 @@ schedule_ue_spec_fairRR(module_id_t module_idP, eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; ue_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; -/* - switch(get_tmode(module_idP,CC_id,UE_id)){ - case 1: - case 2: - case 7: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - break; - case 3: - aggregation = get_aggregation(get_bw_index(module_idP,CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format2A); - break; - default: - LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); - aggregation = 2; - break; - } -*/ + + /* + switch(get_tmode(module_idP,CC_id,UE_id)){ + case 1: + case 2: + case 7: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + break; + case 3: + aggregation = get_aggregation(get_bw_index(module_idP,CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format2A); + break; + default: + LOG_W(MAC,"Unsupported transmission mode %d\n", get_tmode(module_idP,CC_id,UE_id)); + aggregation = 2; + break; + } + */ if (cc[CC_id].tdd_Config != NULL) { //TDD set_ue_dai (subframeP, UE_id, CC_id, - cc[CC_id].tdd_Config->subframeAssignment, + cc[CC_id].tdd_Config->subframeAssignment, UE_list); // update UL DAI after DLSCH scheduling set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); } - nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + nb_available_rb = ue_sched_ctl->pre_nb_available_rbs[CC_id]; + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); + round = ue_sched_ctl->round[CC_id][harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = + mac_eNB_get_rrc_status(module_idP, rnti); + UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; + UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; + + if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < + RRC_CONNECTED) + continue; + + sdu_length_total = 0; + num_sdus = 0; + + /* + DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), + eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); + */ + if (nfapi_mode) { + eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } else { + eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } + + eNB_UE_stats->dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + // store stats + //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi; - round = ue_sched_ctl->round[CC_id][harq_pid]; + // initializing the rb allocation indicator for each UE + for (j = 0; j < N_RBG[CC_id]; j++) { + UE_list-> + UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] + = 0; + } - UE_list->eNB_UE_stats[CC_id][UE_id].crnti = rnti; - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status = - mac_eNB_get_rrc_status(module_idP, rnti); - UE_list->eNB_UE_stats[CC_id][UE_id].harq_pid = harq_pid; - UE_list->eNB_UE_stats[CC_id][UE_id].harq_round = round; + LOG_D(MAC, + "[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", + module_idP, frameP, UE_id, CC_id, rnti, harq_pid, round, + nb_available_rb, ue_sched_ctl->dl_cqi[CC_id], + eNB_UE_stats->dlsch_mcs1, + UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); + /* process retransmission */ - if (UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status < - RRC_CONNECTED) - continue; + if (round != 8) { + // get freq_allocation + nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; + TBS = + get_TBS_DL(UE_list-> + UE_template[CC_id][UE_id].oldmcs1[harq_pid], + nb_rb); - sdu_length_total = 0; - num_sdus = 0; + if (nb_rb <= nb_available_rb) { + if (cc[CC_id].tdd_Config != NULL) { + UE_list->UE_template[CC_id][UE_id].DAI++; + update_ul_dci(module_idP, CC_id, rnti, + UE_list->UE_template[CC_id][UE_id]. + DAI,subframeP); + LOG_D(MAC, + "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", + CC_id, subframeP, UE_id, + UE_list->UE_template[CC_id][UE_id].DAI); + } - /* - DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)), - eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE); - */ - if (nfapi_mode) { - eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; } - else { - eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]]; + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + if (UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j]) + printf + ("WARN: rballoc_subband not free for retrans?\n"); + + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[CC_id] == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + + j = j + 1; } - eNB_UE_stats->dlsch_mcs1 = eNB_UE_stats->dlsch_mcs1; //cmin(eNB_UE_stats->dlsch_mcs1, openair_daq_vars.target_ue_dl_mcs); - - - // store stats - //UE_list->eNB_UE_stats[CC_id][UE_id].dl_cqi= eNB_UE_stats->dl_cqi; - - // initializing the rb allocation indicator for each UE - for (j = 0; j < N_RBG[CC_id]; j++) { - UE_list-> - UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j] - = 0; - } - - LOG_D(MAC, - "[eNB %d] Frame %d: Scheduling UE %d on CC_id %d (rnti %x, harq_pid %d, round %d, rb %d, cqi %d, mcs %d, rrc %d)\n", - module_idP, frameP, UE_id, CC_id, rnti, harq_pid, round, - nb_available_rb, ue_sched_ctl->dl_cqi[CC_id], - eNB_UE_stats->dlsch_mcs1, - UE_list->eNB_UE_stats[CC_id][UE_id].rrc_status); - - - - /* process retransmission */ - - if (round != 8) { - - // get freq_allocation - nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - TBS = - get_TBS_DL(UE_list-> - UE_template[CC_id][UE_id].oldmcs1[harq_pid], - nb_rb); - - if (nb_rb <= nb_available_rb) { - if (cc[CC_id].tdd_Config != NULL) { - UE_list->UE_template[CC_id][UE_id].DAI++; - update_ul_dci(module_idP, CC_id, rnti, - UE_list->UE_template[CC_id][UE_id]. - DAI,subframeP); - LOG_D(MAC, - "DAI update: CC_id %d subframeP %d: UE %d, DAI %d\n", - CC_id, subframeP, UE_id, - UE_list->UE_template[CC_id][UE_id].DAI); - } - - if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id]. - rballoc_subband[harq_pid][j] = - ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - - while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { - if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == - 1) { - if (UE_list-> - UE_template[CC_id] - [UE_id].rballoc_subband[harq_pid][j]) - printf - ("WARN: rballoc_subband not free for retrans?\n"); - UE_list-> - UE_template[CC_id] - [UE_id].rballoc_subband[harq_pid][j] = - ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if ((j == N_RBG[CC_id] - 1) && - ((N_RB_DL[CC_id] == 25) || - (N_RB_DL[CC_id] == 50))) { - nb_rb_temp = - nb_rb_temp - min_rb_unit[CC_id] + - 1; - } else { - nb_rb_temp = - nb_rb_temp - min_rb_unit[CC_id]; - } - } - - j = j + 1; - } - } - - nb_available_rb -= nb_rb; - /* - eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; - eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; - - for(j=0; j<N_RBG[CC_id]; j++) { - eNB->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; - } - */ - - switch (get_tmode(module_idP, CC_id, UE_id)) { - case 1: - case 2: - case 7: - default: - LOG_D(MAC,"retransmission DL_REQ: rnti:%x\n",rnti); - - dl_config_pdu = - &dl_req->dl_config_pdu_list[dl_req-> - number_pdu]; - memset((void *) dl_config_pdu, 0, - sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = - NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = - (uint8_t) (2 + - sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. - dci_format = NFAPI_DL_DCI_FORMAT_1; - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.aggregation_level = - get_aggregation(get_bw_index - (module_idP, CC_id), - ue_sched_ctl->dl_cqi[CC_id], - format1); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = - rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. - harq_process = harq_pid; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.new_data_indicator_1 = - UE_list->UE_template[CC_id][UE_id]. - oldNDI[harq_pid]; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = - UE_list->UE_template[CC_id][UE_id]. - oldmcs1[harq_pid]; - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.redundancy_version_1 = - round & 3; - - if (cc[CC_id].tdd_Config != NULL) { //TDD - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.downlink_assignment_index = - (UE_list->UE_template[CC_id][UE_id].DAI - - 1) & 3; - LOG_D(MAC, - "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", - module_idP, CC_id, harq_pid, round, - (UE_list->UE_template[CC_id][UE_id].DAI - - 1), - UE_list-> - UE_template[CC_id][UE_id].oldmcs1 - [harq_pid]); - } else { - LOG_D(MAC, - "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", - module_idP, CC_id, harq_pid, round, - UE_list-> - UE_template[CC_id][UE_id].oldmcs1 - [harq_pid]); - - } - if (!CCE_allocation_infeasible - (module_idP, CC_id, 1, subframeP, - dl_config_pdu->dci_dl_pdu. - dci_dl_pdu_rel8.aggregation_level, rnti)) { - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - - fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 - /* retransmission, no pdu_index */ - , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]), round & 3, // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - - LOG_D(MAC, - "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", - eNB->pdu_index[CC_id], round); - - program_dlsch_acknak(module_idP, CC_id, UE_id, - frameP, subframeP, - dl_config_pdu-> - dci_dl_pdu.dci_dl_pdu_rel8. - cce_idx); - // No TX request for retransmission (check if null request for FAPI) - } else { - LOG_W(MAC, - "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n", - frameP, subframeP, UE_id, rnti); - } - } - - - add_ue_dlsch_info(module_idP, - CC_id, UE_id, subframeP, - S_DL_SCHEDULED); - - //eNB_UE_stats->dlsch_trials[round]++; - UE_list->eNB_UE_stats[CC_id][UE_id]. - num_retransmission += 1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = - nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id]. - total_rbs_used_retx += nb_rb; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = - eNB_UE_stats->dlsch_mcs1; - UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = - eNB_UE_stats->dlsch_mcs1; - } else { - LOG_D(MAC, - "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", - module_idP, frameP, CC_id, UE_id); - } - } else { /* This is a potentially new SDU opportunity */ - - rlc_status.bytes_in_buffer = 0; - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - TBS = - get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); - // check first for RLC data on DCCH - // add the length for all the control elements (timing adv, drx, etc) : header + payload - - if (ue_sched_ctl->ta_timer == 0) { - ta_update = ue_sched_ctl->ta_update; - /* if we send TA then set timer to not send it for a while */ - if (ta_update != 31) - ue_sched_ctl->ta_timer = 20; - /* reset ta_update */ - ue_sched_ctl->ta_update = 31; - } else { - ta_update = 31; - } - - ta_len = (ta_update != 31) ? 2 : 0; - - header_len_dcch = 2; // 2 bytes DCCH SDU subheader - - if (TBS - ta_len - header_len_dcch > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, (TBS - ta_len - header_len_dcch) + } + + nb_available_rb -= nb_rb; + /* + eNB->mu_mimo_mode[UE_id].pre_nb_available_rbs = nb_rb; + eNB->mu_mimo_mode[UE_id].dl_pow_off = ue_sched_ctl->dl_pow_off[CC_id]; + + for(j=0; j<N_RBG[CC_id]; j++) { + eNB->mu_mimo_mode[UE_id].rballoc_sub[j] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][j]; + } + */ + + switch (get_tmode(module_idP, CC_id, UE_id)) { + case 1: + case 2: + case 7: + default: + LOG_D(MAC,"retransmission DL_REQ: rnti:%x\n",rnti); + dl_config_pdu = + &dl_req->dl_config_pdu_list[dl_req-> + number_pdu]; + memset((void *) dl_config_pdu, 0, + sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = + NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = + (uint8_t) (2 + + sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level = + get_aggregation(get_bw_index + (module_idP, CC_id), + ue_sched_ctl->dl_cqi[CC_id], + format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = + rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8. + harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.new_data_indicator_1 = + UE_list->UE_template[CC_id][UE_id]. + oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = + UE_list->UE_template[CC_id][UE_id]. + oldmcs1[harq_pid]; + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.redundancy_version_1 = + round & 3; + + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.downlink_assignment_index = + (UE_list->UE_template[CC_id][UE_id].DAI - + 1) & 3; + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, dai %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + (UE_list->UE_template[CC_id][UE_id].DAI - + 1), + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + } else { + LOG_D(MAC, + "[eNB %d] Retransmission CC_id %d : harq_pid %d, round %d, mcs %d\n", + module_idP, CC_id, harq_pid, round, + UE_list-> + UE_template[CC_id][UE_id].oldmcs1 + [harq_pid]); + } + + if (!CCE_allocation_infeasible + (module_idP, CC_id, 1, subframeP, + dl_config_pdu->dci_dl_pdu. + dci_dl_pdu_rel8.aggregation_level, rnti)) { + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; + fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 + /* retransmission, no pdu_index */ + , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid]), round & 3, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + LOG_D(MAC, + "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n", + eNB->pdu_index[CC_id], round); + program_dlsch_acknak(module_idP, CC_id, UE_id, + frameP, subframeP, + dl_config_pdu-> + dci_dl_pdu.dci_dl_pdu_rel8. + cce_idx); + // No TX request for retransmission (check if null request for FAPI) + } else { + LOG_W(MAC, + "Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d\%x, infeasible CCE allocation\n", + frameP, subframeP, UE_id, rnti); + } + } + + add_ue_dlsch_info(module_idP, + CC_id, UE_id, subframeP, + S_DL_SCHEDULED); + //eNB_UE_stats->dlsch_trials[round]++; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_retransmission += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = + nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id]. + total_rbs_used_retx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1 = + eNB_UE_stats->dlsch_mcs1; + UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2 = + eNB_UE_stats->dlsch_mcs1; + } else { + LOG_D(MAC, + "[eNB %d] Frame %d CC_id %d : don't schedule UE %d, its retransmission takes more resources than we have\n", + module_idP, frameP, CC_id, UE_id); + } + } else { /* This is a potentially new SDU opportunity */ + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_available_rb); + // check first for RLC data on DCCH + // add the length for all the control elements (timing adv, drx, etc) : header + payload + + if (ue_sched_ctl->ta_timer == 0) { + ta_update = ue_sched_ctl->ta_update; + + /* if we send TA then set timer to not send it for a while */ + if (ta_update != 31) + ue_sched_ctl->ta_timer = 20; + + /* reset ta_update */ + ue_sched_ctl->ta_update = 31; + } else { + ta_update = 31; + } + + ta_len = (ta_update != 31) ? 2 : 0; + header_len_dcch = 2; // 2 bytes DCCH SDU subheader + + if (TBS - ta_len - header_len_dcch > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, (TBS - ta_len - header_len_dcch) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); // transport block set size - - sdu_lengths[0] = 0; - - if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit - LOG_D(MAC, - "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, subframeP, CC_id, - TBS - header_len_dcch); - sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used - (char *) - &dlsch_buffer - [0] + ); // transport block set size + sdu_lengths[0] = 0; + + if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit + LOG_D(MAC, + "[eNB %d] SFN/SF %d.%d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, subframeP, CC_id, + TBS - header_len_dcch); + sdu_lengths[0] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH, TBS, //not used + (char *) + &dlsch_buffer + [0] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); + ); pthread_mutex_lock(&rrc_release_freelist); - if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)){ + + if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)) { uint16_t release_total = 0; - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ + + for(uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0) { release_total++; - }else{ + } else { continue; } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 1) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { rrc_release_info.RRC_release_ctrl[release_num].flag = 3; LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 1->3\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); break; - } - } + } + } } } - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2){ - if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]){ - rrc_release_info.RRC_release_ctrl[release_num].flag = 4; - LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); - break; + + if(rrc_release_info.RRC_release_ctrl[release_num].flag == 2) { + if(rrc_release_info.RRC_release_ctrl[release_num].rnti == rnti) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui == rlc_am_mui.rrc_mui[mui_num]) { + rrc_release_info.RRC_release_ctrl[release_num].flag = 4; + LOG_D(MAC,"DLSCH Release send:index %d rnti %x mui %d mui_num %d flag 2->4\n",release_num,rnti,rlc_am_mui.rrc_mui[mui_num],mui_num); + break; } } } } + if(release_total >= rrc_release_info.num_UEs) break; } } - pthread_mutex_unlock(&rrc_release_freelist); + pthread_mutex_unlock(&rrc_release_freelist); RA_t *ra = &eNB->common_channels[CC_id].ra[0]; + for (uint8_t ra_ii = 0; ra_ii < NB_RA_PROC_MAX; ra_ii++) { - if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)){ - for(uint16_t mui_num = 0;mui_num < rlc_am_mui.rrc_mui_num;mui_num++){ - if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]){ + if((ra[ra_ii].rnti == rnti) && (ra[ra_ii].state == MSGCRNTI)) { + for(uint16_t mui_num = 0; mui_num < rlc_am_mui.rrc_mui_num; mui_num++) { + if(ra[ra_ii].crnti_rrc_mui == rlc_am_mui.rrc_mui[mui_num]) { ra[ra_ii].crnti_harq_pid = harq_pid; ra[ra_ii].state = MSGCRNTI_ACK; break; @@ -1316,337 +1333,339 @@ schedule_ue_spec_fairRR(module_id_t module_idP, } } } - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), - T_INT(sdu_lengths[0])); - LOG_D(MAC, - "[eNB %d][DCCH] CC_id %d frame %d subframe %d UE_id %d/%x Got %d bytes bytes_in_buffer %d from release_num %d\n", - module_idP, CC_id, frameP, subframeP, UE_id, rnti, sdu_lengths[0],rlc_status.bytes_in_buffer,rrc_release_info.num_UEs); - - sdu_length_total = sdu_lengths[0]; - sdu_lcids[0] = DCCH; - UE_list->eNB_UE_stats[CC_id][UE_id]. - num_pdu_tx[DCCH] += 1; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] - += sdu_lengths[0]; - num_sdus = 1; + + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(DCCH), + T_INT(sdu_lengths[0])); + LOG_D(MAC, + "[eNB %d][DCCH] CC_id %d frame %d subframe %d UE_id %d/%x Got %d bytes bytes_in_buffer %d from release_num %d\n", + module_idP, CC_id, frameP, subframeP, UE_id, rnti, sdu_lengths[0],rlc_status.bytes_in_buffer,rrc_release_info.num_UEs); + sdu_length_total = sdu_lengths[0]; + sdu_lcids[0] = DCCH; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH] + += sdu_lengths[0]; + num_sdus = 1; #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC, - "[eNB %d][DCCH] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[0]); + LOG_T(MAC, + "[eNB %d][DCCH] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[0]); - for (k = 0; k < sdu_lengths[0]; k++) { - LOG_T(MAC, "%x ", dlsch_buffer[k]); - } + for (k = 0; k < sdu_lengths[0]; k++) { + LOG_T(MAC, "%x ", dlsch_buffer[k]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - } else { - header_len_dcch = 0; - sdu_length_total = 0; - } - } - // check for DCCH1 and update header information (assume 2 byte sub-header) - if (TBS - ta_len - header_len_dcch - sdu_length_total > 0) { - rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, (TBS - ta_len - header_len_dcch - sdu_length_total) + } else { + header_len_dcch = 0; + sdu_length_total = 0; + } + } + + // check for DCCH1 and update header information (assume 2 byte sub-header) + if (TBS - ta_len - header_len_dcch - sdu_length_total > 0) { + rlc_status = mac_rlc_status_ind(module_idP, rnti, module_idP, frameP, subframeP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, (TBS - ta_len - header_len_dcch - sdu_length_total) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); // transport block set size less allocations for timing advance and - // DCCH SDU - sdu_lengths[num_sdus] = 0; - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC, - "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", - module_idP, frameP, CC_id, - TBS - header_len_dcch - sdu_length_total); - sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS, //not used - (char *) - &dlsch_buffer - [sdu_length_total] + ); // transport block set size less allocations for timing advance and + // DCCH SDU + sdu_lengths[num_sdus] = 0; + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC, + "[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n", + module_idP, frameP, CC_id, + TBS - header_len_dcch - sdu_length_total); + sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, DCCH + 1, TBS, //not used + (char *) + &dlsch_buffer + [sdu_length_total] #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ,0, 0 #endif - ); - - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); - - sdu_lcids[num_sdus] = DCCH1; - sdu_length_total += sdu_lengths[num_sdus]; - header_len_dcch += 2; - UE_list->eNB_UE_stats[CC_id][UE_id]. - num_pdu_tx[DCCH1] += 1; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] - += sdu_lengths[num_sdus]; - num_sdus++; + ); + T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(DCCH + 1), T_INT(sdu_lengths[num_sdus])); + sdu_lcids[num_sdus] = DCCH1; + sdu_length_total += sdu_lengths[num_sdus]; + header_len_dcch += 2; + UE_list->eNB_UE_stats[CC_id][UE_id]. + num_pdu_tx[DCCH1] += 1; + UE_list-> + eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] + += sdu_lengths[num_sdus]; + num_sdus++; #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC, - "[eNB %d][DCCH1] CC_id %d Got %d bytes :", - module_idP, CC_id, sdu_lengths[num_sdus]); + LOG_T(MAC, + "[eNB %d][DCCH1] CC_id %d Got %d bytes :", + module_idP, CC_id, sdu_lengths[num_sdus]); - for (k = 0; k < sdu_lengths[num_sdus]; k++) { - LOG_T(MAC, "%x ", dlsch_buffer[k]); - } + for (k = 0; k < sdu_lengths[num_sdus]; k++) { + LOG_T(MAC, "%x ", dlsch_buffer[k]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif + } + } + + // assume the max dtch header size, and adjust it later + header_len_dtch = 0; + header_len_dtch_last = 0; // the header length of the last mac sdu - } - } - // assume the max dtch header size, and adjust it later - header_len_dtch = 0; - header_len_dtch_last = 0; // the header length of the last mac sdu - // lcid has to be sorted before the actual allocation (similar struct as ue_list). - /* TODO limited lcid for performance */ + // lcid has to be sorted before the actual allocation (similar struct as ue_list). + /* TODO limited lcid for performance */ for (lcid = DTCH; lcid >= DTCH; lcid--) { - // TBD: check if the lcid is active - - header_len_dtch += 3; - header_len_dtch_last = 3; - LOG_D(MAC, - "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", - module_idP, frameP, lcid, TBS, - TBS - ta_len - header_len_dcch - - sdu_length_total - header_len_dtch); - - if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? - rlc_status = mac_rlc_status_ind(module_idP, - rnti, - module_idP, - frameP, - subframeP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - lcid, - TBS - ta_len - - header_len_dcch - - sdu_length_total - - header_len_dtch -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + // TBD: check if the lcid is active + header_len_dtch += 3; + header_len_dtch_last = 3; + LOG_D(MAC, "[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n", + module_idP, + frameP, + lcid, + TBS, + TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch); + + if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ? + rlc_status = mac_rlc_status_ind(module_idP, + rnti, + module_idP, + frameP, + subframeP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch +#ifdef Rel14 + , 0, 0 #endif - ); - - - if (rlc_status.bytes_in_buffer > 0) { - - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", - module_idP, frameP, - TBS - header_len_dcch - - sdu_length_total - header_len_dtch, lcid, - header_len_dtch); - sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, rnti, module_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, lcid, TBS, //not used - (char - *) - &dlsch_buffer - [sdu_length_total] -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0, 0 + ); + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n", + module_idP, + frameP, + TBS - header_len_dcch - sdu_length_total - header_len_dtch, + lcid, + header_len_dtch); + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP, + rnti, + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + lcid, + TBS, //not used + (char *)&dlsch_buffer[sdu_length_total] +#ifdef Rel14 + , 0, 0 #endif - ); - T(T_ENB_MAC_UE_DL_SDU, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_INT(lcid), T_INT(sdu_lengths[num_sdus])); - - LOG_D(MAC, - "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", - module_idP, sdu_lengths[num_sdus], lcid); - sdu_lcids[num_sdus] = lcid; - sdu_length_total += sdu_lengths[num_sdus]; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] - += 1; - UE_list-> - eNB_UE_stats[CC_id][UE_id].num_bytes_tx - [lcid] += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) { - header_len_dtch--; - header_len_dtch_last--; - } - num_sdus++; - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - } // no data for this LCID - else { - header_len_dtch -= 3; - } - } // no TBS left - else { - header_len_dtch -= 3; - break; - } - } - if (header_len_dtch == 0) - header_len_dtch_last = 0; - // there is at least one SDU - // if (num_sdus > 0 ){ - if ((sdu_length_total + header_len_dcch + - header_len_dtch) > 0) { - - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - // adjust header lengths - header_len_dcch_tmp = header_len_dcch; - header_len_dtch_tmp = header_len_dtch; - if (header_len_dtch == 0) { - header_len_dcch = (header_len_dcch > 0) ? 1 : 0; //header_len_dcch; // remove length field - } else { - header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU - header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU - } - - mcs = eNB_UE_stats->dlsch_mcs1; - nb_rb = min_rb_unit[CC_id]; - TBS = get_TBS_DL(mcs, nb_rb); - - while (TBS < - (sdu_length_total + header_len_dcch + - header_len_dtch + ta_len)) { - nb_rb += min_rb_unit[CC_id]; // - - if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = - get_TBS_DL(eNB_UE_stats->dlsch_mcs1, - nb_available_rb); - nb_rb = nb_available_rb; - break; - } - - TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); - } - - if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { - for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band - UE_list->UE_template[CC_id][UE_id]. - rballoc_subband[harq_pid][j] = - ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - } - } else { - nb_rb_temp = nb_rb; - j = 0; - - while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { - if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == - 1) { - UE_list-> - UE_template[CC_id] - [UE_id].rballoc_subband[harq_pid][j] = - ue_sched_ctl->rballoc_sub_UE[CC_id][j]; - - if ((j == N_RBG[CC_id] - 1) && - ((N_RB_DL[CC_id] == 25) || - (N_RB_DL[CC_id] == 50))) { - nb_rb_temp = - nb_rb_temp - min_rb_unit[CC_id] + - 1; - } else { - nb_rb_temp = - nb_rb_temp - min_rb_unit[CC_id]; - } - } - - j = j + 1; - } - } - - // decrease mcs until TBS falls below required length - while ((TBS > - (sdu_length_total + header_len_dcch + - header_len_dtch + ta_len)) && (mcs > 0)) { - mcs--; - TBS = get_TBS_DL(mcs, nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < - (sdu_length_total + header_len_dcch + - header_len_dtch + ta_len)) - && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) - && (mcs < 28)) - || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) - && (mcs <= 15)))) { - mcs++; - TBS = get_TBS_DL(mcs, nb_rb); - } - - LOG_D(MAC, - "dlsch_mcs before and after the rate matching = (%d, %d)\n", - eNB_UE_stats->dlsch_mcs1, mcs); + ); + T(T_ENB_MAC_UE_DL_SDU, + T_INT(module_idP), + T_INT(CC_id), + T_INT(rnti), + T_INT(frameP), + T_INT(subframeP), + T_INT(harq_pid), + T_INT(lcid), + T_INT(sdu_lengths[num_sdus])); + LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n", + module_idP, + sdu_lengths[num_sdus], + lcid); + sdu_lcids[num_sdus] = lcid; + sdu_length_total += sdu_lengths[num_sdus]; + UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[lcid] += 1; + UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[lcid] += sdu_lengths[num_sdus]; + + if (sdu_lengths[num_sdus] < 128) { + header_len_dtch--; + header_len_dtch_last--; + } + + num_sdus++; + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + } else { // no data for this LCID + header_len_dtch -= 3; + } + } else { // no TBS left + header_len_dtch -= 3; + break; + } + } + if (header_len_dtch == 0) + header_len_dtch_last = 0; + + // there is at least one SDU + // if (num_sdus > 0 ){ + if ((sdu_length_total + header_len_dcch + + header_len_dtch) > 0) { + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 + // adjust header lengths + header_len_dcch_tmp = header_len_dcch; + header_len_dtch_tmp = header_len_dtch; + + if (header_len_dtch == 0) { + header_len_dcch = (header_len_dcch > 0) ? 1 : 0; //header_len_dcch; // remove length field + } else { + header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU + header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU + } + + mcs = eNB_UE_stats->dlsch_mcs1; + nb_rb = min_rb_unit[CC_id]; + TBS = get_TBS_DL(mcs, nb_rb); + + while (TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) { + nb_rb += min_rb_unit[CC_id]; // + + if (nb_rb > nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = + get_TBS_DL(eNB_UE_stats->dlsch_mcs1, + nb_available_rb); + nb_rb = nb_available_rb; + break; + } + + TBS = get_TBS_DL(eNB_UE_stats->dlsch_mcs1, nb_rb); + } + + if (nb_rb == ue_sched_ctl->pre_nb_available_rbs[CC_id]) { + for (j = 0; j < N_RBG[CC_id]; j++) { // for indicating the rballoc for each sub-band + UE_list->UE_template[CC_id][UE_id]. + rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + } + } else { + nb_rb_temp = nb_rb; + j = 0; + + while ((nb_rb_temp > 0) && (j < N_RBG[CC_id])) { + if (ue_sched_ctl->rballoc_sub_UE[CC_id][j] == + 1) { + UE_list-> + UE_template[CC_id] + [UE_id].rballoc_subband[harq_pid][j] = + ue_sched_ctl->rballoc_sub_UE[CC_id][j]; + + if ((j == N_RBG[CC_id] - 1) && + ((N_RB_DL[CC_id] == 25) || + (N_RB_DL[CC_id] == 50))) { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id] + + 1; + } else { + nb_rb_temp = + nb_rb_temp - min_rb_unit[CC_id]; + } + } + + j = j + 1; + } + } + + // decrease mcs until TBS falls below required length + while ((TBS > + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) && (mcs > 0)) { + mcs--; + TBS = get_TBS_DL(mcs, nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < + (sdu_length_total + header_len_dcch + + header_len_dtch + ta_len)) + && (((ue_sched_ctl->dl_pow_off[CC_id] > 0) + && (mcs < 28)) + || ((ue_sched_ctl->dl_pow_off[CC_id] == 0) + && (mcs <= 15)))) { + mcs++; + TBS = get_TBS_DL(mcs, nb_rb); + } + + LOG_D(MAC, + "dlsch_mcs before and after the rate matching = (%d, %d)\n", + eNB_UE_stats->dlsch_mcs1, mcs); #ifdef DEBUG_eNB_SCHEDULER - LOG_D(MAC, - "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", - module_idP, CC_id, mcs, TBS, nb_rb); - // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", - // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); + LOG_D(MAC, + "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP, CC_id, mcs, TBS, nb_rb); + // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", + // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); #endif - if ((TBS - header_len_dcch - header_len_dtch - - sdu_length_total - ta_len) <= 2) { - padding = - (TBS - header_len_dcch - header_len_dtch - - sdu_length_total - ta_len); - post_padding = 0; - } else { - padding = 0; - - // adjust the header len - if (header_len_dtch == 0) { - header_len_dcch = header_len_dcch_tmp; - } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) - header_len_dtch = header_len_dtch_tmp; - } - - post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header - } + if ((TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len) <= 2) { + padding = + (TBS - header_len_dcch - header_len_dtch - + sdu_length_total - ta_len); + post_padding = 0; + } else { + padding = 0; + + // adjust the header len + if (header_len_dtch == 0) { + header_len_dcch = header_len_dcch_tmp; + } else { //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) + header_len_dtch = header_len_dtch_tmp; + } + + post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header + } #ifdef PHY_TX_THREAD - struct timespec time_req, time_rem; - time_req.tv_sec = 0; - time_req.tv_nsec = 10000; - while((!oai_exit)&&(phy_tx_txdataF_end == 0)){ - nanosleep(&time_req,&time_rem); - continue; - } + struct timespec time_req, time_rem; + time_req.tv_sec = 0; + time_req.tv_nsec = 10000; + + while((!oai_exit)&&(phy_tx_txdataF_end == 0)) { + nanosleep(&time_req,&time_rem); + continue; + } + #endif + offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, post_padding); + + //#ifdef DEBUG_eNB_SCHEDULER + if (ta_update != 31) { + LOG_D(MAC, + "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", + module_idP, frameP, UE_id, CC_id, + sdu_length_total, num_sdus, sdu_lengths[0], + sdu_lcids[0], offset, ta_update, padding, + post_padding, mcs, TBS, nb_rb, + header_len_dcch, header_len_dtch); + } - offset = generate_dlsch_header((unsigned char *) UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], num_sdus, //num_sdus - sdu_lengths, // - sdu_lcids, 255, // no drx - ta_update, // timing advance - NULL, // contention res id - padding, post_padding); - - //#ifdef DEBUG_eNB_SCHEDULER - if (ta_update != 31) { - LOG_D(MAC, - "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", - module_idP, frameP, UE_id, CC_id, - sdu_length_total, num_sdus, sdu_lengths[0], - sdu_lcids[0], offset, ta_update, padding, - post_padding, mcs, TBS, nb_rb, - header_len_dcch, header_len_dtch); - } - //#endif + //#endif #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n",module_idP ); + LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n",module_idP ); - for (k = 0; k < 16; k++) { - LOG_T(MAC, "%x.", dlsch_buffer[k]); - } + for (k = 0; k < 16; k++) { + LOG_T(MAC, "%x.", dlsch_buffer[k]); + } - LOG_T(MAC, "\n"); + LOG_T(MAC, "\n"); #endif - // cycle through SDUs and place in dlsch_buffer memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset],dlsch_buffer,sdu_length_total); // memcpy(RC.mac[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); @@ -1666,9 +1685,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP, T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS)); - - UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; - + UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid] = nb_rb; add_ue_dlsch_info(module_idP, CC_id, UE_id, @@ -1677,13 +1694,11 @@ schedule_ue_spec_fairRR(module_id_t module_idP, // store stats eNB->eNB_stats[CC_id].dlsch_bytes_tx+=sdu_length_total; eNB->eNB_stats[CC_id].dlsch_pdus_tx+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; UE_list->eNB_UE_stats[CC_id][UE_id].dlsch_mcs2=mcs; UE_list->eNB_UE_stats[CC_id][UE_id].TBS = TBS; - UE_list->eNB_UE_stats[CC_id][UE_id].overhead_bytes= TBS- sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_sdu_bytes+= sdu_length_total; UE_list->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes+= TBS; @@ -1694,168 +1709,152 @@ schedule_ue_spec_fairRR(module_id_t module_idP, update_ul_dci(module_idP,CC_id,rnti,UE_list->UE_template[CC_id][UE_id].DAI,subframeP); } - // do PUCCH power control + // do PUCCH power control // this is the normalized RX power - eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; - + eNB_UE_stats = &UE_list->eNB_UE_stats[CC_id][UE_id]; /* Unit is not dBm, it's special from nfapi */ - normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30;//(+eNB->measurements.n0_power_dB[0]) - target_rx_power= eNB->puCch10xSnr/10 + 30;//(+eNB->measurements.n0_power_dB[0]) - + normalized_rx_power = (5*ue_sched_ctl->pucch1_snr[CC_id]-640)/10+30;//(+eNB->measurements.n0_power_dB[0]) + target_rx_power= eNB->puCch10xSnr/10 + 30;//(+eNB->measurements.n0_power_dB[0]) // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame*10+UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe; + if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { - ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; - - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; - UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; - - if (normalized_rx_power>(target_rx_power+4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - - LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP,frameP, subframeP,harq_pid,tpc, - tpc_accumulated,normalized_rx_power,target_rx_power); - - } // Po_PUCCH has been updated - else { - tpc = 1; //0 - } // time to do TPC update - else { - tpc = 1; //0 - } - - dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; - memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; - dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power - - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; - //deactivate second codeword - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; - if (cc[CC_id].tdd_Config != NULL) { //TDD - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", - module_idP,CC_id,harq_pid, - (UE_list->UE_template[CC_id][UE_id].DAI-1), - mcs); - } else { - LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", - module_idP,CC_id,harq_pid,mcs); - - } - LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); - if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { - - - ue_sched_ctl->round[CC_id][harq_pid] = 0; - dl_req->number_dci++; - dl_req->number_pdu++; - dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; - - eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; - eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - // Toggle NDI for next time - LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", - CC_id, frameP,subframeP,UE_id, - rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); - - UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; - UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; - UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); - AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); - - fill_nfapi_dlsch_config(eNB,dl_req, - TBS, - eNB->pdu_index[CC_id], - rnti, - 0, // type 0 allocation from 7.1.6 in 36.213 - 0, // virtual_resource_block_assignment_flag, unused here - 0, // resource_block_coding, to be filled in later - getQm(mcs), - 0, // redundancy version - 1, // transport blocks - 0, // transport block to codeword swap flag - cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme - 1, // number of layers - 1, // number of subbands - // uint8_t codebook_index, - 4, // UE category capacity - UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, - 0, // delta_power_offset for TM5 - 0, // ngap - 0, // nprb - cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode - 0, //number of PRBs treated as one subband, not used here - 0 // number of beamforming vectors, not used here - ); - eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, - (frameP*10)+subframeP, - TBS, - eNB->pdu_index[CC_id], - eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); - - LOG_D(MAC,"Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n",eNB->pdu_index[CC_id]); - - eNB->pdu_index[CC_id]++; - program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); - last_dlsch_ue_id[CC_id] = UE_id; - } - else { - LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", - frameP,subframeP,UE_id,rnti); - } - } else { // There is no data from RLC or MAC header, so don't schedule + ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around + if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) { + ue_sched_ctl->pucch1_cqi_update[CC_id] = 0; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; + + if (normalized_rx_power>(target_rx_power+4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + + LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + module_idP,frameP, subframeP,harq_pid,tpc, + tpc_accumulated,normalized_rx_power,target_rx_power); + } // Po_PUCCH has been updated + else { + tpc = 1; //0 + } // time to do TPC update + else { + tpc = 1; //0 + } + + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void *)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),ue_sched_ctl->dl_cqi[CC_id],format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; + //deactivate second codeword + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = (UE_list->UE_template[CC_id][UE_id].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", + module_idP,CC_id,harq_pid, + (UE_list->UE_template[CC_id][UE_id].DAI-1), + mcs); + } else { + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", + module_idP,CC_id,harq_pid,mcs); + } + + LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); + + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { + ue_sched_ctl->round[CC_id][harq_pid] = 0; + dl_req->number_dci++; + dl_req->number_pdu++; + dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG; + eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; + eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; + // Toggle NDI for next time + LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frameP,subframeP,UE_id, + rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + fill_nfapi_dlsch_config(eNB,dl_req, + TBS, + eNB->pdu_index[CC_id], + rnti, + 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag, unused here + 0, // resource_block_coding, to be filled in later + getQm(mcs), + 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a, + 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, + (frameP*10)+subframeP, + TBS, + eNB->pdu_index[CC_id], + eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); + LOG_D(MAC,"Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n",eNB->pdu_index[CC_id]); + eNB->pdu_index[CC_id]++; + program_dlsch_acknak(module_idP,CC_id,UE_id,frameP,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); + last_dlsch_ue_id[CC_id] = UE_id; + } else { + LOG_W(MAC,"Frame %d, Subframe %d: Dropping DLSCH allocation for UE %d/%x, infeasible CCE allocations\n", + frameP,subframeP,UE_id,rnti); + } + } else { // There is no data from RLC or MAC header, so don't schedule } } - if (cc[CC_id].tdd_Config != NULL){ // TDD + if (cc[CC_id].tdd_Config != NULL) { // TDD set_ul_DAI(module_idP,UE_id,CC_id,frameP,subframeP); } - } // UE_id loop } // CC_id loop - fill_DLSCH_dci_fairRR(module_idP,frameP,subframeP,mbsfn_flag); stop_meas(&eNB->schedule_dlsch); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,VCD_FUNCTION_OUT); - - } //------------------------------------------------------------------------------ void fill_DLSCH_dci_fairRR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - int* mbsfn_flagP) + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int *mbsfn_flagP) //------------------------------------------------------------------------------ { - // loop over all allocated UEs and compute frequency allocations for PDSCH int UE_id = -1; uint8_t /* first_rb, */ nb_rb=3; @@ -1863,7 +1862,6 @@ fill_DLSCH_dci_fairRR( //unsigned char *vrb_map; uint8_t rballoc_sub[25]; //uint8_t number_of_subbands=13; - //unsigned char round; unsigned char harq_pid; int i; @@ -1889,65 +1887,63 @@ fill_DLSCH_dci_fairRR( // UE specific DCIs for (j = 0; j < dlsch_ue_select[CC_id].ue_num; j++) { - if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG2){ + if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG2) { continue; } - if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG4){ + + if(dlsch_ue_select[CC_id].list[j].ue_priority == SCH_DL_MSG4) { continue; } + UE_id = dlsch_ue_select[CC_id].list[j].UE_id; LOG_T(MAC,"CC_id %d, UE_id: %d => status %d\n",CC_id,UE_id,eNB_dlsch_info[module_idP][CC_id][UE_id].status); if (eNB_dlsch_info[module_idP][CC_id][UE_id].status == S_DL_SCHEDULED) { - // clear scheduling flag eNB_dlsch_info[module_idP][CC_id][UE_id].status = S_DL_WAITING; rnti = UE_RNTI(module_idP,UE_id); - harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP); + harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP); nb_rb = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; - - /// Synchronizing rballoc with rballoc_sub for(i=0; i<N_RBG; i++) { rballoc_sub[i] = UE_list->UE_template[CC_id][UE_id].rballoc_subband[harq_pid][i]; } - nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; - nfapi_dl_config_request_pdu_t* dl_config_pdu; - - for (i=0;i<DL_req[CC_id].dl_config_request_body.number_pdu;i++) { - dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[i]; - if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& - (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && - (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; - } - else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE)&& - (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && - (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type==0)) { - dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); - } - } - } + nfapi_dl_config_request_t *DL_req = &RC.mac[module_idP]->DL_req[0]; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + + for (i=0; i<DL_req[CC_id].dl_config_request_body.number_pdu; i++) { + dl_config_pdu = &DL_req[CC_id].dl_config_request_body.dl_config_pdu_list[i]; + + if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&& + (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti) && + (dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1)) { + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; + } else if ((dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE)&& + (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti) && + (dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type==0)) { + dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,N_RB_DL,N_RBG,rballoc_sub); + } + } } } + } - stop_meas(&eNB->fill_DLSCH_dci); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_OUT); + stop_meas(&eNB->fill_DLSCH_dci); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME + (VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI, VCD_FUNCTION_OUT); } void ulsch_scheduler_pre_ue_select_fairRR( - module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - sub_frame_t sched_subframeP, - ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) -{ + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + sub_frame_t sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { eNB_MAC_INST *eNB=RC.mac[module_idP]; COMMON_channels_t *cc; int CC_id,UE_id; @@ -1958,7 +1954,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( uint8_t first_ue_id[MAX_NUM_CCs][20]; uint8_t ul_inactivity_num[MAX_NUM_CCs]; uint8_t ul_inactivity_id[MAX_NUM_CCs][20]; -// LTE_DL_FRAME_PARMS *frame_parms; + // LTE_DL_FRAME_PARMS *frame_parms; uint8_t ulsch_ue_max_num[MAX_NUM_CCs]; uint16_t saved_ulsch_dci[MAX_NUM_CCs]; rnti_t rnti; @@ -1966,127 +1962,134 @@ void ulsch_scheduler_pre_ue_select_fairRR( uint8_t cc_id_flag[MAX_NUM_CCs]; uint8_t harq_pid = 0,round = 0; UE_list_t *UE_list= &eNB->UE_list; - - uint8_t aggregation = 2; int format_flag; nfapi_hi_dci0_request_body_t *HI_DCI0_req; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { - //save ulsch dci number - saved_ulsch_dci[CC_id] = eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body.number_of_dci; - // maximum multiplicity number - ulsch_ue_max_num[CC_id] =RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; - - cc_id_flag[CC_id] = 0; - ue_first_num[CC_id] = 0; - ul_inactivity_num[CC_id] = 0; - + //save ulsch dci number + saved_ulsch_dci[CC_id] = eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body.number_of_dci; + // maximum multiplicity number + ulsch_ue_max_num[CC_id] =RC.rrc[module_idP]->configuration.ue_multiple_max[CC_id]; + cc_id_flag[CC_id] = 0; + ue_first_num[CC_id] = 0; + ul_inactivity_num[CC_id] = 0; } + // UE round >0 for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { - if (UE_list->active[UE_id] == FALSE) - continue; + if (UE_list->active[UE_id] == FALSE) + continue; - rnti = UE_RNTI(module_idP,UE_id); - if (rnti ==NOT_A_RNTI) + rnti = UE_RNTI(module_idP,UE_id); + + if (rnti ==NOT_A_RNTI) + continue; + + CC_id = UE_PCCID(module_idP,UE_id); + + if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) + continue; + + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + continue; + + // UL DCI + HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + + if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { + cc_id_flag[CC_id] = 1; + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; + ret = cc_id_end(cc_id_flag); + + if ( ret == 0 ) { continue; + } - CC_id = UE_PCCID(module_idP,UE_id); - if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) + if ( ret == 1 ) { + return; + } + } + + cc = &eNB->common_channels[CC_id]; + //harq_pid + harq_pid = subframe2harqpid(cc,(frameP+(sched_subframeP<subframeP ? 1 : 0)),sched_subframeP); + //round + round = UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; + + if ( round > 0 ) { + hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; + format_flag = 2; + + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { + cc_id_flag[CC_id] = 1; continue; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_RETRANS; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = eNB->UE_list.UE_template[CC_id][UE_id].first_rb_ul[harq_pid]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = eNB->UE_list.UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; + ulsch_ue_select[CC_id].ue_num++; + continue; + } + } - if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) + // + int bytes_to_schedule = UE_list->UE_template[CC_id][UE_id].estimated_ul_buffer - UE_list->UE_template[CC_id][UE_id].scheduled_ul_bytes; + + if (bytes_to_schedule < 0) bytes_to_schedule = 0; + + if ( UE_id > last_ulsch_ue_id[CC_id] && ((ulsch_ue_select[CC_id].ue_num+ue_first_num[CC_id]) < ulsch_ue_max_num[CC_id]) ) { + if ( bytes_to_schedule > 0 ) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id][ue_first_num[CC_id]] = bytes_to_schedule; + ue_first_num[CC_id]++; continue; + } - // UL DCI - HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; - if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { - cc_id_flag[CC_id] = 1; - HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; - ret = cc_id_end(cc_id_flag); - if ( ret == 0 ) { - continue; - } - if ( ret == 1 ) { - return; - } + if ( UE_list->UE_template[CC_id][UE_id].ul_SR > 0 ) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; + ue_first_num[CC_id]++; + continue; } - cc = &eNB->common_channels[CC_id]; - //harq_pid - harq_pid = subframe2harqpid(cc,(frameP+(sched_subframeP<subframeP ? 1 : 0)),sched_subframeP); - //round - round = UE_list->UE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid]; + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - if ( round > 0 ) { - hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; - format_flag = 2; - if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - continue; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_RETRANS; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = eNB->UE_list.UE_template[CC_id][UE_id].first_rb_ul[harq_pid]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = eNB->UE_list.UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; - ulsch_ue_select[CC_id].ue_num++; - continue; - } + if ( ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { + first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; + first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; + ue_first_num[CC_id]++; + continue; } - // - int bytes_to_schedule = UE_list->UE_template[CC_id][UE_id].estimated_ul_buffer - UE_list->UE_template[CC_id][UE_id].scheduled_ul_bytes; - if (bytes_to_schedule < 0) bytes_to_schedule = 0; - if ( UE_id > last_ulsch_ue_id[CC_id] && ((ulsch_ue_select[CC_id].ue_num+ue_first_num[CC_id]) < ulsch_ue_max_num[CC_id]) ) { - if ( bytes_to_schedule > 0 ) { - first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; - first_ue_total[CC_id][ue_first_num[CC_id]] = bytes_to_schedule; - ue_first_num[CC_id]++; - continue; - } - if ( UE_list->UE_template[CC_id][UE_id].ul_SR > 0 ) { - first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; - first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; - ue_first_num[CC_id]++; - continue; - } - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - if ( ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + /*if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id] ) < ulsch_ue_max_num[CC_id] ) { + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + uint8_t ul_period = 0; + if (cc->tdd_Config) { + ul_period = 50; + } else { + ul_period = 20; + } + if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { - first_ue_id[CC_id][ue_first_num[CC_id]]= UE_id; - first_ue_total[CC_id] [ue_first_num[CC_id]] = 0; - ue_first_num[CC_id]++; + ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; + ul_inactivity_num[CC_id] ++; continue; } - /*if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id] ) < ulsch_ue_max_num[CC_id] ) { - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - uint8_t ul_period = 0; - if (cc->tdd_Config) { - ul_period = 50; - } else { - ul_period = 20; - } - if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || - ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { - ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; - ul_inactivity_num[CC_id] ++; - continue; - } - }*/ - } - + }*/ + } } for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + for ( int temp = 0; temp < ue_first_num[CC_id]; temp++ ) { if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { cc_id_flag[CC_id] = 1; @@ -2097,113 +2100,121 @@ void ulsch_scheduler_pre_ue_select_fairRR( hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; format_flag = 2; rnti = UE_RNTI(module_idP,first_ue_id[CC_id][temp]); + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - break; + cc_id_flag[CC_id] = 1; + break; } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = first_ue_total[CC_id][temp]; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = first_ue_id[CC_id][temp]; - ulsch_ue_select[CC_id].ue_num++; + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = first_ue_total[CC_id][temp]; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = first_ue_id[CC_id][temp]; + ulsch_ue_select[CC_id].ue_num++; } } } for ( UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++ ) { if (UE_list->active[UE_id] == FALSE) - continue; + continue; rnti = UE_RNTI(module_idP,UE_id); + if (rnti ==NOT_A_RNTI) - continue; + continue; CC_id = UE_PCCID(module_idP,UE_id); if (UE_id > last_ulsch_ue_id[CC_id]) - continue; + continue; if (UE_list->UE_template[CC_id][UE_id].configured == FALSE) - continue; + continue; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 1) - continue; + continue; if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { - cc_id_flag[CC_id] = 1; - HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; - ret = cc_id_end(cc_id_flag); - if ( ret == 0 ) { - continue; - } - if ( ret == 1 ) { - return; - } + cc_id_flag[CC_id] = 1; + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; + ret = cc_id_end(cc_id_flag); + + if ( ret == 0 ) { + continue; + } + + if ( ret == 1 ) { + return; + } } - for(i = 0;i<ulsch_ue_select[CC_id].ue_num;i++){ - if(ulsch_ue_select[CC_id].list[i].UE_id == UE_id){ - break; + for(i = 0; i<ulsch_ue_select[CC_id].ue_num; i++) { + if(ulsch_ue_select[CC_id].list[i].UE_id == UE_id) { + break; } } + if(i < ulsch_ue_select[CC_id].ue_num) continue; HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; //SR BSR - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; int bytes_to_schedule = UE_list->UE_template[CC_id][UE_id].estimated_ul_buffer - UE_list->UE_template[CC_id][UE_id].scheduled_ul_bytes; + if (bytes_to_schedule < 0) bytes_to_schedule = 0; if ( (bytes_to_schedule > 0) || (UE_list->UE_template[CC_id][UE_id].ul_SR > 0) || - ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || - ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED)) ){ - hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; - format_flag = 2; - if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - continue; - } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; - if(bytes_to_schedule > 0) - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = bytes_to_schedule; - else if(UE_list->UE_template[CC_id][UE_id].ul_SR > 0) - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; - ulsch_ue_select[CC_id].ue_num++; - continue; - } + ((UE_sched_ctl->ul_inactivity_timer>20)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED)) ) { + hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; + format_flag = 2; + + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { + cc_id_flag[CC_id] = 1; + continue; + } else { + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_FIRST; + + if(bytes_to_schedule > 0) + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = bytes_to_schedule; + else if(UE_list->UE_template[CC_id][UE_id].ul_SR > 0) + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; + + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = UE_id; + ulsch_ue_select[CC_id].ue_num++; + continue; + } } + //inactivity UE -/* if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id]) < ulsch_ue_max_num[CC_id] ) { - UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; - uint8_t ul_period = 0; - if (cc->tdd_Config) { - ul_period = 50; - } else { - ul_period = 20; - } - if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || - ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { - ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; - ul_inactivity_num[CC_id]++; - continue; - } - }*/ + /* if ( (ulsch_ue_select[CC_id].ue_num+ul_inactivity_num[CC_id]) < ulsch_ue_max_num[CC_id] ) { + UE_sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; + uint8_t ul_period = 0; + if (cc->tdd_Config) { + ul_period = 50; + } else { + ul_period = 20; + } + if ( ((UE_sched_ctl->ul_inactivity_timer>ul_period)&&(UE_sched_ctl->ul_scheduled==0)) || + ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP,UE_id)) < RRC_CONNECTED))) { + ul_inactivity_id[CC_id][ul_inactivity_num[CC_id]]= UE_id; + ul_inactivity_num[CC_id]++; + continue; + } + }*/ } for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + for ( int temp = 0; temp < ul_inactivity_num[CC_id]; temp++ ) { if ( (ulsch_ue_select[CC_id].ue_num >= ulsch_ue_max_num[CC_id]) || (cc_id_flag[CC_id] == 1) ) { HI_DCI0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; @@ -2214,43 +2225,45 @@ void ulsch_scheduler_pre_ue_select_fairRR( hi_dci0_pdu = &HI_DCI0_req->hi_dci0_pdu_list[HI_DCI0_req->number_of_dci+HI_DCI0_req->number_of_hi]; format_flag = 2; rnti = UE_RNTI(module_idP,ul_inactivity_id[CC_id][temp]); + if (CCE_allocation_infeasible(module_idP,CC_id,format_flag,subframeP,aggregation,rnti) == 1) { - cc_id_flag[CC_id] = 1; - continue; + cc_id_flag[CC_id] = 1; + continue; } else { - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - HI_DCI0_req->number_of_dci++; - - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_INACTIVE; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = ul_inactivity_id[CC_id][temp]; - ulsch_ue_select[CC_id].ue_num++; + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + HI_DCI0_req->number_of_dci++; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_INACTIVE; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ul_total_buffer = 0; + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = ul_inactivity_id[CC_id][temp]; + ulsch_ue_select[CC_id].ue_num++; } } + HI_DCI0_req->number_of_dci = saved_ulsch_dci[CC_id]; } + return; } -uint8_t find_rb_table_index(uint8_t average_rbs) -{ +uint8_t find_rb_table_index(uint8_t average_rbs) { int i; + for ( i = 0; i < 34; i++ ) { if ( rb_table[i] > average_rbs ) { return (i-1); } } + return i; } void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - sub_frame_t sched_subframeP, - ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) -{ + frame_t frameP, + sub_frame_t subframeP, + sub_frame_t sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { int CC_id,ulsch_ue_num; eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_list_t *UE_list= &eNB->UE_list; @@ -2275,26 +2288,27 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, for ( CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++ ) { cc = &RC.mac[module_idP]->common_channels[CC_id]; frame_parms = &(RC.eNB[module_idP][CC_id]->frame_parms); + if (cc->tdd_Config) { //TDD if (frame_parms->N_RB_UL == 25) { - num_pucch_rb = 1; + num_pucch_rb = 1; } else if (frame_parms->N_RB_UL == 50) { - num_pucch_rb = 2; + num_pucch_rb = 2; } else { - num_pucch_rb = 3; + num_pucch_rb = 3; } } else {//FDD if (frame_parms->N_RB_UL == 25) { - num_pucch_rb = 1; + num_pucch_rb = 1; } else { - num_pucch_rb = 2; + num_pucch_rb = 2; } } first_rb[CC_id] = num_pucch_rb; ue_num_temp = ulsch_ue_select[CC_id].ue_num; - for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { + for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { UE_id = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { @@ -2309,52 +2323,59 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, continue; } - if (first_rb[CC_id] >= frame_parms->N_RB_UL-num_pucch_rb ) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id); - break; + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id); + break; } - total_rbs = frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id]; + total_rbs = frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id]; average_rbs = (int)round((double)total_rbs/(double)ue_num_temp); + if ( average_rbs < 3 ) { ue_num_temp--; ulsch_ue_num--; ulsch_ue_select[CC_id].ue_num--; continue; } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS ) { if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= average_rbs ) { - // assigne RBS(nb_rb) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + // assigne RBS(nb_rb) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb > average_rbs ) { if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb <= total_rbs ) { - // assigne RBS(average_rbs) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + // assigne RBS(average_rbs) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + first_rb[CC_id] = first_rb[CC_id] + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; } else { - // assigne RBS(remain rbs) - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; - rb_table_index = 2; - while(rb_table[rb_table_index] <= total_rbs){ - rb_table_index++; - } - ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb = rb_table[rb_table_index-1]; - first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index-1]; + // assigne RBS(remain rbs) + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb = first_rb[CC_id]; + rb_table_index = 2; + + while(rb_table[rb_table_index] <= total_rbs) { + rb_table_index++; + } + + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb = rb_table[rb_table_index-1]; + first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index-1]; } } - }else{ + } else { UE_template = &UE_list->UE_template[CC_id][UE_id]; + if ( UE_list->UE_sched_ctrl[UE_id].phr_received == 1 ) { mcs = 20; } else { mcs = 10; } + if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST ) { int bytes_to_schedule = UE_template->estimated_ul_buffer - UE_template->scheduled_ul_bytes; + if (bytes_to_schedule < 0) bytes_to_schedule = 0; if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0 ) { @@ -2369,7 +2390,7 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, } while ( (tbs < bytes_to_schedule) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id])) && - ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { + ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 32 )) { rb_table_index++; tbs = get_TBS_UL(mcs,rb_table[rb_table_index])<<3; tx_power= estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); @@ -2378,6 +2399,7 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, if ( rb_table[rb_table_index]<3 ) { rb_table_index=2; } + if ( rb_table[rb_table_index] <= average_rbs ) { // assigne RBS( nb_rb) first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; @@ -2385,27 +2407,30 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; } + if ( rb_table[rb_table_index] > average_rbs ) { // assigne RBS(average_rbs) rb_table_index = find_rb_table_index(average_rbs); - if (rb_table_index>=34){ - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: average RBs %d > 100\n", - module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id,average_rbs); - break; + + if (rb_table_index>=34) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: average RBs %d > 100\n", + module_idP,frameP,subframeP,UE_id,UE_RNTI(CC_id,UE_id),CC_id,average_rbs); + break; } + first_rb[CC_id] = first_rb[CC_id] + rb_table[rb_table_index]; UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[0] = rb_table[rb_table_index]; UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = rb_table_index; UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = mcs; } - }else { + } else { // assigne RBS( 3 RBs) first_rb[CC_id] = first_rb[CC_id] + 3; UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[0] = 3; UE_list->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = 2; UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; } - }else if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE ) { + } else if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE ) { // assigne RBS( 3 RBs) first_rb[CC_id] = first_rb[CC_id] + 3; UE_list->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul[0] = 3; @@ -2413,6 +2438,7 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, UE_list->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; } } + ue_num_temp--; } } @@ -2421,105 +2447,126 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, void schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP) -{ + sub_frame_t subframeP) { uint16_t i; int CC_id; eNB_MAC_INST *mac = RC.mac[module_idP]; COMMON_channels_t *cc; int sched_frame=frameP; - start_meas(&mac->schedule_ulsch); - int sched_subframe = (subframeP+4)%10; - cc = &mac->common_channels[0]; int tdd_sfa; + // for TDD: check subframes where we have to act and return if nothing should be done now if (cc->tdd_Config) { tdd_sfa = cc->tdd_Config->subframeAssignment; + switch (subframeP) { - case 0: - if ((tdd_sfa == 0)|| - (tdd_sfa == 3)) sched_subframe = 4; - else if (tdd_sfa==6) sched_subframe = 7; - else return; - break; - case 1: - if ((tdd_sfa==0)|| - (tdd_sfa==1)) sched_subframe = 7; - else if (tdd_sfa==6) sched_subframe = 8; - else return; - break; - case 2: // Don't schedule UL in subframe 2 for TDD - return; - case 3: - if (tdd_sfa==2) sched_subframe = 7; - else return; - break; - case 4: - if (tdd_sfa==1) sched_subframe = 8; - else return; - break; - case 5: - if (tdd_sfa==0) sched_subframe = 9; - else if (tdd_sfa==6) sched_subframe = 2; - else return; - break; - case 6: - if (tdd_sfa==0 || tdd_sfa==1) sched_subframe = 2; - else if (tdd_sfa==6) sched_subframe = 3; - else return; - break; - case 7: - return; - case 8: - if ((tdd_sfa>=2) && (tdd_sfa<=5)) sched_subframe=2; - else return; - break; - case 9: - if ((tdd_sfa==1) || (tdd_sfa==3) || (tdd_sfa==4)) sched_subframe=3; - else if (tdd_sfa==6) sched_subframe=4; - else return; - break; + case 0: + if ((tdd_sfa == 0)|| + (tdd_sfa == 3)) sched_subframe = 4; + else if (tdd_sfa==6) sched_subframe = 7; + else return; + + break; + + case 1: + if ((tdd_sfa==0)|| + (tdd_sfa==1)) sched_subframe = 7; + else if (tdd_sfa==6) sched_subframe = 8; + else return; + + break; + + case 2: // Don't schedule UL in subframe 2 for TDD + return; + + case 3: + if (tdd_sfa==2) sched_subframe = 7; + else return; + + break; + + case 4: + if (tdd_sfa==1) sched_subframe = 8; + else return; + + break; + + case 5: + if (tdd_sfa==0) sched_subframe = 9; + else if (tdd_sfa==6) sched_subframe = 2; + else return; + + break; + + case 6: + if (tdd_sfa==0 || tdd_sfa==1) sched_subframe = 2; + else if (tdd_sfa==6) sched_subframe = 3; + else return; + + break; + + case 7: + return; + + case 8: + if ((tdd_sfa>=2) && (tdd_sfa<=5)) sched_subframe=2; + else return; + + break; + + case 9: + if ((tdd_sfa==1) || (tdd_sfa==3) || (tdd_sfa==4)) sched_subframe=3; + else if (tdd_sfa==6) sched_subframe=4; + else return; + + break; } } + if (sched_subframe < subframeP) sched_frame++; + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]; memset(ulsch_ue_select, 0, sizeof(ulsch_ue_select)); - LTE_DL_FRAME_PARMS *frame_parms ; for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { cc = &mac->common_channels[CC_id]; frame_parms= &RC.eNB[module_idP][CC_id]->frame_parms; + // output of scheduling, the UE numbers in RBs, where it is in the code??? // check if RA (Msg3) is active in this subframeP, if so skip the PRBs used for Msg3 // Msg3 is using 1 PRB so we need to increase first_rb accordingly // not sure about the break (can there be more than 1 active RA procedure?) for (i=0; i<NB_RA_PROC_MAX; i++) { - if ((cc->ra[i].state == WAITMSG3) &&(cc->ra[i].Msg3_subframe == sched_subframe)) { + if ((cc->ra[i].state == WAITMSG3) &&(cc->ra[i].Msg3_subframe == sched_subframe)) { ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_MSG3; + if (cc->tdd_Config == NULL) { - if(frame_parms->N_RB_UL == 25){ - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; - }else{ - ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; - } + if(frame_parms->N_RB_UL == 25) { + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; + } else { + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; + } } else { - switch(frame_parms->N_RB_UL){ + switch(frame_parms->N_RB_UL) { case 25: default: ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; break; + case 50: ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 2; break; + case 100: ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 3; break; - } + } } + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = 1; ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = -1; ulsch_ue_select[CC_id].ue_num++; @@ -2531,11 +2578,11 @@ schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, if (is_prach_subframe(frame_parms,sched_frame,sched_subframe)==1) { ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].ue_priority = SCH_UL_PRACH; ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = get_prach_prb_offset( - frame_parms, - frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, - frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset, - 0,//tdd_mapindex - frameP); //Nf + frame_parms, + frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, + frame_parms->prach_config_common.prach_ConfigInfo.prach_FreqOffset, + 0,//tdd_mapindex + frameP); //Nf ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].nb_rb = 6; ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].UE_id = -1; ulsch_ue_select[CC_id].ue_num++; @@ -2547,11 +2594,10 @@ schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, } void schedule_ulsch_rnti_fairRR(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, - ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) -{ + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, + ULSCH_UE_SELECT ulsch_ue_select[MAX_NUM_CCs]) { int16_t UE_id; uint8_t aggregation = 2; uint16_t first_rb[MAX_NUM_CCs]; @@ -2560,7 +2606,7 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, uint8_t round = 0; uint8_t harq_pid = 0; uint8_t status = 0; - uint8_t rb_table_index = -1; + uint8_t rb_table_index = -1; uint32_t cqi_req,cshift,ndi,tpc; int32_t normalized_rx_power; int32_t target_rx_power=-90; @@ -2576,99 +2622,102 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, int rvidx_tab[4] = {0,2,3,1}; uint16_t ul_req_index; uint8_t dlsch_flag; + if (sched_subframeP < subframeP) sched_frame++; nfapi_hi_dci0_request_body_t *hi_dci0_req; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - nfapi_ul_config_request_body_t *ul_req_tmp; nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; LOG_D(MAC,"entering ulsch preprocesor\n"); ulsch_scheduler_pre_processor_fairRR(module_idP, - frameP, - subframeP, - sched_subframeP, - ulsch_ue_select); - + frameP, + subframeP, + sched_subframeP, + ulsch_ue_select); LOG_D(MAC,"exiting ulsch preprocesor\n"); - - // loop over all active UEs for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; - eNB->HI_DCI0_req[CC_id][subframeP].sfn_sf = (frameP<<4)+subframeP; - ul_req_tmp = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body; - nfapi_ul_config_request_t *ul_req = &eNB->UL_req_tmp[CC_id][sched_subframeP]; - + hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body; + eNB->HI_DCI0_req[CC_id][subframeP].sfn_sf = (frameP<<4)+subframeP; + ul_req_tmp = &eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body; + nfapi_ul_config_request_t *ul_req = &eNB->UL_req_tmp[CC_id][sched_subframeP]; ULSCH_first_end = 0; cc = &eNB->common_channels[CC_id]; // This is the actual CC_id in the list N_RB_UL = to_prb(cc->mib->message.dl_Bandwidth); + //leave out first RB for PUCCH if (cc->tdd_Config == NULL) { - if(N_RB_UL == 25){ - first_rb[CC_id] = 1; - }else{ - first_rb[CC_id] = 2; - } - }else { - switch(N_RB_UL){ + if(N_RB_UL == 25) { + first_rb[CC_id] = 1; + } else { + first_rb[CC_id] = 2; + } + } else { + switch(N_RB_UL) { case 25: default: - first_rb[CC_id] = 1; + first_rb[CC_id] = 1; break; + case 50: - first_rb[CC_id] = 2; + first_rb[CC_id] = 2; break; + case 100: - first_rb[CC_id] = 3; + first_rb[CC_id] = 3; break; - } + } } + for ( ulsch_ue_num = 0; ulsch_ue_num < ulsch_ue_select[CC_id].ue_num; ulsch_ue_num++ ) { UE_id = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; + /* be sure that there are some free RBs */ - if (cc->tdd_Config == NULL){ - if(N_RB_UL == 25){ - if (first_rb[CC_id] >= N_RB_UL-1) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; - } - }else{ - if (first_rb[CC_id] >= N_RB_UL-2) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id); - break; - } + if (cc->tdd_Config == NULL) { + if(N_RB_UL == 25) { + if (first_rb[CC_id] >= N_RB_UL-1) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + break; + } + } else { + if (first_rb[CC_id] >= N_RB_UL-2) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id); + break; } + } } else { - if(N_RB_UL == 25){ - if (first_rb[CC_id] >= N_RB_UL-1) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); - break; - } - }else if(N_RB_UL == 50){ - if (first_rb[CC_id] >= N_RB_UL-2) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); - break; - } - }else if(N_RB_UL == 100){ - if (first_rb[CC_id] >= N_RB_UL-3) { - LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", - module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); - break; - } + if(N_RB_UL == 25) { + if (first_rb[CC_id] >= N_RB_UL-1) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); + break; } + } else if(N_RB_UL == 50) { + if (first_rb[CC_id] >= N_RB_UL-2) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); + break; + } + } else if(N_RB_UL == 100) { + if (first_rb[CC_id] >= N_RB_UL-3) { + LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d/%x CC %d N_RB_UL %d first_rb %d: dropping, not enough RBs\n", + module_idP,frameP,subframeP,UE_id,rnti,CC_id, N_RB_UL, first_rb[CC_id]); + break; + } + } } + //MSG3 if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_MSG3) { first_rb[CC_id] ++; continue; } + //PRACH if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_PRACH) { first_rb[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb+ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; @@ -2681,376 +2730,389 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, rnti = UE_RNTI(CC_id,UE_id); LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", module_idP,frameP,subframeP,harq_pid,UE_id,rnti,CC_id, aggregation,N_RB_UL); - int bytes_to_schedule = UE_template->estimated_ul_buffer - UE_template->scheduled_ul_bytes; + if (bytes_to_schedule < 0) bytes_to_schedule = 0; RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = bytes_to_schedule; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP]); - status = mac_eNB_get_rrc_status(module_idP,rnti); + if (status < RRC_CONNECTED) cqi_req = 0; else if (UE_sched_ctrl->cqi_req_timer>30) { - cqi_req = 1; - // To be safe , do not ask CQI in special SFs:36.213/7.2.3 CQI definition - if (cc->tdd_Config) { - switch (cc->tdd_Config->subframeAssignment) { - case 1: - if( subframeP == 1 || subframeP == 6 ) cqi_req=0; - break; - case 3: - if( subframeP == 1 ) cqi_req=0; - break; - default: - LOG_E(MAC," TDD config not supported\n"); - break; - } - } - if(cqi_req == 1){ - UE_sched_ctrl->cqi_req_timer=0; - UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; - } - } - else + cqi_req = 1; + + // To be safe , do not ask CQI in special SFs:36.213/7.2.3 CQI definition + if (cc->tdd_Config) { + switch (cc->tdd_Config->subframeAssignment) { + case 1: + if( subframeP == 1 || subframeP == 6 ) cqi_req=0; + + break; + + case 3: + if( subframeP == 1 ) cqi_req=0; + + break; + + default: + LOG_E(MAC," TDD config not supported\n"); + break; + } + } + + if(cqi_req == 1) { + UE_sched_ctrl->cqi_req_timer=0; + UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; + } + } else cqi_req = 0; //power control //compute the expected ULSCH RX power (for the stats) - // this is the normalized RX power and this should be constant (regardless of mcs normalized_rx_power = (5*UE_sched_ctrl->pusch_snr[CC_id]-640)/10+30; //(+eNB->measurements.n0_power_dB[0]) target_rx_power= eNB->puSch10xSnr/10 + 30; //(+eNB->measurements.n0_power_dB[0]) - // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame*10+UE_template->pusch_tpc_tx_subframe; + if (((framex10psubframe+10)<=(frameP*10+subframeP)) || //normal case - ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) //frame wrap-around - { - UE_template->pusch_tpc_tx_frame=frameP; - UE_template->pusch_tpc_tx_subframe=subframeP; - if (normalized_rx_power>(target_rx_power+4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power<(target_rx_power-4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } + ((framex10psubframe>(frameP*10+subframeP)) && (((10240-framex10psubframe+frameP*10+subframeP)>=10)))) { //frame wrap-around + UE_template->pusch_tpc_tx_frame=frameP; + UE_template->pusch_tpc_tx_subframe=subframeP; + + if (normalized_rx_power>(target_rx_power+4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power<(target_rx_power-4)) { + tpc = 2; //+1 + tpc_accumulated++; } else { tpc = 1; //0 } - if (tpc!=1) { - LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + } else { + tpc = 1; //0 + } + + if (tpc!=1) { + LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", module_idP,frameP,subframeP,harq_pid,tpc, tpc_accumulated,normalized_rx_power,target_rx_power); + } + + // new transmission + if ((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) || + (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE)) { + LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x (SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", + module_idP,harq_pid,frameP,subframeP,UE_id,rnti,UE_template->ul_SR, + UE_sched_ctrl->ul_inactivity_timer, + UE_sched_ctrl->ul_failure_timer, + UE_sched_ctrl->cqi_req_timer); + ndi = 1-UE_template->oldNDI_UL[harq_pid]; + UE_template->oldNDI_UL[harq_pid]=ndi; + UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; + UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + + if (UE_template->pre_allocated_rb_table_index_ul >=0) { + rb_table_index=UE_template->pre_allocated_rb_table_index_ul; + } else { + UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); + rb_table_index=5; // for PHR } - // new transmission - if ((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) || - (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE)) { - LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x (SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", - module_idP,harq_pid,frameP,subframeP,UE_id,rnti,UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - UE_sched_ctrl->ul_failure_timer, - UE_sched_ctrl->cqi_req_timer); - - ndi = 1-UE_template->oldNDI_UL[harq_pid]; - UE_template->oldNDI_UL[harq_pid]=ndi; - UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; - UE_template->mcs_UL[harq_pid] = UE_template->pre_assigned_mcs_ul;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS - if (UE_template->pre_allocated_rb_table_index_ul >=0) { - rb_table_index=UE_template->pre_allocated_rb_table_index_ul; - } else { - UE_template->mcs_UL[harq_pid]=10;//cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index=5; // for PHR - } - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; - - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; - - T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); - - if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) - LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid], - first_rb[CC_id],rb_table[rb_table_index], - rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; - UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; - - UE_sched_ctrl->ul_scheduled |= (1<<harq_pid); - if (UE_id == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled); - - // adjust total UL buffer status by TBS, wait for UL sdus to do final update - /*LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]); - if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) - UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; - else - UE_template->ul_total_buffer = 0; - LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer);*/ - // Cyclic shift for DM RS - cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) - // save it for a potential retransmission - UE_template->cshift[harq_pid] = cshift; - - hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - - hi_dci0_req->number_of_dci++; - hi_dci0_req->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) - hi_dci0_req->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - nfapi_hi_dci0_request_t *nfapi_hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP]; - nfapi_hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! - nfapi_hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); - - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp->number_of_pdus;ul_req_index++){ - if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && - (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); - break; - } - } - // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - first_rb[CC_id], // resource_block_start - rb_table[rb_table_index], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - ndi, // new_data_indication - 0, // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - get_TBS_UL(UE_template->mcs_UL[harq_pid], - rb_table[rb_table_index]) - ); + + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=UE_template->mcs_UL[harq_pid]; + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=rb_table[rb_table_index]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; + T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); + + if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) + LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", + module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,UE_template->mcs_UL[harq_pid], + first_rb[CC_id],rb_table[rb_table_index], + rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; + UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; + UE_sched_ctrl->ul_scheduled |= (1<<harq_pid); + + if (UE_id == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED,UE_sched_ctrl->ul_scheduled); + + // adjust total UL buffer status by TBS, wait for UL sdus to do final update + /*LOG_D(MAC,"[eNB %d] CC_id %d UE %d/%x : adjusting ul_total_buffer, old %d, TBS %d\n", module_idP,CC_id,UE_id,rnti,UE_template->ul_total_buffer,UE_template->TBS_UL[harq_pid]); + if (UE_template->ul_total_buffer > UE_template->TBS_UL[harq_pid]) + UE_template->ul_total_buffer -= UE_template->TBS_UL[harq_pid]; + else + UE_template->ul_total_buffer = 0; + LOG_D(MAC,"ul_total_buffer, new %d\n", UE_template->ul_total_buffer);*/ + // Cyclic shift for DM RS + cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + // save it for a potential retransmission + UE_template->cshift[harq_pid] = cshift; + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; + memset((void *)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; + hi_dci0_req->number_of_dci++; + hi_dci0_req->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4) + hi_dci0_req->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + nfapi_hi_dci0_request_t *nfapi_hi_dci0_req = &eNB->HI_DCI0_req[CC_id][subframeP]; + nfapi_hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! + nfapi_hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp->number_of_pdus; ul_req_index++) { + if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } + + // Add UL_config PDUs + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + cqi_req, + cc, + UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + first_rb[CC_id], // resource_block_start + rb_table[rb_table_index], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL(UE_template->mcs_UL[harq_pid], + rb_table[rb_table_index]) + ); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - UE_template->rach_resource_type>2 ? 2 : 1, - 1, //total_number_of_repetitions - 1, //repetition_number - (frameP*10)+subframeP); - } + + if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + UE_template->rach_resource_type>2 ? 2 : 1, + 1, //total_number_of_repetitions + 1, //repetition_number + (frameP*10)+subframeP); + } + #endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - - }else{ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp->number_of_pdus++; - } - eNB->ul_handle++; - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - uint16_t ul_sched_frame = sched_frame; - uint16_t ul_sched_subframeP = sched_subframeP; - add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); - ul_req->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; - - add_ue_ulsch_info(module_idP, - CC_id, - UE_id, - subframeP, - S_UL_SCHEDULED); - - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); - - // increment first rb for next UE allocation - first_rb[CC_id]+=rb_table[rb_table_index]; - if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) { - UE_template->scheduled_ul_bytes += get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); - UE_template->ul_SR = 0; - } - if((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE) && (ULSCH_first_end == 0)) { - ULSCH_first_end = 1; - last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num-1].UE_id; - } - if((ulsch_ue_num == ulsch_ue_select[CC_id].ue_num-1) && (ULSCH_first_end == 0)) { - ULSCH_first_end = 1; - last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; - } + + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + } else { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; } - else if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS) { // round > 0 => retransmission - T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), - T_INT(round)); - - round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; - uint8_t mcs_rv = 0; - if(rvidx_tab[round&3]==1){ - mcs_rv = 29; - }else if(rvidx_tab[round&3]==2){ - mcs_rv = 30; - }else if(rvidx_tab[round&3]==3){ - mcs_rv = 31; - } - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb); - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; - - - if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) - LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", - module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs_rv,first_rb[CC_id],rb_table[rb_table_index],rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - UE_template->first_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; - - UE_sched_ctrl->ul_scheduled |= (1<<harq_pid); - // Cyclic shift for DM RS - cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) - - hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; - memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs_rv; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = UE_template->oldNDI_UL[harq_pid]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - - hi_dci0_req->number_of_dci++; - // Add UL_config PDUs - LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp->number_of_pdus;ul_req_index++){ - if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && - (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(phich)\n",frameP,subframeP,rnti,ul_req_index); - break; - } - } - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - cqi_req, - cc, - UE_template->physicalConfigDedicated, - get_tmode(module_idP,CC_id,UE_id), - eNB->ul_handle, - rnti, - ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, // resource_block_start - ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], - cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round&3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template->TBS_UL[harq_pid] - ); + + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp->number_of_pdus++; + } + + eNB->ul_handle++; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + uint16_t ul_sched_frame = sched_frame; + uint16_t ul_sched_subframeP = sched_subframeP; + add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); + ul_req->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; + add_ue_ulsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_UL_SCHEDULED); + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,CC_id,frameP,subframeP,UE_id); + // increment first rb for next UE allocation + first_rb[CC_id]+=rb_table[rb_table_index]; + + if(ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_FIRST) { + UE_template->scheduled_ul_bytes += get_TBS_UL(UE_template->mcs_UL[harq_pid],rb_table[rb_table_index]); + UE_template->ul_SR = 0; + } + + if((ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_INACTIVE) && (ULSCH_first_end == 0)) { + ULSCH_first_end = 1; + last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num-1].UE_id; + } + + if((ulsch_ue_num == ulsch_ue_select[CC_id].ue_num-1) && (ULSCH_first_end == 0)) { + ULSCH_first_end = 1; + last_ulsch_ue_id[CC_id] = ulsch_ue_select[CC_id].list[ulsch_ue_num].UE_id; + } + } else if (ulsch_ue_select[CC_id].list[ulsch_ue_num].ue_priority == SCH_UL_RETRANS) { // round > 0 => retransmission + T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, T_INT(module_idP), T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), T_INT(UE_template->mcs_UL[harq_pid]), T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), + T_INT(round)); + round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; + uint8_t mcs_rv = 0; + + if(rvidx_tab[round&3]==1) { + mcs_rv = 29; + } else if(rvidx_tab[round&3]==2) { + mcs_rv = 30; + } else if(rvidx_tab[round&3]==3) { + mcs_rv = 31; + } + + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb); + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS=UE_template->TBS_UL[harq_pid]; + + if (mac_eNB_get_rrc_status(module_idP,rnti) < RRC_CONNECTED) + LOG_D(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", + module_idP,harq_pid,rnti,CC_id,frameP,subframeP,UE_id,mcs_rv,first_rb[CC_id],rb_table[rb_table_index],rb_table_index,UE_template->TBS_UL[harq_pid],harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + UE_template->first_rb_ul[harq_pid] = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; + UE_sched_ctrl->ul_scheduled |= (1<<harq_pid); + // Cyclic shift for DM RS + cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]; + memset((void *)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs_rv; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = UE_template->oldNDI_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; + hi_dci0_req->number_of_dci++; + // Add UL_config PDUs + LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp->number_of_pdus; ul_req_index++) { + if((ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE) && + (ul_req_tmp->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti)) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(phich)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } + + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + cqi_req, + cc, + UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + ulsch_ue_select[CC_id].list[ulsch_ue_num].start_rb, // resource_block_start + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb, // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round&3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template->TBS_UL[harq_pid] + ); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], - UE_template->rach_resource_type>2 ? 2 : 1, - 1, //total_number_of_repetitions - 1, //repetition_number - (frameP*10)+subframeP); - } -#endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - - }else{ - ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; - } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp->number_of_pdus++; - } - eNB->ul_handle++; - ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - ul_req->sfn_sf = sched_frame<<4|sched_subframeP; - LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0(round >0)\n", module_idP,CC_id,frameP,subframeP,UE_id); + if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_index], + UE_template->rach_resource_type>2 ? 2 : 1, + 1, //total_number_of_repetitions + 1, //repetition_number + (frameP*10)+subframeP); + } + +#endif - // increment first rb for next UE allocation - first_rb[CC_id]+=ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + } else { + ul_req_tmp->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; } + + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp->number_of_pdus++; + } + + eNB->ul_handle++; + ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req->sfn_sf = sched_frame<<4|sched_subframeP; + LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0(round >0)\n", module_idP,CC_id,frameP,subframeP,UE_id); + // increment first rb for next UE allocation + first_rb[CC_id]+=ulsch_ue_select[CC_id].list[ulsch_ue_num].nb_rb; + } } // loop over UE_id } // loop of CC_id } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index b43c34fe141bd32fb2d4f239cdfbe7bcbe12512e..06e7a7f4b2eb4947a0d090dc5924e28fb8c23202 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -2272,8 +2272,7 @@ uint8_t get_tmode(module_id_t module_idP, int CC_idP, int UE_idP) eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = &eNB->common_channels[CC_idP]; - struct LTE_PhysicalConfigDedicated *physicalConfigDedicated = - eNB->UE_list.physicalConfigDedicated[CC_idP][UE_idP]; + LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = eNB->UE_list.physicalConfigDedicated[CC_idP][UE_idP]; if (physicalConfigDedicated == NULL) { // RRCConnectionSetup not received by UE yet AssertFatal(cc->p_eNB <= 2, "p_eNB is %d, should be <2\n", diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 92b9c15efbb66fe49e011eaa14ea5ef810e450a4..9a6340a72b08bb094a495e3e44ef7f3861903091 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -51,7 +51,7 @@ #include "pdcp.h" #if defined(ENABLE_ITTI) -#include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "ENB_APP/flexran_agent_defs.h" @@ -76,10 +76,10 @@ extern int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req); extern uint8_t nfapi_mode; // This table holds the allowable PRB sizes for ULSCH transmissions -uint8_t rb_table[34] = - { 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, - 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100 - }; +uint8_t rb_table[34] = { + 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, + 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 96, 100 +}; extern mui_t rrc_eNB_mui; @@ -89,10 +89,9 @@ rx_sdu(const module_id_t enb_mod_idP, const frame_t frameP, const sub_frame_t subframeP, const rnti_t rntiP, - uint8_t * sduP, + uint8_t *sduP, const uint16_t sdu_lenP, - const uint16_t timing_advance, const uint8_t ul_cqi) -{ + const uint16_t timing_advance, const uint8_t ul_cqi) { int current_rnti = rntiP; unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; @@ -104,13 +103,12 @@ rx_sdu(const module_id_t enb_mod_idP, int harq_pid = subframe2harqpid(&mac->common_channels[CC_idP], frameP, subframeP); int lcgid_updated[4] = {0, 0, 0, 0}; - UE_list_t *UE_list = &mac->UE_list; int crnti_rx = 0; RA_t *ra = (RA_t *) & RC.mac[enb_mod_idP]->common_channels[CC_idP].ra[0]; int first_rb = 0; - + rrc_eNB_ue_context_t *ue_contextP = NULL; start_meas(&mac->rx_ulsch_sdu); if ((UE_id > MAX_MOBILES_PER_ENB) || (UE_id == -1)) @@ -119,23 +117,24 @@ rx_sdu(const module_id_t enb_mod_idP, } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME - (VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1); + (VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1); + if (opt_enabled == 1) { trace_pdu(DIRECTION_UPLINK, sduP, sdu_lenP, 0, WS_C_RNTI, current_rnti, frameP, subframeP, - 0, 0); + 0, 0); LOG_D(OPT, "[eNB %d][ULSCH] Frame %d rnti %x with size %d\n", - enb_mod_idP, frameP, current_rnti, sdu_lenP); + enb_mod_idP, frameP, current_rnti, sdu_lenP); } if (UE_id != -1) { LOG_D(MAC, - "[eNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], - current_rnti, UE_id, ul_cqi); - + "[eNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], + current_rnti, UE_id, ul_cqi); AssertFatal(UE_list->UE_sched_ctrl[UE_id]. - round_UL[CC_idP][harq_pid] < 8, "round >= 8\n"); + round_UL[CC_idP][harq_pid] < 8, "round >= 8\n"); + if (sduP != NULL) { UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; @@ -145,58 +144,60 @@ rx_sdu(const module_id_t enb_mod_idP, * lte_est_timing_advance_pusch, maybe it's not necessary? * maybe it's even not correct at all? */ - UE_list->UE_sched_ctrl[UE_id].ta_update = (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance) / 4; + UE_list->UE_sched_ctrl[UE_id].ta_update = (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance) / 4; UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0; first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 0; - mac_eNB_rrc_ul_in_sync(enb_mod_idP, CC_idP, frameP, - subframeP, UE_RNTI(enb_mod_idP, - UE_id)); + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 0; + mac_eNB_rrc_ul_in_sync(enb_mod_idP, CC_idP, frameP, + subframeP, UE_RNTI(enb_mod_idP, + UE_id)); } /* update scheduled bytes */ UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes -= UE_list->UE_template[CC_idP][UE_id].TBS_UL[harq_pid]; + if (UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes < 0) UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes = 0; - } else { // we've got an error + } else { // we've got an error LOG_I(MAC, - "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], - ul_cqi); + "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP,frameP,subframeP, + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], + ul_cqi); - if(ul_cqi>200){ // too high energy pattern + if(ul_cqi>200) { // too high energy pattern UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi; } // AssertFatal(1==0,"ulsch in error\n"); if (UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] == 3) { - UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1 << harq_pid)); - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; - if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10) - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; + UE_list->UE_sched_ctrl[UE_id].ul_scheduled &= (~(1 << harq_pid)); + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; + + if (UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors++ == 10) + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 1; /* update scheduled bytes */ UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes -= UE_list->UE_template[CC_idP][UE_id].TBS_UL[harq_pid]; + if (UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes < 0) UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes = 0; if (find_RA_id(enb_mod_idP, CC_idP, current_rnti) != -1) cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); } else - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; + UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; - // Program NACK for PHICH LOG_D(MAC, - "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n", - current_rnti, harq_pid, first_rb); + "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n", + current_rnti, harq_pid, first_rb); nfapi_hi_dci0_request_t *hi_dci0_req; - uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP] , subframeP); + uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP); hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10]; nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = @@ -213,64 +214,59 @@ rx_sdu(const module_id_t enb_mod_idP, hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP, sf_ahead_dl); hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - return; - } - } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti + } else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti AssertFatal(mac->common_channels[CC_idP]. - radioResourceConfigCommon->rach_ConfigCommon. - maxHARQ_Msg3Tx > 1, - "maxHARQ %d should be greater than 1\n", - (int) mac->common_channels[CC_idP]. - radioResourceConfigCommon->rach_ConfigCommon. - maxHARQ_Msg3Tx); - + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx > 1, + "maxHARQ %d should be greater than 1\n", + (int) mac->common_channels[CC_idP]. + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx); LOG_D(MAC, - "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP, ra[RA_id].msg3_round, - current_rnti, RA_id, ul_cqi); - + "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, CC_idP, ra[RA_id].msg3_round, + current_rnti, RA_id, ul_cqi); first_rb = ra->msg3_first_rb; - if (sduP == NULL) { // we've got an error on Msg3 + if (sduP == NULL) { // we've got an error on Msg3 LOG_D(MAC, - "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", - enb_mod_idP, CC_idP, RA_id, - ra[RA_id].msg3_round, - (int) mac->common_channels[CC_idP]. - radioResourceConfigCommon->rach_ConfigCommon. - maxHARQ_Msg3Tx); - if (ra[RA_id].msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { - cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); - } + "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", + enb_mod_idP, CC_idP, RA_id, + ra[RA_id].msg3_round, + (int) mac->common_channels[CC_idP]. + radioResourceConfigCommon->rach_ConfigCommon. + maxHARQ_Msg3Tx); - else { - first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; - ra[RA_id].msg3_round++; - // prepare handling of retransmission + if (ra[RA_id].msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); + } else { + first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; + ra[RA_id].msg3_round++; + // prepare handling of retransmission get_Msg3allocret(&mac->common_channels[CC_idP], - ra[RA_id].Msg3_subframe, ra[RA_id].Msg3_frame, - &ra[RA_id].Msg3_frame, &ra[RA_id].Msg3_subframe); - add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); + ra[RA_id].Msg3_subframe, ra[RA_id].Msg3_frame, + &ra[RA_id].Msg3_frame, &ra[RA_id].Msg3_subframe); + add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); } /* TODO: program NACK for PHICH? */ - return; } } else { LOG_W(MAC, - "Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", - current_rnti); + "Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", + current_rnti); return; } + payload_ptr = parse_ulsch_header(sduP, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, sdu_lenP); - if(payload_ptr == NULL){ - LOG_E(MAC,"[eNB %d][PUSCH %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n", - enb_mod_idP, harq_pid, CC_idP,current_rnti, UE_id); - return; + if(payload_ptr == NULL) { + LOG_E(MAC,"[eNB %d][PUSCH %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n", + enb_mod_idP, harq_pid, CC_idP,current_rnti, UE_id); + return; } T(T_ENB_MAC_UE_UL_PDU, T_INT(enb_mod_idP), T_INT(CC_idP), @@ -280,65 +276,65 @@ rx_sdu(const module_id_t enb_mod_idP, T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), T_INT(sdu_lenP), T_INT(num_ce), T_INT(num_sdu), T_BUFFER(sduP, sdu_lenP)); - mac->eNB_stats[CC_idP].ulsch_bytes_rx = sdu_lenP; mac->eNB_stats[CC_idP].total_ulsch_bytes_rx += sdu_lenP; mac->eNB_stats[CC_idP].total_ulsch_pdus_rx += 1; - UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0; // control element for (i = 0; i < num_ce; i++) { - T(T_ENB_MAC_UE_UL_CE, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(rx_ces[i])); - switch (rx_ces[i]) { // implement and process BSR + CRNTI + - case POWER_HEADROOM: - if (UE_id != -1) { - UE_list->UE_template[CC_idP][UE_id].phr_info = - (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET + (int8_t)(hundred_times_log10_NPRB[UE_list->UE_template[CC_idP][UE_id].nb_rb_ul[harq_pid]-1]/100); - if(UE_list->UE_template[CC_idP][UE_id].phr_info > 40) - UE_list->UE_template[CC_idP][UE_id].phr_info = 40; - - LOG_D(MAC, - "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n", - enb_mod_idP, CC_idP, rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].phr_info); - UE_list->UE_template[CC_idP][UE_id].phr_info_configured = - 1; - UE_list->UE_sched_ctrl[UE_id].phr_received = 1; - } - payload_ptr += sizeof(POWER_HEADROOM_CMD); - break; + switch (rx_ces[i]) { // implement and process BSR + CRNTI + + case POWER_HEADROOM: + if (UE_id != -1) { + UE_list->UE_template[CC_idP][UE_id].phr_info = + (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET + (int8_t)(hundred_times_log10_NPRB[UE_list->UE_template[CC_idP][UE_id].nb_rb_ul[harq_pid]-1]/100); - case CRNTI: - { - int old_rnti = - (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1]; - int old_UE_id = find_UE_id(enb_mod_idP, old_rnti); - LOG_D(MAC, - "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n", - enb_mod_idP, frameP, subframeP, CC_idP, rx_ces[i], i, - num_ce, old_rnti, old_UE_id); - /* receiving CRNTI means that the current rnti has to go away */ - //cancel_ra_proc(enb_mod_idP, CC_idP, frameP, - // current_rnti); - if (old_UE_id != -1) { - /* TODO: if the UE did random access (followed by a MAC uplink with - * CRNTI) because none of its scheduling request was granted, then - * according to 36.321 5.4.4 the UE's MAC will notify RRC to release - * PUCCH/SRS. According to 36.331 5.3.13 the UE will then apply - * default configuration for CQI reporting and scheduling requests, - * which basically means that the CQI requests won't work anymore and - * that the UE won't do any scheduling request anymore as long as the - * eNB doesn't reconfigure the UE. - * We have to take care of this. As the code is, nothing is done and - * the UE state in the eNB is wrong. - */ + if(UE_list->UE_template[CC_idP][UE_id].phr_info > 40) + UE_list->UE_template[CC_idP][UE_id].phr_info = 40; + + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n", + enb_mod_idP, CC_idP, rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].phr_info); + UE_list->UE_template[CC_idP][UE_id].phr_info_configured = + 1; + UE_list->UE_sched_ctrl[UE_id].phr_received = 1; + } + + payload_ptr += sizeof(POWER_HEADROOM_CMD); + break; + + case CRNTI: { + int old_rnti = + (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1]; + int old_UE_id = find_UE_id(enb_mod_idP, old_rnti); + LOG_D(MAC, + "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n", + enb_mod_idP, frameP, subframeP, CC_idP, rx_ces[i], i, + num_ce, old_rnti, old_UE_id); + + /* receiving CRNTI means that the current rnti has to go away */ + //cancel_ra_proc(enb_mod_idP, CC_idP, frameP, + // current_rnti); + if (old_UE_id != -1) { + /* TODO: if the UE did random access (followed by a MAC uplink with + * CRNTI) because none of its scheduling request was granted, then + * according to 36.321 5.4.4 the UE's MAC will notify RRC to release + * PUCCH/SRS. According to 36.331 5.3.13 the UE will then apply + * default configuration for CQI reporting and scheduling requests, + * which basically means that the CQI requests won't work anymore and + * that the UE won't do any scheduling request anymore as long as the + * eNB doesn't reconfigure the UE. + * We have to take care of this. As the code is, nothing is done and + * the UE state in the eNB is wrong. + */ for (ii = 0; ii < NB_RA_PROC_MAX; ii++) { ra = &mac->common_channels[CC_idP].ra[ii]; + if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { mac_rrc_data_ind(enb_mod_idP, CC_idP, @@ -353,7 +349,6 @@ rx_sdu(const module_id_t enb_mod_idP, LOG_I(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d : (rnti %x UE_id %d) RRCConnectionReconfiguration(Msg4)\n", enb_mod_idP, frameP, subframeP, CC_idP, old_rnti, old_UE_id); - UE_id = old_UE_id; current_rnti = old_rnti; ra->rnti = old_rnti; @@ -363,11 +358,13 @@ rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_inactivity_timer = 0; UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) { UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 0; mac_eNB_rrc_ul_in_sync(enb_mod_idP, CC_idP, frameP, subframeP, old_rnti); } + UE_list->UE_template[CC_idP][UE_id].ul_SR = 1; UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 1; break; @@ -376,368 +373,378 @@ rx_sdu(const module_id_t enb_mod_idP, } else { cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti); } - crnti_rx = 1; - payload_ptr += 2; - break; + + crnti_rx = 1; + payload_ptr += 2; + break; } - case TRUNCATED_BSR: - case SHORT_BSR: - { - uint8_t lcgid; - lcgid = (payload_ptr[0] >> 6); - - LOG_D(MAC, - "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", - enb_mod_idP, CC_idP, rx_ces[i], lcgid, - payload_ptr[0] & 0x3f); - - if (crnti_rx == 1) - LOG_D(MAC, - "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", - enb_mod_idP, CC_idP, rx_ces[i], lcgid, - payload_ptr[0] & 0x3f); - if (UE_id != -1) { - int bsr = payload_ptr[0] & 0x3f; + case TRUNCATED_BSR: + case SHORT_BSR: { + uint8_t lcgid; + lcgid = (payload_ptr[0] >> 6); + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", + enb_mod_idP, CC_idP, rx_ces[i], lcgid, + payload_ptr[0] & 0x3f); - lcgid_updated[lcgid] = 1; + if (crnti_rx == 1) + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", + enb_mod_idP, CC_idP, rx_ces[i], lcgid, + payload_ptr[0] & 0x3f); + if (UE_id != -1) { + int bsr = payload_ptr[0] & 0x3f; + lcgid_updated[lcgid] = 1; // update buffer info UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid] = BSR_TABLE[bsr]; - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; + RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP * 10) + subframeP] = (payload_ptr[0] & 0x3f); + + if (UE_id == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, + RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr + [UE_id][(frameP * 10) + subframeP]); - RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP * 10) + subframeP] = (payload_ptr[0] & 0x3f); - if (UE_id == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BSR, - RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr - [UE_id][(frameP * 10) + subframeP]); - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] = frameP; - } - if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP, UE_id)) < RRC_CONNECTED) - LOG_D(MAC, - "[eNB %d] CC_id %d MAC CE_LCID %d : estimated_ul_buffer = %d (lcg increment %d)\n", - enb_mod_idP, CC_idP, rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer, - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); - } else { - - } - payload_ptr += 1; //sizeof(SHORT_BSR); // fixme + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[lcgid] = frameP; + } + + if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP, UE_id)) < RRC_CONNECTED) + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d : estimated_ul_buffer = %d (lcg increment %d)\n", + enb_mod_idP, CC_idP, rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer, + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]); + } else { + } + + payload_ptr += 1; //sizeof(SHORT_BSR); // fixme } break; - case LONG_BSR: - if (UE_id != -1) { - int bsr0 = (payload_ptr[0] & 0xFC) >> 2; - int bsr1 = ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); - int bsr2 = ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); - int bsr3 = payload_ptr[2] & 0x3F; - - lcgid_updated[LCGID0] = 1; - lcgid_updated[LCGID1] = 1; - lcgid_updated[LCGID2] = 1; - lcgid_updated[LCGID3] = 1; - - // update buffer info - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] = BSR_TABLE[bsr0]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] = BSR_TABLE[bsr1]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] = BSR_TABLE[bsr2]; - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] = BSR_TABLE[bsr3]; - - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = + case LONG_BSR: + if (UE_id != -1) { + int bsr0 = (payload_ptr[0] & 0xFC) >> 2; + int bsr1 = ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); + int bsr2 = ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); + int bsr3 = payload_ptr[2] & 0x3F; + lcgid_updated[LCGID0] = 1; + lcgid_updated[LCGID1] = 1; + lcgid_updated[LCGID2] = 1; + lcgid_updated[LCGID3] = 1; + // update buffer info + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] = BSR_TABLE[bsr0]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] = BSR_TABLE[bsr1]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] = BSR_TABLE[bsr2]; + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] = BSR_TABLE[bsr3]; + UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]; - //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; - - LOG_D(MAC, - "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is LCGID0 = %u LCGID1 = " - "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, CC_idP, - rx_ces[i], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); - if (crnti_rx == 1) + //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is LCGID0 = %u LCGID1 = " - "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, - CC_idP, rx_ces[i], + "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, CC_idP, + rx_ces[i], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] = 0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] = frameP; - } - - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] = 0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] = frameP; - } - - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] = 0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] = frameP; - } - - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] = 0; - } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] == 0) { - UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] = frameP; - - } - } + if (crnti_rx == 1) + LOG_D(MAC, + "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is LCGID0 = %u LCGID1 = " + "%u LCGID2 = %u LCGID3 = %u\n", enb_mod_idP, + CC_idP, rx_ces[i], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]); + + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] = 0; + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID0] = frameP; + } - payload_ptr += 3; ////sizeof(LONG_BSR); - break; + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] = 0; + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID1] = frameP; + } - default: - LOG_E(MAC, - "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", - enb_mod_idP, CC_idP, rx_ces[i]); - break; + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] = 0; + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID2] = frameP; + } + + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] = 0; + } else if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] == 0) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_creation_time[LCGID3] = frameP; + } + } + + payload_ptr += 3; ////sizeof(LONG_BSR); + break; + + default: + LOG_E(MAC, + "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n", + enb_mod_idP, CC_idP, rx_ces[i]); + break; } } for (i = 0; i < num_sdu; i++) { LOG_D(MAC, "SDU Number %d MAC Subheader SDU_LCID %d, length %d\n", - i, rx_lcids[i], rx_lengths[i]); - + i, rx_lcids[i], rx_lengths[i]); T(T_ENB_MAC_UE_UL_SDU, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(rx_lcids[i]), T_INT(rx_lengths[i])); T(T_ENB_MAC_UE_UL_SDU_WITH_DATA, T_INT(enb_mod_idP), T_INT(CC_idP), T_INT(current_rnti), T_INT(frameP), T_INT(subframeP), T_INT(rx_lcids[i]), T_INT(rx_lengths[i]), T_BUFFER(payload_ptr, - rx_lengths - [i])); + rx_lengths + [i])); switch (rx_lcids[i]) { - case CCCH: - if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) { - LOG_E(MAC, - "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n", - enb_mod_idP, CC_idP, frameP, rx_lengths[i], - CCCH_PAYLOAD_SIZE_MAX, sdu_lenP); - break; - } - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", - enb_mod_idP, CC_idP, frameP, payload_ptr[0], - payload_ptr[1], payload_ptr[2], payload_ptr[3], - payload_ptr[4], payload_ptr[5], current_rnti); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 1); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 0); - for (ii = 0; ii < NB_RA_PROC_MAX; ii++) { - RA_t *ra = &mac->common_channels[CC_idP].ra[ii]; - - LOG_D(MAC, - "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n", - enb_mod_idP, CC_idP, ii, ra->rnti, - current_rnti, ra->state); - - if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { - - //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); - - if (UE_id < 0) { - memcpy(&ra->cont_res_id[0], payload_ptr, 6); - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", - enb_mod_idP, CC_idP, frameP, rx_lengths[i], - payload_ptr - sduP); - - if ((UE_id = add_new_ue(enb_mod_idP, CC_idP, - mac->common_channels[CC_idP]. - ra[ii].rnti, harq_pid + case CCCH: + if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) { + LOG_E(MAC, + "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], + CCCH_PAYLOAD_SIZE_MAX, sdu_lenP); + break; + } + + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", + enb_mod_idP, CC_idP, frameP, payload_ptr[0], + payload_ptr[1], payload_ptr[2], payload_ptr[3], + payload_ptr[4], payload_ptr[5], current_rnti); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 1); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 0); + + for (ii = 0; ii < NB_RA_PROC_MAX; ii++) { + RA_t *ra = &mac->common_channels[CC_idP].ra[ii]; + LOG_D(MAC, + "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n", + enb_mod_idP, CC_idP, ii, ra->rnti, + current_rnti, ra->state); + + if ((ra->rnti == current_rnti) && (ra->state != IDLE)) { + //payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); + if (UE_id < 0) { + memcpy(&ra->cont_res_id[0], payload_ptr, 6); + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], + payload_ptr - sduP); + + if ((UE_id = add_new_ue(enb_mod_idP, CC_idP, + mac->common_channels[CC_idP]. + ra[ii].rnti, harq_pid #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , - mac->common_channels[CC_idP]. - ra[ii].rach_resource_type + , + mac->common_channels[CC_idP]. + ra[ii].rach_resource_type #endif - )) == -1) { - LOG_E(MAC,"[MAC][eNB] Max user count reached\n"); - cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti); - break; - // kill RA procedure - } else - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", - enb_mod_idP, CC_idP, frameP, ra->rnti, - UE_id); - } else { - LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n", - enb_mod_idP, CC_idP, frameP, UE_id, - rx_lengths[i], payload_ptr - sduP); - // kill RA procedure - } - - mac_rrc_data_ind(enb_mod_idP, - CC_idP, - frameP, subframeP, - current_rnti, - CCCH, - (uint8_t *) payload_ptr, - rx_lengths[i], - 0); - - - if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest - // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); - } - // prepare transmission of Msg4 - ra->state = MSG4; - - - - if(mac->common_channels[CC_idP].tdd_Config!=NULL){ - switch(mac->common_channels[CC_idP].tdd_Config->subframeAssignment){ - case 1: - ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0); - ra->Msg4_subframe = (subframeP + 7) % 10; - break; - default: printf("%s:%d: TODO\n", __FILE__, __LINE__); abort(); - // TODO need to be complete for other tdd configs. + )) == -1) { + LOG_E(MAC,"[MAC][eNB] Max user count reached\n"); + cancel_ra_proc(enb_mod_idP, CC_idP, frameP,current_rnti); + break; + // kill RA procedure + } else + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d Added user with rnti %x => UE %d\n", + enb_mod_idP, CC_idP, frameP, ra->rnti, + UE_id); + } else { + LOG_D(MAC, + "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3 from already registered UE %d: length %d, offset %ld\n", + enb_mod_idP, CC_idP, frameP, UE_id, + rx_lengths[i], payload_ptr - sduP); + // kill RA procedure } - }else{ - // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different - ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); - ra->Msg4_subframe = (subframeP + 4) % 10; - } - UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; - } // if process is active - } // loop on RA processes + mac_rrc_data_ind(enb_mod_idP, + CC_idP, + frameP, subframeP, + current_rnti, + CCCH, + (uint8_t *) payload_ptr, + rx_lengths[i], + 0); + + if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest + // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); + } - break; + // prepare transmission of Msg4 + ra->state = MSG4; + + if(mac->common_channels[CC_idP].tdd_Config!=NULL) { + switch(mac->common_channels[CC_idP].tdd_Config->subframeAssignment) { + case 1: + ra->Msg4_frame = frameP + ((subframeP > 2) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 7) % 10; + break; - case DCCH: - case DCCH1: - // if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){ + default: + printf("%s:%d: TODO\n", __FILE__, __LINE__); + abort(); + // TODO need to be complete for other tdd configs. + } + } else { + // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different + ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); + ra->Msg4_subframe = (subframeP + 4) % 10; + } + UE_list->UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; + } // if process is active + } // loop on RA processes -#if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC, "offset: %d\n", - (unsigned char) ((unsigned char *) payload_ptr - sduP)); - for (j = 0; j < 32; j++) { - LOG_T(MAC, "%x ", payload_ptr[j]); - } - LOG_T(MAC, "\n"); -#endif + break; - if (UE_id != -1) { - if (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { - // adjust buffer occupancy of the correponding logical channel group - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; - else - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; + case DCCH: + case DCCH1: + // if(eNB_mac_inst[module_idP][CC_idP].Dcch_lchan[UE_id].Active==1){ +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + LOG_T(MAC, "offset: %d\n", + (unsigned char) ((unsigned char *) payload_ptr - sduP)); - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; - //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; + for (j = 0; j < 32; j++) { + LOG_T(MAC, "%x ", payload_ptr[j]); } - LOG_D(MAC, - "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n", - enb_mod_idP, CC_idP, frameP, rx_lengths[i], UE_id, - rx_lcids[i]); + LOG_T(MAC, "\n"); +#endif - mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); //(unsigned int*)crc_status); - UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]] += 1; - UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]] += rx_lengths[i]; + if (UE_id != -1) { + if (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { + // adjust buffer occupancy of the correponding logical channel group + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; + else + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; + UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; + //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; + } - } + LOG_D(MAC, + "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d \n", + enb_mod_idP, CC_idP, frameP, rx_lengths[i], UE_id, + rx_lcids[i]); + mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); //(unsigned int*)crc_status); + UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]] += 1; + UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]] += rx_lengths[i]; + } - /* UE_id != -1 */ - // } - break; + /* UE_id != -1 */ + // } + break; // all the DRBS - case DTCH: - default: - + case DTCH: + default: #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC, "offset: %d\n", - (unsigned char) ((unsigned char *) payload_ptr - sduP)); - for (j = 0; j < 32; j++) { - LOG_T(MAC, "%x ", payload_ptr[j]); - } - LOG_T(MAC, "\n"); + LOG_T(MAC, "offset: %d\n", + (unsigned char) ((unsigned char *) payload_ptr - sduP)); + + for (j = 0; j < 32; j++) { + LOG_T(MAC, "%x ", payload_ptr[j]); + } + + LOG_T(MAC, "\n"); #endif - if (rx_lcids[i] < NB_RB_MAX) { - LOG_D(MAC, - "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n", - enb_mod_idP, CC_idP, frameP, rx_lengths[i], UE_id, - rx_lcids[i]); - - if (UE_id != -1) { - // adjust buffer occupancy of the correponding logical channel group - LOG_D(MAC, - "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n", - enb_mod_idP, CC_idP, frameP, rx_lengths[i], - UE_id, rx_lcids[i], - UE_list->UE_template[CC_idP][UE_id]. - lcgidmap[rx_lcids[i]], - UE_list->UE_template[CC_idP][UE_id]. - ul_buffer_info[UE_list->UE_template[CC_idP] - [UE_id].lcgidmap[rx_lcids[i]]]); - if (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { - if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; - else - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; + if (rx_lcids[i] < NB_RB_MAX) { + LOG_D(MAC, "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n", + enb_mod_idP, + CC_idP, + frameP, + rx_lengths[i], + UE_id, + rx_lcids[i]); + + if (UE_id != -1) { + // adjust buffer occupancy of the correponding logical channel group + LOG_D(MAC, "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d, removing from LCGID %ld, %d\n", + enb_mod_idP, + CC_idP, + frameP, + rx_lengths[i], + UE_id, + rx_lcids[i], + UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]], + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]]); + + if (lcgid_updated[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] == 0) { + if (UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] >= rx_lengths[i]) { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] -= rx_lengths[i]; + } else { + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[UE_list->UE_template[CC_idP][UE_id].lcgidmap[rx_lcids[i]]] = 0; + } - UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + - UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; - //UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer += UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer / 4; - } + UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer = + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[0] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[1] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[2] + + UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[3]; + } - if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block - mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); //(unsigned int*)crc_status); - - UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]] += 1; - UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]] += rx_lengths[i]; - //clear uplane_inactivity_timer - UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; - } else { /* rx_length[i] */ - UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx += 1; - LOG_E(MAC, - "[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ", - enb_mod_idP, CC_idP, frameP, rx_lcids[i], - UE_id); - } - } else { /*(UE_id != -1 */ - LOG_E(MAC, - "[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ", - enb_mod_idP, CC_idP, frameP, rx_lcids[i], UE_id); - } - } + if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block + mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL); + UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]] += 1; + UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]] += rx_lengths[i]; + //clear uplane_inactivity_timer + UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; + // reset RRC inactivity timer after uplane activity + ue_contextP = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], current_rnti); + if (ue_contextP != NULL) { + ue_contextP->ue_context.ue_rrc_inactivity_timer = 1; + } else { + LOG_E(MAC, "[eNB %d] CC_id %d Couldn't find the context associated to UE (RNTI %d) and reset RRC inactivity timer\n", + enb_mod_idP, + CC_idP, + current_rnti); + } + } else { /* rx_length[i] */ + UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx += 1; + LOG_E(MAC, "[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ", + enb_mod_idP, + CC_idP, + frameP, + rx_lcids[i], + UE_id); + } + } else { // end if (UE_id != -1) + LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ", + enb_mod_idP, + CC_idP, + frameP, + rx_lcids[i], + UE_id); + } + } - break; + break; } payload_ptr += rx_lengths[i]; @@ -745,12 +752,11 @@ rx_sdu(const module_id_t enb_mod_idP, // Program ACK for PHICH LOG_D(MAC, - "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n", - current_rnti, harq_pid, first_rb); + "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n", + current_rnti, harq_pid, first_rb); nfapi_hi_dci0_request_t *hi_dci0_req; - uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP] , subframeP); + uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP); hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10]; - nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; @@ -771,6 +777,7 @@ rx_sdu(const module_id_t enb_mod_idP, if ((num_sdu == 0) && (num_ce == 0)) { if (UE_id != -1) UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx += 1; + /* if (msg3_flagP != NULL) { if( *msg3_flagP == 1 ) { @@ -790,8 +797,7 @@ rx_sdu(const module_id_t enb_mod_idP, stop_meas(&mac->rx_ulsch_sdu); } -uint32_t bytes_to_bsr_index(int32_t nbytes) -{ +uint32_t bytes_to_bsr_index(int32_t nbytes) { uint32_t i = 0; if (nbytes < 0) { @@ -807,30 +813,26 @@ uint32_t bytes_to_bsr_index(int32_t nbytes) void add_ue_ulsch_info(module_id_t module_idP, int CC_id, int UE_id, - sub_frame_t subframeP, UE_ULSCH_STATUS status) -{ + sub_frame_t subframeP, UE_ULSCH_STATUS status) { eNB_ulsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP, UE_id); eNB_ulsch_info[module_idP][CC_id][UE_id].subframe = subframeP; eNB_ulsch_info[module_idP][CC_id][UE_id].status = status; - eNB_ulsch_info[module_idP][CC_id][UE_id].serving_num++; } unsigned char *parse_ulsch_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) -{ + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { unsigned char not_done = 1, num_ces = 0, num_sdus = - 0, lcid, num_sdu_cnt; + 0, lcid, num_sdu_cnt; unsigned char *mac_header_ptr = mac_header; unsigned short length, ce_len = 0; while (not_done == 1) { - if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) { not_done = 0; } @@ -838,62 +840,61 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID; if (lcid < EXTENDED_POWER_HEADROOM) { - if (not_done == 0) { // last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length - (mac_header_ptr - mac_header) - ce_len; - - for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus; - num_sdu_cnt++) { - length -= rx_lengths[num_sdu_cnt]; - } + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = tb_length - (mac_header_ptr - mac_header) - ce_len; + + for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus; + num_sdu_cnt++) { + length -= rx_lengths[num_sdu_cnt]; + } } else { - if (((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F == 0) { - length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; - mac_header_ptr += 2; //sizeof(SCH_SUBHEADER_SHORT); - } else { // F = 1 - length = - ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB & - 0x7f) << 8) | (((SCH_SUBHEADER_LONG *) - mac_header_ptr)->L_LSB & 0xff); - mac_header_ptr += 3; //sizeof(SCH_SUBHEADER_LONG); - } + if (((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F == 0) { + length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L; + mac_header_ptr += 2; //sizeof(SCH_SUBHEADER_SHORT); + } else { // F = 1 + length = + ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB & + 0x7f) << 8) | (((SCH_SUBHEADER_LONG *) + mac_header_ptr)->L_LSB & 0xff); + mac_header_ptr += 3; //sizeof(SCH_SUBHEADER_LONG); + } } LOG_D(MAC, - "[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n", - num_sdus, lcid, tb_length, length, - mac_header_ptr - mac_header); + "[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n", + num_sdus, lcid, tb_length, length, + mac_header_ptr - mac_header); rx_lcids[num_sdus] = lcid; rx_lengths[num_sdus] = length; num_sdus++; - } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI + } else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI if (lcid == SHORT_PADDING) { - mac_header_ptr++; + mac_header_ptr++; } else { - rx_ces[num_ces] = lcid; - num_ces++; - mac_header_ptr++; - - if (lcid == LONG_BSR) { - ce_len += 3; - } else if (lcid == CRNTI) { - ce_len += 2; - } else if ((lcid == POWER_HEADROOM) - || (lcid == TRUNCATED_BSR) - || (lcid == SHORT_BSR)) { - ce_len++; - } else { - LOG_E(MAC, "unknown CE %d \n", lcid); - //AssertFatal(1 == 0, "unknown CE"); + rx_ces[num_ces] = lcid; + num_ces++; + mac_header_ptr++; + + if (lcid == LONG_BSR) { + ce_len += 3; + } else if (lcid == CRNTI) { + ce_len += 2; + } else if ((lcid == POWER_HEADROOM) + || (lcid == TRUNCATED_BSR) + || (lcid == SHORT_BSR)) { + ce_len++; + } else { + LOG_E(MAC, "unknown CE %d \n", lcid); + //AssertFatal(1 == 0, "unknown CE"); return NULL; - } + } } } } *num_ce = num_ces; *num_sdu = num_sdus; - return (mac_header_ptr); } @@ -904,18 +905,18 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, */ void set_msg3_subframe(module_id_t mod_id, - int CC_id, - int frame, - int subframe, int rnti, int Msg3_frame, - int Msg3_subframe) -{ + int CC_id, + int frame, + int subframe, int rnti, int Msg3_frame, + int Msg3_subframe) { eNB_MAC_INST *mac = RC.mac[mod_id]; int i; + for (i = 0; i < NB_RA_PROC_MAX; i++) { if (mac->common_channels[CC_id].ra[i].state != IDLE && - mac->common_channels[CC_id].ra[i].rnti == rnti) { + mac->common_channels[CC_id].ra[i].rnti == rnti) { mac->common_channels[CC_id].ra[i].Msg3_subframe = - Msg3_subframe; + Msg3_subframe; break; } } @@ -923,90 +924,105 @@ set_msg3_subframe(module_id_t mod_id, void schedule_ulsch(module_id_t module_idP, frame_t frameP, - sub_frame_t subframeP) -{ + sub_frame_t subframeP) { uint16_t first_rb[NFAPI_CC_MAX], i; int CC_id; eNB_MAC_INST *mac = RC.mac[module_idP]; slice_info_t *sli = &RC.mac[module_idP]->slice_info; COMMON_channels_t *cc; - start_meas(&mac->schedule_ulsch); - int sched_frame=frameP; int sched_subframe = (subframeP + 4) % 10; - cc = &mac->common_channels[0]; int tdd_sfa; + // for TDD: check subframes where we have to act and return if nothing should be done now if (cc->tdd_Config) { tdd_sfa = cc->tdd_Config->subframeAssignment; + switch (subframeP) { - case 0: - if ((tdd_sfa == 0) || (tdd_sfa == 3)) - sched_subframe = 4; - else if (tdd_sfa == 6) - sched_subframe = 7; - else - return; - break; - case 1: - if ((tdd_sfa == 0) || (tdd_sfa == 1)) - sched_subframe = 7; - else if (tdd_sfa == 6) - sched_subframe = 8; - else + case 0: + if ((tdd_sfa == 0) || (tdd_sfa == 3)) + sched_subframe = 4; + else if (tdd_sfa == 6) + sched_subframe = 7; + else + return; + + break; + + case 1: + if ((tdd_sfa == 0) || (tdd_sfa == 1)) + sched_subframe = 7; + else if (tdd_sfa == 6) + sched_subframe = 8; + else + return; + + break; + + default: return; - break; - default: - return; - case 2: // Don't schedule UL in subframe 2 for TDD - return; - case 3: - if (tdd_sfa == 2) - sched_subframe = 7; - else - return; - break; - case 4: - if (tdd_sfa == 1) - sched_subframe = 8; - else - return; - break; - case 5: - if (tdd_sfa == 0) - sched_subframe = 9; - else if (tdd_sfa == 6) - sched_subframe = 2; - else - return; - break; - case 6: - if (tdd_sfa == 0 || tdd_sfa == 1) - sched_subframe = 2; - else if (tdd_sfa == 6) - sched_subframe = 3; - else - return; - break; - case 7: - return; - case 8: - if ((tdd_sfa >= 2) && (tdd_sfa <= 5)) - sched_subframe = 2; - else + case 2: // Don't schedule UL in subframe 2 for TDD return; - break; - case 9: - if ((tdd_sfa == 1) || (tdd_sfa == 3) || (tdd_sfa == 4)) - sched_subframe = 3; - else if (tdd_sfa == 6) - sched_subframe = 4; - else + + case 3: + if (tdd_sfa == 2) + sched_subframe = 7; + else + return; + + break; + + case 4: + if (tdd_sfa == 1) + sched_subframe = 8; + else + return; + + break; + + case 5: + if (tdd_sfa == 0) + sched_subframe = 9; + else if (tdd_sfa == 6) + sched_subframe = 2; + else + return; + + break; + + case 6: + if (tdd_sfa == 0 || tdd_sfa == 1) + sched_subframe = 2; + else if (tdd_sfa == 6) + sched_subframe = 3; + else + return; + + break; + + case 7: return; - break; + + case 8: + if ((tdd_sfa >= 2) && (tdd_sfa <= 5)) + sched_subframe = 2; + else + return; + + break; + + case 9: + if ((tdd_sfa == 1) || (tdd_sfa == 3) || (tdd_sfa == 4)) + sched_subframe = 3; + else if (tdd_sfa == 6) + sched_subframe = 4; + else + return; + + break; } } @@ -1031,11 +1047,12 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, for (i = 0; i < NB_RA_PROC_MAX; i++) { if ((cc->ra[i].state == WAITMSG3) && - (cc->ra[i].Msg3_subframe == sched_subframe)) { + (cc->ra[i].Msg3_subframe == sched_subframe)) { if (first_rb[CC_id] < cc->ra[i].msg3_first_rb + cc->ra[i].msg3_nb_rb) first_rb[CC_id] = cc->ra[i].msg3_first_rb + cc->ra[i].msg3_nb_rb; - // cc->ray[i].Msg3_subframe = -1; - break; + + // cc->ray[i].Msg3_subframe = -1; + break; } } } @@ -1050,11 +1067,10 @@ schedule_ulsch(module_id_t module_idP, frame_t frameP, void schedule_ulsch_rnti(module_id_t module_idP, - int slice_idx, - frame_t frameP, - sub_frame_t subframeP, - unsigned char sched_subframeP, uint16_t * first_rb) -{ + int slice_idx, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframeP, uint16_t *first_rb) { int UE_id; uint8_t aggregation = 2; rnti_t rnti = -1; @@ -1082,56 +1098,55 @@ schedule_ulsch_rnti(module_id_t module_idP, int first_rb_slice[NFAPI_CC_MAX]; if (sched_subframeP < subframeP) - sched_frame++; + sched_frame++; nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_id][subframeP]; nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - nfapi_ul_config_request_t *ul_req_tmp = &mac->UL_req_tmp[CC_id][sched_subframeP]; nfapi_ul_config_request_body_t *ul_req_tmp_body = &ul_req_tmp->ul_config_request_body; nfapi_ul_config_ulsch_harq_information *ulsch_harq_information; - for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth); - UE_list->first_rb_offset[CC_id][slice_idx] = cmin(N_RB_UL, sli->ul[slice_idx].first_rb); - } + UE_list->first_rb_offset[CC_id][slice_idx] = cmin(N_RB_UL, sli->ul[slice_idx].first_rb); + } //LOG_D(MAC, "entering ulsch preprocesor\n"); ulsch_scheduler_pre_processor(module_idP, slice_idx, frameP, subframeP, sched_subframeP, first_rb); - for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { + for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; ++CC_id) { first_rb_slice[CC_id] = first_rb[CC_id] + UE_list->first_rb_offset[CC_id][slice_idx]; } - //LOG_D(MAC, "exiting ulsch preprocesor\n"); + //LOG_D(MAC, "exiting ulsch preprocesor\n"); hi_dci0_req->sfn_sf = (frameP << 4) + subframeP; // loop over all active UEs for (UE_id = UE_list->head_ul; UE_id >= 0; UE_id = UE_list->next_ul[UE_id]) { - if (!ue_ul_slice_membership(module_idP, UE_id, slice_idx)) - continue; + continue; // don't schedule if Msg4 is not received yet if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id]. configured == FALSE) { - LOG_D(MAC, - "[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n", - module_idP, frameP, subframeP, UE_id); - continue; + LOG_D(MAC, + "[eNB %d] frame %d subfarme %d, UE %d: not configured, skipping UE scheduling \n", + module_idP, frameP, subframeP, UE_id); + continue; } rnti = UE_RNTI(module_idP, UE_id); if (rnti == NOT_A_RNTI) { LOG_W(MAC, "[eNB %d] frame %d subfarme %d, UE %d: no RNTI \n", - module_idP, frameP, subframeP, UE_id); + module_idP, frameP, subframeP, UE_id); continue; } drop_ue = 0; + /* let's drop the UE if get_eNB_UE_stats returns NULL when calling it with any of the UE's active UL CCs */ /* TODO: refine? @@ -1147,6 +1162,7 @@ schedule_ulsch_rnti(module_id_t module_idP, if (drop_ue == 1) { /* we can't come here, ulsch_scheduler_pre_processor won't put in the list a UE with no PHY context */ abort(); + /* TODO: this is a hack. Sometimes the UE has no PHY context but * is still present in the MAC with 'ul_failure_timer' = 0 and * 'ul_out_of_sync' = 0. It seems wrong and the UE stays there forever. Let's @@ -1155,18 +1171,20 @@ schedule_ulsch_rnti(module_id_t module_idP, * In the meantime, this hack... */ if (UE_list->UE_sched_ctrl[UE_id].ul_failure_timer == 0 && - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0) { - LOG_W(MAC, - "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: UE in weird state, let's put it 'out of sync'\n", - module_idP, frameP, subframeP, UE_id, rnti, CC_id); - // inform RRC of failure and clear timer - mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, - subframeP, rnti); - UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; - UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync == 0) { + LOG_W(MAC, + "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: UE in weird state, let's put it 'out of sync'\n", + module_idP, frameP, subframeP, UE_id, rnti, CC_id); + // inform RRC of failure and clear timer + mac_eNB_rrc_ul_failure(module_idP, CC_id, frameP, + subframeP, rnti); + UE_list->UE_sched_ctrl[UE_id].ul_failure_timer = 0; + UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync = 1; } + continue; } + // loop over all active UL CC_ids for this UE for (n = 0; n < UE_list->numactiveULCCs[UE_id]; n++) { // This is the actual CC_id in the list @@ -1174,416 +1192,421 @@ schedule_ulsch_rnti(module_id_t module_idP, N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth); /* - aggregation=get_aggregation(get_bw_index(module_idP,CC_id), - eNB_UE_stats->dl_cqi, - format0); + aggregation=get_aggregation(get_bw_index(module_idP,CC_id), + eNB_UE_stats->dl_cqi, + format0); */ if (CCE_allocation_infeasible - (module_idP, CC_id, 1, subframeP, aggregation, rnti)) { - LOG_W(MAC, - "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", - module_idP, frameP, subframeP, UE_id, rnti, CC_id); - continue; // break; + (module_idP, CC_id, 1, subframeP, aggregation, rnti)) { + LOG_W(MAC, + "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: not enough nCCE\n", + module_idP, frameP, subframeP, UE_id, rnti, CC_id); + continue; // break; } /* be sure that there are some free RBs */ if (first_rb_slice[CC_id] >= N_RB_UL - 1) { - LOG_W(MAC, - "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", - module_idP, frameP, subframeP, UE_id, rnti, CC_id); - continue; + LOG_W(MAC, + "[eNB %d] frame %d subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n", + module_idP, frameP, subframeP, UE_id, rnti, CC_id); + continue; } - // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel + // if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel UE_template = &UE_list->UE_template[CC_id][UE_id]; UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; harq_pid = subframe2harqpid(&cc[CC_id], sched_frame, sched_subframeP); round = UE_sched_ctrl->round_UL[CC_id][harq_pid]; AssertFatal(round < 8, "round %d > 7 for UE %d/%x\n", round, - UE_id, rnti); + UE_id, rnti); LOG_D(MAC, - "[eNB %d] frame %d subframe %d (sched_frame %d, sched_subframe %d), Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", - module_idP, frameP, subframeP, sched_frame, sched_subframeP, harq_pid, UE_id, rnti, - CC_id, aggregation, N_RB_UL); - + "[eNB %d] frame %d subframe %d (sched_frame %d, sched_subframe %d), Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n", + module_idP, frameP, subframeP, sched_frame, sched_subframeP, harq_pid, UE_id, rnti, + CC_id, aggregation, N_RB_UL); RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP * 10) + subframeP] = UE_template->estimated_ul_buffer; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO,RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP * - 10) + - subframeP]); - if (UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0 || round > 0) // || ((frameP%10)==0)) - // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames - { - LOG_D(MAC, - "[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", - module_idP, harq_pid, frameP, subframeP, UE_id, rnti, - round, UE_template->ul_SR, - UE_sched_ctrl->ul_inactivity_timer, - UE_sched_ctrl->ul_failure_timer, - UE_sched_ctrl->cqi_req_timer); - // reset the scheduling request - UE_template->ul_SR = 0; - status = mac_eNB_get_rrc_status(module_idP, rnti); - cqi_req = 0; - - if (status >= RRC_CONNECTED && UE_sched_ctrl->cqi_req_timer > 30) { - if (UE_sched_ctrl->cqi_received == 0) { - if (nfapi_mode) { - cqi_req = 0; - } else { - cqi_req = 1; - // To be safe , do not ask CQI in special Subframes:36.213/7.2.3 CQI definition - if (cc[CC_id].tdd_Config) { - switch (cc[CC_id].tdd_Config->subframeAssignment) { - case 1: - if( subframeP == 1 || subframeP == 6 ) cqi_req=0; - break; - case 3: - if( subframeP == 1 ) cqi_req=0; - break; - default: - LOG_E(MAC," TDD config not supported\n"); - break; - } - } - if(cqi_req == 1) UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; - } - } - else if (UE_sched_ctrl->cqi_received == 1) { - UE_sched_ctrl->cqi_req_flag = 0; - UE_sched_ctrl->cqi_received = 0; - UE_sched_ctrl->cqi_req_timer = 0; - } - } - - //power control - //compute the expected ULSCH RX power (for the stats) - - // this is the normalized RX power and this should be constant (regardless of mcs - //is not in dBm, unit from nfapi, converting to dBm: ToDo: Noise power hard coded to 30 - normalized_rx_power = (5*UE_sched_ctrl->pusch_snr[CC_id]-640)/10+30; - target_rx_power= mac->puSch10xSnr/10 + 30; - //printf("\n mac->puSch10xSnr = %d, normalized_rx_power = %d, target_rx_power = %d \n",mac->puSch10xSnr,normalized_rx_power,target_rx_power); - // this assumes accumulated tpc - // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out - int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame * 10 + UE_template->pusch_tpc_tx_subframe; - if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case - ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) //frame wrap-around - { - UE_template->pusch_tpc_tx_frame = frameP; - UE_template->pusch_tpc_tx_subframe = subframeP; - if (normalized_rx_power > (target_rx_power + 4)) { - tpc = 0; //-1 - tpc_accumulated--; - } else if (normalized_rx_power < (target_rx_power - 4)) { - tpc = 2; //+1 - tpc_accumulated++; - } else { - tpc = 1; //0 - } - } else { - tpc = 1; //0 - } - //tpc = 1; - if (tpc != 1) { - LOG_D(MAC, - "[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", - module_idP, frameP, subframeP, harq_pid, tpc, - tpc_accumulated, normalized_rx_power, - target_rx_power); - } - // new transmission - if (round == 0) { - - ndi = 1 - UE_template->oldNDI_UL[harq_pid]; - UE_template->oldNDI_UL[harq_pid] = ndi; - UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power = normalized_rx_power; - UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power = target_rx_power; - UE_template->mcs_UL[harq_pid] = cmin(UE_template->pre_assigned_mcs_ul, sli->ul[slice_idx].maxmcs); - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1= UE_template->mcs_UL[harq_pid]; - //cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS - if (UE_template->pre_allocated_rb_table_index_ul >= 0) { - rb_table_index = UE_template->pre_allocated_rb_table_index_ul; - } else { - UE_template->mcs_UL[harq_pid] = 10; //cmin (10, openair_daq_vars.target_ue_ul_mcs); - rb_table_index = 5; // for PHR - } - - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = UE_template->mcs_UL[harq_pid]; - // buffer_occupancy = UE_template->ul_total_buffer; - - - while (((rb_table[rb_table_index] > (N_RB_UL - first_rb_slice[CC_id])) - || (rb_table[rb_table_index] > 45)) - && (rb_table_index > 0)) { - rb_table_index--; - } - - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid], - rb_table[rb_table_index]); - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += rb_table[rb_table_index]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = UE_template->TBS_UL[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_TBS += UE_template->TBS_UL[harq_pid]; - // buffer_occupancy -= TBS; - - T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), - T_INT(CC_id), T_INT(rnti), T_INT(frameP), - T_INT(subframeP), T_INT(harq_pid), - T_INT(UE_template->mcs_UL[harq_pid]), - T_INT(first_rb_slice[CC_id]), - T_INT(rb_table[rb_table_index]), - T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); - - if (mac_eNB_get_rrc_status(module_idP, rnti) < RRC_CONNECTED) - LOG_D(MAC, - "[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", - module_idP, harq_pid, rnti, CC_id, frameP, - subframeP, UE_id, - UE_template->mcs_UL[harq_pid], - first_rb_slice[CC_id], rb_table[rb_table_index], - rb_table_index, - UE_template->TBS_UL[harq_pid], harq_pid); - - // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) - //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; - UE_template->first_rb_ul[harq_pid] = first_rb_slice[CC_id]; - - UE_sched_ctrl->ul_scheduled |= (1 << harq_pid); - if (UE_id == UE_list->head) - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED, - UE_sched_ctrl->ul_scheduled); - - // adjust scheduled UL bytes by TBS, wait for UL sdus to do final update - LOG_D(MAC, - "[eNB %d] CC_id %d UE %d/%x : adjusting scheduled_ul_bytes, old %d, TBS %d\n", - module_idP, CC_id, UE_id, rnti, - UE_template->scheduled_ul_bytes, - UE_template->TBS_UL[harq_pid]); - - UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid]; - - LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes); - - // Cyclic shift for DM RS - cshift = 0; // values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) - // save it for a potential retransmission - UE_template->cshift[harq_pid] = cshift; - - hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; - memset((void *) hi_dci0_pdu, 0,sizeof(nfapi_hi_dci0_request_pdu_t)); - hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; - hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_dci_pdu); - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb_slice[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; - - hi_dci0_req_body->number_of_dci++; - hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4); - hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; - - hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! - hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; - - - LOG_D(MAC, - "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid, frameP, subframeP, UE_id, rnti, - sched_frame, sched_subframeP); - - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp_body->number_of_pdus;ul_req_index++){ - if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); - break; - } - } + 10) + + subframeP]); - // Add UL_config PDUs - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, first_rb_slice[CC_id], // resource_block_start - rb_table[rb_table_index], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - ndi, // new_data_indication - 0, // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - get_TBS_UL - (UE_template-> - mcs_UL[harq_pid], - rb_table - [rb_table_index])); -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions - 1, //repetition_number - (frameP * - 10) + - subframeP); - } -#endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; - - }else{ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; + if (UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0 || round > 0) // || ((frameP%10)==0)) + // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames + { + LOG_D(MAC, + "[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n", + module_idP, harq_pid, frameP, subframeP, UE_id, rnti, + round, UE_template->ul_SR, + UE_sched_ctrl->ul_inactivity_timer, + UE_sched_ctrl->ul_failure_timer, + UE_sched_ctrl->cqi_req_timer); + // reset the scheduling request + UE_template->ul_SR = 0; + status = mac_eNB_get_rrc_status(module_idP, rnti); + cqi_req = 0; + + if (status >= RRC_CONNECTED && UE_sched_ctrl->cqi_req_timer > 30) { + if (UE_sched_ctrl->cqi_received == 0) { + if (nfapi_mode) { + cqi_req = 0; + } else { + cqi_req = 1; + + // To be safe , do not ask CQI in special Subframes:36.213/7.2.3 CQI definition + if (cc[CC_id].tdd_Config) { + switch (cc[CC_id].tdd_Config->subframeAssignment) { + case 1: + if( subframeP == 1 || subframeP == 6 ) cqi_req=0; + + break; + + case 3: + if( subframeP == 1 ) cqi_req=0; + + break; + + default: + LOG_E(MAC," TDD config not supported\n"); + break; + } } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp_body->number_of_pdus++; + + if(cqi_req == 1) UE_sched_ctrl->cqi_req_flag |= 1 << sched_subframeP; } + } else if (UE_sched_ctrl->cqi_received == 1) { + UE_sched_ctrl->cqi_req_flag = 0; + UE_sched_ctrl->cqi_received = 0; + UE_sched_ctrl->cqi_req_timer = 0; + } + } - ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; - ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; - mac->ul_handle++; - - uint16_t ul_sched_frame = sched_frame; - uint16_t ul_sched_subframeP = sched_subframeP; - - //add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); - ul_req_tmp->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; - - add_ue_ulsch_info(module_idP, - CC_id, UE_id, subframeP, - S_UL_SCHEDULED); - - LOG_D(MAC, "[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP, CC_id, frameP, subframeP, UE_id); - LOG_D(MAC,"[PUSCH %d] SFN/SF:%04d%d UL_CFG:SFN/SF:%04d%d CQI:%d for UE %d/%x\n", harq_pid,frameP,subframeP,ul_sched_frame,ul_sched_subframeP,cqi_req,UE_id,rnti); - - // increment first rb for next UE allocation - first_rb_slice[CC_id] += rb_table[rb_table_index]; - } else { // round > 0 => retransmission - T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, - T_INT(module_idP), T_INT(CC_id), T_INT(rnti), - T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), - T_INT(UE_template->mcs_UL[harq_pid]), - T_INT(first_rb_slice[CC_id]), - T_INT(rb_table[rb_table_index]), T_INT(round)); - - // Add UL_config PDUs - LOG_D(MAC, - "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", - harq_pid, frameP, subframeP, UE_id, rnti, - sched_frame, sched_subframeP); - ul_req_index = 0; - dlsch_flag = 0; - for(ul_req_index = 0;ul_req_index < ul_req_tmp_body->number_of_pdus;ul_req_index++){ - if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti){ - dlsch_flag = 1; - LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); - break; - } + //power control + //compute the expected ULSCH RX power (for the stats) + // this is the normalized RX power and this should be constant (regardless of mcs + //is not in dBm, unit from nfapi, converting to dBm: ToDo: Noise power hard coded to 30 + normalized_rx_power = (5*UE_sched_ctrl->pusch_snr[CC_id]-640)/10+30; + target_rx_power= mac->puSch10xSnr/10 + 30; + //printf("\n mac->puSch10xSnr = %d, normalized_rx_power = %d, target_rx_power = %d \n",mac->puSch10xSnr,normalized_rx_power,target_rx_power); + // this assumes accumulated tpc + // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out + int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame * 10 + UE_template->pusch_tpc_tx_subframe; + + if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || //normal case + ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) { //frame wrap-around + UE_template->pusch_tpc_tx_frame = frameP; + UE_template->pusch_tpc_tx_subframe = subframeP; + + if (normalized_rx_power > (target_rx_power + 4)) { + tpc = 0; //-1 + tpc_accumulated--; + } else if (normalized_rx_power < (target_rx_power - 4)) { + tpc = 2; //+1 + tpc_accumulated++; + } else { + tpc = 1; //0 + } + } else { + tpc = 1; //0 + } + + //tpc = 1; + if (tpc != 1) { + LOG_D(MAC, + "[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n", + module_idP, frameP, subframeP, harq_pid, tpc, + tpc_accumulated, normalized_rx_power, + target_rx_power); + } + + // new transmission + if (round == 0) { + ndi = 1 - UE_template->oldNDI_UL[harq_pid]; + UE_template->oldNDI_UL[harq_pid] = ndi; + UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power = normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power = target_rx_power; + UE_template->mcs_UL[harq_pid] = cmin(UE_template->pre_assigned_mcs_ul, sli->ul[slice_idx].maxmcs); + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1= UE_template->mcs_UL[harq_pid]; + + //cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + if (UE_template->pre_allocated_rb_table_index_ul >= 0) { + rb_table_index = UE_template->pre_allocated_rb_table_index_ul; + } else { + UE_template->mcs_UL[harq_pid] = 10; //cmin (10, openair_daq_vars.target_ue_ul_mcs); + rb_table_index = 5; // for PHR + } + + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = UE_template->mcs_UL[harq_pid]; + // buffer_occupancy = UE_template->ul_total_buffer; + + while (((rb_table[rb_table_index] > (N_RB_UL - first_rb_slice[CC_id])) + || (rb_table[rb_table_index] > 45)) + && (rb_table_index > 0)) { + rb_table_index--; + } + + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid], + rb_table[rb_table_index]); + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += rb_table[rb_table_index]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = UE_template->TBS_UL[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_TBS += UE_template->TBS_UL[harq_pid]; + // buffer_occupancy -= TBS; + T(T_ENB_MAC_UE_UL_SCHEDULE, T_INT(module_idP), + T_INT(CC_id), T_INT(rnti), T_INT(frameP), + T_INT(subframeP), T_INT(harq_pid), + T_INT(UE_template->mcs_UL[harq_pid]), + T_INT(first_rb_slice[CC_id]), + T_INT(rb_table[rb_table_index]), + T_INT(UE_template->TBS_UL[harq_pid]), T_INT(ndi)); + + if (mac_eNB_get_rrc_status(module_idP, rnti) < RRC_CONNECTED) + LOG_D(MAC, + "[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE %d (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", + module_idP, harq_pid, rnti, CC_id, frameP, + subframeP, UE_id, + UE_template->mcs_UL[harq_pid], + first_rb_slice[CC_id], rb_table[rb_table_index], + rb_table_index, + UE_template->TBS_UL[harq_pid], harq_pid); + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = rb_table[rb_table_index]; + UE_template->first_rb_ul[harq_pid] = first_rb_slice[CC_id]; + UE_sched_ctrl->ul_scheduled |= (1 << harq_pid); + + if (UE_id == UE_list->head) + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SCHEDULED, + UE_sched_ctrl->ul_scheduled); + + // adjust scheduled UL bytes by TBS, wait for UL sdus to do final update + LOG_D(MAC, + "[eNB %d] CC_id %d UE %d/%x : adjusting scheduled_ul_bytes, old %d, TBS %d\n", + module_idP, CC_id, UE_id, rnti, + UE_template->scheduled_ul_bytes, + UE_template->TBS_UL[harq_pid]); + UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid]; + LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes); + // Cyclic shift for DM RS + cshift = 0; // values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + // save it for a potential retransmission + UE_template->cshift[harq_pid] = cshift; + hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; + memset((void *) hi_dci0_pdu, 0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_DCI_PDU_REL8_TAG; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb_slice[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = rb_table[rb_table_index]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = UE_template->mcs_UL[harq_pid]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.harq_pid = harq_pid; + hi_dci0_req_body->number_of_dci++; + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(sched_frame, sched_subframeP, 0); //(frameP, subframeP, 4); + hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + hi_dci0_req->sfn_sf = frameP<<4|subframeP; // sfnsf_add_subframe(sched_frame, sched_subframeP, 0); // sunday! + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + LOG_D(MAC, + "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid, frameP, subframeP, UE_id, rnti, + sched_frame, sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) { + if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; } - fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, UE_template->first_rb_ul[harq_pid], // resource_block_start - UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks - UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms - 0, // frequency_hopping_enabled_flag - 0, // frequency_hopping_bits - UE_template->oldNDI_UL[harq_pid], // new_data_indication - rvidx_tab[round & 3], // redundancy_version - harq_pid, // harq_process_number - 0, // ul_tx_mode - 0, // current_tx_nb - 0, // n_srs - UE_template-> - TBS_UL[harq_pid]); + } + + // Add UL_config PDUs + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, + first_rb_slice[CC_id], // resource_block_start + rb_table[rb_table_index], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL + (UE_template-> + mcs_UL[harq_pid], + rb_table + [rb_table_index])); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation - fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions - 1, //repetition_number - (frameP * - 10) + - subframeP); - } + + if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + 1, //repetition_number + (frameP * + 10) + + subframeP); + } + #endif - if(dlsch_flag == 1){ - if(cqi_req == 1){ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag=NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = UE_template->nb_rb_ul[harq_pid]; - - }else{ - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; - ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured - ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = UE_template->nb_rb_ul[harq_pid]; - } - fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); - }else{ - ul_req_tmp_body->number_of_pdus++; + + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + rb_table[rb_table_index]; + } else { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index]; } - mac->ul_handle++; + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp_body->number_of_pdus++; + } - ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; + ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + mac->ul_handle++; + uint16_t ul_sched_frame = sched_frame; + uint16_t ul_sched_subframeP = sched_subframeP; + //add_subframe(&ul_sched_frame, &ul_sched_subframeP, 2); + ul_req_tmp->sfn_sf = ul_sched_frame<<4|ul_sched_subframeP; + add_ue_ulsch_info(module_idP, + CC_id, UE_id, subframeP, + S_UL_SCHEDULED); + LOG_D(MAC, "[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP, CC_id, frameP, subframeP, UE_id); + LOG_D(MAC,"[PUSCH %d] SFN/SF:%04d%d UL_CFG:SFN/SF:%04d%d CQI:%d for UE %d/%x\n", harq_pid,frameP,subframeP,ul_sched_frame,ul_sched_subframeP,cqi_req,UE_id,rnti); + // increment first rb for next UE allocation + first_rb_slice[CC_id] += rb_table[rb_table_index]; + } else { // round > 0 => retransmission + T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION, + T_INT(module_idP), T_INT(CC_id), T_INT(rnti), + T_INT(frameP), T_INT(subframeP), T_INT(harq_pid), + T_INT(UE_template->mcs_UL[harq_pid]), + T_INT(first_rb_slice[CC_id]), + T_INT(rb_table[rb_table_index]), T_INT(round)); + // Add UL_config PDUs + LOG_D(MAC, + "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", + harq_pid, frameP, subframeP, UE_id, rnti, + sched_frame, sched_subframeP); + ul_req_index = 0; + dlsch_flag = 0; + + for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) { + if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE && + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) { + dlsch_flag = 1; + LOG_D(MAC,"Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",frameP,subframeP,rnti,ul_req_index); + break; + } + } + + fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], cqi_req, cc, UE_template->physicalConfigDedicated, get_tmode(module_idP, CC_id, UE_id), mac->ul_handle, rnti, + UE_template->first_rb_ul[harq_pid], // resource_block_start + UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks + UE_template->mcs_UL[harq_pid], cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + UE_template->oldNDI_UL[harq_pid], // new_data_indication + rvidx_tab[round & 3], // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + UE_template-> + TBS_UL[harq_pid]); +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) + + if (UE_template->rach_resource_type > 0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index], UE_template->rach_resource_type > 2 ? 2 : 1, 1, //total_number_of_repetitions + 1, //repetition_number + (frameP * + 10) + + subframeP); + } - ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; - ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; +#endif - LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n", - harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,cqi_req); - } /* - else if (round > 0) { //we schedule a retransmission + if(dlsch_flag == 1) { + if(cqi_req == 1) { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag= + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + UE_template->nb_rb_ul[harq_pid]; + } else { + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE; + ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = + NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG; + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured + ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = + UE_template->nb_rb_ul[harq_pid]; + } - ndi = UE_template->oldNDI_UL[harq_pid]; + fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP); + } else { + ul_req_tmp_body->number_of_pdus++; + } - if ((round&3)==0) { - mcs = openair_daq_vars.target_ue_ul_mcs; - } else { - mcs = rvidx_tab[round&3] + 28; //not correct for round==4! + mac->ul_handle++; + ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG; + ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP; + ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST; + LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n", + harq_pid,frameP,subframeP,UE_id,rnti,sched_frame,sched_subframeP,cqi_req); + } /* - } + else if (round > 0) { //we schedule a retransmission - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, harq_pid %d, round %d)\n", - module_idP,UE_id,rnti,CC_id,frameP,subframeP,mcs, - first_rb[CC_id],UE_template->nb_rb_ul[harq_pid], - harq_pid, round); + ndi = UE_template->oldNDI_UL[harq_pid]; - rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, - first_rb[CC_id], - UE_template->nb_rb_ul[harq_pid]); - first_rb[CC_id]+=UE_template->nb_rb_ul[harq_pid]; // increment for next UE allocation + if ((round&3)==0) { + mcs = openair_daq_vars.target_ue_ul_mcs; + } else { + mcs = rvidx_tab[round&3] + 28; //not correct for round==4! - UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1; - UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid]; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; - } - */ + } - } // UE_is_to_be_scheduled - } // loop over UE_id - } // loop of CC_id + LOG_I(MAC,"[eNB %d][PUSCH %d/%x] CC_id %d Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, harq_pid %d, round %d)\n", + module_idP,UE_id,rnti,CC_id,frameP,subframeP,mcs, + first_rb[CC_id],UE_template->nb_rb_ul[harq_pid], + harq_pid, round); + + rballoc = mac_xface->computeRIV(frame_parms->N_RB_UL, + first_rb[CC_id], + UE_template->nb_rb_ul[harq_pid]); + first_rb[CC_id]+=UE_template->nb_rb_ul[harq_pid]; // increment for next UE allocation + + UE_list->eNB_UE_stats[CC_id][UE_id].num_retransmission_rx+=1; + UE_list->eNB_UE_stats[CC_id][UE_id].rbs_used_retx_rx=UE_template->nb_rb_ul[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=UE_template->nb_rb_ul[harq_pid]; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=mcs; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2=mcs; + } + */ + } // UE_is_to_be_scheduled + } // loop over UE_id + } // loop of CC_id } diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h index 0625a327eb302af8aba74f7120f31bad7da0aa18..7785abd16f85fcb9f9d0fb96e886b99272d4a33e 100644 --- a/openair2/LAYER2/MAC/mac.h +++ b/openair2/LAYER2/MAC/mac.h @@ -1,4 +1,4 @@ -/* + /* * 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. @@ -1070,8 +1070,7 @@ typedef struct { /*! \brief UE list used by eNB to order UEs/CC for scheduling*/ typedef struct { /// Dedicated information for UEs - struct PhysicalConfigDedicated - *physicalConfigDedicated[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; + LTE_PhysicalConfigDedicated_t *physicalConfigDedicated[NFAPI_CC_MAX][MAX_MOBILES_PER_ENB]; /// DLSCH pdu DLSCH_PDU DLSCH_pdu[NFAPI_CC_MAX][2][MAX_MOBILES_PER_ENB]; /// DCI template and MAC connection parameters for UEs diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c index 126d7c3aac4e9413a31de6fbd4b1ba9f46e21fa2..4265a841e91741bfc7c2fda4edee37dd97a9b9f7 100644 --- a/openair2/RRC/LTE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -38,7 +38,7 @@ #include "common/ran_context.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "flexran_agent_extern.h" @@ -54,7 +54,7 @@ mac_rrc_data_req( const frame_t frameP, const rb_id_t Srb_id, const uint8_t Nb_tb, - uint8_t* const buffer_pP, + uint8_t *const buffer_pP, const uint8_t mbsfn_sync_area ) //-------------------------------------------------------------------------- @@ -64,7 +64,6 @@ mac_rrc_data_req( uint8_t Sdu_size = 0; uint8_t sfn = (uint8_t)((frameP>>2)&0xff); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); } @@ -72,156 +71,151 @@ mac_rrc_data_req( eNB_RRC_INST *rrc; rrc_eNB_carrier_data_t *carrier; LTE_BCCH_BCH_Message_t *mib; + rrc = RC.rrc[Mod_idP]; + carrier = &rrc->carrier[0]; + mib = &carrier->mib; + if((Srb_id & RAB_OFFSET) == BCCH) { + if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) { + return 0; + } - rrc = RC.rrc[Mod_idP]; - carrier = &rrc->carrier[0]; - mib = &carrier->mib; + // All even frames transmit SIB in SF 5 + AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255, + "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP); - if((Srb_id & RAB_OFFSET) == BCCH) { - if(RC.rrc[Mod_idP]->carrier[CC_id].SI.Active==0) { - return 0; - } - - // All even frames transmit SIB in SF 5 - AssertFatal(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1 != 255, - "[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP); + if ((frameP%2) == 0) { + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB1, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); - if ((frameP%2) == 0) { - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB1, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); + if (LOG_DEBUGFLAG(DEBUG_RRC)) { + LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { - LOG_T(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP); + for (int i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1; i++) { + LOG_T(RRC,"%x.",buffer_pP[i]); + } - for (int i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1; i++) { - LOG_T(RRC,"%x.",buffer_pP[i]); - } + LOG_T(RRC,"\n"); + } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - LOG_T(RRC,"\n"); - } /* LOG_DEBUGFLAG(DEBUG_RRC) */ + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); + } // All RFN mod 8 transmit SIB2-3 in SF 5 + else if ((frameP%8) == 1) { + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB23, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1); - } // All RFN mod 8 transmit SIB2-3 in SF 5 - else if ((frameP%8) == 1) { - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB23, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); + if (LOG_DEBUGFLAG(DEBUG_RRC)) { + LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { - LOG_T(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP); + for (int i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23; i++) { + LOG_T(RRC,"%x.",buffer_pP[i]); + } - for (int i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23; i++) { - LOG_T(RRC,"%x.",buffer_pP[i]); - } + LOG_T(RRC,"\n"); + } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - LOG_T(RRC,"\n"); - } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); - } else { - return(0); - } + return(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23); + } else { + return(0); } - if( (Srb_id & RAB_OFFSET ) == MIBCH) { - - mib->message.systemFrameNumber.buf = &sfn; - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message, - NULL, - (void*)mib, - carrier->MIB, - 24); - LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded); - buffer_pP[0]=carrier->MIB[0]; - buffer_pP[1]=carrier->MIB[1]; - buffer_pP[2]=carrier->MIB[2]; - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return(3); - } - - if( (Srb_id & RAB_OFFSET ) == CCCH) { - LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); + } - if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) { - LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP); - return -1; - } + if( (Srb_id & RAB_OFFSET ) == MIBCH) { + mib->message.systemFrameNumber.buf = &sfn; + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message, + NULL, + (void *)mib, + carrier->MIB, + 24); + LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded); + buffer_pP[0]=carrier->MIB[0]; + buffer_pP[1]=carrier->MIB[1]; + buffer_pP[2]=carrier->MIB[2]; + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return(3); + } - Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0; + if( (Srb_id & RAB_OFFSET ) == CCCH) { + LOG_T(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); - // check if data is there for MAC - if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer - LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload); + if(RC.rrc[Mod_idP]->carrier[CC_id].Srb0.Active==0) { + LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP); + return -1; + } - memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size); - Sdu_size = Srb_info->Tx_buffer.payload_size; - Srb_info->Tx_buffer.payload_size=0; - } + Srb_info=&RC.rrc[Mod_idP]->carrier[CC_id].Srb0; - return (Sdu_size); + // check if data is there for MAC + if(Srb_info->Tx_buffer.payload_size>0) { //Fill buffer + LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload); + memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size); + Sdu_size = Srb_info->Tx_buffer.payload_size; + Srb_info->Tx_buffer.payload_size=0; } - if( (Srb_id & RAB_OFFSET ) == PCCH) { - LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); - - // check if data is there for MAC - if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer - LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + return (Sdu_size); + } - memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); - Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]; - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0; - } + if( (Srb_id & RAB_OFFSET ) == PCCH) { + LOG_T(RRC,"[eNB %d] Frame %d PCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); - return (Sdu_size); + // check if data is there for MAC + if(RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] > 0) { //Fill buffer + LOG_D(RRC,"[eNB %d] PCCH (%p) has %d bytes\n",Mod_idP,&RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + memcpy(buffer_pP, RC.rrc[Mod_idP]->carrier[CC_id].paging[mbsfn_sync_area], RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]); + Sdu_size = RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area]; + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_paging[mbsfn_sync_area] = 0; } + return (Sdu_size); + } + #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - if((Srb_id & RAB_OFFSET) == MCCH) { - if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) { - return 0; // this parameter is set in function init_mcch in rrc_eNB.c - } + if((Srb_id & RAB_OFFSET) == MCCH) { + if(RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESS[mbsfn_sync_area].Active==0) { + return 0; // this parameter is set in function init_mcch in rrc_eNB.c + } - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area], - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].MCCH_MESSAGE[mbsfn_sync_area], + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); - if (LOG_DEBUGFLAG(DEBUG_RRC)) { - LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP); + if (LOG_DEBUGFLAG(DEBUG_RRC)) { + LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_idP,frameP); - for (int i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) { - LOG_T(RRC,"%x.",buffer_pP[i]); - } + for (int i=0; i<RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; i++) { + LOG_T(RRC,"%x.",buffer_pP[i]); + } - LOG_T(RRC,"\n"); - } /* LOG_DEBUGFLAG(DEBUG_RRC) */ + LOG_T(RRC,"\n"); + } /* LOG_DEBUGFLAG(DEBUG_RRC) */ - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); - } + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); + } #endif // #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR){ - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); - } - - if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR){ // First SI message with SIB2/3 - memcpy(&buffer_pP[0], - RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR, - RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); - return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); - } -#endif + if ((Srb_id & RAB_OFFSET) == BCCH_SIB1_BR) { + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB1_BR, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB1_BR); + } + if ((Srb_id & RAB_OFFSET) == BCCH_SI_BR) { // First SI message with SIB2/3 + memcpy(&buffer_pP[0], + RC.rrc[Mod_idP]->carrier[CC_id].SIB23_BR, + RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); + return (RC.rrc[Mod_idP]->carrier[CC_id].sizeof_SIB23_BR); + } +#endif return(0); } @@ -234,7 +228,7 @@ mac_rrc_data_ind( const sub_frame_t sub_frameP, const rnti_t rntiP, const rb_id_t srb_idP, - const uint8_t* sduP, + const uint8_t *sduP, const sdu_size_t sdu_lenP, const uint8_t mbsfn_sync_areaP ) @@ -243,42 +237,44 @@ mac_rrc_data_ind( SRB_INFO *Srb_info; protocol_ctxt_t ctxt; sdu_size_t sdu_size = 0; - /* for no gcc warnings */ (void)sdu_size; - /* int si_window; */ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, rntiP, frameP, sub_frameP,0); - if((srb_idP & RAB_OFFSET) == CCCH) { + if((srb_idP & RAB_OFFSET) == CCCH) { Srb_info = &RC.rrc[module_idP]->carrier[CC_id].Srb0; LOG_D(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",module_idP,Srb_info->Srb_id); - + // msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id); if (sdu_lenP > 0) { memcpy(Srb_info->Rx_buffer.Payload,sduP,sdu_lenP); Srb_info->Rx_buffer.payload_size = sdu_lenP; rrc_eNB_decode_ccch(&ctxt, Srb_info, CC_id); } + } + + if((srb_idP & RAB_OFFSET) == DCCH) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.module_id],rntiP); + + if(ue_context_p) { + rrc_eNB_generate_defaultRRCConnectionReconfiguration(&ctxt, + ue_context_p, + 0); + ue_context_p->ue_context.Status = RRC_RECONFIGURED; } - if((srb_idP & RAB_OFFSET) == DCCH) { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.module_id],rntiP); - if(ue_context_p){ - rrc_eNB_generate_defaultRRCConnectionReconfiguration(&ctxt, - ue_context_p, - 0); - ue_context_p->ue_context.Status = RRC_RECONFIGURED; - } - } + } return(0); - } //------------------------------------------------------------------------------ +/* +* Get RRC status (Connected, Idle...) of UE from RNTI +*/ int mac_eNB_get_rrc_status( const module_id_t Mod_idP, @@ -286,10 +282,8 @@ mac_eNB_get_rrc_status( ) //------------------------------------------------------------------------------ { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[Mod_idP], - rntiP); + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[Mod_idP], rntiP); if (ue_context_p != NULL) { return(ue_context_p->ue_context.Status); @@ -299,60 +293,59 @@ mac_eNB_get_rrc_status( } void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) -{ - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context( RC.rrc[Mod_instP], rntiP); if (ue_context_p != NULL) { LOG_I(RRC,"Frame %d, Subframe %d: UE %x UL failure, activating timer\n",frameP,subframeP,rntiP); + if(ue_context_p->ue_context.ul_failure_timer == 0) ue_context_p->ue_context.ul_failure_timer=1; - } - else { + } else { LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); } + if (rrc_agent_registered[Mod_instP]) { agent_rrc_xface[Mod_instP]->flexran_agent_notify_ue_state_change(Mod_instP, - rntiP, - PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + rntiP, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); } + rrc_mac_remove_ue(Mod_instP,rntiP); } void mac_eNB_rrc_uplane_failure(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) -{ - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[Mod_instP], - rntiP); - if (ue_context_p != NULL) { - LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP); - - if(ue_context_p->ue_context.ul_failure_timer == 0) - ue_context_p->ue_context.ul_failure_timer=19999; - } - else { - LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP); - } + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_eNB_get_ue_context( + RC.rrc[Mod_instP], + rntiP); + + if (ue_context_p != NULL) { + LOG_I(RRC,"Frame %d, Subframe %d: UE %x U-Plane failure, activating timer\n",frameP,subframeP,rntiP); + + if(ue_context_p->ue_context.ul_failure_timer == 0) + ue_context_p->ue_context.ul_failure_timer=19999; + } else { + LOG_W(RRC,"Frame %d, Subframe %d: U-Plane failure: UE %x unknown \n",frameP,subframeP,rntiP); + } } -void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, - const int CC_idP, - const frame_t frameP, - const sub_frame_t subframeP, - const rnti_t rntiP) -{ - struct rrc_eNB_ue_context_s* ue_context_p = NULL; +void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, + const int CC_idP, + const frame_t frameP, + const sub_frame_t subframeP, + const rnti_t rntiP) { + struct rrc_eNB_ue_context_s *ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context( RC.rrc[Mod_instP], rntiP); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index 02f0e059e05c3366779e953bc797901ea3bc2dac..6d831741c2292481e0589cf84f0dd44c2f4a8d75 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -53,8 +53,8 @@ #include "LTE_SRB-ToAddModList.h" #include "LTE_DRB-ToAddModList.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) -#include "LTE_MCCH-Message.h" -//#define MRB1 1 + #include "LTE_MCCH-Message.h" + //#define MRB1 1 #endif #include "RRC/LTE/rrc_defs.h" @@ -81,14 +81,14 @@ #include "enb_config.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif #include "common/ran_context.h" #include "secu_defs.h" #if !defined (msg) -#define msg printf + #define msg printf #endif @@ -117,8 +117,7 @@ uint16_t two_tier_hexagonal_adjacent_cellIds[7][6] = {{1,2,4,5,7,8}, // CellI * This is a helper function for xer_sprint, which directs all incoming data * into the provided string. */ -static int xer__print2s (const void *buffer, size_t size, void *app_key) -{ +static int xer__print2s (const void *buffer, size_t size, void *app_key) { xer_sprint_string_t *string_buffer = (xer_sprint_string_t *) app_key; size_t string_remaining = string_buffer->string_size - string_buffer->string_index; @@ -134,15 +133,12 @@ static int xer__print2s (const void *buffer, size_t size, void *app_key) return 0; } -int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, void *sptr) -{ +int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, void *sptr) { asn_enc_rval_t er; xer_sprint_string_t string_buffer; - string_buffer.string = string; string_buffer.string_size = string_size; string_buffer.string_index = 0; - er = xer_encode(td, sptr, XER_F_BASIC, xer__print2s, &string_buffer); if (er.encoded < 0) { @@ -158,14 +154,12 @@ int xer_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td, voi return er.encoded; } -uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index) -{ +uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index) { return(two_tier_hexagonal_adjacent_cellIds[Mod_id][index]); } /* This only works for the hexagonal topology...need a more general function for other topologies */ -uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) -{ +uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) { uint8_t i; for(i=0; i<7; i++) { @@ -178,54 +172,52 @@ uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId) return 0xFF; //error! } -uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame) -{ - +uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich_Resource, uint32_t phich_duration, uint32_t frame) { asn_enc_rval_t enc_rval; LTE_BCCH_BCH_Message_t *mib=&carrier->mib ; uint8_t sfn = (uint8_t)((frame>>2)&0xff); - uint16_t *spare= calloc(1, sizeof(uint16_t)); + uint16_t *spare = calloc(1, sizeof(uint16_t)); + if (spare == NULL) abort(); switch (N_RB_DL) { + case 6: + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n6; + break; - case 6: - mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n6; - break; + case 15: + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n15; + break; - case 15: - mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n15; - break; + case 25: + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n25; + break; - case 25: - mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n25; - break; + case 50: + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n50; + break; - case 50: - mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n50; - break; + case 75: + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n75; + break; - case 75: - mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n75; - break; + case 100: + mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n100; + break; - case 100: - mib->message.dl_Bandwidth = LTE_MasterInformationBlock__dl_Bandwidth_n100; - break; - default: - AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL); + default: + AssertFatal(1==0,"Unknown dl_Bandwidth %d\n",N_RB_DL); } AssertFatal(phich_Resource <= LTE_PHICH_Config__phich_Resource_two,"Illegal phich_Resource\n"); mib->message.phich_Config.phich_Resource = phich_Resource; AssertFatal(phich_duration <= LTE_PHICH_Config__phich_Duration_extended,"Illegal phich_Duration\n"); mib->message.phich_Config.phich_Duration = phich_duration; - LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x,sfn %x\n", - (uint32_t)mib->message.dl_Bandwidth, - (uint32_t)phich_duration, - (uint32_t)phich_Resource, - (uint32_t)sfn); - + LOG_I(RRC,"[MIB] systemBandwidth %x, phich_duration %x, phich_resource %x, sfn %x\n", + (uint32_t)mib->message.dl_Bandwidth, + (uint32_t)phich_duration, + (uint32_t)phich_Resource, + (uint32_t)sfn); mib->message.systemFrameNumber.buf = &sfn; mib->message.systemFrameNumber.size = 1; mib->message.systemFrameNumber.bits_unused=0; @@ -238,16 +230,14 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich mib->message.spare.bits_unused = 3; // This makes a spare of 5 bits mib->message.schedulingInfoSIB1_BR_r13 = 0; // turn off eMTC #endif - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_BCH_Message, NULL, - (void*)mib, + (void *)mib, carrier->MIB, 24); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - if (enc_rval.encoded==-1) { return(-1); } @@ -257,58 +247,55 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich //TTN for D2D // 3GPP 36.331 (Section 5.10.7.4) -uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, uint32_t frame, uint8_t subframe, uint8_t in_coverage, uint8_t mode) -{ +uint8_t do_MIB_SL(const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index, uint32_t frame, uint8_t subframe, uint8_t in_coverage, uint8_t mode) { + asn_enc_rval_t enc_rval; + LTE_SBCCH_SL_BCH_MessageType_t *mib_sl = &UE_rrc_inst[ctxt_pP->module_id].mib_sl[eNB_index]; + uint8_t sfn = (uint8_t)((frame>>2)&0xff); + UE_rrc_inst[ctxt_pP->module_id].MIB = (uint8_t *) malloc16(4); - asn_enc_rval_t enc_rval; - LTE_SBCCH_SL_BCH_MessageType_t *mib_sl = &UE_rrc_inst[ctxt_pP->module_id].mib_sl[eNB_index]; - uint8_t sfn = (uint8_t)((frame>>2)&0xff); - UE_rrc_inst[ctxt_pP->module_id].MIB = (uint8_t*) malloc16(4); - - if (in_coverage > 0 ){ - //in coverage - mib_sl->inCoverage_r12 = TRUE; - mib_sl->sl_Bandwidth_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth; - if (UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config) { - mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config->subframeAssignment; - } else { - mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = LTE_TDD_ConfigSL_r12__subframeAssignmentSL_r12_none; - } - //if triggered by sl communication - if (UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){ - mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; - } - //if triggered by sl discovery - if (UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12){ - mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; - } - //Todo - if triggered by v2x - } else { - //Todo - out of coverage for V2X - // Todo - UE has a selected SyncRef UE - mib_sl->inCoverage_r12 = FALSE; - //set sl-Bandwidth, subframeAssignmentSL and reserved from the pre-configured parameters - } - - //set FrameNumber, subFrameNumber - mib_sl->directFrameNumber_r12.buf = &sfn; - mib_sl->directFrameNumber_r12.size = 1; - mib_sl->directFrameNumber_r12.bits_unused=0; - mib_sl->directSubframeNumber_r12 = subframe; + if (in_coverage > 0 ) { + //in coverage + mib_sl->inCoverage_r12 = TRUE; + mib_sl->sl_Bandwidth_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib2[eNB_index]->freqInfo.ul_Bandwidth; + if (UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config) { + mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config->subframeAssignment; + } else { + mib_sl->tdd_ConfigSL_r12.subframeAssignmentSL_r12 = LTE_TDD_ConfigSL_r12__subframeAssignmentSL_r12_none; + } - LOG_I(RRC,"[MIB-SL] sfn %x, subframe %x\n", (uint32_t)sfn, (uint8_t)subframe); + //if triggered by sl communication + if (UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12) { + mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib18[eNB_index]->commConfig_r12->commSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; + } + + //if triggered by sl discovery + if (UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12) { + mib_sl->reserved_r12 = *UE_rrc_inst[ctxt_pP->module_id].sib19[eNB_index]->discConfig_r12->discSyncConfig_r12->list.array[0]->txParameters_r12->syncInfoReserved_r12; + } + //Todo - if triggered by v2x + } else { + //Todo - out of coverage for V2X + // Todo - UE has a selected SyncRef UE + mib_sl->inCoverage_r12 = FALSE; + //set sl-Bandwidth, subframeAssignmentSL and reserved from the pre-configured parameters + } + //set FrameNumber, subFrameNumber + mib_sl->directFrameNumber_r12.buf = &sfn; + mib_sl->directFrameNumber_r12.size = 1; + mib_sl->directFrameNumber_r12.bits_unused=0; + mib_sl->directSubframeNumber_r12 = subframe; + LOG_I(RRC,"[MIB-SL] sfn %x, subframe %x\n", (uint32_t)sfn, (uint8_t)subframe); enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_SBCCH_SL_BCH_Message, NULL, - (void*)mib_sl, + (void *)mib_sl, UE_rrc_inst[ctxt_pP->module_id].MIB, 24); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - if (enc_rval.encoded==-1) { return(-1); } @@ -318,13 +305,11 @@ uint8_t do_MIB_SL(const protocol_ctxt_t* const ctxt_pP, const uint8_t eNB_index, uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, - int Mod_id,int CC_id + int Mod_id,int CC_id #if defined(ENABLE_ITTI) - , RrcConfigurationReq *configuration + , RrcConfigurationReq *configuration #endif - ) -{ - + ) { // SystemInformation_t systemInformation; #if defined(ENABLE_ITTI) int num_plmn = configuration->num_plmn; @@ -336,20 +321,15 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, asn_enc_rval_t enc_rval; LTE_SchedulingInfo_t schedulingInfo; LTE_SIB_Type_t sib_type; - uint8_t *buffer = carrier->SIB1; LTE_BCCH_DL_SCH_Message_t *bcch_message = &carrier->siblock1; LTE_SystemInformationBlockType1_t **sib1 = &carrier->sib1; int i; - - memset(bcch_message,0,sizeof(LTE_BCCH_DL_SCH_Message_t)); bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_PR_c1; bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1; // memcpy(&bcch_message.message.choice.c1.choice.systemInformationBlockType1,sib1,sizeof(SystemInformationBlockType1_t)); - *sib1 = &bcch_message->message.choice.c1.choice.systemInformationBlockType1; - memset(PLMN_identity_info,0,num_plmn * sizeof(LTE_PLMN_IdentityInfo_t)); memset(&schedulingInfo,0,sizeof(LTE_SchedulingInfo_t)); memset(&sib_type,0,sizeof(LTE_SIB_Type_t)); @@ -358,9 +338,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, for (i = 0; i < configuration->num_plmn; ++i) { PLMN_identity_info[i].plmn_Identity.mcc = CALLOC(1,sizeof(*PLMN_identity_info[i].plmn_Identity.mcc)); memset(PLMN_identity_info[i].plmn_Identity.mcc,0,sizeof(*PLMN_identity_info[i].plmn_Identity.mcc)); - asn_set_empty(&PLMN_identity_info[i].plmn_Identity.mcc->list);//.size=0; - #if defined(ENABLE_ITTI) dummy_mcc[i][0] = (configuration->mcc[i] / 100) % 10; dummy_mcc[i][1] = (configuration->mcc[i] / 10) % 10; @@ -373,7 +351,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, ASN_SEQUENCE_ADD(&PLMN_identity_info[i].plmn_Identity.mcc->list,&dummy_mcc[i][0]); ASN_SEQUENCE_ADD(&PLMN_identity_info[i].plmn_Identity.mcc->list,&dummy_mcc[i][1]); ASN_SEQUENCE_ADD(&PLMN_identity_info[i].plmn_Identity.mcc->list,&dummy_mcc[i][2]); - PLMN_identity_info[i].plmn_Identity.mnc.list.size=0; PLMN_identity_info[i].plmn_Identity.mnc.list.count=0; #if defined(ENABLE_ITTI) @@ -408,11 +385,9 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, //assign_enum(&PLMN_identity_info.cellReservedForOperatorUse,PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved); PLMN_identity_info[i].cellReservedForOperatorUse=LTE_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved; - ASN_SEQUENCE_ADD(&(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list,&PLMN_identity_info[i]); } - // 16 bits (*sib1)->cellAccessRelatedInfo.trackingAreaCode.buf = MALLOC(2); #if defined(ENABLE_ITTI) @@ -424,7 +399,6 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, #endif (*sib1)->cellAccessRelatedInfo.trackingAreaCode.size=2; (*sib1)->cellAccessRelatedInfo.trackingAreaCode.bits_unused=0; - // 28 bits (*sib1)->cellAccessRelatedInfo.cellIdentity.buf = MALLOC(8); #if defined(ENABLE_ITTI) @@ -440,14 +414,11 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, #endif (*sib1)->cellAccessRelatedInfo.cellIdentity.size=4; (*sib1)->cellAccessRelatedInfo.cellIdentity.bits_unused=4; - // assign_enum(&(*sib1)->cellAccessRelatedInfo.cellBarred,SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred); (*sib1)->cellAccessRelatedInfo.cellBarred=LTE_SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred; - // assign_enum(&(*sib1)->cellAccessRelatedInfo.intraFreqReselection,SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_allowed); (*sib1)->cellAccessRelatedInfo.intraFreqReselection=LTE_SystemInformationBlockType1__cellAccessRelatedInfo__intraFreqReselection_notAllowed; (*sib1)->cellAccessRelatedInfo.csg_Indication=0; - (*sib1)->cellSelectionInfo.q_RxLevMin=-65; (*sib1)->cellSelectionInfo.q_RxLevMinOffset=NULL; //(*sib1)->p_Max = CALLOC(1, sizeof(P_Max_t)); @@ -458,35 +429,29 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, #else 7; #endif - schedulingInfo.si_Periodicity=LTE_SchedulingInfo__si_Periodicity_rf8; - // This is for SIB2/3 sib_type=LTE_SIB_Type_sibType3; ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,&sib_type); ASN_SEQUENCE_ADD(&(*sib1)->schedulingInfoList.list,&schedulingInfo); - // ASN_SEQUENCE_ADD(&schedulingInfo.sib_MappingInfo.list,NULL); - #if defined(ENABLE_ITTI) if (configuration->frame_type[CC_id] == TDD) #endif { (*sib1)->tdd_Config = CALLOC(1,sizeof(struct LTE_TDD_Config)); - (*sib1)->tdd_Config->subframeAssignment = #if defined(ENABLE_ITTI) configuration->tdd_config[CC_id]; #else 3; #endif - (*sib1)->tdd_Config->specialSubframePatterns = #if defined(ENABLE_ITTI) configuration->tdd_config_s[CC_id]; #else - 0; + 0; #endif } @@ -495,19 +460,16 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier, // (*sib1).nonCriticalExtension = calloc(1,sizeof(*(*sib1).nonCriticalExtension)); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message, (void*)bcch_message); + xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message, (void *)bcch_message); } enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_DL_SCH_Message, NULL, - (void*)bcch_message, + (void *)bcch_message, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - - LOG_D(RRC,"[eNB] SystemInformationBlockType1 Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); if (enc_rval.encoded==-1) { @@ -521,13 +483,10 @@ uint8_t do_SIB23(uint8_t Mod_id, int CC_id #if defined(ENABLE_ITTI) - , RrcConfigurationReq *configuration + , RrcConfigurationReq *configuration #endif - ) -{ - + ) { struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib2_part,*sib3_part; - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) //TTN - for D2D struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib18_part, *sib19_part, *sib21_part; @@ -539,7 +498,6 @@ uint8_t do_SIB23(uint8_t Mod_id, //struct SL_DiscResourcePool_r12 *SL_DiscResourcePoolPS; //for SIB19 (discRxPoolPS) //struct SL_V2X_ConfigCommon_r14 *SL_V2X_ConfigCommon; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part; LTE_MBSFN_SubframeConfigList_t *MBSFNSubframeConfigList; @@ -547,7 +505,6 @@ uint8_t do_SIB23(uint8_t Mod_id, struct LTE_MBSFN_AreaInfo_r9 *MBSFN_Area1, *MBSFN_Area2; #endif asn_enc_rval_t enc_rval; - uint8_t *buffer = RC.rrc[Mod_id]->carrier[CC_id].SIB23; LTE_BCCH_DL_SCH_Message_t *bcch_message = &RC.rrc[Mod_id]->carrier[CC_id].systemInformation; LTE_SystemInformationBlockType2_t **sib2 = &RC.rrc[Mod_id]->carrier[CC_id].sib2; @@ -556,7 +513,6 @@ uint8_t do_SIB23(uint8_t Mod_id, LTE_SystemInformationBlockType13_r9_t **sib13 = &RC.rrc[Mod_id]->carrier[CC_id].sib13; uint8_t MBMS_flag = RC.rrc[Mod_id]->carrier[CC_id].MBMS_flag; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //TTN - for D2D LTE_SystemInformationBlockType18_r12_t **sib18 = &RC.rrc[Mod_id]->carrier[CC_id].sib18; @@ -590,13 +546,10 @@ uint8_t do_SIB23(uint8_t Mod_id, sib3_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib2_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib3_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); - sib2_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2; sib3_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3; - *sib2 = &sib2_part->choice.sib2; *sib3 = &sib3_part->choice.sib3; - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0) { @@ -607,7 +560,6 @@ uint8_t do_SIB23(uint8_t Mod_id, } #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //TTN - for D2D sib18_part = CALLOC(1,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); @@ -616,28 +568,20 @@ uint8_t do_SIB23(uint8_t Mod_id, memset(sib18_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib19_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); memset(sib21_part,0,sizeof(struct LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member)); - sib18_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib18_v1250; sib19_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib19_v1250; sib21_part->present = LTE_SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib21_v1430; - *sib18 = &sib18_part->choice.sib18_v1250; *sib19 = &sib19_part->choice.sib19_v1250; *sib21 = &sib21_part->choice.sib21_v1430; - #endif - - // sib2 - (*sib2)->ac_BarringInfo = NULL; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (*sib2)->ext1 = NULL; (*sib2)->ext2 = NULL; #endif - #if defined(ENABLE_ITTI) - (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles = configuration->rach_numberOfRA_Preambles[CC_id]; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL; @@ -660,17 +604,17 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer = configuration->rach_macContentionResolutionTimer[CC_id]; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = configuration->rach_maxHARQ_Msg3Tx[CC_id]; - // BCCH-Config (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff = configuration->bcch_modificationPeriodCoeff[CC_id]; - // PCCH-Config (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = configuration->pcch_defaultPagingCycle[CC_id]; (*sib2)->radioResourceConfigCommon.pcch_Config.nB = configuration->pcch_nB[CC_id]; - + LOG_I(RRC,"[SIB2] With ITTI. Basic config of paging cycle DRX: radio frame cycle length %x, paging occasion number %x\n", + (uint32_t)configuration->pcch_defaultPagingCycle[CC_id], + (uint32_t)configuration->pcch_nB[CC_id]); // PRACH-Config (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex = configuration->prach_root[CC_id]; @@ -682,13 +626,11 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->prach_zero_correlation[CC_id]; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset = configuration->prach_freq_offset[CC_id]; - // PDSCH-Config (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower = configuration->pdsch_referenceSignalPower[CC_id]; (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b = configuration->pdsch_p_b[CC_id]; - // PUSCH-Config (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB = configuration->pusch_n_SB[CC_id]; @@ -706,19 +648,17 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->pusch_sequenceHoppingEnabled[CC_id]; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift = configuration->pusch_nDMRS1[CC_id]; - // PUCCH-Config - (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift = configuration->pucch_delta_shift[CC_id]; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI = configuration->pucch_nRB_CQI[CC_id]; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = configuration->pucch_nCS_AN[CC_id]; -//#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) + //#if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = configuration->pucch_n1_AN[CC_id]; -//#endif + //#endif // SRS Config if (configuration->srs_enable[CC_id]==1) { @@ -738,6 +678,7 @@ uint8_t do_SIB23(uint8_t Mod_id, } else { (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_MaxUpPts = NULL; } + RC.rrc[Mod_id]->srs_enable[CC_id] = 1; } else { RC.rrc[Mod_id]->srs_enable[CC_id] = 0; @@ -746,7 +687,6 @@ uint8_t do_SIB23(uint8_t Mod_id, } // uplinkPowerControlCommon - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH = configuration->pusch_p0_Nominal[CC_id]; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH @@ -767,9 +707,7 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->msg3_delta_Preamble[CC_id]; (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength = configuration->ul_CyclicPrefixLength[CC_id]; - // UE Timers and Constants - (*sib2)->ue_TimersAndConstants.t300 = configuration->ue_TimersAndConstants_t300[CC_id]; (*sib2)->ue_TimersAndConstants.t301 @@ -782,7 +720,6 @@ uint8_t do_SIB23(uint8_t Mod_id, = configuration->ue_TimersAndConstants_t311[CC_id]; (*sib2)->ue_TimersAndConstants.n311 = configuration->ue_TimersAndConstants_n311[CC_id]; - #else (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.numberOfRA_Preambles=LTE_RACH_ConfigCommon__preambleInfo__numberOfRA_Preambles_n64; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.preambleInfo.preamblesGroupAConfig = NULL; @@ -794,27 +731,20 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.ra_SupervisionInfo.mac_ContentionResolutionTimer= LTE_RACH_ConfigCommon__ra_SupervisionInfo__mac_ContentionResolutionTimer_sf48; (*sib2)->radioResourceConfigCommon.rach_ConfigCommon.maxHARQ_Msg3Tx = 4; - // BCCH-Config (*sib2)->radioResourceConfigCommon.bcch_Config.modificationPeriodCoeff=BCCH_Config__modificationPeriodCoeff_n2; - // PCCH-Config (*sib2)->radioResourceConfigCommon.pcch_Config.defaultPagingCycle = LTE_PCCH_Config__defaultPagingCycle_rf128; (*sib2)->radioResourceConfigCommon.pcch_Config.nB=LTE_PCCH_Config__nB_oneT; - // PRACH-Config (*sib2)->radioResourceConfigCommon.prach_Config.rootSequenceIndex=Mod_id;//0;//384; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_ConfigIndex = 0;//3; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.highSpeedFlag = 0; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.zeroCorrelationZoneConfig = 1;//12; (*sib2)->radioResourceConfigCommon.prach_Config.prach_ConfigInfo.prach_FreqOffset = 2; - // PDSCH-Config (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.referenceSignalPower=0; // corresponds to 24.7 dBm 5 MHz/ 27.7 10 MHz/ 30.7 20 MHz - - (*sib2)->radioResourceConfigCommon.pdsch_ConfigCommon.p_b=0; - // PUSCH-Config (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.n_SB=1; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode=LTE_PUSCH_ConfigCommon__pusch_ConfigBasic__hoppingMode_interSubFrame; @@ -824,55 +754,35 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH=0; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled=0; (*sib2)->radioResourceConfigCommon.pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift=0; - // PUCCH-Config - (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.deltaPUCCH_Shift=LTE_PUCCH_ConfigCommon__deltaPUCCH_Shift_ds1; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nRB_CQI = 1; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.nCS_AN = 0; (*sib2)->radioResourceConfigCommon.pucch_ConfigCommon.n1PUCCH_AN = 32; - - (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present=LTE_SoundingRS_UL_ConfigCommon_PR_release; (*sib2)->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.release=0; - // uplinkPowerControlCommon - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUSCH = -108; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.p0_NominalPUCCH = -108; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.alpha=LTE_UplinkPowerControlCommon__alpha_al1; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1_deltaF2; (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format1b=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format1b_deltaF3; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2_deltaF0; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2a=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2a_deltaF0; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaFList_PUCCH.deltaF_PUCCH_Format2b=LTE_DeltaFList_PUCCH__deltaF_PUCCH_Format2b_deltaF0; - (*sib2)->radioResourceConfigCommon.uplinkPowerControlCommon.deltaPreambleMsg3 = 6; - (*sib2)->radioResourceConfigCommon.ul_CyclicPrefixLength=UL_CyclicPrefixLength_len1; - (*sib2)->ue_TimersAndConstants.t300=UE_TimersAndConstants__t300_ms1000; - (*sib2)->ue_TimersAndConstants.t301=UE_TimersAndConstants__t301_ms1000; - (*sib2)->ue_TimersAndConstants.t310=UE_TimersAndConstants__t310_ms1000; - (*sib2)->ue_TimersAndConstants.n310=UE_TimersAndConstants__n310_n20; - (*sib2)->ue_TimersAndConstants.t311=UE_TimersAndConstants__t311_ms10000; - (*sib2)->ue_TimersAndConstants.n311=UE_TimersAndConstants__n311_n1; - #endif - (*sib2)->freqInfo.additionalSpectrumEmission = 1; (*sib2)->freqInfo.ul_CarrierFreq = NULL; (*sib2)->freqInfo.ul_Bandwidth = NULL; // (*sib2)->mbsfn_SubframeConfigList = NULL; - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (MBMS_flag > 0) { @@ -880,37 +790,29 @@ uint8_t do_SIB23(uint8_t Mod_id, LTE_MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig1; (*sib2)->mbsfn_SubframeConfigList = CALLOC(1,sizeof(struct LTE_MBSFN_SubframeConfigList)); MBSFNSubframeConfigList = (*sib2)->mbsfn_SubframeConfigList; - sib2_mbsfn_SubframeConfig1= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig1)); - memset((void*)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1)); - + memset((void *)sib2_mbsfn_SubframeConfig1,0,sizeof(*sib2_mbsfn_SubframeConfig1)); sib2_mbsfn_SubframeConfig1->radioframeAllocationPeriod= LTE_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4; sib2_mbsfn_SubframeConfig1->radioframeAllocationOffset= 1; sib2_mbsfn_SubframeConfig1->subframeAllocation.present= LTE_MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame; sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf= MALLOC(1); sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.size= 1; sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.bits_unused= 2; - sib2_mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2; - ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig1); if (MBMS_flag == 4 ) { LOG_I(RRC,"Adding MBSFN subframe Configuration 2 to SIB2\n"); LTE_MBSFN_SubframeConfig_t *sib2_mbsfn_SubframeConfig2; sib2_mbsfn_SubframeConfig2= CALLOC(1,sizeof(*sib2_mbsfn_SubframeConfig2)); - memset((void*)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2)); - + memset((void *)sib2_mbsfn_SubframeConfig2,0,sizeof(*sib2_mbsfn_SubframeConfig2)); sib2_mbsfn_SubframeConfig2->radioframeAllocationPeriod= LTE_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4; sib2_mbsfn_SubframeConfig2->radioframeAllocationOffset= 1; sib2_mbsfn_SubframeConfig2->subframeAllocation.present= LTE_MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame; sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf= MALLOC(1); sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.size= 1; sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.bits_unused= 2; - sib2_mbsfn_SubframeConfig2->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2; - - ASN_SEQUENCE_ADD(&MBSFNSubframeConfigList->list,sib2_mbsfn_SubframeConfig2); } } @@ -918,29 +820,22 @@ uint8_t do_SIB23(uint8_t Mod_id, #else // no MBMS transmission (*sib2)->mbsfn_SubframeConfigList = NULL; #endif - (*sib2)->timeAlignmentTimerCommon=LTE_TimeAlignmentTimer_infinity;//TimeAlignmentTimer_sf5120; - /// (*SIB3) #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) (*sib3)->ext1 = NULL; #endif (*sib3)->cellReselectionInfoCommon.q_Hyst=LTE_SystemInformationBlockType3__cellReselectionInfoCommon__q_Hyst_dB4; - (*sib3)->cellReselectionInfoCommon.speedStateReselectionPars=NULL; - (*sib3)->cellReselectionServingFreqInfo.s_NonIntraSearch=NULL; (*sib3)->cellReselectionServingFreqInfo.threshServingLow=31; (*sib3)->cellReselectionServingFreqInfo.cellReselectionPriority=7; - (*sib3)->intraFreqCellReselectionInfo.q_RxLevMin = -70; (*sib3)->intraFreqCellReselectionInfo.p_Max = NULL; (*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch)); *(*sib3)->intraFreqCellReselectionInfo.s_IntraSearch = 31; (*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth=CALLOC(1,sizeof(*(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth)); - *(*sib3)->intraFreqCellReselectionInfo.allowedMeasBandwidth = LTE_AllowedMeasBandwidth_mbw6; - (*sib3)->intraFreqCellReselectionInfo.presenceAntennaPort1 = 0; (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.buf = CALLOC(8,1); (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.size = 1; @@ -948,7 +843,6 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib3)->intraFreqCellReselectionInfo.neighCellConfig.bits_unused = 6; (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA = 1; (*sib3)->intraFreqCellReselectionInfo.t_ReselectionEUTRA_SF = (struct LTE_SpeedStateScaleFactors *)NULL; - // SIB13 // fill in all elements of SIB13 if present #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) @@ -958,7 +852,6 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib13)->notificationConfig_r9.notificationRepetitionCoeff_r9= LTE_MBMS_NotificationConfig_r9__notificationRepetitionCoeff_r9_n2; (*sib13)->notificationConfig_r9.notificationOffset_r9= 0; (*sib13)->notificationConfig_r9.notificationSF_Index_r9= 1; - // MBSFN-AreaInfoList MBSFNArea_list= &(*sib13)->mbsfn_AreaInfoList_r9;//CALLOC(1,sizeof(*MBSFNArea_list)); memset(MBSFNArea_list,0,sizeof(*MBSFNArea_list)); @@ -973,14 +866,9 @@ uint8_t do_SIB23(uint8_t Mod_id, // Subframe Allocation Info MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1); MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.size= 1; - MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x20<<2; // FDD: SF1 - - MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2; - MBSFN_Area1->mcch_Config_r9.signallingMCS_r9= LTE_MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7; - ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area1); //MBSFN Area 2: currently only activated for eMBMS relaying @@ -996,12 +884,8 @@ uint8_t do_SIB23(uint8_t Mod_id, MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1); MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.size= 1; MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2; - MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x04<<2; // FDD: SF6 - - MBSFN_Area2->mcch_Config_r9.signallingMCS_r9= LTE_MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n7; - ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area2); } @@ -1009,8 +893,6 @@ uint8_t do_SIB23(uint8_t Mod_id, } #endif - - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) //TTN - for D2D // SIB18 @@ -1018,10 +900,8 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib18)->commConfig_r12 = CALLOC (1, sizeof(*(*sib18)->commConfig_r12)); SL_CommRxPoolList= &(*sib18)->commConfig_r12->commRxPool_r12; memset(SL_CommRxPoolList,0,sizeof(*SL_CommRxPoolList)); - SL_CommResourcePool = CALLOC(1, sizeof(*SL_CommResourcePool)); memset(SL_CommResourcePool,0,sizeof(*SL_CommResourcePool)); - SL_CommResourcePool->sc_CP_Len_r12 = configuration->rxPool_sc_CP_Len[CC_id]; SL_CommResourcePool->sc_Period_r12 = configuration->rxPool_sc_Period[CC_id]; SL_CommResourcePool->data_CP_Len_r12 = configuration->rxPool_data_CP_Len[CC_id]; @@ -1032,54 +912,54 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = configuration->rxPool_ResourceConfig_offsetIndicator_present[CC_id]; if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) { - SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; - } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ){ - SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) { + SL_CommResourcePool->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->rxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; } SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = configuration->rxPool_ResourceConfig_subframeBitmap_present[CC_id]; - if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12){ - //for BS4 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12){ - //for BS8 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12){ - //for BS12 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12){ - //for BS16 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12){ - //for BS30 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12){ - //for BS40 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12){ - //for BS42 - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + + if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) { + //for BS4 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) { + //for BS8 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) { + //for BS12 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) { + //for BS16 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) { + //for BS30 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) { + //for BS40 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) { + //for BS42 + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_CommResourcePool->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; } //dataHoppingConfig_r12 SL_CommResourcePool->dataHoppingConfig_r12.hoppingParameter_r12 = 0; SL_CommResourcePool->dataHoppingConfig_r12.numSubbands_r12 = LTE_SL_HoppingConfigComm_r12__numSubbands_r12_ns1; SL_CommResourcePool->dataHoppingConfig_r12.rb_Offset_r12 = 0; - //ue_SelectedResourceConfig_r12 SL_CommResourcePool->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->ue_SelectedResourceConfig_r12)); SL_CommResourcePool->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20; @@ -1107,13 +987,11 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_CommResourcePool->txParameters_r12 = CALLOC (1, sizeof (*SL_CommResourcePool->txParameters_r12)); SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.alpha_r12 = LTE_Alpha_r12_al0; SL_CommResourcePool->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0; - SL_CommResourcePool->ext1 = NULL ; //end SL_CommResourcePool //add SL_CommResourcePool to SL_CommRxPoolList ASN_SEQUENCE_ADD(&SL_CommRxPoolList->list,SL_CommResourcePool); //end commRxPool_r12 - //TODO: commTxPoolNormalCommon_r12, similar to commRxPool_r12 //TODO: commTxPoolExceptional_r12 //TODO: commSyncConfig_r12 @@ -1121,17 +999,14 @@ uint8_t do_SIB23(uint8_t Mod_id, (*sib18)->ext1 = NULL; (*sib18)->lateNonCriticalExtension = NULL; // end SIB18 - // SIB19 // fill in all elements of SIB19 if present - //discConfig_r12 (*sib19)->discConfig_r12 = CALLOC (1, sizeof(*(*sib19)->discConfig_r12)); SL_DiscRxPoolList = &(*sib19)->discConfig_r12->discRxPool_r12; memset(SL_DiscRxPoolList,0,sizeof(*SL_DiscRxPoolList)); //fill SL_DiscResourcePool SL_DiscResourcePool = CALLOC(1, sizeof(*SL_DiscResourcePool)); - SL_DiscResourcePool->cp_Len_r12 = configuration->discRxPool_cp_Len[CC_id]; SL_DiscResourcePool->discPeriod_r12 = configuration->discRxPool_discPeriod[CC_id]; //sc_TF_ResourceConfig_r12 @@ -1141,137 +1016,134 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_DiscResourcePool->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPool_ResourceConfig_prb_Start[CC_id]; SL_DiscResourcePool->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPool_ResourceConfig_prb_End[CC_id]; SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPool_ResourceConfig_offsetIndicator_present[CC_id]; + if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_small_r12 ) { - SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; - } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ){ - SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.present == LTE_SL_OffsetIndicator_r12_PR_large_r12 ) { + SL_DiscResourcePool->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPool_ResourceConfig_offsetIndicator_choice[CC_id] ; } + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPool_ResourceConfig_subframeBitmap_present[CC_id]; - if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12){ - //for BS4 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12){ - //for BS8 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12){ - //for BS12 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12){ - //for BS16 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12){ - //for BS30 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12){ - //for BS40 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12){ - //for BS42 - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + + if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs4_r12) { + //for BS4 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs8_r12) { + //for BS8 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs12_r12) { + //for BS12 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs16_r12) { + //for BS16 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs30_r12) { + //for BS30 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs40_r12) { + //for BS40 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.present == LTE_SubframeBitmapSL_r12_PR_bs42_r12) { + //for BS42 + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = (uint8_t *)configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePool->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; } //add SL_DiscResourcePool to SL_DiscRxPoolList ASN_SEQUENCE_ADD(&SL_DiscRxPoolList->list,SL_DiscResourcePool); + /* + //for DiscRxPoolPS + (*sib19)->ext1 = CALLOC (1, sizeof(*(*sib19)->ext1)); + (*sib19)->ext1->discConfigPS_13 = CALLOC (1, sizeof(*((*sib19)->ext1->discConfigPS_13))); + + SL_DiscRxPoolPSList = &(*sib19)->ext1->discConfigPS_13->discRxPoolPS_r13; + memset(SL_DiscRxPoolPSList,0,sizeof(*SL_DiscRxPoolPSList)); + //fill SL_DiscResourcePool + SL_DiscResourcePoolPS = CALLOC(1, sizeof(*SL_DiscResourcePoolPS)); + + SL_DiscResourcePoolPS->cp_Len_r12 = configuration->discRxPoolPS_cp_Len[CC_id]; + SL_DiscResourcePoolPS->discPeriod_r12 = configuration->discRxPoolPS_discPeriod[CC_id]; + //sc_TF_ResourceConfig_r12 + SL_DiscResourcePoolPS->numRetx_r12 = configuration->discRxPoolPS_numRetx[CC_id]; + SL_DiscResourcePoolPS->numRepetition_r12 = configuration->discRxPoolPS_numRepetition[CC_id]; + + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Num[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Start[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPoolPS_ResourceConfig_prb_End[CC_id]; + + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_present[CC_id]; + if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) { + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){ + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; + } -/* - //for DiscRxPoolPS - (*sib19)->ext1 = CALLOC (1, sizeof(*(*sib19)->ext1)); - (*sib19)->ext1->discConfigPS_13 = CALLOC (1, sizeof(*((*sib19)->ext1->discConfigPS_13))); - - SL_DiscRxPoolPSList = &(*sib19)->ext1->discConfigPS_13->discRxPoolPS_r13; - memset(SL_DiscRxPoolPSList,0,sizeof(*SL_DiscRxPoolPSList)); - //fill SL_DiscResourcePool - SL_DiscResourcePoolPS = CALLOC(1, sizeof(*SL_DiscResourcePoolPS)); - - SL_DiscResourcePoolPS->cp_Len_r12 = configuration->discRxPoolPS_cp_Len[CC_id]; - SL_DiscResourcePoolPS->discPeriod_r12 = configuration->discRxPoolPS_discPeriod[CC_id]; - //sc_TF_ResourceConfig_r12 - SL_DiscResourcePoolPS->numRetx_r12 = configuration->discRxPoolPS_numRetx[CC_id]; - SL_DiscResourcePoolPS->numRepetition_r12 = configuration->discRxPoolPS_numRepetition[CC_id]; - - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Num_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Num[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_Start_r12 = configuration->discRxPoolPS_ResourceConfig_prb_Start[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.prb_End_r12 = configuration->discRxPoolPS_ResourceConfig_prb_End[CC_id]; - - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_present[CC_id]; - if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_small_r12 ) { - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; - } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.present == SL_OffsetIndicator_r12_PR_large_r12 ){ - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.offsetIndicator_r12.choice.large_r12 = configuration->discRxPoolPS_ResourceConfig_offsetIndicator_choice[CC_id] ; - } - - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_present[CC_id]; - if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){ - //for BS4 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){ - //for BS8 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){ - //for BS12 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){ - //for BS16 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){ - //for BS30 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){ - //for BS40 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){ - //for BS42 - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; - SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; - } - - //add SL_DiscResourcePool to SL_DiscRxPoolList - ASN_SEQUENCE_ADD(&SL_DiscRxPoolPSList->list,SL_DiscResourcePoolPS); -*/ + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_present[CC_id]; + if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs4_r12){ + //for BS4 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs8_r12){ + //for BS8 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs8_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs12_r12){ + //for BS12 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs12_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs16_r12){ + //for BS16 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs30_r12){ + //for BS30 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs30_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs40_r12){ + //for BS40 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + }else if (SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.present == SubframeBitmapSL_r12_PR_bs42_r12){ + //for BS42 + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.size = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_size[CC_id]; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.buf = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_buf[CC_id];; + SL_DiscResourcePoolPS->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs42_r12.bits_unused = configuration->discRxPoolPS_ResourceConfig_subframeBitmap_choice_bs_bits_unused[CC_id]; + } + //add SL_DiscResourcePool to SL_DiscRxPoolList + ASN_SEQUENCE_ADD(&SL_DiscRxPoolPSList->list,SL_DiscResourcePoolPS); + */ (*sib19)->lateNonCriticalExtension = NULL; //end SIB19 - //SIB21 (*sib21)->sl_V2X_ConfigCommon_r14 = CALLOC (1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14)); //SL_V2X_ConfigCommon= (*sib21)->sl_V2X_ConfigCommon_r14; memset((*sib21)->sl_V2X_ConfigCommon_r14,0,sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14)); - struct LTE_SL_CommRxPoolListV2X_r14 *SL_CommRxPoolListV2X; struct LTE_SL_CommResourcePoolV2X_r14 *SL_CommResourcePoolV2X; (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14 = CALLOC(1, sizeof(*(*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14)); SL_CommRxPoolListV2X = (*sib21)->sl_V2X_ConfigCommon_r14->v2x_CommRxPool_r14; - SL_CommResourcePoolV2X = CALLOC(1, sizeof(*SL_CommResourcePoolV2X)); memset(SL_CommResourcePoolV2X,0,sizeof(*SL_CommResourcePoolV2X)); - SL_CommResourcePoolV2X->sl_OffsetIndicator_r14 = CALLOC(1, sizeof(*SL_CommResourcePoolV2X->sl_OffsetIndicator_r14)); SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->present = LTE_SL_OffsetIndicator_r12_PR_small_r12; SL_CommResourcePoolV2X->sl_OffsetIndicator_r14->choice.small_r12 = 0; @@ -1284,34 +1156,26 @@ uint8_t do_SIB23(uint8_t Mod_id, SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[2] = 0xFF; SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[3] = 0xFF; SL_CommResourcePoolV2X->sl_Subframe_r14.choice.bs40_r14.buf[4] = 0xFF; - SL_CommResourcePoolV2X->adjacencyPSCCH_PSSCH_r14 = 1; SL_CommResourcePoolV2X->sizeSubchannel_r14 = 10; SL_CommResourcePoolV2X->numSubchannel_r14 = 5; SL_CommResourcePoolV2X->startRB_Subchannel_r14 = 10; - //rxParametersNCell_r12 SL_CommResourcePoolV2X->rxParametersNCell_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14)); SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14 = CALLOC (1, sizeof (*SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14)); SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->subframeAssignment = 0 ; SL_CommResourcePoolV2X->rxParametersNCell_r14->tdd_Config_r14->specialSubframePatterns = 0; SL_CommResourcePoolV2X->rxParametersNCell_r14->syncConfigIndex_r14 = 0; - ASN_SEQUENCE_ADD(&SL_CommRxPoolListV2X->list,SL_CommResourcePoolV2X); //end SIB21 #endif - - bcch_message->message.present = LTE_BCCH_DL_SCH_MessageType_PR_c1; bcch_message->message.choice.c1.present = LTE_BCCH_DL_SCH_MessageType__c1_PR_systemInformation; - /* memcpy((void*)&bcch_message.message.choice.c1.choice.systemInformation, (void*)systemInformation, sizeof(SystemInformation_t));*/ - bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.present = LTE_SystemInformation__criticalExtensions_PR_systemInformation_r8; bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0; - // asn_set_empty(&systemInformation->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list);//.size=0; // systemInformation->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count=0; ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list, @@ -1323,21 +1187,20 @@ uint8_t do_SIB23(uint8_t Mod_id, if (MBMS_flag > 0) { ASN_SEQUENCE_ADD(&bcch_message->message.choice.c1.choice.systemInformation.criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list,sib13_part); } + #endif if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message, (void*)bcch_message); + xer_fprint(stdout, &asn_DEF_LTE_BCCH_DL_SCH_Message, (void *)bcch_message); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_BCCH_DL_SCH_Message, NULL, - (void*)bcch_message, + (void *)bcch_message, buffer, 900); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - - LOG_D(RRC,"[eNB] SystemInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); if (enc_rval.encoded==-1) { @@ -1348,22 +1211,15 @@ uint8_t do_SIB23(uint8_t Mod_id, return((enc_rval.encoded+7)/8); } -uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) -{ - +uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) { asn_enc_rval_t enc_rval; uint8_t buf[5],buf2=0; - LTE_UL_CCCH_Message_t ul_ccch_msg; - LTE_RRCConnectionRequest_t *rrcConnectionRequest; - memset((void *)&ul_ccch_msg,0,sizeof(LTE_UL_CCCH_Message_t)); - ul_ccch_msg.message.present = LTE_UL_CCCH_MessageType_PR_c1; ul_ccch_msg.message.choice.c1.present = LTE_UL_CCCH_MessageType__c1_PR_rrcConnectionRequest; rrcConnectionRequest = &ul_ccch_msg.message.choice.c1.choice.rrcConnectionRequest; - rrcConnectionRequest->criticalExtensions.present = LTE_RRCConnectionRequest__criticalExtensions_PR_rrcConnectionRequest_r8; if (1) { @@ -1392,206 +1248,185 @@ uint8_t do_RRCConnectionRequest(uint8_t Mod_id, uint8_t *buffer,uint8_t *rv) } rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.establishmentCause = LTE_EstablishmentCause_mo_Signalling; //EstablishmentCause_mo_Data; - rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.buf = &buf2; rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.size=1; rrcConnectionRequest->criticalExtensions.choice.rrcConnectionRequest_r8.spare.bits_unused = 7; - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_CCCH_Message, (void*)&ul_ccch_msg); - } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_CCCH_Message, (void *)&ul_ccch_msg); + } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_CCCH_Message, NULL, - (void*)&ul_ccch_msg, + (void *)&ul_ccch_msg, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - LOG_D(RRC,"[UE] RRCConnectionRequest Encoded %zd bits (%zd bytes) \n",enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); - } //TTN for D2D - 3GPP TS 36.331 (Section 5.10.2.3) -uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, LTE_SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode) -{ - - asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_SidelinkUEInformation_r12_t *sidelinkUEInformation; - LTE_ARFCN_ValueEUTRA_r9_t carrierFreq = 25655;//sidelink communication frequency (hardcoded - should come from SIB2) - - memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_messageClassExtension; - ul_dcch_msg.message.choice.messageClassExtension.present = LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2; - ul_dcch_msg.message.choice.messageClassExtension.choice.c2.present = LTE_UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12; - sidelinkUEInformation = &ul_dcch_msg.message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12; - - //3GPP TS 36.331 (Section 5.10.2.3) - sidelinkUEInformation->criticalExtensions.present = LTE_SidelinkUEInformation_r12__criticalExtensions_PR_c1; - sidelinkUEInformation->criticalExtensions.choice.c1.present = LTE_SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12; - switch(mode) { - //if SIB18 is available - case SL_RECEIVE_COMMUNICATION: // to receive sidelink communication +uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, LTE_SL_DestinationInfoList_r12_t *destinationInfoList, long *discTxResourceReq, SL_TRIGGER_t mode) { + asn_enc_rval_t enc_rval; + LTE_UL_DCCH_Message_t ul_dcch_msg; + LTE_SidelinkUEInformation_r12_t *sidelinkUEInformation; + LTE_ARFCN_ValueEUTRA_r9_t carrierFreq = 25655;//sidelink communication frequency (hardcoded - should come from SIB2) + memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); + ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_messageClassExtension; + ul_dcch_msg.message.choice.messageClassExtension.present = LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2; + ul_dcch_msg.message.choice.messageClassExtension.choice.c2.present = LTE_UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12; + sidelinkUEInformation = &ul_dcch_msg.message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12; + //3GPP TS 36.331 (Section 5.10.2.3) + sidelinkUEInformation->criticalExtensions.present = LTE_SidelinkUEInformation_r12__criticalExtensions_PR_c1; + sidelinkUEInformation->criticalExtensions.choice.c1.present = LTE_SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12; + + switch(mode) { + //if SIB18 is available + case SL_RECEIVE_COMMUNICATION: // to receive sidelink communication sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12)); - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12, (void*)&carrierFreq, - sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12, (void *)&carrierFreq, + sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); break; - case SL_TRANSMIT_NON_RELAY_ONE_TO_MANY: //to transmit non-relay related one-to-many sidelink communication + case SL_TRANSMIT_NON_RELAY_ONE_TO_MANY: //to transmit non-relay related one-to-many sidelink communication //commTxResourceReq sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12)); - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12, (void*)&carrierFreq, - sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12, (void *)&carrierFreq, + sizeof(LTE_ARFCN_ValueEUTRA_r9_t)); memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12, - destinationInfoList, - sizeof(LTE_SL_DestinationInfoList_r12_t)); + destinationInfoList, + sizeof(LTE_SL_DestinationInfoList_r12_t)); break; - case SL_TRANSMIT_NON_RELAY_ONE_TO_ONE://transmit non-relay related one-to-one sidelink communication + case SL_TRANSMIT_NON_RELAY_ONE_TO_ONE://transmit non-relay related one-to-one sidelink communication //if commTxResourceUC-ReqAllowed is included in SIB18 sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); - + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12)); - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12, (void*)&carrierFreq, - sizeof (LTE_ARFCN_ValueEUTRA_r9_t)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12, (void *)&carrierFreq, + sizeof (LTE_ARFCN_ValueEUTRA_r9_t)); memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12, - destinationInfoList, - sizeof(LTE_SL_DestinationInfoList_r12_t)); + destinationInfoList, + sizeof(LTE_SL_DestinationInfoList_r12_t)); break; - case SL_TRANSMIT_RELAY_ONE_TO_ONE: //transmit relay related one-to-one sidelink communication + case SL_TRANSMIT_RELAY_ONE_TO_ONE: //transmit relay related one-to-one sidelink communication //if SIB19 includes discConfigRelay and UE acts a relay or UE has a selected relay sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13= CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13)); memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12, - destinationInfoList, - sizeof(*destinationInfoList)); + destinationInfoList, + sizeof(*destinationInfoList)); //set ue-type to relayUE or remoteUE - sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 =LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 + =LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; //sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12->nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 =SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_remoteUE; break; - case SL_TRANSMIT_RELAY_ONE_TO_MANY: //transmit relay related one-to-many sidelink communication + case SL_TRANSMIT_RELAY_ONE_TO_MANY: //transmit relay related one-to-many sidelink communication //if SIB19 includes discConfigRelay and UE acts a relay //set ue-type to relayUE sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13= CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13)); - sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 = LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13)); + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->ue_Type_r13 = + LTE_SidelinkUEInformation_v1310_IEs__commTxResourceInfoReqRelay_r13__ue_Type_r13_relayUE; memcpy(&sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12, - destinationInfoList, - sizeof(*destinationInfoList)); + destinationInfoList, + sizeof(*destinationInfoList)); break; - //if SIB19 is available - //we consider only one frequency - a serving frequency - case SL_RECEIVE_DISCOVERY: //receive sidelink discovery announcements - + //if SIB19 is available + //we consider only one frequency - a serving frequency + case SL_RECEIVE_DISCOVERY: //receive sidelink discovery announcements sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12)); *sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discRxInterest_r12 = LTE_SidelinkUEInformation_r12_IEs__discRxInterest_r12_true; break; - case SL_TRANSMIT_NON_PS_DISCOVERY://to transmit non-PS related sidelink discovery announcements + + case SL_TRANSMIT_NON_PS_DISCOVERY://to transmit non-PS related sidelink discovery announcements //for the first frequency sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12)); - - memcpy((void*)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12, - (void*)discTxResourceReq, - sizeof(long)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12)); + memcpy((void *)sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12, + (void *)discTxResourceReq, + sizeof(long)); //for additional frequency break; - case SL_TRANSMIT_PS_DISCOVERY://to transmit PS related sidelink discovery announcements + case SL_TRANSMIT_PS_DISCOVERY://to transmit PS related sidelink discovery announcements //if to transmit non-relay PS related discovery announcements and SIB19 includes discConfigPS //if UE is acting as relay UE and SIB includes discConfigRelay (relay threshold condition) //if relay UE/has a selected relay UE and if SIB19 includes discConfigRelay sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13 = CALLOC(1, - sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13)); + sizeof(*sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13)); sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13 = *discTxResourceReq; break; - //SIB21 - case SL_RECEIVE_V2X: + + //SIB21 + case SL_RECEIVE_V2X: //TODO break; - case SL_TRANSMIT_V2X: + + case SL_TRANSMIT_V2X: //TODO break; - //TODO: request sidelink discovery transmission/reception gaps - //TODO: report the system information parameters related to sidelink discovery of carriers other than the primary - default: - break; - } - - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void*)&ul_dcch_msg); - } - - - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, - NULL, - (void*)&ul_dcch_msg, - buffer, - 100); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - - - LOG_D(RRC,"SidelinkUEInformation Encoded %d bits (%d bytes)\n",(uint32_t)enc_rval.encoded,(uint32_t)((enc_rval.encoded+7)/8)); + //TODO: request sidelink discovery transmission/reception gaps + //TODO: report the system information parameters related to sidelink discovery of carriers other than the primary + default: + break; + } - return((enc_rval.encoded+7)/8); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); + } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, + NULL, + (void *)&ul_dcch_msg, + buffer, + 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + LOG_D(RRC,"SidelinkUEInformation Encoded %d bits (%d bytes)\n",(uint32_t)enc_rval.encoded,(uint32_t)((enc_rval.encoded+7)/8)); + return((enc_rval.encoded+7)/8); } -uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS) -{ - - +uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, const char *dedicatedInfoNAS) { asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_RRCConnectionSetupComplete_t *rrcConnectionSetupComplete; - memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete; rrcConnectionSetupComplete = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionSetupComplete; - rrcConnectionSetupComplete->rrc_TransactionIdentifier = Transaction_id; rrcConnectionSetupComplete->criticalExtensions.present = LTE_RRCConnectionSetupComplete__criticalExtensions_PR_c1; rrcConnectionSetupComplete->criticalExtensions.choice.c1.present = LTE_RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8; - rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension=CALLOC(1, sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.nonCriticalExtension)); - rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.selectedPLMN_Identity= 1; - rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME = NULL;//calloc(1,sizeof(*rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME)); /* @@ -1612,65 +1447,54 @@ uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uin rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.size=1; rrcConnectionSetupComplete->criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8.registeredMME->mmec.bits_unused=0; */ - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void*)&ul_dcch_msg); - } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); + } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, - (void*)&ul_dcch_msg, + (void *)&ul_dcch_msg, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - LOG_D(RRC,"RRCConnectionSetupComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); - } //------------------------------------------------------------------------------ uint8_t do_RRCConnectionReconfigurationComplete( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, const uint8_t Transaction_id ) //------------------------------------------------------------------------------ { - - asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_RRCConnectionReconfigurationComplete_t *rrcConnectionReconfigurationComplete; - memset((void *)&ul_dcch_msg,0,sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete; rrcConnectionReconfigurationComplete = &ul_dcch_msg.message.choice.c1.choice.rrcConnectionReconfigurationComplete; - rrcConnectionReconfigurationComplete->rrc_TransactionIdentifier = Transaction_id; rrcConnectionReconfigurationComplete->criticalExtensions.present = LTE_RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8; rrcConnectionReconfigurationComplete->criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8.nonCriticalExtension=NULL; - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void*)&ul_dcch_msg); - } + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); + } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, - (void*)&ul_dcch_msg, + (void *)&ul_dcch_msg, buffer, 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - LOG_D(RRC,"RRCConnectionReconfigurationComplete Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); } @@ -1678,39 +1502,31 @@ do_RRCConnectionReconfigurationComplete( //------------------------------------------------------------------------------ uint8_t do_RRCConnectionSetup( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, LTE_SRB_ToAddModList_t **SRB_configList, - struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) -{ - + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) { asn_enc_rval_t enc_rval; eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; rrc_eNB_carrier_data_t *carrier = &rrc->carrier[CC_id]; - - long* logicalchannelgroup = NULL; - struct LTE_SRB_ToAddMod* SRB1_config = NULL; - struct LTE_SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL; - struct LTE_SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL; - struct LTE_LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL; - + long *logicalchannelgroup = NULL; + struct LTE_SRB_ToAddMod *SRB1_config = NULL; + struct LTE_SRB_ToAddMod__rlc_Config *SRB1_rlc_config = NULL; + struct LTE_SRB_ToAddMod__logicalChannelConfig *SRB1_lchan_config = NULL; + struct LTE_LogicalChannelConfig__ul_SpecificParameters *SRB1_ul_SpecificParameters = NULL; #ifdef CBA - struct LTE_PUSCH_CBAConfigDedicated_vlola* pusch_CBAConfigDedicated_vlola = NULL; - long* betaOffset_CBA_Index = NULL; - long* cShift_CBA = NULL; + struct LTE_PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola = NULL; + long *betaOffset_CBA_Index = NULL; + long *cShift_CBA = NULL; #endif - LTE_PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL; - + LTE_PhysicalConfigDedicated_t *physicalConfigDedicated2 = NULL; LTE_DL_CCCH_Message_t dl_ccch_msg; - - LTE_RRCConnectionSetup_t* rrcConnectionSetup = NULL; - + LTE_RRCConnectionSetup_t *rrcConnectionSetup = NULL; LTE_DL_FRAME_PARMS *frame_parms = &RC.eNB[ctxt_pP->module_id][CC_id]->frame_parms; - memset((void *)&dl_ccch_msg,0,sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup; @@ -1725,14 +1541,11 @@ do_RRCConnectionSetup( } *SRB_configList = CALLOC(1,sizeof(LTE_SRB_ToAddModList_t)); - /// SRB1 SRB1_config = CALLOC(1,sizeof(*SRB1_config)); - SRB1_config->srb_Identity = 1; SRB1_rlc_config = CALLOC(1,sizeof(*SRB1_rlc_config)); SRB1_config->rlc_Config = SRB1_rlc_config; - SRB1_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB1_rlc_config->choice.explicitValue.present=LTE_RLC_Config_PR_am; #if defined(ENABLE_ITTI) @@ -1742,44 +1555,31 @@ do_RRCConnectionSetup( SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = rrc->srb1_max_retx_threshold; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = rrc->srb1_timer_reordering; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = rrc->srb1_timer_status_prohibit; -#else +#else SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms20;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p4;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms0; -#endif - +#endif SRB1_lchan_config = CALLOC(1,sizeof(*SRB1_lchan_config)); SRB1_config->logicalChannelConfig = SRB1_lchan_config; - SRB1_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; SRB1_ul_SpecificParameters = CALLOC(1,sizeof(*SRB1_ul_SpecificParameters)); - SRB1_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB1_ul_SpecificParameters; - - SRB1_ul_SpecificParameters->priority = 1; - //assign_enum(&SRB1_ul_SpecificParameters->prioritisedBitRate,LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity); SRB1_ul_SpecificParameters->prioritisedBitRate=LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50); SRB1_ul_SpecificParameters->bucketSizeDuration=LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - logicalchannelgroup = CALLOC(1,sizeof(long)); *logicalchannelgroup=0; SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; - - ASN_SEQUENCE_ADD(&(*SRB_configList)->list,SRB1_config); - // PhysicalConfigDedicated - physicalConfigDedicated2 = CALLOC(1,sizeof(*physicalConfigDedicated2)); *physicalConfigDedicated = physicalConfigDedicated2; - physicalConfigDedicated2->pdsch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated)); physicalConfigDedicated2->pucch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pucch_ConfigDedicated)); physicalConfigDedicated2->pusch_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->pusch_ConfigDedicated)); @@ -1787,10 +1587,12 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH)); physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH = CALLOC(1,sizeof(*physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH)); physicalConfigDedicated2->cqi_ReportConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig)); + if (rrc->srs_enable[CC_id]==1) physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = CALLOC(1,sizeof(*physicalConfigDedicated2->soundingRS_UL_ConfigDedicated)); else physicalConfigDedicated2->soundingRS_UL_ConfigDedicated = NULL; + physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->schedulingRequestConfig = CALLOC(1,sizeof(*physicalConfigDedicated2->schedulingRequestConfig)); @@ -1818,7 +1620,6 @@ do_RRCConnectionSetup( physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_ACK_Index = 0; // 2.00 physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_RI_Index = 0; // 1.25 physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_CQI_Index = 8; // 2.25 - // UplinkPowerControlDedicated physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUSCH = 0; // 0 dB //assign_enum(&physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled, @@ -1831,9 +1632,7 @@ do_RRCConnectionSetup( sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient)); // assign_enum(physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient,FilterCoefficient_fc4); // fc4 dB *physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient=LTE_FilterCoefficient_fc4; // fc4 dB - // TPC-PDCCH-Config - physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->present=LTE_TPC_PDCCH_Config_PR_setup; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.present = LTE_TPC_Index_PR_indexOfFormat3; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1; @@ -1842,7 +1641,6 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0]=0x12; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused=0; - physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present=LTE_TPC_PDCCH_Config_PR_setup; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.present = LTE_TPC_Index_PR_indexOfFormat3; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1; @@ -1851,9 +1649,7 @@ do_RRCConnectionSetup( physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0]=0x22; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1]=0x34+ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused=0; - // CQI ReportConfig - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic)); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) *physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic= LTE_CQI_ReportModeAperiodic_rm30; @@ -1862,65 +1658,67 @@ do_RRCConnectionSetup( #endif physicalConfigDedicated2->cqi_ReportConfig->nomPDSCH_RS_EPRE_Offset = 0; // 0 dB //physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=NULL; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic)); physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = LTE_CQI_ReportPeriodic_PR_release; - /* - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = CQI_ReportPeriodic_PR_setup; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0; // n2_pucch - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0; // Icqi/pmi - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI; // subband CQI - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4; - - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL; - physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0; - */ + /* + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->present = CQI_ReportPeriodic_PR_setup; + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_PUCCH_ResourceIndex = 0; // n2_pucch + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex = 0; // Icqi/pmi + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present = CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI; // subband CQI + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.choice.subbandCQI.k=4; + + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL; + physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0; + */ //soundingRS-UL-ConfigDedicated if (rrc->srs_enable[CC_id]==1) { physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = LTE_SoundingRS_UL_ConfigDedicated_PR_setup; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_Bandwidth = - LTE_SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; + LTE_SoundingRS_UL_ConfigDedicated__setup__srs_Bandwidth_bw0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_HoppingBandwidth = - LTE_SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0; + LTE_SoundingRS_UL_ConfigDedicated__setup__srs_HoppingBandwidth_hbw0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.freqDomainPosition=0; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.duration=1; + if (carrier->sib1->tdd_Config==NULL) { // FDD if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present - == LTE_SoundingRS_UL_ConfigCommon_PR_setup) - if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=0) - LOG_W(RRC,"This code has been optimized for SRS Subframe Config 0, but current config is %zd. Expect undefined behaviour!\n", - carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig); - if (ue_context_pP->local_uid >=20) - LOG_W(RRC,"This code has been optimized for up to 10 UEs, but current UE_id is %d. Expect undefined behaviour!\n", - ue_context_pP->local_uid); + == LTE_SoundingRS_UL_ConfigCommon_PR_setup) + if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=0) + LOG_W(RRC,"This code has been optimized for SRS Subframe Config 0, but current config is %zd. Expect undefined behaviour!\n", + carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig); + + if (ue_context_pP->local_uid >=20) + LOG_W(RRC,"This code has been optimized for up to 10 UEs, but current UE_id is %d. Expect undefined behaviour!\n", + ue_context_pP->local_uid); + //the current code will allow for 20 UEs - to be revised for more physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=7+ue_context_pP->local_uid/2; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb= ue_context_pP->local_uid%2; - } - else { + } else { if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.present - == LTE_SoundingRS_UL_ConfigCommon_PR_setup) - if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=7) { - LOG_W(RRC,"This code has been optimized for SRS Subframe Config 7 and TDD config 3, but current configs are %zd and %zd. Expect undefined behaviour!\n", - carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig, - carrier->sib1->tdd_Config->subframeAssignment); - } - if (ue_context_pP->local_uid >=6) - LOG_W(RRC,"This code has been optimized for up to 6 UEs, but current UE_id is %d. Expect undefined behaviour!\n", - ue_context_pP->local_uid); + == LTE_SoundingRS_UL_ConfigCommon_PR_setup) + if (carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig!=7) { + LOG_W(RRC,"This code has been optimized for SRS Subframe Config 7 and TDD config 3, but current configs are %zd and %zd. Expect undefined behaviour!\n", + carrier->sib2->radioResourceConfigCommon.soundingRS_UL_ConfigCommon.choice.setup.srs_SubframeConfig, + carrier->sib1->tdd_Config->subframeAssignment); + } + + if (ue_context_pP->local_uid >=6) + LOG_W(RRC,"This code has been optimized for up to 6 UEs, but current UE_id is %d. Expect undefined behaviour!\n", + ue_context_pP->local_uid); + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex=17+ue_context_pP->local_uid/2; physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb= ue_context_pP->local_uid%2; } - LOG_W(RRC,"local UID %d, srs ConfigIndex %zd, TransmissionComb %zd\n",ue_context_pP->local_uid, - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex, - physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb); + LOG_W(RRC,"local UID %d, srs ConfigIndex %zd, TransmissionComb %zd\n",ue_context_pP->local_uid, + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.srs_ConfigIndex, + physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.transmissionComb); physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift= - LTE_SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0; + LTE_SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0; } - //AntennaInfoDedicated physicalConfigDedicated2->antennaInfo = CALLOC(1,sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->antennaInfo->present = LTE_PhysicalConfigDedicated__antennaInfo_PR_explicitValue; @@ -1928,99 +1726,102 @@ do_RRCConnectionSetup( // AntennaInfoDedicated__transmissionMode_tm2); switch (transmission_mode) { - default: - LOG_W(RRC,"At RRCConnectionSetup Transmission mode can only take values 1 or 2! Defaulting to 1!\n"); - case 1: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; - break; - - case 2: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; - break; - /* - case 3: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm3; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction= CALLOC(1, - sizeof(*physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction)); - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; - physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; - - break; - - case 4: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm4; - break; - - case 5: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm5; - break; - - case 6: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm6; - break; - - case 7: - physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm7; - break; - */ - } + default: + LOG_W(RRC,"At RRCConnectionSetup Transmission mode can only take values 1 or 2! Defaulting to 1!\n"); + case 1: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm1; + break; + + case 2: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= LTE_AntennaInfoDedicated__transmissionMode_tm2; + break; + /* + case 3: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm3; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction= CALLOC(1, + sizeof(*physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction)); + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; + physicalConfigDedicated2->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; + + break; + + case 4: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm4; + break; + + case 5: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm5; + break; + + case 6: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm6; + break; + + case 7: + physicalConfigDedicated2->antennaInfo->choice.explicitValue.transmissionMode= AntennaInfoDedicated__transmissionMode_tm7; + break; + */ + } physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.present = LTE_AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release; physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0; - // SchedulingRequestConfig - physicalConfigDedicated2->schedulingRequestConfig->present = LTE_SchedulingRequestConfig_PR_setup; + if (carrier->sib1->tdd_Config == NULL) { physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; } else { - switch (carrier->sib1->tdd_Config->subframeAssignment) { + switch (carrier->sib1->tdd_Config->subframeAssignment) { case 1: - switch(frame_parms->N_RB_UL){ + switch(frame_parms->N_RB_UL) { case 25: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 15 - ue_context_pP->local_uid/4; - break; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 15 - ue_context_pP->local_uid/4; + break; + case 50: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 31 - ue_context_pP->local_uid/4; - break; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 31 - ue_context_pP->local_uid/4; + break; + case 100: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 63 - ue_context_pP->local_uid/4; - break; - } - break; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 63 - ue_context_pP->local_uid/4; + break; + } + + break; + default: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; - break; - } + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = 71 - ue_context_pP->local_uid/10;//ue_context_pP->local_uid; + break; + } } if (carrier->sib1->tdd_Config == NULL) { // FDD physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 5+(ue_context_pP->local_uid%10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) } else { switch (carrier->sib1->tdd_Config->subframeAssignment) { - case 1: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(ue_context_pP->local_uid&1)+(( - ue_context_pP->local_uid&3)>>1)*5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) - break; + case 1: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+(ue_context_pP->local_uid&1)+(( + ue_context_pP->local_uid&3)>>1)*5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) + break; - case 3: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ - (ue_context_pP->local_uid%3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) - break; + case 3: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ + (ue_context_pP->local_uid%3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + break; - case 4: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ - (ue_context_pP->local_uid&1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) - break; + case 4: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7+ + (ue_context_pP->local_uid&1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + break; - default: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7; // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..) - break; + default: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7; // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..) + break; } } @@ -2028,7 +1829,6 @@ do_RRCConnectionSetup( //SchedulingRequestConfig__setup__dsr_TransMax_n4); // assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4; physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = LTE_SchedulingRequestConfig__setup__dsr_TransMax_n4; - rrcConnectionSetup->rrc_TransactionIdentifier = Transaction_id; rrcConnectionSetup->criticalExtensions.present = LTE_RRCConnectionSetup__criticalExtensions_PR_c1; rrcConnectionSetup->criticalExtensions.choice.c1.present = LTE_RRCConnectionSetup__criticalExtensions__c1_PR_rrcConnectionSetup_r8 ; @@ -2037,51 +1837,57 @@ do_RRCConnectionSetup( rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.drb_ToReleaseList = NULL; rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.sps_Config = NULL; rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.physicalConfigDedicated = physicalConfigDedicated2; - rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.mac_MainConfig = NULL; -#ifdef CBA - betaOffset_CBA_Index = CALLOC(1,sizeof(long)); - cShift_CBA = CALLOC(1,sizeof(long)); - *betaOffset_CBA_Index=10; // need to be changed by Kaijie - *cShift_CBA=4; - physicalConfigDedicated2->pusch_CBAConfigDedicated_vlola->betaOffset_CBA_Index=betaOffset_CBA_Index; - physicalConfigDedicated2->pusch_CBAConfigDedicated_vlola->cShift_CBA=cShift_CBA; - rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.sps_CBA_ConfigList_vlola = NULL; -#endif - + rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.mac_MainConfig = CALLOC(1,sizeof(struct LTE_RadioResourceConfigDedicated__mac_MainConfig)); + rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.mac_MainConfig->present = LTE_RadioResourceConfigDedicated__mac_MainConfig_PR_explicitValue; + LTE_MAC_MainConfig_t *mac_MainConfig = &rrcConnectionSetup->criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated.mac_MainConfig->choice.explicitValue; + mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config)); + long *maxHARQ_Tx = CALLOC(1, sizeof(long)); + *maxHARQ_Tx = LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + long *periodicBSR_Timer = CALLOC(1, sizeof(long)); + *periodicBSR_Timer = LTE_PeriodicBSR_Timer_r12_sf64; + mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx; + mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer; + mac_MainConfig->ul_SCH_Config->retxBSR_Timer = LTE_RetxBSR_Timer_r12_sf320; + mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE + mac_MainConfig->timeAlignmentTimerDedicated = LTE_TimeAlignmentTimer_infinity; + mac_MainConfig->drx_Config = NULL; + mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config)); + mac_MainConfig->phr_Config->present = LTE_MAC_MainConfig__phr_Config_PR_setup; + mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes + mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes + mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; // Value dB1 =1 dB, dB3 = 3 dB if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; - } + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } LOG_D(RRC,"RRCConnectionSetup Encoded %zd bits (%zd bytes) \n", enc_rval.encoded,(enc_rval.encoded+7)/8); - // FREEMEM(SRB_list); // free(SRB1_config); // free(SRB1_rlc_config); // free(SRB1_lchan_config); // free(SRB1_ul_SpecificParameters); - return((enc_rval.encoded+7)/8); } //------------------------------------------------------------------------------ uint8_t do_SecurityModeCommand( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id, const uint8_t cipheringAlgorithm, const uint8_t integrityProtAlgorithm @@ -2090,15 +1896,11 @@ do_SecurityModeCommand( { LTE_DL_DCCH_Message_t dl_dcch_msg; asn_enc_rval_t enc_rval; - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_securityModeCommand; - dl_dcch_msg.message.choice.c1.choice.securityModeCommand.rrc_TransactionIdentifier = Transaction_id; dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.present = LTE_SecurityModeCommand__criticalExtensions_PR_c1; - dl_dcch_msg.message.choice.c1.choice.securityModeCommand.criticalExtensions.choice.c1.present = LTE_SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8; // the two following information could be based on the mod_id @@ -2108,20 +1910,20 @@ do_SecurityModeCommand( = (e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm)integrityProtAlgorithm; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void*)&dl_dcch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; - } + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } LOG_D(RRC,"[eNB %d] securityModeCommand for UE %x Encoded %zd bits (%zd bytes)\n", ctxt_pP->module_id, @@ -2144,25 +1946,19 @@ do_SecurityModeCommand( //------------------------------------------------------------------------------ uint8_t do_UECapabilityEnquiry( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id ) //------------------------------------------------------------------------------ { - LTE_DL_DCCH_Message_t dl_dcch_msg; - LTE_RAT_Type_t rat=LTE_RAT_Type_eutra; asn_enc_rval_t enc_rval; - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry; - dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.rrc_TransactionIdentifier = Transaction_id; - dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.present = LTE_UECapabilityEnquiry__criticalExtensions_PR_c1; dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.present = LTE_UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8; @@ -2171,18 +1967,19 @@ do_UECapabilityEnquiry( &rat); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void*)&dl_dcch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } LOG_D(RRC,"[eNB %d] UECapabilityRequest for UE %x Encoded %zd bits (%zd bytes)\n", @@ -2204,7 +2001,7 @@ do_UECapabilityEnquiry( //------------------------------------------------------------------------------ uint16_t do_RRCConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, uint8_t Transaction_id, LTE_SRB_ToAddModList_t *SRB_list, @@ -2233,24 +2030,17 @@ do_RRCConnectionReconfiguration( ) //------------------------------------------------------------------------------ { - asn_enc_rval_t enc_rval; - LTE_DL_DCCH_Message_t dl_dcch_msg; LTE_RRCConnectionReconfiguration_t *rrcConnectionReconfiguration; - - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration; rrcConnectionReconfiguration = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionReconfiguration; - // RRCConnectionReconfiguration rrcConnectionReconfiguration->rrc_TransactionIdentifier = Transaction_id; rrcConnectionReconfiguration->criticalExtensions.present = LTE_RRCConnectionReconfiguration__criticalExtensions_PR_c1; rrcConnectionReconfiguration->criticalExtensions.choice.c1.present = LTE_RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8 ; - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated)); rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList = SRB_list; @@ -2277,9 +2067,8 @@ do_RRCConnectionReconfiguration( if (MeasId_list != NULL) { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig)); - memset((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig, + memset((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig, 0, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list; rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; @@ -2311,9 +2100,8 @@ do_RRCConnectionReconfiguration( if (mobilityInfo !=NULL) { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo = CALLOC(1, sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo)); - memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void*)mobilityInfo, + memcpy((void *)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo, (void *)mobilityInfo, sizeof(LTE_MobilityControlInfo_t)); - } else { rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo = NULL; } @@ -2324,108 +2112,109 @@ do_RRCConnectionReconfiguration( //TTN for D2D //allocate dedicated resource pools for SL communication (sl_CommConfig_r12) if (sl_CommConfig != NULL) { - LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL communication \n"); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12)); - memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, (void*)sl_CommConfig, - sizeof(LTE_SL_CommConfig_r12_t)); + LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL communication \n"); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12 + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12)); + memcpy((void *) + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_CommConfig_r12, + (void *)sl_CommConfig, + sizeof(LTE_SL_CommConfig_r12_t)); } //allocate dedicated resource pools for SL discovery (sl_DiscConfig) - if (sl_DiscConfig != NULL){ - LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL discovery \n"); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); - rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 = CALLOC(1, - sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12)); - memcpy((void*)rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12, (void*)sl_DiscConfig, - sizeof(LTE_SL_DiscConfig_r12_t)); + if (sl_DiscConfig != NULL) { + LOG_I(RRC,"[RRCConnectionReconfiguration] allocating a dedicated resource pool for SL discovery \n"); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension)); + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12 + = CALLOC(1, + sizeof(*rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12)); + memcpy((void *) + rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->sl_DiscConfig_r12, + (void *)sl_DiscConfig, + sizeof(LTE_SL_DiscConfig_r12_t)); } enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, RRC_BUF_SIZE); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout,&asn_DEF_LTE_DL_DCCH_Message,(void*)&dl_dcch_msg); + xer_fprint(stdout,&asn_DEF_LTE_DL_DCCH_Message,(void *)&dl_dcch_msg); } - LOG_I(RRC,"RRCConnectionReconfiguration Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); // for (i=0;i<30;i++) // msg("%x.",buffer[i]); // msg("\n"); - - return((enc_rval.encoded+7)/8); } //------------------------------------------------------------------------------ uint8_t do_RRCConnectionReestablishment( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, LTE_SRB_ToAddModList_t **SRB_configList, - struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) -{ + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated) { asn_enc_rval_t enc_rval; - - long* logicalchannelgroup = NULL; - struct LTE_SRB_ToAddMod* SRB1_config = NULL; - struct LTE_SRB_ToAddMod* SRB2_config = NULL; - struct LTE_SRB_ToAddMod__rlc_Config* SRB1_rlc_config = NULL; - struct LTE_SRB_ToAddMod__logicalChannelConfig* SRB1_lchan_config = NULL; - struct LTE_LogicalChannelConfig__ul_SpecificParameters* SRB1_ul_SpecificParameters = NULL; + long *logicalchannelgroup = NULL; + struct LTE_SRB_ToAddMod *SRB1_config = NULL; + struct LTE_SRB_ToAddMod *SRB2_config = NULL; + struct LTE_SRB_ToAddMod__rlc_Config *SRB1_rlc_config = NULL; + struct LTE_SRB_ToAddMod__logicalChannelConfig *SRB1_lchan_config = NULL; + struct LTE_LogicalChannelConfig__ul_SpecificParameters *SRB1_ul_SpecificParameters = NULL; eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; - #ifdef CBA - struct LTE_PUSCH_CBAConfigDedicated_vlola* pusch_CBAConfigDedicated_vlola = NULL; - long* betaOffset_CBA_Index = NULL; - long* cShift_CBA = NULL; + struct LTE_PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola = NULL; + long *betaOffset_CBA_Index = NULL; + long *cShift_CBA = NULL; #endif - LTE_PhysicalConfigDedicated_t* physicalConfigDedicated2 = NULL; - + LTE_PhysicalConfigDedicated_t *physicalConfigDedicated2 = NULL; LTE_DL_CCCH_Message_t dl_ccch_msg; - - LTE_RRCConnectionReestablishment_t* rrcConnectionReestablishment = NULL; - + LTE_RRCConnectionReestablishment_t *rrcConnectionReestablishment = NULL; int i = 0; LTE_SRB_ToAddModList_t **SRB_configList2 = NULL; SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[Transaction_id]; + if (*SRB_configList2) { free(*SRB_configList2); } - *SRB_configList2 = CALLOC(1, sizeof(LTE_SRB_ToAddModList_t)); + *SRB_configList2 = CALLOC(1, sizeof(LTE_SRB_ToAddModList_t)); memset((void *)&dl_ccch_msg, 0, sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment; @@ -2434,15 +2223,15 @@ do_RRCConnectionReestablishment( // RRCConnectionReestablishment // Configure SRB1 - // get old configuration of SRB2 if (*SRB_configList != NULL) { for (i = 0; (i < (*SRB_configList)->list.count) && (i < 3); i++) { LOG_D(RRC, "(*SRB_configList)->list.array[%d]->srb_Identity=%ld\n", - i, (*SRB_configList)->list.array[i]->srb_Identity); - if ((*SRB_configList)->list.array[i]->srb_Identity == 2 ){ + i, (*SRB_configList)->list.array[i]->srb_Identity); + + if ((*SRB_configList)->list.array[i]->srb_Identity == 2 ) { SRB2_config = (*SRB_configList)->list.array[i]; - } else if ((*SRB_configList)->list.array[i]->srb_Identity == 1 ){ + } else if ((*SRB_configList)->list.array[i]->srb_Identity == 1 ) { SRB1_config = (*SRB_configList)->list.array[i]; } } @@ -2453,44 +2242,36 @@ do_RRCConnectionReestablishment( LOG_W(RRC,"SRB1 configuration does not exist in SRB configuration list, use default\n"); /// SRB1 SRB1_config = CALLOC(1, sizeof(*SRB1_config)); - SRB1_config->srb_Identity = 1; SRB1_rlc_config = CALLOC(1, sizeof(*SRB1_rlc_config)); SRB1_config->rlc_Config = SRB1_rlc_config; - SRB1_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB1_rlc_config->choice.explicitValue.present=LTE_RLC_Config_PR_am; - #if defined(ENABLE_ITTI) +#if defined(ENABLE_ITTI) SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = rrc->srb1_timer_poll_retransmit; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = rrc->srb1_poll_pdu; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = rrc->srb1_poll_byte; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = rrc->srb1_max_retx_threshold; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = rrc->srb1_timer_reordering; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = rrc->srb1_timer_status_prohibit; - #else +#else SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms20;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p4;; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms0; - #endif - +#endif SRB1_lchan_config = CALLOC(1, sizeof(*SRB1_lchan_config)); SRB1_config->logicalChannelConfig = SRB1_lchan_config; - SRB1_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; SRB1_ul_SpecificParameters = CALLOC(1, sizeof(*SRB1_ul_SpecificParameters)); - SRB1_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB1_ul_SpecificParameters; SRB1_ul_SpecificParameters->priority = 1; - //assign_enum(&SRB1_ul_SpecificParameters->prioritisedBitRate,LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity); SRB1_ul_SpecificParameters->prioritisedBitRate=LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50); SRB1_ul_SpecificParameters->bucketSizeDuration=LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - logicalchannelgroup = CALLOC(1, sizeof(long)); *logicalchannelgroup = 0; SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; @@ -2507,11 +2288,8 @@ do_RRCConnectionReestablishment( } *SRB_configList = CALLOC(1, sizeof(LTE_SRB_ToAddModList_t)); - ASN_SEQUENCE_ADD(&(*SRB_configList)->list,SRB1_config); - physicalConfigDedicated2 = *physicalConfigDedicated; - rrcConnectionReestablishment->rrc_TransactionIdentifier = Transaction_id; rrcConnectionReestablishment->criticalExtensions.present = LTE_RRCConnectionReestablishment__criticalExtensions_PR_c1; rrcConnectionReestablishment->criticalExtensions.choice.c1.present = LTE_RRCConnectionReestablishment__criticalExtensions__c1_PR_rrcConnectionReestablishment_r8; @@ -2521,27 +2299,28 @@ do_RRCConnectionReestablishment( rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.sps_Config = NULL; rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.physicalConfigDedicated = physicalConfigDedicated2; rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.radioResourceConfigDedicated.mac_MainConfig = NULL; - uint8_t KeNB_star[32] = { 0 }; uint16_t pci = rrc->carrier[CC_id].physCellId; uint32_t earfcn_dl = (uint32_t)freq_to_arfcn10(RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, - rrc->carrier[CC_id].dl_CarrierFreq); + rrc->carrier[CC_id].dl_CarrierFreq); bool is_rel8_only = true; + if (earfcn_dl > 65535) { is_rel8_only = false; } LOG_D(RRC, "pci=%d, eutra_band=%d, downlink_frequency=%d, earfcn_dl=%u, is_rel8_only=%s\n", - pci, - RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, - rrc->carrier[CC_id].dl_CarrierFreq, - earfcn_dl, - is_rel8_only == true ? "true": "false"); + pci, + RC.mac[ctxt_pP->module_id]->common_channels[CC_id].eutra_band, + rrc->carrier[CC_id].dl_CarrierFreq, + earfcn_dl, + is_rel8_only == true ? "true": "false"); #if defined(ENABLE_SECURITY) + if (ue_context_pP->ue_context.nh_ncc >= 0) { derive_keNB_star(ue_context_pP->ue_context.nh, pci, earfcn_dl, is_rel8_only, KeNB_star); rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = ue_context_pP->ue_context.nh_ncc; - } else { // first HO + } else { // first HO derive_keNB_star (ue_context_pP->ue_context.kenb, pci, earfcn_dl, is_rel8_only, KeNB_star); // LG: really 1 rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0; @@ -2553,24 +2332,26 @@ do_RRCConnectionReestablishment( #else rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nextHopChainingCount = 0; #endif - rrcConnectionReestablishment->criticalExtensions.choice.c1.choice.rrcConnectionReestablishment_r8.nonCriticalExtension = NULL; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_E(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_E(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + LOG_D(RRC,"RRCConnectionReestablishment Encoded %u bits (%u bytes)\n", + (uint32_t)enc_rval.encoded, (uint32_t)(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); } @@ -2578,42 +2359,37 @@ do_RRCConnectionReestablishment( uint8_t do_RRCConnectionReestablishmentReject( uint8_t Mod_id, - uint8_t* const buffer) + uint8_t *const buffer) //------------------------------------------------------------------------------ { - asn_enc_rval_t enc_rval; - LTE_DL_CCCH_Message_t dl_ccch_msg; LTE_RRCConnectionReestablishmentReject_t *rrcConnectionReestablishmentReject; - memset((void *)&dl_ccch_msg,0,sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject; rrcConnectionReestablishmentReject = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReestablishmentReject; - // RRCConnectionReestablishmentReject rrcConnectionReestablishmentReject->criticalExtensions.present = LTE_RRCConnectionReestablishmentReject__criticalExtensions_PR_rrcConnectionReestablishmentReject_r8; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_E(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; - } + if(enc_rval.encoded == -1) { + LOG_E(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } LOG_D(RRC,"RRCConnectionReestablishmentReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); } @@ -2621,20 +2397,16 @@ do_RRCConnectionReestablishmentReject( uint8_t do_RRCConnectionReject( uint8_t Mod_id, - uint8_t* const buffer) + uint8_t *const buffer) //------------------------------------------------------------------------------ { - asn_enc_rval_t enc_rval; - LTE_DL_CCCH_Message_t dl_ccch_msg; LTE_RRCConnectionReject_t *rrcConnectionReject; - memset((void *)&dl_ccch_msg,0,sizeof(LTE_DL_CCCH_Message_t)); dl_ccch_msg.message.present = LTE_DL_CCCH_MessageType_PR_c1; dl_ccch_msg.message.choice.c1.present = LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionReject; rrcConnectionReject = &dl_ccch_msg.message.choice.c1.choice.rrcConnectionReject; - // RRCConnectionReject rrcConnectionReject->criticalExtensions.present = LTE_RRCConnectionReject__criticalExtensions_PR_c1; rrcConnectionReject->criticalExtensions.choice.c1.present = LTE_RRCConnectionReject__criticalExtensions__c1_PR_rrcConnectionReject_r8; @@ -2642,62 +2414,51 @@ do_RRCConnectionReject( rrcConnectionReject->criticalExtensions.choice.c1.choice.rrcConnectionReject_r8.waitTime = 1; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void*)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_LTE_DL_CCCH_Message, (void *)&dl_ccch_msg); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_CCCH_Message, NULL, - (void*)&dl_ccch_msg, + (void *)&dl_ccch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_E(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } LOG_D(RRC,"RRCConnectionReject Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); - return((enc_rval.encoded+7)/8); } uint8_t do_RRCConnectionRelease( uint8_t Mod_id, uint8_t *buffer, - uint8_t Transaction_id) -{ - + uint8_t Transaction_id) { asn_enc_rval_t enc_rval; - LTE_DL_DCCH_Message_t dl_dcch_msg; LTE_RRCConnectionRelease_t *rrcConnectionRelease; - - memset(&dl_dcch_msg,0,sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_rrcConnectionRelease; rrcConnectionRelease = &dl_dcch_msg.message.choice.c1.choice.rrcConnectionRelease; - // RRCConnectionRelease rrcConnectionRelease->rrc_TransactionIdentifier = Transaction_id; rrcConnectionRelease->criticalExtensions.present = LTE_RRCConnectionRelease__criticalExtensions_PR_c1; rrcConnectionRelease->criticalExtensions.choice.c1.present =LTE_RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8 ; - rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause = LTE_ReleaseCause_other; rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.redirectedCarrierInfo = NULL; rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.idleModeMobilityControlInfo = NULL; - rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.nonCriticalExtension=CALLOC(1, sizeof(*rrcConnectionRelease->criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.nonCriticalExtension)); - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_DL_DCCH_Message, NULL, - (void*)&dl_dcch_msg, + (void *)&dl_dcch_msg, buffer, RRC_BUF_SIZE); - return((enc_rval.encoded+7)/8); } @@ -2709,9 +2470,7 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, uint8_t sync_area, uint8_t *buffer, LTE_MCCH_Message_t *mcch_message, - LTE_MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration) -{ - + LTE_MBSFNAreaConfiguration_r9_t **mbsfnAreaConfiguration) { asn_enc_rval_t enc_rval; LTE_MBSFN_SubframeConfig_t *mbsfn_SubframeConfig1; LTE_PMCH_Info_r9_t *pmch_Info_1; @@ -2719,17 +2478,13 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, // MBMS_SessionInfo_r9_t *mbms_Session_2; eNB_RRC_INST *rrc = RC.rrc[Mod_id]; rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0]; - - memset(mcch_message,0,sizeof(LTE_MCCH_Message_t)); mcch_message->message.present = LTE_MCCH_MessageType_PR_c1; mcch_message->message.choice.c1.present = LTE_MCCH_MessageType__c1_PR_mbsfnAreaConfiguration_r9; *mbsfnAreaConfiguration = &mcch_message->message.choice.c1.choice.mbsfnAreaConfiguration_r9; - // Common Subframe Allocation (CommonSF-Alloc-r9) - mbsfn_SubframeConfig1= CALLOC(1,sizeof(*mbsfn_SubframeConfig1)); - memset((void*)mbsfn_SubframeConfig1,0,sizeof(*mbsfn_SubframeConfig1)); + memset((void *)mbsfn_SubframeConfig1,0,sizeof(*mbsfn_SubframeConfig1)); // mbsfn_SubframeConfig1->radioframeAllocationPeriod= LTE_MBSFN_SubframeConfig__radioframeAllocationPeriod_n4; mbsfn_SubframeConfig1->radioframeAllocationOffset= 1; @@ -2740,36 +2495,33 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, // CURRENTLY WE ARE SUPPORITNG ONLY ONE sf ALLOCATION switch (sync_area) { - case 0: - if (carrier->sib1->tdd_Config != NULL) {// pattern 001110 for TDD - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. - } else { //111000 - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2; - } + case 0: + if (carrier->sib1->tdd_Config != NULL) {// pattern 001110 for TDD + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. + } else { //111000 + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x38<<2; + } - break; + break; - case 1: - if (carrier->sib1->tdd_Config != NULL) { - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. - } else { // 000111 - mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2; - } + case 1: + if (carrier->sib1->tdd_Config != NULL) { + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x08<<2;// shift 2bits cuz 2last bits are unused. + } else { // 000111 + mbsfn_SubframeConfig1->subframeAllocation.choice.oneFrame.buf[0]=0x07<<2; + } - default : - break; + default : + break; } ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->commonSF_Alloc_r9.list,mbsfn_SubframeConfig1); - // commonSF-AllocPeriod-r9 (*mbsfnAreaConfiguration)->commonSF_AllocPeriod_r9= LTE_MBSFNAreaConfiguration_r9__commonSF_AllocPeriod_r9_rf16; - // PMCHs Information List (PMCH-InfoList-r9) // PMCH_1 Config pmch_Info_1 = CALLOC(1,sizeof(LTE_PMCH_Info_r9_t)); - memset((void*)pmch_Info_1,0,sizeof(LTE_PMCH_Info_r9_t)); - + memset((void *)pmch_Info_1,0,sizeof(LTE_PMCH_Info_r9_t)); /* * take the value of last mbsfn subframe in this CSA period because there is only one PMCH in this mbsfn area * Note: this has to be set based on the subframeAllocation and CSA @@ -2777,7 +2529,6 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, pmch_Info_1->pmch_Config_r9.sf_AllocEnd_r9= 3; pmch_Info_1->pmch_Config_r9.dataMCS_r9= 7; pmch_Info_1->pmch_Config_r9.mch_SchedulingPeriod_r9= LTE_PMCH_Config_r9__mch_SchedulingPeriod_r9_rf16; - // MBMSs-SessionInfoList-r9 // pmch_Info_1->mbms_SessionInfoList_r9 = CALLOC(1,sizeof(struct MBMS_SessionInfoList_r9)); // Session 1 @@ -2788,7 +2539,7 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, mbms_Session_1->tmgi_r9.plmn_Id_r9.choice.plmn_Index_r9= 1; // Service ID memset(&mbms_Session_1->tmgi_r9.serviceId_r9,0,sizeof(OCTET_STRING_t));// need to check - OCTET_STRING_fromBuf(&mbms_Session_1->tmgi_r9.serviceId_r9,(const char*)&TMGI[2],3); + OCTET_STRING_fromBuf(&mbms_Session_1->tmgi_r9.serviceId_r9,(const char *)&TMGI[2],3); // Session ID is still missing here, it can be used as an rab id or mrb id mbms_Session_1->sessionId_r9 = CALLOC(1,sizeof(OCTET_STRING_t)); mbms_Session_1->sessionId_r9->buf= MALLOC(1); @@ -2797,7 +2548,6 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, // Logical Channel ID mbms_Session_1->logicalChannelIdentity_r9= MTCH; ASN_SEQUENCE_ADD(&pmch_Info_1->mbms_SessionInfoList_r9.list,mbms_Session_1); - /* // Session 2 //mbms_Session_2 = CALLOC(1,sizeof(MBMS_SessionInfo_r9_t)); memset(mbms_Session_2,0,sizeof(MBMS_SessionInfo_r9_t)); @@ -2818,18 +2568,19 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, ASN_SEQUENCE_ADD(&(*mbsfnAreaConfiguration)->pmch_InfoList_r9.list,pmch_Info_1); if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout,&asn_DEF_LTE_MCCH_Message,(void*)mcch_message); + xer_fprint(stdout,&asn_DEF_LTE_MCCH_Message,(void *)mcch_message); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_MCCH_Message, NULL, - (void*)mcch_message, + (void *)mcch_message, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } LOG_D(RRC,"[eNB] MCCH Message Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); @@ -2843,24 +2594,17 @@ uint8_t do_MBSFNAreaConfig(uint8_t Mod_id, } #endif -uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t) -{ - +uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_id,long rsrp_s,long rsrq_s,long rsrp_t,long rsrq_t) { asn_enc_rval_t enc_rval; - LTE_UL_DCCH_Message_t ul_dcch_msg; - LTE_MeasurementReport_t *measurementReport; - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_measurementReport; measurementReport = &ul_dcch_msg.message.choice.c1.choice.measurementReport; - measurementReport->criticalExtensions.present=LTE_MeasurementReport__criticalExtensions_PR_c1; measurementReport->criticalExtensions.choice.c1.present=LTE_MeasurementReport__criticalExtensions__c1_PR_measurementReport_r8; measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension=CALLOC(1, sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.nonCriticalExtension)); - measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measId=measid; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultPCell.rsrpResult=rsrp_s; @@ -2872,24 +2616,17 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells=CALLOC(1, sizeof(*measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells)); measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->present=LTE_MeasResults__measResultNeighCells_PR_measResultListEUTRA; - LTE_MeasResultListEUTRA_t *measResultListEUTRA2; measResultListEUTRA2 = CALLOC(1,sizeof(*measResultListEUTRA2)); - struct LTE_MeasResultEUTRA *measresulteutra2; measresulteutra2 = CALLOC(1,sizeof(*measresulteutra2)); measresulteutra2->physCellId=phy_id;//1; - struct LTE_MeasResultEUTRA__cgi_Info *measresult_cgi2; measresult_cgi2 = CALLOC(1,sizeof(*measresult_cgi2)); - memset(&measresult_cgi2->cellGlobalId.plmn_Identity,0,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity)); - // measresult_cgi2->cellGlobalId.plmn_Identity.mcc=CALLOC(1,sizeof(measresult_cgi2->cellGlobalId.plmn_Identity.mcc)); measresult_cgi2->cellGlobalId.plmn_Identity.mcc = CALLOC(1, sizeof(*measresult_cgi2->cellGlobalId.plmn_Identity.mcc)); - asn_set_empty(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list);//.size=0; - LTE_MCC_MNC_Digit_t dummy; dummy=2; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy); @@ -2897,14 +2634,12 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy); dummy=2; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mcc->list,&dummy); - measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.size=0; measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list.count=0; dummy=8; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy); dummy=0; ASN_SEQUENCE_ADD(&measresult_cgi2->cellGlobalId.plmn_Identity.mnc.list,&dummy); - measresult_cgi2->cellGlobalId.cellIdentity.buf=MALLOC(8); measresult_cgi2->cellGlobalId.cellIdentity.buf[0]=0x01; measresult_cgi2->cellGlobalId.cellIdentity.buf[1]=0x48; @@ -2912,57 +2647,44 @@ uint8_t do_MeasurementReport(uint8_t Mod_id, uint8_t *buffer,int measid,int phy_ measresult_cgi2->cellGlobalId.cellIdentity.buf[3]=0x03; measresult_cgi2->cellGlobalId.cellIdentity.size=4; measresult_cgi2->cellGlobalId.cellIdentity.bits_unused=4; - measresult_cgi2->trackingAreaCode.buf = MALLOC(2); measresult_cgi2->trackingAreaCode.buf[0]=0x00; measresult_cgi2->trackingAreaCode.buf[1]=0x10; measresult_cgi2->trackingAreaCode.size=2; measresult_cgi2->trackingAreaCode.bits_unused=0; - - measresulteutra2->cgi_Info=measresult_cgi2; - struct LTE_MeasResultEUTRA__measResult meas2; // int rsrp_va=10; - meas2.rsrpResult=&(rsrp_t); //&rsrp_va; meas2.rsrqResult=&(rsrq_t); - measresulteutra2->measResult=meas2; - ASN_SEQUENCE_ADD(&measResultListEUTRA2->list,measresulteutra2); - measurementReport->criticalExtensions.choice.c1.choice.measurementReport_r8.measResults.measResultNeighCells->choice.measResultListEUTRA=*(measResultListEUTRA2); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void*)&ul_dcch_msg); + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); } - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, - (void*)&ul_dcch_msg, + (void *)&ul_dcch_msg, buffer, 100); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; - } + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; + } return((enc_rval.encoded+7)/8); } -uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer) -{ +uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t transaction_id, uint32_t pdu_length, uint8_t *pdu_buffer) { ssize_t encoded; - LTE_DL_DCCH_Message_t dl_dcch_msg; - memset(&dl_dcch_msg, 0, sizeof(LTE_DL_DCCH_Message_t)); - dl_dcch_msg.message.present = LTE_DL_DCCH_MessageType_PR_c1; dl_dcch_msg.message.choice.c1.present = LTE_DL_DCCH_MessageType__c1_PR_dlInformationTransfer; dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.rrc_TransactionIdentifier = transaction_id; @@ -2972,31 +2694,22 @@ uint8_t do_DLInformationTransfer(uint8_t Mod_id, uint8_t **buffer, uint8_t trans LTE_DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS; dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length; dl_dcch_msg.message.choice.c1.choice.dlInformationTransfer.criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer; - - encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_DL_DCCH_Message, NULL, (void*) &dl_dcch_msg, (void **) buffer); - - + encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **) buffer); return encoded; } -uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain) -{ +uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_paging_identity, cn_domain_t cn_domain) { LOG_D(RRC, "[eNB %d] do_Paging start\n", Mod_id); asn_enc_rval_t enc_rval; - LTE_PCCH_Message_t pcch_msg; LTE_PagingRecord_t *paging_record_p; int j; - pcch_msg.message.present = LTE_PCCH_MessageType_PR_c1; pcch_msg.message.choice.c1.present = LTE_PCCH_MessageType__c1_PR_paging; - pcch_msg.message.choice.c1.choice.paging.pagingRecordList = CALLOC(1,sizeof(*pcch_msg.message.choice.c1.choice.paging.pagingRecordList)); - pcch_msg.message.choice.c1.choice.paging.systemInfoModification = NULL; pcch_msg.message.choice.c1.choice.paging.etws_Indication = NULL; pcch_msg.message.choice.c1.choice.paging.nonCriticalExtension = NULL; - asn_set_empty(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list); pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count = 0; @@ -3014,11 +2727,12 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin &paging_record_p->ue_Identity.choice.s_TMSI.mmec); paging_record_p->ue_Identity.choice.s_TMSI.mmec.bits_unused = 0; M_TMSI_TO_OCTET_STRING(ue_paging_identity.choice.s_tmsi.m_tmsi, - &paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI); + &paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI); paging_record_p->ue_Identity.choice.s_TMSI.m_TMSI.bits_unused = 0; } else if (ue_paging_identity.presenceMask == UE_PAGING_IDENTITY_imsi) { paging_record_p->ue_Identity.present = LTE_PagingUE_Identity_PR_imsi; LTE_IMSI_Digit_t imsi_digit[21]; + for (j = 0; j< ue_paging_identity.choice.imsi.length; j++) { /* IMSI size */ imsi_digit[j] = (LTE_IMSI_Digit_t)ue_paging_identity.choice.imsi.buffer[j]; ASN_SEQUENCE_ADD(&paging_record_p->ue_Identity.choice.imsi.list, &imsi_digit[j]); @@ -3031,33 +2745,30 @@ uint8_t do_Paging(uint8_t Mod_id, uint8_t *buffer, ue_paging_identity_t ue_pagin } else { paging_record_p->cn_Domain = LTE_PagingRecord__cn_Domain_cs; } + /* add to list */ ASN_SEQUENCE_ADD(&pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list, paging_record_p); LOG_D(RRC, "[eNB %d] do_Paging paging_record: cn_Domain %ld, ue_paging_identity.presenceMask %d, PagingRecordList.count %d\n", - Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); + Mod_id, paging_record_p->cn_Domain, ue_paging_identity.presenceMask, pcch_msg.message.choice.c1.choice.paging.pagingRecordList->list.count); + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_PCCH_Message, NULL, (void *)&pcch_msg, buffer, RRC_BUF_SIZE); - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_PCCH_Message, NULL, (void*)&pcch_msg, buffer, RRC_BUF_SIZE); - if(enc_rval.encoded == -1) - { - LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - return -1; + if(enc_rval.encoded == -1) { + LOG_I(RRC, "[eNB AssertFatal]ASN1 message encoding failed (%s, %lu)!\n", + enc_rval.failed_type->name, enc_rval.encoded); + return -1; } + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_PCCH_Message, (void*)&pcch_msg); + xer_fprint(stdout, &asn_DEF_LTE_PCCH_Message, (void *)&pcch_msg); } return((enc_rval.encoded+7)/8); } -uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer) -{ +uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t *pdu_buffer) { ssize_t encoded; - LTE_UL_DCCH_Message_t ul_dcch_msg; - memset(&ul_dcch_msg, 0, sizeof(LTE_UL_DCCH_Message_t)); - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer; ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.present = LTE_ULInformationTransfer__criticalExtensions_PR_c1; @@ -3066,33 +2777,24 @@ uint8_t do_ULInformationTransfer(uint8_t **buffer, uint32_t pdu_length, uint8_t LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS; ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.size = pdu_length; ul_dcch_msg.message.choice.c1.choice.ulInformationTransfer.criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.choice.dedicatedInfoNAS.buf = pdu_buffer; - - encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_UL_DCCH_Message, NULL, (void*) &ul_dcch_msg, (void **) buffer); - + encoded = uper_encode_to_new_buffer (&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, (void **) buffer); return encoded; } -OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) -{ +OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) { static OAI_UECapability_t UECapability; /* TODO declared static to allow returning this has an address should be allocated in a cleaner way. */ static LTE_SupportedBandEUTRA_t Bandlist[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it static LTE_InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it static LTE_BandInfoEUTRA_t BandInfoEUTRA[4]; // the macro ASN_SEQUENCE_ADD() does not copy the source, but only stores a reference to it - asn_enc_rval_t enc_rval; asn_dec_rval_t dec_rval; - long maxNumberROHC_ContextSessions = LTE_PDCP_Parameters__maxNumberROHC_ContextSessions_cs16; int i; - LTE_UE_EUTRA_Capability_t *UE_EUTRA_Capability; char UE_EUTRA_Capability_xer[8192]; size_t size; - LOG_I(RRC,"Allocating %zu bytes for UE_EUTRA_Capability\n",sizeof(*UE_EUTRA_Capability)); - UE_EUTRA_Capability = CALLOC(1, sizeof(*UE_EUTRA_Capability)); - assert(UE_EUTRA_Capability); if (!UE_EUTRA_Capability_xer_fname) { @@ -3104,10 +2806,8 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) Bandlist[2].halfDuplex = 0; Bandlist[3].bandEUTRA = 38; // UL/DL 2570-2620, TDD Bandlist[3].halfDuplex = 0; - - memset((void*)InterFreqBandInfo, 0, sizeof(InterFreqBandInfo)); - memset((void*)BandInfoEUTRA, 0, sizeof(BandInfoEUTRA)); - + memset((void *)InterFreqBandInfo, 0, sizeof(InterFreqBandInfo)); + memset((void *)BandInfoEUTRA, 0, sizeof(BandInfoEUTRA)); InterFreqBandInfo[0][0].interFreqNeedForGaps = 0; InterFreqBandInfo[0][1].interFreqNeedForGaps = 1; InterFreqBandInfo[0][2].interFreqNeedForGaps = 1; @@ -3124,8 +2824,6 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) InterFreqBandInfo[3][1].interFreqNeedForGaps = 1; InterFreqBandInfo[3][2].interFreqNeedForGaps = 1; InterFreqBandInfo[3][3].interFreqNeedForGaps = 0; - - UE_EUTRA_Capability->accessStratumRelease = 0;//AccessStratumRelease_rel8; UE_EUTRA_Capability->ue_Category = 4; UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0001=0; @@ -3137,47 +2835,39 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0102=0; UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0103=0; UE_EUTRA_Capability->pdcp_Parameters.supportedROHC_Profiles.profile0x0104=0; - UE_EUTRA_Capability->pdcp_Parameters.maxNumberROHC_ContextSessions = &maxNumberROHC_ContextSessions; - UE_EUTRA_Capability->phyLayerParameters.ue_TxAntennaSelectionSupported = 0; UE_EUTRA_Capability->phyLayerParameters.ue_SpecificRefSigsSupported = 0; UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list.count = 0; - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void*)&Bandlist[3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void*)&BandInfoEUTRA[3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void*)&InterFreqBandInfo[0][3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void*)&InterFreqBandInfo[1][3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void*)&InterFreqBandInfo[2][3]); - - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][0]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][1]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][2]); - ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void*)&InterFreqBandInfo[3][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->rf_Parameters.supportedBandListEUTRA.list,(void *)&Bandlist[3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list,(void *)&BandInfoEUTRA[3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[0]->interFreqBandList.list,(void *)&InterFreqBandInfo[0][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[1]->interFreqBandList.list,(void *)&InterFreqBandInfo[1][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[2]->interFreqBandList.list,(void *)&InterFreqBandInfo[2][3]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][0]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][1]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][2]); + ASN_SEQUENCE_ADD(&UE_EUTRA_Capability->measParameters.bandListEUTRA.list.array[3]->interFreqBandList.list,(void *)&InterFreqBandInfo[3][3]); // UE_EUTRA_Capability->measParameters.bandListEUTRA.list.count = 0; // no measurements on other bands // UE_EUTRA_Capability->featureGroupIndicators // null - if(get_softmodem_params()->usim_test == 1) - { + if (get_softmodem_params()->usim_test == 1) { // featureGroup is mandatory for CMW tests // featureGroup is filled only for usim-test mode BIT_STRING_t *bit_string = CALLOC(1, sizeof(*bit_string)); @@ -3191,8 +2881,7 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) // UE_EUTRA_Capability->interRAT_Parameters // null } else { - - FILE* f = fopen(UE_EUTRA_Capability_xer_fname, "r"); + FILE *f = fopen(UE_EUTRA_Capability_xer_fname, "r"); assert(f); size = fread(UE_EUTRA_Capability_xer, 1, sizeof UE_EUTRA_Capability_xer, f); fclose(f); @@ -3203,24 +2892,23 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) return(NULL); } - dec_rval = xer_decode(0, &asn_DEF_LTE_UE_EUTRA_Capability, (void*)UE_EUTRA_Capability, UE_EUTRA_Capability_xer, size); + dec_rval = xer_decode(0, &asn_DEF_LTE_UE_EUTRA_Capability, (void *)UE_EUTRA_Capability, UE_EUTRA_Capability_xer, size); assert(dec_rval.code == RC_OK); } UECapability.UE_EUTRA_Capability = UE_EUTRA_Capability; + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout,&asn_DEF_LTE_UE_EUTRA_Capability,(void *)UE_EUTRA_Capability); + xer_fprint(stdout,&asn_DEF_LTE_UE_EUTRA_Capability,(void *)UE_EUTRA_Capability); } + enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UE_EUTRA_Capability, NULL, - (void*)UE_EUTRA_Capability, + (void *)UE_EUTRA_Capability, &UECapability.sdu[0], MAX_UE_CAPABILITY_SIZE); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded); - - - UECapability.sdu_size = (enc_rval.encoded + 7) / 8; LOG_I(PHY, "[RRC]UE Capability encoded, %d bytes (%zd bits)\n", UECapability.sdu_size, enc_rval.encoded + 7); @@ -3235,7 +2923,6 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) LOG_D(PHY, "[RRC]UE Capability encoded, %s\n", sdu); free(sdu); } - return(&UECapability); } diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h index 690b3e852573efcf738b7f3522458da2df8f7acd..2d0c6ba7b6298a8ffe700b12ad3e08a62d79ed41 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -57,7 +57,7 @@ uint16_t get_adjacent_cell_id(uint8_t Mod_id,uint8_t index); uint8_t get_adjacent_cell_mod_id(uint16_t phyCellId); /** -\brief Generate configuration for SIB1 (eNB). +\brief Generate configuration for MIB (eNB). @param carrier pointer to Carrier information @param N_RB_DL Number of downlink PRBs @param phich_Resource PHICH resoure parameter @@ -71,7 +71,7 @@ uint8_t do_MIB(rrc_eNB_carrier_data_t *carrier, uint32_t N_RB_DL, uint32_t phich @param carrier pointer to Carrier information @param Mod_id Instance of eNB @param Component carrier Component carrier to configure -@param configuration Pointer Configuration Request structure +@param configuration Pointer Configuration Request structure @return size of encoded bit stream in bytes*/ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id, RrcConfigurationReq *configuration @@ -91,7 +91,7 @@ uint8_t do_SIB1(rrc_eNB_carrier_data_t *carrier,int Mod_id,int CC_id, RrcConfigu uint8_t do_SIB23(uint8_t Mod_id, int CC_id #if defined(ENABLE_ITTI) - , RrcConfigurationReq *configuration + , RrcConfigurationReq *configuration #endif ); @@ -115,16 +115,16 @@ uint8_t do_SidelinkUEInformation(uint8_t Mod_id, uint8_t *buffer, LTE_SL_Destina /** \brief Generate an RRCConnectionSetupComplete UL-DCCH-Message (UE) @param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU @returns Size of encoded bit stream in bytes*/ -uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t* buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, - const char* dedicatedInfoNAS); +uint8_t do_RRCConnectionSetupComplete(uint8_t Mod_id, uint8_t *buffer, const uint8_t Transaction_id, const int dedicatedInfoNASLength, + const char *dedicatedInfoNAS); /** \brief Generate an RRCConnectionReconfigurationComplete UL-DCCH-Message (UE) @param buffer Pointer to PER-encoded ASN.1 description of UL-DCCH-Message PDU @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReconfigurationComplete( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, const uint8_t Transaction_id ); @@ -143,14 +143,14 @@ PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionSetup( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, - LTE_SRB_ToAddModList_t** SRB_configList, - struct LTE_PhysicalConfigDedicated** physicalConfigDedicated + LTE_SRB_ToAddModList_t **SRB_configList, + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated ); /** @@ -177,31 +177,31 @@ do_RRCConnectionSetup( uint16_t do_RRCConnectionReconfiguration( - const protocol_ctxt_t* const ctxt_pP, - uint8_t *buffer, - uint8_t Transaction_id, - LTE_SRB_ToAddModList_t *SRB_list, - LTE_DRB_ToAddModList_t *DRB_list, - LTE_DRB_ToReleaseList_t *DRB_list2, - struct LTE_SPS_Config *sps_Config, - struct LTE_PhysicalConfigDedicated *physicalConfigDedicated, - LTE_MeasObjectToAddModList_t *MeasObj_list, - LTE_ReportConfigToAddModList_t *ReportConfig_list, - LTE_QuantityConfig_t *quantityConfig, - LTE_MeasIdToAddModList_t *MeasId_list, - LTE_MAC_MainConfig_t *mac_MainConfig, - LTE_MeasGapConfig_t *measGapConfig, - LTE_MobilityControlInfo_t *mobilityInfo, - struct LTE_MeasConfig__speedStatePars *speedStatePars, - LTE_RSRP_Range_t *rsrp, - LTE_C_RNTI_t *cba_rnti, - struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList* dedicatedInfoNASList, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *buffer, + uint8_t Transaction_id, + LTE_SRB_ToAddModList_t *SRB_list, + LTE_DRB_ToAddModList_t *DRB_list, + LTE_DRB_ToReleaseList_t *DRB_list2, + struct LTE_SPS_Config *sps_Config, + struct LTE_PhysicalConfigDedicated *physicalConfigDedicated, + LTE_MeasObjectToAddModList_t *MeasObj_list, + LTE_ReportConfigToAddModList_t *ReportConfig_list, + LTE_QuantityConfig_t *quantityConfig, + LTE_MeasIdToAddModList_t *MeasId_list, + LTE_MAC_MainConfig_t *mac_MainConfig, + LTE_MeasGapConfig_t *measGapConfig, + LTE_MobilityControlInfo_t *mobilityInfo, + struct LTE_MeasConfig__speedStatePars *speedStatePars, + LTE_RSRP_Range_t *rsrp, + LTE_C_RNTI_t *cba_rnti, + struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList, LTE_SL_CommConfig_r12_t *sl_CommConfig, LTE_SL_DiscConfig_r12_t *sl_DiscConfig #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , LTE_SCellToAddMod_r10_t *SCell_config + , LTE_SCellToAddMod_r10_t *SCell_config #endif - ); +); /** \brief Generate an RRCConnectionReestablishment DL-CCCH-Message (eNB). This routine configures SRB_ToAddMod (SRB1/SRB2) and PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting (PUCCH format 2/2a/2b) or SRS. @@ -216,10 +216,10 @@ PhysicalConfigDedicated IEs. The latter does not enable periodic CQI reporting @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReestablishment( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, int CC_id, - uint8_t* const buffer, + uint8_t *const buffer, const uint8_t transmission_mode, const uint8_t Transaction_id, LTE_SRB_ToAddModList_t **SRB_configList, @@ -232,8 +232,8 @@ do_RRCConnectionReestablishment( @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReestablishmentReject( - uint8_t Mod_id, - uint8_t* const buffer); + uint8_t Mod_id, + uint8_t *const buffer); /** \brief Generate an RRCConnectionReject DL-CCCH-Message (eNB). @@ -242,8 +242,8 @@ do_RRCConnectionReestablishmentReject( @returns Size of encoded bit stream in bytes*/ uint8_t do_RRCConnectionReject( - uint8_t Mod_id, - uint8_t* const buffer); + uint8_t Mod_id, + uint8_t *const buffer); /** \brief Generate an RRCConnectionRequest UL-CCCH-Message (UE) based on random string or S-TMSI. This @@ -286,14 +286,14 @@ OAI_UECapability_t *fill_ue_capability(char *LTE_UE_EUTRA_Capability_xer); uint8_t do_UECapabilityEnquiry( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id ); uint8_t do_SecurityModeCommand( - const protocol_ctxt_t* const ctxt_pP, - uint8_t* const buffer, + const protocol_ctxt_t *const ctxt_pP, + uint8_t *const buffer, const uint8_t Transaction_id, const uint8_t cipheringAlgorithm, const uint8_t integrityProtAlgorithm); diff --git a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 index b6f64a99ed835e7e320475b740e3b210ed07c242..ceb4a7cd3744b2c9c5d0400fb7a1201acf6943e3 100755 --- a/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 +++ b/openair2/RRC/LTE/MESSAGES/asn1c/ASN1_files/lte-rrc-13.9.1.asn1 @@ -735,7 +735,7 @@ Paging-v1130-IEs ::= SEQUENCE { } Paging-v1310-IEs ::= SEQUENCE { - redistributionIndication-r13 ENUMERATED {true} OPTIONAL, --Need ON + redistributionIndication-r13 ENUMERATED {true} OPTIONAL, -- Need ON systemInfoModification-eDRX-r13 ENUMERATED {true} OPTIONAL, -- Need ON nonCriticalExtension SEQUENCE {} OPTIONAL } diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index 5e7beb7b76cf694f98ac9a115afc9c2e4f3727d7..9d428830860a5d80127476ad958141f0143ad295 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -64,10 +64,10 @@ #define IPV4_ADDR "%u.%u.%u.%u" #define IPV4_ADDR_FORMAT(aDDRESS) \ - (uint8_t)((aDDRESS) & 0x000000ff), \ - (uint8_t)(((aDDRESS) & 0x0000ff00) >> 8 ), \ - (uint8_t)(((aDDRESS) & 0x00ff0000) >> 16), \ - (uint8_t)(((aDDRESS) & 0xff000000) >> 24) + (uint8_t)((aDDRESS) & 0x000000ff), \ + (uint8_t)(((aDDRESS) & 0x0000ff00) >> 8 ), \ + (uint8_t)(((aDDRESS) & 0x00ff0000) >> 16), \ + (uint8_t)(((aDDRESS) & 0xff000000) >> 24) //----------------------------------------------------- @@ -84,74 +84,74 @@ #define GROUP_COMMUNICATION_RELEASE_RSP 8 #define PC5S_ESTABLISH_REQ 9 #define PC5S_ESTABLISH_RSP 10 -#define PC5_DISCOVERY_MESSAGE 11 +#define PC5_DISCOVERY_MESSAGE 11 -#define PC5_DISCOVERY_PAYLOAD_SIZE 29 +#define PC5_DISCOVERY_PAYLOAD_SIZE 29 typedef enum { - UE_STATE_OFF_NETWORK, - UE_STATE_ON_NETWORK + UE_STATE_OFF_NETWORK, + UE_STATE_ON_NETWORK } SL_UE_STATE_t; typedef enum { - GROUP_COMMUNICATION_RELEASE_OK = 0, - GROUP_COMMUNICATION_RELEASE_FAILURE + GROUP_COMMUNICATION_RELEASE_OK = 0, + GROUP_COMMUNICATION_RELEASE_FAILURE } Group_Communication_Status_t; struct GroupCommunicationEstablishReq { - uint32_t sourceL2Id; - uint32_t groupL2Id; - uint32_t groupIpAddress; - uint8_t pppp; + uint32_t sourceL2Id; + uint32_t groupL2Id; + uint32_t groupIpAddress; + uint8_t pppp; }; struct GroupCommunicationReleaseReq { - uint32_t sourceL2Id; - uint32_t groupL2Id; - int slrb_id; + uint32_t sourceL2Id; + uint32_t groupL2Id; + int slrb_id; }; struct DirectCommunicationEstablishReq { - uint32_t sourceL2Id; - uint32_t destinationL2Id; - uint32_t pppp; + uint32_t sourceL2Id; + uint32_t destinationL2Id; + uint32_t pppp; }; -struct PC5SEstablishReq{ - uint8_t type; - uint32_t sourceL2Id; - uint32_t destinationL2Id; +struct PC5SEstablishReq { + uint8_t type; + uint32_t sourceL2Id; + uint32_t destinationL2Id; }; -struct PC5SEstablishRsp{ - uint32_t slrbid_lcid28; - uint32_t slrbid_lcid29; - uint32_t slrbid_lcid30; +struct PC5SEstablishRsp { + uint32_t slrbid_lcid28; + uint32_t slrbid_lcid29; + uint32_t slrbid_lcid30; }; //PC5_DISCOVERY MESSAGE typedef struct { - unsigned char payload[PC5_DISCOVERY_PAYLOAD_SIZE]; - uint32_t measuredPower; + unsigned char payload[PC5_DISCOVERY_PAYLOAD_SIZE]; + uint32_t measuredPower; } __attribute__((__packed__)) PC5DiscoveryMessage ; struct sidelink_ctrl_element { - unsigned short type; - union { - struct GroupCommunicationEstablishReq group_comm_establish_req; - struct DirectCommunicationEstablishReq direct_comm_establish_req; - Group_Communication_Status_t group_comm_release_rsp; - //struct DirectCommunicationReleaseReq direct_comm_release_req; - SL_UE_STATE_t ue_state; - int slrb_id; - struct PC5SEstablishReq pc5s_establish_req; - struct PC5SEstablishRsp pc5s_establish_rsp; - PC5DiscoveryMessage pc5_discovery_message; - } sidelinkPrimitive; + unsigned short type; + union { + struct GroupCommunicationEstablishReq group_comm_establish_req; + struct DirectCommunicationEstablishReq direct_comm_establish_req; + Group_Communication_Status_t group_comm_release_rsp; + //struct DirectCommunicationReleaseReq direct_comm_release_req; + SL_UE_STATE_t ue_state; + int slrb_id; + struct PC5SEstablishReq pc5s_establish_req; + struct PC5SEstablishRsp pc5s_establish_rsp; + PC5DiscoveryMessage pc5_discovery_message; + } sidelinkPrimitive; }; @@ -167,7 +167,7 @@ void *send_UE_status_notification(void *); //#include "COMMON/openair_defs.h" #ifndef USER_MODE -//#include <rtai.h> + //#include <rtai.h> #endif #include "LTE_SystemInformationBlockType1.h" @@ -182,18 +182,18 @@ void *send_UE_status_notification(void *); #include "LTE_SBCCH-SL-BCH-MessageType.h" #include "LTE_BCCH-BCH-Message.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) -#include "LTE_MCCH-Message.h" -#include "LTE_MBSFNAreaConfiguration-r9.h" + #include "LTE_MCCH-Message.h" + #include "LTE_MBSFNAreaConfiguration-r9.h" #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) -#include "LTE_SCellToAddMod-r10.h" + #include "LTE_SCellToAddMod-r10.h" #endif #include "LTE_AS-Config.h" #include "LTE_AS-Context.h" #include "LTE_UE-EUTRA-Capability.h" #include "LTE_MeasResults.h" #if (LTE_RRC_VERSION >= MAKE_VERSION(12, 0, 0)) -#include "LTE_SidelinkUEInformation-r12.h" + #include "LTE_SidelinkUEInformation-r12.h" #endif /* for ImsiMobileIdentity_t */ @@ -203,66 +203,66 @@ void *send_UE_status_notification(void *); * the code is in favor of Rel14, those defines do the translation */ #if (LTE_RRC_VERSION < MAKE_VERSION(14, 0, 0)) -# define CipheringAlgorithm_r12_t e_SecurityAlgorithmConfig__cipheringAlgorithm -# define CipheringAlgorithm_r12_eea0 SecurityAlgorithmConfig__cipheringAlgorithm_eea0 -# define CipheringAlgorithm_r12_eea1 SecurityAlgorithmConfig__cipheringAlgorithm_eea1 -# define CipheringAlgorithm_r12_eea2 SecurityAlgorithmConfig__cipheringAlgorithm_eea2 -# define CipheringAlgorithm_r12_spare1 SecurityAlgorithmConfig__cipheringAlgorithm_spare1 -# define Alpha_r12_al0 UplinkPowerControlCommon__alpha_al0 -# define Alpha_r12_al04 UplinkPowerControlCommon__alpha_al04 -# define Alpha_r12_al05 UplinkPowerControlCommon__alpha_al05 -# define Alpha_r12_al06 UplinkPowerControlCommon__alpha_al06 -# define Alpha_r12_al07 UplinkPowerControlCommon__alpha_al07 -# define Alpha_r12_al08 UplinkPowerControlCommon__alpha_al08 -# define Alpha_r12_al09 UplinkPowerControlCommon__alpha_al09 -# define Alpha_r12_al1 UplinkPowerControlCommon__alpha_al1 -# define PreambleTransMax_n3 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3 -# define PreambleTransMax_n4 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4 -# define PreambleTransMax_n5 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5 -# define PreambleTransMax_n6 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6 -# define PreambleTransMax_n7 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7 -# define PreambleTransMax_n8 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8 -# define PreambleTransMax_n10 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10 -# define PreambleTransMax_n20 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20 -# define PreambleTransMax_n50 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50 -# define PreambleTransMax_n100 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100 -# define PreambleTransMax_n200 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200 -# define PeriodicBSR_Timer_r12_sf5 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf5 -# define PeriodicBSR_Timer_r12_sf10 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf10 -# define PeriodicBSR_Timer_r12_sf16 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf16 -# define PeriodicBSR_Timer_r12_sf20 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf20 -# define PeriodicBSR_Timer_r12_sf32 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf32 -# define PeriodicBSR_Timer_r12_sf40 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf40 -# define PeriodicBSR_Timer_r12_sf64 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf64 -# define PeriodicBSR_Timer_r12_sf80 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf80 -# define PeriodicBSR_Timer_r12_sf128 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf128 -# define PeriodicBSR_Timer_r12_sf160 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf160 -# define PeriodicBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf320 -# define PeriodicBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf640 -# define PeriodicBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf1280 -# define PeriodicBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf2560 -# define PeriodicBSR_Timer_r12_infinity MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity -# define RetxBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf320 -# define RetxBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf640 -# define RetxBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf1280 -# define RetxBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560 -# define RetxBSR_Timer_r12_sf5120 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf5120 -# define RetxBSR_Timer_r12_sf10240 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240 + #define CipheringAlgorithm_r12_t e_SecurityAlgorithmConfig__cipheringAlgorithm + #define CipheringAlgorithm_r12_eea0 SecurityAlgorithmConfig__cipheringAlgorithm_eea0 + #define CipheringAlgorithm_r12_eea1 SecurityAlgorithmConfig__cipheringAlgorithm_eea1 + #define CipheringAlgorithm_r12_eea2 SecurityAlgorithmConfig__cipheringAlgorithm_eea2 + #define CipheringAlgorithm_r12_spare1 SecurityAlgorithmConfig__cipheringAlgorithm_spare1 + #define Alpha_r12_al0 UplinkPowerControlCommon__alpha_al0 + #define Alpha_r12_al04 UplinkPowerControlCommon__alpha_al04 + #define Alpha_r12_al05 UplinkPowerControlCommon__alpha_al05 + #define Alpha_r12_al06 UplinkPowerControlCommon__alpha_al06 + #define Alpha_r12_al07 UplinkPowerControlCommon__alpha_al07 + #define Alpha_r12_al08 UplinkPowerControlCommon__alpha_al08 + #define Alpha_r12_al09 UplinkPowerControlCommon__alpha_al09 + #define Alpha_r12_al1 UplinkPowerControlCommon__alpha_al1 + #define PreambleTransMax_n3 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n3 + #define PreambleTransMax_n4 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n4 + #define PreambleTransMax_n5 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n5 + #define PreambleTransMax_n6 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n6 + #define PreambleTransMax_n7 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n7 + #define PreambleTransMax_n8 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n8 + #define PreambleTransMax_n10 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n10 + #define PreambleTransMax_n20 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n20 + #define PreambleTransMax_n50 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n50 + #define PreambleTransMax_n100 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n100 + #define PreambleTransMax_n200 RACH_ConfigCommon__ra_SupervisionInfo__preambleTransMax_n200 + #define PeriodicBSR_Timer_r12_sf5 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf5 + #define PeriodicBSR_Timer_r12_sf10 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf10 + #define PeriodicBSR_Timer_r12_sf16 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf16 + #define PeriodicBSR_Timer_r12_sf20 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf20 + #define PeriodicBSR_Timer_r12_sf32 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf32 + #define PeriodicBSR_Timer_r12_sf40 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf40 + #define PeriodicBSR_Timer_r12_sf64 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf64 + #define PeriodicBSR_Timer_r12_sf80 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf80 + #define PeriodicBSR_Timer_r12_sf128 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf128 + #define PeriodicBSR_Timer_r12_sf160 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf160 + #define PeriodicBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf320 + #define PeriodicBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf640 + #define PeriodicBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf1280 + #define PeriodicBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_sf2560 + #define PeriodicBSR_Timer_r12_infinity MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity + #define RetxBSR_Timer_r12_sf320 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf320 + #define RetxBSR_Timer_r12_sf640 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf640 + #define RetxBSR_Timer_r12_sf1280 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf1280 + #define RetxBSR_Timer_r12_sf2560 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560 + #define RetxBSR_Timer_r12_sf5120 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf5120 + #define RetxBSR_Timer_r12_sf10240 MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf10240 #endif // This corrects something generated by asn1c which is different between Rel8 and Rel10 #if (LTE_RRC_VERSION <= MAKE_VERSION(10, 0, 0)) -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10 -#define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member SystemInformation_r8_IEs_sib_TypeAndInfo_Member + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib2 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib3 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib4 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib5 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib6 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib7 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib8 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib9 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib10 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10 + #define SystemInformation_r8_IEs__sib_TypeAndInfo__Member_PR_sib11 SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11 #endif @@ -279,13 +279,13 @@ void *send_UE_status_notification(void *); */ //#include "L3_rrc_defs.h" #ifndef NO_RRM -#include "L3_rrc_interface.h" -#include "rrc_rrm_msg.h" -#include "rrc_rrm_interface.h" + #include "L3_rrc_interface.h" + #include "rrc_rrm_msg.h" + #include "rrc_rrm_interface.h" #endif #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif /* TODO: be sure this include is correct. @@ -293,11 +293,11 @@ void *send_UE_status_notification(void *); * issue #186. */ #if !defined(ENABLE_ITTI) -# include "as_message.h" + #include "as_message.h" #endif #if defined(ENABLE_USE_MME) -# include "commonDef.h" + #include "commonDef.h" #endif //-------- @@ -387,10 +387,10 @@ typedef enum SL_TRIGGER_e { #define RRC_TRANSACTION_IDENTIFIER_NUMBER 3 typedef struct { - unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */ - unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */ - unsigned long Guaranteed_bit_rate; /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/ - unsigned long Max_bit_rate; /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/ + unsigned short transport_block_size; /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */ + unsigned short max_transport_blocks; /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */ + unsigned long Guaranteed_bit_rate; /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/ + unsigned long Max_bit_rate; /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/ uint8_t Delay_class; /*!< \brief Delay class offered by MAC layer scheduling*/ uint8_t Target_bler; /*!< \brief Target Average Transport Block Error rate*/ uint8_t Lchan_t; /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/ @@ -516,29 +516,29 @@ typedef struct eNB_RRC_UE_s { #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) LTE_SCellToAddMod_r10_t sCell_config[2]; #endif - LTE_SRB_ToAddModList_t* SRB_configList; - LTE_SRB_ToAddModList_t* SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; - LTE_DRB_ToAddModList_t* DRB_configList; - LTE_DRB_ToAddModList_t* DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; - LTE_DRB_ToReleaseList_t* DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + LTE_SRB_ToAddModList_t *SRB_configList; + LTE_SRB_ToAddModList_t *SRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + LTE_DRB_ToAddModList_t *DRB_configList; + LTE_DRB_ToAddModList_t *DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; + LTE_DRB_ToReleaseList_t *DRB_Release_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; uint8_t DRB_active[8]; - struct LTE_PhysicalConfigDedicated* physicalConfigDedicated; - struct LTE_SPS_Config* sps_Config; - LTE_MeasObjectToAddMod_t* MeasObj[MAX_MEAS_OBJ]; - struct LTE_ReportConfigToAddMod* ReportConfig[MAX_MEAS_CONFIG]; - struct LTE_QuantityConfig* QuantityConfig; - struct LTE_MeasIdToAddMod* MeasId[MAX_MEAS_ID]; - LTE_MAC_MainConfig_t* mac_MainConfig; - LTE_MeasGapConfig_t* measGapConfig; + struct LTE_PhysicalConfigDedicated *physicalConfigDedicated; + struct LTE_SPS_Config *sps_Config; + LTE_MeasObjectToAddMod_t *MeasObj[MAX_MEAS_OBJ]; + struct LTE_ReportConfigToAddMod *ReportConfig[MAX_MEAS_CONFIG]; + struct LTE_QuantityConfig *QuantityConfig; + struct LTE_MeasIdToAddMod *MeasId[MAX_MEAS_ID]; + LTE_MAC_MainConfig_t *mac_MainConfig; + LTE_MeasGapConfig_t *measGapConfig; SRB_INFO SI; SRB_INFO Srb0; SRB_INFO_TABLE_ENTRY Srb1; SRB_INFO_TABLE_ENTRY Srb2; - LTE_MeasConfig_t* measConfig; - HANDOVER_INFO* handover_info; - LTE_MeasResults_t* measResults; + LTE_MeasConfig_t *measConfig; + HANDOVER_INFO *handover_info; + LTE_MeasResults_t *measResults; - LTE_UE_EUTRA_Capability_t* UE_Capability; + LTE_UE_EUTRA_Capability_t *UE_Capability; ImsiMobileIdentity_t imsi; #if defined(ENABLE_SECURITY) @@ -552,7 +552,7 @@ typedef struct eNB_RRC_UE_s { LTE_CipheringAlgorithm_r12_t ciphering_algorithm; e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; - uint8_t Status; + uint8_t Status; // RRC status, type enum UE_STATE_t rnti_t rnti; uint64_t random_ue_identity; @@ -573,7 +573,7 @@ typedef struct eNB_RRC_UE_s { security_capabilities_t security_capabilities; /* Total number of e_rab already setup in the list */ - uint8_t setup_e_rabs; + uint8_t setup_e_rabs; /* Number of e_rab to be setup in the list */ uint8_t nb_of_e_rabs; /* Number of e_rab to be modified in the list */ @@ -599,6 +599,8 @@ typedef struct eNB_RRC_UE_s { uint32_t ue_release_timer_thres_rrc; uint32_t ue_reestablishment_timer; uint32_t ue_reestablishment_timer_thres; + /* RRC inactivity timer: on timeout, should release RRC connection for inactivity on all E-RABs */ + uint32_t ue_rrc_inactivity_timer; uint8_t e_rab_release_command_flag; int8_t reestablishment_xid; } eNB_RRC_UE_t; @@ -768,7 +770,7 @@ typedef struct UE_RRC_INST_s { //current destination uint32_t destinationL2Id; //List of destinations - uint32_t destinationList[MAX_NUM_DEST]; + uint32_t destinationList[MAX_NUM_DEST]; //sl_discovery.. SRB_INFO SL_Discovery[NB_CNX_UE]; #endif diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 6f269b93cbfd96cd432ddd7a908dabb9bb53c8cf..f9e51e2f08e585a14c61cc91af460a27b6bd17ec 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -75,34 +75,34 @@ #include "OCG_extern.h" #if defined(ENABLE_SECURITY) -# include "UTIL/OSA/osa_defs.h" + #include "UTIL/OSA/osa_defs.h" #endif #if defined(ENABLE_USE_MME) -# include "rrc_eNB_S1AP.h" -# include "rrc_eNB_GTPV1U.h" -# if defined(ENABLE_ITTI) -# else -# include "../../S1AP/s1ap_eNB.h" -# endif -/* temporary warning removale while implementing noS1 */ -/* as config option */ + #include "rrc_eNB_S1AP.h" + #include "rrc_eNB_GTPV1U.h" + #if defined(ENABLE_ITTI) + #else + #include "../../S1AP/s1ap_eNB.h" + #endif + /* temporary warning removale while implementing noS1 */ + /* as config option */ #else -# ifdef EPC_MODE_ENABLED -# undef EPC_MODE_ENABLED -# endif -# define EPC_MODE_ENABLED 0 + #ifdef EPC_MODE_ENABLED + #undef EPC_MODE_ENABLED + #endif + #define EPC_MODE_ENABLED 0 #endif #include "pdcp.h" #include "gtpv1u_eNB_task.h" #if defined(ENABLE_ITTI) -# include "intertask_interface.h" + #include "intertask_interface.h" #endif #if ENABLE_RAL -# include "rrc_eNB_ral.h" + #include "rrc_eNB_ral.h" #endif #include "SIMULATION/TOOLS/sim.h" // for taus @@ -111,12 +111,12 @@ extern RAN_CONTEXT_t RC; #ifdef PHY_EMUL -extern EMULATION_VARS *Emul_vars; + extern EMULATION_VARS *Emul_vars; #endif extern eNB_MAC_INST *eNB_mac_inst; extern UE_MAC_INST *UE_mac_inst; #ifdef BIGPHYSAREA -extern void* bigphys_malloc(int); + extern void *bigphys_malloc(int); #endif extern uint16_t two_tier_hexagonal_cellIds[7]; @@ -125,30 +125,30 @@ mui_t rrc_eNB_mui = 0; void openair_rrc_on( - const protocol_ctxt_t* const ctxt_pP + const protocol_ctxt_t *const ctxt_pP ) //----------------------------------------------------------------------------- { int CC_id; + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB:OPENAIR RRC IN....\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" ENB:OPENAIR RRC IN....\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1; - rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1; - } + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1; + rrc_config_buffer (&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Active = 1; + } } //----------------------------------------------------------------------------- static void init_SI( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const int CC_id #if defined(ENABLE_ITTI) , - RrcConfigurationReq * configuration + RrcConfigurationReq *configuration #endif ) //----------------------------------------------------------------------------- @@ -156,14 +156,11 @@ init_SI( #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) int i; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 1, 0)) LTE_SystemInformationBlockType1_v1310_IEs_t *sib1_v13ext=(LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL; #endif - LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__); - - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t*) malloc16(4); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB = (uint8_t *) malloc16(4); // copy basic parameters RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId = configuration->Nid_cell[CC_id]; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB = configuration->nb_antenna_ports[CC_id]; @@ -173,84 +170,74 @@ init_SI( #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition = configuration->pbch_repetition[CC_id]; #endif - LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", - (int)configuration->N_RB_DL[CC_id], - (int)configuration->phich_resource[CC_id], - (int)configuration->phich_duration[CC_id]); + LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n", + (int)configuration->N_RB_DL[CC_id], + (int)configuration->phich_resource[CC_id], + (int)configuration->phich_duration[CC_id]); do_MIB(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id], #ifdef ENABLE_ITTI - configuration->N_RB_DL[CC_id], - configuration->phich_resource[CC_id], - configuration->phich_duration[CC_id] + configuration->N_RB_DL[CC_id], + configuration->phich_resource[CC_id], + configuration->phich_duration[CC_id] #else - 50,0,0 + 50,0,0 #endif - ,0); - - + ,0); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = 0; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = 0; - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1 = (uint8_t*) malloc16(32); - + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1 = (uint8_t *) malloc16(32); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB1!=NULL,PROTOCOL_RRC_CTXT_FMT" init_SI: FATAL, no memory for SIB1 allocated\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 = do_SIB1(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],ctxt_pP->module_id,CC_id #if defined(ENABLE_ITTI) - , configuration + , configuration #endif - ); - + ); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB1 != 255,"FATAL, RC.rrc[enb_mod_idP].carrier[CC_id].sizeof_SIB1 == 255"); - - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t*) malloc16(64); + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23 = (uint8_t *) malloc16(64); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].SIB23!=NULL,"cannot allocate memory for SIB"); RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 = do_SIB23( - ctxt_pP->module_id, - - CC_id + ctxt_pP->module_id, + CC_id #if defined(ENABLE_ITTI) - , configuration + , configuration #endif - ); - + ); AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_SIB23 != 255,"FATAL, RC.rrc[mod].carrier[CC_id].sizeof_SIB23 == 255"); - - LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" SIB2/3 Contents (partial)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.n_SB = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.n_SB); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.n_SB); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.hoppingMode = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.hoppingMode); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.hoppingMode); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.pusch_HoppingOffset = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.pusch_HoppingOffset); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.pusch_HoppingOffset); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.enable64QAM = %d\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - pusch_ConfigBasic.enable64QAM); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + pusch_ConfigBasic.enable64QAM); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupHoppingEnabled = %d\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.groupHoppingEnabled); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.groupHoppingEnabled); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.groupAssignmentPUSCH = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.sequenceHoppingEnabled = %d\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + (int)RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); LOG_T(RRC, PROTOCOL_RRC_CTXT_FMT" pusch_config_common.cyclicShift = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. - ul_ReferenceSignalsPUSCH.cyclicShift); - + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon.pusch_ConfigCommon. + ul_ReferenceSignalsPUSCH.cyclicShift); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) if (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag > 0) { @@ -258,177 +245,174 @@ init_SI( // SIB 2 // LOG_D(RRC, "[eNB %d] mbsfn_SubframeConfigList.list.count = %ld\n", enb_mod_idP, RC.rrc[enb_mod_idP].sib2->mbsfn_SubframeConfigList->list.count); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN subframe allocation %d/%d(partial)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - i, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + i, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.count); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" mbsfn_Subframe_pattern is = %x\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->subframeAllocation.choice.oneFrame.buf[0] >> 0); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_period = %ld (just index number, not the real value)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod); // need to display the real value, using array of char (like in dumping SIB2) + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationPeriod); // need to display the real value, using array of char (like in dumping SIB2) LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" radioframe_allocation_offset = %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList->list.array[i]->radioframeAllocationOffset); } #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) + // SIB13 for (i = 0; i < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count; i++) { LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" SIB13 contents for MBSFN sync area %d/%d (partial)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - i, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + i, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.count); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Repetition Period: %ld (just index number, not real value)\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); LOG_D(RRC, PROTOCOL_RRC_CTXT_FMT" MCCH Offset: %ld\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9.list.array[i]->mcch_Config_r9.mcch_Offset_r9); } + #endif - } - else memset((void*)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); + } else memset((void *)&RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13,0,sizeof(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13)); //TTN - SIB 18 for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count; j++) { - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - j+1, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); - + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB18 %d/%d \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.count); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 rxPool_sc_CP_Len: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_CP_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 sc_Period_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_Period_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 data_CP_Len_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->data_CP_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Num_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_Start_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 prb_End_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.prb_End_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 offsetIndicator: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB18 subframeBitmap_choice_bs_buf: %s \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib18->commConfig_r12->commRxPool_r12.list.array[j]->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); } //TTN - SIB 19 for (int j = 0; j < RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count; j++) { - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - j+1, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); - + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Contents of SIB19 %d/%d \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + j+1, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.count); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 cp_Len_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->cp_Len_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 discPeriod_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->discPeriod_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRetx_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRetx_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 numRepetition_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->numRepetition_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Num_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Num_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_Start_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_Start_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 prb_End_r12: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.prb_End_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 offsetIndicator: %ld \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12); + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" SIB19 tf_ResourceConfig_r12 subframeBitmap_choice_bs_buf: %s \n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP), + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib19->discConfig_r12->discRxPool_r12.list.array[j]->tf_ResourceConfig_r12.subframeBitmap_r12.choice.bs16_r12.buf); } #endif - LOG_D(RRC, - PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - + PROTOCOL_RRC_CTXT_FMT" RRC_UE --- MAC_CONFIG_REQ (SIB1.tdd & SIB2 params) ---> MAC_UE\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) && + + if ((RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib.message.schedulingInfoSIB1_BR_r13>0) && (RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR!=NULL)) { - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v8.9)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v9.2)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v11.3)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v12.5)\n"); - AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, - "sib2_br->nonCriticalExtension is null (v13.10)\n"); - sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension; + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v8.9)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v9.2)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v11.3)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v12.5)\n"); + AssertFatal(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension!=NULL, + "sib2_br->nonCriticalExtension is null (v13.10)\n"); + sib1_v13ext = RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1_BR->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension; } -#endif +#endif LOG_D(RRC, "About to call rrc_mac_config_req_eNB\n"); - rrc_mac_config_req_eNB(ctxt_pP->module_id, CC_id, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Ncp, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->freqBandIndicator, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].dl_CarrierFreq, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].pbch_repetition, #endif - 0, // rnti - (LTE_BCCH_BCH_Message_t *) - &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib, - (LTE_RadioResourceConfigCommonSIB_t *) & - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon, + 0, // rnti + (LTE_BCCH_BCH_Message_t *) + &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].mib, + (LTE_RadioResourceConfigCommonSIB_t *) & + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->radioResourceConfigCommon, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) & - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon, + (LTE_RadioResourceConfigCommonSIB_t *) & + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2_BR->radioResourceConfigCommon, #endif - (struct LTE_PhysicalConfigDedicated *)NULL, + (struct LTE_PhysicalConfigDedicated *)NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - (LTE_MAC_MainConfig_t *) NULL, 0, - (struct LTE_LogicalChannelConfig *)NULL, - (LTE_MeasGapConfig_t *) NULL, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->tdd_Config, - NULL, - &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->schedulingInfoList, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth, - &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission, - (LTE_MBSFN_SubframeConfigList_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + (LTE_MAC_MainConfig_t *) NULL, 0, + (struct LTE_LogicalChannelConfig *)NULL, + (LTE_MeasGapConfig_t *) NULL, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->tdd_Config, + NULL, + &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib1->schedulingInfoList, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].ul_CarrierFreq, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.ul_Bandwidth, + &RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->freqInfo.additionalSpectrumEmission, + (LTE_MBSFN_SubframeConfigList_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib2->mbsfn_SubframeConfigList #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag, - (LTE_MBSFN_AreaInfoList_r9_t*) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9, - (LTE_PMCH_InfoList_r9_t *) NULL + , + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MBMS_flag, + (LTE_MBSFN_AreaInfoList_r9_t *) & RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sib13->mbsfn_AreaInfoList_r9, + (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - sib1_v13ext + , + sib1_v13ext #endif - ); + ); } #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) @@ -440,92 +424,81 @@ init_MCCH( ) //----------------------------------------------------------------------------- { - int sync_area = 0; // initialize RRC_eNB_INST MCCH entry RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE = - malloc(RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t*)); + malloc(RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area * sizeof(uint8_t *)); for (sync_area = 0; sync_area < RC.rrc[enb_mod_idP]->carrier[CC_id].num_mbsfn_sync_area; sync_area++) { - RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = 0; RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] = (uint8_t *) malloc16(32); - AssertFatal(RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area] != NULL, - "[eNB %d]init_MCCH: FATAL, no memory for MCCH MESSAGE allocated \n", enb_mod_idP); + "[eNB %d]init_MCCH: FATAL, no memory for MCCH MESSAGE allocated \n", enb_mod_idP); RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] = do_MBSFNAreaConfig(enb_mod_idP, - sync_area, - (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], - &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch, - &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message); - + sync_area, + (uint8_t *)RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], + &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch, + &RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message); LOG_I(RRC, "mcch message pointer %p for sync area %d \n", - RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], - sync_area); + RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESSAGE[sync_area], + sync_area); LOG_D(RRC, "[eNB %d] MCCH_MESSAGE contents for Sync Area %d (partial)\n", enb_mod_idP, sync_area); LOG_D(RRC, "[eNB %d] CommonSF_AllocPeriod_r9 %ld\n", enb_mod_idP, - RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9); + RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_AllocPeriod_r9); LOG_D(RRC, - "[eNB %d] CommonSF_Alloc_r9.list.count (number of MBSFN Subframe Pattern) %d\n", - enb_mod_idP, RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count); + "[eNB %d] CommonSF_Alloc_r9.list.count (number of MBSFN Subframe Pattern) %d\n", + enb_mod_idP, RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.count); LOG_D(RRC, "[eNB %d] MBSFN Subframe Pattern: %02x (in hex)\n", - enb_mod_idP, - RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation. - choice.oneFrame.buf[0]); - + enb_mod_idP, + RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->commonSF_Alloc_r9.list.array[0]->subframeAllocation. + choice.oneFrame.buf[0]); AssertFatal(RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] != 255, - "RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255"); + "RC.rrc[enb_mod_idP]->carrier[CC_id].sizeof_MCCH_MESSAGE[sync_area] == 255"); RC.rrc[enb_mod_idP]->carrier[CC_id].MCCH_MESS[sync_area].Active = 1; } - //Set the RC.rrc[enb_mod_idP]->MCCH_MESS.Active to 1 (allow to transfer MCCH message RRC->MAC in function mac_rrc_data_req) - // ??Configure MCCH logical channel // call mac_config_req with appropriate structure from ASN.1 description - - // LOG_I(RRC, "DUY: serviceID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->tmgi_r9.serviceId_r9.buf[2]); // LOG_I(RRC, "DUY: session ID is %d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->sessionId_r9->buf[0]); rrc_mac_config_req_eNB(enb_mod_idP, CC_id, - 0,0,0,0,0, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - 0,//rnti - (LTE_BCCH_BCH_Message_t *)NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + 0,//rnti + (LTE_BCCH_BCH_Message_t *)NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - (struct LTE_PhysicalConfigDedicated *)NULL, + (struct LTE_PhysicalConfigDedicated *)NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - (LTE_MAC_MainConfig_t *) NULL, - 0, - (struct LTE_LogicalChannelConfig *)NULL, - (LTE_MeasGapConfig_t *) NULL, - (LTE_TDD_Config_t *) NULL, - (LTE_MobilityControlInfo_t *)NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + (LTE_MAC_MainConfig_t *) NULL, + 0, + (struct LTE_LogicalChannelConfig *)NULL, + (LTE_MeasGapConfig_t *) NULL, + (LTE_TDD_Config_t *) NULL, + (LTE_MobilityControlInfo_t *)NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , - 0, - (LTE_MBSFN_AreaInfoList_r9_t *) NULL, - (LTE_PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) + , + 0, + (LTE_MBSFN_AreaInfoList_r9_t *) NULL, + (LTE_PMCH_InfoList_r9_t *) & (RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); - + ); //LOG_I(RRC,"DUY: lcid after rrc_mac_config_req is %02d\n",RC.rrc[enb_mod_idP]->mcch_message->pmch_InfoList_r9.list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9); - } //----------------------------------------------------------------------------- @@ -541,13 +514,11 @@ static void init_MBMS( if (RC.rrc[enb_mod_idP]->carrier[CC_id].MBMS_flag > 0) { PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,enb_mod_idP); - LOG_D(RRC, "[eNB %d] Frame %d : Radio Bearer config request for MBMS\n", enb_mod_idP, frameP); //check the lcid // Configuring PDCP and RLC for MBMS Radio Bearer - rrc_pdcp_config_asn1_req(&ctxt, - (LTE_SRB_ToAddModList_t *)NULL, // LTE_SRB_ToAddModList - (LTE_DRB_ToAddModList_t *)NULL, // LTE_DRB_ToAddModList + (LTE_SRB_ToAddModList_t *)NULL, // LTE_SRB_ToAddModList + (LTE_DRB_ToAddModList_t *)NULL, // LTE_DRB_ToAddModList (LTE_DRB_ToReleaseList_t *)NULL, 0, // security mode NULL, // key rrc encryption @@ -557,18 +528,15 @@ static void init_MBMS( , &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) #endif ,NULL); - rrc_rlc_config_asn1_req(&ctxt, NULL, // LTE_SRB_ToAddModList NULL, // LTE_DRB_ToAddModList NULL, // DRB_ToReleaseList &(RC.rrc[enb_mod_idP]->carrier[CC_id].mcch_message->pmch_InfoList_r9) - #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,0, 0 #endif - ); - + ); //rrc_mac_config_req(); } } @@ -621,14 +589,14 @@ rrc_eNB_get_next_transaction_identifier( //----------------------------------------------------------------------------- // return the ue context if there is already an UE with ue_identityP, NULL otherwise -static struct rrc_eNB_ue_context_s* +static struct rrc_eNB_ue_context_s * rrc_eNB_ue_context_random_exist( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint64_t ue_identityP ) //----------------------------------------------------------------------------- { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { if (ue_context_p->ue_context.random_ue_identity == ue_identityP) return ue_context_p; @@ -637,47 +605,47 @@ rrc_eNB_ue_context_random_exist( } //----------------------------------------------------------------------------- // return the ue context if there is already an UE with the same S-TMSI(MMEC+M-TMSI), NULL otherwise -static struct rrc_eNB_ue_context_s* +static struct rrc_eNB_ue_context_s * rrc_eNB_ue_context_stmsi_exist( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const mme_code_t mme_codeP, const m_tmsi_t m_tmsiP ) //----------------------------------------------------------------------------- { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { LOG_I(RRC,"checking for UE S-TMSI %x, mme %x (%p): rnti %x", - m_tmsiP, mme_codeP, ue_context_p, - ue_context_p->ue_context.rnti); + m_tmsiP, mme_codeP, ue_context_p, + ue_context_p->ue_context.rnti); + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { printf("=> S-TMSI %x, MME %x\n", - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code); + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code); + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi == m_tmsiP) if (ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code == mme_codeP) return ue_context_p; - } - else + } else printf("\n"); - } return NULL; } //----------------------------------------------------------------------------- // return a new ue context structure if ue_identityP, ctxt_pP->rnti not found in collection -static struct rrc_eNB_ue_context_s* +static struct rrc_eNB_ue_context_s * rrc_eNB_get_next_free_ue_context( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const uint64_t ue_identityP ) //----------------------------------------------------------------------------- { - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[ctxt_pP->module_id], - ctxt_pP->rnti); + RC.rrc[ctxt_pP->module_id], + ctxt_pP->rnti); if (ue_context_p == NULL) { ue_context_p = rrc_eNB_allocate_new_UE_context(RC.rrc[ctxt_pP->module_id]); @@ -698,7 +666,6 @@ rrc_eNB_get_next_free_ue_context( PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ue_context_p->local_uid); return ue_context_p; - } else { LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Cannot create new UE context, already exist\n", @@ -710,8 +677,8 @@ rrc_eNB_get_next_free_ue_context( //----------------------------------------------------------------------------- void rrc_eNB_free_mem_UE_context( - const protocol_ctxt_t* const ctxt_pP, - struct rrc_eNB_ue_context_s* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + struct rrc_eNB_ue_context_s *const ue_context_pP ) //----------------------------------------------------------------------------- { @@ -730,11 +697,11 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.SRB_configList = NULL; } - for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){ - if (ue_context_pP->ue_context.SRB_configList2[i]) { - free(ue_context_pP->ue_context.SRB_configList2[i]); - ue_context_pP->ue_context.SRB_configList2[i] = NULL; - } + for(i = 0; i < RRC_TRANSACTION_IDENTIFIER_NUMBER; i++) { + if (ue_context_pP->ue_context.SRB_configList2[i]) { + free(ue_context_pP->ue_context.SRB_configList2[i]); + ue_context_pP->ue_context.SRB_configList2[i] = NULL; + } } if (ue_context_pP->ue_context.DRB_configList) { @@ -742,15 +709,16 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.DRB_configList = NULL; } - for(i = 0;i < RRC_TRANSACTION_IDENTIFIER_NUMBER;i++){ - if (ue_context_pP->ue_context.DRB_configList2[i]) { - free(ue_context_pP->ue_context.DRB_configList2[i]); - ue_context_pP->ue_context.DRB_configList2[i] = NULL; - } - if (ue_context_pP->ue_context.DRB_Release_configList2[i]) { - free(ue_context_pP->ue_context.DRB_Release_configList2[i]); - ue_context_pP->ue_context.DRB_Release_configList2[i] = NULL; - } + for(i = 0; i < RRC_TRANSACTION_IDENTIFIER_NUMBER; i++) { + if (ue_context_pP->ue_context.DRB_configList2[i]) { + free(ue_context_pP->ue_context.DRB_configList2[i]); + ue_context_pP->ue_context.DRB_configList2[i] = NULL; + } + + if (ue_context_pP->ue_context.DRB_Release_configList2[i]) { + free(ue_context_pP->ue_context.DRB_Release_configList2[i]); + ue_context_pP->ue_context.DRB_Release_configList2[i] = NULL; + } } memset(ue_context_pP->ue_context.DRB_active, 0, sizeof(ue_context_pP->ue_context.DRB_active)); @@ -789,14 +757,14 @@ rrc_eNB_free_mem_UE_context( ue_context_pP->ue_context.mac_MainConfig = NULL; } -/* if (ue_context_pP->ue_context.measGapConfig) { - ASN_STRUCT_FREE(asn_DEF_LTE_MeasGapConfig, ue_context_pP->ue_context.measGapConfig); - ue_context_pP->ue_context.measGapConfig = NULL; - }*/ - if (ue_context_pP->ue_context.handover_info) { - ASN_STRUCT_FREE(asn_DEF_LTE_Handover, ue_context_pP->ue_context.handover_info); - ue_context_pP->ue_context.handover_info = NULL; - } + /* if (ue_context_pP->ue_context.measGapConfig) { + ASN_STRUCT_FREE(asn_DEF_LTE_MeasGapConfig, ue_context_pP->ue_context.measGapConfig); + ue_context_pP->ue_context.measGapConfig = NULL; + }*/ + if (ue_context_pP->ue_context.handover_info) { + ASN_STRUCT_FREE(asn_DEF_LTE_Handover, ue_context_pP->ue_context.handover_info); + ue_context_pP->ue_context.handover_info = NULL; + } //SRB_INFO SI; //SRB_INFO Srb0; @@ -837,240 +805,256 @@ rrc_eNB_free_mem_UE_context( } //----------------------------------------------------------------------------- -// should be called when UE is lost by eNB +/* +* Should be called when UE context in eNB should be released +* or when S1 command UE_CONTEXT_RELEASE_REQ should be sent +*/ void -rrc_eNB_free_UE(const module_id_t enb_mod_idP,const struct rrc_eNB_ue_context_s* const ue_context_pP) +rrc_eNB_free_UE( + const module_id_t enb_mod_idP, + const struct rrc_eNB_ue_context_s *const ue_context_pP) //----------------------------------------------------------------------------- { - - - protocol_ctxt_t ctxt; rnti_t rnti = ue_context_pP->ue_context.rnti; + if (enb_mod_idP >= NB_eNB_INST) { - LOG_I(RRC, "eNB inst invalid (%d/%d) for UE %x!\n",enb_mod_idP, NB_eNB_INST,rnti); - return; + LOG_E(RRC, "eNB instance invalid (%d/%d) for UE %x!\n", + enb_mod_idP, + NB_eNB_INST, + rnti); + return; } - /* ue_context_p = rrc_eNB_get_ue_context( - &RC.rrc[enb_mod_idP], - rntiP - ); - */ - if (NULL != ue_context_pP) { - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, rnti, 0, 0,enb_mod_idP); - LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", enb_mod_idP, rnti); - if(EPC_MODE_ENABLED) { - - if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && - (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) { - LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ RNTI %x\n", enb_mod_idP, rnti); - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); // send cause 21: connection with ue lost + if (EPC_MODE_ENABLED) { + if ((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", + enb_mod_idP, + rnti); + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); + // send cause 21: radio connection with ue lost /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered) - * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before - * triggering the S1 UE Context Release Request procedure - * in order to allow the UE to perform the NAS recovery - * procedure, see TS 23.401 [17]. - */ - return; + * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before + * triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery + * procedure, see TS 23.401 [17]. + */ + return; + } + + if((ue_context_pP->ue_context.ue_rrc_inactivity_timer >= RC.rrc[enb_mod_idP]->configuration.rrc_inactivity_timer_thres) && + (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED) && + (RC.rrc[enb_mod_idP]->configuration.rrc_inactivity_timer_thres > 0)) { + LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 20, user inactivity\n", + enb_mod_idP, + rnti); + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 20); + // send cause 20: user inactivity + return; } } - // add UE info to freeList - LOG_I(RRC, "put UE %x into freeList\n", rnti); - put_UE_in_freelist(enb_mod_idP, rnti, 1); - } -} -void remove_UE_from_freelist(module_id_t mod_id, rnti_t rnti) -{ + LOG_W(RRC, "[eNB %d] Removing UE RNTI %x\n", + enb_mod_idP, + rnti); + // add UE info to freeList + LOG_I(RRC, "Put UE %x into freeList\n", + rnti); + put_UE_in_freelist(enb_mod_idP, rnti, 1); +} - eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - pthread_mutex_lock(&lock_ue_freelist); - UE_free_list_t *free_list = &eNB_MAC->UE_free_list; - free_list->UE_free_ctrl[free_list->head_freelist].rnti = 0; - free_list->head_freelist = (free_list->head_freelist + 1) % (NUMBER_OF_UE_MAX+1); - free_list->num_UEs--; - pthread_mutex_unlock(&lock_ue_freelist); +void remove_UE_from_freelist(module_id_t mod_id, rnti_t rnti) { + eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; + pthread_mutex_lock(&lock_ue_freelist); + UE_free_list_t *free_list = &eNB_MAC->UE_free_list; + free_list->UE_free_ctrl[free_list->head_freelist].rnti = 0; + free_list->head_freelist = (free_list->head_freelist + 1) % (NUMBER_OF_UE_MAX+1); + free_list->num_UEs--; + pthread_mutex_unlock(&lock_ue_freelist); } -void put_UE_in_freelist(module_id_t mod_id, rnti_t rnti, boolean_t removeFlag) -{ - UE_free_list_t *free_list = NULL; - eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - pthread_mutex_lock(&lock_ue_freelist); - free_list = &eNB_MAC->UE_free_list; - free_list->UE_free_ctrl[free_list->tail_freelist].rnti = rnti; - free_list->UE_free_ctrl[free_list->tail_freelist].removeContextFlg = removeFlag; - free_list->num_UEs++; - free_list->tail_freelist = (free_list->tail_freelist + 1) % (NUMBER_OF_UE_MAX+1); - pthread_mutex_unlock(&lock_ue_freelist); +void put_UE_in_freelist(module_id_t mod_id, rnti_t rnti, boolean_t removeFlag) { + UE_free_list_t *free_list = NULL; + eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; + pthread_mutex_lock(&lock_ue_freelist); + free_list = &eNB_MAC->UE_free_list; + free_list->UE_free_ctrl[free_list->tail_freelist].rnti = rnti; + free_list->UE_free_ctrl[free_list->tail_freelist].removeContextFlg = removeFlag; + free_list->num_UEs++; + free_list->tail_freelist = (free_list->tail_freelist + 1) % (NUMBER_OF_UE_MAX+1); + pthread_mutex_unlock(&lock_ue_freelist); } -void release_UE_in_freeList(module_id_t mod_id) -{ - int i, j , CC_id, pdu_number; - protocol_ctxt_t ctxt; - LTE_eNB_ULSCH_t *ulsch = NULL; - LTE_eNB_DLSCH_t *dlsch = NULL; - nfapi_ul_config_request_body_t *ul_req_tmp = NULL; - PHY_VARS_eNB *eNB_PHY = NULL; - struct rrc_eNB_ue_context_s *ue_context_pP = NULL; - eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; - boolean_t remove_UEContext; - rnti_t rnti; - int head, tail, ue_num; - - pthread_mutex_lock(&lock_ue_freelist); - head = eNB_MAC->UE_free_list.head_freelist; - tail = eNB_MAC->UE_free_list.tail_freelist; - if(head == tail){ - pthread_mutex_unlock(&lock_ue_freelist); - return; - } - if(tail < head){ - tail = head + eNB_MAC->UE_free_list.num_UEs; - } +void release_UE_in_freeList(module_id_t mod_id) { + int i, j, CC_id, pdu_number; + protocol_ctxt_t ctxt; + LTE_eNB_ULSCH_t *ulsch = NULL; + LTE_eNB_DLSCH_t *dlsch = NULL; + nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + PHY_VARS_eNB *eNB_PHY = NULL; + struct rrc_eNB_ue_context_s *ue_context_pP = NULL; + eNB_MAC_INST *eNB_MAC = RC.mac[mod_id]; + boolean_t remove_UEContext; + rnti_t rnti; + int head, tail, ue_num; + pthread_mutex_lock(&lock_ue_freelist); + head = eNB_MAC->UE_free_list.head_freelist; + tail = eNB_MAC->UE_free_list.tail_freelist; + + if(head == tail) { pthread_mutex_unlock(&lock_ue_freelist); + return; + } - for(ue_num = head; ue_num < tail; ue_num++){ - ue_num = ue_num % (NUMBER_OF_UE_MAX+1); - rnti = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].rnti; - if(rnti != 0){ - remove_UEContext = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].removeContextFlg; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, rnti, 0, 0,mod_id); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - eNB_PHY = RC.eNB[mod_id][CC_id]; - for (i=0; i<MAX_MOBILES_PER_ENB; i++) { - ulsch = eNB_PHY->ulsch[i]; - if((ulsch != NULL) && (ulsch->rnti == rnti)){ - void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); - LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); - clean_eNb_ulsch(ulsch); - } - if(eNB_PHY->uci_vars[i].rnti == rnti){ - LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); - memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); - } - } - for (i=0; i<MAX_MOBILES_PER_ENB; i++) { - dlsch = eNB_PHY->dlsch[i][0]; - if((dlsch != NULL) && (dlsch->rnti == rnti)){ - void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); - LOG_I(RRC, "clean_eNb_dlsch dlsch[%d] UE %x \n", i, rnti); - clean_eNb_dlsch(dlsch); - } - } + if(tail < head) { + tail = head + eNB_MAC->UE_free_list.num_UEs; + } - if (rrc_agent_registered[mod_id]) { - agent_rrc_xface[mod_id]->flexran_agent_notify_ue_state_change(mod_id, - rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); - } + pthread_mutex_unlock(&lock_ue_freelist); + + for(ue_num = head; ue_num < tail; ue_num++) { + ue_num = ue_num % (NUMBER_OF_UE_MAX+1); + rnti = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].rnti; + + if(rnti != 0) { + remove_UEContext = eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].removeContextFlg; + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, mod_id, ENB_FLAG_YES, rnti, 0, 0,mod_id); + + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + eNB_PHY = RC.eNB[mod_id][CC_id]; + + for (i=0; i<MAX_MOBILES_PER_ENB; i++) { + ulsch = eNB_PHY->ulsch[i]; + + if((ulsch != NULL) && (ulsch->rnti == rnti)) { + void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); + LOG_I(RRC, "clean_eNb_ulsch ulsch[%d] UE %x\n", i, rnti); + clean_eNb_ulsch(ulsch); + } + + if(eNB_PHY->uci_vars[i].rnti == rnti) { + LOG_I(MAC, "clean eNb uci_vars[%d] UE %x \n",i, rnti); + memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); + } + } + + for (i=0; i<MAX_MOBILES_PER_ENB; i++) { + dlsch = eNB_PHY->dlsch[i][0]; + + if((dlsch != NULL) && (dlsch->rnti == rnti)) { + void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch); + LOG_I(RRC, "clean_eNb_dlsch dlsch[%d] UE %x \n", i, rnti); + clean_eNb_dlsch(dlsch); + } + } + + if (rrc_agent_registered[mod_id]) { + agent_rrc_xface[mod_id]->flexran_agent_notify_ue_state_change(mod_id, + rnti, PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + } + + for(j = 0; j < 10; j++) { + ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; - for(j = 0; j < 10; j++){ - ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; - if(ul_req_tmp){ - pdu_number = ul_req_tmp->number_of_pdus; - for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ - if((ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_cqi_pdu.ue_information.ue_information_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) || - (ul_req_tmp->ul_config_pdu_list[pdu_index].srs_pdu.srs_pdu_rel8.rnti == rnti)){ - LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); - if(pdu_index < pdu_number -1){ - memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); - } - ul_req_tmp->number_of_pdus--; - } - } + if(ul_req_tmp) { + pdu_number = ul_req_tmp->number_of_pdus; + + for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--) { + if((ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_cqi_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].uci_sr_pdu.ue_information.ue_information_rel8.rnti == rnti) || + (ul_req_tmp->ul_config_pdu_list[pdu_index].srs_pdu.srs_pdu_rel8.rnti == rnti)) { + LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number); + + if(pdu_index < pdu_number -1) { + memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); } + + ul_req_tmp->number_of_pdus--; } } - rrc_mac_remove_ue(mod_id,rnti); - rrc_rlc_remove_ue(&ctxt); - pdcp_remove_UE(&ctxt); - - if(remove_UEContext){ - ue_context_pP = rrc_eNB_get_ue_context( - RC.rrc[mod_id],rnti); - if(ue_context_pP){ - rrc_eNB_remove_ue_context(&ctxt,RC.rrc[mod_id], - (struct rrc_eNB_ue_context_s*) ue_context_pP); - } - } - LOG_I(RRC, "[release_UE_in_freeList] remove UE %x from freeList\n", rnti); - remove_UE_from_freelist(mod_id, rnti); + } + } + } + + rrc_mac_remove_ue(mod_id,rnti); + rrc_rlc_remove_ue(&ctxt); + pdcp_remove_UE(&ctxt); + + if(remove_UEContext) { + ue_context_pP = rrc_eNB_get_ue_context( + RC.rrc[mod_id],rnti); + + if(ue_context_pP) { + rrc_eNB_remove_ue_context(&ctxt,RC.rrc[mod_id], + (struct rrc_eNB_ue_context_s *) ue_context_pP); } + } + + LOG_I(RRC, "[release_UE_in_freeList] remove UE %x from freeList\n", rnti); + remove_UE_from_freelist(mod_id, rnti); } + } } //----------------------------------------------------------------------------- +/* +* Process the rrc connection setup complete message from UE (SRB1 Active) +*/ void rrc_eNB_process_RRCConnectionSetupComplete( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, - LTE_RRCConnectionSetupComplete_r8_IEs_t * rrcConnectionSetupComplete + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, + LTE_RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete ) //----------------------------------------------------------------------------- { LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing LTE_RRCConnectionSetupComplete from UE (SRB1 Active)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - - ue_context_pP->ue_context.Srb1.Active=1; + ue_context_pP->ue_context.Srb1.Active = 1; + ue_context_pP->ue_context.Status = RRC_CONNECTED; + ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); if (EPC_MODE_ENABLED == 1) { // Forward message to S1AP layer - rrc_eNB_send_S1AP_NAS_FIRST_REQ( - ctxt_pP, - ue_context_pP, - rrcConnectionSetupComplete); + rrc_eNB_send_S1AP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcConnectionSetupComplete); } else { // RRC loop back (no S1AP), send SecurityModeCommand to UE - rrc_eNB_generate_SecurityModeCommand( - ctxt_pP, - ue_context_pP); - // rrc_eNB_generate_UECapabilityEnquiry(enb_mod_idP,frameP,ue_mod_idP); + rrc_eNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP); } } //----------------------------------------------------------------------------- void rrc_eNB_generate_SecurityModeCommand( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ) //----------------------------------------------------------------------------- { uint8_t buffer[100]; uint8_t size; - T(T_ENB_RRC_SECURITY_MODE_COMMAND, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - size = do_SecurityModeCommand( ctxt_pP, buffer, rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), ue_context_pP->ue_context.ciphering_algorithm, ue_context_pP->ue_context.integrity_algorithm); - - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Security Mode Command\n"); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size); - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (securityModeCommand to UE MUI %d) --->[PDCP][RB %02d]\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, rrc_eNB_mui, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1081,50 +1065,42 @@ rrc_eNB_generate_SecurityModeCommand( ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } //----------------------------------------------------------------------------- void rrc_eNB_generate_UECapabilityEnquiry( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ) //----------------------------------------------------------------------------- { - uint8_t buffer[100]; uint8_t size; - T(T_ENB_RRC_UE_CAPABILITY_ENQUIRY, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - size = do_UECapabilityEnquiry( ctxt_pP, buffer, rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate UECapabilityEnquiry (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size); - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (UECapabilityEnquiry MUI %d) --->[PDCP][RB %02d]\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, rrc_eNB_mui, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1135,40 +1111,34 @@ rrc_eNB_generate_UECapabilityEnquiry( ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionReject( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ) //----------------------------------------------------------------------------- { - T(T_ENB_RRC_CONNECTION_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionReject(ctxt_pP->module_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); - + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); LOG_DUMPMSG(RRC,DEBUG_RRC, (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, "[MSG] RRCConnectionReject\n"); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1178,7 +1148,6 @@ rrc_eNB_generate_RRCConnectionReject( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionReject (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -1188,8 +1157,8 @@ rrc_eNB_generate_RRCConnectionReject( //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionReestablishment( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ) //----------------------------------------------------------------------------- @@ -1198,16 +1167,14 @@ rrc_eNB_generate_RRCConnectionReestablishment( LTE_SRB_ToAddModList_t **SRB_configList; LTE_SRB_ToAddMod_t *SRB1_config; int cnt; - T(T_ENB_RRC_CONNECTION_REESTABLISHMENT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - SRB_configList = &ue_context_pP->ue_context.SRB_configList; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionReestablishment(ctxt_pP, ue_context_pP, CC_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), SRB_configList, @@ -1216,7 +1183,7 @@ rrc_eNB_generate_RRCConnectionReestablishment( (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, "[MSG] RRCConnectionReestablishment\n" - ); + ); // configure SRB1 for UE if (*SRB_configList != NULL) { @@ -1239,38 +1206,38 @@ rrc_eNB_generate_RRCConnectionReestablishment( PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_eNB\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); rrc_mac_config_req_eNB(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - ctxt_pP->rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + ctxt_pP->rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - (struct LTE_PhysicalConfigDedicated* ) ue_context_pP->ue_context.physicalConfigDedicated, + (struct LTE_PhysicalConfigDedicated * ) ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - 1, - SRB1_logicalChannelConfig, - ue_context_pP->ue_context.measGapConfig, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - ,(LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + ,(LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); + ); break; } } @@ -1284,23 +1251,23 @@ rrc_eNB_generate_RRCConnectionReestablishment( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP->ue_context.rnti, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionReestablishment (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); - if(UE_id != -1){ + + if(UE_id != -1) { // activate release timer, if RRCComplete not received after 100 frames, remove UE RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; // remove UE after 100 frames after LTE_RRCConnectionReestablishmentRelease is triggered RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 1000; - }else{ + } else { LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Generating LTE_RRCConnectionReestablishment without UE_id(MAC) rnti %x\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); + PROTOCOL_RRC_CTXT_UE_FMT" Generating LTE_RRCConnectionReestablishment without UE_id(MAC) rnti %x\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); } + // activate release timer, if RRCComplete not received after 100 frames, remove UE ue_context_pP->ue_context.ue_reestablishment_timer = 1; // remove UE after 100 frames after LTE_RRCConnectionReestablishmentRelease is triggered @@ -1310,25 +1277,23 @@ rrc_eNB_generate_RRCConnectionReestablishment( //----------------------------------------------------------------------------- void rrc_eNB_process_RRCConnectionReestablishmentComplete( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rnti_t reestablish_rnti, - rrc_eNB_ue_context_t* ue_context_pP, + rrc_eNB_ue_context_t *ue_context_pP, const uint8_t xid, - LTE_RRCConnectionReestablishmentComplete_r8_IEs_t * LTE_RRCConnectionReestablishmentComplete + LTE_RRCConnectionReestablishmentComplete_r8_IEs_t *LTE_RRCConnectionReestablishmentComplete ) //----------------------------------------------------------------------------- { LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, processing LTE_RRCConnectionReestablishmentComplete from UE (SRB1 Active)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - LTE_DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList; - LTE_SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; - LTE_SRB_ToAddModList_t** SRB_configList2 = NULL; - LTE_DRB_ToAddModList_t** DRB_configList2 = NULL; + LTE_DRB_ToAddModList_t *DRB_configList = ue_context_pP->ue_context.DRB_configList; + LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; + LTE_SRB_ToAddModList_t **SRB_configList2 = NULL; + LTE_DRB_ToAddModList_t **DRB_configList2 = NULL; struct LTE_SRB_ToAddMod *SRB2_config = NULL; struct LTE_DRB_ToAddMod *DRB_config = NULL; int i = 0; @@ -1352,183 +1317,174 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( (void)dedicatedInfoNas; LTE_C_RNTI_t *cba_RNTI = NULL; uint8_t next_xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); - ue_context_pP->ue_context.Status = RRC_CONNECTED; + ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED ue_context_pP->ue_context.reestablishment_xid = next_xid; - SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[xid]; + // get old configuration of SRB2 if (*SRB_configList2 != NULL) { - if((*SRB_configList2)->list.count!=0){ + if((*SRB_configList2)->list.count!=0) { LOG_D(RRC, "SRB_configList2(%p) count is %d\n SRB_configList2->list.array[0] addr is %p", - SRB_configList2, (*SRB_configList2)->list.count, (*SRB_configList2)->list.array[0]); + SRB_configList2, (*SRB_configList2)->list.count, (*SRB_configList2)->list.array[0]); } + for (i = 0; (i < (*SRB_configList2)->list.count) && (i < 3); i++) { - if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ){ + if ((*SRB_configList2)->list.array[i]->srb_Identity == 2 ) { LOG_D(RRC, "get SRB2_config from (ue_context_pP->ue_context.SRB_configList2[%d])\n", xid); SRB2_config = (*SRB_configList2)->list.array[i]; break; } } } + SRB_configList2 = &ue_context_pP->ue_context.SRB_configList2[next_xid]; DRB_configList2 = &ue_context_pP->ue_context.DRB_configList2[next_xid]; - if(SRB_configList2!=NULL){ + if(SRB_configList2!=NULL) { if (*SRB_configList2) { free(*SRB_configList2); LOG_D(RRC, "free(ue_context_pP->ue_context.SRB_configList2[%d])\n", next_xid); } - }else{ - LOG_E(RRC, "SRB_configList2 is null\n"); + } else { + LOG_E(RRC, "SRB_configList2 is null\n"); } + *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2)); + if (SRB2_config != NULL) { // Add SRB2 to SRB configuration list - ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); ASN_SEQUENCE_ADD(&(*SRB_configList2)->list, SRB2_config); - LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList\n", - SRB2_config->srb_Identity); + SRB2_config->srb_Identity); LOG_D(RRC, "Add SRB2_config (srb_Identity:%ld) to ue_context_pP->ue_context.SRB_configList2[%d]\n", - SRB2_config->srb_Identity, next_xid); + SRB2_config->srb_Identity, next_xid); } else { // SRB configuration list only contains SRB1. LOG_W(RRC,"SRB2 configuration does not exist in SRB configuration list\n"); } - - - if(DRB_configList2!=NULL){ + if(DRB_configList2!=NULL) { if (*DRB_configList2) { free(*DRB_configList2); LOG_D(RRC, "free(ue_context_pP->ue_context.DRB_configList2[%d])\n", next_xid); } - }else{ - LOG_E(RRC, "DRB_configList2 is null\n"); + } else { + LOG_E(RRC, "DRB_configList2 is null\n"); } + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); if (DRB_configList != NULL) { LOG_D(RRC, "get DRB_config from (ue_context_pP->ue_context.DRB_configList)\n"); + for (i = 0; (i < DRB_configList->list.count) && (i < 3); i++) { DRB_config = DRB_configList->list.array[i]; - // Add DRB to DRB configuration list, for LTE_RRCConnectionReconfigurationComplete ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); } } + ue_context_pP->ue_context.Srb1.Active = 1; //ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = 2; - -#if defined(ENABLE_USE_MME) - hashtable_rc_t h_rc; - int j; - rrc_ue_s1ap_ids_t* rrc_ue_s1ap_ids_p = NULL; - uint16_t ue_initial_id = ue_context_pP->ue_context.ue_initial_id; - uint32_t eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - eNB_RRC_INST *rrc_instance_p = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]; - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&rrc_ue_s1ap_ids_p); - if (h_rc == HASH_TABLE_OK) { - rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; - } - } - if (ue_initial_id != 0) { - h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&rrc_ue_s1ap_ids_p); - if (h_rc == HASH_TABLE_OK) { - rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; - } +#if defined(ENABLE_USE_MME) + hashtable_rc_t h_rc; + int j; + rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL; + uint16_t ue_initial_id = ue_context_pP->ue_context.ue_initial_id; + uint32_t eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; + eNB_RRC_INST *rrc_instance_p = RC.rrc[ENB_INSTANCE_TO_MODULE_ID(ctxt_pP->instance)]; + + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_p->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&rrc_ue_s1ap_ids_p); + + if (h_rc == HASH_TABLE_OK) { + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; } + } - gtpv1u_enb_create_tunnel_req_t create_tunnel_req; - - /* Save e RAB information for later */ - memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); - - for ( j = 0, i = 0; i < NB_RB_MAX; i++) { - if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED || ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_DONE) { - create_tunnel_req.eps_bearer_id[j] = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; - create_tunnel_req.sgw_S1u_teid[j] = ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + if (ue_initial_id != 0) { + h_rc = hashtable_get(rrc_instance_p->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void **)&rrc_ue_s1ap_ids_p); - memcpy(&create_tunnel_req.sgw_addr[j], - &ue_context_pP->ue_context.e_rab[i].param.sgw_addr, - sizeof(transport_layer_addr_t)); - j++; - } + if (h_rc == HASH_TABLE_OK) { + rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; } + } - create_tunnel_req.rnti = ctxt_pP->rnti; // warning put zero above - create_tunnel_req.num_tunnels = j; + gtpv1u_enb_create_tunnel_req_t create_tunnel_req; + /* Save e RAB information for later */ + memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); + + for ( j = 0, i = 0; i < NB_RB_MAX; i++) { + if (ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED || ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_DONE) { + create_tunnel_req.eps_bearer_id[j] = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + create_tunnel_req.sgw_S1u_teid[j] = ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + memcpy(&create_tunnel_req.sgw_addr[j], + &ue_context_pP->ue_context.e_rab[i].param.sgw_addr, + sizeof(transport_layer_addr_t)); + j++; + } + } - gtpv1u_update_s1u_tunnel( - ctxt_pP->instance, - &create_tunnel_req, - reestablish_rnti); + create_tunnel_req.rnti = ctxt_pP->rnti; // warning put zero above + create_tunnel_req.num_tunnels = j; + gtpv1u_update_s1u_tunnel( + ctxt_pP->instance, + &create_tunnel_req, + reestablish_rnti); #endif /* Update RNTI in ue_context */ ue_context_pP->ue_id_rnti = ctxt_pP->rnti; // here ue_id_rnti is just a key, may be something else ue_context_pP->ue_context.rnti = ctxt_pP->rnti; #if defined(ENABLE_USE_MME) - uint8_t send_security_mode_command = FALSE; - rrc_pdcp_config_security( - ctxt_pP, - ue_context_pP, - send_security_mode_command); - LOG_D(RRC, "set security successfully \n"); + uint8_t send_security_mode_command = FALSE; + rrc_pdcp_config_security( + ctxt_pP, + ue_context_pP, + send_security_mode_command); + LOG_D(RRC, "set security successfully \n"); #endif // Measurement ID list MeasId_list = CALLOC(1, sizeof(*MeasId_list)); memset((void *)MeasId_list, 0, sizeof(*MeasId_list)); - MeasId0 = CALLOC(1, sizeof(*MeasId0)); MeasId0->measId = 1; MeasId0->measObjectId = 1; MeasId0->reportConfigId = 1; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0); - MeasId1 = CALLOC(1, sizeof(*MeasId1)); MeasId1->measId = 2; MeasId1->measObjectId = 1; MeasId1->reportConfigId = 2; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1); - MeasId2 = CALLOC(1, sizeof(*MeasId2)); MeasId2->measId = 3; MeasId2->measObjectId = 1; MeasId2->reportConfigId = 3; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2); - MeasId3 = CALLOC(1, sizeof(*MeasId3)); MeasId3->measId = 4; MeasId3->measObjectId = 1; MeasId3->reportConfigId = 4; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3); - MeasId4 = CALLOC(1, sizeof(*MeasId4)); MeasId4->measId = 5; MeasId4->measObjectId = 1; MeasId4->reportConfigId = 5; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4); - MeasId5 = CALLOC(1, sizeof(*MeasId5)); MeasId5->measId = 6; MeasId5->measObjectId = 1; MeasId5->reportConfigId = 6; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5); - // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list; - // Add one EUTRA Measurement Object MeasObj_list = CALLOC(1, sizeof(*MeasObj_list)); memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list)); - // Configure MeasObject - MeasObj = CALLOC(1, sizeof(*MeasObj)); memset((void *)MeasObj, 0, sizeof(*MeasObj)); - MeasObj->measObjectId = 1; MeasObj->measObject.present = LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA; MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz @@ -1540,10 +1496,8 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1; MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6; MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL; // Default is 15 or 0dB - MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList = (LTE_CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); - CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; // Add adjacent cell lists (6 per eNB) @@ -1552,28 +1506,19 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( CellToAdd->cellIndex = i + 1; CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); CellToAdd->cellIndividualOffset = LTE_Q_OffsetRange_dB0; - ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); } ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; - // Report Configurations for periodical, A1-A5 events ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list)); - ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per)); - ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1)); - ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2)); - ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3)); - ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4)); - ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5)); - ReportConfig_per->reportConfigId = 1; ReportConfig_per->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1585,9 +1530,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per); - ReportConfig_A1->reportConfigId = 2; ReportConfig_A1->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1598,13 +1541,11 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( a1_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1. a1_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1); if (RC.rrc[ctxt_pP->module_id]->HO_flag == 1 /*HO_MEASURMENT */ ) { @@ -1620,39 +1561,32 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( eventA2.a2_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA2.a2_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2); - ReportConfig_A3->reportConfigId = 4; ReportConfig_A3->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present = LTE_ReportConfigEUTRA__triggerType_PR_event; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = LTE_ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset = 1; //10; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA3.reportOnLeave = 1; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis = 0.5; // FIXME ...hysteresis is of type long! ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = LTE_TimeToTrigger_ms40; ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3); - ReportConfig_A4->reportConfigId = 5; ReportConfig_A4->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1663,16 +1597,13 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( eventA4.a4_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA4.a4_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4); - ReportConfig_A5->reportConfigId = 6; ReportConfig_A5->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -1687,20 +1618,16 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( eventA5.a5_Threshold1.choice.threshold_RSRP = 10; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA5.a5_Threshold2.choice.threshold_RSRP = 10; - ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; - rsrp = CALLOC(1, sizeof(LTE_RSRP_Range_t)); *rsrp = 20; - Sparams = CALLOC(1, sizeof(*Sparams)); Sparams->present = LTE_MeasConfig__speedStatePars_PR_setup; Sparams->choice.setup.timeToTrigger_SF.sf_High = LTE_SpeedStateScaleFactors__sf_Medium_oDot75; @@ -1709,7 +1636,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5; Sparams->choice.setup.mobilityStateParameters.t_Evaluation = LTE_MobilityStateParameters__t_Evaluation_s60; Sparams->choice.setup.mobilityStateParameters.t_HystNormal = LTE_MobilityStateParameters__t_HystNormal_s120; - quantityConfig = CALLOC(1, sizeof(*quantityConfig)); memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct LTE_QuantityConfigEUTRA)); @@ -1723,7 +1649,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = LTE_FilterCoefficient_fc4; *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = LTE_FilterCoefficient_fc4; - LOG_I(RRC, "[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n", ctxt_pP->module_id, ctxt_pP->frame); @@ -1737,15 +1662,14 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig = CALLOC(1, sizeof(*ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, (void *)ue_context_pP->ue_context.mac_MainConfig, sizeof(LTE_MAC_MainConfig_t)); ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated = CALLOC(1, sizeof(LTE_PhysicalConfigDedicated_t)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, - (void*)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(LTE_PhysicalConfigDedicated_t)); + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, + (void *)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(LTE_PhysicalConfigDedicated_t)); ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.sps_Config = NULL; //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,(void *)rrc_inst->sps_Config[ue_mod_idP],sizeof(SPS_Config_t)); - } #ifdef CBA @@ -1773,7 +1697,6 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif - #if defined(ENABLE_ITTI) /* Initialize NAS list */ dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); @@ -1784,7 +1707,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(dedicatedInfoNas, - (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, + (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); LOG_D(RRC, "Add LTE_DedicatedInfoNAS(%d) to LTE_DedicatedInfoNASList\n", i); ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); @@ -1796,11 +1719,10 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; } - /* TODO should test if e RAB are Ok before! */ ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", - i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); + i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); } /* If list is empty free the list and reset the address */ @@ -1810,43 +1732,39 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif - // send LTE_RRCConnectionReconfiguration memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, next_xid, //Transaction_id, - (LTE_SRB_ToAddModList_t*)*SRB_configList2, // SRB_configList - (LTE_DRB_ToAddModList_t*)DRB_configList, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // maybe ue_context_pP->ue_context.sps_Config, - (struct LTE_PhysicalConfigDedicated*)ue_context_pP->ue_context.physicalConfigDedicated, + (LTE_SRB_ToAddModList_t *)*SRB_configList2, // SRB_configList + (LTE_DRB_ToAddModList_t *)DRB_configList, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // maybe ue_context_pP->ue_context.sps_Config, + (struct LTE_PhysicalConfigDedicated *)ue_context_pP->ue_context.physicalConfigDedicated, #ifdef EXMIMO_IOT NULL, NULL, NULL,NULL, #else - (LTE_MeasObjectToAddModList_t*)MeasObj_list, // MeasObj_list, - (LTE_ReportConfigToAddModList_t*)ReportConfig_list, // ReportConfig_list, - (LTE_QuantityConfig_t*)quantityConfig, //quantityConfig, - (LTE_MeasIdToAddModList_t*)NULL, -#endif - (LTE_MAC_MainConfig_t*)ue_context_pP->ue_context.mac_MainConfig, - (LTE_MeasGapConfig_t*)NULL, - (LTE_MobilityControlInfo_t*)NULL, - (struct LTE_MeasConfig__speedStatePars*)Sparams, // Sparams, - (LTE_RSRP_Range_t*)rsrp, // rsrp, - (LTE_C_RNTI_t*)cba_RNTI, // cba_RNTI - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, //dedicatedInfoNASList - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + (LTE_MeasObjectToAddModList_t *)MeasObj_list, // MeasObj_list, + (LTE_ReportConfigToAddModList_t *)ReportConfig_list, // ReportConfig_list, + (LTE_QuantityConfig_t *)quantityConfig, //quantityConfig, + (LTE_MeasIdToAddModList_t *)NULL, +#endif + (LTE_MAC_MainConfig_t *)ue_context_pP->ue_context.mac_MainConfig, + (LTE_MeasGapConfig_t *)NULL, + (LTE_MobilityControlInfo_t *)NULL, + (struct LTE_MeasConfig__speedStatePars *)Sparams, // Sparams, + (LTE_RSRP_Range_t *)rsrp, // rsrp, + (LTE_C_RNTI_t *)cba_RNTI, // cba_RNTI + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList, //dedicatedInfoNASList + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL + , (LTE_SCellToAddMod_r10_t *)NULL #endif ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); - - #if defined(ENABLE_ITTI) /* Free all NAS PDUs */ @@ -1859,19 +1777,18 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( } #endif - if(size==65535){ + + if(size==65535) { LOG_E(RRC,"RRC decode err!!! do_RRCConnectionReconfiguration\n"); put_UE_in_freelist(ctxt_pP->module_id, reestablish_rnti, 0); return; - }else{ + } else { LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE id %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - LOG_D(RRC, "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1882,55 +1799,55 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } + // delete UE data of prior RNTI. UE use current RNTI. -// protocol_ctxt_t ctxt_prior = *ctxt_pP; -// ctxt_prior.rnti = reestablish_rnti; -// -// LTE_eNB_ULSCH_t *ulsch = NULL; -// nfapi_ul_config_request_body_t *ul_req_tmp = NULL; -// PHY_VARS_eNB *eNB_PHY = NULL; -// eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id]; -// for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { -// eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id]; -// for (int i=0; i<MAX_MOBILES_PER_ENB; i++) { -// ulsch = eNB_PHY->ulsch[i]; -// if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){ -// void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); -// LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti); -// clean_eNb_ulsch(ulsch); -// break; -// } -// } -// -// for(int j = 0; j < 10; j++){ -// ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; -// if(ul_req_tmp){ -// int pdu_number = ul_req_tmp->number_of_pdus; -// for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ -// if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == ctxt_prior.rnti){ -// LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", ctxt_prior.rnti, pdu_index, pdu_number); -// if(pdu_index < pdu_number -1){ -// memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); -// } -// ul_req_tmp->number_of_pdus--; -// } -// } -// } -// } -// } -// rrc_mac_remove_ue(ctxt_prior.module_id, ctxt_prior.rnti); -// rrc_rlc_remove_ue(&ctxt_prior); -// pdcp_remove_UE(&ctxt_prior); + // protocol_ctxt_t ctxt_prior = *ctxt_pP; + // ctxt_prior.rnti = reestablish_rnti; + // + // LTE_eNB_ULSCH_t *ulsch = NULL; + // nfapi_ul_config_request_body_t *ul_req_tmp = NULL; + // PHY_VARS_eNB *eNB_PHY = NULL; + // eNB_MAC_INST *eNB_MAC = RC.mac[ctxt_prior.module_id]; + // for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + // eNB_PHY = RC.eNB[ctxt_prior.module_id][CC_id]; + // for (int i=0; i<MAX_MOBILES_PER_ENB; i++) { + // ulsch = eNB_PHY->ulsch[i]; + // if((ulsch != NULL) && (ulsch->rnti == ctxt_prior.rnti)){ + // void clean_eNb_ulsch(LTE_eNB_ULSCH_t *ulsch); + // LOG_I(RRC, "clean_eNb_ulsch UE %x \n", ctxt_prior.rnti); + // clean_eNb_ulsch(ulsch); + // break; + // } + // } + // + // for(int j = 0; j < 10; j++){ + // ul_req_tmp = &eNB_MAC->UL_req_tmp[CC_id][j].ul_config_request_body; + // if(ul_req_tmp){ + // int pdu_number = ul_req_tmp->number_of_pdus; + // for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){ + // if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == ctxt_prior.rnti){ + // LOG_I(RRC, "remove UE %x from ul_config_pdu_list %d/%d\n", ctxt_prior.rnti, pdu_index, pdu_number); + // if(pdu_index < pdu_number -1){ + // memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t)); + // } + // ul_req_tmp->number_of_pdus--; + // } + // } + // } + // } + // } + // rrc_mac_remove_ue(ctxt_prior.module_id, ctxt_prior.rnti); + // rrc_rlc_remove_ue(&ctxt_prior); + // pdcp_remove_UE(&ctxt_prior); // add UE info to freeList for RU_thread to remove the UE instead of remove it here LOG_I(RRC, "[RRCConnectionReestablishment]put UE %x into freeList\n", reestablish_rnti); put_UE_in_freelist(ctxt_pP->module_id, reestablish_rnti, 0); @@ -1939,34 +1856,32 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionReestablishmentReject( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ) //----------------------------------------------------------------------------- { int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); - if(UE_id != -1){ + + if(UE_id != -1) { RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1; RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 20; - }else{ + } else { LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Generating LTE_RRCConnectionReestablishmentReject without UE_id(MAC) rnti %x\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); + PROTOCOL_RRC_CTXT_UE_FMT" Generating LTE_RRCConnectionReestablishmentReject without UE_id(MAC) rnti %x\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); } T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REJECT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionReestablishmentReject(ctxt_pP->module_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); - + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload); LOG_DUMPMSG(RRC,DEBUG_RRC, (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, "[MSG] RRCConnectionReestablishmentReject\n"); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -1976,7 +1891,6 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP == NULL ? -1 : ue_context_pP->ue_context.rnti, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionReestablishmentReject (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -1984,45 +1898,36 @@ rrc_eNB_generate_RRCConnectionReestablishmentReject( } //----------------------------------------------------------------------------- +/* +* Generate the RRC Connection Release to UE. +* If received, UE should switch to RRC_IDLE mode. +*/ void rrc_eNB_generate_RRCConnectionRelease( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ) //----------------------------------------------------------------------------- { - - uint8_t buffer[RRC_BUF_SIZE]; - uint16_t size; - + uint8_t buffer[RRC_BUF_SIZE]; + uint16_t size = 0; + memset(buffer, 0, RRC_BUF_SIZE); T(T_ENB_RRC_CONNECTION_RELEASE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCConnectionRelease(ctxt_pP->module_id, buffer,rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id)); - // set release timer - //ue_context_pP->ue_context.ue_release_timer=1; - // remove UE after 10 frames after LTE_RRCConnectionRelease is triggered - //ue_context_pP->ue_context.ue_release_timer_thres=100; - // set release timer -// ue_context_pP->ue_context.ue_release_timer_rrc = 1; - // remove UE after 10 frames after LTE_RRCConnectionRelease is triggered -// ue_context_pP->ue_context.ue_release_timer_thres_rrc = 100; ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; - //ue_context_pP->ue_context.ue_release_timer_s1 = 0; + ue_context_pP->ue_context.ue_rrc_inactivity_timer = 0; LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate LTE_RRCConnectionRelease (bytes %d)\n", + PROTOCOL_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCConnectionRelease (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size); - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" --- PDCP_DATA_REQ/%d Bytes (rrcConnectionRelease MUI %d) --->[PDCP][RB %u]\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), size, rrc_eNB_mui, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -2034,49 +1939,52 @@ rrc_eNB_generate_RRCConnectionRelease( rrc_eNB_mui, size); pthread_mutex_lock(&rrc_release_freelist); - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 0){ - if(ue_context_pP->ue_context.ue_release_timer_s1 > 0){ + + for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 0) { + if (ue_context_pP->ue_context.ue_release_timer_s1 > 0) { rrc_release_info.RRC_release_ctrl[release_num].flag = 1; - }else{ + } else { rrc_release_info.RRC_release_ctrl[release_num].flag = 2; } + rrc_release_info.RRC_release_ctrl[release_num].rnti = ctxt_pP->rnti; rrc_release_info.RRC_release_ctrl[release_num].rrc_eNB_mui = rrc_eNB_mui; rrc_release_info.num_UEs++; - LOG_D(RRC,"Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n",release_num, - ctxt_pP->rnti, rrc_eNB_mui,rrc_release_info.RRC_release_ctrl[release_num].flag); + LOG_D(RRC, "Generate DLSCH Release send: index %d rnti %x mui %d flag %d \n", + release_num, + ctxt_pP->rnti, + rrc_eNB_mui, + rrc_release_info.RRC_release_ctrl[release_num].flag); break; } } + pthread_mutex_unlock(&rrc_release_freelist); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + rrc_data_req(ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } -uint8_t qci_to_priority[9]={2,4,3,5,1,6,7,8,9}; +uint8_t qci_to_priority[9]= {2,4,3,5,1,6,7,8,9}; // TBD: this directive can be remived if we create a similar e_rab_param_t structure in RRC context -#if defined(ENABLE_ITTI) +#if defined(ENABLE_ITTI) //----------------------------------------------------------------------------- void -rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state - ) +rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + const uint8_t ho_state + ) //----------------------------------------------------------------------------- { - uint8_t buffer[RRC_BUF_SIZE]; uint16_t size; int i; - struct LTE_DRB_ToAddMod *DRB_config = NULL; struct LTE_RLC_Config *DRB_rlc_config = NULL; struct LTE_PDCP_Config *DRB_pdcp_config = NULL; @@ -2085,61 +1993,53 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co struct LTE_LogicalChannelConfig *DRB_lchan_config = NULL; struct LTE_LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters = NULL; - // LTE_DRB_ToAddModList_t** DRB_configList=&ue_context_pP->ue_context.DRB_configList; - LTE_DRB_ToAddModList_t* DRB_configList=ue_context_pP->ue_context.DRB_configList; - LTE_DRB_ToAddModList_t** DRB_configList2=NULL; + // LTE_DRB_ToAddModList_t** DRB_configList=&ue_context_pP->ue_context.DRB_configList; + LTE_DRB_ToAddModList_t *DRB_configList=ue_context_pP->ue_context.DRB_configList; + LTE_DRB_ToAddModList_t **DRB_configList2=NULL; //DRB_ToAddModList_t** RRC_DRB_configList=&ue_context_pP->ue_context.DRB_configList; - struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; LTE_DedicatedInfoNAS_t *dedicatedInfoNas = NULL; /* for no gcc warnings */ (void)dedicatedInfoNas; - long *logicalchannelgroup_drb; -// int drb_identity_index=0; - + // int drb_identity_index=0; uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); //Transaction_id, DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid]; + if (*DRB_configList2) { free(*DRB_configList2); } + //*DRB_configList = CALLOC(1, sizeof(*DRB_configList)); - *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); /* Initialize NAS list */ dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); - int e_rab_done=0; - - for ( i = 0 ; - i < ue_context_pP->ue_context.setup_e_rabs ; - i++){ - if (e_rab_done >= ue_context_pP->ue_context.nb_of_e_rabs){ - break; + for ( i = 0 ; + i < ue_context_pP->ue_context.setup_e_rabs ; + i++) { + if (e_rab_done >= ue_context_pP->ue_context.nb_of_e_rabs) { + break; } - + // bypass the new and already configured erabs if (ue_context_pP->ue_context.e_rab[i].status >= E_RAB_STATUS_DONE) { -// drb_identity_index++; + // drb_identity_index++; continue; } - - DRB_config = CALLOC(1, sizeof(*DRB_config)); + DRB_config = CALLOC(1, sizeof(*DRB_config)); DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); // allowed value 5..15, value : x+4 - *(DRB_config->eps_BearerIdentity) = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation - - // DRB_config->drb_Identity = 1 + drb_identity_index + e_rab_done;// + i ;// (LTE_DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id; - // 1 + drb_identiy_index; + *(DRB_config->eps_BearerIdentity) = ue_context_pP->ue_context.e_rab[i].param.e_rab_id;//+ 4; // especial case generation + // DRB_config->drb_Identity = 1 + drb_identity_index + e_rab_done;// + i ;// (LTE_DRB_Identity_t) ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + // 1 + drb_identiy_index; DRB_config->drb_Identity = i+1; - DRB_config->logicalChannelIdentity = CALLOC(1, sizeof(long)); *(DRB_config->logicalChannelIdentity) = DRB_config->drb_Identity + 2; //(long) (ue_context_pP->ue_context.e_rab[i].param.e_rab_id + 2); // value : x+2 - DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); DRB_config->rlc_Config = DRB_rlc_config; - DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); DRB_config->pdcp_Config = DRB_pdcp_config; DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); @@ -2147,123 +2047,114 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co DRB_pdcp_config->rlc_AM = NULL; DRB_pdcp_config->rlc_UM = NULL; - - switch (ue_context_pP->ue_context.e_rab[i].param.qos.qci){ + switch (ue_context_pP->ue_context.e_rab[i].param.qos.qci) { /* * type: realtime data with medium packer error rate * action: swtich to RLC UM */ - case 1: // 100ms, 10^-2, p2, GBR - case 2: // 150ms, 10^-3, p4, GBR - case 3: // 50ms, 10^-3, p3, GBR - case 4: // 300ms, 10^-6, p5 - case 7: // 100ms, 10^-3, p7, GBR - case 9: // 300ms, 10^-6, p9 - case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR - case 66: // 100ms, 10^-2, p2, non-mission critical voice , GBR - // RLC - DRB_rlc_config->present = LTE_RLC_Config_PR_um_Bi_Directional; - DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; - DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; - DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; - // PDCP - PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); - DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; - PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; - break; - + case 1: // 100ms, 10^-2, p2, GBR + case 2: // 150ms, 10^-3, p4, GBR + case 3: // 50ms, 10^-3, p3, GBR + case 4: // 300ms, 10^-6, p5 + case 7: // 100ms, 10^-3, p7, GBR + case 9: // 300ms, 10^-6, p9 + case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR + case 66: // 100ms, 10^-2, p2, non-mission critical voice , GBR + // RLC + DRB_rlc_config->present = LTE_RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; + // PDCP + PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + break; + /* * type: non-realtime data with low packer error rate * action: swtich to RLC AM */ - case 5: // 100ms, 10^-6, p1 , IMS signaling - case 6: // 300ms, 10^-6, p6 - case 8: // 300ms, 10^-6, p8 - case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority - case 70: // 200ms, 10^-6, p5.5, mision critical data - // RLC - DRB_rlc_config->present = LTE_RLC_Config_PR_am; - DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms50; - DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p16; - DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; - DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; - DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; - DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms25; - - // PDCP - PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); - DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; - PDCP_rlc_AM->statusReportRequired = FALSE; - - break; - default : - LOG_E(RRC,"not supported qci %d\n", ue_context_pP->ue_context.e_rab[i].param.qos.qci); - ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_FAILED; - ue_context_pP->ue_context.e_rab[i].xid = xid; - e_rab_done++; - continue; + case 5: // 100ms, 10^-6, p1 , IMS signaling + case 6: // 300ms, 10^-6, p6 + case 8: // 300ms, 10^-6, p8 + case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority + case 70: // 200ms, 10^-6, p5.5, mision critical data + // RLC + DRB_rlc_config->present = LTE_RLC_Config_PR_am; + DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms50; + DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p16; + DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; + DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; + DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; + DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms25; + // PDCP + PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); + DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; + PDCP_rlc_AM->statusReportRequired = FALSE; + break; + + default : + LOG_E(RRC,"not supported qci %d\n", ue_context_pP->ue_context.e_rab[i].param.qos.qci); + ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_FAILED; + ue_context_pP->ue_context.e_rab[i].xid = xid; + e_rab_done++; + continue; } DRB_pdcp_config->headerCompression.present = LTE_PDCP_Config__headerCompression_PR_notUsed; - DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config)); DRB_config->logicalChannelConfig = DRB_lchan_config; DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; if (ue_context_pP->ue_context.e_rab[i].param.qos.qci < 9 ) - DRB_ul_SpecificParameters->priority = qci_to_priority[ue_context_pP->ue_context.e_rab[i].param.qos.qci-1] + 3; + DRB_ul_SpecificParameters->priority = qci_to_priority[ue_context_pP->ue_context.e_rab[i].param.qos.qci-1] + 3; // ue_context_pP->ue_context.e_rab[i].param.qos.allocation_retention_priority.priority_level; - else + else DRB_ul_SpecificParameters->priority= 4; DRB_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; - //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; DRB_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - logicalchannelgroup_drb = CALLOC(1, sizeof(long)); *logicalchannelgroup_drb = 1;//(i+1) % 3; DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; - ASN_SEQUENCE_ADD(&DRB_configList->list, DRB_config); ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); //ue_context_pP->ue_context.DRB_configList2[drb_identity_index] = &(*DRB_configList); - LOG_I(RRC,"EPS ID %ld, DRB ID %ld (index %d), QCI %d, priority %ld, LCID %ld LCGID %ld \n", - *DRB_config->eps_BearerIdentity, - DRB_config->drb_Identity, i, - ue_context_pP->ue_context.e_rab[i].param.qos.qci, - DRB_ul_SpecificParameters->priority, - *(DRB_config->logicalChannelIdentity), - *DRB_ul_SpecificParameters->logicalChannelGroup - ); - + *DRB_config->eps_BearerIdentity, + DRB_config->drb_Identity, i, + ue_context_pP->ue_context.e_rab[i].param.qos.qci, + DRB_ul_SpecificParameters->priority, + *(DRB_config->logicalChannelIdentity), + *DRB_ul_SpecificParameters->logicalChannelGroup + ); e_rab_done++; - ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; + ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; ue_context_pP->ue_context.e_rab[i].xid = xid; - { if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { - dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); - memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf(dedicatedInfoNas, - (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, - ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); - ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); - LOG_I(RRC,"add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length, i); - } - else { - LOG_W(RRC,"Not received activate dedicated EPS bearer context request\n"); + dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); + memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); + ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); + LOG_I(RRC,"add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length, i); + } else { + LOG_W(RRC,"Not received activate dedicated EPS bearer context request\n"); } + /* TODO parameters yet to process ... */ { - // ue_context_pP->ue_context.e_rab[i].param.qos; - // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; - // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + // ue_context_pP->ue_context.e_rab[i].param.qos; + // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; + // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; } } - } /* If list is empty free the list and reset the address */ @@ -2272,33 +2163,29 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co free(dedicatedInfoNASList); dedicatedInfoNASList = NULL; LOG_W(RRC,"dedlicated NAS list is empty, free the list and reset the address\n"); - } + } } else { LOG_W(RRC,"dedlicated NAS list is empty\n"); } memset(buffer, 0, RRC_BUF_SIZE); - - size = do_RRCConnectionReconfiguration(ctxt_pP, - buffer, - xid, - (LTE_SRB_ToAddModList_t*)NULL, - (LTE_DRB_ToAddModList_t*)*DRB_configList2, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // *sps_Config, - NULL, NULL, NULL, NULL,NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + xid, + (LTE_SRB_ToAddModList_t *)NULL, + (LTE_DRB_ToAddModList_t *)*DRB_configList2, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL + , (LTE_SCellToAddMod_r10_t *)NULL #endif ); - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size,"[MSG] RRC Connection Reconfiguration\n"); - - #if defined(ENABLE_ITTI) /* Free all NAS PDUs */ @@ -2309,16 +2196,14 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL; } } -#endif - LOG_I(RRC, +#endif + LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - LOG_D(RRC, "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -2329,7 +2214,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( ctxt_pP, DCCH, @@ -2338,20 +2222,17 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* co size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - - } int -rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state - ) +rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + const uint8_t ho_state + ) //----------------------------------------------------------------------------- { uint8_t buffer[RRC_BUF_SIZE]; uint16_t size; int i, j; - struct LTE_DRB_ToAddMod *DRB_config = NULL; struct LTE_RLC_Config *DRB_rlc_config = NULL; struct LTE_PDCP_Config *DRB_pdcp_config = NULL; @@ -2359,15 +2240,13 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons struct LTE_PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; struct LTE_LogicalChannelConfig *DRB_lchan_config = NULL; struct LTE_LogicalChannelConfig__ul_SpecificParameters - *DRB_ul_SpecificParameters = NULL; - LTE_DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList; - LTE_DRB_ToAddModList_t* DRB_configList2 = NULL; - + *DRB_ul_SpecificParameters = NULL; + LTE_DRB_ToAddModList_t *DRB_configList = ue_context_pP->ue_context.DRB_configList; + LTE_DRB_ToAddModList_t *DRB_configList2 = NULL; struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; LTE_DedicatedInfoNAS_t *dedicatedInfoNas = NULL; /* for no gcc warnings */ (void)dedicatedInfoNas; - uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); // Transaction_id, DRB_configList2 = CALLOC(1, sizeof(*DRB_configList2)); /* Initialize NAS list */ @@ -2388,6 +2267,7 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons } DRB_config = NULL; + // search exist DRB_config for (j = 0; j < DRB_configList->list.count; j++) { if((uint8_t)*(DRB_configList->list.array[j]->eps_BearerIdentity) == ue_context_pP->ue_context.modify_e_rab[i].param.e_rab_id) { @@ -2395,6 +2275,7 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons break; } } + if (NULL == DRB_config) { ue_context_pP->ue_context.modify_e_rab[i].xid = xid; ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED; @@ -2406,85 +2287,89 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons } DRB_rlc_config = DRB_config->rlc_Config; - DRB_pdcp_config = DRB_config->pdcp_Config; *DRB_pdcp_config->discardTimer = LTE_PDCP_Config__discardTimer_infinity; + switch (ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci) { - /* - * type: realtime data with medium packer error rate - * action: swtich to RLC UM - */ - case 1: // 100ms, 10^-2, p2, GBR - case 2: // 150ms, 10^-3, p4, GBR - case 3: // 50ms, 10^-3, p3, GBR - case 4: // 300ms, 10^-6, p5 - case 7: // 100ms, 10^-3, p7, GBR - case 9: // 300ms, 10^-6, p9 - case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR - case 66: // 100ms, 10^-2, p2, non-mission critical voice , GBR - // RLC - DRB_rlc_config->present = LTE_RLC_Config_PR_um_Bi_Directional; - DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; - DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; - DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; - // PDCP - if (DRB_pdcp_config->rlc_AM) { - free(DRB_pdcp_config->rlc_AM); - DRB_pdcp_config->rlc_AM = NULL; - } - if (DRB_pdcp_config->rlc_UM) { - free(DRB_pdcp_config->rlc_UM); - DRB_pdcp_config->rlc_UM = NULL; - } - PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); - DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; - PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; - break; + /* + * type: realtime data with medium packer error rate + * action: swtich to RLC UM + */ + case 1: // 100ms, 10^-2, p2, GBR + case 2: // 150ms, 10^-3, p4, GBR + case 3: // 50ms, 10^-3, p3, GBR + case 4: // 300ms, 10^-6, p5 + case 7: // 100ms, 10^-3, p7, GBR + case 9: // 300ms, 10^-6, p9 + case 65: // 75ms, 10^-2, p0.7, mission critical voice, GBR + case 66: // 100ms, 10^-2, p2, non-mission critical voice , GBR + // RLC + DRB_rlc_config->present = LTE_RLC_Config_PR_um_Bi_Directional; + DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; + DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; + + // PDCP + if (DRB_pdcp_config->rlc_AM) { + free(DRB_pdcp_config->rlc_AM); + DRB_pdcp_config->rlc_AM = NULL; + } - /* - * type: non-realtime data with low packer error rate - * action: swtich to RLC AM - */ - case 5: // 100ms, 10^-6, p1 , IMS signaling - case 6: // 300ms, 10^-6, p6 - case 8: // 300ms, 10^-6, p8 - case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority - case 70: // 200ms, 10^-6, p5.5, mision critical data - // RLC - DRB_rlc_config->present = LTE_RLC_Config_PR_am; - DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms50; - DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p16; - DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; - DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; - DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; - DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms25; - - // PDCP - if (DRB_pdcp_config->rlc_AM) { - free(DRB_pdcp_config->rlc_AM); - DRB_pdcp_config->rlc_AM = NULL; - } - if (DRB_pdcp_config->rlc_UM) { - free(DRB_pdcp_config->rlc_UM); - DRB_pdcp_config->rlc_UM = NULL; - } - PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); - DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; - PDCP_rlc_AM->statusReportRequired = FALSE; - - break; - default : - LOG_E(RRC, "not supported qci %d\n", ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci); - ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED; - ue_context_pP->ue_context.modify_e_rab[i].xid = xid; - ue_context_pP->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK; - ue_context_pP->ue_context.modify_e_rab[i].cause_value = 37;//S1ap_CauseRadioNetwork_not_supported_QCI_value; - ue_context_pP->ue_context.nb_of_failed_e_rabs++; - continue; + if (DRB_pdcp_config->rlc_UM) { + free(DRB_pdcp_config->rlc_UM); + DRB_pdcp_config->rlc_UM = NULL; + } + + PDCP_rlc_UM = CALLOC(1, sizeof(*PDCP_rlc_UM)); + DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; + PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; + break; + + /* + * type: non-realtime data with low packer error rate + * action: swtich to RLC AM + */ + case 5: // 100ms, 10^-6, p1 , IMS signaling + case 6: // 300ms, 10^-6, p6 + case 8: // 300ms, 10^-6, p8 + case 69: // 60ms, 10^-6, p0.5, mission critical delay sensitive data, Lowest Priority + case 70: // 200ms, 10^-6, p5.5, mision critical data + // RLC + DRB_rlc_config->present = LTE_RLC_Config_PR_am; + DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms50; + DRB_rlc_config->choice.am.ul_AM_RLC.pollPDU = LTE_PollPDU_p16; + DRB_rlc_config->choice.am.ul_AM_RLC.pollByte = LTE_PollByte_kBinfinity; + DRB_rlc_config->choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t8; + DRB_rlc_config->choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; + DRB_rlc_config->choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms25; + + // PDCP + if (DRB_pdcp_config->rlc_AM) { + free(DRB_pdcp_config->rlc_AM); + DRB_pdcp_config->rlc_AM = NULL; + } + + if (DRB_pdcp_config->rlc_UM) { + free(DRB_pdcp_config->rlc_UM); + DRB_pdcp_config->rlc_UM = NULL; + } + + PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); + DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; + PDCP_rlc_AM->statusReportRequired = FALSE; + break; + + default : + LOG_E(RRC, "not supported qci %d\n", ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci); + ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_FAILED; + ue_context_pP->ue_context.modify_e_rab[i].xid = xid; + ue_context_pP->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_pP->ue_context.modify_e_rab[i].cause_value = 37;//S1ap_CauseRadioNetwork_not_supported_QCI_value; + ue_context_pP->ue_context.nb_of_failed_e_rabs++; + continue; } DRB_pdcp_config->headerCompression.present = LTE_PDCP_Config__headerCompression_PR_notUsed; - DRB_lchan_config = DRB_config->logicalChannelConfig; DRB_ul_SpecificParameters = DRB_lchan_config->ul_SpecificParameters; @@ -2494,36 +2379,30 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons DRB_ul_SpecificParameters->priority= 4; DRB_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; - DRB_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - ASN_SEQUENCE_ADD(&(DRB_configList2)->list, DRB_config); - LOG_I(RRC, "EPS ID %ld, DRB ID %ld (index %d), QCI %d, priority %ld, LCID %ld LCGID %ld \n", - *DRB_config->eps_BearerIdentity, - DRB_config->drb_Identity, i, - ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci, - DRB_ul_SpecificParameters->priority, - *(DRB_config->logicalChannelIdentity), - *DRB_ul_SpecificParameters->logicalChannelGroup - ); - + *DRB_config->eps_BearerIdentity, + DRB_config->drb_Identity, i, + ue_context_pP->ue_context.modify_e_rab[i].param.qos.qci, + DRB_ul_SpecificParameters->priority, + *(DRB_config->logicalChannelIdentity), + *DRB_ul_SpecificParameters->logicalChannelGroup + ); //e_rab_done++; ue_context_pP->ue_context.modify_e_rab[i].status = E_RAB_STATUS_DONE; ue_context_pP->ue_context.modify_e_rab[i].xid = xid; - { if (ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer != NULL) { dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(dedicatedInfoNas, - (char*)ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer, - ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length); + (char *)ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length); ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); LOG_I(RRC, "add NAS info with size %d (rab id %d)\n",ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.length, i); - } - else { + } else { LOG_W(RRC, "Not received activate dedicated EPS bearer context request\n"); } } @@ -2541,27 +2420,24 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons } memset(buffer, 0, RRC_BUF_SIZE); - - size = do_RRCConnectionReconfiguration(ctxt_pP, - buffer, - xid, - (LTE_SRB_ToAddModList_t*)NULL, - (LTE_DRB_ToAddModList_t*)DRB_configList2, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // *sps_Config, - NULL, NULL, NULL, NULL,NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + xid, + (LTE_SRB_ToAddModList_t *)NULL, + (LTE_DRB_ToAddModList_t *)DRB_configList2, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL + , (LTE_SCellToAddMod_r10_t *)NULL #endif - ); - + ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); - #if defined(ENABLE_ITTI) /* Free all NAS PDUs */ @@ -2572,16 +2448,14 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons ue_context_pP->ue_context.modify_e_rab[i].param.nas_pdu.buffer = NULL; } } -#endif - LOG_I(RRC, +#endif + LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - LOG_D(RRC, "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -2592,7 +2466,6 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( ctxt_pP, DCCH, @@ -2606,96 +2479,95 @@ rrc_eNB_modify_dedicatedRRCConnectionReconfiguration(const protocol_ctxt_t* cons //----------------------------------------------------------------------------- void -rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t xid, - uint32_t nas_length, - uint8_t* nas_buffer) +rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t xid, + uint32_t nas_length, + uint8_t *nas_buffer) //----------------------------------------------------------------------------- { - uint8_t buffer[RRC_BUF_SIZE]; - int i; - uint16_t size = 0; - LTE_DRB_ToReleaseList_t** DRB_Release_configList2=NULL; - LTE_DRB_Identity_t* DRB_release; - struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; - - DRB_Release_configList2=&ue_context_pP->ue_context.DRB_Release_configList2[xid]; - if (*DRB_Release_configList2) { - free(*DRB_Release_configList2); - } - *DRB_Release_configList2 = CALLOC(1, sizeof(**DRB_Release_configList2)); - - for(i = 0; i < NB_RB_MAX; i++){ - if((ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_TORELEASE) && ue_context_pP->ue_context.e_rab[i].xid == xid){ - DRB_release = CALLOC(1, sizeof(LTE_DRB_Identity_t)); - *DRB_release = i+1; - ASN_SEQUENCE_ADD(&(*DRB_Release_configList2)->list, DRB_release); - //free(DRB_release); - } - } + uint8_t buffer[RRC_BUF_SIZE]; + int i; + uint16_t size = 0; + LTE_DRB_ToReleaseList_t **DRB_Release_configList2=NULL; + LTE_DRB_Identity_t *DRB_release; + struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList = NULL; + DRB_Release_configList2=&ue_context_pP->ue_context.DRB_Release_configList2[xid]; - /* If list is empty free the list and reset the address */ - if (nas_length > 0) { - LTE_DedicatedInfoNAS_t *dedicatedInfoNas = NULL; - dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); - dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); - memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf(dedicatedInfoNas, - (char*)nas_buffer, - nas_length); - ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); - LOG_I(RRC,"add NAS info with size %d\n",nas_length); - } else { - LOG_W(RRC,"dedlicated NAS list is empty\n"); + if (*DRB_Release_configList2) { + free(*DRB_Release_configList2); + } + + *DRB_Release_configList2 = CALLOC(1, sizeof(**DRB_Release_configList2)); + + for(i = 0; i < NB_RB_MAX; i++) { + if((ue_context_pP->ue_context.e_rab[i].status == E_RAB_STATUS_TORELEASE) && ue_context_pP->ue_context.e_rab[i].xid == xid) { + DRB_release = CALLOC(1, sizeof(LTE_DRB_Identity_t)); + *DRB_release = i+1; + ASN_SEQUENCE_ADD(&(*DRB_Release_configList2)->list, DRB_release); + //free(DRB_release); } + } - memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(ctxt_pP, - buffer, - xid, - NULL, - NULL, - (LTE_DRB_ToReleaseList_t*)*DRB_Release_configList2, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + /* If list is empty free the list and reset the address */ + if (nas_length > 0) { + LTE_DedicatedInfoNAS_t *dedicatedInfoNas = NULL; + dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); + dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); + memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char *)nas_buffer, + nas_length); + ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); + LOG_I(RRC,"add NAS info with size %d\n",nas_length); + } else { + LOG_W(RRC,"dedlicated NAS list is empty\n"); + } + + memset(buffer, 0, RRC_BUF_SIZE); + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + xid, + NULL, + NULL, + (LTE_DRB_ToReleaseList_t *)*DRB_Release_configList2, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL + , (LTE_SCellToAddMod_r10_t *)NULL #endif - ); - ue_context_pP->ue_context.e_rab_release_command_flag = 1; - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, - "[MSG] RRC Connection Reconfiguration\n"); - + ); + ue_context_pP->ue_context.e_rab_release_command_flag = 1; + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, + "[MSG] RRC Connection Reconfiguration\n"); #if defined(ENABLE_ITTI) + /* Free all NAS PDUs */ if (nas_length > 0) { - /* Free the NAS PDU buffer and invalidate it */ - free(nas_buffer); + /* Free the NAS PDU buffer and invalidate it */ + free(nas_buffer); } -#endif +#endif LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE RNTI %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - LOG_D(RRC, "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -2706,7 +2578,6 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( ctxt_pP, DCCH, @@ -2715,33 +2586,29 @@ rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release( const protocol_ size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - } -#endif +#endif //----------------------------------------------------------------------------- void -rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state - ) +rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + const uint8_t ho_state + ) //----------------------------------------------------------------------------- { uint8_t buffer[RRC_BUF_SIZE]; uint16_t size; int i; - // configure SRB1/SRB2, PhysicalConfigDedicated, LTE_MAC_MainConfig for UE - eNB_RRC_INST* rrc_inst = RC.rrc[ctxt_pP->module_id]; - struct LTE_PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; - + eNB_RRC_INST *rrc_inst = RC.rrc[ctxt_pP->module_id]; + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; struct LTE_SRB_ToAddMod *SRB2_config = NULL; struct LTE_SRB_ToAddMod__rlc_Config *SRB2_rlc_config = NULL; struct LTE_SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config = NULL; struct LTE_LogicalChannelConfig__ul_SpecificParameters - *SRB2_ul_SpecificParameters = NULL; - LTE_SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; + *SRB2_ul_SpecificParameters = NULL; + LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; LTE_SRB_ToAddModList_t **SRB_configList2 = NULL; - struct LTE_DRB_ToAddMod *DRB_config = NULL; struct LTE_RLC_Config *DRB_rlc_config = NULL; struct LTE_PDCP_Config *DRB_pdcp_config = NULL; @@ -2749,15 +2616,15 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons struct LTE_PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; struct LTE_LogicalChannelConfig *DRB_lchan_config = NULL; struct LTE_LogicalChannelConfig__ul_SpecificParameters - *DRB_ul_SpecificParameters = NULL; - LTE_DRB_ToAddModList_t** DRB_configList = &ue_context_pP->ue_context.DRB_configList; - LTE_DRB_ToAddModList_t** DRB_configList2 = NULL; + *DRB_ul_SpecificParameters = NULL; + LTE_DRB_ToAddModList_t **DRB_configList = &ue_context_pP->ue_context.DRB_configList; + LTE_DRB_ToAddModList_t **DRB_configList2 = NULL; LTE_MAC_MainConfig_t *mac_MainConfig = NULL; LTE_MeasObjectToAddModList_t *MeasObj_list = NULL; LTE_MeasObjectToAddMod_t *MeasObj = NULL; LTE_ReportConfigToAddModList_t *ReportConfig_list = NULL; LTE_ReportConfigToAddMod_t *ReportConfig_per, *ReportConfig_A1, - *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; + *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; LTE_MeasIdToAddModList_t *MeasId_list = NULL; LTE_MeasIdToAddMod_t *MeasId0, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5; #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) @@ -2765,10 +2632,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons // uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1); //uint8_t sCellIndexToAdd = 0; #endif - long *logicalchannelgroup, *logicalchannelgroup_drb; long *maxHARQ_Tx, *periodicBSR_Timer; - LTE_RSRP_Range_t *rsrp = NULL; struct LTE_MeasConfig__speedStatePars *Sparams = NULL; LTE_QuantityConfig_t *quantityConfig = NULL; @@ -2778,11 +2643,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons LTE_DedicatedInfoNAS_t *dedicatedInfoNas = NULL; /* for no gcc warnings */ (void)dedicatedInfoNas; - LTE_C_RNTI_t *cba_RNTI = NULL; - uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); //Transaction_id, - #ifdef CBA //struct PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola; uint8_t *cba_RNTI_buf; @@ -2808,24 +2670,22 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons } #endif - T(T_ENB_RRC_CONNECTION_RECONFIGURATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - // Configure SRB2 /// SRB2 SRB_configList2=&ue_context_pP->ue_context.SRB_configList2[xid]; + if (*SRB_configList2) { free(*SRB_configList2); } + *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2)); memset(*SRB_configList2, 0, sizeof(**SRB_configList2)); SRB2_config = CALLOC(1, sizeof(*SRB2_config)); - SRB2_config->srb_Identity = 2; SRB2_rlc_config = CALLOC(1, sizeof(*SRB2_rlc_config)); SRB2_config->rlc_Config = SRB2_rlc_config; - SRB2_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB2_rlc_config->choice.explicitValue.present = LTE_RLC_Config_PR_am; SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms15; @@ -2834,26 +2694,19 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t32; SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms10; - SRB2_lchan_config = CALLOC(1, sizeof(*SRB2_lchan_config)); SRB2_config->logicalChannelConfig = SRB2_lchan_config; - SRB2_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; - SRB2_ul_SpecificParameters = CALLOC(1, sizeof(*SRB2_ul_SpecificParameters)); - SRB2_ul_SpecificParameters->priority = 3; // let some priority for SRB1 and dedicated DRBs SRB2_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; SRB2_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - // LCG for CCCH and DCCH is 0 as defined in 36331 logicalchannelgroup = CALLOC(1, sizeof(long)); *logicalchannelgroup = 0; - SRB2_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; - SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB2_ul_SpecificParameters; // this list has the configuration for SRB1 and SRB2 ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); @@ -2866,21 +2719,20 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons if (*DRB_configList) { free(*DRB_configList); } + *DRB_configList = CALLOC(1, sizeof(**DRB_configList)); memset(*DRB_configList, 0, sizeof(**DRB_configList)); - // list for the configured DRB for a this xid DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid]; + if (*DRB_configList2) { free(*DRB_configList2); } + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); memset(*DRB_configList2, 0, sizeof(**DRB_configList2)); - - /// DRB DRB_config = CALLOC(1, sizeof(*DRB_config)); - DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); *(DRB_config->eps_BearerIdentity) = 5L; // LW set to first value, allowed value 5..15, value : x+4 // DRB_config->drb_Identity = (LTE_DRB_Identity_t) 1; //allowed values 1..32 @@ -2890,7 +2742,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons *(DRB_config->logicalChannelIdentity) = (long)3; // value : x+2 DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); DRB_config->rlc_Config = DRB_rlc_config; - #ifdef RRC_DEFAULT_RAB_IS_AM DRB_rlc_config->present = LTE_RLC_Config_PR_am; DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms50; @@ -2909,18 +2760,15 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; #endif #endif - DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); DRB_config->pdcp_Config = DRB_pdcp_config; DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); *DRB_pdcp_config->discardTimer = LTE_PDCP_Config__discardTimer_infinity; DRB_pdcp_config->rlc_AM = NULL; DRB_pdcp_config->rlc_UM = NULL; - /* avoid gcc warnings */ (void)PDCP_rlc_AM; (void)PDCP_rlc_UM; - #ifdef RRC_DEFAULT_RAB_IS_AM // EXMIMO_IOT PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; @@ -2931,33 +2779,25 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; #endif DRB_pdcp_config->headerCompression.present = LTE_PDCP_Config__headerCompression_PR_notUsed; - DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config)); DRB_config->logicalChannelConfig = DRB_lchan_config; DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; - DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer DRB_ul_SpecificParameters->prioritisedBitRate =LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ; - //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; DRB_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) logicalchannelgroup_drb = CALLOC(1, sizeof(long)); *logicalchannelgroup_drb = 1; DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; - ASN_SEQUENCE_ADD(&(*DRB_configList)->list, DRB_config); ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); - //ue_context_pP->ue_context.DRB_configList2[0] = &(*DRB_configList); - mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig)); ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig; - mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config)); - maxHARQ_Tx = CALLOC(1, sizeof(long)); *maxHARQ_Tx = LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx; @@ -2966,20 +2806,13 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer; mac_MainConfig->ul_SCH_Config->retxBSR_Timer = LTE_RetxBSR_Timer_r12_sf320; mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE - mac_MainConfig->timeAlignmentTimerDedicated = LTE_TimeAlignmentTimer_infinity; - mac_MainConfig->drx_Config = NULL; - mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config)); - mac_MainConfig->phr_Config->present = LTE_MAC_MainConfig__phr_Config_PR_setup; mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes - mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes - mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; // Value dB1 =1 dB, dB3 = 3 dB - #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long)); *sr_ProhibitTimer_r9 = 0; // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR @@ -2995,124 +2828,108 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons if ((*physicalConfigDedicated)->antennaInfo) { (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.ue_TransmissionMode[0]; LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.ue_TransmissionMode[0]); - if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm3) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; - } - else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; + if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm3) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; + } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; + } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; + } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; } - else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; - } - else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; - } - } - else { + } else { LOG_E(RRC,"antenna_info not present in physical_config_dedicated. Not reconfiguring!\n"); } + if ((*physicalConfigDedicated)->cqi_ReportConfig) { if ((rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) || - (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) || - (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6)) { - //feedback mode needs to be set as well - //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable - printf("setting cqi reporting mode to rm31\n"); + (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) || + (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6)) { + //feedback mode needs to be set as well + //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable + printf("setting cqi reporting mode to rm31\n"); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31; + *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31; #else - *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI + *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI #endif } - } - else { + } else { LOG_E(RRC,"cqi_ReportConfig not present in physical_config_dedicated. Not reconfiguring!\n"); } - } - else { + } else { LOG_E(RRC,"physical_config_dedicated not present in LTE_RRCConnectionReconfiguration. Not reconfiguring!\n"); } // Measurement ID list MeasId_list = CALLOC(1, sizeof(*MeasId_list)); memset((void *)MeasId_list, 0, sizeof(*MeasId_list)); - MeasId0 = CALLOC(1, sizeof(*MeasId0)); MeasId0->measId = 1; MeasId0->measObjectId = 1; MeasId0->reportConfigId = 1; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0); - MeasId1 = CALLOC(1, sizeof(*MeasId1)); MeasId1->measId = 2; MeasId1->measObjectId = 1; MeasId1->reportConfigId = 2; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1); - MeasId2 = CALLOC(1, sizeof(*MeasId2)); MeasId2->measId = 3; MeasId2->measObjectId = 1; MeasId2->reportConfigId = 3; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2); - MeasId3 = CALLOC(1, sizeof(*MeasId3)); MeasId3->measId = 4; MeasId3->measObjectId = 1; MeasId3->reportConfigId = 4; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3); - MeasId4 = CALLOC(1, sizeof(*MeasId4)); MeasId4->measId = 5; MeasId4->measObjectId = 1; MeasId4->reportConfigId = 5; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4); - MeasId5 = CALLOC(1, sizeof(*MeasId5)); MeasId5->measId = 6; MeasId5->measObjectId = 1; MeasId5->reportConfigId = 6; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5); - // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list; - // Add one EUTRA Measurement Object MeasObj_list = CALLOC(1, sizeof(*MeasObj_list)); memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list)); - // Configure MeasObject - MeasObj = CALLOC(1, sizeof(*MeasObj)); memset((void *)MeasObj, 0, sizeof(*MeasObj)); - MeasObj->measObjectId = 1; MeasObj->measObject.present = LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA; MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz @@ -3124,10 +2941,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1; MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6; MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL; // Default is 15 or 0dB - MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList = (LTE_CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); - CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; // Add adjacent cell lists (6 per eNB) @@ -3136,28 +2951,19 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons CellToAdd->cellIndex = i + 1; CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); CellToAdd->cellIndividualOffset = LTE_Q_OffsetRange_dB0; - ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); } ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; - // Report Configurations for periodical, A1-A5 events ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list)); - ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per)); - ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1)); - ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2)); - ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3)); - ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4)); - ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5)); - ReportConfig_per->reportConfigId = 1; ReportConfig_per->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -3169,9 +2975,7 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per); - ReportConfig_A1->reportConfigId = 2; ReportConfig_A1->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -3182,15 +2986,13 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons a1_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1. a1_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1); - + if (ho_state == 1 /*HO_MEASURMENT */ ) { LOG_I(RRC, "[eNB %d] frame %d: requesting A2, A3, A4, A5, and A6 event reporting\n", ctxt_pP->module_id, ctxt_pP->frame); @@ -3204,39 +3006,32 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons eventA2.a2_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA2.a2_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2); - ReportConfig_A3->reportConfigId = 4; ReportConfig_A3->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present = LTE_ReportConfigEUTRA__triggerType_PR_event; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present = LTE_ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset = 1; //10; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA3.reportOnLeave = 1; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis = 0.5; // FIXME ...hysteresis is of type long! ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = LTE_TimeToTrigger_ms40; ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3); - ReportConfig_A4->reportConfigId = 5; ReportConfig_A4->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -3247,16 +3042,13 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons eventA4.a4_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA4.a4_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4); - ReportConfig_A5->reportConfigId = 6; ReportConfig_A5->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -3271,20 +3063,16 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons eventA5.a5_Threshold1.choice.threshold_RSRP = 10; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA5.a5_Threshold2.choice.threshold_RSRP = 10; - ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; - rsrp = CALLOC(1, sizeof(LTE_RSRP_Range_t)); *rsrp = 20; - Sparams = CALLOC(1, sizeof(*Sparams)); Sparams->present = LTE_MeasConfig__speedStatePars_PR_setup; Sparams->choice.setup.timeToTrigger_SF.sf_High = LTE_SpeedStateScaleFactors__sf_Medium_oDot75; @@ -3293,7 +3081,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5; Sparams->choice.setup.mobilityStateParameters.t_Evaluation = LTE_MobilityStateParameters__t_Evaluation_s60; Sparams->choice.setup.mobilityStateParameters.t_HystNormal = LTE_MobilityStateParameters__t_HystNormal_s120; - quantityConfig = CALLOC(1, sizeof(*quantityConfig)); memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct LTE_QuantityConfigEUTRA)); @@ -3307,7 +3094,6 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = LTE_FilterCoefficient_fc4; *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = LTE_FilterCoefficient_fc4; - LOG_I(RRC, "[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n", ctxt_pP->module_id, ctxt_pP->frame); @@ -3321,15 +3107,14 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig = CALLOC(1, sizeof(*ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, (void *)mac_MainConfig, sizeof(LTE_MAC_MainConfig_t)); ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated = CALLOC(1, sizeof(LTE_PhysicalConfigDedicated_t)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, - (void*)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(LTE_PhysicalConfigDedicated_t)); + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, + (void *)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(LTE_PhysicalConfigDedicated_t)); ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.sps_Config = NULL; //memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config,(void *)rrc_inst->sps_Config[ue_mod_idP],sizeof(SPS_Config_t)); - } #if defined(ENABLE_ITTI) @@ -3341,8 +3126,8 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf(dedicatedInfoNas, - (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); } @@ -3353,11 +3138,10 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; } - /* TODO should test if e RAB are Ok before! */ ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; - LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", - i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); + LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", + i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); } /* If list is empty free the list and reset the address */ @@ -3367,41 +3151,38 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons } #endif - memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, xid, //Transaction_id, - (LTE_SRB_ToAddModList_t*)*SRB_configList2, // SRB_configList - (LTE_DRB_ToAddModList_t*)*DRB_configList, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // *sps_Config, - (struct LTE_PhysicalConfigDedicated*)*physicalConfigDedicated, + (LTE_SRB_ToAddModList_t *)*SRB_configList2, // SRB_configList + (LTE_DRB_ToAddModList_t *)*DRB_configList, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // *sps_Config, + (struct LTE_PhysicalConfigDedicated *)*physicalConfigDedicated, #ifdef EXMIMO_IOT NULL, NULL, NULL,NULL, #else - (LTE_MeasObjectToAddModList_t*)MeasObj_list, - (LTE_ReportConfigToAddModList_t*)ReportConfig_list, - (LTE_QuantityConfig_t*)quantityConfig, - (LTE_MeasIdToAddModList_t*)MeasId_list, -#endif - (LTE_MAC_MainConfig_t*)mac_MainConfig, - (LTE_MeasGapConfig_t*)NULL, - (LTE_MobilityControlInfo_t*)NULL, - (struct LTE_MeasConfig__speedStatePars*)Sparams, - (LTE_RSRP_Range_t*)rsrp, - (LTE_C_RNTI_t*)cba_RNTI, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + (LTE_MeasObjectToAddModList_t *)MeasObj_list, + (LTE_ReportConfigToAddModList_t *)ReportConfig_list, + (LTE_QuantityConfig_t *)quantityConfig, + (LTE_MeasIdToAddModList_t *)MeasId_list, +#endif + (LTE_MAC_MainConfig_t *)mac_MainConfig, + (LTE_MeasGapConfig_t *)NULL, + (LTE_MobilityControlInfo_t *)NULL, + (struct LTE_MeasConfig__speedStatePars *)Sparams, + (LTE_RSRP_Range_t *)rsrp, + (LTE_C_RNTI_t *)cba_RNTI, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL + , (LTE_SCellToAddMod_r10_t *)NULL #endif ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); - #if defined(ENABLE_ITTI) /* Free all NAS PDUs */ @@ -3414,15 +3195,12 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons } #endif - LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE id %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - LOG_D(RRC, "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -3433,42 +3211,38 @@ rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* cons ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } //----------------------------------------------------------------------------- void -flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - const uint8_t ho_state, - agent_reconf_rrc * trig_param - ) +flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + const uint8_t ho_state, + agent_reconf_rrc *trig_param + ) //----------------------------------------------------------------------------- { uint8_t buffer[RRC_BUF_SIZE]; uint16_t size; int i; - // configure SRB1/SRB2, PhysicalConfigDedicated, LTE_MAC_MainConfig for UE - eNB_RRC_INST* rrc_inst = RC.rrc[ctxt_pP->module_id]; - struct LTE_PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; - + eNB_RRC_INST *rrc_inst = RC.rrc[ctxt_pP->module_id]; + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; struct LTE_SRB_ToAddMod *SRB2_config = NULL; struct LTE_SRB_ToAddMod__rlc_Config *SRB2_rlc_config = NULL; struct LTE_SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config = NULL; struct LTE_LogicalChannelConfig__ul_SpecificParameters - *SRB2_ul_SpecificParameters = NULL; - LTE_SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; + *SRB2_ul_SpecificParameters = NULL; + LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; LTE_SRB_ToAddModList_t **SRB_configList2 = NULL; - struct LTE_DRB_ToAddMod *DRB_config = NULL; struct LTE_RLC_Config *DRB_rlc_config = NULL; struct LTE_PDCP_Config *DRB_pdcp_config = NULL; @@ -3476,15 +3250,15 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt struct LTE_PDCP_Config__rlc_UM *PDCP_rlc_UM = NULL; struct LTE_LogicalChannelConfig *DRB_lchan_config = NULL; struct LTE_LogicalChannelConfig__ul_SpecificParameters - *DRB_ul_SpecificParameters = NULL; - LTE_DRB_ToAddModList_t** DRB_configList = &ue_context_pP->ue_context.DRB_configList; - LTE_DRB_ToAddModList_t** DRB_configList2 = NULL; + *DRB_ul_SpecificParameters = NULL; + LTE_DRB_ToAddModList_t **DRB_configList = &ue_context_pP->ue_context.DRB_configList; + LTE_DRB_ToAddModList_t **DRB_configList2 = NULL; LTE_MAC_MainConfig_t *mac_MainConfig = NULL; LTE_MeasObjectToAddModList_t *MeasObj_list = NULL; LTE_MeasObjectToAddMod_t *MeasObj = NULL; LTE_ReportConfigToAddModList_t *ReportConfig_list = NULL; LTE_ReportConfigToAddMod_t *ReportConfig_per;//, *ReportConfig_A1, - // *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; + // *ReportConfig_A2, *ReportConfig_A3, *ReportConfig_A4, *ReportConfig_A5; LTE_MeasIdToAddModList_t *MeasId_list = NULL; LTE_MeasIdToAddMod_t *MeasId0; //, *MeasId1, *MeasId2, *MeasId3, *MeasId4, *MeasId5; #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) @@ -3492,10 +3266,8 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt // uint8_t sCellIndexToAdd = rrc_find_free_SCell_index(enb_mod_idP, ue_mod_idP, 1); //uint8_t sCellIndexToAdd = 0; #endif - long *logicalchannelgroup, *logicalchannelgroup_drb; long *maxHARQ_Tx, *periodicBSR_Timer; - LTE_RSRP_Range_t *rsrp = NULL; struct LTE_MeasConfig__speedStatePars *Sparams = NULL; LTE_QuantityConfig_t *quantityConfig = NULL; @@ -3505,11 +3277,8 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt LTE_DedicatedInfoNAS_t *dedicatedInfoNas = NULL; /* for no gcc warnings */ (void)dedicatedInfoNas; - LTE_C_RNTI_t *cba_RNTI = NULL; - uint8_t xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); //Transaction_id, - #ifdef CBA //struct PUSCH_CBAConfigDedicated_vlola *pusch_CBAConfigDedicated_vlola; uint8_t *cba_RNTI_buf; @@ -3535,24 +3304,22 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt } #endif - T(T_ENB_RRC_CONNECTION_RECONFIGURATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - // Configure SRB2 /// SRB2 SRB_configList2=&ue_context_pP->ue_context.SRB_configList2[xid]; + if (*SRB_configList2) { free(*SRB_configList2); } + *SRB_configList2 = CALLOC(1, sizeof(**SRB_configList2)); memset(*SRB_configList2, 0, sizeof(**SRB_configList2)); SRB2_config = CALLOC(1, sizeof(*SRB2_config)); - SRB2_config->srb_Identity = 2; SRB2_rlc_config = CALLOC(1, sizeof(*SRB2_rlc_config)); SRB2_config->rlc_Config = SRB2_rlc_config; - SRB2_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB2_rlc_config->choice.explicitValue.present = LTE_RLC_Config_PR_am; SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms15; @@ -3561,26 +3328,19 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t32; SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms10; - SRB2_lchan_config = CALLOC(1, sizeof(*SRB2_lchan_config)); SRB2_config->logicalChannelConfig = SRB2_lchan_config; - SRB2_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; - SRB2_ul_SpecificParameters = CALLOC(1, sizeof(*SRB2_ul_SpecificParameters)); - SRB2_ul_SpecificParameters->priority = 3; // let some priority for SRB1 and dedicated DRBs SRB2_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; SRB2_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - // LCG for CCCH and DCCH is 0 as defined in 36331 logicalchannelgroup = CALLOC(1, sizeof(long)); *logicalchannelgroup = 0; - SRB2_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; - SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB2_ul_SpecificParameters; // this list has the configuration for SRB1 and SRB2 ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); @@ -3593,21 +3353,20 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt if (*DRB_configList) { free(*DRB_configList); } + *DRB_configList = CALLOC(1, sizeof(**DRB_configList)); memset(*DRB_configList, 0, sizeof(**DRB_configList)); - // list for the configured DRB for a this xid DRB_configList2=&ue_context_pP->ue_context.DRB_configList2[xid]; + if (*DRB_configList2) { free(*DRB_configList2); } + *DRB_configList2 = CALLOC(1, sizeof(**DRB_configList2)); memset(*DRB_configList2, 0, sizeof(**DRB_configList2)); - - /// DRB DRB_config = CALLOC(1, sizeof(*DRB_config)); - DRB_config->eps_BearerIdentity = CALLOC(1, sizeof(long)); *(DRB_config->eps_BearerIdentity) = 5L; // LW set to first value, allowed value 5..15, value : x+4 // DRB_config->drb_Identity = (LTE_DRB_Identity_t) 1; //allowed values 1..32 @@ -3617,7 +3376,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt *(DRB_config->logicalChannelIdentity) = (long)3; // value : x+2 DRB_rlc_config = CALLOC(1, sizeof(*DRB_rlc_config)); DRB_config->rlc_Config = DRB_rlc_config; - #ifdef RRC_DEFAULT_RAB_IS_AM DRB_rlc_config->present = LTE_RLC_Config_PR_am; DRB_rlc_config->choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms50; @@ -3636,18 +3394,15 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; #endif #endif - DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); DRB_config->pdcp_Config = DRB_pdcp_config; DRB_pdcp_config->discardTimer = CALLOC(1, sizeof(long)); *DRB_pdcp_config->discardTimer = LTE_PDCP_Config__discardTimer_infinity; DRB_pdcp_config->rlc_AM = NULL; DRB_pdcp_config->rlc_UM = NULL; - /* avoid gcc warnings */ (void)PDCP_rlc_AM; (void)PDCP_rlc_UM; - #ifdef RRC_DEFAULT_RAB_IS_AM // EXMIMO_IOT PDCP_rlc_AM = CALLOC(1, sizeof(*PDCP_rlc_AM)); DRB_pdcp_config->rlc_AM = PDCP_rlc_AM; @@ -3658,33 +3413,25 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; #endif DRB_pdcp_config->headerCompression.present = LTE_PDCP_Config__headerCompression_PR_notUsed; - DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config)); DRB_config->logicalChannelConfig = DRB_lchan_config; DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; - DRB_ul_SpecificParameters->priority = 12; // lower priority than srb1, srb2 and other dedicated bearer DRB_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8 ; - //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + //LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; DRB_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) logicalchannelgroup_drb = CALLOC(1, sizeof(long)); *logicalchannelgroup_drb = 1; DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; - ASN_SEQUENCE_ADD(&(*DRB_configList)->list, DRB_config); ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); - //ue_context_pP->ue_context.DRB_configList2[0] = &(*DRB_configList); - mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig)); // ue_context_pP->ue_context.mac_MainConfig = LTE_MAC_MainConfig; - mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config)); - maxHARQ_Tx = CALLOC(1, sizeof(long)); *maxHARQ_Tx = LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx; @@ -3693,20 +3440,13 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer; mac_MainConfig->ul_SCH_Config->retxBSR_Timer = LTE_RetxBSR_Timer_r12_sf320; mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE - mac_MainConfig->timeAlignmentTimerDedicated = LTE_TimeAlignmentTimer_infinity; - mac_MainConfig->drx_Config = NULL; - mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config)); - mac_MainConfig->phr_Config->present = LTE_MAC_MainConfig__phr_Config_PR_setup; mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes - mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes - mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; // Value dB1 =1 dB, dB3 = 3 dB - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long)); *sr_ProhibitTimer_r9 = 0; // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR @@ -3722,95 +3462,84 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt if ((*physicalConfigDedicated)->antennaInfo) { (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.transmissionMode = rrc_inst->configuration.ue_TransmissionMode[0]; LOG_D(RRC,"Setting transmission mode to %ld+1\n",rrc_inst->configuration.ue_TransmissionMode[0]); - if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm3) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; - } - else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; + if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm3) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm3; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.buf[0] = 0xc0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm3.bits_unused=6; + } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm4; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.buf[0] = 0xfc; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm4.bits_unused=2; + } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; + } else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6) { + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= + CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = + LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; + (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; } - else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm5; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm5.bits_unused=4; - } - else if (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6) { - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction= - CALLOC(1,sizeof(LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR)); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->present = - LTE_AntennaInfoDedicated__codebookSubsetRestriction_PR_n2TxAntenna_tm6; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf= MALLOC(1); - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.buf[0] = 0xf0; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.size=1; - (*physicalConfigDedicated)->antennaInfo->choice.explicitValue.codebookSubsetRestriction->choice.n2TxAntenna_tm6.bits_unused=4; - } - } - else { + } else { LOG_E(RRC,"antenna_info not present in physical_config_dedicated. Not reconfiguring!\n"); } + if ((*physicalConfigDedicated)->cqi_ReportConfig) { if ((rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm4) || - (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) || - (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6)) { - //feedback mode needs to be set as well - //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable - printf("setting cqi reporting mode to rm31\n"); + (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm5) || + (rrc_inst->configuration.ue_TransmissionMode[0] == LTE_AntennaInfoDedicated__transmissionMode_tm6)) { + //feedback mode needs to be set as well + //TODO: I think this is taken into account in the PHY automatically based on the transmission mode variable + printf("setting cqi reporting mode to rm31\n"); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31; + *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportModeAperiodic_rm31; #else - *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI + *((*physicalConfigDedicated)->cqi_ReportConfig->cqi_ReportModeAperiodic)=LTE_CQI_ReportConfig__cqi_ReportModeAperiodic_rm31; // HLC CQI, no PMI #endif } - } - else { + } else { LOG_E(RRC,"cqi_ReportConfig not present in physical_config_dedicated. Not reconfiguring!\n"); } - } - else { + } else { LOG_E(RRC,"physical_config_dedicated not present in LTE_RRCConnectionReconfiguration. Not reconfiguring!\n"); } // Measurement ID list MeasId_list = CALLOC(1, sizeof(*MeasId_list)); memset((void *)MeasId_list, 0, sizeof(*MeasId_list)); - MeasId0 = CALLOC(1, sizeof(*MeasId0)); MeasId0->measId = 1; MeasId0->measObjectId = 1; MeasId0->reportConfigId = 1; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0); - /* * Add one EUTRA Measurement Object */ - MeasObj_list = CALLOC(1, sizeof(*MeasObj_list)); memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list)); - - // Configure MeasObject - + // Configure MeasObject MeasObj = CALLOC(1, sizeof(*MeasObj)); memset((void *)MeasObj, 0, sizeof(*MeasObj)); - MeasObj->measObjectId = 1; MeasObj->measObject.present = LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA; MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 3350; //band 7, 2.68GHz @@ -3822,10 +3551,8 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1; MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6; MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL; // Default is 15 or 0dB - MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList = (LTE_CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); - CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; // Add adjacent cell lists (6 per eNB) @@ -3834,7 +3561,6 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt CellToAdd->cellIndex = i + 1; CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); CellToAdd->cellIndividualOffset = LTE_Q_OffsetRange_dB0; - ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); } @@ -3845,78 +3571,48 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt /* RRC Strategy Measurement */ - - if (strcmp("one_shot", trig_param->trigger_policy) == 0){ - - trig_param->report_interval = 0; - trig_param->report_amount = 0; - - } - - else if (strcmp("event_driven", trig_param->trigger_policy) == 0){ - - trig_param->report_interval = 6; - trig_param->report_amount = 2; - - } - - else if (strcmp("periodical", trig_param->trigger_policy) == 0){ - - trig_param->report_interval = 1; - trig_param->report_amount = 7; - - } - - else { - - LOG_E(FLEXRAN_AGENT, "There is something wrong on RRC agent!"); + if (strcmp("one_shot", trig_param->trigger_policy) == 0) { + trig_param->report_interval = 0; + trig_param->report_amount = 0; + } else if (strcmp("event_driven", trig_param->trigger_policy) == 0) { + trig_param->report_interval = 6; + trig_param->report_amount = 2; + } else if (strcmp("periodical", trig_param->trigger_policy) == 0) { + trig_param->report_interval = 1; + trig_param->report_amount = 7; + } else { + LOG_E(FLEXRAN_AGENT, "There is something wrong on RRC agent!"); } - - ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list)); - ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per)); - - // Periodical Measurement Report - + // Periodical Measurement Report ReportConfig_per->reportConfigId = 1; ReportConfig_per->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; - - ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = - LTE_ReportConfigEUTRA__triggerType_PR_periodical; - - ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.periodical.purpose = - LTE_ReportConfigEUTRA__triggerType__periodical__purpose_reportStrongestCells; - - // ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = TimeToTrigger_ms40; - ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; - ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; - ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; - ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = trig_param->report_interval ;//ReportInterval_ms2048; // RRC counter frame- ms1024 is 1ms - - ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = trig_param->report_amount; //ReportConfigEUTRA__reportAmount_r2; // put r1 to see once, r2 for 2 times and ... - - + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = + LTE_ReportConfigEUTRA__triggerType_PR_periodical; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.periodical.purpose = + LTE_ReportConfigEUTRA__triggerType__periodical__purpose_reportStrongestCells; + // ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger = TimeToTrigger_ms40; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = trig_param->report_interval ;//ReportInterval_ms2048; // RRC counter frame- ms1024 is 1ms + ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = trig_param->report_amount; //ReportConfigEUTRA__reportAmount_r2; // put r1 to see once, r2 for 2 times and ... ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per); - - - - quantityConfig = CALLOC(1, sizeof(*quantityConfig)); - memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); - quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct LTE_QuantityConfigEUTRA)); - memset((void *)quantityConfig->quantityConfigEUTRA, 0, sizeof(*quantityConfig->quantityConfigEUTRA)); - quantityConfig->quantityConfigCDMA2000 = NULL; - quantityConfig->quantityConfigGERAN = NULL; - quantityConfig->quantityConfigUTRA = NULL; - quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = - CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP))); - quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = - CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); - *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = LTE_FilterCoefficient_fc4; - *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = LTE_FilterCoefficient_fc4; - - + quantityConfig = CALLOC(1, sizeof(*quantityConfig)); + memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); + quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(struct LTE_QuantityConfigEUTRA)); + memset((void *)quantityConfig->quantityConfigEUTRA, 0, sizeof(*quantityConfig->quantityConfigEUTRA)); + quantityConfig->quantityConfigCDMA2000 = NULL; + quantityConfig->quantityConfigGERAN = NULL; + quantityConfig->quantityConfigUTRA = NULL; + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = + CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP))); + quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = + CALLOC(1, sizeof(*(quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ))); + *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = LTE_FilterCoefficient_fc4; + *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = LTE_FilterCoefficient_fc4; #if defined(ENABLE_ITTI) /* Initialize NAS list */ dedicatedInfoNASList = CALLOC(1, sizeof(struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList)); @@ -3926,23 +3622,22 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt if (ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer != NULL) { dedicatedInfoNas = CALLOC(1, sizeof(LTE_DedicatedInfoNAS_t)); memset(dedicatedInfoNas, 0, sizeof(OCTET_STRING_t)); - OCTET_STRING_fromBuf(dedicatedInfoNas, - (char*)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, + OCTET_STRING_fromBuf(dedicatedInfoNas, + (char *)ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer, ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length); ASN_SEQUENCE_ADD(&dedicatedInfoNASList->list, dedicatedInfoNas); } /* TODO parameters yet to process ... */ // { - // ue_context_pP->ue_context.e_rab[i].param.qos; - // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; - // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; + // ue_context_pP->ue_context.e_rab[i].param.qos; + // ue_context_pP->ue_context.e_rab[i].param.sgw_addr; + // ue_context_pP->ue_context.e_rab[i].param.gtp_teid; // } - /* TODO should test if e RAB are Ok before! */ ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_DONE; - LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", - i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); + LOG_D(RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", + i, ue_context_pP->ue_context.e_rab[i].status, "E_RAB_STATUS_DONE"); } /* If list is empty free the list and reset the address */ @@ -3952,41 +3647,38 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt } #endif - memset(buffer, 0, RRC_BUF_SIZE); - size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, xid, //Transaction_id, - (LTE_SRB_ToAddModList_t*)NULL, // SRB_configList - (LTE_DRB_ToAddModList_t*)NULL, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // *sps_Config, - (struct LTE_PhysicalConfigDedicated*)*physicalConfigDedicated, -// #ifdef EXMIMO_IOT -// NULL, NULL, NULL,NULL, -// #else - (LTE_MeasObjectToAddModList_t*)MeasObj_list, - (LTE_ReportConfigToAddModList_t*)ReportConfig_list, - (LTE_QuantityConfig_t*)quantityConfig, - (LTE_MeasIdToAddModList_t*)MeasId_list, -// #endif - (LTE_MAC_MainConfig_t*)mac_MainConfig, - (LTE_MeasGapConfig_t*)NULL, - (LTE_MobilityControlInfo_t*)NULL, - (struct LTE_MeasConfig__speedStatePars*)Sparams, - (LTE_RSRP_Range_t*)rsrp, - (LTE_C_RNTI_t*)cba_RNTI, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)dedicatedInfoNASList, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + (LTE_SRB_ToAddModList_t *)NULL, // SRB_configList + (LTE_DRB_ToAddModList_t *)NULL, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // *sps_Config, + (struct LTE_PhysicalConfigDedicated *)*physicalConfigDedicated, + // #ifdef EXMIMO_IOT + // NULL, NULL, NULL,NULL, + // #else + (LTE_MeasObjectToAddModList_t *)MeasObj_list, + (LTE_ReportConfigToAddModList_t *)ReportConfig_list, + (LTE_QuantityConfig_t *)quantityConfig, + (LTE_MeasIdToAddModList_t *)MeasId_list, + // #endif + (LTE_MAC_MainConfig_t *)mac_MainConfig, + (LTE_MeasGapConfig_t *)NULL, + (LTE_MobilityControlInfo_t *)NULL, + (struct LTE_MeasConfig__speedStatePars *)Sparams, + (LTE_RSRP_Range_t *)rsrp, + (LTE_C_RNTI_t *)cba_RNTI, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)dedicatedInfoNASList, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL + , (LTE_SCellToAddMod_r10_t *)NULL #endif ); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)buffer,size, "[MSG] RRC Connection Reconfiguration\n"); - #if defined(ENABLE_ITTI) /* Free all NAS PDUs */ @@ -3999,15 +3691,12 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt } #endif - LOG_I(RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE id %x)\n", ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - LOG_D(RRC, "[FRAME %05d][RRC_eNB][MOD %u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %x MUI %d) --->][PDCP][MOD %u][RB %u]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -4018,31 +3707,28 @@ flexran_rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); } //----------------------------------------------------------------------------- int rrc_eNB_generate_RRCConnectionReconfiguration_SCell( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, uint32_t dl_CarrierFreq_r10 ) //----------------------------------------------------------------------------- { - uint8_t size; uint8_t buffer[100]; - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) uint8_t sCellIndexToAdd = 0; //one SCell so far @@ -4060,32 +3746,30 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell( size = do_RRCConnectionReconfiguration(ctxt_pP, buffer, rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id),//Transaction_id, - (LTE_SRB_ToAddModList_t*)NULL, - (LTE_DRB_ToAddModList_t*)NULL, - (LTE_DRB_ToReleaseList_t*)NULL, - (struct LTE_SPS_Config*)NULL, - (struct LTE_PhysicalConfigDedicated*)NULL, - (LTE_MeasObjectToAddModList_t*)NULL, - (LTE_ReportConfigToAddModList_t*)NULL, - (LTE_QuantityConfig_t*)NULL, - (LTE_MeasIdToAddModList_t*)NULL, - (LTE_MAC_MainConfig_t*)NULL, - (LTE_MeasGapConfig_t*)NULL, - (LTE_MobilityControlInfo_t*)NULL, - (struct LTE_MeasConfig__speedStatePars*)NULL, - (LTE_RSRP_Range_t*)NULL, - (LTE_C_RNTI_t*)NULL, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL - + (LTE_SRB_ToAddModList_t *)NULL, + (LTE_DRB_ToAddModList_t *)NULL, + (LTE_DRB_ToReleaseList_t *)NULL, + (struct LTE_SPS_Config *)NULL, + (struct LTE_PhysicalConfigDedicated *)NULL, + (LTE_MeasObjectToAddModList_t *)NULL, + (LTE_ReportConfigToAddModList_t *)NULL, + (LTE_QuantityConfig_t *)NULL, + (LTE_MeasIdToAddModList_t *)NULL, + (LTE_MAC_MainConfig_t *)NULL, + (LTE_MeasGapConfig_t *)NULL, + (LTE_MobilityControlInfo_t *)NULL, + (struct LTE_MeasConfig__speedStatePars *)NULL, + (LTE_RSRP_Range_t *)NULL, + (LTE_C_RNTI_t *)NULL, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)NULL, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) , ue_context_pP->ue_context.sCell_config #endif ); LOG_I(RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration (bytes %d, UE id %x)\n", ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_RRC_UE, @@ -4096,15 +3780,14 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell( ue_context_pP->ue_context.rnti, rrc_eNB_mui, size); - rrc_data_req( - ctxt_pP, - DCCH, - rrc_eNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + ctxt_pP, + DCCH, + rrc_eNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); return(0); } @@ -4112,64 +3795,64 @@ rrc_eNB_generate_RRCConnectionReconfiguration_SCell( //----------------------------------------------------------------------------- void rrc_eNB_process_MeasurementReport( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, - const LTE_MeasResults_t* const measResults2 + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, + const LTE_MeasResults_t *const measResults2 ) //----------------------------------------------------------------------------- { int i=0; int neighboring_cells=-1; - T(T_ENB_RRC_MEASUREMENT_REPORT, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); if (measResults2 == NULL ) return; - - if (measResults2->measId > 0 ){ - if (ue_context_pP->ue_context.measResults == NULL) { - ue_context_pP->ue_context.measResults = CALLOC(1, sizeof(LTE_MeasResults_t)); - } - ue_context_pP->ue_context.measResults->measId=measResults2->measId; - ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult=measResults2->measResultPCell.rsrpResult; - ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult=measResults2->measResultPCell.rsrqResult; - LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRP of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult-140); - LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRQ of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult/2 - 20); - } - if (measResults2->measResultNeighCells == NULL) - return; - - if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) { - neighboring_cells = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count; - - if (ue_context_pP->ue_context.measResults->measResultNeighCells == NULL) { - - ue_context_pP->ue_context.measResults->measResultNeighCells = CALLOC(1, sizeof(*measResults2->measResultNeighCells)*neighboring_cells); - } - ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count = neighboring_cells; - for (i=0; i < neighboring_cells; i++){ - memcpy (ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i], - measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i], - sizeof(LTE_MeasResultListEUTRA_t)); - - LOG_D(RRC, "Physical Cell Id %d\n", - (int)ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->physCellId); - LOG_D(RRC, "RSRP of Target %d\n", - (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult)); - LOG_D(RRC, "RSRQ of Target %d\n", - (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult)); - } - } -// #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + if (measResults2->measId > 0 ) { + if (ue_context_pP->ue_context.measResults == NULL) { + ue_context_pP->ue_context.measResults = CALLOC(1, sizeof(LTE_MeasResults_t)); + } + + ue_context_pP->ue_context.measResults->measId=measResults2->measId; + ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult=measResults2->measResultPCell.rsrpResult; + ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult=measResults2->measResultPCell.rsrqResult; + LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRP of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, + ue_context_pP->ue_context.measResults->measResultPCell.rsrpResult-140); + LOG_D(RRC, "[eNB %d]Frame %d: UE %x (Measurement Id %d): RSRQ of Source %ld\n", ctxt_pP->module_id, ctxt_pP->frame, ctxt_pP->rnti, (int)measResults2->measId, + ue_context_pP->ue_context.measResults->measResultPCell.rsrqResult/2 - 20); + } + + if (measResults2->measResultNeighCells == NULL) + return; + + if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) { + neighboring_cells = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count; - -// #else + if (ue_context_pP->ue_context.measResults->measResultNeighCells == NULL) { + ue_context_pP->ue_context.measResults->measResultNeighCells = CALLOC(1, sizeof(*measResults2->measResultNeighCells)*neighboring_cells); + } + + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.count = neighboring_cells; + + for (i=0; i < neighboring_cells; i++) { + memcpy (ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i], + measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[i], + sizeof(LTE_MeasResultListEUTRA_t)); + LOG_D(RRC, "Physical Cell Id %d\n", + (int)ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->physCellId); + LOG_D(RRC, "RSRP of Target %d\n", + (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrpResult)); + LOG_D(RRC, "RSRQ of Target %d\n", + (int)*(ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultListEUTRA.list.array[i]->measResult.rsrqResult)); + } + } + + // #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + // #else // LOG_I(RRC, "RSRP of Source %d\n", measResults2->measResultServCell.rsrpResult); // LOG_I(RRC, "RSRQ of Source %d\n", measResults2->measResultServCell.rsrqResult); -// #endif - + // #endif // if (ue_context_pP->ue_context.handover_info->ho_prepare != 0xF0) { // rrc_eNB_generate_HandoverPreparationInformation(ctxt_pP, // ue_context_pP, @@ -4179,33 +3862,29 @@ rrc_eNB_process_MeasurementReport( // LOG_D(RRC, "[eNB %d] Frame %d: Ignoring MeasReport from UE %x as Handover is in progress... \n", ctxt_pP->module_id, ctxt_pP->frame, // ctxt_pP->rnti); // } - //Look for IP address of the target eNB //Send Handover Request -> target eNB //Wait for Handover Acknowledgement <- target eNB //Send Handover Command - //x2delay(); // handover_request_x2(ue_mod_idP,enb_mod_idP,measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId); - // uint8_t buffer[100]; // int size=rrc_eNB_generate_Handover_Command_TeNB(0,0,buffer); // // send_check_message((char*)buffer,size); //send_handover_command(); - } //----------------------------------------------------------------------------- void rrc_eNB_generate_HandoverPreparationInformation( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, LTE_PhysCellId_t targetPhyId ) //----------------------------------------------------------------------------- { - struct rrc_eNB_ue_context_s* ue_context_target_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_target_p = NULL; //uint8_t UE_id_target = -1; uint8_t mod_id_target = get_adjacent_cell_mod_id(targetPhyId); HANDOVER_INFO *handoverInfo = CALLOC(1, sizeof(*handoverInfo)); @@ -4215,30 +3894,24 @@ rrc_eNB_generate_HandoverPreparationInformation( struct LTE_PhysicalConfigDedicated **physicalConfigDedicated = &RC.rrc[enb_mod_idP]->physicalConfigDedicated[ue_mod_idP]; RadioResourceConfigDedicated_t *radioResourceConfigDedicated = CALLOC(1,sizeof(RadioResourceConfigDedicated_t)); */ - T(T_ENB_RRC_HANDOVER_PREPARATION_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - handoverInfo->as_config.antennaInfoCommon.antennaPortsCount = 0; //Not used 0- but check value handoverInfo->as_config.sourceDl_CarrierFreq = 36090; //Verify! - memcpy((void *)&handoverInfo->as_config.sourceMasterInformationBlock, - (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.mib, sizeof(LTE_MasterInformationBlock_t)); + (void *)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.mib, sizeof(LTE_MasterInformationBlock_t)); memcpy((void *)&handoverInfo->as_config.sourceMeasConfig, - (void*)ue_context_pP->ue_context.measConfig, sizeof(LTE_MeasConfig_t)); - + (void *)ue_context_pP->ue_context.measConfig, sizeof(LTE_MeasConfig_t)); // FIXME handoverInfo not used... free( handoverInfo ); handoverInfo = 0; - //to be configured - memset((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSecurityAlgorithmConfig, + memset((void *)&ue_context_pP->ue_context.handover_info->as_config.sourceSecurityAlgorithmConfig, 0, sizeof(LTE_SecurityAlgorithmConfig_t)); - - memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType1, - (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB1, sizeof(LTE_SystemInformationBlockType1_t)); - memcpy((void*)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType2, - (void*)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB23, sizeof(LTE_SystemInformationBlockType2_t)); + memcpy((void *)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType1, + (void *)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB1, sizeof(LTE_SystemInformationBlockType1_t)); + memcpy((void *)&ue_context_pP->ue_context.handover_info->as_config.sourceSystemInformationBlockType2, + (void *)&RC.rrc[ctxt_pP->module_id]->carrier[0] /* CROUX TBC */.SIB23, sizeof(LTE_SystemInformationBlockType2_t)); ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo = CALLOC(1, sizeof(LTE_ReestablishmentInfo_t)); ue_context_pP->ue_context.handover_info->as_context.reestablishmentInfo->sourcePhysCellId = @@ -4277,11 +3950,11 @@ rrc_eNB_generate_HandoverPreparationInformation( mod_id_target); ue_context_target_p->ue_context.handover_info = CALLOC(1, sizeof(*(ue_context_target_p->ue_context.handover_info))); - memcpy((void*)&ue_context_target_p->ue_context.handover_info->as_context, - (void*)&ue_context_pP->ue_context.handover_info->as_context, + memcpy((void *)&ue_context_target_p->ue_context.handover_info->as_context, + (void *)&ue_context_pP->ue_context.handover_info->as_context, sizeof(LTE_AS_Context_t)); - memcpy((void*)&ue_context_target_p->ue_context.handover_info->as_config, - (void*)&ue_context_pP->ue_context.handover_info->as_config, + memcpy((void *)&ue_context_target_p->ue_context.handover_info->as_config, + (void *)&ue_context_pP->ue_context.handover_info->as_config, sizeof(LTE_AS_Config_t)); ue_context_target_p->ue_context.handover_info->ho_prepare = 0x00;// 0xFF; ue_context_target_p->ue_context.handover_info->ho_complete = 0; @@ -4291,11 +3964,9 @@ rrc_eNB_generate_HandoverPreparationInformation( ue_context_target_p->ue_context.handover_info->modid_t = mod_id_target; ue_context_target_p->ue_context.handover_info->modid_s = ctxt_pP->module_id; ue_context_target_p->ue_context.handover_info->ueid_t = ue_context_target_p->ue_context.rnti; - } else { LOG_E(RRC, "\nError in obtaining free UE id in target eNB %ld for handover \n", targetPhyId); } - } else { LOG_E(RRC, "\nError in obtaining Module ID of target eNB for handover \n"); } @@ -4304,15 +3975,13 @@ rrc_eNB_generate_HandoverPreparationInformation( //----------------------------------------------------------------------------- void rrc_eNB_process_handoverPreparationInformation( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ) //----------------------------------------------------------------------------- { T(T_ENB_RRC_HANDOVER_PREPARATION_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - LOG_I(RRC, "[eNB %d] Frame %d : Logical Channel UL-DCCH, processing RRCHandoverPreparationInformation, sending LTE_RRCConnectionReconfiguration to UE %d \n", ctxt_pP->module_id, ctxt_pP->frame, ue_context_pP->ue_context.rnti); @@ -4327,12 +3996,12 @@ rrc_eNB_process_handoverPreparationInformation( //----------------------------------------------------------------------------- void check_handovers( - protocol_ctxt_t* const ctxt_pP + protocol_ctxt_t *const ctxt_pP ) //----------------------------------------------------------------------------- { int result; - struct rrc_eNB_ue_context_s* ue_context_p; + struct rrc_eNB_ue_context_s *ue_context_p; RB_FOREACH(ue_context_p, rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head) { ctxt_pP->rnti = ue_context_p->ue_id_rnti; @@ -4372,13 +4041,14 @@ check_handovers( #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) ,NULL, NULL #endif - ); + ); + //AssertFatal(result == TRUE, "PDCP data request failed!\n"); - if(result != TRUE) - { + if(result != TRUE) { LOG_I(RRC, "PDCP data request failed!\n"); return; } + ue_context_p->ue_context.handover_info->ho_complete = 0xF2; } } @@ -4389,33 +4059,29 @@ check_handovers( //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionReconfiguration_handover( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t* const nas_pdu, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t *const nas_pdu, const uint32_t nas_length ) //----------------------------------------------------------------------------- { T(T_ENB_RRC_CONNECTION_RECONFIGURATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - uint8_t buffer[RRC_BUF_SIZE]; int i; uint8_t rv[2]; uint16_t Idx; // configure SRB1/SRB2, PhysicalConfigDedicated, LTE_MAC_MainConfig for UE - eNB_RRC_INST* rrc_inst = RC.rrc[ctxt_pP->module_id]; - struct LTE_PhysicalConfigDedicated** physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; - + eNB_RRC_INST *rrc_inst = RC.rrc[ctxt_pP->module_id]; + struct LTE_PhysicalConfigDedicated **physicalConfigDedicated = &ue_context_pP->ue_context.physicalConfigDedicated; struct LTE_SRB_ToAddMod *SRB2_config; struct LTE_SRB_ToAddMod__rlc_Config *SRB2_rlc_config; struct LTE_SRB_ToAddMod__logicalChannelConfig *SRB2_lchan_config; struct LTE_LogicalChannelConfig__ul_SpecificParameters *SRB2_ul_SpecificParameters; LTE_LogicalChannelConfig_t *SRB1_logicalChannelConfig = NULL; - LTE_SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; // not used in this context: may be removed + LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; // not used in this context: may be removed LTE_SRB_ToAddModList_t *SRB_configList2; - struct LTE_DRB_ToAddMod *DRB_config; struct LTE_RLC_Config *DRB_rlc_config; struct LTE_PDCP_Config *DRB_pdcp_config; @@ -4423,7 +4089,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( struct LTE_LogicalChannelConfig *DRB_lchan_config; struct LTE_LogicalChannelConfig__ul_SpecificParameters *DRB_ul_SpecificParameters; LTE_DRB_ToAddModList_t *DRB_configList2; - LTE_MAC_MainConfig_t *mac_MainConfig; LTE_MeasObjectToAddModList_t *MeasObj_list; LTE_MeasObjectToAddMod_t *MeasObj; @@ -4440,10 +4105,8 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) long *sr_ProhibitTimer_r9; #endif - long *logicalchannelgroup, *logicalchannelgroup_drb; long *maxHARQ_Tx, *periodicBSR_Timer; - // LTE_RSRP_Range_t *rsrp; struct LTE_MeasConfig__speedStatePars *Sparams; LTE_CellsToAddMod_t *CellToAdd; @@ -4457,7 +4120,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( LTE_PhysicalConfigDedicated_t *physicalConfigDedicated2; struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList; protocol_ctxt_t ctxt; - LOG_D(RRC, "[eNB %d] Frame %d: handover preparation: get the newSourceUEIdentity (C-RNTI): ", ctxt_pP->module_id, ctxt_pP->frame); @@ -4474,7 +4136,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( SRB1_config->srb_Identity = 1; SRB1_rlc_config = CALLOC(1, sizeof(*SRB1_rlc_config)); SRB1_config->rlc_Config = SRB1_rlc_config; - SRB1_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB1_rlc_config->choice.explicitValue.present = LTE_RLC_Config_PR_am; SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms15; @@ -4483,35 +4144,25 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( SRB1_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t16; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB1_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms10; - SRB1_lchan_config = CALLOC(1, sizeof(*SRB1_lchan_config)); SRB1_config->logicalChannelConfig = SRB1_lchan_config; - SRB1_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; SRB1_ul_SpecificParameters = CALLOC(1, sizeof(*SRB1_ul_SpecificParameters)); - SRB1_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB1_ul_SpecificParameters; - SRB1_ul_SpecificParameters->priority = 1; - //assign_enum(&SRB1_ul_SpecificParameters->prioritisedBitRate,LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity); SRB1_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - //assign_enum(&SRB1_ul_SpecificParameters->bucketSizeDuration,LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50); SRB1_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - logicalchannelgroup = CALLOC(1, sizeof(long)); *logicalchannelgroup = 0; SRB1_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; - ASN_SEQUENCE_ADD(&SRB_configList2->list, SRB1_config); - //2nd: now reconfigure phy config dedicated physicalConfigDedicated2 = CALLOC(1, sizeof(*physicalConfigDedicated2)); *physicalConfigDedicated = physicalConfigDedicated2; - physicalConfigDedicated2->pdsch_ConfigDedicated = CALLOC(1, sizeof(*physicalConfigDedicated2->pdsch_ConfigDedicated)); physicalConfigDedicated2->pucch_ConfigDedicated = @@ -4533,18 +4184,15 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( //assign_enum(&physicalConfigDedicated2->pdsch_ConfigDedicated->p_a, // PDSCH_ConfigDedicated__p_a_dB0); physicalConfigDedicated2->pdsch_ConfigDedicated->p_a = LTE_PDSCH_ConfigDedicated__p_a_dB0; - // PUCCH physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.present = LTE_PUCCH_ConfigDedicated__ackNackRepetition_PR_release; physicalConfigDedicated2->pucch_ConfigDedicated->ackNackRepetition.choice.release = 0; physicalConfigDedicated2->pucch_ConfigDedicated->tdd_AckNackFeedbackMode = NULL; //PUCCH_ConfigDedicated__tdd_AckNackFeedbackMode_multiplexing; - // Pusch_config_dedicated physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_ACK_Index = 0; // 2.00 physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_RI_Index = 0; // 1.25 physicalConfigDedicated2->pusch_ConfigDedicated->betaOffset_CQI_Index = 8; // 2.25 - // UplinkPowerControlDedicated physicalConfigDedicated2->uplinkPowerControlDedicated->p0_UE_PUSCH = 0; // 0 dB //assign_enum(&physicalConfigDedicated2->uplinkPowerControlDedicated->deltaMCS_Enabled, @@ -4558,7 +4206,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( CALLOC(1, sizeof(*physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient)); // assign_enum(physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient,FilterCoefficient_fc4); // fc4 dB *physicalConfigDedicated2->uplinkPowerControlDedicated->filterCoefficient = LTE_FilterCoefficient_fc4; // fc4 dB - // TPC-PDCCH-Config physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->present = LTE_TPC_PDCCH_Config_PR_setup; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_Index.present = LTE_TPC_Index_PR_indexOfFormat3; @@ -4568,7 +4215,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[0] = 0x12; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUCCH->choice.setup.tpc_RNTI.bits_unused = 0; - physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->present = LTE_TPC_PDCCH_Config_PR_setup; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.present = LTE_TPC_Index_PR_indexOfFormat3; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_Index.choice.indexOfFormat3 = 1; @@ -4577,7 +4223,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[0] = 0x22; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.buf[1] = 0x34 + ue_context_pP->local_uid; physicalConfigDedicated2->tpc_PDCCH_ConfigPUSCH->choice.setup.tpc_RNTI.bits_unused = 0; - // CQI ReportConfig /* physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic=CALLOC(1,sizeof(*physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportModeAperiodic)); @@ -4594,7 +4239,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.ri_ConfigIndex=NULL; physicalConfigDedicated2->cqi_ReportConfig->cqi_ReportPeriodic->choice.setup.simultaneousAckNackAndCQI=0; */ - //soundingRS-UL-ConfigDedicated /* physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->present = SoundingRS_UL_ConfigDedicated_PR_setup; @@ -4609,7 +4253,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( assign_enum(&physicalConfigDedicated2->soundingRS_UL_ConfigDedicated->choice.setup.cyclicShift, SoundingRS_UL_ConfigDedicated__setup__cyclicShift_cs0); */ - //AntennaInfoDedicated physicalConfigDedicated2->antennaInfo = CALLOC(1, sizeof(*physicalConfigDedicated2->antennaInfo)); physicalConfigDedicated2->antennaInfo->present = LTE_PhysicalConfigDedicated__antennaInfo_PR_explicitValue; @@ -4637,7 +4280,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.present = LTE_AntennaInfoDedicated__ue_TransmitAntennaSelection_PR_release; physicalConfigDedicated2->antennaInfo->choice.explicitValue.ue_TransmitAntennaSelection.choice.release = 0; - // SchedulingRequestConfig physicalConfigDedicated2->schedulingRequestConfig->present = LTE_SchedulingRequestConfig_PR_setup; physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_PUCCH_ResourceIndex = ue_context_pP->local_uid; @@ -4647,24 +4289,24 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( 10); // Isr = 5 (every 10 subframes, offset=2+UE_id mod3) } else { switch (rrc_inst->carrier[0].sib1->tdd_Config->subframeAssignment) { - case 1: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid & 1) + (( - ue_context_pP->local_uid & 3) >> 1) * 5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) - break; + case 1: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid & 1) + (( + ue_context_pP->local_uid & 3) >> 1) * 5; // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 7 for UE2, 8 for UE3 , 2 for UE4 etc..) + break; - case 3: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid % - 3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) - break; + case 3: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid % + 3); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + break; - case 4: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid & - 1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) - break; + case 4: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7 + (ue_context_pP->local_uid & + 1); // Isr = 5 (every 10 subframes, offset=2 for UE0, 3 for UE1, 3 for UE2, 2 for UE3 , etc..) + break; - default: - physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7; // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..) - break; + default: + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.sr_ConfigIndex = 7; // Isr = 5 (every 10 subframes, offset=2 for all UE0 etc..) + break; } } @@ -4673,59 +4315,55 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( // assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4; physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = LTE_SchedulingRequestConfig__setup__dsr_TransMax_n4; - LOG_D(RRC, "handover_config [FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 UE %x) --->][MAC_eNB][MOD %02d][]\n", ctxt_pP->frame, ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ctxt_pP->module_id); rrc_mac_config_req_eNB( - ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + ctxt_pP->module_id, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) -0, -#endif - ue_context_pP->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t*) NULL, + 0, +#endif + ue_context_pP->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t*) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - ue_context_pP->ue_context.physicalConfigDedicated, + ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - 1, - SRB1_logicalChannelConfig, - ue_context_pP->ue_context.measGapConfig, - (LTE_TDD_Config_t*) NULL, - (LTE_MobilityControlInfo_t*) NULL, - (LTE_SchedulingInfoList_t*) NULL, - 0, - NULL, - NULL, - (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (LTE_TDD_Config_t *) NULL, + (LTE_MobilityControlInfo_t *) NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, + NULL, + NULL, + (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); - + ); // Configure target eNB SRB2 /// SRB2 SRB2_config = CALLOC(1, sizeof(*SRB2_config)); SRB_configList2 = CALLOC(1, sizeof(*SRB_configList2)); memset(SRB_configList2, 0, sizeof(*SRB_configList2)); - SRB2_config->srb_Identity = 2; SRB2_rlc_config = CALLOC(1, sizeof(*SRB2_rlc_config)); SRB2_config->rlc_Config = SRB2_rlc_config; - SRB2_rlc_config->present = LTE_SRB_ToAddMod__rlc_Config_PR_explicitValue; SRB2_rlc_config->choice.explicitValue.present = LTE_RLC_Config_PR_am; SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.t_PollRetransmit = LTE_T_PollRetransmit_ms15; @@ -4734,34 +4372,26 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( SRB2_rlc_config->choice.explicitValue.choice.am.ul_AM_RLC.maxRetxThreshold = LTE_UL_AM_RLC__maxRetxThreshold_t32; SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_Reordering = LTE_T_Reordering_ms35; SRB2_rlc_config->choice.explicitValue.choice.am.dl_AM_RLC.t_StatusProhibit = LTE_T_StatusProhibit_ms10; - SRB2_lchan_config = CALLOC(1, sizeof(*SRB2_lchan_config)); SRB2_config->logicalChannelConfig = SRB2_lchan_config; - SRB2_lchan_config->present = LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue; - SRB2_ul_SpecificParameters = CALLOC(1, sizeof(*SRB2_ul_SpecificParameters)); - SRB2_ul_SpecificParameters->priority = 1; SRB2_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; SRB2_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - // LCG for CCCH and DCCH is 0 as defined in 36331 logicalchannelgroup = CALLOC(1, sizeof(long)); *logicalchannelgroup = 0; - SRB2_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup; SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters = SRB2_ul_SpecificParameters; ASN_SEQUENCE_ADD(&SRB_configList->list, SRB2_config); ASN_SEQUENCE_ADD(&SRB_configList2->list, SRB2_config); - // Configure target eNB DRB DRB_configList2 = CALLOC(1, sizeof(*DRB_configList2)); /// DRB DRB_config = CALLOC(1, sizeof(*DRB_config)); - //DRB_config->drb_Identity = (LTE_DRB_Identity_t) 1; //allowed values 1..32 // NN: this is the 1st DRB for this ue, so set it to 1 DRB_config->drb_Identity = (LTE_DRB_Identity_t) 1; // (ue_mod_idP+1); //allowed values 1..32 @@ -4773,7 +4403,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( DRB_rlc_config->choice.um_Bi_Directional.ul_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.sn_FieldLength = LTE_SN_FieldLength_size10; DRB_rlc_config->choice.um_Bi_Directional.dl_UM_RLC.t_Reordering = LTE_T_Reordering_ms35; - DRB_pdcp_config = CALLOC(1, sizeof(*DRB_pdcp_config)); DRB_config->pdcp_Config = DRB_pdcp_config; DRB_pdcp_config->discardTimer = NULL; @@ -4782,53 +4411,37 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( DRB_pdcp_config->rlc_UM = PDCP_rlc_UM; PDCP_rlc_UM->pdcp_SN_Size = LTE_PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits; DRB_pdcp_config->headerCompression.present = LTE_PDCP_Config__headerCompression_PR_notUsed; - DRB_lchan_config = CALLOC(1, sizeof(*DRB_lchan_config)); DRB_config->logicalChannelConfig = DRB_lchan_config; DRB_ul_SpecificParameters = CALLOC(1, sizeof(*DRB_ul_SpecificParameters)); DRB_lchan_config->ul_SpecificParameters = DRB_ul_SpecificParameters; - DRB_ul_SpecificParameters->priority = 2; // lower priority than srb1, srb2 DRB_ul_SpecificParameters->prioritisedBitRate = LTE_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; DRB_ul_SpecificParameters->bucketSizeDuration = LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50; - // LCG for DTCH can take the value from 1 to 3 as defined in 36331: normally controlled by upper layers (like RRM) logicalchannelgroup_drb = CALLOC(1, sizeof(long)); *logicalchannelgroup_drb = 1; DRB_ul_SpecificParameters->logicalChannelGroup = logicalchannelgroup_drb; - ASN_SEQUENCE_ADD(&DRB_configList2->list, DRB_config); - mac_MainConfig = CALLOC(1, sizeof(*mac_MainConfig)); ue_context_pP->ue_context.mac_MainConfig = mac_MainConfig; - mac_MainConfig->ul_SCH_Config = CALLOC(1, sizeof(*mac_MainConfig->ul_SCH_Config)); - maxHARQ_Tx = CALLOC(1, sizeof(long)); *maxHARQ_Tx = LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; mac_MainConfig->ul_SCH_Config->maxHARQ_Tx = maxHARQ_Tx; - periodicBSR_Timer = CALLOC(1, sizeof(long)); *periodicBSR_Timer = LTE_PeriodicBSR_Timer_r12_sf64; mac_MainConfig->ul_SCH_Config->periodicBSR_Timer = periodicBSR_Timer; - mac_MainConfig->ul_SCH_Config->retxBSR_Timer = LTE_RetxBSR_Timer_r12_sf320; - mac_MainConfig->ul_SCH_Config->ttiBundling = 0; // FALSE - mac_MainConfig->drx_Config = NULL; - mac_MainConfig->phr_Config = CALLOC(1, sizeof(*mac_MainConfig->phr_Config)); - mac_MainConfig->phr_Config->present = LTE_MAC_MainConfig__phr_Config_PR_setup; mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; // sf20 = 20 subframes - mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer = LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; // sf20 = 20 subframes - mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange = LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; // Value dB1 =1 dB, dB3 = 3 dB - #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) sr_ProhibitTimer_r9 = CALLOC(1, sizeof(long)); *sr_ProhibitTimer_r9 = 0; // SR tx on PUCCH, Value in number of SR period(s). Value 0 = no timer for SR, Value 2= 2*SR @@ -4839,54 +4452,43 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( // Measurement ID list MeasId_list = CALLOC(1, sizeof(*MeasId_list)); memset((void *)MeasId_list, 0, sizeof(*MeasId_list)); - MeasId0 = CALLOC(1, sizeof(*MeasId0)); MeasId0->measId = 1; MeasId0->measObjectId = 1; MeasId0->reportConfigId = 1; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId0); - MeasId1 = CALLOC(1, sizeof(*MeasId1)); MeasId1->measId = 2; MeasId1->measObjectId = 1; MeasId1->reportConfigId = 2; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId1); - MeasId2 = CALLOC(1, sizeof(*MeasId2)); MeasId2->measId = 3; MeasId2->measObjectId = 1; MeasId2->reportConfigId = 3; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId2); - MeasId3 = CALLOC(1, sizeof(*MeasId3)); MeasId3->measId = 4; MeasId3->measObjectId = 1; MeasId3->reportConfigId = 4; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId3); - MeasId4 = CALLOC(1, sizeof(*MeasId4)); MeasId4->measId = 5; MeasId4->measObjectId = 1; MeasId4->reportConfigId = 5; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId4); - MeasId5 = CALLOC(1, sizeof(*MeasId5)); MeasId5->measId = 6; MeasId5->measObjectId = 1; MeasId5->reportConfigId = 6; ASN_SEQUENCE_ADD(&MeasId_list->list, MeasId5); - // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measIdToAddModList = MeasId_list; - // Add one EUTRA Measurement Object MeasObj_list = CALLOC(1, sizeof(*MeasObj_list)); memset((void *)MeasObj_list, 0, sizeof(*MeasObj_list)); - // Configure MeasObject - MeasObj = CALLOC(1, sizeof(*MeasObj)); memset((void *)MeasObj, 0, sizeof(*MeasObj)); - MeasObj->measObjectId = 1; MeasObj->measObject.present = LTE_MeasObjectToAddMod__measObject_PR_measObjectEUTRA; MeasObj->measObject.choice.measObjectEUTRA.carrierFreq = 36090; @@ -4897,7 +4499,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.size = 1; MeasObj->measObject.choice.measObjectEUTRA.neighCellConfig.bits_unused = 6; MeasObj->measObject.choice.measObjectEUTRA.offsetFreq = NULL; // Default is 15 or 0dB - MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList = (LTE_CellsToAddModList_t *) CALLOC(1, sizeof(*CellsToAddModList)); CellsToAddModList = MeasObj->measObject.choice.measObjectEUTRA.cellsToAddModList; @@ -4908,28 +4509,19 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( CellToAdd->cellIndex = i + 1; CellToAdd->physCellId = get_adjacent_cell_id(ctxt_pP->module_id, i); CellToAdd->cellIndividualOffset = LTE_Q_OffsetRange_dB0; - ASN_SEQUENCE_ADD(&CellsToAddModList->list, CellToAdd); } ASN_SEQUENCE_ADD(&MeasObj_list->list, MeasObj); // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->measObjectToAddModList = MeasObj_list; - // Report Configurations for periodical, A1-A5 events ReportConfig_list = CALLOC(1, sizeof(*ReportConfig_list)); - ReportConfig_per = CALLOC(1, sizeof(*ReportConfig_per)); - ReportConfig_A1 = CALLOC(1, sizeof(*ReportConfig_A1)); - ReportConfig_A2 = CALLOC(1, sizeof(*ReportConfig_A2)); - ReportConfig_A3 = CALLOC(1, sizeof(*ReportConfig_A3)); - ReportConfig_A4 = CALLOC(1, sizeof(*ReportConfig_A4)); - ReportConfig_A5 = CALLOC(1, sizeof(*ReportConfig_A5)); - ReportConfig_per->reportConfigId = 1; ReportConfig_per->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -4941,9 +4533,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( ReportConfig_per->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_per->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_per); - ReportConfig_A1->reportConfigId = 2; ReportConfig_A1->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -4954,15 +4544,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( a1_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA1. a1_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A1->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A1); - ReportConfig_A2->reportConfigId = 3; ReportConfig_A2->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -4973,15 +4560,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( a2_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA2. a2_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A2); - ReportConfig_A3->reportConfigId = 4; ReportConfig_A3->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -4992,15 +4576,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( 10; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA3.reportOnLeave = 1; - ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A3->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A3); - ReportConfig_A4->reportConfigId = 5; ReportConfig_A4->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -5011,15 +4592,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( a4_Threshold.present = LTE_ThresholdEUTRA_PR_threshold_RSRP; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA4. a4_Threshold.choice.threshold_RSRP = 10; - ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A4->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A4); - ReportConfig_A5->reportConfigId = 6; ReportConfig_A5->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.present = @@ -5034,15 +4612,12 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( eventA5.a5_Threshold1.choice.threshold_RSRP = 10; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice. eventA5.a5_Threshold2.choice.threshold_RSRP = 10; - ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.triggerQuantity = LTE_ReportConfigEUTRA__triggerQuantity_rsrp; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportQuantity = LTE_ReportConfigEUTRA__reportQuantity_both; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.maxReportCells = 2; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportInterval = LTE_ReportInterval_ms120; ReportConfig_A5->reportConfig.choice.reportConfigEUTRA.reportAmount = LTE_ReportConfigEUTRA__reportAmount_infinity; - ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5); - Sparams = CALLOC(1, sizeof(*Sparams)); Sparams->present = LTE_MeasConfig__speedStatePars_PR_setup; Sparams->choice.setup.timeToTrigger_SF.sf_High = LTE_SpeedStateScaleFactors__sf_Medium_oDot75; @@ -5051,7 +4626,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( Sparams->choice.setup.mobilityStateParameters.n_CellChangeMedium = 5; Sparams->choice.setup.mobilityStateParameters.t_Evaluation = LTE_MobilityStateParameters__t_Evaluation_s60; Sparams->choice.setup.mobilityStateParameters.t_HystNormal = LTE_MobilityStateParameters__t_HystNormal_s120; - quantityConfig = CALLOC(1, sizeof(*quantityConfig)); memset((void *)quantityConfig, 0, sizeof(*quantityConfig)); quantityConfig->quantityConfigEUTRA = CALLOC(1, sizeof(*quantityConfig->quantityConfigEUTRA)); @@ -5065,9 +4639,7 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( CALLOC(1, sizeof(*quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ)); *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = LTE_FilterCoefficient_fc4; *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = LTE_FilterCoefficient_fc4; - /* mobilityinfo */ - mobilityInfo = CALLOC(1, sizeof(*mobilityInfo)); memset((void *)mobilityInfo, 0, sizeof(*mobilityInfo)); mobilityInfo->targetPhysCellId = @@ -5078,22 +4650,17 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( mobilityInfo->targetPhysCellId, ctxt_pP->module_id, ue_context_pP->ue_context.rnti); - mobilityInfo->additionalSpectrumEmission = CALLOC(1, sizeof(*mobilityInfo->additionalSpectrumEmission)); *mobilityInfo->additionalSpectrumEmission = 1; //Check this value! - mobilityInfo->t304 = LTE_MobilityControlInfo__t304_ms50; // need to configure an appropriate value here - // New UE Identity (C-RNTI) to identify an UE uniquely in a cell mobilityInfo->newUE_Identity.size = 2; mobilityInfo->newUE_Identity.bits_unused = 0; mobilityInfo->newUE_Identity.buf = rv; mobilityInfo->newUE_Identity.buf[0] = rv[0]; mobilityInfo->newUE_Identity.buf[1] = rv[1]; - //memset((void *)&mobilityInfo->radioResourceConfigCommon,(void *)&rrc_inst->sib2->radioResourceConfigCommon,sizeof(RadioResourceConfigCommon_t)); //memset((void *)&mobilityInfo->radioResourceConfigCommon,0,sizeof(RadioResourceConfigCommon_t)); - // Configuring radioResourceConfigCommon mobilityInfo->radioResourceConfigCommon.rach_ConfigCommon = CALLOC(1, sizeof(*mobilityInfo->radioResourceConfigCommon.rach_ConfigCommon)); @@ -5104,7 +4671,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( memcpy((void *)mobilityInfo->radioResourceConfigCommon.prach_Config.prach_ConfigInfo, (void *)&rrc_inst->carrier[0] /* CROUX TBC */.sib2->radioResourceConfigCommon.prach_Config.prach_ConfigInfo, sizeof(LTE_PRACH_ConfigInfo_t)); - mobilityInfo->radioResourceConfigCommon.prach_Config.rootSequenceIndex = rrc_inst->carrier[0] /* CROUX TBC */.sib2->radioResourceConfigCommon.prach_Config.rootSequenceIndex; mobilityInfo->radioResourceConfigCommon.pdsch_ConfigCommon = @@ -5136,31 +4702,27 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( mobilityInfo->radioResourceConfigCommon.ul_CyclicPrefixLength = rrc_inst->carrier[0] /* CROUX TBC */.sib2->radioResourceConfigCommon.ul_CyclicPrefixLength; //End of configuration of radioResourceConfigCommon - mobilityInfo->carrierFreq = CALLOC(1, sizeof(*mobilityInfo->carrierFreq)); //CALLOC(1,sizeof(CarrierFreqEUTRA_t)); 36090 mobilityInfo->carrierFreq->dl_CarrierFreq = 36090; mobilityInfo->carrierFreq->ul_CarrierFreq = NULL; - mobilityInfo->carrierBandwidth = CALLOC(1, sizeof( *mobilityInfo->carrierBandwidth)); //CALLOC(1,sizeof(struct LTE_CarrierBandwidthEUTRA)); LTE_AllowedMeasBandwidth_mbw25 mobilityInfo->carrierBandwidth->dl_Bandwidth = LTE_CarrierBandwidthEUTRA__dl_Bandwidth_n25; mobilityInfo->carrierBandwidth->ul_Bandwidth = NULL; mobilityInfo->rach_ConfigDedicated = NULL; - // store the srb and drb list for ho management, mainly in case of failure - memcpy(ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.srb_ToAddModList, - (void*)SRB_configList2, + (void *)SRB_configList2, sizeof(LTE_SRB_ToAddModList_t)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToAddModList, - (void*)DRB_configList2, + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToAddModList, + (void *)DRB_configList2, sizeof(LTE_DRB_ToAddModList_t)); ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.drb_ToReleaseList = NULL; - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, - (void*)mac_MainConfig, + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.mac_MainConfig, + (void *)mac_MainConfig, sizeof(LTE_MAC_MainConfig_t)); - memcpy((void*)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, - (void*)ue_context_pP->ue_context.physicalConfigDedicated, + memcpy((void *)ue_context_pP->ue_context.handover_info->as_config.sourceRadioResourceConfig.physicalConfigDedicated, + (void *)ue_context_pP->ue_context.physicalConfigDedicated, sizeof(LTE_PhysicalConfigDedicated_t)); /* memcpy((void *)rrc_inst->handover_info[ue_mod_idP]->as_config.sourceRadioResourceConfig.sps_Config, (void *)rrc_inst->sps_Config[ue_mod_idP], @@ -5175,19 +4737,15 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( ue_context_pP->ue_context.Srb1.Srb_info.Srb_id = Idx; memcpy(&ue_context_pP->ue_context.Srb1.Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); memcpy(&ue_context_pP->ue_context.Srb1.Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - - // SRB2 + // SRB2 ue_context_pP->ue_context.Srb2.Active = 1; ue_context_pP->ue_context.Srb2.Srb_info.Srb_id = Idx; memcpy(&ue_context_pP->ue_context.Srb2.Srb_info.Lchan_desc[0], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); memcpy(&ue_context_pP->ue_context.Srb2.Srb_info.Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - LOG_I(RRC, "[eNB %d] CALLING RLC CONFIG SRB1 (rbid %d) for UE %x\n", ctxt_pP->module_id, Idx, ue_context_pP->ue_context.rnti); - // rrc_pdcp_config_req (enb_mod_idP, frameP, 1, CONFIG_ACTION_ADD, idx, UNDEF_SECURITY_MODE); // rrc_rlc_config_req(enb_mod_idP,frameP,1,CONFIG_ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - rrc_pdcp_config_asn1_req(&ctxt, ue_context_pP->ue_context.SRB_configList, (LTE_DRB_ToAddModList_t *) NULL, (LTE_DRB_ToReleaseList_t *) NULL, 0xff, NULL, NULL, NULL @@ -5195,7 +4753,6 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( , (LTE_PMCH_InfoList_r9_t *) NULL #endif ,NULL); - rrc_rlc_config_asn1_req(&ctxt, ue_context_pP->ue_context.SRB_configList, (LTE_DRB_ToAddModList_t *) NULL, (LTE_DRB_ToReleaseList_t *) NULL @@ -5204,47 +4761,46 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( , 0, 0 #endif ); - /* Initialize NAS list */ dedicatedInfoNASList = NULL; - // LTE_RRCConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.measConfig->reportConfigToAddModList = ReportConfig_list; memset(buffer, 0, RRC_BUF_SIZE); - - int size=do_RRCConnectionReconfiguration( - ctxt_pP, - buffer, - rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id, - SRB_configList2, - DRB_configList2, - NULL, // DRB2_list, - NULL, //*sps_Config, - ue_context_pP->ue_context.physicalConfigDedicated, - MeasObj_list, - ReportConfig_list, - NULL, //quantityConfig, - MeasId_list, - mac_MainConfig, - NULL, - mobilityInfo, - Sparams, - NULL, - NULL, - dedicatedInfoNASList, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)NULL + int size=do_RRCConnectionReconfiguration( + ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id, + SRB_configList2, + DRB_configList2, + NULL, // DRB2_list, + NULL, //*sps_Config, + ue_context_pP->ue_context.physicalConfigDedicated, + MeasObj_list, + ReportConfig_list, + NULL, //quantityConfig, + MeasId_list, + mac_MainConfig, + NULL, + mobilityInfo, + Sparams, + NULL, + NULL, + dedicatedInfoNASList, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , NULL // SCellToAddMod_r10_t + , NULL // SCellToAddMod_r10_t #endif - ); - if (size <= 0) - LOG_E(RRC, - "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration for handover (bytes %d, UE rnti %x) failed\n", - ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - else - LOG_I(RRC, - "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration for handover (bytes %d, UE rnti %x)\n", - ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + ); + + if (size <= 0) + LOG_E(RRC, + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration for handover (bytes %d, UE rnti %x) failed\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + else + LOG_I(RRC, + "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration for handover (bytes %d, UE rnti %x)\n", + ctxt_pP->module_id, ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); + // to be updated if needed /*if (RC.rrc[ctxt_pP->module_id]->SRB1_config[ue_mod_idP]->logicalChannelConfig) { if (RC.rrc[ctxt_pP->module_id]->SRB1_config[ue_mod_idP]->logicalChannelConfig->present == LTE_SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { @@ -5258,55 +4814,52 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; } */ - LOG_D(RRC, "[FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration_handover to UE %x MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", ctxt_pP->frame, ctxt_pP->module_id, size, ue_context_pP->ue_context.rnti, rrc_eNB_mui, ctxt_pP->module_id, DCCH); //rrc_rlc_data_req(ctxt_pP->module_id,frameP, 1,(ue_mod_idP*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); //pdcp_data_req (ctxt_pP->module_id, frameP, 1, (ue_mod_idP * NB_RB_MAX) + DCCH,rrc_eNB_mui++, 0, size, (char *) buffer, 1); - rrc_mac_config_req_eNB( - ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + ctxt_pP->module_id, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - ue_context_pP->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + ue_context_pP->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - ue_context_pP->ue_context.physicalConfigDedicated, + ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - 1, - SRB1_logicalChannelConfig, - ue_context_pP->ue_context.measGapConfig, - (LTE_TDD_Config_t *) NULL, - (LTE_MobilityControlInfo_t *) mobilityInfo, - (LTE_SchedulingInfoList_t *) NULL, 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (LTE_TDD_Config_t *) NULL, + (LTE_MobilityControlInfo_t *) mobilityInfo, + (LTE_SchedulingInfoList_t *) NULL, 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); - + ); /* handoverCommand.criticalExtensions.present = HandoverCommand__criticalExtensions_PR_c1; handoverCommand.criticalExtensions.choice.c1.present = HandoverCommand__criticalExtensions__c1_PR_handoverCommand_r8; handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.buf = buffer; handoverCommand.criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.size = size; */ -//#warning "COMPILATION PROBLEM" + //#warning "COMPILATION PROBLEM" #ifdef PROBLEM_COMPILATION_RESOLVED if (sourceModId != 0xFF) { @@ -5351,10 +4904,14 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover( */ //----------------------------------------------------------------------------- +/* +* TODO: * add function description +* * format the function correctly +*/ void rrc_eNB_process_RRCConnectionReconfigurationComplete( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, const uint8_t xid ) //----------------------------------------------------------------------------- @@ -5367,20 +4924,16 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( (void)oip_ifup; (void)dest_ip_offset; #endif - uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; ue_context_pP->ue_context.ue_reestablishment_timer = 0; - - LTE_DRB_ToAddModList_t* DRB_configList = ue_context_pP->ue_context.DRB_configList2[xid]; - LTE_SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid]; - LTE_DRB_ToReleaseList_t* DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; - LTE_DRB_Identity_t* drb_id_p = NULL; - + LTE_DRB_ToAddModList_t *DRB_configList = ue_context_pP->ue_context.DRB_configList2[xid]; + LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList2[xid]; + LTE_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; + LTE_DRB_Identity_t *drb_id_p = NULL; T(T_ENB_RRC_CONNECTION_RECONFIGURATION_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - #if defined(ENABLE_SECURITY) /* Derive the keys from kenb */ @@ -5393,9 +4946,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ue_context_pP->ue_context.kenb, &kRRCenc); derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, ue_context_pP->ue_context.kenb, &kRRCint); - #endif - // Refresh SRBs/DRBs MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, @@ -5405,12 +4956,11 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( MSC_AS_TIME_FMT" CONFIG_REQ UE %x DRB (security unchanged)", MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP->ue_context.rnti); - rrc_pdcp_config_asn1_req( ctxt_pP, SRB_configList, //NULL, //LG-RK 14/05/2014 SRB_configList, - DRB_configList, -// (LTE_DRB_ToReleaseList_t *) NULL, + DRB_configList, + // (LTE_DRB_ToReleaseList_t *) NULL, DRB_Release_configList2, /*RC.rrc[ctxt_pP->module_id]->ciphering_algorithm[ue_mod_idP] | (RC.rrc[ctxt_pP->module_id]->integrity_algorithm[ue_mod_idP] << 4), @@ -5428,45 +4978,45 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP, SRB_configList, // NULL, //LG-RK 14/05/2014 SRB_configList, DRB_configList, -// (LTE_DRB_ToReleaseList_t *) NULL + // (LTE_DRB_ToReleaseList_t *) NULL DRB_Release_configList2 #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) , (LTE_PMCH_InfoList_r9_t *) NULL , 0, 0 #endif ); - + // set the SRB active in Ue context if (SRB_configList != NULL) { for (i = 0; (i < SRB_configList->list.count) && (i < 3); i++) { - if (SRB_configList->list.array[i]->srb_Identity == 1 ){ - ue_context_pP->ue_context.Srb1.Active=1; - } - else if (SRB_configList->list.array[i]->srb_Identity == 2 ) { - ue_context_pP->ue_context.Srb2.Active=1; - ue_context_pP->ue_context.Srb2.Srb_info.Srb_id=2; - LOG_I(RRC,"[eNB %d] Frame %d CC %d : SRB2 is now active\n", - ctxt_pP->module_id, - ctxt_pP->frame, - ue_context_pP->ue_context.primaryCC_id); + if (SRB_configList->list.array[i]->srb_Identity == 1 ) { + ue_context_pP->ue_context.Srb1.Active=1; + } else if (SRB_configList->list.array[i]->srb_Identity == 2 ) { + ue_context_pP->ue_context.Srb2.Active=1; + ue_context_pP->ue_context.Srb2.Srb_info.Srb_id=2; + LOG_I(RRC,"[eNB %d] Frame %d CC %d : SRB2 is now active\n", + ctxt_pP->module_id, + ctxt_pP->frame, + ue_context_pP->ue_context.primaryCC_id); } else { - LOG_W(RRC,"[eNB %d] Frame %d CC %d : invalide SRB identity %ld\n", - ctxt_pP->module_id, - ctxt_pP->frame, + LOG_W(RRC,"[eNB %d] Frame %d CC %d : invalide SRB identity %ld\n", + ctxt_pP->module_id, + ctxt_pP->frame, ue_context_pP->ue_context.primaryCC_id, - SRB_configList->list.array[i]->srb_Identity); + SRB_configList->list.array[i]->srb_Identity); } } + free(SRB_configList); ue_context_pP->ue_context.SRB_configList2[xid] = NULL; } - + // Loop through DRBs and establish if necessary if (DRB_configList != NULL) { for (i = 0; i < DRB_configList->list.count; i++) { // num max DRB (11-3-8) if (DRB_configList->list.array[i]) { - drb_id = (int)DRB_configList->list.array[i]->drb_Identity; + drb_id = (int)DRB_configList->list.array[i]->drb_Identity; LOG_I(RRC, "[eNB %d] Frame %d : Logical Channel UL-DCCH, Received LTE_RRCConnectionReconfigurationComplete from UE rnti %x, reconfiguring DRB %d/LCID %d\n", ctxt_pP->module_id, @@ -5492,7 +5042,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( RADIO_ACCESS_BEARER,Rlc_info_um); */ ue_context_pP->ue_context.DRB_active[drb_id] = 1; - LOG_D(RRC, "[eNB %d] Frame %d: Establish RLC UM Bidirectional, DRB %d Active\n", ctxt_pP->module_id, ctxt_pP->frame, (int)DRB_configList->list.array[i]->drb_Identity); @@ -5508,7 +5057,7 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( ctxt_pP->module_id + 1); // fourth octet if (oip_ifup == 0) { // interface is up --> send a config the DRB - module_id_t ue_module_id; + module_id_t ue_module_id; dest_ip_offset = 8; LOG_I(OIP, "[eNB %d] Config the oai%d to send/receive pkt on DRB %ld to/from the protocol stack\n", @@ -5528,7 +5077,6 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( # endif #endif - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (DRB) ---> MAC_eNB\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); @@ -5538,43 +5086,41 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( } rrc_mac_config_req_eNB( - ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + ctxt_pP->module_id, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - ue_context_pP->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + ue_context_pP->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - ue_context_pP->ue_context.physicalConfigDedicated, + ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - DRB2LCHAN[i], - DRB_configList->list.array[i]->logicalChannelConfig, - ue_context_pP->ue_context.measGapConfig, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + DRB2LCHAN[i], + DRB_configList->list.array[i]->logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); - + ); } else { // remove LCHAN from MAC/PHY - if (ue_context_pP->ue_context.DRB_active[drb_id] == 1) { // DRB has just been removed so remove RLC + PDCP for DRB /* rrc_pdcp_config_req (ctxt_pP->module_id, frameP, 1, CONFIG_ACTION_REMOVE, @@ -5594,90 +5140,89 @@ rrc_eNB_process_RRCConnectionReconfigurationComplete( PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (DRB) ---> MAC_eNB\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); rrc_mac_config_req_eNB(ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - ue_context_pP->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + ue_context_pP->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - ue_context_pP->ue_context.physicalConfigDedicated, + ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - DRB2LCHAN[i], - (LTE_LogicalChannelConfig_t *) NULL, - (LTE_MeasGapConfig_t *) NULL, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + DRB2LCHAN[i], + (LTE_LogicalChannelConfig_t *) NULL, + (LTE_MeasGapConfig_t *) NULL, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); + ); } } } - free(DRB_configList); + + free(DRB_configList); ue_context_pP->ue_context.DRB_configList2[xid] = NULL; } - if(DRB_Release_configList2 != NULL){ - for (i = 0; i < DRB_Release_configList2->list.count; i++) { - if (DRB_Release_configList2->list.array[i]) { - drb_id_p = DRB_Release_configList2->list.array[i]; - drb_id = *drb_id_p; - if (ue_context_pP->ue_context.DRB_active[drb_id] == 1) { - ue_context_pP->ue_context.DRB_active[drb_id] = 0; - } - } + if(DRB_Release_configList2 != NULL) { + for (i = 0; i < DRB_Release_configList2->list.count; i++) { + if (DRB_Release_configList2->list.array[i]) { + drb_id_p = DRB_Release_configList2->list.array[i]; + drb_id = *drb_id_p; + + if (ue_context_pP->ue_context.DRB_active[drb_id] == 1) { + ue_context_pP->ue_context.DRB_active[drb_id] = 0; + } } - free(DRB_Release_configList2); - ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL; + } + + free(DRB_Release_configList2); + ue_context_pP->ue_context.DRB_Release_configList2[xid] = NULL; } } //----------------------------------------------------------------------------- void rrc_eNB_generate_RRCConnectionSetup( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const int CC_id ) //----------------------------------------------------------------------------- { - LTE_LogicalChannelConfig_t *SRB1_logicalChannelConfig; //,*SRB2_logicalChannelConfig; LTE_SRB_ToAddModList_t **SRB_configList; LTE_SRB_ToAddMod_t *SRB1_config; int cnt; - T(T_ENB_RRC_CONNECTION_SETUP, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - SRB_configList = &ue_context_pP->ue_context.SRB_configList; RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size = do_RRCConnectionSetup(ctxt_pP, ue_context_pP, CC_id, - (uint8_t*) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, - (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 + (uint8_t *) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload, + (uint8_t) RC.rrc[ctxt_pP->module_id]->carrier[CC_id].p_eNB, //at this point we do not have the UE capability information, so it can only be TM1 or TM2 rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), SRB_configList, &ue_context_pP->ue_context.physicalConfigDedicated); - LOG_DUMPMSG(RRC,DEBUG_RRC, (char *)(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.Payload), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size, @@ -5705,40 +5250,40 @@ rrc_eNB_generate_RRCConnectionSetup( PROTOCOL_RRC_CTXT_UE_FMT" RRC_eNB --- MAC_CONFIG_REQ (SRB1) ---> MAC_eNB\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); rrc_mac_config_req_eNB( - ctxt_pP->module_id, - ue_context_pP->ue_context.primaryCC_id, - 0,0,0,0,0, + ctxt_pP->module_id, + ue_context_pP->ue_context.primaryCC_id, + 0,0,0,0,0, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - 0, + 0, #endif - ue_context_pP->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + ue_context_pP->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, #endif - ue_context_pP->ue_context.physicalConfigDedicated, + ue_context_pP->ue_context.physicalConfigDedicated, #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, -#endif - (LTE_MeasObjectToAddMod_t **) NULL, - ue_context_pP->ue_context.mac_MainConfig, - 1, - SRB1_logicalChannelConfig, - ue_context_pP->ue_context.measGapConfig, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct LTE_PhysicalConfigDedicatedSCell_r10 *)NULL, +#endif + (LTE_MeasObjectToAddMod_t **) NULL, + ue_context_pP->ue_context.mac_MainConfig, + 1, + SRB1_logicalChannelConfig, + ue_context_pP->ue_context.measGapConfig, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL #endif #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0)) - , - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL + , + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL #endif - ); + ); break; } } @@ -5753,18 +5298,15 @@ rrc_eNB_generate_RRCConnectionSetup( MSC_AS_TIME_ARGS(ctxt_pP), ue_context_pP->ue_context.rnti, RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel DL-CCCH, Generating LTE_RRCConnectionSetup (bytes %d)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), RC.rrc[ctxt_pP->module_id]->carrier[CC_id].Srb0.Tx_buffer.payload_size); - //ue_context_pP->ue_context.ue_release_timer_thres=100; - // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE - ue_context_pP->ue_context.ue_release_timer=1; - // remove UE after 10 frames after LTE_RRCConnectionRelease is triggered - ue_context_pP->ue_context.ue_release_timer_thres=1000; + // activate release timer, if RRCSetupComplete not received after 100 frames, remove UE + ue_context_pP->ue_context.ue_release_timer=1; + // remove UE after 10 frames after LTE_RRCConnectionRelease is triggered + ue_context_pP->ue_context.ue_release_timer_thres=1000; } @@ -5773,7 +5315,7 @@ rrc_eNB_generate_RRCConnectionSetup( char openair_rrc_eNB_configuration( const module_id_t enb_mod_idP, - RrcConfigurationReq* configuration + RrcConfigurationReq *configuration ) #else char @@ -5785,18 +5327,18 @@ openair_rrc_eNB_init( { protocol_ctxt_t ctxt; int CC_id; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, enb_mod_idP, ENB_FLAG_YES, NOT_A_RNTI, 0, 0,enb_mod_idP); LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Init...\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); - #if OCP_FRAMEWORK + while ( RC.rrc[enb_mod_idP] == NULL ) { LOG_E(RRC, "RC.rrc not yet initialized, waiting 1 second\n"); sleep(1); } -#endif + +#endif AssertFatal(RC.rrc[enb_mod_idP] != NULL, "RC.rrc not initialized!"); AssertFatal(MAX_MOBILES_PER_ENB < (module_id_t)0xFFFFFFFFFFFFFFFF, " variable overflow"); #ifdef ENABLE_ITTI @@ -5828,22 +5370,15 @@ openair_rrc_eNB_init( // for (j = 0; j < (MAX_MOBILES_PER_ENB + 1); j++) { // RC.rrc[enb_mod_idP]->Srb2[j].Active = 0; // } - - RC.rrc[ctxt.module_id]->initial_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL); RC.rrc[ctxt.module_id]->s1ap_id2_s1ap_ids = hashtable_create (MAX_MOBILES_PER_ENB * 2, NULL, NULL); - memcpy(&RC.rrc[ctxt.module_id]->configuration,configuration,sizeof(RrcConfigurationReq)); - /// System Information INIT - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Checking release \n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - // can clear it at runtime RC.rrc[ctxt.module_id]->carrier[0].MBMS_flag = 0; - // This has to come from some top-level configuration // only CC_id 0 is logged #if (LTE_RRC_VERSION < MAKE_VERSION(10, 0, 0)) @@ -5853,7 +5388,6 @@ openair_rrc_eNB_init( #endif PROTOCOL_RRC_CTXT_ARGS(&ctxt), RC.rrc[ctxt.module_id]->carrier[0].MBMS_flag); - #else LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Rel8 RRC\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); #endif @@ -5877,7 +5411,6 @@ openair_rrc_eNB_init( RC.rrc[ctxt.module_id]->carrier[CC_id].cba_rnti[3], RC.rrc[ctxt.module_id]->carrier[CC_id].num_active_cba_groups); } - #endif for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { @@ -5887,32 +5420,33 @@ openair_rrc_eNB_init( , configuration #endif ); + for (int ue_id = 0; ue_id < MAX_MOBILES_PER_ENB; ue_id++) { - RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0; - RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t*) malloc16(256); + RC.rrc[ctxt.module_id]->carrier[CC_id].sizeof_paging[ue_id] = 0; + RC.rrc[ctxt.module_id]->carrier[CC_id].paging[ue_id] = (uint8_t *) malloc16(256); } } - rrc_init_global_param(); - for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + switch (RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag) { - case 1: - case 2: - case 3: - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 1 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); - RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 1; - break; + case 1: + case 2: + case 3: + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 1 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); + RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 1; + break; - case 4: - LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 2 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); - RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 2; - break; + case 4: + LOG_I(RRC, PROTOCOL_RRC_CTXT_FMT" Configuring 2 MBSFN sync area\n", PROTOCOL_RRC_CTXT_ARGS(&ctxt)); + RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 2; + break; - default: - RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 0; - break; + default: + RC.rrc[ctxt.module_id]->carrier[CC_id].num_mbsfn_sync_area = 0; + break; } // if we are here the RC.rrc[enb_mod_idP]->MBMS_flag > 0, @@ -5922,21 +5456,19 @@ openair_rrc_eNB_init( /// MTCH data bearer init init_MBMS(ctxt.module_id, CC_id, 0); } -#endif +#endif openair_rrc_top_init_eNB(RC.rrc[ctxt.module_id]->carrier[CC_id].MBMS_flag,0); } openair_rrc_on(&ctxt); - return 0; - } /*------------------------------------------------------------------------------*/ int rrc_eNB_decode_ccch( - protocol_ctxt_t* const ctxt_pP, - const SRB_INFO* const Srb_info, + protocol_ctxt_t *const ctxt_pP, + const SRB_INFO *const Srb_info, const int CC_id ) //----------------------------------------------------------------------------- @@ -5944,21 +5476,18 @@ rrc_eNB_decode_ccch( module_id_t Idx; asn_dec_rval_t dec_rval; LTE_UL_CCCH_Message_t *ul_ccch_msg = NULL; - LTE_RRCConnectionRequest_r8_IEs_t* rrcConnectionRequest = NULL; - LTE_RRCConnectionReestablishmentRequest_r8_IEs_t* rrcConnectionReestablishmentRequest = NULL; + LTE_RRCConnectionRequest_r8_IEs_t *rrcConnectionRequest = NULL; + LTE_RRCConnectionReestablishmentRequest_r8_IEs_t *rrcConnectionReestablishmentRequest = NULL; int i, rval; - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; uint64_t random_value = 0; int stmsi_received = 0; - T(T_ENB_RRC_UL_CCCH_DATA_IN, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - //memset(ul_ccch_msg,0,sizeof(UL_CCCH_Message_t)); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ((uint8_t*) Srb_info->Rx_buffer.Payload)[0], + ((uint8_t *) Srb_info->Rx_buffer.Payload)[0], ((uint8_t *) Srb_info->Rx_buffer.Payload)[1], ((uint8_t *) Srb_info->Rx_buffer.Payload)[2], ((uint8_t *) Srb_info->Rx_buffer.Payload)[3], @@ -5967,15 +5496,15 @@ rrc_eNB_decode_ccch( dec_rval = uper_decode( NULL, &asn_DEF_LTE_UL_CCCH_Message, - (void**)&ul_ccch_msg, - (uint8_t*) Srb_info->Rx_buffer.Payload, + (void **)&ul_ccch_msg, + (uint8_t *) Srb_info->Rx_buffer.Payload, 100, 0, 0); /* -#if defined(ENABLE_ITTI) -# if defined(DISABLE_ITTI_XER_PRINT) + #if defined(ENABLE_ITTI) + # if defined(DISABLE_ITTI_XER_PRINT) { MessageDef *message_p; @@ -5984,7 +5513,7 @@ rrc_eNB_decode_ccch( itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, message_p); } -# else + # else { char message_string[10000]; size_t message_string_size; @@ -6000,8 +5529,8 @@ rrc_eNB_decode_ccch( itti_send_msg_to_task(TASK_UNKNOWN, ctxt_pP->instance, msg_p); } } -# endif -#endif + # endif + #endif */ for (i = 0; i < 8; i++) { @@ -6016,467 +5545,454 @@ rrc_eNB_decode_ccch( } if (ul_ccch_msg->message.present == LTE_UL_CCCH_MessageType_PR_c1) { - switch (ul_ccch_msg->message.choice.c1.present) { + case LTE_UL_CCCH_MessageType__c1_PR_NOTHING: + LOG_I(RRC, + PROTOCOL_RRC_CTXT_FMT" Received PR_NOTHING on UL-CCCH-Message\n", + PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); + break; - case LTE_UL_CCCH_MessageType__c1_PR_NOTHING: - LOG_I(RRC, - PROTOCOL_RRC_CTXT_FMT" Received PR_NOTHING on UL-CCCH-Message\n", - PROTOCOL_RRC_CTXT_ARGS(ctxt_pP)); - break; + case LTE_UL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentRequest: + T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)(Srb_info->Rx_buffer.Payload), + Srb_info->Rx_buffer.payload_size, + "[MSG] RRC Connection Reestablishment Request\n"); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB--- MAC_DATA_IND (rrcConnectionReestablishmentRequest on SRB0) --> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrcConnectionReestablishmentRequest = + &ul_ccch_msg->message.choice.c1.choice.rrcConnectionReestablishmentRequest.criticalExtensions.choice.rrcConnectionReestablishmentRequest_r8; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest cause %s\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ((rrcConnectionReestablishmentRequest->reestablishmentCause == LTE_ReestablishmentCause_otherFailure) ? "Other Failure" : + (rrcConnectionReestablishmentRequest->reestablishmentCause == LTE_ReestablishmentCause_handoverFailure) ? "Handover Failure" : + "reconfigurationFailure")); + /*{ + uint64_t c_rnti = 0; + + memcpy(((uint8_t *) & c_rnti) + 3, rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.buf, + rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.size); + ue_mod_id = rrc_eNB_get_UE_index(enb_mod_idP, c_rnti); + } - case LTE_UL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentRequest: - T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + if ((RC.rrc[enb_mod_idP]->phyCellId == rrcConnectionReestablishmentRequest.UE_identity.physCellId) && + (ue_mod_id != UE_INDEX_INVALID)){ + rrc_eNB_generate_RRCConnectionReestablishment(enb_mod_idP, frameP, ue_mod_id); + }else { + rrc_eNB_generate_RRCConnectionReestablishmentReject(enb_mod_idP, frameP, ue_mod_id); + } + */ + /* reject all reestablishment attempts for the moment */ + // rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, + // rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti), + // CC_id); + { + uint16_t c_rnti = 0; - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)(Srb_info->Rx_buffer.Payload), - Srb_info->Rx_buffer.payload_size, - "[MSG] RRC Connection Reestablishment Request\n"); + if (rrcConnectionReestablishmentRequest->ue_Identity.physCellId != RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + rrcConnectionReestablishmentRequest->ue_Identity.physCellId, + RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + } - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB--- MAC_DATA_IND (rrcConnectionReestablishmentRequest on SRB0) --> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - rrcConnectionReestablishmentRequest = - &ul_ccch_msg->message.choice.c1.choice.rrcConnectionReestablishmentRequest.criticalExtensions.choice.rrcConnectionReestablishmentRequest_r8; - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest cause %s\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ((rrcConnectionReestablishmentRequest->reestablishmentCause == LTE_ReestablishmentCause_otherFailure) ? "Other Failure" : - (rrcConnectionReestablishmentRequest->reestablishmentCause == LTE_ReestablishmentCause_handoverFailure) ? "Handover Failure" : - "reconfigurationFailure")); - /*{ - uint64_t c_rnti = 0; - - memcpy(((uint8_t *) & c_rnti) + 3, rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.buf, - rrcConnectionReestablishmentRequest.UE_identity.c_RNTI.size); - ue_mod_id = rrc_eNB_get_UE_index(enb_mod_idP, c_rnti); - } + LOG_D(RRC, "physCellId is %ld\n", rrcConnectionReestablishmentRequest->ue_Identity.physCellId); - if ((RC.rrc[enb_mod_idP]->phyCellId == rrcConnectionReestablishmentRequest.UE_identity.physCellId) && - (ue_mod_id != UE_INDEX_INVALID)){ - rrc_eNB_generate_RRCConnectionReestablishment(enb_mod_idP, frameP, ue_mod_id); - }else { - rrc_eNB_generate_RRCConnectionReestablishmentReject(enb_mod_idP, frameP, ue_mod_id); - } - */ - /* reject all reestablishment attempts for the moment */ -// rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, -// rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti), -// CC_id); -{ - uint16_t c_rnti = 0; + for (i = 0; i < rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.size; i++) { + LOG_D(RRC, "rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[%d] = %x\n", + i, rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[i]); + } - if (rrcConnectionReestablishmentRequest->ue_Identity.physCellId != RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId) { - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest ue_Identity.physCellId(%ld) is not equal to current physCellId(%d), let's reject the UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - rrcConnectionReestablishmentRequest->ue_Identity.physCellId, - RC.rrc[ctxt_pP->module_id]->carrier[CC_id].physCellId); - rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); - break; - } - LOG_D(RRC, "physCellId is %ld\n", rrcConnectionReestablishmentRequest->ue_Identity.physCellId); + if (rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size == 0 || + rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size > 2) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest c_RNTI range error, let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + } - for (i = 0; i < rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.size; i++) { - LOG_D(RRC, "rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[%d] = %x\n", - i, rrcConnectionReestablishmentRequest->ue_Identity.shortMAC_I.buf[i]); - } + c_rnti = BIT_STRING_to_uint16(&rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI); + LOG_D(RRC, "c_rnti is %x\n", c_rnti); + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], c_rnti); - if (rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size == 0 || - rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI.size > 2) { - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest c_RNTI range error, let's reject the UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); - break; + if (ue_context_p == NULL) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest without UE context, let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + } - } + int UE_id = find_UE_id(ctxt_pP->module_id, c_rnti); - c_rnti = BIT_STRING_to_uint16(&rrcConnectionReestablishmentRequest->ue_Identity.c_RNTI); - LOG_D(RRC, "c_rnti is %x\n", c_rnti); + if(UE_id == -1) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest without UE_id(MAC) rnti %x, let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),c_rnti); + rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); + break; + } - ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], c_rnti); - if (ue_context_p == NULL) { - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest without UE context, let's reject the UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); - break; - } - int UE_id = find_UE_id(ctxt_pP->module_id, c_rnti); - if(UE_id == -1){ - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest without UE_id(MAC) rnti %x, let's reject the UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),c_rnti); - rrc_eNB_generate_RRCConnectionReestablishmentReject(ctxt_pP, ue_context_p, CC_id); - break; - } + if((RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer > 0) && + (RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres > 20)) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RCConnectionReestablishmentComplete(Previous) don't receive, delete the Previous UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1000; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + } - if((RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer > 0) && - (RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres > 20)){ - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RCConnectionReestablishmentComplete(Previous) don't receive, delete the Previous UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1000; - ue_context_p->ue_context.ue_reestablishment_timer = 0; - } + if(ue_context_p->ue_context.ue_reestablishment_timer > 0) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRRCConnectionReconfigurationComplete(Previous) don't receive, delete the Previous UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + ue_context_p->ue_context.Status = RRC_RECONFIGURED; + protocol_ctxt_t ctxt_old_p; + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt_old_p, + ctxt_pP->instance, + ENB_FLAG_YES, + c_rnti, + ctxt_pP->frame, + ctxt_pP->subframe); + rrc_eNB_process_RRCConnectionReconfigurationComplete(&ctxt_old_p, + ue_context_p, + ue_context_p->ue_context.reestablishment_xid); - if(ue_context_p->ue_context.ue_reestablishment_timer > 0){ - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RRRCConnectionReconfigurationComplete(Previous) don't receive, delete the Previous UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - ue_context_p->ue_context.Status = RRC_RECONFIGURED; - protocol_ctxt_t ctxt_old_p; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt_old_p, - ctxt_pP->instance, - ENB_FLAG_YES, - c_rnti, - ctxt_pP->frame, - ctxt_pP->subframe); - rrc_eNB_process_RRCConnectionReconfigurationComplete(&ctxt_old_p, - ue_context_p, - ue_context_p->ue_context.reestablishment_xid); - for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; - } else { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + } else { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + } } } - } - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p); - /* reset timers */ - ue_context_p->ue_context.ul_failure_timer = 0; - ue_context_p->ue_context.ue_release_timer = 0; - ue_context_p->ue_context.ue_reestablishment_timer = 0; - ue_context_p->ue_context.ue_release_timer_s1 = 0; - ue_context_p->ue_context.ue_release_timer_rrc = 0; - ue_context_p->ue_context.reestablishment_xid = -1; - - // insert C-RNTI to map - for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if (reestablish_rnti_map[i][0] == 0) { - reestablish_rnti_map[i][0] = ctxt_pP->rnti; - reestablish_rnti_map[i][1] = c_rnti; - break; - } - } - LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n", - i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p); + /* reset timers */ + ue_context_p->ue_context.ul_failure_timer = 0; + ue_context_p->ue_context.ue_release_timer = 0; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + ue_context_p->ue_context.ue_release_timer_s1 = 0; + ue_context_p->ue_context.ue_release_timer_rrc = 0; + ue_context_p->ue_context.reestablishment_xid = -1; + + // insert C-RNTI to map + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + if (reestablish_rnti_map[i][0] == 0) { + reestablish_rnti_map[i][0] = ctxt_pP->rnti; + reestablish_rnti_map[i][1] = c_rnti; + break; + } + } + + LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n", + i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]); #if defined(ENABLE_ITTI) - ue_context_p->ue_context.reestablishment_cause = rrcConnectionReestablishmentRequest->reestablishmentCause; - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection reestablishment request from UE physCellId %ld cause %ld\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - rrcConnectionReestablishmentRequest->ue_Identity.physCellId, - ue_context_p->ue_context.reestablishment_cause); + ue_context_p->ue_context.reestablishment_cause = rrcConnectionReestablishmentRequest->reestablishmentCause; + LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection reestablishment request from UE physCellId %ld cause %ld\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + rrcConnectionReestablishmentRequest->ue_Identity.physCellId, + ue_context_p->ue_context.reestablishment_cause); #else - LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection restablishment request for UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept connection restablishment request for UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); #endif - #ifndef NO_RRM - send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id)); + send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id)); #else - - ue_context_p->ue_context.primaryCC_id = CC_id; - - //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; - Idx = DCCH; - // SRB1 - ue_context_p->ue_context.Srb1.Active = 1; - ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx; - memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - - // SRB2: set it to go through SRB1 with id 1 (DCCH) - ue_context_p->ue_context.Srb2.Active = 1; - ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx; - memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - - rrc_eNB_generate_RRCConnectionReestablishment(ctxt_pP, ue_context_p, CC_id); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - Idx); - - MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, - MSC_PDCP_ENB, - NULL, - 0, - MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti); - - rrc_pdcp_config_asn1_req(ctxt_pP, - ue_context_p->ue_context.SRB_configList, - (LTE_DRB_ToAddModList_t *) NULL, - (LTE_DRB_ToReleaseList_t*) NULL, - 0xff, - NULL, - NULL, - NULL + ue_context_p->ue_context.primaryCC_id = CC_id; + //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; + Idx = DCCH; + // SRB1 + ue_context_p->ue_context.Srb1.Active = 1; + ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + // SRB2: set it to go through SRB1 with id 1 (DCCH) + ue_context_p->ue_context.Srb2.Active = 1; + ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + rrc_eNB_generate_RRCConnectionReestablishment(ctxt_pP, ue_context_p, CC_id); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + Idx); + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_PDCP_ENB, + NULL, + 0, + MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti); + rrc_pdcp_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, + (LTE_DRB_ToAddModList_t *) NULL, + (LTE_DRB_ToReleaseList_t *) NULL, + 0xff, + NULL, + NULL, + NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , (LTE_PMCH_InfoList_r9_t *) NULL + , (LTE_PMCH_InfoList_r9_t *) NULL #endif - ,NULL); - - rrc_rlc_config_asn1_req(ctxt_pP, - ue_context_p->ue_context.SRB_configList, - (LTE_DRB_ToAddModList_t*) NULL, - (LTE_DRB_ToReleaseList_t*) NULL + ,NULL); + rrc_rlc_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, + (LTE_DRB_ToAddModList_t *) NULL, + (LTE_DRB_ToReleaseList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , (LTE_PMCH_InfoList_r9_t *) NULL, - 0,0 + , (LTE_PMCH_InfoList_r9_t *) NULL, + 0,0 # endif - ); + ); #endif //NO_RRM - } - break; - - case LTE_UL_CCCH_MessageType__c1_PR_rrcConnectionRequest: - T(T_ENB_RRC_CONNECTION_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + } + break; - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)(Srb_info->Rx_buffer.Payload), - Srb_info->Rx_buffer.payload_size, - "[MSG] RRC Connection Request\n"); + case LTE_UL_CCCH_MessageType__c1_PR_rrcConnectionRequest: + T(T_ENB_RRC_CONNECTION_REQUEST, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)(Srb_info->Rx_buffer.Payload), + Srb_info->Rx_buffer.payload_size, + "[MSG] RRC Connection Request\n"); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB --- MAC_DATA_IND (rrcConnectionRequest on SRB0) --> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + ue_context_p = rrc_eNB_get_ue_context( + RC.rrc[ctxt_pP->module_id], + ctxt_pP->rnti); - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT"MAC_eNB --- MAC_DATA_IND (rrcConnectionRequest on SRB0) --> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[ctxt_pP->module_id], - ctxt_pP->rnti); + if (ue_context_p != NULL) { + // erase content + rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_p); + MSC_LOG_RX_DISCARDED_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Srb_info->Rx_buffer.Payload, + dec_rval.consumed, + MSC_AS_TIME_FMT" LTE_RRCConnectionRequest UE %x size %u (UE already in context)", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + dec_rval.consumed); + } else { + rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8; + { + if (LTE_InitialUE_Identity_PR_randomValue == rrcConnectionRequest->ue_Identity.present) { + if(rrcConnectionRequest->ue_Identity.choice.randomValue.size != 5) { + LOG_I(RRC, "wrong InitialUE-Identity randomValue size, expected 5, provided %lu", + (long unsigned int)rrcConnectionRequest->ue_Identity.choice.randomValue.size); + return -1; + } - if (ue_context_p != NULL) { - // erase content - rrc_eNB_free_mem_UE_context(ctxt_pP, ue_context_p); + memcpy(((uint8_t *) & random_value) + 3, + rrcConnectionRequest->ue_Identity.choice.randomValue.buf, + rrcConnectionRequest->ue_Identity.choice.randomValue.size); + + /* if there is already a registered UE (with another RNTI) with this random_value, + * the current one must be removed from MAC/PHY (zombie UE) + */ + if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { + LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", + ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti); + ue_context_p->ue_context.ul_failure_timer = 20000; + } - MSC_LOG_RX_DISCARDED_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Srb_info->Rx_buffer.Payload, - dec_rval.consumed, - MSC_AS_TIME_FMT" LTE_RRCConnectionRequest UE %x size %u (UE already in context)", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - dec_rval.consumed); - } else { - rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8; - { - if (LTE_InitialUE_Identity_PR_randomValue == rrcConnectionRequest->ue_Identity.present) { - if(rrcConnectionRequest->ue_Identity.choice.randomValue.size != 5) - { - LOG_I(RRC, "wrong InitialUE-Identity randomValue size, expected 5, provided %lu", - (long unsigned int)rrcConnectionRequest->ue_Identity.choice.randomValue.size); - return -1; - } - memcpy(((uint8_t*) & random_value) + 3, - rrcConnectionRequest->ue_Identity.choice.randomValue.buf, - rrcConnectionRequest->ue_Identity.choice.randomValue.size); - /* if there is already a registered UE (with another RNTI) with this random_value, - * the current one must be removed from MAC/PHY (zombie UE) - */ - if ((ue_context_p = rrc_eNB_ue_context_random_exist(ctxt_pP, random_value))) { - LOG_W(RRC, "new UE rnti %x (coming with random value) is already there as UE %x, removing %x from MAC/PHY\n", - ctxt_pP->rnti, ue_context_p->ue_context.rnti, ue_context_p->ue_context.rnti); - ue_context_p->ue_context.ul_failure_timer = 20000; - } - ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); - } else if (LTE_InitialUE_Identity_PR_s_TMSI == rrcConnectionRequest->ue_Identity.present) { - /* Save s-TMSI */ - LTE_S_TMSI_t s_TMSI = rrcConnectionRequest->ue_Identity.choice.s_TMSI; - mme_code_t mme_code = BIT_STRING_to_uint8(&s_TMSI.mmec); - m_tmsi_t m_tmsi = BIT_STRING_to_uint32(&s_TMSI.m_TMSI); - random_value = (((uint64_t)mme_code) << 32) | m_tmsi; - if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist(ctxt_pP, mme_code, m_tmsi))) { - LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti); - rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti); - stmsi_received=1; - /* replace rnti in the context */ - /* for that, remove the context from the RB tree */ - RB_REMOVE(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p); - /* and insert again, after changing rnti everywhere it has to be changed */ - ue_context_p->ue_id_rnti = ctxt_pP->rnti; - ue_context_p->ue_context.rnti = ctxt_pP->rnti; - RB_INSERT(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p); - /* reset timers */ - ue_context_p->ue_context.ul_failure_timer = 0; - ue_context_p->ue_context.ue_release_timer = 0; - ue_context_p->ue_context.ue_reestablishment_timer = 0; - ue_context_p->ue_context.ue_release_timer_s1 = 0; - ue_context_p->ue_context.ue_release_timer_rrc = 0; - ue_context_p->ue_context.reestablishment_xid = -1; - } else { - LOG_I(RRC," S-TMSI doesn't exist, setting Initialue_identity_s_TMSI.m_tmsi to %p => %x\n",ue_context_p,m_tmsi); -// ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY); - ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP,random_value); - if (ue_context_p == NULL) - LOG_E(RRC, "%s:%d:%s: rrc_eNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__); - if (ue_context_p != NULL) { - ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = TRUE; - ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code; - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi; + ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, random_value); + } else if (LTE_InitialUE_Identity_PR_s_TMSI == rrcConnectionRequest->ue_Identity.present) { + /* Save s-TMSI */ + LTE_S_TMSI_t s_TMSI = rrcConnectionRequest->ue_Identity.choice.s_TMSI; + mme_code_t mme_code = BIT_STRING_to_uint8(&s_TMSI.mmec); + m_tmsi_t m_tmsi = BIT_STRING_to_uint32(&s_TMSI.m_TMSI); + random_value = (((uint64_t)mme_code) << 32) | m_tmsi; + + if ((ue_context_p = rrc_eNB_ue_context_stmsi_exist(ctxt_pP, mme_code, m_tmsi))) { + LOG_I(RRC," S-TMSI exists, ue_context_p %p, old rnti %x => %x\n",ue_context_p,ue_context_p->ue_context.rnti,ctxt_pP->rnti); + rrc_mac_remove_ue(ctxt_pP->module_id, ue_context_p->ue_context.rnti); + stmsi_received=1; + /* replace rnti in the context */ + /* for that, remove the context from the RB tree */ + RB_REMOVE(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p); + /* and insert again, after changing rnti everywhere it has to be changed */ + ue_context_p->ue_id_rnti = ctxt_pP->rnti; + ue_context_p->ue_context.rnti = ctxt_pP->rnti; + RB_INSERT(rrc_ue_tree_s, &RC.rrc[ctxt_pP->module_id]->rrc_ue_head, ue_context_p); + /* reset timers */ + ue_context_p->ue_context.ul_failure_timer = 0; + ue_context_p->ue_context.ue_release_timer = 0; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + ue_context_p->ue_context.ue_release_timer_s1 = 0; + ue_context_p->ue_context.ue_release_timer_rrc = 0; + ue_context_p->ue_context.reestablishment_xid = -1; } else { - /* TODO: do we have to break here? */ - //break; + LOG_I(RRC," S-TMSI doesn't exist, setting Initialue_identity_s_TMSI.m_tmsi to %p => %x\n",ue_context_p,m_tmsi); + // ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY); + ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP,random_value); + + if (ue_context_p == NULL) + LOG_E(RRC, "%s:%d:%s: rrc_eNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__); + + if (ue_context_p != NULL) { + ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = TRUE; + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code; + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi; + } else { + /* TODO: do we have to break here? */ + //break; + } } - } - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Srb_info->Rx_buffer.Payload, - dec_rval.consumed, - MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (s-TMSI mmec %u m_TMSI %u random UE id (0x%" PRIx64 ")", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - dec_rval.consumed, - ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code, - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.random_ue_identity); - } else { - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionRequest without random UE identity or S-TMSI not supported, let's reject the UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - rrc_eNB_generate_RRCConnectionReject(ctxt_pP, - rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti), - CC_id); - break; + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Srb_info->Rx_buffer.Payload, + dec_rval.consumed, + MSC_AS_TIME_FMT" RRCConnectionRequest UE %x size %u (s-TMSI mmec %u m_TMSI %u random UE id (0x%" PRIx64 ")", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + dec_rval.consumed, + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code, + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.random_ue_identity); + } else { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionRequest without random UE identity or S-TMSI not supported, let's reject the UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rrc_eNB_generate_RRCConnectionReject(ctxt_pP, + rrc_eNB_get_ue_context(RC.rrc[ctxt_pP->module_id], ctxt_pP->rnti), + CC_id); + break; + } } + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p); - } - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" UE context: %p\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p); + if (ue_context_p != NULL) { +#if defined(ENABLE_ITTI) + ue_context_p->ue_context.establishment_cause = rrcConnectionRequest->establishmentCause; + ue_context_p->ue_context.reestablishment_cause = LTE_ReestablishmentCause_spare1; - if (ue_context_p != NULL) { + if (stmsi_received==0) + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE random UE identity (0x%" PRIx64 ") MME code %u TMSI %u cause %ld\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p->ue_context.random_ue_identity, + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code, + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.establishment_cause); + else + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE MME code %u TMSI %u cause %ld\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code, + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.establishment_cause); -#if defined(ENABLE_ITTI) - ue_context_p->ue_context.establishment_cause = rrcConnectionRequest->establishmentCause; - ue_context_p->ue_context.reestablishment_cause = LTE_ReestablishmentCause_spare1; - if (stmsi_received==0) - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE random UE identity (0x%" PRIx64 ") MME code %u TMSI %u cause %ld\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p->ue_context.random_ue_identity, - ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code, - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.establishment_cause); - else - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection from UE MME code %u TMSI %u cause %ld\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code, - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.establishment_cause); #else - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection for UE random UE identity (0x%" PRIx64 ")\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p->ue_context.random_ue_identity); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Accept new connection for UE random UE identity (0x%" PRIx64 ")\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + ue_context_p->ue_context.random_ue_identity); #endif - if (stmsi_received == 0) - RC.rrc[ctxt_pP->module_id]->Nb_ue++; - } else { - // no context available - if (rrc_agent_registered[ctxt_pP->module_id]) { - agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, - ctxt_pP->rnti, - PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); - } - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - random_value); - rrc_mac_remove_ue(ctxt_pP->module_id,ctxt_pP->rnti); - return -1; + if (stmsi_received == 0) + RC.rrc[ctxt_pP->module_id]->Nb_ue++; + } else { + // no context available + if (rrc_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + ctxt_pP->rnti, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_DEACTIVATED); + } + + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Can't create new context for UE random UE identity (0x%" PRIx64 ")\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + random_value); + rrc_mac_remove_ue(ctxt_pP->module_id,ctxt_pP->rnti); + return -1; + } } - } #ifndef NO_RRM - send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id)); + send_msg(&S_rrc, msg_rrc_MR_attach_ind(ctxt_pP->module_id, Mac_id)); #else - - ue_context_p->ue_context.primaryCC_id = CC_id; - - //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; - Idx = DCCH; - // SRB1 - ue_context_p->ue_context.Srb1.Active = 1; - ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx; - memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - - // SRB2: set it to go through SRB1 with id 1 (DCCH) - ue_context_p->ue_context.Srb2.Active = 1; - ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx; - memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1], - &DCCH_LCHAN_DESC, - LCHAN_DESC_SIZE); - - rrc_eNB_generate_RRCConnectionSetup(ctxt_pP, ue_context_p, CC_id); - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - Idx); - - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_PDCP_ENB, - NULL, - 0, - MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti); - - rrc_pdcp_config_asn1_req(ctxt_pP, - ue_context_p->ue_context.SRB_configList, - (LTE_DRB_ToAddModList_t *) NULL, - (LTE_DRB_ToReleaseList_t*) NULL, - 0xff, - NULL, - NULL, - NULL + ue_context_p->ue_context.primaryCC_id = CC_id; + //LG COMMENT Idx = (ue_mod_idP * NB_RB_MAX) + DCCH; + Idx = DCCH; + // SRB1 + ue_context_p->ue_context.Srb1.Active = 1; + ue_context_p->ue_context.Srb1.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + memcpy(&ue_context_p->ue_context.Srb1.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + // SRB2: set it to go through SRB1 with id 1 (DCCH) + ue_context_p->ue_context.Srb2.Active = 1; + ue_context_p->ue_context.Srb2.Srb_info.Srb_id = Idx; + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[0], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + memcpy(&ue_context_p->ue_context.Srb2.Srb_info.Lchan_desc[1], + &DCCH_LCHAN_DESC, + LCHAN_DESC_SIZE); + rrc_eNB_generate_RRCConnectionSetup(ctxt_pP, ue_context_p, CC_id); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT"CALLING RLC CONFIG SRB1 (rbid %d)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + Idx); + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_PDCP_ENB, + NULL, + 0, + MSC_AS_TIME_FMT" CONFIG_REQ UE %x SRB", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti); + rrc_pdcp_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, + (LTE_DRB_ToAddModList_t *) NULL, + (LTE_DRB_ToReleaseList_t *) NULL, + 0xff, + NULL, + NULL, + NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , (LTE_PMCH_InfoList_r9_t *) NULL + , (LTE_PMCH_InfoList_r9_t *) NULL #endif - ,NULL); - - rrc_rlc_config_asn1_req(ctxt_pP, - ue_context_p->ue_context.SRB_configList, - (LTE_DRB_ToAddModList_t*) NULL, - (LTE_DRB_ToReleaseList_t*) NULL + ,NULL); + rrc_rlc_config_asn1_req(ctxt_pP, + ue_context_p->ue_context.SRB_configList, + (LTE_DRB_ToAddModList_t *) NULL, + (LTE_DRB_ToReleaseList_t *) NULL #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - , (LTE_PMCH_InfoList_r9_t *) NULL - , 0, 0 + , (LTE_PMCH_InfoList_r9_t *) NULL + , 0, 0 #endif - ); + ); #endif //NO_RRM + break; - break; - - default: - LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - rval = -1; - break; + default: + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + rval = -1; + break; } rval = 0; @@ -6492,28 +6008,25 @@ rrc_eNB_decode_ccch( //----------------------------------------------------------------------------- int rrc_eNB_decode_dcch( - const protocol_ctxt_t* const ctxt_pP, + const protocol_ctxt_t *const ctxt_pP, const rb_id_t Srb_id, - const uint8_t* const Rx_sdu, + const uint8_t *const Rx_sdu, const sdu_size_t sdu_sizeP ) //----------------------------------------------------------------------------- { - asn_dec_rval_t dec_rval; //UL_DCCH_Message_t uldcchmsg; LTE_UL_DCCH_Message_t *ul_dcch_msg = NULL; //&uldcchmsg; int i; - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; #if defined(ENABLE_ITTI) # if defined(ENABLE_USE_MME) - MessageDef * msg_delete_tunnels_p = NULL; + MessageDef *msg_delete_tunnels_p = NULL; uint8_t xid; #endif #endif - - int dedicated_DRB=0; - + int dedicated_DRB=0; T(T_ENB_RRC_UL_DCCH_DATA_IN, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); @@ -6526,19 +6039,18 @@ rrc_eNB_decode_dcch( PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), Srb_id); } - //memset(ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); + //memset(ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); LOG_D(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Decoding UL-DCCH Message\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); dec_rval = uper_decode( NULL, &asn_DEF_LTE_UL_DCCH_Message, - (void**)&ul_dcch_msg, + (void **)&ul_dcch_msg, Rx_sdu, sdu_sizeP, 0, 0); - { for (i = 0; i < sdu_sizeP; i++) { LOG_T(RRC, "%x.", Rx_sdu[i]); @@ -6559,162 +6071,170 @@ rrc_eNB_decode_dcch( ctxt_pP->rnti); if (ul_dcch_msg->message.present == LTE_UL_DCCH_MessageType_PR_c1) { - switch (ul_dcch_msg->message.choice.c1.present) { - case LTE_UL_DCCH_MessageType__c1_PR_NOTHING: /* No components present */ - break; - - case LTE_UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000: - break; - - case LTE_UL_DCCH_MessageType__c1_PR_measurementReport: - // to avoid segmentation fault - if(!ue_context_p){ - LOG_I(RRC, "Processing measurementReport UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); + case LTE_UL_DCCH_MessageType__c1_PR_NOTHING: /* No components present */ break; - } - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND " - "%d bytes (measurementReport) ---> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - rrc_eNB_process_MeasurementReport( - ctxt_pP, - ue_context_p, - &ul_dcch_msg->message.choice.c1.choice.measurementReport. - criticalExtensions.choice.c1.choice.measurementReport_r8.measResults); - break; - case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete: - // to avoid segmentation fault - if(!ue_context_p){ - LOG_I(RRC, "Processing LTE_RRCConnectionReconfigurationComplete UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); + case LTE_UL_DCCH_MessageType__c1_PR_csfbParametersRequestCDMA2000: break; - } - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)(Rx_sdu),sdu_sizeP, - "[MSG] RRC Connection Reconfiguration Complete\n"); - - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" LTE_RRCConnectionReconfigurationComplete UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); - - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " - "(RRCConnectionReconfigurationComplete) ---> RRC_eNB]\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - - if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions. - present == - LTE_RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8) { - /*NN: revise the condition */ - /*FK: left the condition as is for the case MME is used (S1 mode) but setting dedicated_DRB = 1 otherwise (noS1 mode) so that no second RRCReconfiguration message activationg more DRB is sent as this causes problems with the nasmesh driver.*/ - if (EPC_MODE_ENABLED) { - if (ue_context_p->ue_context.Status == RRC_RECONFIGURED){ - dedicated_DRB = 1; - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - //clear - int16_t UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); - if(UE_id == -1){ - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReconfigurationComplete without rnti %x, fault\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); - break; - } - if(RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag == 1){ - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld) C-RNTI Complete\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - dedicated_DRB = 2; - RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; - } - } else { - dedicated_DRB = 0; - ue_context_p->ue_context.Status = RRC_RECONFIGURED; - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (default DRB, xid %ld)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - } - ue_context_p->ue_context.reestablishment_xid = -1; - } else { - dedicated_DRB = 1; - ue_context_p->ue_context.Status = RRC_RECONFIGURED; - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - } - - rrc_eNB_process_RRCConnectionReconfigurationComplete( + + case LTE_UL_DCCH_MessageType__c1_PR_measurementReport: + + // to avoid segmentation fault + if(!ue_context_p) { + LOG_I(RRC, "Processing measurementReport UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); + break; + } + + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND " + "%d bytes (measurementReport) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); + rrc_eNB_process_MeasurementReport( ctxt_pP, ue_context_p, - ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - - //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future - if (rrc_agent_registered[ctxt_pP->module_id]) { - agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, - ue_context_p->ue_id_rnti, - PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED); - } - } + &ul_dcch_msg->message.choice.c1.choice.measurementReport. + criticalExtensions.choice.c1.choice.measurementReport_r8.measResults); + break; + + case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReconfigurationComplete: + + // to avoid segmentation fault + if(!ue_context_p) { + LOG_I(RRC, "Processing LTE_RRCConnectionReconfigurationComplete UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); + break; + } + + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)(Rx_sdu),sdu_sizeP, + "[MSG] RRC Connection Reconfiguration Complete\n"); + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" LTE_RRCConnectionReconfigurationComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(RRCConnectionReconfigurationComplete) ---> RRC_eNB]\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); + + if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions. + present == + LTE_RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8) { + /*NN: revise the condition */ + /*FK: left the condition as is for the case MME is used (S1 mode) but setting dedicated_DRB = 1 otherwise (noS1 mode) so that no second RRCReconfiguration message activationg more DRB is sent as this causes problems with the nasmesh driver.*/ + if (EPC_MODE_ENABLED) { + if (ue_context_p->ue_context.Status == RRC_RECONFIGURED) { + dedicated_DRB = 1; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + //clear + int16_t UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); + + if(UE_id == -1) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RRCConnectionReconfigurationComplete without rnti %x, fault\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); + break; + } + + if(RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag == 1) { + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld) C-RNTI Complete\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + dedicated_DRB = 2; + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; + } + } else { + dedicated_DRB = 0; + ue_context_p->ue_context.Status = RRC_RECONFIGURED; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (default DRB, xid %ld)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + } + + ue_context_p->ue_context.reestablishment_xid = -1; + } else { + dedicated_DRB = 1; + ue_context_p->ue_context.Status = RRC_RECONFIGURED; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + } + + rrc_eNB_process_RRCConnectionReconfigurationComplete( + ctxt_pP, + ue_context_p, + ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + + //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future + if (rrc_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + ue_context_p->ue_id_rnti, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_UPDATED); + } + } + #if defined(ENABLE_ITTI) #if defined(ENABLE_USE_MME) - if (dedicated_DRB == 1){ -// rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, -// ue_context_p, -// ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); -if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { - rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(ctxt_pP, - ue_context_p, - ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + if (dedicated_DRB == 1) { + // rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, + // ue_context_p, + // ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { + rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(ctxt_pP, + ue_context_p, + ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); ue_context_p->ue_context.nb_of_modify_e_rabs = 0; ue_context_p->ue_context.nb_of_failed_e_rabs = 0; memset(ue_context_p->ue_context.modify_e_rab, 0, sizeof(ue_context_p->ue_context.modify_e_rab)); + for(int i = 0; i < NB_RB_MAX; i++) { ue_context_p->ue_context.modify_e_rab[i].xid = -1; } - - } else if(ue_context_p->ue_context.e_rab_release_command_flag == 1){ + } else if(ue_context_p->ue_context.e_rab_release_command_flag == 1) { xid = ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier; ue_context_p->ue_context.e_rab_release_command_flag = 0; //gtp tunnel delete msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - for(i = 0; i < NB_RB_MAX; i++){ - if(xid == ue_context_p->ue_context.e_rab[i].xid){ - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; - ue_context_p->ue_context.enb_gtp_teid[i] = 0; - memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); - ue_context_p->ue_context.enb_gtp_ebi[i] = 0; - } + + for(i = 0; i < NB_RB_MAX; i++) { + if(xid == ue_context_p->ue_context.e_rab[i].xid) { + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; + ue_context_p->ue_context.enb_gtp_teid[i] = 0; + memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); + ue_context_p->ue_context.enb_gtp_ebi[i] = 0; + } } + itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->instance, msg_delete_tunnels_p); //S1AP_E_RAB_RELEASE_RESPONSE rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(ctxt_pP, - ue_context_p, - xid); + ue_context_p, + xid); } else { - rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, - ue_context_p, - ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); + rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(ctxt_pP, + ue_context_p, + ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); } - }else if(dedicated_DRB == 0){ - if(ue_context_p->ue_context.reestablishment_cause == LTE_ReestablishmentCause_spare1){ - rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, - ue_context_p); + } else if(dedicated_DRB == 0) { + if(ue_context_p->ue_context.reestablishment_cause == LTE_ReestablishmentCause_spare1) { + rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(ctxt_pP, + ue_context_p); } else { ue_context_p->ue_context.reestablishment_cause = LTE_ReestablishmentCause_spare1; + for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; @@ -6723,443 +6243,443 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { } } } - }else if(dedicated_DRB == 2){ - for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; - } else { - ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; - } - } - } -#endif + } else if(dedicated_DRB == 2) { + for (uint8_t e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + if (ue_context_p->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + } else { + ue_context_p->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + } + } + } + +#endif #else // establish a dedicated bearer - if (dedicated_DRB == 0 ) { - // ue_context_p->ue_context.e_rab[0].status = E_RAB_STATUS_ESTABLISHED; - rrc_eNB_reconfigure_DRBs(ctxt_pP,ue_context_p); - } -#endif - break; - case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete: - T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + if (dedicated_DRB == 0 ) { + // ue_context_p->ue_context.e_rab[0].status = E_RAB_STATUS_ESTABLISHED; + rrc_eNB_reconfigure_DRBs(ctxt_pP,ue_context_p); + } + +#endif + break; - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, - "[MSG] RRC Connection Reestablishment Complete\n"); + case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionReestablishmentComplete: + T(T_ENB_RRC_CONNECTION_REESTABLISHMENT_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, + "[MSG] RRC Connection Reestablishment Complete\n"); + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" LTE_RRCConnectionReestablishmentComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(rrcConnectionReestablishmentComplete) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); + { + rnti_t reestablish_rnti = 0; + + // select C-RNTI from map + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + if (reestablish_rnti_map[i][0] == ctxt_pP->rnti) { + reestablish_rnti = reestablish_rnti_map[i][1]; + ue_context_p = rrc_eNB_get_ue_context( + RC.rrc[ctxt_pP->module_id], + reestablish_rnti); + // clear currentC-RNTI from map + reestablish_rnti_map[i][0] = 0; + reestablish_rnti_map[i][1] = 0; + break; + } + } - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" LTE_RRCConnectionReestablishmentComplete UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); + LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n", + i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]); - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " - "(rrcConnectionReestablishmentComplete) ---> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - { - rnti_t reestablish_rnti = 0; - // select C-RNTI from map - for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if (reestablish_rnti_map[i][0] == ctxt_pP->rnti) { - reestablish_rnti = reestablish_rnti_map[i][1]; - ue_context_p = rrc_eNB_get_ue_context( - RC.rrc[ctxt_pP->module_id], - reestablish_rnti); - // clear currentC-RNTI from map - reestablish_rnti_map[i][0] = 0; - reestablish_rnti_map[i][1] = 0; + if (!ue_context_p) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentComplete without UE context, falt\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); break; } - } - LOG_D(RRC, "reestablish_rnti_map[%d] [0] %x, [1] %x\n", - i, reestablish_rnti_map[i][0], reestablish_rnti_map[i][1]); - if (!ue_context_p) { - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentComplete without UE context, falt\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - break; + //clear + int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); + + if(UE_id == -1) { + LOG_E(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentComplete without UE_id(MAC) rnti %x, fault\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); + break; + } + + RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + + if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.present == + LTE_RRCConnectionReestablishmentComplete__criticalExtensions_PR_rrcConnectionReestablishmentComplete_r8) { + rrc_eNB_process_RRCConnectionReestablishmentComplete(ctxt_pP, reestablish_rnti, ue_context_p, + ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier, + &ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8); + + //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future + if (mac_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + ue_context_p->ue_id_rnti, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); + } + } + + //ue_context_p->ue_context.ue_release_timer = 0; + ue_context_p->ue_context.ue_reestablishment_timer = 1; + // remove UE after 100 frames after LTE_RRCConnectionReestablishmentRelease is triggered + ue_context_p->ue_context.ue_reestablishment_timer_thres = 1000; } - //clear - int UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); - if(UE_id == -1){ - LOG_E(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentComplete without UE_id(MAC) rnti %x, fault\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ctxt_pP->rnti); + break; + + case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete: + + // to avoid segmentation fault + if(!ue_context_p) { + LOG_I(RRC, "Processing LTE_RRCConnectionSetupComplete UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); break; } - RC.mac[ctxt_pP->module_id]->UE_list.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0; - ue_context_p->ue_context.ue_reestablishment_timer = 0; - if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.present == - LTE_RRCConnectionReestablishmentComplete__criticalExtensions_PR_rrcConnectionReestablishmentComplete_r8) { - rrc_eNB_process_RRCConnectionReestablishmentComplete(ctxt_pP, reestablish_rnti, ue_context_p, - ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier, - &ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8); + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, + "[MSG] RRC Connection SetupComplete\n"); + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" LTE_RRCConnectionSetupComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(RRCConnectionSetupComplete) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); - //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future - if (mac_agent_registered[ctxt_pP->module_id]) { - agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, - ue_context_p->ue_id_rnti, - PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); + if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.present == + LTE_RRCConnectionSetupComplete__criticalExtensions_PR_c1) { + if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1. + present == + LTE_RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8) { + rrc_eNB_process_RRCConnectionSetupComplete( + ctxt_pP, + ue_context_p, + &ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8); + LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + + //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future + if (rrc_agent_registered[ctxt_pP->module_id]) { + agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, + ue_context_p->ue_id_rnti, + PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); + } } } - //ue_context_p->ue_context.ue_release_timer = 0; - ue_context_p->ue_context.ue_reestablishment_timer = 1; - // remove UE after 100 frames after LTE_RRCConnectionReestablishmentRelease is triggered - ue_context_p->ue_context.ue_reestablishment_timer_thres = 1000; - } - break; - case LTE_UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete: - // to avoid segmentation fault - if(!ue_context_p){ - LOG_I(RRC, "Processing LTE_RRCConnectionSetupComplete UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); + ue_context_p->ue_context.ue_release_timer=0; break; - } - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, - "[MSG] RRC Connection SetupComplete\n"); - - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" LTE_RRCConnectionSetupComplete UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); - - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " - "(RRCConnectionSetupComplete) ---> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - - if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.present == - LTE_RRCConnectionSetupComplete__criticalExtensions_PR_c1) { - if (ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1. - present == - LTE_RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8) { - rrc_eNB_process_RRCConnectionSetupComplete( - ctxt_pP, - ue_context_p, - &ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8); - ue_context_p->ue_context.Status = RRC_CONNECTED; - LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - - //WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future - if (rrc_agent_registered[ctxt_pP->module_id]) { - agent_rrc_xface[ctxt_pP->module_id]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id, - ue_context_p->ue_id_rnti, - PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED); - } + + case LTE_UL_DCCH_MessageType__c1_PR_securityModeComplete: + T(T_ENB_RRC_SECURITY_MODE_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + + // to avoid segmentation fault + if(!ue_context_p) { + LOG_I(RRC, "Processing securityModeComplete UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); + break; } - } - ue_context_p->ue_context.ue_release_timer=0; - break; + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, + "[MSG] RRC Security Mode Complete\n"); + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" securityModeComplete UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" received securityModeComplete on UL-DCCH %d from UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(securityModeComplete) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); - case LTE_UL_DCCH_MessageType__c1_PR_securityModeComplete: - T(T_ENB_RRC_SECURITY_MODE_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - // to avoid segmentation fault - if(!ue_context_p){ - LOG_I(RRC, "Processing securityModeComplete UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); - break; - } - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, - "[MSG] RRC Security Mode Complete\n"); + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)ul_dcch_msg); + } + // confirm with PDCP about the security mode for DCCH + //rrc_pdcp_config_req (enb_mod_idP, frameP, 1,CONFIG_ACTION_SET_SECURITY_MODE, (ue_mod_idP * NB_RB_MAX) + DCCH, 0x77); + // continue the procedure + rrc_eNB_generate_UECapabilityEnquiry( + ctxt_pP, + ue_context_p); + break; - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" securityModeComplete UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); + case LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure: + T(T_ENB_RRC_SECURITY_MODE_FAILURE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, + "[MSG] RRC Security Mode Failure\n"); + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" securityModeFailure UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); + LOG_W(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(securityModeFailure) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" received securityModeComplete on UL-DCCH %d from UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH); - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " - "(securityModeComplete) ---> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)ul_dcch_msg); - } - // confirm with PDCP about the security mode for DCCH - //rrc_pdcp_config_req (enb_mod_idP, frameP, 1,CONFIG_ACTION_SET_SECURITY_MODE, (ue_mod_idP * NB_RB_MAX) + DCCH, 0x77); - // continue the procedure - rrc_eNB_generate_UECapabilityEnquiry( - ctxt_pP, - ue_context_p); - break; + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)ul_dcch_msg); + } - case LTE_UL_DCCH_MessageType__c1_PR_securityModeFailure: - T(T_ENB_RRC_SECURITY_MODE_FAILURE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, - "[MSG] RRC Security Mode Failure\n"); - - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" securityModeFailure UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); - - LOG_W(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " - "(securityModeFailure) ---> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)ul_dcch_msg); - } - // cancel the security mode in PDCP + // cancel the security mode in PDCP + // followup with the remaining procedure + //#warning "LG Removed rrc_eNB_generate_UECapabilityEnquiry after receiving securityModeFailure" + rrc_eNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); + break; - // followup with the remaining procedure -//#warning "LG Removed rrc_eNB_generate_UECapabilityEnquiry after receiving securityModeFailure" - rrc_eNB_generate_UECapabilityEnquiry(ctxt_pP, ue_context_p); - break; + case LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: + T(T_ENB_RRC_UE_CAPABILITY_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - case LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: - T(T_ENB_RRC_UE_CAPABILITY_INFORMATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - // to avoid segmentation fault - if(!ue_context_p){ + // to avoid segmentation fault + if(!ue_context_p) { LOG_I(RRC, "Processing ueCapabilityInformation UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); break; - } - - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, - "[MSG] RRC UECapablility Information\n"); + } - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" ueCapabilityInformation UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, + "[MSG] RRC UECapablility Information\n"); + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" ueCapabilityInformation UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" received ueCapabilityInformation on UL-DCCH %d from UE\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH); + LOG_D(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " + "(UECapabilityInformation) ---> RRC_eNB\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + DCCH, + sdu_sizeP); - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" received ueCapabilityInformation on UL-DCCH %d from UE\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH); - LOG_D(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " - "(UECapabilityInformation) ---> RRC_eNB\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - DCCH, - sdu_sizeP); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)ul_dcch_msg); - } - LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); - if (ue_context_p->ue_context.UE_Capability) { - LOG_I(RRC, "freeing old UE capabilities for UE %x\n", ctxt_pP->rnti); - ASN_STRUCT_FREE(asn_DEF_LTE_UE_EUTRA_Capability, - ue_context_p->ue_context.UE_Capability); - ue_context_p->ue_context.UE_Capability = 0; - } - dec_rval = uper_decode(NULL, - &asn_DEF_LTE_UE_EUTRA_Capability, - (void **)&ue_context_p->ue_context.UE_Capability, - ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions. - choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list. - array[0]->ueCapabilityRAT_Container.buf, - ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions. - choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list. - array[0]->ueCapabilityRAT_Container.size, 0, 0); - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UE_EUTRA_Capability, ue_context_p->ue_context.UE_Capability); - } + } - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Failed to decode UE capabilities (%zu bytes)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - dec_rval.consumed); - ASN_STRUCT_FREE(asn_DEF_LTE_UE_EUTRA_Capability, - ue_context_p->ue_context.UE_Capability); - ue_context_p->ue_context.UE_Capability = 0; - } + LOG_I(RRC, "got UE capabilities for UE %x\n", ctxt_pP->rnti); - if (EPC_MODE_ENABLED) { + if (ue_context_p->ue_context.UE_Capability) { + LOG_I(RRC, "freeing old UE capabilities for UE %x\n", ctxt_pP->rnti); + ASN_STRUCT_FREE(asn_DEF_LTE_UE_EUTRA_Capability, + ue_context_p->ue_context.UE_Capability); + ue_context_p->ue_context.UE_Capability = 0; + } - if (EPC_MODE_ENABLED == 1) { - rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(ctxt_pP, - ue_context_p, - ul_dcch_msg); - } - } else { - ue_context_p->ue_context.nb_of_e_rabs = 1; - for (i = 0; i < ue_context_p->ue_context.nb_of_e_rabs; i++){ - ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW; - ue_context_p->ue_context.e_rab[i].param.e_rab_id = 1+i; - ue_context_p->ue_context.e_rab[i].param.qos.qci=9; - } - ue_context_p->ue_context.setup_e_rabs =ue_context_p->ue_context.nb_of_e_rabs; - } + dec_rval = uper_decode(NULL, + &asn_DEF_LTE_UE_EUTRA_Capability, + (void **)&ue_context_p->ue_context.UE_Capability, + ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions. + choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list. + array[0]->ueCapabilityRAT_Container.buf, + ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions. + choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list. + array[0]->ueCapabilityRAT_Container.size, 0, 0); + + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + xer_fprint(stdout, &asn_DEF_LTE_UE_EUTRA_Capability, ue_context_p->ue_context.UE_Capability); + } - rrc_eNB_generate_defaultRRCConnectionReconfiguration(ctxt_pP, - ue_context_p, - RC.rrc[ctxt_pP->module_id]->HO_flag); - break; + if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Failed to decode UE capabilities (%zu bytes)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + dec_rval.consumed); + ASN_STRUCT_FREE(asn_DEF_LTE_UE_EUTRA_Capability, + ue_context_p->ue_context.UE_Capability); + ue_context_p->ue_context.UE_Capability = 0; + } + + if (EPC_MODE_ENABLED) { + if (EPC_MODE_ENABLED == 1) { + rrc_eNB_send_S1AP_UE_CAPABILITIES_IND(ctxt_pP, + ue_context_p, + ul_dcch_msg); + } + } else { + ue_context_p->ue_context.nb_of_e_rabs = 1; - case LTE_UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer: - T(T_ENB_RRC_UL_HANDOVER_PREPARATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + for (i = 0; i < ue_context_p->ue_context.nb_of_e_rabs; i++) { + ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW; + ue_context_p->ue_context.e_rab[i].param.e_rab_id = 1+i; + ue_context_p->ue_context.e_rab[i].param.qos.qci=9; + } - break; + ue_context_p->ue_context.setup_e_rabs =ue_context_p->ue_context.nb_of_e_rabs; + } - case LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: - T(T_ENB_RRC_UL_INFORMATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - // to avoid segmentation fault - if(!ue_context_p){ + rrc_eNB_generate_defaultRRCConnectionReconfiguration(ctxt_pP, + ue_context_p, + RC.rrc[ctxt_pP->module_id]->HO_flag); + break; + + case LTE_UL_DCCH_MessageType__c1_PR_ulHandoverPreparationTransfer: + T(T_ENB_RRC_UL_HANDOVER_PREPARATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + break; + + case LTE_UL_DCCH_MessageType__c1_PR_ulInformationTransfer: + T(T_ENB_RRC_UL_INFORMATION_TRANSFER, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + + // to avoid segmentation fault + if(!ue_context_p) { LOG_I(RRC, "Processing ulInformationTransfer UE %x, ue_context_p is NULL\n", ctxt_pP->rnti); break; - } + } - LOG_D(RRC,"[MSG] RRC UL Information Transfer \n"); - LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, - "[MSG] RRC UL Information Transfer \n"); - - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" ulInformationTransfer UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); - - if (EPC_MODE_ENABLED == 1) { - rrc_eNB_send_S1AP_UPLINK_NAS(ctxt_pP, - ue_context_p, - ul_dcch_msg); - } - break; + LOG_D(RRC,"[MSG] RRC UL Information Transfer \n"); + LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, + "[MSG] RRC UL Information Transfer \n"); + MSC_LOG_RX_MESSAGE( + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" ulInformationTransfer UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); - case LTE_UL_DCCH_MessageType__c1_PR_counterCheckResponse: - T(T_ENB_RRC_COUNTER_CHECK_RESPONSE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + if (EPC_MODE_ENABLED == 1) { + rrc_eNB_send_S1AP_UPLINK_NAS(ctxt_pP, + ue_context_p, + ul_dcch_msg); + } - break; + break; + case LTE_UL_DCCH_MessageType__c1_PR_counterCheckResponse: + T(T_ENB_RRC_COUNTER_CHECK_RESPONSE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + break; #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0)) - case LTE_UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9: - T(T_ENB_RRC_UE_INFORMATION_RESPONSE_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - break; - - case LTE_UL_DCCH_MessageType__c1_PR_proximityIndication_r9: - T(T_ENB_RRC_PROXIMITY_INDICATION_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + case LTE_UL_DCCH_MessageType__c1_PR_ueInformationResponse_r9: + T(T_ENB_RRC_UE_INFORMATION_RESPONSE_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + break; - break; + case LTE_UL_DCCH_MessageType__c1_PR_proximityIndication_r9: + T(T_ENB_RRC_PROXIMITY_INDICATION_R9, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + break; #endif - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - case LTE_UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10: - T(T_ENB_RRC_RECONFIGURATION_COMPLETE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - break; - - case LTE_UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10: - T(T_ENB_RRC_MBMS_COUNTING_RESPONSE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - break; + case LTE_UL_DCCH_MessageType__c1_PR_rnReconfigurationComplete_r10: + T(T_ENB_RRC_RECONFIGURATION_COMPLETE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + break; - case LTE_UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10: - T(T_ENB_RRC_INTER_FREQ_RSTD_MEASUREMENT_INDICATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + case LTE_UL_DCCH_MessageType__c1_PR_mbmsCountingResponse_r10: + T(T_ENB_RRC_MBMS_COUNTING_RESPONSE_R10, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + break; - break; + case LTE_UL_DCCH_MessageType__c1_PR_interFreqRSTDMeasurementIndication_r10: + T(T_ENB_RRC_INTER_FREQ_RSTD_MEASUREMENT_INDICATION, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + break; #endif - default: - T(T_ENB_RRC_UNKNOW_MESSAGE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), - T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); - - LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message %s:%u\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - __FILE__, __LINE__); - return -1; + default: + T(T_ENB_RRC_UNKNOW_MESSAGE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame), + T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti)); + LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown message %s:%u\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), + __FILE__, __LINE__); + return -1; } return 0; //TTN for D2D - } else if (ul_dcch_msg->message.present == LTE_UL_DCCH_MessageType_PR_messageClassExtension){ - LOG_I(RRC, "THINH [UL_DCCH_MessageType_PR_messageClassExtension]\n"); + } else if (ul_dcch_msg->message.present == LTE_UL_DCCH_MessageType_PR_messageClassExtension) { + LOG_I(RRC, "THINH [UL_DCCH_MessageType_PR_messageClassExtension]\n"); - switch (ul_dcch_msg->message.choice.messageClassExtension.present) { - case LTE_UL_DCCH_MessageType__messageClassExtension_PR_NOTHING: /* No components present */ + switch (ul_dcch_msg->message.choice.messageClassExtension.present) { + case LTE_UL_DCCH_MessageType__messageClassExtension_PR_NOTHING: /* No components present */ break; - case LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2: //SidelinkUEInformation - //case UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12: //SidelinkUEInformation - LOG_I(RRC,"THINH [UL_DCCH_MessageType__messageClassExtension_PR_c2]\n"); + case LTE_UL_DCCH_MessageType__messageClassExtension_PR_c2: //SidelinkUEInformation + //case UL_DCCH_MessageType__messageClassExtension__c2_PR_sidelinkUEInformation_r12: //SidelinkUEInformation + LOG_I(RRC,"THINH [UL_DCCH_MessageType__messageClassExtension_PR_c2]\n"); LOG_DUMPMSG(RRC,DEBUG_RRC,(char *)Rx_sdu,sdu_sizeP, "[MSG] RRC SidelinkUEInformation \n"); - MSC_LOG_RX_MESSAGE( - MSC_RRC_ENB, - MSC_RRC_UE, - Rx_sdu, - sdu_sizeP, - MSC_AS_TIME_FMT" SidelinkUEInformation UE %x size %u", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_p->ue_context.rnti, - sdu_sizeP); - + MSC_RRC_ENB, + MSC_RRC_UE, + Rx_sdu, + sdu_sizeP, + MSC_AS_TIME_FMT" SidelinkUEInformation UE %x size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_p->ue_context.rnti, + sdu_sizeP); LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RLC RB %02d --- RLC_DATA_IND %d bytes " "(SidelinkUEInformation) ---> RRC_eNB\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), DCCH, sdu_sizeP); - rrc_eNB_process_SidelinkUEInformation( - ctxt_pP, - ue_context_p, - &ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12); + ctxt_pP, + ue_context_p, + &ul_dcch_msg->message.choice.messageClassExtension.choice.c2.choice.sidelinkUEInformation_r12); break; - default: + + default: break; - } - //end TTN + } + + //end TTN } else { LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Unknown error %s:%u\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -7171,16 +6691,15 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) { } #if defined(ENABLE_ITTI) -void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP){ - +void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP) { int i; int e_rab_done=0; - for (i = 0; + + for (i = 0; i < 3;//NB_RB_MAX - 3; // S1AP_MAX_E_RAB i++) { - - if ( ue_context_pP->ue_context.e_rab[i].status < E_RAB_STATUS_DONE){ + if ( ue_context_pP->ue_context.e_rab[i].status < E_RAB_STATUS_DONE) { ue_context_pP->ue_context.e_rab[i].status = E_RAB_STATUS_NEW; ue_context_pP->ue_context.e_rab[i].param.e_rab_id = i + 1; ue_context_pP->ue_context.e_rab[i].param.qos.qci = i % 9; @@ -7189,18 +6708,17 @@ void rrc_eNB_reconfigure_DRBs (const protocol_ctxt_t* const ctxt_pP, ue_context_pP->ue_context.e_rab[i].param.qos.allocation_retention_priority.pre_emp_vulnerability= PRE_EMPTION_VULNERABILITY_DISABLED; ue_context_pP->ue_context.e_rab[i].param.nas_pdu.buffer = NULL; ue_context_pP->ue_context.e_rab[i].param.nas_pdu.length = 0; - // memset (ue_context_pP->ue_context.e_rab[i].param.sgw_addr.buffer,0,20); + // memset (ue_context_pP->ue_context.e_rab[i].param.sgw_addr.buffer,0,20); ue_context_pP->ue_context.e_rab[i].param.sgw_addr.length = 0; ue_context_pP->ue_context.e_rab[i].param.gtp_teid=0; - ue_context_pP->ue_context.nb_of_e_rabs++; e_rab_done++; - LOG_I(RRC,"setting up the dedicated DRBs %d (index %d) status %d \n", - ue_context_pP->ue_context.e_rab[i].param.e_rab_id, i, ue_context_pP->ue_context.e_rab[i].status); + LOG_I(RRC,"setting up the dedicated DRBs %d (index %d) status %d \n", + ue_context_pP->ue_context.e_rab[i].param.e_rab_id, i, ue_context_pP->ue_context.e_rab[i].status); } } + ue_context_pP->ue_context.setup_e_rabs+=e_rab_done; - rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(ctxt_pP, ue_context_pP, 0); } @@ -7213,23 +6731,20 @@ void rrc_enb_init(void) { //----------------------------------------------------------------------------- void *rrc_enb_process_itti_msg(void *notUsed) { - MessageDef *msg_p; - const char *msg_name_p; - instance_t instance; - int result; - SRB_INFO *srb_info_p; - int CC_id; - - protocol_ctxt_t ctxt; - - // Wait for a message - itti_receive_msg(TASK_RRC_ENB, &msg_p); - - msg_name_p = ITTI_MSG_NAME(msg_p); - instance = ITTI_MSG_INSTANCE(msg_p); - LOG_I(RRC,"Received message %s\n",msg_name_p); - - switch (ITTI_MSG_ID(msg_p)) { + MessageDef *msg_p; + const char *msg_name_p; + instance_t instance; + int result; + SRB_INFO *srb_info_p; + int CC_id; + protocol_ctxt_t ctxt; + // Wait for a message + itti_receive_msg(TASK_RRC_ENB, &msg_p); + msg_name_p = ITTI_MSG_NAME(msg_p); + instance = ITTI_MSG_INSTANCE(msg_p); + LOG_I(RRC,"Received message %s\n",msg_name_p); + + switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: LOG_W(RRC, " *** Exiting RRC thread\n"); itti_exit_task(); @@ -7239,7 +6754,7 @@ void *rrc_enb_process_itti_msg(void *notUsed) { LOG_I(RRC, "[eNB %d] Received %s\n", instance, msg_name_p); break; - /* Messages from MAC */ + /* Messages from MAC */ case RRC_MAC_CCCH_DATA_IND: PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, @@ -7250,25 +6765,24 @@ void *rrc_enb_process_itti_msg(void *notUsed) { LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Received %s\n", PROTOCOL_RRC_CTXT_UE_ARGS(&ctxt), msg_name_p); - CC_id = RRC_MAC_CCCH_DATA_IND(msg_p).CC_id; srb_info_p = &RC.rrc[instance]->carrier[CC_id].Srb0; - LOG_I(RRC,"Decoding CCCH : inst %d, CC_id %d, ctxt %p, sib_info_p->Rx_buffer.payload_size %d\n", - instance,CC_id,&ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); + instance,CC_id,&ctxt, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); + if (RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size >= RRC_BUFFER_SIZE_MAX) { - LOG_I(RRC, "CCCH message has size %d > %d\n",RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); - break; + LOG_I(RRC, "CCCH message has size %d > %d\n",RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size,RRC_BUFFER_SIZE_MAX); + break; } + memcpy(srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND(msg_p).sdu, RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size); srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size; - rrc_eNB_decode_ccch(&ctxt, srb_info_p, CC_id); break; - - /* Messages from PDCP */ + + /* Messages from PDCP */ case RRC_DCCH_DATA_IND: PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, @@ -7284,18 +6798,18 @@ void *rrc_enb_process_itti_msg(void *notUsed) { RRC_DCCH_DATA_IND(msg_p).dcch_index, RRC_DCCH_DATA_IND(msg_p).sdu_p, RRC_DCCH_DATA_IND(msg_p).sdu_size); - // Message buffer has been processed, free it now. result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND(msg_p).sdu_p); + if (result != EXIT_SUCCESS) { - LOG_I(RRC, "Failed to free memory (%d)!\n",result); - break; + LOG_I(RRC, "Failed to free memory (%d)!\n",result); + break; } - break; + break; # if defined(ENABLE_USE_MME) - /* Messages from S1AP */ + /* Messages from S1AP */ case S1AP_DOWNLINK_NAS: rrc_eNB_process_S1AP_DOWNLINK_NAS(msg_p, msg_name_p, instance, &rrc_eNB_mui); break; @@ -7312,8 +6826,8 @@ void *rrc_enb_process_itti_msg(void *notUsed) { LOG_D(RRC, "[eNB %d] Received Paging message from S1AP: %s\n", instance, msg_name_p); rrc_eNB_process_PAGING_IND(msg_p, msg_name_p, instance); break; - - case S1AP_E_RAB_SETUP_REQ: + + case S1AP_E_RAB_SETUP_REQ: rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(msg_p, msg_name_p, instance); LOG_D(RRC, "[eNB %d] Received the message %s\n", instance, msg_name_p); break; @@ -7325,7 +6839,7 @@ void *rrc_enb_process_itti_msg(void *notUsed) { case S1AP_E_RAB_RELEASE_COMMAND: rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(msg_p, msg_name_p, instance); break; - + case S1AP_UE_CONTEXT_RELEASE_REQ: rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ(msg_p, msg_name_p, instance); break; @@ -7335,19 +6849,20 @@ void *rrc_enb_process_itti_msg(void *notUsed) { break; case GTPV1U_ENB_DELETE_TUNNEL_RESP: + /* Nothing to do. Apparently everything is done in S1AP processing */ //LOG_I(RRC, "[eNB %d] Received message %s, not processed because procedure not synched\n", //instance, msg_name_p); - if (rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti) - && rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc > 0) { + if (rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti) + && rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc > 0) { rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc = - rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_thres_rrc; + rrc_eNB_get_ue_context(RC.rrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_thres_rrc; } - break; + break; # endif - /* Messages from eNB app */ + /* Messages from eNB app */ case RRC_CONFIGURATION_REQ: LOG_I(RRC, "[eNB %d] Received %s : %p\n", instance, msg_name_p,&RRC_CONFIGURATION_REQ(msg_p)); openair_rrc_eNB_configuration(ENB_INSTANCE_TO_MODULE_ID(instance), &RRC_CONFIGURATION_REQ(msg_p)); @@ -7356,33 +6871,31 @@ void *rrc_enb_process_itti_msg(void *notUsed) { default: LOG_E(RRC, "[eNB %d] Received unexpected message %s\n", instance, msg_name_p); break; - } + } - result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - if (result != EXIT_SUCCESS) { - LOG_I(RRC, "Failed to free memory (%d)!\n",result); - } - msg_p = NULL; - return NULL; + result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + + if (result != EXIT_SUCCESS) { + LOG_I(RRC, "Failed to free memory (%d)!\n",result); + } + + msg_p = NULL; + return NULL; } //----------------------------------------------------------------------------- -void* +void * rrc_enb_task( - void* args_p + void *args_p ) //----------------------------------------------------------------------------- { rrc_enb_init(); - itti_mark_task_ready(TASK_RRC_ENB); LOG_I(RRC,"Entering main loop of RRC message task\n"); - while (1) { - (void) rrc_enb_process_itti_msg(NULL); - } } #endif @@ -7392,13 +6905,10 @@ void openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active) //----------------------------------------------------------------------------- { - module_id_t module_id; int CC_id; - /* for no gcc warnings */ (void)CC_id; - LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_eNB_INST=%d\n", RC.nb_inst); if (RC.nb_inst > 0) { @@ -7427,9 +6937,7 @@ openair_rrc_top_init_eNB(int eMBMS_active,uint8_t HO_active) } #endif - } - - + } } //----------------------------------------------------------------------------- @@ -7439,8 +6947,8 @@ rrc_top_cleanup_eNB( ) //----------------------------------------------------------------------------- { + for (int i=0; i<RC.nb_inst; i++) free (RC.rrc[i]); - for (int i=0;i<RC.nb_inst;i++) free (RC.rrc[i]); free(RC.rrc); } @@ -7449,121 +6957,139 @@ rrc_top_cleanup_eNB( //TTN - for D2D uint8_t rrc_eNB_process_SidelinkUEInformation( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* ue_context_pP, - LTE_SidelinkUEInformation_r12_t * sidelinkUEInformation + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *ue_context_pP, + LTE_SidelinkUEInformation_r12_t *sidelinkUEInformation ) //----------------------------------------------------------------------------- { - LTE_SL_DestinationInfoList_r12_t *destinationInfoList; - int n_destinations = 0; - int n_discoveryMessages = 0; - - LOG_I(RRC, - PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing SidelinkUEInformation from UE (SRB1 Active)\n", - PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); - - //For SL Communication - if (sidelinkUEInformation->criticalExtensions.present == LTE_SidelinkUEInformation_r12__criticalExtensions_PR_c1){ - if (sidelinkUEInformation->criticalExtensions.choice.c1.present == LTE_SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12){ - // express its interest to receive SL communication - if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12 != NULL){ - - } - - // express its interest to transmit non-relay one-to-many SL communication - if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12 != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12 != NULL)){ - n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.count; - destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); - for (int i=0; i< n_destinations; i++ ){ - //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.array[i]); - ASN_SEQUENCE_ADD(&destinationInfoList->list, sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.array[i]); - } - //generate RRC Reconfiguration - rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); - return 0; - - } - - // express its interest to transmit non-relay one-to-one SL communication - if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13 != NULL)) { - if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12 != NULL){ - n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.count; - destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); - for (int i=0; i< n_destinations; i++ ){ - //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.array[i]); - ASN_SEQUENCE_ADD(&destinationInfoList->list,sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.array[i]); - } - //generate RRC Reconfiguration - rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); - return 0; - } - } - - // express its interest to transmit relay related one-to-one SL communication - if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) &&(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13 != NULL)) { - if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.count > 0) { - n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.count; - destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); - for (int i=0; i< n_destinations; i++ ){ - //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.array[i]); - ASN_SEQUENCE_ADD(&destinationInfoList->list, sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.array[i]); - } - //generate RRC Reconfiguration - rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); - return 0; - } - } - - //express its interest to transmit relay related one-to-many SL communication - if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13 != NULL)) { - if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.count > 0){ - n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.count; - destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); - for (int i=0; i< n_destinations; i++ ){ - //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.array[i]); - ASN_SEQUENCE_ADD(&destinationInfoList->list,sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.array[i]); - } - //generate RRC Reconfiguration - rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); - return 0; - } - } - - //For SL Discovery - //express its interest to receive SL discovery announcements - //express its interest to transmit non-PS related discovery announcements - if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12 != NULL){ - n_discoveryMessages = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12); - //generate RRC Reconfiguration - rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, NULL, n_discoveryMessages); - return 0; - } - //express its interest to transmit PS related discovery announcements - if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13 !=NULL)) { - if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13 > 0){ - n_discoveryMessages = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13; - //generate RRC Reconfiguration - rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, NULL, n_discoveryMessages); - return 0; - } - } + LTE_SL_DestinationInfoList_r12_t *destinationInfoList; + int n_destinations = 0; + int n_discoveryMessages = 0; + LOG_I(RRC, + PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing SidelinkUEInformation from UE (SRB1 Active)\n", + PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP)); + + //For SL Communication + if (sidelinkUEInformation->criticalExtensions.present == LTE_SidelinkUEInformation_r12__criticalExtensions_PR_c1) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.present == LTE_SidelinkUEInformation_r12__criticalExtensions__c1_PR_sidelinkUEInformation_r12) { + // express its interest to receive SL communication + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commRxInterestedFreq_r12 != NULL) { + } + + // express its interest to transmit non-relay one-to-many SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12 != NULL) && + (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->carrierFreq_r12 != NULL)) { + n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.count; + destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); + + for (int i=0; i< n_destinations; i++ ) { + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list, sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.commTxResourceReq_r12->destinationInfoList_r12.list.array[i]); + } + + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + } + + // express its interest to transmit non-relay one-to-one SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && + (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13 != NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->carrierFreq_r12 != NULL) { + n_destinations = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.count; + destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); + + for (int i=0; i< n_destinations; i++ ) { + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list, + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceReqUC_r13->destinationInfoList_r12.list.array[i]); + } + + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + } } - } - return 0; + + // express its interest to transmit relay related one-to-one SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && + (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13 != NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.count + > 0) { + n_destinations = + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.count; + destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); + + for (int i=0; i< n_destinations; i++ ) { + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list, + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelayUC_r13->destinationInfoList_r12.list.array[i]); + } + + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + } + } + + //express its interest to transmit relay related one-to-many SL communication + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && + (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13 != NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.count + > 0) { + n_destinations = + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.count; + destinationInfoList = CALLOC(1, sizeof(LTE_SL_DestinationInfoList_r12_t)); + + for (int i=0; i< n_destinations; i++ ) { + //sl_DestinationIdentityList[i] = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.array[i]); + ASN_SEQUENCE_ADD(&destinationInfoList->list, + sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->commTxResourceInfoReqRelay_r13->commTxResourceReqRelay_r13->destinationInfoList_r12.list.array[i]); + } + + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, destinationInfoList, 0); + return 0; + } + } + + //For SL Discovery + //express its interest to receive SL discovery announcements + //express its interest to transmit non-PS related discovery announcements + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12 != NULL) { + n_discoveryMessages = *(sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.discTxResourceReq_r12); + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, NULL, n_discoveryMessages); + return 0; + } + + //express its interest to transmit PS related discovery announcements + if ((sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension != NULL) && + (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13 !=NULL)) { + if (sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13 > 0) { + n_discoveryMessages = sidelinkUEInformation->criticalExtensions.choice.c1.choice.sidelinkUEInformation_r12.nonCriticalExtension->discTxResourceReqPS_r13->discTxResourceReq_r13; + //generate RRC Reconfiguration + rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink(ctxt_pP, ue_context_pP, NULL, n_discoveryMessages); + return 0; + } + } + } + } + + return 0; } //----------------------------------------------------------------------------- int rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, LTE_SL_DestinationInfoList_r12_t *destinationInfoList, int n_discoveryMessages ) //----------------------------------------------------------------------------- { - uint8_t buffer[RRC_BUF_SIZE]; uint16_t size = -1; memset(buffer, 0, RRC_BUF_SIZE); @@ -7571,58 +7097,56 @@ rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( // allocate dedicated pools for UE -sl-CommConfig/sl-DiscConfig (sl-V2X-ConfigDedicated) //populate dedicated resources for SL communication (sl-CommConfig) if ((destinationInfoList != NULL) && (destinationInfoList->list.count > 0)) { - - LOG_I(RRC,"[eNB %d] Frame %d, Generate LTE_RRCConnectionReconfiguration_Sidelink (bytes %d, UE id %x), number of destinations %d\n", - ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti,destinationInfoList->list.count ); - //get dedicated resources from available pool and assign to the UE - LTE_SL_CommConfig_r12_t sl_CommConfig[destinationInfoList->list.count]; - //get a RP from the available RPs - sl_CommConfig[0] = rrc_eNB_get_sidelink_commTXPool(ctxt_pP, ue_context_pP, destinationInfoList); - - size = do_RRCConnectionReconfiguration(ctxt_pP, - buffer, - rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id - (LTE_SRB_ToAddModList_t*)NULL, - (LTE_DRB_ToAddModList_t*)NULL, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // *sps_Config, - NULL, NULL, NULL, NULL,NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL, - (LTE_SL_CommConfig_r12_t*)&sl_CommConfig, - (LTE_SL_DiscConfig_r12_t*)NULL - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL - #endif - ); - // + LOG_I(RRC,"[eNB %d] Frame %d, Generate LTE_RRCConnectionReconfiguration_Sidelink (bytes %d, UE id %x), number of destinations %d\n", + ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti,destinationInfoList->list.count ); + //get dedicated resources from available pool and assign to the UE + LTE_SL_CommConfig_r12_t sl_CommConfig[destinationInfoList->list.count]; + //get a RP from the available RPs + sl_CommConfig[0] = rrc_eNB_get_sidelink_commTXPool(ctxt_pP, ue_context_pP, destinationInfoList); + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id + (LTE_SRB_ToAddModList_t *)NULL, + (LTE_DRB_ToAddModList_t *)NULL, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)NULL, + (LTE_SL_CommConfig_r12_t *)&sl_CommConfig, + (LTE_SL_DiscConfig_r12_t *)NULL +#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + , (LTE_SCellToAddMod_r10_t *)NULL +#endif + ); + // } + //populate dedicated resources for SL discovery (sl-DiscConfig) if (n_discoveryMessages > 0) { - LTE_SL_DiscConfig_r12_t sl_DiscConfig[n_discoveryMessages]; - //get a RP from the available RPs - sl_DiscConfig[0] = rrc_eNB_get_sidelink_discTXPool(ctxt_pP, ue_context_pP, n_discoveryMessages ); - size = do_RRCConnectionReconfiguration(ctxt_pP, - buffer, - rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id - (LTE_SRB_ToAddModList_t*)NULL, - (LTE_DRB_ToAddModList_t*)NULL, - (LTE_DRB_ToReleaseList_t*)NULL, // DRB2_list, - (struct LTE_SPS_Config*)NULL, // *sps_Config, - NULL, NULL, NULL, NULL,NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList*)NULL, - (LTE_SL_CommConfig_r12_t*)NULL, - (LTE_SL_DiscConfig_r12_t*)&sl_DiscConfig - #if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) - , (LTE_SCellToAddMod_r10_t*)NULL - #endif - ); + LTE_SL_DiscConfig_r12_t sl_DiscConfig[n_discoveryMessages]; + //get a RP from the available RPs + sl_DiscConfig[0] = rrc_eNB_get_sidelink_discTXPool(ctxt_pP, ue_context_pP, n_discoveryMessages ); + size = do_RRCConnectionReconfiguration(ctxt_pP, + buffer, + rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id), //Transaction_id + (LTE_SRB_ToAddModList_t *)NULL, + (LTE_DRB_ToAddModList_t *)NULL, + (LTE_DRB_ToReleaseList_t *)NULL, // DRB2_list, + (struct LTE_SPS_Config *)NULL, // *sps_Config, + NULL, NULL, NULL, NULL,NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + (struct LTE_RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *)NULL, + (LTE_SL_CommConfig_r12_t *)NULL, + (LTE_SL_DiscConfig_r12_t *)&sl_DiscConfig +#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0)) + , (LTE_SCellToAddMod_r10_t *)NULL +#endif + ); } LOG_I(RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate LTE_RRCConnectionReconfiguration_Sidelink (bytes %d, UE id %x)\n", ctxt_pP->module_id,ctxt_pP->frame, size, ue_context_pP->ue_context.rnti); - rrc_data_req( ctxt_pP, DCCH, @@ -7631,306 +7155,327 @@ rrc_eNB_generate_RRCConnectionReconfiguration_Sidelink( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); - // rrc_data_req(); - return size; } -LTE_SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, LTE_SL_DestinationInfoList_r12_t *destinationInfoList ){ - // for the moment, use scheduled resource allocation - LTE_SL_CommConfig_r12_t *sl_CommConfig; - LTE_SL_CommResourcePool_r12_t *sc_CommTxConfig; - - sl_CommConfig = CALLOC(1, sizeof(struct LTE_SL_CommConfig_r12)); - sl_CommConfig->commTxResources_r12 = CALLOC(1, sizeof(*sl_CommConfig->commTxResources_r12)); - sl_CommConfig->commTxResources_r12->present = LTE_SL_CommConfig_r12__commTxResources_r12_PR_setup; - - sl_CommConfig->commTxResources_r12->choice.setup.present = LTE_SL_CommConfig_r12__commTxResources_r12__setup_PR_scheduled_r12; - sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.size = 2; - sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf = CALLOC(1,2); - sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf[0] = 0x00; - sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf[1] = 0x01;//ctxt_pP->rnti;//rnti - sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.bits_unused = 0; - sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12 = CALLOC(1,sizeof(*sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12)); - //*sl_CommConfig_test->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12 = 12; //Msc - sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mac_MainConfig_r12.retx_BSR_TimerSL = LTE_RetxBSR_Timer_r12_sf320; //MacConfig, for testing only - //sl_CommConfig_test->commTxResources_r12->choice.setup.choice.scheduled_r12.sc_CommTxConfig_r12; - - sc_CommTxConfig = & sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sc_CommTxConfig_r12; - - sc_CommTxConfig->sc_CP_Len_r12 = LTE_SL_CP_Len_r12_normal; - sc_CommTxConfig->sc_Period_r12 = LTE_SL_PeriodComm_r12_sf40; - sc_CommTxConfig->data_CP_Len_r12 = LTE_SL_CP_Len_r12_normal; - //sc_TF_ResourceConfig_r12 - sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_Num_r12 = 20; - sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_Start_r12 = 5; - sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_End_r12 = 44; - sc_CommTxConfig->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = LTE_SL_OffsetIndicator_r12_PR_small_r12; - sc_CommTxConfig->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0; - - sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = LTE_SubframeBitmapSL_r12_PR_bs40_r12; - sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = 5; - sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = CALLOC(1,5); - sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = 0; - //dataHoppingConfig_r12 - sc_CommTxConfig->dataHoppingConfig_r12.hoppingParameter_r12 = 0; - sc_CommTxConfig->dataHoppingConfig_r12.numSubbands_r12 = LTE_SL_HoppingConfigComm_r12__numSubbands_r12_ns1; - sc_CommTxConfig->dataHoppingConfig_r12.rb_Offset_r12 = 0; - //ue_SelectedResourceConfig_r12 - sc_CommTxConfig->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->ue_SelectedResourceConfig_r12)); - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Start_r12 = 5; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_End_r12 = 44; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = LTE_SL_OffsetIndicator_r12_PR_small_r12; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0 ; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = LTE_SubframeBitmapSL_r12_PR_bs40_r12; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = 5; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = CALLOC(1,5); - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = 0; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[0] = 0xF0; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[1] = 0xFF; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[2] = 0xFF; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[3] = 0xFF; - sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[4] = 0xFF; - //rxParametersNCell_r12 - sc_CommTxConfig->rxParametersNCell_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->rxParametersNCell_r12)); - sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12 )); - sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12->subframeAssignment = 0 ; - sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12->specialSubframePatterns = 0; - sc_CommTxConfig->rxParametersNCell_r12->syncConfigIndex_r12 = 0; - //txParameters_r12 - sc_CommTxConfig->txParameters_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->txParameters_r12)); - sc_CommTxConfig->txParameters_r12->sc_TxParameters_r12.alpha_r12 = LTE_Alpha_r12_al0; - sc_CommTxConfig->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0; - sc_CommTxConfig->ext1 = NULL ; - - return *sl_CommConfig; +LTE_SL_CommConfig_r12_t rrc_eNB_get_sidelink_commTXPool( const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, LTE_SL_DestinationInfoList_r12_t *destinationInfoList ) { + // for the moment, use scheduled resource allocation + LTE_SL_CommConfig_r12_t *sl_CommConfig; + LTE_SL_CommResourcePool_r12_t *sc_CommTxConfig; + sl_CommConfig = CALLOC(1, sizeof(struct LTE_SL_CommConfig_r12)); + sl_CommConfig->commTxResources_r12 = CALLOC(1, sizeof(*sl_CommConfig->commTxResources_r12)); + sl_CommConfig->commTxResources_r12->present = LTE_SL_CommConfig_r12__commTxResources_r12_PR_setup; + sl_CommConfig->commTxResources_r12->choice.setup.present = LTE_SL_CommConfig_r12__commTxResources_r12__setup_PR_scheduled_r12; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.size = 2; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf = CALLOC(1,2); + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf[0] = 0x00; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.buf[1] = 0x01;//ctxt_pP->rnti;//rnti + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sl_RNTI_r12.bits_unused = 0; + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12 = CALLOC(1,sizeof(*sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12)); + //*sl_CommConfig_test->commTxResources_r12->choice.setup.choice.scheduled_r12.mcs_r12 = 12; //Msc + sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.mac_MainConfig_r12.retx_BSR_TimerSL = LTE_RetxBSR_Timer_r12_sf320; //MacConfig, for testing only + //sl_CommConfig_test->commTxResources_r12->choice.setup.choice.scheduled_r12.sc_CommTxConfig_r12; + sc_CommTxConfig = & sl_CommConfig->commTxResources_r12->choice.setup.choice.scheduled_r12.sc_CommTxConfig_r12; + sc_CommTxConfig->sc_CP_Len_r12 = LTE_SL_CP_Len_r12_normal; + sc_CommTxConfig->sc_Period_r12 = LTE_SL_PeriodComm_r12_sf40; + sc_CommTxConfig->data_CP_Len_r12 = LTE_SL_CP_Len_r12_normal; + //sc_TF_ResourceConfig_r12 + sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_Num_r12 = 20; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_Start_r12 = 5; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.prb_End_r12 = 44; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.offsetIndicator_r12.present = LTE_SL_OffsetIndicator_r12_PR_small_r12; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.present = LTE_SubframeBitmapSL_r12_PR_bs40_r12; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.size = 5; + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.buf = CALLOC(1,5); + sc_CommTxConfig->sc_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs40_r12.bits_unused = 0; + //dataHoppingConfig_r12 + sc_CommTxConfig->dataHoppingConfig_r12.hoppingParameter_r12 = 0; + sc_CommTxConfig->dataHoppingConfig_r12.numSubbands_r12 = LTE_SL_HoppingConfigComm_r12__numSubbands_r12_ns1; + sc_CommTxConfig->dataHoppingConfig_r12.rb_Offset_r12 = 0; + //ue_SelectedResourceConfig_r12 + sc_CommTxConfig->ue_SelectedResourceConfig_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->ue_SelectedResourceConfig_r12)); + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Num_r12 = 20; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_Start_r12 = 5; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.prb_End_r12 = 44; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.present = LTE_SL_OffsetIndicator_r12_PR_small_r12; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.offsetIndicator_r12.choice.small_r12 = 0 ; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.present = LTE_SubframeBitmapSL_r12_PR_bs40_r12; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.size = 5; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf = CALLOC(1,5); + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.bits_unused = 0; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[0] = 0xF0; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[1] = 0xFF; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[2] = 0xFF; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[3] = 0xFF; + sc_CommTxConfig->ue_SelectedResourceConfig_r12->data_TF_ResourceConfig_r12.subframeBitmap_r12.choice.bs4_r12.buf[4] = 0xFF; + //rxParametersNCell_r12 + sc_CommTxConfig->rxParametersNCell_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->rxParametersNCell_r12)); + sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12 )); + sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12->subframeAssignment = 0 ; + sc_CommTxConfig->rxParametersNCell_r12->tdd_Config_r12->specialSubframePatterns = 0; + sc_CommTxConfig->rxParametersNCell_r12->syncConfigIndex_r12 = 0; + //txParameters_r12 + sc_CommTxConfig->txParameters_r12 = CALLOC (1, sizeof (*sc_CommTxConfig->txParameters_r12)); + sc_CommTxConfig->txParameters_r12->sc_TxParameters_r12.alpha_r12 = LTE_Alpha_r12_al0; + sc_CommTxConfig->txParameters_r12->sc_TxParameters_r12.p0_r12 = 0; + sc_CommTxConfig->ext1 = NULL ; + return *sl_CommConfig; } -LTE_SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, int n_discoveryMessages ){ - //TODO - LTE_SL_DiscConfig_r12_t sl_DiscConfig; - sl_DiscConfig.discTxResources_r12 = CALLOC(1,sizeof(*sl_DiscConfig.discTxResources_r12)); - sl_DiscConfig.discTxResources_r12->present = LTE_SL_DiscConfig_r12__discTxResources_r12_PR_setup; - sl_DiscConfig.discTxResources_r12->choice.setup.present = LTE_SL_DiscConfig_r12__discTxResources_r12__setup_PR_scheduled_r12; - //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discHoppingConfig_r12; - //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTF_IndexList_r12; - //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTxConfig_r12; - return sl_DiscConfig; +LTE_SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool( const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, int n_discoveryMessages ) { + //TODO + LTE_SL_DiscConfig_r12_t sl_DiscConfig; + sl_DiscConfig.discTxResources_r12 = CALLOC(1,sizeof(*sl_DiscConfig.discTxResources_r12)); + sl_DiscConfig.discTxResources_r12->present = LTE_SL_DiscConfig_r12__discTxResources_r12_PR_setup; + sl_DiscConfig.discTxResources_r12->choice.setup.present = LTE_SL_DiscConfig_r12__discTxResources_r12__setup_PR_scheduled_r12; + //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discHoppingConfig_r12; + //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTF_IndexList_r12; + //sl_DiscConfig.discTxResources_r12->choice.setup.choice.scheduled_r12.discTxConfig_r12; + return sl_DiscConfig; } + RRC_status_t rrc_rx_tx( - protocol_ctxt_t* const ctxt_pP, - const int CC_id + protocol_ctxt_t *const ctxt_pP, + const int CC_id ) //----------------------------------------------------------------------------- { - //uint8_t UE_id; - int32_t current_timestamp_ms, ref_timestamp_ms; + int32_t current_timestamp_ms = 0; + int32_t ref_timestamp_ms = 0; struct timeval ts; - struct rrc_eNB_ue_context_s *ue_context_p = NULL,*ue_to_be_removed = NULL; - + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_to_be_removed = NULL; #ifdef LOCALIZATION - double estimated_distance; - protocol_ctxt_t ctxt; -#endif - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_IN); - - check_handovers(ctxt_pP); - // counetr, and get the value and aggregate - - // check for UL failure - RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { - ctxt_pP->rnti = ue_context_p->ue_id_rnti; - if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe==0)) { - if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { - LOG_I(RRC,"UE rnti %x:S-TMSI %x failure timer %d/8\n", - ue_context_p->ue_context.rnti, - ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, - ue_context_p->ue_context.ul_failure_timer); - } - else { - LOG_I(RRC,"UE rnti %x failure timer %d/8\n", - ue_context_p->ue_context.rnti, - ue_context_p->ue_context.ul_failure_timer); - } + double estimated_distance = 0; + protocol_ctxt_t ctxt; +#endif + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX, VCD_FUNCTION_IN); + check_handovers(ctxt_pP); // counter, get the value and aggregate + // check for UL failure or for UE to be released + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { + ctxt_pP->rnti = ue_context_p->ue_id_rnti; + + if ((ctxt_pP->frame == 0) && (ctxt_pP->subframe == 0)) { + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { + LOG_I(RRC, "UE rnti %x: S-TMSI %x failure timer %d/8\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi, + ue_context_p->ue_context.ul_failure_timer); + } else { + LOG_I(RRC, "UE rnti %x failure timer %d/8\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.ul_failure_timer); } - if (ue_context_p->ue_context.ul_failure_timer>0) { - ue_context_p->ue_context.ul_failure_timer++; - if (ue_context_p->ue_context.ul_failure_timer >= 20000) { - // remove UE after 20 seconds after MAC has indicated UL failure - LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); - ue_to_be_removed = ue_context_p; - break; - } + } + + if (ue_context_p->ue_context.ul_failure_timer > 0) { + ue_context_p->ue_context.ul_failure_timer++; + + if (ue_context_p->ue_context.ul_failure_timer >= 20000) { + // remove UE after 20 seconds after MAC (or else) has indicated UL failure + LOG_I(RRC, "Removing UE %x instance, because of uplink failure timer timeout\n", + ue_context_p->ue_context.rnti); + ue_to_be_removed = ue_context_p; + break; // break RB_FOREACH } - if (ue_context_p->ue_context.ue_release_timer_s1>0) { - ue_context_p->ue_context.ue_release_timer_s1++; - if (ue_context_p->ue_context.ue_release_timer_s1 >= - ue_context_p->ue_context.ue_release_timer_thres_s1) { - LOG_I(RRC,"Removing UE %x instance Because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n", - ue_context_p->ue_context.rnti, ue_context_p->ue_context.ue_release_timer_thres_s1); -// ue_context_p->ue_context.ue_release_timer_s1 = 0; + } + + if (ue_context_p->ue_context.ue_release_timer_s1 > 0) { + ue_context_p->ue_context.ue_release_timer_s1++; + + if (ue_context_p->ue_context.ue_release_timer_s1 >= ue_context_p->ue_context.ue_release_timer_thres_s1) { + LOG_I(RRC, "Removing UE %x instance, because of UE_CONTEXT_RELEASE_COMMAND not received after %d ms from sending request\n", + ue_context_p->ue_context.rnti, + ue_context_p->ue_context.ue_release_timer_thres_s1); #if defined(ENABLE_USE_MME) #if defined(ENABLE_ITTI) - rrc_eNB_generate_RRCConnectionRelease(ctxt_pP, ue_context_p); + rrc_eNB_generate_RRCConnectionRelease(ctxt_pP, ue_context_p); #endif #else - ue_to_be_removed = ue_context_p; -#endif - ue_context_p->ue_context.ue_release_timer_s1 = 0; - break; - } + ue_to_be_removed = ue_context_p; +#endif + ue_context_p->ue_context.ue_release_timer_s1 = 0; + break; // break RB_FOREACH + } // end if timer_s1 timeout + } // end if timer_s1 > 0 (S1 UE_CONTEXT_RELEASE_REQ ongoing) + + if (ue_context_p->ue_context.ue_release_timer_rrc > 0) { + ue_context_p->ue_context.ue_release_timer_rrc++; + + if (ue_context_p->ue_context.ue_release_timer_rrc >= ue_context_p->ue_context.ue_release_timer_thres_rrc) { + LOG_I(RRC, "Removing UE %x instance after UE_CONTEXT_RELEASE_Complete (ue_release_timer_rrc timeout)\n", + ue_context_p->ue_context.rnti); + ue_context_p->ue_context.ue_release_timer_rrc = 0; + ue_to_be_removed = ue_context_p; + break; // break RB_FOREACH } + } - if (ue_context_p->ue_context.ue_release_timer_rrc>0) { - ue_context_p->ue_context.ue_release_timer_rrc++; - if (ue_context_p->ue_context.ue_release_timer_rrc >= - ue_context_p->ue_context.ue_release_timer_thres_rrc) { - LOG_I(RRC,"Removing UE %x instance After UE_CONTEXT_RELEASE_Complete\n", ue_context_p->ue_context.rnti); - ue_context_p->ue_context.ue_release_timer_rrc = 0; - ue_to_be_removed = ue_context_p; - ue_context_p->ue_context.ue_release_timer_rrc = 0; - break; + pthread_mutex_lock(&rrc_release_freelist); + + if (rrc_release_info.num_UEs > 0) { + uint16_t release_total = 0; + + for (uint16_t release_num = 0; release_num < NUMBER_OF_UE_MAX; release_num++) { + if (rrc_release_info.RRC_release_ctrl[release_num].flag > 0) { + release_total++; } - } - pthread_mutex_lock(&rrc_release_freelist); - if(rrc_release_info.num_UEs > 0){ - uint16_t release_total = 0; - for(uint16_t release_num = 0;release_num < NUMBER_OF_UE_MAX;release_num++){ - if(rrc_release_info.RRC_release_ctrl[release_num].flag > 0){ - release_total++; - } - if( (rrc_release_info.RRC_release_ctrl[release_num].flag > 2) && - (rrc_release_info.RRC_release_ctrl[release_num].rnti == ue_context_p->ue_context.rnti)){ - ue_context_p->ue_context.ue_release_timer_rrc = 1; - ue_context_p->ue_context.ue_release_timer_thres_rrc = 100; + + if ((rrc_release_info.RRC_release_ctrl[release_num].flag > 2) && + (rrc_release_info.RRC_release_ctrl[release_num].rnti == ue_context_p->ue_context.rnti)) { + ue_context_p->ue_context.ue_release_timer_rrc = 1; + ue_context_p->ue_context.ue_release_timer_thres_rrc = 100; #if defined(ENABLE_USE_MME) #if defined(ENABLE_ITTI) - int e_rab; - MessageDef *msg_complete_p = NULL; - MessageDef *msg_delete_tunnels_p = NULL; - uint32_t eNB_ue_s1ap_id = ue_context_p->ue_context.eNB_ue_s1ap_id; - if(rrc_release_info.RRC_release_ctrl[release_num].flag == 4){ - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - NULL,0, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", - eNB_ue_s1ap_id); - msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); - S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - itti_send_msg_to_task(TASK_S1AP, ctxt_pP->module_id, msg_complete_p); - } - MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_GTPU_ENB, NULL,0, "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ", eNB_ue_s1ap_id); - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - // do not wait response - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = - ue_context_p->ue_context.enb_gtp_ebi[e_rab]; - // erase data - ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; - memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); - ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; - } - itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->module_id, msg_delete_tunnels_p); - struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; - rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids( - RC.rrc[ctxt_pP->module_id], - 0, - eNB_ue_s1ap_id); - if (NULL != rrc_ue_s1ap_ids) { - rrc_eNB_S1AP_remove_ue_ids( - RC.rrc[ctxt_pP->module_id], - rrc_ue_s1ap_ids); - } -#endif -#endif - rrc_release_info.RRC_release_ctrl[release_num].flag = 0; - rrc_release_info.num_UEs--; - break; - } - if(release_total >= rrc_release_info.num_UEs) - break; - } - } - pthread_mutex_unlock(&rrc_release_freelist); - - if (ue_context_p->ue_context.ue_reestablishment_timer>0) { - ue_context_p->ue_context.ue_reestablishment_timer++; - if (ue_context_p->ue_context.ue_reestablishment_timer >= - ue_context_p->ue_context.ue_reestablishment_timer_thres) { - LOG_I(RRC,"UE %d reestablishment_timer max\n",ue_context_p->ue_context.rnti); - ue_context_p->ue_context.ul_failure_timer = 20000; - ue_to_be_removed = ue_context_p; - ue_context_p->ue_context.ue_reestablishment_timer = 0; - break; + int e_rab = 0; + MessageDef *msg_complete_p = NULL; + MessageDef *msg_delete_tunnels_p = NULL; + uint32_t eNB_ue_s1ap_id = ue_context_p->ue_context.eNB_ue_s1ap_id; + + if (rrc_release_info.RRC_release_ctrl[release_num].flag == 4) { // if timer_s1 == 0 + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_S1AP_ENB, NULL, 0, + "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", + eNB_ue_s1ap_id); + msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); + S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; + itti_send_msg_to_task(TASK_S1AP, ctxt_pP->module_id, msg_complete_p); + } + + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, MSC_GTPU_ENB, NULL,0, "0 GTPV1U_ENB_DELETE_TUNNEL_REQ rnti %x ", eNB_ue_s1ap_id); + msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); + memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); + // do not wait response + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; + + for (e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = + ue_context_p->ue_context.enb_gtp_ebi[e_rab]; + // erase data + ue_context_p->ue_context.enb_gtp_teid[e_rab] = 0; + memset(&ue_context_p->ue_context.enb_gtp_addrs[e_rab], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[e_rab])); + ue_context_p->ue_context.enb_gtp_ebi[e_rab] = 0; + } + + itti_send_msg_to_task(TASK_GTPV1_U, ctxt_pP->module_id, msg_delete_tunnels_p); + struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; + rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[ctxt_pP->module_id], 0, eNB_ue_s1ap_id); + + if (rrc_ue_s1ap_ids != NULL) { + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[ctxt_pP->module_id], rrc_ue_s1ap_ids); + } + +#endif +#endif + rrc_release_info.RRC_release_ctrl[release_num].flag = 0; + rrc_release_info.num_UEs--; + break; // break for (release_num) + } // end if ((rrc_release_info.RRC_release_ctrl[release_num].flag > 2) && ... + + if (release_total >= rrc_release_info.num_UEs) { + break; // break for (release_num) } - } + } // end for (release_num) + } // end if (rrc_release_info.num_UEs > 0) - if (ue_context_p->ue_context.ue_release_timer>0) { - ue_context_p->ue_context.ue_release_timer++; - if (ue_context_p->ue_context.ue_release_timer >= - ue_context_p->ue_context.ue_release_timer_thres) { - LOG_I(RRC,"Removing UE %x instance\n",ue_context_p->ue_context.rnti); - ue_to_be_removed = ue_context_p; - ue_context_p->ue_context.ue_release_timer = 0; - break; - } + pthread_mutex_unlock(&rrc_release_freelist); + + if ((ue_context_p->ue_context.ue_rrc_inactivity_timer > 0) && (RC.rrc[ctxt_pP->module_id]->configuration.rrc_inactivity_timer_thres > 0)) { + ue_context_p->ue_context.ue_rrc_inactivity_timer++; // (un)comment this line to (de)activate the RRC inactivity timer + + if (ue_context_p->ue_context.ue_rrc_inactivity_timer >= RC.rrc[ctxt_pP->module_id]->configuration.rrc_inactivity_timer_thres) { + LOG_I(RRC, "Removing UE %x instance because of rrc_inactivity_timer timeout\n", + ue_context_p->ue_context.rnti); + ue_to_be_removed = ue_context_p; + break; // break RB_FOREACH } } - if (ue_to_be_removed) { - if(ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { - ue_to_be_removed->ue_context.ue_release_timer_s1 = 1; - ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100; - ue_to_be_removed->ue_context.ue_release_timer = 0; - ue_to_be_removed->ue_context.ue_reestablishment_timer = 0; + + if (ue_context_p->ue_context.ue_reestablishment_timer > 0) { + ue_context_p->ue_context.ue_reestablishment_timer++; + + if (ue_context_p->ue_context.ue_reestablishment_timer >= ue_context_p->ue_context.ue_reestablishment_timer_thres) { + LOG_I(RRC, "Removing UE %x instance because of reestablishment_timer timeout\n", + ue_context_p->ue_context.rnti); + ue_context_p->ue_context.ul_failure_timer = 20000; // lead to send S1 UE_CONTEXT_RELEASE_REQ + ue_to_be_removed = ue_context_p; + ue_context_p->ue_context.ue_reestablishment_timer = 0; + break; // break RB_FOREACH } - rrc_eNB_free_UE(ctxt_pP->module_id,ue_to_be_removed); - if(ue_to_be_removed->ue_context.ul_failure_timer >= 20000){ - ue_to_be_removed->ue_context.ul_failure_timer = 0; + } + + if (ue_context_p->ue_context.ue_release_timer > 0) { + ue_context_p->ue_context.ue_release_timer++; + + if (ue_context_p->ue_context.ue_release_timer >= ue_context_p->ue_context.ue_release_timer_thres) { + LOG_I(RRC, "Removing UE %x instance because of RRC Connection Setup timer timeout\n", + ue_context_p->ue_context.rnti); + /* + * TODO: Naming problem here: ue_release_timer seems to have been used when RRC Connection Release was sent. + * It is no more the case. + * The timer should be renamed. + */ + ue_to_be_removed = ue_context_p; + ue_context_p->ue_context.ue_release_timer = 0; + break; // break RB_FOREACH } } + } // end RB_FOREACH + + if (ue_to_be_removed) { + if ((ue_to_be_removed->ue_context.ul_failure_timer >= 20000) || + ((ue_to_be_removed->ue_context.ue_rrc_inactivity_timer >= RC.rrc[ctxt_pP->module_id]->configuration.rrc_inactivity_timer_thres) && + (RC.rrc[ctxt_pP->module_id]->configuration.rrc_inactivity_timer_thres > 0))) { + ue_to_be_removed->ue_context.ue_release_timer_s1 = 1; + ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100; + ue_to_be_removed->ue_context.ue_release_timer = 0; + ue_to_be_removed->ue_context.ue_reestablishment_timer = 0; + } -#ifdef RRC_LOCALIZATION + rrc_eNB_free_UE(ctxt_pP->module_id, ue_to_be_removed); - /* for the localization, only primary CC_id might be relevant*/ - gettimeofday(&ts, NULL); - current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; - ref_timestamp_ms = RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms; - RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { - ctxt = *ctxt_pP; - ctxt.rnti = ue_context_p->ue_context.rnti; - estimated_distance = rrc_get_estimated_ue_distance( - &ctxt, - CC_id, - RC.rrc[ctxt_pP->module_id]->loc_type); - - if ((current_timestamp_ms - ref_timestamp_ms > RC.rrc[ctxt_pP->module_id]->aggregation_period_ms) && - estimated_distance != -1) { - LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", - ctxt.rnti, - ctxt_pP->module_id, - current_timestamp_ms, - ctxt_pP->frame, - estimated_distance); - LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status); - push_front(&RC.rrc[ctxt_pP->module_id]->loc_list, - estimated_distance); - RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms; - } + if (ue_to_be_removed->ue_context.ul_failure_timer >= 20000) { + ue_to_be_removed->ue_context.ul_failure_timer = 0; } -#endif - (void)ts; /* remove gcc warning "unused variable" */ - (void)ref_timestamp_ms; /* remove gcc warning "unused variable" */ - (void)current_timestamp_ms; /* remove gcc warning "unused variable" */ + if ((ue_to_be_removed->ue_context.ue_rrc_inactivity_timer >= RC.rrc[ctxt_pP->module_id]->configuration.rrc_inactivity_timer_thres) && + (RC.rrc[ctxt_pP->module_id]->configuration.rrc_inactivity_timer_thres > 0)) { + ue_to_be_removed->ue_context.ue_rrc_inactivity_timer = 0; //reset timer after S1 command UE context release request is sent + } + } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); - return (RRC_OK); +#ifdef RRC_LOCALIZATION + /* for the localization, only primary CC_id might be relevant*/ + gettimeofday(&ts, NULL); + current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; + ref_timestamp_ms = RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms; + RB_FOREACH(ue_context_p, rrc_ue_tree_s, &(RC.rrc[ctxt_pP->module_id]->rrc_ue_head)) { + ctxt = *ctxt_pP; + ctxt.rnti = ue_context_p->ue_context.rnti; + estimated_distance = rrc_get_estimated_ue_distance(&ctxt, CC_id, RC.rrc[ctxt_pP->module_id]->loc_type); + + if ((current_timestamp_ms - ref_timestamp_ms > RC.rrc[ctxt_pP->module_id]->aggregation_period_ms) && + estimated_distance != -1) { + LOG_D(LOCALIZE, "RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", + ctxt.rnti, + ctxt_pP->module_id, + current_timestamp_ms, + ctxt_pP->frame, + estimated_distance); + LOG_D(LOCALIZE, "RRC status %d\n", + ue_context_p->ue_context.Status); + push_front(&RC.rrc[ctxt_pP->module_id]->loc_list, estimated_distance); + RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms; + } // end if + } // end RB_FOREACH +#endif + (void)ts; /* remove gcc warning "unused variable" */ + (void)ref_timestamp_ms; /* remove gcc warning "unused variable" */ + (void)current_timestamp_ms; /* remove gcc warning "unused variable" */ + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX, VCD_FUNCTION_OUT); + return RRC_OK; } diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index 83ae4fff40e5b936079c89db6e2168efb42c78e2..56219d9ebd73182501bb9259692bd6d331bf3e31 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -37,18 +37,22 @@ # include "enb_config.h" # include "common/ran_context.h" -# if defined(ENABLE_ITTI) -# include "asn1_conversions.h" -# include "intertask_interface.h" -# include "pdcp.h" -# include "pdcp_primitives.h" -# include "s1ap_eNB.h" -# else -# include "../../S1AP/s1ap_eNB.h" -# endif +# include "s1ap_eNB_defs.h" +# include "s1ap_eNB_management_procedures.h" +# include "s1ap_eNB_ue_context.h" + +#if defined(ENABLE_ITTI) + #include "asn1_conversions.h" + #include "intertask_interface.h" + #include "pdcp.h" + #include "pdcp_primitives.h" + #include "s1ap_eNB.h" +#else + #include "../../S1AP/s1ap_eNB.h" +#endif #if defined(ENABLE_SECURITY) -# include "UTIL/OSA/osa_defs.h" + #include "UTIL/OSA/osa_defs.h" #endif #include "msc.h" @@ -75,32 +79,29 @@ static const uint16_t S1AP_INTEGRITY_EIA1_MASK = 0x8000; static const uint16_t S1AP_INTEGRITY_EIA2_MASK = 0x4000; #if (LTE_RRC_VERSION >= MAKE_VERSION(9, 2, 0)) -# define INTEGRITY_ALGORITHM_NONE LTE_SecurityAlgorithmConfig__integrityProtAlgorithm_eia0_v920 + #define INTEGRITY_ALGORITHM_NONE LTE_SecurityAlgorithmConfig__integrityProtAlgorithm_eia0_v920 #else -#ifdef EXMIMO_IOT -# define INTEGRITY_ALGORITHM_NONE LTE_SecurityAlgorithmConfig__integrityProtAlgorithm_eia2 -#else -# define INTEGRITY_ALGORITHM_NONE LTE_SecurityAlgorithmConfig__integrityProtAlgorithm_reserved -#endif + #ifdef EXMIMO_IOT + #define INTEGRITY_ALGORITHM_NONE LTE_SecurityAlgorithmConfig__integrityProtAlgorithm_eia2 + #else + #define INTEGRITY_ALGORITHM_NONE LTE_SecurityAlgorithmConfig__integrityProtAlgorithm_reserved + #endif #endif -void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_context_pP) -{ +void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_context_pP) { /* Process NAS message locally to get the IMSI */ nas_message_t nas_msg; memset(&nas_msg, 0, sizeof(nas_message_t)); - int size = 0; - nas_message_security_header_t *header = &nas_msg.header; /* Decode the first octet of the header (security header type or EPS * bearer identity, and protocol discriminator) */ - DECODE_U8((char *) pdu_buf, *(uint8_t*) (header), size); + DECODE_U8((char *) pdu_buf, *(uint8_t *) (header), size); /* Decode NAS message only if decodable*/ if (!(header->security_header_type <= SECURITY_HEADER_TYPE_INTEGRITY_PROTECTED - && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE - && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE)) + && header->protocol_discriminator == EPS_MOBILITY_MANAGEMENT_MESSAGE + && pdu_len > NAS_MESSAGE_SECURITY_HEADER_SIZE)) return; if (header->security_header_type != SECURITY_HEADER_TYPE_NOT_PROTECTED) { @@ -114,11 +115,9 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c * can modify it as we want. The callee retains the original address! */ pdu_buf += size; pdu_len -= size; - /* Decode plain NAS message */ EMM_msg *e_msg = &nas_msg.plain.emm; emm_msg_header_t *emm_header = &e_msg->header; - /* First decode the EMM message header */ int e_head_size = 0; @@ -161,9 +160,13 @@ void extract_imsi(uint8_t *pdu_buf, uint32_t pdu_len, rrc_eNB_ue_context_t *ue_c # if defined(ENABLE_ITTI) //------------------------------------------------------------------------------ -struct rrc_ue_s1ap_ids_s* +/* +* Get the UE S1 struct containing hashtables S1_id/UE_id. +* Is also used to set the S1_id of the UE, depending on inputs. +*/ +struct rrc_ue_s1ap_ids_s * rrc_eNB_S1AP_get_ue_ids( - eNB_RRC_INST* const rrc_instance_pP, + eNB_RRC_INST *const rrc_instance_pP, const uint16_t ue_initial_id, const uint32_t eNB_ue_s1ap_id ) @@ -171,48 +174,136 @@ rrc_eNB_S1AP_get_ue_ids( { rrc_ue_s1ap_ids_t *result = NULL; rrc_ue_s1ap_ids_t *result2 = NULL; + /*****************************/ + instance_t instance = 0; + s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL; + s1ap_eNB_ue_context_t *ue_desc_p = NULL; + rrc_eNB_ue_context_t *ue_context_p = NULL; + /*****************************/ hashtable_rc_t h_rc; - // we assume that a rrc_ue_s1ap_ids_s is initially inserted in initial_id2_s1ap_ids - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result); - } if (ue_initial_id != UE_INITIAL_ID_INVALID) { - h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void**)&result); - if (h_rc == HASH_TABLE_OK) { - if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void**)&result2); - if (h_rc != HASH_TABLE_OK) { - result2 = malloc(sizeof(*result2)); - if (NULL != result2) { - *result2 = *result; - result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id; - result->eNB_ue_s1ap_id = eNB_ue_s1ap_id; - h_rc = hashtable_insert(rrc_instance_pP->s1ap_id2_s1ap_ids, - (hash_key_t)eNB_ue_s1ap_id, - result2); + h_rc = hashtable_get(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id, (void **)&result); + + if (h_rc == HASH_TABLE_OK) { + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&result2); + + if (h_rc != HASH_TABLE_OK) { // this case is equivalent to associate eNB_ue_s1ap_id and ue_initial_id + result2 = malloc(sizeof(*result2)); + + if (NULL != result2) { + *result2 = *result; + result2->eNB_ue_s1ap_id = eNB_ue_s1ap_id; + result->eNB_ue_s1ap_id = eNB_ue_s1ap_id; + h_rc = hashtable_insert(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, result2); + if (h_rc != HASH_TABLE_OK) { LOG_E(S1AP, "[eNB %ld] Error while hashtable_insert in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32"\n", - rrc_instance_pP - RC.rrc[0], eNB_ue_s1ap_id); + rrc_instance_pP - RC.rrc[0], + eNB_ue_s1ap_id); } - } - } - } - } - } + } + } else { // here we should check that the association was done correctly + if ((result->ue_initial_id != result2->ue_initial_id) || (result->eNB_ue_s1ap_id != result2->eNB_ue_s1ap_id)) { + LOG_E(S1AP, "[eNB %ld] Error while hashtable_get, two rrc_ue_s1ap_ids_t that should be equal, are not:\n \ + ue_initial_id 1 = %"PRIu16",\n \ + ue_initial_id 2 = %"PRIu16",\n \ + eNB_ue_s1ap_id 1 = %"PRIu32",\n \ + eNB_ue_s1ap_id 2 = %"PRIu32"\n", + rrc_instance_pP - RC.rrc[0], + result->ue_initial_id, + result2->ue_initial_id, + result->eNB_ue_s1ap_id, + result2->eNB_ue_s1ap_id); + + // Still return *result + } + } + } // end if if (eNB_ue_s1ap_id > 0) + } else { // end if (h_rc == HASH_TABLE_OK) + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in initial_id2_s1ap_ids ue_initial_id %"PRIu16"\n", + rrc_instance_pP - RC.rrc[0], + ue_initial_id); + + return NULL; + /* + * At the moment this is written, this case shouldn't (cannot) happen and is equivalent to an error. + * One could try to find the struct instance based on s1ap_id2_s1ap_ids and eNB_ue_s1ap_id (if > 0), + * but this behavior is not expected at the moment. + */ + } // end else (h_rc != HASH_TABLE_OK) + } else { // end if (ue_initial_id != UE_INITIAL_ID_INVALID) + if (eNB_ue_s1ap_id > 0) { + h_rc = hashtable_get(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id, (void **)&result); + + if (h_rc != HASH_TABLE_OK) { + /* + * This case is uncommon, but can happen when: + * -> if the first NAS message was a Detach Request (non exhaustiv), the UE RRC context exist + * but is not associated with eNB_ue_s1ap_id + * -> ... (?) + */ + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", trying to find it through S1AP context\n", + rrc_instance_pP - RC.rrc[0], + eNB_ue_s1ap_id); + instance = ENB_MODULE_ID_TO_INSTANCE(rrc_instance_pP - RC.rrc[0]); // get eNB instance + s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); // get s1ap_eNB_instance + + if (s1ap_eNB_instance_p != NULL) { + ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, eNB_ue_s1ap_id); // get s1ap_eNB_ue_context + } else { + LOG_E(S1AP, "[eNB instance %d] Couldn't find the eNB S1AP context\n", + instance); + + return NULL; + } + + if (ue_desc_p != NULL) { + result = rrc_eNB_S1AP_get_ue_ids(rrc_instance_pP, ue_desc_p->ue_initial_id, eNB_ue_s1ap_id); + + if (result != NULL) { + ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instance)], result->ue_rnti); + + if ((ue_context_p != NULL) && (ue_context_p->ue_context.eNB_ue_s1ap_id == 0)) { + ue_context_p->ue_context.eNB_ue_s1ap_id = eNB_ue_s1ap_id; + } else { + LOG_E(RRC, "[eNB %ld] Incoherence between RRC context and S1AP context (%d != %d) for UE RNTI %d or UE RRC context doesn't exist\n", + rrc_instance_pP - RC.rrc[0], + ue_context_p->ue_context.eNB_ue_s1ap_id, + eNB_ue_s1ap_id, + result->ue_rnti); + } + } + } else { + LOG_E(S1AP, "[eNB %ld] In hashtable_get, couldn't find in s1ap_id2_s1ap_ids eNB_ue_s1ap_id %"PRIu32", even when looking at S1AP context\n", + rrc_instance_pP - RC.rrc[0], + eNB_ue_s1ap_id); + + return NULL; + } + } // end if (h_rc != HASH_TABLE_OK) + } // end if (eNB_ue_s1ap_id > 0) + } // end else (ue_initial_id == UE_INITIAL_ID_INVALID) + return result; } + //------------------------------------------------------------------------------ +/* +* Remove UE ids (ue_initial_id and S1_id) from hashtables. +*/ void rrc_eNB_S1AP_remove_ue_ids( - eNB_RRC_INST* const rrc_instance_pP, - struct rrc_ue_s1ap_ids_s* const ue_ids_pP + eNB_RRC_INST *const rrc_instance_pP, + struct rrc_ue_s1ap_ids_s *const ue_ids_pP ) //------------------------------------------------------------------------------ { const uint16_t ue_initial_id = ue_ids_pP->ue_initial_id; const uint32_t eNB_ue_s1ap_id = ue_ids_pP->eNB_ue_s1ap_id; hashtable_rc_t h_rc; + if (rrc_instance_pP == NULL) { LOG_E(RRC, "Bad RRC instance\n"); return; @@ -224,21 +315,23 @@ rrc_eNB_S1AP_remove_ue_ids( } if (eNB_ue_s1ap_id > 0) { - h_rc = hashtable_remove(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id); - if (h_rc != HASH_TABLE_OK) { - LOG_W(RRC, "S1AP Did not find entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); - } else { - LOG_W(RRC, "S1AP removed entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); - } + h_rc = hashtable_remove(rrc_instance_pP->s1ap_id2_s1ap_ids, (hash_key_t)eNB_ue_s1ap_id); + + if (h_rc != HASH_TABLE_OK) { + LOG_W(RRC, "S1AP Did not find entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); + } else { + LOG_W(RRC, "S1AP removed entry in hashtable s1ap_id2_s1ap_ids for eNB_ue_s1ap_id %u\n", eNB_ue_s1ap_id); + } } if (ue_initial_id != UE_INITIAL_ID_INVALID) { h_rc = hashtable_remove(rrc_instance_pP->initial_id2_s1ap_ids, (hash_key_t)ue_initial_id); - if (h_rc != HASH_TABLE_OK) { - LOG_W(RRC, "S1AP Did not find entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); - } else { - LOG_W(RRC, "S1AP removed entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); - } + + if (h_rc != HASH_TABLE_OK) { + LOG_W(RRC, "S1AP Did not find entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); + } else { + LOG_W(RRC, "S1AP removed entry in hashtable initial_id2_s1ap_ids for ue_initial_id %u\n", ue_initial_id); + } } } @@ -276,25 +369,17 @@ get_next_ue_initial_id( *\param eNB_ue_s1ap_id The value sent by S1AP. *\return the UE index or UE_INDEX_INVALID if not found. */ -static struct rrc_eNB_ue_context_s* +static struct rrc_eNB_ue_context_s * rrc_eNB_get_ue_context_from_s1ap_ids( const instance_t instanceP, const uint16_t ue_initial_idP, const uint32_t eNB_ue_s1ap_idP -) -{ - rrc_ue_s1ap_ids_t* temp = NULL; - temp = - rrc_eNB_S1AP_get_ue_ids( - RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], - ue_initial_idP, - eNB_ue_s1ap_idP); - - if (temp) { - - return rrc_eNB_get_ue_context( - RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], - temp->ue_rnti); +) { + rrc_ue_s1ap_ids_t *temp = NULL; + temp = rrc_eNB_S1AP_get_ue_ids(RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], ue_initial_idP, eNB_ue_s1ap_idP); + + if (temp != NULL) { + return rrc_eNB_get_ue_context(RC.rrc[ENB_INSTANCE_TO_MODULE_ID(instanceP)], temp->ue_rnti); } return NULL; @@ -305,10 +390,8 @@ rrc_eNB_get_ue_context_from_s1ap_ids( *\param algorithms The bit mask of available algorithms received from S1AP. *\return the selected algorithm. */ -static LTE_CipheringAlgorithm_r12_t rrc_eNB_select_ciphering(uint16_t algorithms) -{ - -//#warning "Forced return SecurityAlgorithmConfig__cipheringAlgorithm_eea0, to be deleted in future" +static LTE_CipheringAlgorithm_r12_t rrc_eNB_select_ciphering(uint16_t algorithms) { + //#warning "Forced return SecurityAlgorithmConfig__cipheringAlgorithm_eea0, to be deleted in future" return LTE_CipheringAlgorithm_r12_eea0; if (algorithms & S1AP_ENCRYPTION_EEA2_MASK) { @@ -327,9 +410,7 @@ static LTE_CipheringAlgorithm_r12_t rrc_eNB_select_ciphering(uint16_t algorithms *\param algorithms The bit mask of available algorithms received from S1AP. *\return the selected algorithm. */ -static e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm rrc_eNB_select_integrity(uint16_t algorithms) -{ - +static e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm rrc_eNB_select_integrity(uint16_t algorithms) { if (algorithms & S1AP_INTEGRITY_EIA2_MASK) { return LTE_SecurityAlgorithmConfig__integrityProtAlgorithm_eia2; } @@ -350,18 +431,15 @@ static e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm rrc_eNB_select_inte */ static int rrc_eNB_process_security( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - security_capabilities_t* security_capabilities_pP -) -{ + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + security_capabilities_t *security_capabilities_pP +) { boolean_t changed = FALSE; LTE_CipheringAlgorithm_r12_t cipheringAlgorithm; e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm integrityProtAlgorithm; - /* Save security parameters */ ue_context_pP->ue_context.security_capabilities = *security_capabilities_pP; - // translation LOG_D(RRC, "[eNB %d] NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n", @@ -392,7 +470,6 @@ rrc_eNB_process_security( (unsigned long)cipheringAlgorithm, integrityProtAlgorithm, changed ? "changed" : "same"); - return changed; } @@ -404,16 +481,15 @@ rrc_eNB_process_security( */ //------------------------------------------------------------------------------ static void process_eNB_security_key ( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t* security_key_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t *security_key_pP ) //------------------------------------------------------------------------------ { #if defined(ENABLE_SECURITY) char ascii_buffer[65]; uint8_t i; - /* Saves the security key */ memcpy (ue_context_pP->ue_context.kenb, security_key_pP, SECURITY_KEY_LENGTH); memset (ue_context_pP->ue_context.nh, 0, SECURITY_KEY_LENGTH); @@ -424,7 +500,6 @@ static void process_eNB_security_key ( } ascii_buffer[2 * i] = '\0'; - LOG_I (RRC, "[eNB %d][UE %x] Saved security key %s\n", ctxt_pP->module_id, ue_context_pP->ue_context.rnti, ascii_buffer); #endif } @@ -433,17 +508,14 @@ static void process_eNB_security_key ( //------------------------------------------------------------------------------ void rrc_pdcp_config_security( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, const uint8_t send_security_mode_command ) //------------------------------------------------------------------------------ { - #if defined(ENABLE_SECURITY) - - - LTE_SRB_ToAddModList_t* SRB_configList = ue_context_pP->ue_context.SRB_configList; + LTE_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; @@ -465,16 +537,13 @@ rrc_pdcp_config_security( derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, ue_context_pP->ue_context.kenb, &kRRCint); - #if !defined(USRP_REC_PLAY) SET_LOG_DUMP(DEBUG_SECURITY) ; #endif - if ( LOG_DUMPFLAG( DEBUG_SECURITY ) ) { if (print_keys ==1 ) { print_keys =0; - LOG_DUMPMSG(RRC, DEBUG_SECURITY, ue_context_pP->ue_context.kenb, 32,"\nKeNB:" ); LOG_DUMPMSG(RRC, DEBUG_SECURITY, kRRCenc, 32,"\nKRRCenc:" ); LOG_DUMPMSG(RRC, DEBUG_SECURITY, kRRCint, 32,"\nKRRCint:" ); @@ -482,8 +551,7 @@ rrc_pdcp_config_security( } key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, ctxt_pP->enb_flag, DCCH, 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) { pdcp_config_set_security( @@ -511,8 +579,8 @@ rrc_pdcp_config_security( //------------------------------------------------------------------------------ void rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP ) //------------------------------------------------------------------------------ { @@ -520,7 +588,6 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( int e_rab; int e_rabs_done = 0; int e_rabs_failed = 0; - msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_INITIAL_CONTEXT_SETUP_RESP); S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; @@ -551,11 +618,8 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( ue_context_pP->ue_id_rnti, S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).eNB_ue_s1ap_id, e_rabs_done, e_rabs_failed); - - S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done; S1AP_INITIAL_CONTEXT_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; - itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } # endif @@ -563,9 +627,9 @@ rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP( //------------------------------------------------------------------------------ void rrc_eNB_send_S1AP_UPLINK_NAS( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_UL_DCCH_Message_t* const ul_dcch_msg + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_UL_DCCH_Message_t *const ul_dcch_msg ) //------------------------------------------------------------------------------ { @@ -574,29 +638,25 @@ rrc_eNB_send_S1AP_UPLINK_NAS( LTE_ULInformationTransfer_t *ulInformationTransfer = &ul_dcch_msg->message.choice.c1.choice.ulInformationTransfer; if ((ulInformationTransfer->criticalExtensions.present == LTE_ULInformationTransfer__criticalExtensions_PR_c1) - && (ulInformationTransfer->criticalExtensions.choice.c1.present - == LTE_ULInformationTransfer__criticalExtensions__c1_PR_ulInformationTransfer_r8) - && (ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.present - == LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) { + && (ulInformationTransfer->criticalExtensions.choice.c1.present + == LTE_ULInformationTransfer__criticalExtensions__c1_PR_ulInformationTransfer_r8) + && (ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType.present + == LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) { /* This message hold a dedicated info NAS payload, forward it to NAS */ struct LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType = - &ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType; + &ulInformationTransfer->criticalExtensions.choice.c1.choice.ulInformationTransfer_r8.dedicatedInfoType; uint32_t pdu_length; uint8_t *pdu_buffer; MessageDef *msg_p; - pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size; pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf; - msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UPLINK_NAS); S1AP_UPLINK_NAS (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; S1AP_UPLINK_NAS (msg_p).nas_pdu.length = pdu_length; S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer = pdu_buffer; - extract_imsi(S1AP_UPLINK_NAS (msg_p).nas_pdu.buffer, S1AP_UPLINK_NAS (msg_p).nas_pdu.length, ue_context_pP); - itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } } @@ -608,10 +668,9 @@ rrc_eNB_send_S1AP_UPLINK_NAS( ulInformationTransfer; if (ulInformationTransfer->criticalExtensions.present == - LTE_ULInformationTransfer__criticalExtensions_PR_c1) { + LTE_ULInformationTransfer__criticalExtensions_PR_c1) { if (ulInformationTransfer->criticalExtensions.choice.c1.present == - LTE_ULInformationTransfer__criticalExtensions__c1_PR_ulInformationTransfer_r8) { - + LTE_ULInformationTransfer__criticalExtensions__c1_PR_ulInformationTransfer_r8) { ULInformationTransfer_r8_IEs_t *ulInformationTransferR8; ulInformationTransferR8 = @@ -620,14 +679,12 @@ rrc_eNB_send_S1AP_UPLINK_NAS( if (ulInformationTransferR8->dedicatedInfoType.present == LTE_ULInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS) { - extract_imsi(ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size, ue_context_pP); - s1ap_eNB_new_data_request (mod_id, ue_index, - ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, - ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size); + ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.buf, + ulInformationTransferR8->dedicatedInfoType.choice.dedicatedInfoNAS.size); } } } @@ -637,9 +694,9 @@ rrc_eNB_send_S1AP_UPLINK_NAS( //------------------------------------------------------------------------------ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_UL_DCCH_Message_t* ul_dcch_msg + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_UL_DCCH_Message_t *ul_dcch_msg ) //------------------------------------------------------------------------------ { @@ -660,15 +717,14 @@ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( if (ret.encoded == -1) abort(); memset(&rac, 0, sizeof(LTE_UERadioAccessCapabilityInformation_t)); - rac.criticalExtensions.present = LTE_UERadioAccessCapabilityInformation__criticalExtensions_PR_c1; rac.criticalExtensions.choice.c1.present = LTE_UERadioAccessCapabilityInformation__criticalExtensions__c1_PR_ueRadioAccessCapabilityInformation_r8; rac.criticalExtensions.choice.c1.choice.ueRadioAccessCapabilityInformation_r8.ue_RadioAccessCapabilityInfo.buf = buf; rac.criticalExtensions.choice.c1.choice.ueRadioAccessCapabilityInformation_r8.ue_RadioAccessCapabilityInfo.size = (ret.encoded+7)/8; rac.criticalExtensions.choice.c1.choice.ueRadioAccessCapabilityInformation_r8.nonCriticalExtension = NULL; - /* 8192 is arbitrary, should be big enough */ buf2 = malloc16(8192); + if (buf2 == NULL) abort(); ret = uper_encode_to_buffer(&asn_DEF_LTE_UERadioAccessCapabilityInformation, NULL, &rac, buf2, 8192); @@ -676,84 +732,78 @@ void rrc_eNB_send_S1AP_UE_CAPABILITIES_IND( if (ret.encoded == -1) abort(); MessageDef *msg_p; - msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UE_CAPABILITIES_IND); S1AP_UE_CAPABILITIES_IND (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; S1AP_UE_CAPABILITIES_IND (msg_p).ue_radio_cap.length = (ret.encoded+7)/8; S1AP_UE_CAPABILITIES_IND (msg_p).ue_radio_cap.buffer = buf2; - itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } //------------------------------------------------------------------------------ +/* +* Initial UE NAS message on S1AP. +*/ void rrc_eNB_send_S1AP_NAS_FIRST_REQ( - const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - LTE_RRCConnectionSetupComplete_r8_IEs_t* rrcConnectionSetupComplete + const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + LTE_RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete ) //------------------------------------------------------------------------------ - - { - eNB_RRC_INST *rrc=RC.rrc[ctxt_pP->module_id]; + eNB_RRC_INST *rrc = RC.rrc[ctxt_pP->module_id]; #if defined(ENABLE_ITTI) { - MessageDef* message_p = NULL; - rrc_ue_s1ap_ids_t* rrc_ue_s1ap_ids_p = NULL; + MessageDef *message_p = NULL; + rrc_ue_s1ap_ids_t *rrc_ue_s1ap_ids_p = NULL; hashtable_rc_t h_rc; - - message_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_NAS_FIRST_REQ); + message_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_NAS_FIRST_REQ); memset(&message_p->ittiMsg.s1ap_nas_first_req, 0, sizeof(s1ap_nas_first_req_t)); - - ue_context_pP->ue_context.ue_initial_id = get_next_ue_initial_id (ctxt_pP->module_id); - S1AP_NAS_FIRST_REQ (message_p).ue_initial_id = ue_context_pP->ue_context.ue_initial_id; - + ue_context_pP->ue_context.ue_initial_id = get_next_ue_initial_id(ctxt_pP->module_id); + S1AP_NAS_FIRST_REQ(message_p).ue_initial_id = ue_context_pP->ue_context.ue_initial_id; rrc_ue_s1ap_ids_p = malloc(sizeof(*rrc_ue_s1ap_ids_p)); rrc_ue_s1ap_ids_p->ue_initial_id = ue_context_pP->ue_context.ue_initial_id; rrc_ue_s1ap_ids_p->eNB_ue_s1ap_id = UE_INITIAL_ID_INVALID; rrc_ue_s1ap_ids_p->ue_rnti = ctxt_pP->rnti; - h_rc = hashtable_insert(RC.rrc[ctxt_pP->module_id]->initial_id2_s1ap_ids, - (hash_key_t)ue_context_pP->ue_context.ue_initial_id, - rrc_ue_s1ap_ids_p); + (hash_key_t)ue_context_pP->ue_context.ue_initial_id, + rrc_ue_s1ap_ids_p); + if (h_rc != HASH_TABLE_OK) { LOG_E(S1AP, "[eNB %d] Error while hashtable_insert in initial_id2_s1ap_ids ue_initial_id %u\n", - ctxt_pP->module_id, ue_context_pP->ue_context.ue_initial_id); + ctxt_pP->module_id, + ue_context_pP->ue_context.ue_initial_id); } /* Assume that cause is coded in the same way in RRC and S1ap, just check that the value is in S1ap range */ AssertFatal(ue_context_pP->ue_context.establishment_cause < RRC_CAUSE_LAST, - "Establishment cause invalid (%jd/%d) for eNB %d!", - ue_context_pP->ue_context.establishment_cause, RRC_CAUSE_LAST, ctxt_pP->module_id); - + "Establishment cause invalid (%jd/%d) for eNB %d!", + ue_context_pP->ue_context.establishment_cause, + RRC_CAUSE_LAST, + ctxt_pP->module_id); S1AP_NAS_FIRST_REQ (message_p).establishment_cause = ue_context_pP->ue_context.establishment_cause; - - /* Forward NAS message */S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer = - rrcConnectionSetupComplete->dedicatedInfoNAS.buf; + /* Forward NAS message */ + S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer = rrcConnectionSetupComplete->dedicatedInfoNAS.buf; S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length = rrcConnectionSetupComplete->dedicatedInfoNAS.size; - extract_imsi(S1AP_NAS_FIRST_REQ (message_p).nas_pdu.buffer, S1AP_NAS_FIRST_REQ (message_p).nas_pdu.length, ue_context_pP); - /* Fill UE identities with available information */ { S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask = UE_IDENTITIES_NONE; if (ue_context_pP->ue_context.Initialue_identity_s_TMSI.presence) { /* Fill s-TMSI */ - UE_S_TMSI* s_TMSI = &ue_context_pP->ue_context.Initialue_identity_s_TMSI; - + UE_S_TMSI *s_TMSI = &ue_context_pP->ue_context.Initialue_identity_s_TMSI; S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask |= UE_IDENTITIES_s_tmsi; S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code = s_TMSI->mme_code; S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi = s_TMSI->m_tmsi; LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ with s_TMSI: MME code %u M-TMSI %u ue %x\n", - ctxt_pP->module_id, - S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code, - S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi, - ue_context_pP->ue_context.rnti); - } + ctxt_pP->module_id, + S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.mme_code, + S1AP_NAS_FIRST_REQ (message_p).ue_identity.s_tmsi.m_tmsi, + ue_context_pP->ue_context.rnti); + } // end if S-TMSI presence /* selected_plmn_identity: IE is 1-based, convert to 0-based (C array) */ int selected_plmn_identity = rrcConnectionSetupComplete->selectedPLMN_Identity - 1; @@ -762,7 +812,6 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( if (rrcConnectionSetupComplete->registeredMME != NULL) { /* Fill GUMMEI */ struct LTE_RegisteredMME *r_mme = rrcConnectionSetupComplete->registeredMME; - S1AP_NAS_FIRST_REQ (message_p).ue_identity.presenceMask |= UE_IDENTITIES_gummei; if (r_mme->plmn_Identity != NULL) { @@ -770,9 +819,9 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( /* Use first indicated PLMN MCC if it is defined */ S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc = *r_mme->plmn_Identity->mcc->list.array[selected_plmn_identity]; LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI MCC %u ue %x\n", - ctxt_pP->module_id, - S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc, - ue_context_pP->ue_context.rnti); + ctxt_pP->module_id, + S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mcc, + ue_context_pP->ue_context.rnti); } if (r_mme->plmn_Identity->mnc.list.count > 0) { @@ -783,32 +832,29 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mnc, ue_context_pP->ue_context.rnti); } - } else { + } else { // end if plmn_Identity != NULL S1AP_NAS_FIRST_REQ(message_p).ue_identity.gummei.mcc = rrc->configuration.mcc[selected_plmn_identity]; S1AP_NAS_FIRST_REQ(message_p).ue_identity.gummei.mnc = rrc->configuration.mnc[selected_plmn_identity]; S1AP_NAS_FIRST_REQ(message_p).ue_identity.gummei.mnc_len = rrc->configuration.mnc_digit_length[selected_plmn_identity]; - } + } // end else (plmn_Identity == NULL) S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code = BIT_STRING_to_uint8 (&r_mme->mmec); S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id = BIT_STRING_to_uint16 (&r_mme->mmegi); - - MSC_LOG_TX_MESSAGE( - MSC_S1AP_ENB, - MSC_S1AP_MME, - (const char *)&message_p->ittiMsg.s1ap_nas_first_req, - sizeof(s1ap_nas_first_req_t), - MSC_AS_TIME_FMT" S1AP_NAS_FIRST_REQ eNB %u UE %x", - MSC_AS_TIME_ARGS(ctxt_pP), - ctxt_pP->module_id, - ctxt_pP->rnti); - + MSC_LOG_TX_MESSAGE(MSC_S1AP_ENB, + MSC_S1AP_MME, + (const char *)&message_p->ittiMsg.s1ap_nas_first_req, + sizeof(s1ap_nas_first_req_t), + MSC_AS_TIME_FMT" S1AP_NAS_FIRST_REQ eNB %u UE %x", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt_pP->module_id, + ctxt_pP->rnti); LOG_I(S1AP, "[eNB %d] Build S1AP_NAS_FIRST_REQ adding in s_TMSI: GUMMEI mme_code %u mme_group_id %u ue %x\n", ctxt_pP->module_id, S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_code, S1AP_NAS_FIRST_REQ (message_p).ue_identity.gummei.mme_group_id, ue_context_pP->ue_context.rnti); - } - } + } // end if MME info present + } // end "Fill UE identities with available information" sub-part itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, message_p); } #else @@ -828,10 +874,10 @@ rrc_eNB_send_S1AP_NAS_FIRST_REQ( //------------------------------------------------------------------------------ int rrc_eNB_process_S1AP_DOWNLINK_NAS( - MessageDef* msg_p, - const char* msg_name, + MessageDef *msg_p, + const char *msg_name, instance_t instance, - mui_t* rrc_eNB_mui + mui_t *rrc_eNB_mui ) //------------------------------------------------------------------------------ { @@ -839,15 +885,12 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( uint32_t eNB_ue_s1ap_id; uint32_t length; uint8_t *buffer; - uint8_t srb_id; - - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint8_t srb_id; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; ue_initial_id = S1AP_DOWNLINK_NAS (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); - - LOG_I(RRC, "[eNB %d] Received %s: ue_initial_id %d, eNB_ue_s1ap_id %d\n", instance, msg_name, @@ -855,7 +898,6 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( eNB_ue_s1ap_id); if (ue_context_p == NULL) { - MSC_LOG_RX_MESSAGE( MSC_RRC_ENB, MSC_S1AP_ENB, @@ -865,20 +907,14 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), ue_initial_id, eNB_ue_s1ap_id); - /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; - LOG_W(RRC, "[eNB %d] In S1AP_DOWNLINK_NAS: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id); - msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_NAS_NON_DELIVERY_IND); S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).nas_pdu.length = S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length; S1AP_NAS_NON_DELIVERY_IND (msg_fail_p).nas_pdu.buffer = S1AP_DOWNLINK_NAS (msg_p).nas_pdu.buffer; - // TODO add failure cause when defined! - - MSC_LOG_TX_MESSAGE( MSC_RRC_ENB, MSC_S1AP_ENB, @@ -888,14 +924,11 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), ue_initial_id, eNB_ue_s1ap_id); - itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); return (-1); } else { PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); - srb_id = ue_context_p->ue_context.Srb2.Srb_info.Srb_id; - /* Is it the first income from S1AP ? */ if (ue_context_p->ue_context.eNB_ue_s1ap_id == 0) { @@ -911,8 +944,6 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), ue_initial_id, S1AP_DOWNLINK_NAS (msg_p).eNB_ue_s1ap_id); - - /* Create message for PDCP (DLInformationTransfer_t) */ length = do_DLInformationTransfer ( instance, @@ -920,37 +951,32 @@ rrc_eNB_process_S1AP_DOWNLINK_NAS( rrc_eNB_get_next_transaction_identifier (instance), S1AP_DOWNLINK_NAS (msg_p).nas_pdu.length, S1AP_DOWNLINK_NAS (msg_p).nas_pdu.buffer); - LOG_DUMPMSG(RRC,DEBUG_RRC,buffer,length,"[MSG] RRC DL Information Transfer\n"); - - /* - * switch UL or DL NAS message without RRC piggybacked to SRB2 if active. + /* + * switch UL or DL NAS message without RRC piggybacked to SRB2 if active. */ /* Transfer data to PDCP */ rrc_data_req ( - &ctxt, - srb_id, - *rrc_eNB_mui++, - SDU_CONFIRM_NO, - length, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - + &ctxt, + srb_id, + *rrc_eNB_mui++, + SDU_CONFIRM_NO, + length, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); return (0); } } /*------------------------------------------------------------------------------*/ -int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) -{ +int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) { uint16_t ue_initial_id; uint32_t eNB_ue_s1ap_id; //MessageDef *message_gtpv1u_p = NULL; gtpv1u_enb_create_tunnel_req_t create_tunnel_req; gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; - uint8_t inde_list[NB_RB_MAX - 3]={0}; - - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint8_t inde_list[NB_RB_MAX - 3]= {0}; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; ue_initial_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; @@ -961,63 +987,49 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p = NULL; - LOG_W(RRC, "[eNB %d] In S1AP_INITIAL_CONTEXT_SETUP_REQ: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id); - msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_INITIAL_CONTEXT_SETUP_FAIL); S1AP_INITIAL_CONTEXT_SETUP_FAIL (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - // TODO add failure cause when defined! - itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); return (-1); } else { - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).eNB_ue_s1ap_id; - /* Save e RAB information for later */ { int i; - - memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); + memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); ue_context_p->ue_context.nb_of_e_rabs = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).nb_of_e_rabs; - + for (i = 0; i < ue_context_p->ue_context.nb_of_e_rabs; i++) { ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW; ue_context_p->ue_context.e_rab[i].param = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i]; - - create_tunnel_req.eps_bearer_id[i] = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].e_rab_id; create_tunnel_req.sgw_S1u_teid[i] = S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].gtp_teid; - memcpy(&create_tunnel_req.sgw_addr[i], &S1AP_INITIAL_CONTEXT_SETUP_REQ (msg_p).e_rab_param[i].sgw_addr, sizeof(transport_layer_addr_t)); inde_list[create_tunnel_req.num_tunnels]= i; create_tunnel_req.num_tunnels++; } - - create_tunnel_req.rnti = ue_context_p->ue_context.rnti; // warning put zero above -// create_tunnel_req.num_tunnels = i; + create_tunnel_req.rnti = ue_context_p->ue_context.rnti; // warning put zero above + // create_tunnel_req.num_tunnels = i; gtpv1u_create_s1u_tunnel( instance, &create_tunnel_req, &create_tunnel_resp); - rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( - &ctxt, - &create_tunnel_resp, - &inde_list[0]); + &ctxt, + &create_tunnel_resp, + &inde_list[0]); ue_context_p->ue_context.setup_e_rabs=ue_context_p->ue_context.nb_of_e_rabs; } - /* TODO parameters yet to process ... */ { // S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr; } - rrc_eNB_process_security ( &ctxt, ue_context_p, @@ -1026,10 +1038,8 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char &ctxt, ue_context_p, S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).security_key); - { uint8_t send_security_mode_command = TRUE; - #ifndef EXMIMO_IOT if ((ue_context_p->ue_context.ciphering_algorithm == SecurityAlgorithmConfig__cipheringAlgorithm_eea0) @@ -1044,7 +1054,6 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char send_security_mode_command); if (send_security_mode_command) { - rrc_eNB_generate_SecurityModeCommand ( &ctxt, ue_context_p); @@ -1063,30 +1072,23 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char } /*------------------------------------------------------------------------------*/ -int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) -{ +int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) { uint32_t eNB_ue_s1ap_id; - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; - eNB_ue_s1ap_id = S1AP_UE_CTXT_MODIFICATION_REQ (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; - LOG_W(RRC, "[eNB %d] In S1AP_UE_CTXT_MODIFICATION_REQ: unknown UE from eNB_ue_s1ap_id (%d)\n", instance, eNB_ue_s1ap_id); - msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_UE_CTXT_MODIFICATION_FAIL); S1AP_UE_CTXT_MODIFICATION_FAIL (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - // TODO add failure cause when defined! - itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); return (-1); } else { - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); /* TODO parameters yet to process ... */ { @@ -1112,85 +1114,72 @@ int rrc_eNB_process_S1AP_UE_CTXT_MODIFICATION_REQ(MessageDef *msg_p, const char &ctxt, ue_context_p, S1AP_UE_CTXT_MODIFICATION_REQ(msg_p).security_key); - /* TODO reconfigure lower layers... */ } /* Send the response */ { MessageDef *msg_resp_p; - msg_resp_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CTXT_MODIFICATION_RESP); S1AP_UE_CTXT_MODIFICATION_RESP(msg_resp_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - itti_send_msg_to_task(TASK_S1AP, instance, msg_resp_p); } - return (0); } } /*------------------------------------------------------------------------------*/ -int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char *msg_name, instance_t instance) -{ +int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_REQ (MessageDef *msg_p, const char *msg_name, instance_t instance) { uint32_t eNB_ue_s1ap_id; - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - + struct rrc_eNB_ue_context_s *ue_context_p = NULL; eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_REQ(msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p; - LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_REQ: unknown UE from eNB_ue_s1ap_id (%d)\n", instance, eNB_ue_s1ap_id); - msg_fail_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_RESP); /* TODO change message ID. */ S1AP_UE_CONTEXT_RELEASE_RESP(msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - // TODO add failure cause when defined! - itti_send_msg_to_task(TASK_S1AP, instance, msg_fail_p); return (-1); } else { /* TODO release context. */ - /* Send the response */ { MessageDef *msg_resp_p; - msg_resp_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_RESP); S1AP_UE_CONTEXT_RELEASE_RESP(msg_resp_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - itti_send_msg_to_task(TASK_S1AP, instance, msg_resp_p); } - return (0); } } //------------------------------------------------------------------------------ -void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( - const module_id_t enb_mod_idP, - const rrc_eNB_ue_context_t* const ue_context_pP, - const s1ap_Cause_t causeP, - const long cause_valueP -) +/* +* Send the S1 command UE_CONTEXT_RELEASE_REQUEST to the MME. +*/ +void +rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ( + const module_id_t enb_mod_idP, + const rrc_eNB_ue_context_t *const ue_context_pP, + const s1ap_Cause_t causeP, + const long cause_valueP) //------------------------------------------------------------------------------ { if (ue_context_pP == NULL) { - LOG_W(RRC, - "[eNB] In S1AP_UE_CONTEXT_RELEASE_COMMAND: invalid UE\n"); + LOG_E(RRC, "[eNB] In S1AP_UE_CONTEXT_RELEASE_REQ: invalid UE\n"); } else { - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - NULL,0, - "0 S1AP_UE_CONTEXT_RELEASE_REQ eNB_ue_s1ap_id 0x%06"PRIX32" ", - ue_context_pP->ue_context.eNB_ue_s1ap_id); - + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_S1AP_ENB, + NULL, + 0, + "0 S1AP_UE_CONTEXT_RELEASE_REQ eNB_ue_s1ap_id 0x%06"PRIX32" ", + ue_context_pP->ue_context.eNB_ue_s1ap_id); MessageDef *msg_context_release_req_p = NULL; msg_context_release_req_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_REQ); S1AP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; @@ -1201,81 +1190,65 @@ void rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ ( } -/*------------------------------------------------------------------------------*/ -int rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND (MessageDef *msg_p, const char *msg_name, instance_t instance) -{ - uint32_t eNB_ue_s1ap_id; - protocol_ctxt_t ctxt; +//----------------------------------------------------------------------------- +/* +* Process the S1 command UE_CONTEXT_RELEASE_COMMAND, sent by MME. +* The eNB should remove all e-rab, S1 context, and other context of the UE. +*/ +int +rrc_eNB_process_S1AP_UE_CONTEXT_RELEASE_COMMAND( + MessageDef *msg_p, + const char *msg_name, + instance_t instance) { + //----------------------------------------------------------------------------- + uint32_t eNB_ue_s1ap_id = 0; + protocol_ctxt_t ctxt; struct rrc_eNB_ue_context_s *ue_context_p = NULL; - struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; - + struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = NULL; eNB_ue_s1ap_id = S1AP_UE_CONTEXT_RELEASE_COMMAND(msg_p).eNB_ue_s1ap_id; - - - ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); if (ue_context_p == NULL) { /* Can not associate this message to an UE index */ - MessageDef *msg_complete_p; - - LOG_W(RRC, - "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: unknown UE from eNB_ue_s1ap_id (%d)\n", + MessageDef *msg_complete_p = NULL; + LOG_W(RRC, "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: unknown UE from eNB_ue_s1ap_id (%d)\n", instance, eNB_ue_s1ap_id); - - MSC_LOG_EVENT( - MSC_RRC_ENB, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found", - eNB_ue_s1ap_id); - - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - NULL,0, - "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", - eNB_ue_s1ap_id); - + MSC_LOG_EVENT(MSC_RRC_ENB, "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" context not found", + eNB_ue_s1ap_id); + MSC_LOG_TX_MESSAGE(MSC_RRC_ENB, + MSC_S1AP_ENB, + NULL, + 0, + "0 S1AP_UE_CONTEXT_RELEASE_COMPLETE eNB_ue_s1ap_id 0x%06"PRIX32" ", + eNB_ue_s1ap_id); msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; itti_send_msg_to_task(TASK_S1AP, instance, msg_complete_p); + rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); - rrc_ue_s1ap_ids = rrc_eNB_S1AP_get_ue_ids( - RC.rrc[instance], - UE_INITIAL_ID_INVALID, - eNB_ue_s1ap_id); - - if (NULL != rrc_ue_s1ap_ids) { - rrc_eNB_S1AP_remove_ue_ids( - RC.rrc[instance], - rrc_ue_s1ap_ids); + if (rrc_ue_s1ap_ids != NULL) { + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); } - return (-1); + + return -1; } else { ue_context_p->ue_context.ue_release_timer_s1 = 0; PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); rrc_eNB_generate_RRCConnectionRelease(&ctxt, ue_context_p); - /* - LOG_W(RRC, - "[eNB %d] In S1AP_UE_CONTEXT_RELEASE_COMMAND: TODO call rrc_eNB_connection_release for eNB %d\n", - instance, - eNB_ue_s1ap_id); - */ - return (0); + return 0; } } -int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) -{ +int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) { uint16_t ue_initial_id; uint32_t eNB_ue_s1ap_id; gtpv1u_enb_create_tunnel_req_t create_tunnel_req; gtpv1u_enb_create_tunnel_resp_t create_tunnel_resp; - uint8_t inde_list[NB_RB_MAX - 3]={0}; - - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + uint8_t inde_list[NB_RB_MAX - 3]= {0}; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; uint8_t e_rab_done; - ue_initial_id = S1AP_E_RAB_SETUP_REQ (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_E_RAB_SETUP_REQ (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); @@ -1285,185 +1258,159 @@ int rrc_eNB_process_S1AP_E_RAB_SETUP_REQ(MessageDef *msg_p, const char *msg_name if (ue_context_p == NULL) { /* Can not associate this message to an UE index, send a failure to S1AP and discard it! */ MessageDef *msg_fail_p = NULL; - LOG_W(RRC, "[eNB %d] In S1AP_E_RAB_SETUP_REQ: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id); - msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_SETUP_REQUEST_FAIL); S1AP_E_RAB_SETUP_REQ (msg_fail_p).eNB_ue_s1ap_id = eNB_ue_s1ap_id; - // TODO add failure cause when defined! - itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); return (-1); } else { - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); ue_context_p->ue_context.eNB_ue_s1ap_id = S1AP_E_RAB_SETUP_REQ (msg_p).eNB_ue_s1ap_id; - /* Save e RAB information for later */ { int i; - - memset(&create_tunnel_req, 0 , sizeof(create_tunnel_req)); + memset(&create_tunnel_req, 0, sizeof(create_tunnel_req)); uint8_t nb_e_rabs_tosetup = S1AP_E_RAB_SETUP_REQ (msg_p).nb_e_rabs_tosetup; e_rab_done = 0; // keep the previous bearer // the index for the rec - for (i = 0; - // i < nb_e_rabs_tosetup; - i < NB_RB_MAX - 3; // loop all e-rabs in e_rab[] - i++) { - //if (ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status == E_RAB_STATUS_DONE) - // LOG_W(RRC,"E-RAB already configured, reconfiguring\n"); + for (i = 0; + // i < nb_e_rabs_tosetup; + i < NB_RB_MAX - 3; // loop all e-rabs in e_rab[] + i++) { + //if (ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status == E_RAB_STATUS_DONE) + // LOG_W(RRC,"E-RAB already configured, reconfiguring\n"); // check e-rab status, if e rab status is greater than E_RAB_STATUS_DONE, don't not config this one if(ue_context_p->ue_context.e_rab[i].status >= E_RAB_STATUS_DONE) - continue; + continue; + //ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].status = E_RAB_STATUS_NEW; //ue_context_p->ue_context.e_rab[i+ue_context_p->ue_context.setup_e_rabs].param = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[i]; ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_NEW; ue_context_p->ue_context.e_rab[i].param = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done]; - create_tunnel_req.eps_bearer_id[e_rab_done] = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done].e_rab_id; create_tunnel_req.sgw_S1u_teid[e_rab_done] = S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done].gtp_teid; - memcpy(&create_tunnel_req.sgw_addr[e_rab_done], & S1AP_E_RAB_SETUP_REQ (msg_p).e_rab_setup_params[e_rab_done].sgw_addr, sizeof(transport_layer_addr_t)); - - LOG_I(RRC,"E_RAB setup REQ: local index %d teid %u, eps id %d \n", - i, - create_tunnel_req.sgw_S1u_teid[e_rab_done], - create_tunnel_req.eps_bearer_id[i] ); + LOG_I(RRC,"E_RAB setup REQ: local index %d teid %u, eps id %d \n", + i, + create_tunnel_req.sgw_S1u_teid[e_rab_done], + create_tunnel_req.eps_bearer_id[i] ); inde_list[e_rab_done] = i; - e_rab_done++; - if(e_rab_done >= nb_e_rabs_tosetup){ - break; + e_rab_done++; + + if(e_rab_done >= nb_e_rabs_tosetup) { + break; } } + ue_context_p->ue_context.nb_of_e_rabs=nb_e_rabs_tosetup; - - create_tunnel_req.rnti = ue_context_p->ue_context.rnti; // warning put zero above create_tunnel_req.num_tunnels = e_rab_done; - // NN: not sure if we should create a new tunnel: need to check teid, etc. gtpv1u_create_s1u_tunnel( instance, &create_tunnel_req, &create_tunnel_resp); - rrc_eNB_process_GTPV1U_CREATE_TUNNEL_RESP( - &ctxt, - &create_tunnel_resp, - &inde_list[0]); - + &ctxt, + &create_tunnel_resp, + &inde_list[0]); ue_context_p->ue_context.setup_e_rabs+=nb_e_rabs_tosetup; - } - /* TODO parameters yet to process ... */ { // S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr; } - rrc_eNB_generate_dedicatedRRCConnectionReconfiguration(&ctxt, ue_context_p, 0); - return (0); } } /*NN: careful about the typcast of xid (long -> uint8_t*/ -int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t xid ){ - +int rrc_eNB_send_S1AP_E_RAB_SETUP_RESP(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t xid ) { MessageDef *msg_p = NULL; int e_rab; int e_rabs_done = 0; int e_rabs_failed = 0; - msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_SETUP_RESP); S1AP_E_RAB_SETUP_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - - for (e_rab = 0; e_rab < ue_context_pP->ue_context.setup_e_rabs ; e_rab++) { - /* only respond to the corresponding transaction */ + for (e_rab = 0; e_rab < ue_context_pP->ue_context.setup_e_rabs ; e_rab++) { + /* only respond to the corresponding transaction */ //if (((xid+1)%4) == ue_context_pP->ue_context.e_rab[e_rab].xid) { if (xid == ue_context_pP->ue_context.e_rab[e_rab].xid) { - if (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_DONE) { - - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; - // TODO add other information from S1-U when it will be integrated - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid = ue_context_pP->ue_context.enb_gtp_teid[e_rab]; - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr = ue_context_pP->ue_context.enb_gtp_addrs[e_rab]; - //S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr.length += 4; - ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; - - LOG_I (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d, xid %d): nb_of_e_rabs %d, e_rab_id %d, teid: %u, addr: %d.%d.%d.%d \n ", - e_rabs_done, e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, - ue_context_pP->ue_context.nb_of_e_rabs, - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id, - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid, - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[0], - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[1], - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[2], - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[3]); - - e_rabs_done++; - } else if ((ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_NEW) || - (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)){ - LOG_D (RRC,"E-RAB is NEW or already ESTABLISHED\n"); - }else { /* to be improved */ - ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; - S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; - e_rabs_failed++; - // TODO add cause when it will be integrated - } - + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; + // TODO add other information from S1-U when it will be integrated + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid = ue_context_pP->ue_context.enb_gtp_teid[e_rab]; + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr = ue_context_pP->ue_context.enb_gtp_addrs[e_rab]; + //S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rab].eNB_addr.length += 4; + ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_ESTABLISHED; + LOG_I (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d, xid %d): nb_of_e_rabs %d, e_rab_id %d, teid: %u, addr: %d.%d.%d.%d \n ", + e_rabs_done, e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, + ue_context_pP->ue_context.nb_of_e_rabs, + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id, + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].gtp_teid, + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[0], + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[1], + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[2], + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs[e_rabs_done].eNB_addr.buffer[3]); + e_rabs_done++; + } else if ((ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_NEW) || + (ue_context_pP->ue_context.e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)) { + LOG_D (RRC,"E-RAB is NEW or already ESTABLISHED\n"); + } else { /* to be improved */ + ue_context_pP->ue_context.e_rab[e_rab].status = E_RAB_STATUS_FAILED; + S1AP_E_RAB_SETUP_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.e_rab[e_rab].param.e_rab_id; + e_rabs_failed++; + // TODO add cause when it will be integrated + } + S1AP_E_RAB_SETUP_RESP (msg_p).nb_of_e_rabs = e_rabs_done; S1AP_E_RAB_SETUP_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; - // NN: add conditions for e_rabs_failed + // NN: add conditions for e_rabs_failed } else { - /*debug info for the xid */ + /*debug info for the xid */ LOG_D(RRC,"xid does not corresponds (context e_rab index %d, status %d, xid %d/%d) \n ", - e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, ue_context_pP->ue_context.e_rab[e_rab].xid); - } + e_rab, ue_context_pP->ue_context.e_rab[e_rab].status, xid, ue_context_pP->ue_context.e_rab[e_rab].xid); + } } - if ((e_rabs_done > 0) ){ - - LOG_I(RRC,"S1AP_E_RAB_SETUP_RESP: sending the message: nb_of_erabs %d, total e_rabs %d, index %d\n", - ue_context_pP->ue_context.nb_of_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab); - MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p), - sizeof(s1ap_e_rab_setup_resp_t), - MSC_AS_TIME_FMT" E_RAB_SETUP_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_pP->ue_id_rnti, - S1AP_E_RAB_SETUP_RESP (msg_p).eNB_ue_s1ap_id, - e_rabs_done, e_rabs_failed); - - - itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); - } + + if ((e_rabs_done > 0) ) { + LOG_I(RRC,"S1AP_E_RAB_SETUP_RESP: sending the message: nb_of_erabs %d, total e_rabs %d, index %d\n", + ue_context_pP->ue_context.nb_of_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab); + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_S1AP_ENB, + (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p), + sizeof(s1ap_e_rab_setup_resp_t), + MSC_AS_TIME_FMT" E_RAB_SETUP_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_id_rnti, + S1AP_E_RAB_SETUP_RESP (msg_p).eNB_ue_s1ap_id, + e_rabs_done, e_rabs_failed); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); + } + for(int i = 0; i < NB_RB_MAX; i++) { - ue_context_pP->ue_context.e_rab[i].xid = -1; + ue_context_pP->ue_context.e_rab[i].xid = -1; } - + return 0; } -int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) -{ +int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_name, instance_t instance) { int i; uint16_t ue_initial_id; uint32_t eNB_ue_s1ap_id; - struct rrc_eNB_ue_context_s* ue_context_p = NULL; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; - ue_initial_id = S1AP_E_RAB_MODIFY_REQ (msg_p).ue_initial_id; eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id; ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, ue_initial_id, eNB_ue_s1ap_id); @@ -1475,27 +1422,23 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam LOG_W(RRC, "[eNB %d] In S1AP_E_RAB_MODIFY_REQ: unknown UE from S1AP ids (%d, %d)\n", instance, ue_initial_id, eNB_ue_s1ap_id); int nb_of_e_rabs_failed = 0; MessageDef *msg_fail_p = NULL; - msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP); - S1AP_E_RAB_MODIFY_RESP (msg_fail_p).eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id; S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs = 0; for (nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; nb_of_e_rabs_failed++) { S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id = - S1AP_E_RAB_MODIFY_REQ (msg_p).e_rab_modify_params[nb_of_e_rabs_failed].e_rab_id; + S1AP_E_RAB_MODIFY_REQ (msg_p).e_rab_modify_params[nb_of_e_rabs_failed].e_rab_id; S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK; S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = 31;//S1ap_CauseRadioNetwork_multiple_E_RAB_ID_instances; } - S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; itti_send_msg_to_task(TASK_S1AP, instance, msg_fail_p); return (-1); - } else { PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); ue_context_p->ue_context.eNB_ue_s1ap_id = eNB_ue_s1ap_id; - /* Save e RAB information for later */ { int j; @@ -1509,9 +1452,10 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam // already treated continue; } + for (j = i+1; j < S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; j++) { if (is_treated[j] == FALSE && - S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) { + S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) { // handle multiple E-RAB ID ue_context_p->ue_context.modify_e_rab[j].status = E_RAB_STATUS_NEW; ue_context_p->ue_context.modify_e_rab[j].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[j].e_rab_id; @@ -1522,6 +1466,7 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam is_treated[j] = TRUE; } } + if (is_treated[i] == TRUE) { // handle multiple E-RAB ID ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW; @@ -1545,9 +1490,10 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam for (j = 0; j < NB_RB_MAX-3; j++) { if (ue_context_p->ue_context.e_rab[j].param.e_rab_id == S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id) { - if(ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_TORELEASE || ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_DONE){ + if(ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_TORELEASE || ue_context_p->ue_context.e_rab[j].status == E_RAB_STATUS_DONE) { break; } + ue_context_p->ue_context.modify_e_rab[i].status = E_RAB_STATUS_NEW; ue_context_p->ue_context.modify_e_rab[i].cause = S1AP_CAUSE_NOTHING; ue_context_p->ue_context.modify_e_rab[i].param.e_rab_id = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].e_rab_id; @@ -1556,7 +1502,6 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam ue_context_p->ue_context.modify_e_rab[i].param.nas_pdu.buffer = S1AP_E_RAB_MODIFY_REQ(msg_p).e_rab_modify_params[i].nas_pdu.buffer; ue_context_p->ue_context.modify_e_rab[i].param.sgw_addr = ue_context_p->ue_context.e_rab[j].param.sgw_addr; ue_context_p->ue_context.modify_e_rab[i].param.gtp_teid = ue_context_p->ue_context.e_rab[j].param.gtp_teid; - is_treated[i] = TRUE; break; } @@ -1576,7 +1521,6 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam ue_context_p->ue_context.nb_of_modify_e_rabs = S1AP_E_RAB_MODIFY_REQ (msg_p).nb_e_rabs_tomodify; ue_context_p->ue_context.nb_of_failed_e_rabs = nb_of_failed_e_rabs; } - /* TODO parameters yet to process ... */ { // S1AP_INITIAL_CONTEXT_SETUP_REQ(msg_p).ue_ambr; @@ -1591,36 +1535,31 @@ int rrc_eNB_process_S1AP_E_RAB_MODIFY_REQ(MessageDef *msg_p, const char *msg_nam { int nb_of_e_rabs_failed = 0; MessageDef *msg_fail_p = NULL; - msg_fail_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP); - S1AP_E_RAB_MODIFY_RESP (msg_fail_p).eNB_ue_s1ap_id = S1AP_E_RAB_MODIFY_REQ (msg_p).eNB_ue_s1ap_id; -// S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs[S1AP_MAX_E_RAB]; + // S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs[S1AP_MAX_E_RAB]; S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs = 0; for(nb_of_e_rabs_failed = 0; nb_of_e_rabs_failed < ue_context_p->ue_context.nb_of_failed_e_rabs; nb_of_e_rabs_failed++) { S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].e_rab_id = - ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].param.e_rab_id; + ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].param.e_rab_id; S1AP_E_RAB_MODIFY_RESP (msg_fail_p).e_rabs_failed[nb_of_e_rabs_failed].cause = ue_context_p->ue_context.modify_e_rab[nb_of_e_rabs_failed].cause; } - S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; + S1AP_E_RAB_MODIFY_RESP (msg_fail_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; itti_send_msg_to_task (TASK_S1AP, instance, msg_fail_p); - ue_context_p->ue_context.nb_of_modify_e_rabs = 0; ue_context_p->ue_context.nb_of_failed_e_rabs = 0; memset(ue_context_p->ue_context.modify_e_rab, 0, sizeof(ue_context_p->ue_context.modify_e_rab)); - return (0); } } // end of ue_context_p != NULL } /*NN: careful about the typcast of xid (long -> uint8_t*/ -int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t* const ctxt_pP, - rrc_eNB_ue_context_t* const ue_context_pP, - uint8_t xid ) { - +int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t *const ctxt_pP, + rrc_eNB_ue_context_t *const ue_context_pP, + uint8_t xid ) { MessageDef *msg_p = NULL; int i; int e_rab; @@ -1630,7 +1569,6 @@ int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t* const ctxt_pP, S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; for (e_rab = 0; e_rab < ue_context_pP->ue_context.nb_of_modify_e_rabs; e_rab++) { - /* only respond to the corresponding transaction */ if (xid == ue_context_pP->ue_context.modify_e_rab[e_rab].xid) { if (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_DONE) { @@ -1643,202 +1581,200 @@ int rrc_eNB_send_S1AP_E_RAB_MODIFY_RESP(const protocol_ctxt_t* const ctxt_pP, break; } } + if (i < ue_context_pP->ue_context.setup_e_rabs) { S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id; - // TODO add other information from S1-U when it will be integrated - + // TODO add other information from S1-U when it will be integrated LOG_D (RRC,"enb_gtp_addr (msg index %d, e_rab index %d, status %d, xid %d): nb_of_modify_e_rabs %d, e_rab_id %d \n ", - e_rabs_done, e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, - ue_context_pP->ue_context.nb_of_modify_e_rabs, - S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id); - + e_rabs_done, e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, + ue_context_pP->ue_context.nb_of_modify_e_rabs, + S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs[e_rabs_done].e_rab_id); e_rabs_done++; } else { // unexpected S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id; - S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause = S1AP_CAUSE_RADIO_NETWORK; S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause_value = 30;//S1ap_CauseRadioNetwork_unknown_E_RAB_ID; - e_rabs_failed++; } } else if ((ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_NEW) || - (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)){ + (ue_context_pP->ue_context.modify_e_rab[e_rab].status == E_RAB_STATUS_ESTABLISHED)) { LOG_D (RRC,"E-RAB is NEW or already ESTABLISHED\n"); } else { /* status == E_RAB_STATUS_FAILED; */ S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].e_rab_id = ue_context_pP->ue_context.modify_e_rab[e_rab].param.e_rab_id; // add failure cause when defined S1AP_E_RAB_MODIFY_RESP (msg_p).e_rabs_failed[e_rabs_failed].cause = ue_context_pP->ue_context.modify_e_rab[e_rab].cause; - e_rabs_failed++; } } else { /*debug info for the xid */ LOG_D(RRC,"xid does not corresponds (context e_rab index %d, status %d, xid %d/%d) \n ", - e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, ue_context_pP->ue_context.modify_e_rab[e_rab].xid); + e_rab, ue_context_pP->ue_context.modify_e_rab[e_rab].status, xid, ue_context_pP->ue_context.modify_e_rab[e_rab].xid); } } - S1AP_E_RAB_MODIFY_RESP (msg_p).nb_of_e_rabs = e_rabs_done; S1AP_E_RAB_MODIFY_RESP (msg_p).nb_of_e_rabs_failed = e_rabs_failed; + // NN: add conditions for e_rabs_failed if (e_rabs_done > 0 || e_rabs_failed > 0) { LOG_D(RRC,"S1AP_E_RAB_MODIFY_RESP: sending the message: nb_of_modify_e_rabs %d, total e_rabs %d, index %d\n", - ue_context_pP->ue_context.nb_of_modify_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab); -MSC_LOG_TX_MESSAGE( - MSC_RRC_ENB, - MSC_S1AP_ENB, - (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p), - sizeof(s1ap_e_rab_setup_resp_t), - MSC_AS_TIME_FMT" E_RAB_MODIFY_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail", - MSC_AS_TIME_ARGS(ctxt_pP), - ue_context_pP->ue_id_rnti, - S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id, - e_rabs_done, e_rabs_failed); - + ue_context_pP->ue_context.nb_of_modify_e_rabs, ue_context_pP->ue_context.setup_e_rabs, e_rab); + MSC_LOG_TX_MESSAGE( + MSC_RRC_ENB, + MSC_S1AP_ENB, + (const char *)&S1AP_E_RAB_SETUP_RESP (msg_p), + sizeof(s1ap_e_rab_setup_resp_t), + MSC_AS_TIME_FMT" E_RAB_MODIFY_RESP UE %X eNB_ue_s1ap_id %u e_rabs:%u succ %u fail", + MSC_AS_TIME_ARGS(ctxt_pP), + ue_context_pP->ue_id_rnti, + S1AP_E_RAB_MODIFY_RESP (msg_p).eNB_ue_s1ap_id, + e_rabs_done, e_rabs_failed); itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); } return 0; } -int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *msg_name, instance_t instance){ - uint32_t eNB_ue_s1ap_id; - struct rrc_eNB_ue_context_s* ue_context_p = NULL; - protocol_ctxt_t ctxt; - e_rab_release_t e_rab_release_params[S1AP_MAX_E_RAB]; - uint8_t nb_e_rabs_torelease; - int erab; - int i; - uint8_t b_existed,is_existed; - uint8_t xid; - uint8_t e_rab_release_drb; - MessageDef * msg_delete_tunnels_p = NULL; - e_rab_release_drb = 0; - memcpy(&e_rab_release_params[0], &(S1AP_E_RAB_RELEASE_COMMAND (msg_p).e_rab_release_params[0]), sizeof(e_rab_release_t)*S1AP_MAX_E_RAB); - - eNB_ue_s1ap_id = S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id; - nb_e_rabs_torelease = S1AP_E_RAB_RELEASE_COMMAND (msg_p).nb_e_rabs_torelease; - ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); - if(ue_context_p != NULL){ - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); - - xid = rrc_eNB_get_next_transaction_identifier(ctxt.module_id); - - LOG_D(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d ENB_UE_S1AP_ID %d release_e_rabs %d \n", - S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id, eNB_ue_s1ap_id,nb_e_rabs_torelease); - for(erab = 0; erab < nb_e_rabs_torelease; erab++){ - b_existed = 0; - is_existed = 0; - for ( i = erab-1; i>= 0; i--){ - if (e_rab_release_params[erab].e_rab_id == e_rab_release_params[i].e_rab_id){ - is_existed = 1; - break; - } - } - if(is_existed == 1){ - //e_rab_id is existed - continue; - } - for ( i = 0; i < NB_RB_MAX; i++){ - if (e_rab_release_params[erab].e_rab_id == ue_context_p->ue_context.e_rab[i].param.e_rab_id){ - b_existed = 1; - break; - } - } - if(b_existed == 0) { - //no e_rab_id - ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id; - ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK; - ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 30; - ue_context_p->ue_context.nb_release_of_e_rabs++; - } else { - if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_FAILED){ - ue_context_p->ue_context.e_rab[i].xid = xid; - continue; - } else if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED){ - ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_TORELEASE; - ue_context_p->ue_context.e_rab[i].xid = xid; - e_rab_release_drb++; - }else{ - //e_rab_id status NG - ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id; - ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK; - ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 0; - ue_context_p->ue_context.nb_release_of_e_rabs++; - } - } +int rrc_eNB_process_S1AP_E_RAB_RELEASE_COMMAND(MessageDef *msg_p, const char *msg_name, instance_t instance) { + uint32_t eNB_ue_s1ap_id; + struct rrc_eNB_ue_context_s *ue_context_p = NULL; + protocol_ctxt_t ctxt; + e_rab_release_t e_rab_release_params[S1AP_MAX_E_RAB]; + uint8_t nb_e_rabs_torelease; + int erab; + int i; + uint8_t b_existed,is_existed; + uint8_t xid; + uint8_t e_rab_release_drb; + MessageDef *msg_delete_tunnels_p = NULL; + e_rab_release_drb = 0; + memcpy(&e_rab_release_params[0], &(S1AP_E_RAB_RELEASE_COMMAND (msg_p).e_rab_release_params[0]), sizeof(e_rab_release_t)*S1AP_MAX_E_RAB); + eNB_ue_s1ap_id = S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id; + nb_e_rabs_torelease = S1AP_E_RAB_RELEASE_COMMAND (msg_p).nb_e_rabs_torelease; + ue_context_p = rrc_eNB_get_ue_context_from_s1ap_ids(instance, UE_INITIAL_ID_INVALID, eNB_ue_s1ap_id); + + if(ue_context_p != NULL) { + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, ENB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + xid = rrc_eNB_get_next_transaction_identifier(ctxt.module_id); + LOG_D(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d ENB_UE_S1AP_ID %d release_e_rabs %d \n", + S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id, eNB_ue_s1ap_id,nb_e_rabs_torelease); + + for(erab = 0; erab < nb_e_rabs_torelease; erab++) { + b_existed = 0; + is_existed = 0; + + for ( i = erab-1; i>= 0; i--) { + if (e_rab_release_params[erab].e_rab_id == e_rab_release_params[i].e_rab_id) { + is_existed = 1; + break; } - if(e_rab_release_drb > 0) { - //RRCConnectionReconfiguration To UE - rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(&ctxt, ue_context_p, xid, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.length, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.buffer); - } else { - //gtp tunnel delete - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); - memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; - for(i = 0; i < NB_RB_MAX; i++){ - if(xid == ue_context_p->ue_context.e_rab[i].xid){ - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; - ue_context_p->ue_context.enb_gtp_teid[i] = 0; - memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); - ue_context_p->ue_context.enb_gtp_ebi[i] = 0; - } - } + } - itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p); + if(is_existed == 1) { + //e_rab_id is existed + continue; + } - //S1AP_E_RAB_RELEASE_RESPONSE - rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(&ctxt, ue_context_p, xid); + for ( i = 0; i < NB_RB_MAX; i++) { + if (e_rab_release_params[erab].e_rab_id == ue_context_p->ue_context.e_rab[i].param.e_rab_id) { + b_existed = 1; + break; } + } + + if(b_existed == 0) { + //no e_rab_id + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 30; + ue_context_p->ue_context.nb_release_of_e_rabs++; + } else { + if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_FAILED) { + ue_context_p->ue_context.e_rab[i].xid = xid; + continue; + } else if(ue_context_p->ue_context.e_rab[i].status == E_RAB_STATUS_ESTABLISHED) { + ue_context_p->ue_context.e_rab[i].status = E_RAB_STATUS_TORELEASE; + ue_context_p->ue_context.e_rab[i].xid = xid; + e_rab_release_drb++; + } else { + //e_rab_id status NG + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].e_rab_id = e_rab_release_params[erab].e_rab_id; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause = S1AP_CAUSE_RADIO_NETWORK; + ue_context_p->ue_context.e_rabs_release_failed[ue_context_p->ue_context.nb_release_of_e_rabs].cause_value = 0; + ue_context_p->ue_context.nb_release_of_e_rabs++; + } + } + } + + if(e_rab_release_drb > 0) { + //RRCConnectionReconfiguration To UE + rrc_eNB_generate_dedicatedRRCConnectionReconfiguration_release(&ctxt, ue_context_p, xid, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.length, S1AP_E_RAB_RELEASE_COMMAND (msg_p).nas_pdu.buffer); } else { - LOG_E(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d ENB_UE_S1AP_ID %d Error ue_context_p NULL \n", - S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id, S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id); - return -1; + //gtp tunnel delete + msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_ENB, GTPV1U_ENB_DELETE_TUNNEL_REQ); + memset(>PV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p), 0, sizeof(GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p))); + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).rnti = ue_context_p->ue_context.rnti; + + for(i = 0; i < NB_RB_MAX; i++) { + if(xid == ue_context_p->ue_context.e_rab[i].xid) { + GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).eps_bearer_id[GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_erab++] = ue_context_p->ue_context.enb_gtp_ebi[i]; + ue_context_p->ue_context.enb_gtp_teid[i] = 0; + memset(&ue_context_p->ue_context.enb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.enb_gtp_addrs[i])); + ue_context_p->ue_context.enb_gtp_ebi[i] = 0; + } + } + + itti_send_msg_to_task(TASK_GTPV1_U, instance, msg_delete_tunnels_p); + //S1AP_E_RAB_RELEASE_RESPONSE + rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(&ctxt, ue_context_p, xid); } + } else { + LOG_E(RRC,"S1AP-E-RAB Release Command: MME_UE_S1AP_ID %d ENB_UE_S1AP_ID %d Error ue_context_p NULL \n", + S1AP_E_RAB_RELEASE_COMMAND (msg_p).mme_ue_s1ap_id, S1AP_E_RAB_RELEASE_COMMAND (msg_p).eNB_ue_s1ap_id); + return -1; + } - return 0; + return 0; } -int rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(const protocol_ctxt_t* const ctxt_pP, rrc_eNB_ue_context_t* const ue_context_pP, uint8_t xid){ - int e_rabs_released = 0; - MessageDef *msg_p; +int rrc_eNB_send_S1AP_E_RAB_RELEASE_RESPONSE(const protocol_ctxt_t *const ctxt_pP, rrc_eNB_ue_context_t *const ue_context_pP, uint8_t xid) { + int e_rabs_released = 0; + MessageDef *msg_p; + msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_RELEASE_RESPONSE); + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - msg_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_RELEASE_RESPONSE); - S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id = ue_context_pP->ue_context.eNB_ue_s1ap_id; - - for (int i = 0; i < NB_RB_MAX; i++){ - if (xid == ue_context_pP->ue_context.e_rab[i].xid){ - S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rab_release[e_rabs_released].e_rab_id = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; - e_rabs_released++; - //clear - memset(&ue_context_pP->ue_context.e_rab[i],0,sizeof(e_rab_param_t)); - } - } - S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_released = e_rabs_released; - S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_failed = ue_context_pP->ue_context.nb_release_of_e_rabs; - memcpy(&(S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rabs_failed[0]),&ue_context_pP->ue_context.e_rabs_release_failed[0],sizeof(e_rab_failed_t)*ue_context_pP->ue_context.nb_release_of_e_rabs); - - ue_context_pP->ue_context.setup_e_rabs -= e_rabs_released; - LOG_I(RRC,"S1AP-E-RAB RELEASE RESPONSE: ENB_UE_S1AP_ID %d release_e_rabs %d setup_e_rabs %d \n", - S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id, - e_rabs_released, ue_context_pP->ue_context.setup_e_rabs); - - itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); - //clear xid - for(int i = 0; i < NB_RB_MAX; i++) { - ue_context_pP->ue_context.e_rab[i].xid = -1; + for (int i = 0; i < NB_RB_MAX; i++) { + if (xid == ue_context_pP->ue_context.e_rab[i].xid) { + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rab_release[e_rabs_released].e_rab_id = ue_context_pP->ue_context.e_rab[i].param.e_rab_id; + e_rabs_released++; + //clear + memset(&ue_context_pP->ue_context.e_rab[i],0,sizeof(e_rab_param_t)); } - //clear release e_rabs - ue_context_pP->ue_context.nb_release_of_e_rabs = 0; - memset(&ue_context_pP->ue_context.e_rabs_release_failed[0],0,sizeof(e_rab_failed_t)*S1AP_MAX_E_RAB); - return 0; + } + + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_released = e_rabs_released; + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).nb_of_e_rabs_failed = ue_context_pP->ue_context.nb_release_of_e_rabs; + memcpy(&(S1AP_E_RAB_RELEASE_RESPONSE (msg_p).e_rabs_failed[0]),&ue_context_pP->ue_context.e_rabs_release_failed[0],sizeof(e_rab_failed_t)*ue_context_pP->ue_context.nb_release_of_e_rabs); + ue_context_pP->ue_context.setup_e_rabs -= e_rabs_released; + LOG_I(RRC,"S1AP-E-RAB RELEASE RESPONSE: ENB_UE_S1AP_ID %d release_e_rabs %d setup_e_rabs %d \n", + S1AP_E_RAB_RELEASE_RESPONSE (msg_p).eNB_ue_s1ap_id, + e_rabs_released, ue_context_pP->ue_context.setup_e_rabs); + itti_send_msg_to_task (TASK_S1AP, ctxt_pP->instance, msg_p); + + //clear xid + for(int i = 0; i < NB_RB_MAX; i++) { + ue_context_pP->ue_context.e_rab[i].xid = -1; + } + + //clear release e_rabs + ue_context_pP->ue_context.nb_release_of_e_rabs = 0; + memset(&ue_context_pP->ue_context.e_rabs_release_failed[0],0,sizeof(e_rab_failed_t)*S1AP_MAX_E_RAB); + return 0; } /*------------------------------------------------------------------------------*/ -int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance_t instance) -{ +int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance_t instance) { const unsigned int Ttab[4] = {32,64,128,256}; uint8_t Tc,Tue; /* DRX cycle of UE */ uint32_t pcch_nB; /* 4T, 2T, T, T/2, T/4, T/8, T/16, T/32 */ @@ -1846,132 +1782,150 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance uint32_t Ns = 0; /* Ns: max(1,nB/T) */ uint8_t i_s; /* i_s = floor(UE_ID/N) mod Ns */ uint32_t T; /* DRX cycle */ + for (uint16_t tai_size = 0; tai_size < S1AP_PAGING_IND(msg_p).tai_size; tai_size++) { - LOG_D(RRC,"[eNB %d] In S1AP_PAGING_IND: MCC %d, MNC %d, TAC %d\n", instance, S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc, - S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc, S1AP_PAGING_IND(msg_p).tac[tai_size]); - for (uint8_t j = 0; j < RC.rrc[instance]->configuration.num_plmn; j++) { - if (RC.rrc[instance]->configuration.mcc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc - && RC.rrc[instance]->configuration.mnc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc - && RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) { - for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type; - /* get nB from configuration */ - /* get default DRX cycle from configuration */ - Tc = (uint8_t)RC.rrc[instance]->configuration.pcch_defaultPagingCycle[CC_id]; - if (Tc < LTE_PCCH_Config__defaultPagingCycle_rf32 || Tc > LTE_PCCH_Config__defaultPagingCycle_rf256) { - continue; - } - Tue = (uint8_t)S1AP_PAGING_IND(msg_p).paging_drx; - /* set T = min(Tc,Tue) */ - T = Tc < Tue ? Ttab[Tc] : Ttab[Tue]; - /* set pcch_nB = PCCH-Config->nB */ - pcch_nB = (uint32_t)RC.rrc[instance]->configuration.pcch_nB[CC_id]; - switch (pcch_nB) { - case LTE_PCCH_Config__nB_fourT: - Ns = 4; - break; - case LTE_PCCH_Config__nB_twoT: - Ns = 2; - break; - default: - Ns = 1; - break; - } - /* set N = min(T,nB) */ - if (pcch_nB > LTE_PCCH_Config__nB_oneT) { - switch (pcch_nB) { - case LTE_PCCH_Config__nB_halfT: - N = T/2; - break; - case LTE_PCCH_Config__nB_quarterT: - N = T/4; - break; - case LTE_PCCH_Config__nB_oneEighthT: - N = T/8; - break; - case LTE_PCCH_Config__nB_oneSixteenthT: - N = T/16; - break; - case LTE_PCCH_Config__nB_oneThirtySecondT: - N = T/32; - break; - default: - /* pcch_nB error */ - LOG_E(RRC, "[eNB %d] In S1AP_PAGING_IND: pcch_nB error (pcch_nB %d) \n", - instance, pcch_nB); - return (-1); - } - } else { - N = T; - } - - /* insert data to UE_PF_PO or update data in UE_PF_PO */ - pthread_mutex_lock(&ue_pf_po_mutex); - uint8_t i = 0; - for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { - if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value)) - || (UE_PF_PO[CC_id][i].enable_flag != TRUE)) { - /* set T = min(Tc,Tue) */ - UE_PF_PO[CC_id][i].T = T; - /* set UE_ID */ - UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)S1AP_PAGING_IND(msg_p).ue_index_value; - /* calculate PF and PO */ - /* set PF_min : SFN mod T = (T div N)*(UE_ID mod N) */ - UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N); - /* set PO */ - /* i_s = floor(UE_ID/N) mod Ns */ - i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns); - if (Ns == 1) { - UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? 9 : 0; - } else if (Ns==2) { - UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4+(5*i_s)) : (5*i_s); - } else if (Ns==4) { - UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1))); - } - if (UE_PF_PO[CC_id][i].enable_flag == TRUE) { - //paging exist UE log - LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Update exist UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO); - } else { - /* set enable_flag */ - UE_PF_PO[CC_id][i].enable_flag = TRUE; - //paging new UE log - LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Insert a new UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO); - } - break; - } - } - pthread_mutex_unlock(&ue_pf_po_mutex); - - uint32_t length; - uint8_t buffer[RRC_BUF_SIZE]; - uint8_t *message_buffer; - /* Transfer data to PDCP */ - MessageDef *message_p; - message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_PCCH_DATA_REQ); - /* Create message for PDCP (DLInformationTransfer_t) */ - length = do_Paging (instance, - buffer, - S1AP_PAGING_IND(msg_p).ue_paging_identity, - S1AP_PAGING_IND(msg_p).cn_domain); - if(length == -1) - { - LOG_I(RRC, "do_Paging error"); - return -1; - } - message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length); - /* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */ - memcpy (message_buffer, buffer, length); - RRC_PCCH_DATA_REQ (message_p).sdu_size = length; - RRC_PCCH_DATA_REQ (message_p).sdu_p = message_buffer; - RRC_PCCH_DATA_REQ (message_p).mode = PDCP_TRANSMISSION_MODE_TRANSPARENT; /* not used */ - RRC_PCCH_DATA_REQ (message_p).rnti = P_RNTI; - RRC_PCCH_DATA_REQ (message_p).ue_index = i; - RRC_PCCH_DATA_REQ (message_p).CC_id = CC_id; - LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length); - itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p); + LOG_D(RRC,"[eNB %d] In S1AP_PAGING_IND: MCC %d, MNC %d, TAC %d\n", instance, S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc, + S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc, S1AP_PAGING_IND(msg_p).tac[tai_size]); + + for (uint8_t j = 0; j < RC.rrc[instance]->configuration.num_plmn; j++) { + if (RC.rrc[instance]->configuration.mcc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mcc + && RC.rrc[instance]->configuration.mnc[j] == S1AP_PAGING_IND(msg_p).plmn_identity[tai_size].mnc + && RC.rrc[instance]->configuration.tac == S1AP_PAGING_IND(msg_p).tac[tai_size]) { + for (uint8_t CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + lte_frame_type_t frame_type = RC.eNB[instance][CC_id]->frame_parms.frame_type; + /* get nB from configuration */ + /* get default DRX cycle from configuration */ + Tc = (uint8_t)RC.rrc[instance]->configuration.pcch_defaultPagingCycle[CC_id]; + + if (Tc < LTE_PCCH_Config__defaultPagingCycle_rf32 || Tc > LTE_PCCH_Config__defaultPagingCycle_rf256) { + continue; + } + + Tue = (uint8_t)S1AP_PAGING_IND(msg_p).paging_drx; + /* set T = min(Tc,Tue) */ + T = Tc < Tue ? Ttab[Tc] : Ttab[Tue]; + /* set pcch_nB = PCCH-Config->nB */ + pcch_nB = (uint32_t)RC.rrc[instance]->configuration.pcch_nB[CC_id]; + + switch (pcch_nB) { + case LTE_PCCH_Config__nB_fourT: + Ns = 4; + break; + + case LTE_PCCH_Config__nB_twoT: + Ns = 2; + break; + + default: + Ns = 1; + break; + } + + /* set N = min(T,nB) */ + if (pcch_nB > LTE_PCCH_Config__nB_oneT) { + switch (pcch_nB) { + case LTE_PCCH_Config__nB_halfT: + N = T/2; + break; + + case LTE_PCCH_Config__nB_quarterT: + N = T/4; + break; + + case LTE_PCCH_Config__nB_oneEighthT: + N = T/8; + break; + + case LTE_PCCH_Config__nB_oneSixteenthT: + N = T/16; + break; + + case LTE_PCCH_Config__nB_oneThirtySecondT: + N = T/32; + break; + + default: + /* pcch_nB error */ + LOG_E(RRC, "[eNB %d] In S1AP_PAGING_IND: pcch_nB error (pcch_nB %d) \n", + instance, pcch_nB); + return (-1); + } + } else { + N = T; + } + + /* insert data to UE_PF_PO or update data in UE_PF_PO */ + pthread_mutex_lock(&ue_pf_po_mutex); + uint8_t i = 0; + + for (i = 0; i < MAX_MOBILES_PER_ENB; i++) { + if ((UE_PF_PO[CC_id][i].enable_flag == TRUE && UE_PF_PO[CC_id][i].ue_index_value == (uint16_t)(S1AP_PAGING_IND(msg_p).ue_index_value)) + || (UE_PF_PO[CC_id][i].enable_flag != TRUE)) { + /* set T = min(Tc,Tue) */ + UE_PF_PO[CC_id][i].T = T; + /* set UE_ID */ + UE_PF_PO[CC_id][i].ue_index_value = (uint16_t)S1AP_PAGING_IND(msg_p).ue_index_value; + /* calculate PF and PO */ + /* set PF_min : SFN mod T = (T div N)*(UE_ID mod N) */ + UE_PF_PO[CC_id][i].PF_min = (T / N) * (UE_PF_PO[CC_id][i].ue_index_value % N); + /* set PO */ + /* i_s = floor(UE_ID/N) mod Ns */ + i_s = (uint8_t)((UE_PF_PO[CC_id][i].ue_index_value / N) % Ns); + + if (Ns == 1) { + UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? 9 : 0; + } else if (Ns==2) { + UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4+(5*i_s)) : (5*i_s); + } else if (Ns==4) { + UE_PF_PO[CC_id][i].PO = (frame_type==FDD) ? (4*(i_s&1)+(5*(i_s>>1))) : ((i_s&1)+(5*(i_s>>1))); + } + + if (UE_PF_PO[CC_id][i].enable_flag == TRUE) { + //paging exist UE log + LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Update exist UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO); + } else { + /* set enable_flag */ + UE_PF_PO[CC_id][i].enable_flag = TRUE; + //paging new UE log + LOG_D(RRC,"[eNB %d] CC_id %d In S1AP_PAGING_IND: Insert a new UE %d, T %d, PF %d, PO %d\n", instance, CC_id, UE_PF_PO[CC_id][i].ue_index_value, T, UE_PF_PO[CC_id][i].PF_min, UE_PF_PO[CC_id][i].PO); } + + break; + } } + + pthread_mutex_unlock(&ue_pf_po_mutex); + uint32_t length; + uint8_t buffer[RRC_BUF_SIZE]; + uint8_t *message_buffer; + /* Transfer data to PDCP */ + MessageDef *message_p; + message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_PCCH_DATA_REQ); + /* Create message for PDCP (DLInformationTransfer_t) */ + length = do_Paging (instance, + buffer, + S1AP_PAGING_IND(msg_p).ue_paging_identity, + S1AP_PAGING_IND(msg_p).cn_domain); + + if(length == -1) { + LOG_I(RRC, "do_Paging error"); + return -1; + } + + message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length); + /* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */ + memcpy (message_buffer, buffer, length); + RRC_PCCH_DATA_REQ (message_p).sdu_size = length; + RRC_PCCH_DATA_REQ (message_p).sdu_p = message_buffer; + RRC_PCCH_DATA_REQ (message_p).mode = PDCP_TRANSMISSION_MODE_TRANSPARENT; /* not used */ + RRC_PCCH_DATA_REQ (message_p).rnti = P_RNTI; + RRC_PCCH_DATA_REQ (message_p).ue_index = i; + RRC_PCCH_DATA_REQ (message_p).CC_id = CC_id; + LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length); + itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p); + } } + } } return (0); diff --git a/openair3/S1AP/s1ap_eNB.c b/openair3/S1AP/s1ap_eNB.c index 3edc5be0d5f42e66758dab67e42789d8edcc9d49..9eab896d8314ae6e6b9ccb804d64d887cb548265 100644 --- a/openair3/S1AP/s1ap_eNB.c +++ b/openair3/S1AP/s1ap_eNB.c @@ -61,7 +61,7 @@ #include "assertions.h" #include "conversions.h" #if defined(TEST_S1C_MME) -#include "oaisim_mme_test_s1c.h" + #include "oaisim_mme_test_s1c.h" #endif s1ap_eNB_config_t s1ap_config; @@ -74,22 +74,17 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t * void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp); -uint32_t s1ap_generate_eNB_id(void) -{ +uint32_t s1ap_generate_eNB_id(void) { char *out; char hostname[50]; int ret; uint32_t eNB_id; - /* Retrieve the host name */ ret = gethostname(hostname, sizeof(hostname)); DevAssert(ret == 0); - out = crypt(hostname, "eurecom"); DevAssert(out != NULL); - eNB_id = ((out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3]); - return eNB_id; } @@ -99,55 +94,42 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p, uint16_t in_streams, uint16_t out_streams, uint8_t broadcast_plmn_num, - uint8_t broadcast_plmn_index[PLMN_LIST_MAX_SIZE]) -{ + uint8_t broadcast_plmn_index[PLMN_LIST_MAX_SIZE]) { MessageDef *message_p = NULL; sctp_new_association_req_t *sctp_new_association_req_p = NULL; s1ap_eNB_mme_data_t *s1ap_mme_data_p = NULL; struct s1ap_eNB_mme_data_s *mme = NULL; - DevAssert(instance_p != NULL); DevAssert(mme_ip_address != NULL); - message_p = itti_alloc_new_message(TASK_S1AP, SCTP_NEW_ASSOCIATION_REQ); - sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req; - sctp_new_association_req_p->port = S1AP_PORT_NUMBER; sctp_new_association_req_p->ppid = S1AP_SCTP_PPID; - sctp_new_association_req_p->in_streams = in_streams; sctp_new_association_req_p->out_streams = out_streams; - memcpy(&sctp_new_association_req_p->remote_address, mme_ip_address, sizeof(*mme_ip_address)); - memcpy(&sctp_new_association_req_p->local_address, local_ip_addr, sizeof(*local_ip_addr)); - S1AP_INFO("[eNB %d] check the mme registration state\n",instance_p->instance); - mme = NULL; if ( mme == NULL ) { - /* Create new MME descriptor */ s1ap_mme_data_p = calloc(1, sizeof(*s1ap_mme_data_p)); DevAssert(s1ap_mme_data_p != NULL); - s1ap_mme_data_p->cnx_id = s1ap_eNB_fetch_add_global_cnx_id(); sctp_new_association_req_p->ulp_cnx_id = s1ap_mme_data_p->cnx_id; - s1ap_mme_data_p->assoc_id = -1; s1ap_mme_data_p->broadcast_plmn_num = broadcast_plmn_num; + for (int i = 0; i < broadcast_plmn_num; ++i) s1ap_mme_data_p->broadcast_plmn_index[i] = broadcast_plmn_index[i]; - s1ap_mme_data_p->s1ap_eNB_instance = instance_p; + s1ap_mme_data_p->s1ap_eNB_instance = instance_p; STAILQ_INIT(&s1ap_mme_data_p->served_gummei); - /* Insert the new descriptor in list of known MME * but not yet associated. */ @@ -158,12 +140,10 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p, } else if (mme->state == S1AP_ENB_STATE_WAITING) { instance_p->s1ap_mme_pending_nb ++; sctp_new_association_req_p->ulp_cnx_id = mme->cnx_id; - S1AP_INFO("[eNB %d] MME already registered, retrive the data (state %d, cnx %d, mme_nb %d, mme_pending_nb %d)\n", instance_p->instance, mme->state, mme->cnx_id, instance_p->s1ap_mme_nb, instance_p->s1ap_mme_pending_nb); - /*s1ap_mme_data_p->cnx_id = mme->cnx_id; sctp_new_association_req_p->ulp_cnx_id = mme->cnx_id; @@ -181,13 +161,10 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p, } -void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *s1ap_register_eNB) -{ +void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *s1ap_register_eNB) { s1ap_eNB_instance_t *new_instance; uint8_t index; - DevAssert(s1ap_register_eNB != NULL); - /* Look if the provided instance already exists */ new_instance = s1ap_eNB_get_instance(instance); @@ -197,38 +174,36 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t * DevCheck(new_instance->cell_type == s1ap_register_eNB->cell_type, new_instance->cell_type, s1ap_register_eNB->cell_type, 0); DevCheck(new_instance->num_plmn == s1ap_register_eNB->num_plmn, new_instance->num_plmn, s1ap_register_eNB->num_plmn, 0); DevCheck(new_instance->tac == s1ap_register_eNB->tac, new_instance->tac, s1ap_register_eNB->tac, 0); - for (int i = 0; i < new_instance->num_plmn; i++) - { + + for (int i = 0; i < new_instance->num_plmn; i++) { DevCheck(new_instance->mcc[i] == s1ap_register_eNB->mcc[i], new_instance->mcc[i], s1ap_register_eNB->mcc[i], 0); DevCheck(new_instance->mnc[i] == s1ap_register_eNB->mnc[i], new_instance->mnc[i], s1ap_register_eNB->mnc[i], 0); DevCheck(new_instance->mnc_digit_length[i] == s1ap_register_eNB->mnc_digit_length[i], new_instance->mnc_digit_length[i], s1ap_register_eNB->mnc_digit_length[i], 0); } + DevCheck(new_instance->default_drx == s1ap_register_eNB->default_drx, new_instance->default_drx, s1ap_register_eNB->default_drx, 0); } else { new_instance = calloc(1, sizeof(s1ap_eNB_instance_t)); DevAssert(new_instance != NULL); - RB_INIT(&new_instance->s1ap_ue_head); RB_INIT(&new_instance->s1ap_mme_head); - /* Copy usefull parameters */ new_instance->instance = instance; new_instance->eNB_name = s1ap_register_eNB->eNB_name; new_instance->eNB_id = s1ap_register_eNB->eNB_id; new_instance->cell_type = s1ap_register_eNB->cell_type; new_instance->tac = s1ap_register_eNB->tac; - for (int i = 0; i < s1ap_register_eNB->num_plmn; i++) - { + + for (int i = 0; i < s1ap_register_eNB->num_plmn; i++) { new_instance->mcc[i] = s1ap_register_eNB->mcc[i]; new_instance->mnc[i] = s1ap_register_eNB->mnc[i]; new_instance->mnc_digit_length[i] = s1ap_register_eNB->mnc_digit_length[i]; } + new_instance->num_plmn = s1ap_register_eNB->num_plmn; new_instance->default_drx = s1ap_register_eNB->default_drx; - /* Add the new instance to the list of eNB (meaningfull in virtual mode) */ s1ap_eNB_insert_new_instance(new_instance); - S1AP_INFO("Registered new eNB[%d] and %s eNB id %u\n", instance, s1ap_register_eNB->cell_type == CELL_MACRO_ENB ? "macro" : "home", @@ -250,16 +225,12 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t * } } -void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp) -{ +void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp) { s1ap_eNB_instance_t *instance_p; s1ap_eNB_mme_data_t *s1ap_mme_data_p; - DevAssert(sctp_new_association_resp != NULL); - instance_p = s1ap_eNB_get_instance(instance); DevAssert(instance_p != NULL); - s1ap_mme_data_p = s1ap_eNB_get_MME(instance_p, -1, sctp_new_association_resp->ulp_cnx_id); DevAssert(s1ap_mme_data_p != NULL); @@ -269,9 +240,7 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa sctp_new_association_resp->sctp_state, instance, sctp_new_association_resp->ulp_cnx_id); - s1ap_handle_s1_setup_message(s1ap_mme_data_p, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN); - return; } @@ -279,20 +248,17 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa s1ap_mme_data_p->assoc_id = sctp_new_association_resp->assoc_id; s1ap_mme_data_p->in_streams = sctp_new_association_resp->in_streams; s1ap_mme_data_p->out_streams = sctp_new_association_resp->out_streams; - /* Prepare new S1 Setup Request */ s1ap_eNB_generate_s1_setup_request(instance_p, s1ap_mme_data_p); } static -void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind) -{ +void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind) { int result; - DevAssert(sctp_data_ind != NULL); #if defined(TEST_S1C_MME) mme_test_s1_notify_sctp_data_ind(sctp_data_ind->assoc_id, sctp_data_ind->stream, - sctp_data_ind->buffer, sctp_data_ind->buffer_length); + sctp_data_ind->buffer, sctp_data_ind->buffer_length); #else s1ap_eNB_handle_message(sctp_data_ind->assoc_id, sctp_data_ind->stream, sctp_data_ind->buffer, sctp_data_ind->buffer_length); @@ -301,23 +267,19 @@ void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind) AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); } -void s1ap_eNB_init(void) -{ +void s1ap_eNB_init(void) { S1AP_DEBUG("Starting S1AP layer\n"); - s1ap_eNB_prepare_internal_data(); - itti_mark_task_ready(TASK_S1AP); MSC_START_USE(); } -void *s1ap_eNB_process_itti_msg(void* notUsed) -{ +void *s1ap_eNB_process_itti_msg(void *notUsed) { MessageDef *received_msg = NULL; int result; - itti_receive_msg(TASK_S1AP, &received_msg); + itti_receive_msg(TASK_S1AP, &received_msg); - switch (ITTI_MSG_ID(received_msg)) { + switch (ITTI_MSG_ID(received_msg)) { case TERMINATE_MESSAGE: S1AP_WARN(" *** Exiting S1AP thread\n"); itti_exit_task(); @@ -371,16 +333,16 @@ void *s1ap_eNB_process_itti_msg(void* notUsed) case S1AP_E_RAB_SETUP_RESP: { s1ap_eNB_e_rab_setup_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), - &S1AP_E_RAB_SETUP_RESP(received_msg)); + &S1AP_E_RAB_SETUP_RESP(received_msg)); } break; case S1AP_E_RAB_MODIFY_RESP: { s1ap_eNB_e_rab_modify_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), - &S1AP_E_RAB_MODIFY_RESP(received_msg)); + &S1AP_E_RAB_MODIFY_RESP(received_msg)); } break; - + case S1AP_NAS_NON_DELIVERY_IND: { s1ap_eNB_nas_non_delivery_ind(ITTI_MESSAGE_GET_INSTANCE(received_msg), &S1AP_NAS_NON_DELIVERY_IND(received_msg)); @@ -396,11 +358,8 @@ void *s1ap_eNB_process_itti_msg(void* notUsed) case S1AP_UE_CONTEXT_RELEASE_REQ: { s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL; // test struct s1ap_eNB_ue_context_s *ue_context_p = NULL; // test - s1ap_ue_context_release_req(ITTI_MESSAGE_GET_INSTANCE(received_msg), &S1AP_UE_CONTEXT_RELEASE_REQ(received_msg)); - - s1ap_eNB_instance_p = s1ap_eNB_get_instance(ITTI_MESSAGE_GET_INSTANCE(received_msg)); // test DevAssert(s1ap_eNB_instance_p != NULL); // test @@ -413,9 +372,9 @@ void *s1ap_eNB_process_itti_msg(void* notUsed) } break; - case S1AP_E_RAB_RELEASE_RESPONSE: { - s1ap_eNB_e_rab_release_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), - &S1AP_E_RAB_RELEASE_RESPONSE(received_msg)); + case S1AP_E_RAB_RELEASE_RESPONSE: { + s1ap_eNB_e_rab_release_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), + &S1AP_E_RAB_RELEASE_RESPONSE(received_msg)); } break; @@ -423,20 +382,18 @@ void *s1ap_eNB_process_itti_msg(void* notUsed) S1AP_ERROR("Received unhandled message: %d:%s\n", ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg)); break; - } - - result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } - received_msg = NULL; - return NULL; + result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + received_msg = NULL; + return NULL; } -void *s1ap_eNB_task(void *arg) -{ +void *s1ap_eNB_task(void *arg) { s1ap_eNB_init(); - + while (1) { (void) s1ap_eNB_process_itti_msg(NULL); } @@ -444,23 +401,26 @@ void *s1ap_eNB_task(void *arg) return NULL; } +//----------------------------------------------------------------------------- +/* +* eNB generate a S1 setup request towards MME +*/ static int s1ap_eNB_generate_s1_setup_request( - s1ap_eNB_instance_t *instance_p, s1ap_eNB_mme_data_t *s1ap_mme_data_p) + s1ap_eNB_instance_t *instance_p, + s1ap_eNB_mme_data_t *s1ap_mme_data_p) +//----------------------------------------------------------------------------- { - S1AP_S1AP_PDU_t pdu; - S1AP_S1SetupRequest_t *out; - S1AP_S1SetupRequestIEs_t *ie; - S1AP_SupportedTAs_Item_t *ta; - S1AP_PLMNidentity_t *plmn; - uint8_t *buffer; - uint32_t len; + S1AP_S1AP_PDU_t pdu; + S1AP_S1SetupRequest_t *out = NULL; + S1AP_S1SetupRequestIEs_t *ie = NULL; + S1AP_SupportedTAs_Item_t *ta = NULL; + S1AP_PLMNidentity_t *plmn = NULL; + uint8_t *buffer = NULL; + uint32_t len = 0; int ret = 0; - DevAssert(instance_p != NULL); DevAssert(s1ap_mme_data_p != NULL); - s1ap_mme_data_p->state = S1AP_ENB_STATE_WAITING; - /* Prepare the S1AP message to encode */ memset(&pdu, 0, sizeof(pdu)); pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage; @@ -468,7 +428,6 @@ static int s1ap_eNB_generate_s1_setup_request( pdu.choice.initiatingMessage.criticality = S1AP_Criticality_reject; pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_S1SetupRequest; out = &pdu.choice.initiatingMessage.value.choice.S1SetupRequest; - /* mandatory */ ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_Global_ENB_ID; @@ -519,7 +478,6 @@ static int s1ap_eNB_generate_s1_setup_request( ASN_SEQUENCE_ADD(&ie->value.choice.SupportedTAs.list, ta); } ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_DefaultPagingDRX; @@ -540,6 +498,7 @@ static int s1ap_eNB_generate_s1_setup_request( /* optional */ #if (S1AP_VERSION >= MAKE_VERSION(13, 0, 0)) + if (0) { ie = (S1AP_S1SetupRequestIEs_t *)calloc(1, sizeof(S1AP_S1SetupRequestIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_UE_RetentionInformation; @@ -558,6 +517,7 @@ static int s1ap_eNB_generate_s1_setup_request( // ie->value.choice.NB_IoT_DefaultPagingDRX = ; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } + #endif /* #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) */ if (s1ap_eNB_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -567,6 +527,5 @@ static int s1ap_eNB_generate_s1_setup_request( /* Non UE-Associated signalling -> stream = 0 */ s1ap_eNB_itti_send_sctp_data_req(instance_p->instance, s1ap_mme_data_p->assoc_id, buffer, len, 0); - return ret; } diff --git a/openair3/S1AP/s1ap_eNB_handlers.c b/openair3/S1AP/s1ap_eNB_handlers.c index 5c6b208b87336111216ec516b78448b47971aa94..0f7afb68f76d03d2ae832a2ce49f848db6c64504 100644 --- a/openair3/S1AP/s1ap_eNB_handlers.c +++ b/openair3/S1AP/s1ap_eNB_handlers.c @@ -66,13 +66,13 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, static int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, - uint32_t stream, - S1AP_S1AP_PDU_t *pdu); + uint32_t stream, + S1AP_S1AP_PDU_t *pdu); static int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, - uint32_t stream, - S1AP_S1AP_PDU_t *pdu); + uint32_t stream, + S1AP_S1AP_PDU_t *pdu); static int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, @@ -86,13 +86,13 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, static int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, - uint32_t stream, - S1AP_S1AP_PDU_t *pdu); + uint32_t stream, + S1AP_S1AP_PDU_t *pdu); static int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, - uint32_t stream, - S1AP_S1AP_PDU_t *pdu); + uint32_t stream, + S1AP_S1AP_PDU_t *pdu); /* Handlers matrix. Only eNB related procedure present here */ s1ap_message_decoded_callback messages_callback[][3] = { @@ -148,16 +148,15 @@ s1ap_message_decoded_callback messages_callback[][3] = { #endif /* #if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) */ }; char *s1ap_direction2String(int s1ap_dir) { -static char *s1ap_direction_String[] = { - "", /* Nothing */ - "Originating message", /* originating message */ - "Successfull outcome", /* successfull outcome */ - "UnSuccessfull outcome", /* successfull outcome */ -}; -return(s1ap_direction_String[s1ap_dir]); + static char *s1ap_direction_String[] = { + "", /* Nothing */ + "Originating message", /* originating message */ + "Successfull outcome", /* successfull outcome */ + "UnSuccessfull outcome", /* successfull outcome */ + }; + return(s1ap_direction_String[s1ap_dir]); } -void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shutdown) -{ +void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shutdown) { if (sctp_shutdown) { /* A previously connected MME has been shutdown */ @@ -173,7 +172,6 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut /* If there are no more associated MME, inform eNB app */ if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb == 0) { MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_S1AP, S1AP_DEREGISTERED_ENB_IND); S1AP_DEREGISTERED_ENB_IND(message_p).nb_mme = 0; itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p); @@ -192,7 +190,6 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut /* If there are no more pending messages, inform eNB app */ if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb == 0) { MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_S1AP, S1AP_REGISTER_ENB_CNF); S1AP_REGISTER_ENB_CNF(message_p).nb_mme = mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb; itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p); @@ -201,13 +198,10 @@ void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shut } int s1ap_eNB_handle_message(uint32_t assoc_id, int32_t stream, - const uint8_t *const data, const uint32_t data_length) -{ + const uint8_t *const data, const uint32_t data_length) { S1AP_S1AP_PDU_t pdu; int ret; - DevAssert(data != NULL); - memset(&pdu, 0, sizeof(pdu)); if (s1ap_eNB_decode_pdu(&pdu, data, data_length) < 0) { @@ -246,14 +240,11 @@ int s1ap_eNB_handle_message(uint32_t assoc_id, int32_t stream, static int s1ap_eNB_handle_s1_setup_failure(uint32_t assoc_id, uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + S1AP_S1AP_PDU_t *pdu) { S1AP_S1SetupFailure_t *container; S1AP_S1SetupFailureIEs_t *ie; s1ap_eNB_mme_data_t *mme_desc_p; - DevAssert(pdu != NULL); - container = &pdu->choice.unsuccessfulOutcome.value.choice.S1SetupFailure; /* S1 Setup Failure == Non UE-related procedure -> stream 0 */ @@ -280,22 +271,18 @@ int s1ap_eNB_handle_s1_setup_failure(uint32_t assoc_id, mme_desc_p->state = S1AP_ENB_STATE_WAITING; s1ap_handle_s1_setup_message(mme_desc_p, 0); - return 0; } static int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + S1AP_S1AP_PDU_t *pdu) { S1AP_S1SetupResponse_t *container; S1AP_S1SetupResponseIEs_t *ie; s1ap_eNB_mme_data_t *mme_desc_p; int i; - DevAssert(pdu != NULL); - container = &pdu->choice.successfulOutcome.value.choice.S1SetupResponse; /* S1 Setup Response == Non UE-related procedure -> stream 0 */ @@ -324,20 +311,16 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, S1AP_ServedGUMMEIsItem_t *gummei_item_p; struct served_gummei_s *new_gummei_p; int j; - gummei_item_p = ie->value.choice.ServedGUMMEIs.list.array[i]; new_gummei_p = calloc(1, sizeof(struct served_gummei_s)); - STAILQ_INIT(&new_gummei_p->served_plmns); STAILQ_INIT(&new_gummei_p->served_group_ids); STAILQ_INIT(&new_gummei_p->mme_codes); - S1AP_DEBUG("servedPLMNs.list.count %d\n", gummei_item_p->servedPLMNs.list.count); for (j = 0; j < gummei_item_p->servedPLMNs.list.count; j++) { S1AP_PLMNidentity_t *plmn_identity_p; struct plmn_identity_s *new_plmn_identity_p; - plmn_identity_p = gummei_item_p->servedPLMNs.list.array[j]; new_plmn_identity_p = calloc(1, sizeof(struct plmn_identity_s)); TBCD_TO_MCC_MNC(plmn_identity_p, new_plmn_identity_p->mcc, @@ -349,7 +332,6 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, for (j = 0; j < gummei_item_p->servedGroupIDs.list.count; j++) { S1AP_MME_Group_ID_t *mme_group_id_p; struct served_group_id_s *new_group_id_p; - mme_group_id_p = gummei_item_p->servedGroupIDs.list.array[j]; new_group_id_p = calloc(1, sizeof(struct served_group_id_s)); OCTET_STRING_TO_INT16(mme_group_id_p, new_group_id_p->mme_group_id); @@ -360,10 +342,8 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, for (j = 0; j < gummei_item_p->servedMMECs.list.count; j++) { S1AP_MME_Code_t *mme_code_p; struct mme_code_s *new_mme_code_p; - mme_code_p = gummei_item_p->servedMMECs.list.array[j]; new_mme_code_p = calloc(1, sizeof(struct mme_code_s)); - OCTET_STRING_TO_INT8(mme_code_p, new_mme_code_p->mme_code); STAILQ_INSERT_TAIL(&new_gummei_p->mme_codes, new_mme_code_p, next); new_gummei_p->nb_mme_code++; @@ -376,10 +356,10 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container, S1AP_ProtocolIE_ID_id_RelativeMMECapacity, true); mme_desc_p->relative_mme_capacity = ie->value.choice.RelativeMMECapacity; - /* Optionaly set the mme name */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_S1SetupResponseIEs_t, ie, container, S1AP_ProtocolIE_ID_id_MMEname, false); + if (ie) { mme_desc_p->mme_name = calloc(ie->value.choice.MMEname.size + 1, sizeof(char)); memcpy(mme_desc_p->mme_name, ie->value.choice.MMEname.buf, @@ -394,7 +374,6 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, mme_desc_p->state = S1AP_ENB_STATE_CONNECTED; mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb ++; s1ap_handle_s1_setup_message(mme_desc_p, 0); - return 0; } @@ -402,14 +381,11 @@ int s1ap_eNB_handle_s1_setup_response(uint32_t assoc_id, static int s1ap_eNB_handle_error_indication(uint32_t assoc_id, uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + S1AP_S1AP_PDU_t *pdu) { S1AP_ErrorIndication_t *container; S1AP_ErrorIndicationIEs_t *ie; s1ap_eNB_mme_data_t *mme_desc_p; - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage.value.choice.ErrorIndication; /* S1 Setup Failure == Non UE-related procedure -> stream 0 */ @@ -455,118 +431,156 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, case S1AP_CauseRadioNetwork_unspecified: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unspecified\n"); break; + case S1AP_CauseRadioNetwork_tx2relocoverall_expiry: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_tx2relocoverall_expiry\n"); break; + case S1AP_CauseRadioNetwork_successful_handover: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_successful_handover\n"); break; + case S1AP_CauseRadioNetwork_release_due_to_eutran_generated_reason: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_release_due_to_eutran_generated_reason\n"); break; + case S1AP_CauseRadioNetwork_handover_cancelled: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_handover_cancelled\n"); break; + case S1AP_CauseRadioNetwork_partial_handover: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_partial_handover\n"); break; + case S1AP_CauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system\n"); break; + case S1AP_CauseRadioNetwork_ho_target_not_allowed: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_ho_target_not_allowed\n"); break; + case S1AP_CauseRadioNetwork_tS1relocoverall_expiry: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_tS1relocoverall_expiry\n"); break; + case S1AP_CauseRadioNetwork_tS1relocprep_expiry: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_tS1relocprep_expiry\n"); break; + case S1AP_CauseRadioNetwork_cell_not_available: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_cell_not_available\n"); break; + case S1AP_CauseRadioNetwork_unknown_targetID: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_targetID\n"); break; + case S1AP_CauseRadioNetwork_no_radio_resources_available_in_target_cell: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_no_radio_resources_available_in_target_cell\n"); break; + case S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id\n"); break; + case S1AP_CauseRadioNetwork_unknown_enb_ue_s1ap_id: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_enb_ue_s1ap_id\n"); break; + case S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_pair_ue_s1ap_id\n"); break; + case S1AP_CauseRadioNetwork_handover_desirable_for_radio_reason: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_handover_desirable_for_radio_reason\n"); break; + case S1AP_CauseRadioNetwork_time_critical_handover: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_time_critical_handover\n"); break; + case S1AP_CauseRadioNetwork_resource_optimisation_handover: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_resource_optimisation_handover\n"); break; + case S1AP_CauseRadioNetwork_reduce_load_in_serving_cell: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_reduce_load_in_serving_cell\n"); break; + case S1AP_CauseRadioNetwork_user_inactivity: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_user_inactivity\n"); break; + case S1AP_CauseRadioNetwork_radio_connection_with_ue_lost: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_radio_connection_with_ue_lost\n"); break; + case S1AP_CauseRadioNetwork_load_balancing_tau_required: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_load_balancing_tau_required\n"); break; + case S1AP_CauseRadioNetwork_cs_fallback_triggered: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_cs_fallback_triggered\n"); break; + case S1AP_CauseRadioNetwork_ue_not_available_for_ps_service: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_ue_not_available_for_ps_service\n"); break; + case S1AP_CauseRadioNetwork_radio_resources_not_available: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_radio_resources_not_available\n"); break; + case S1AP_CauseRadioNetwork_failure_in_radio_interface_procedure: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_failure_in_radio_interface_procedure\n"); break; + case S1AP_CauseRadioNetwork_invalid_qos_combination: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_invals1ap_id_qos_combination\n"); break; + case S1AP_CauseRadioNetwork_interrat_redirection: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_interrat_redirection\n"); break; + case S1AP_CauseRadioNetwork_interaction_with_other_procedure: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_interaction_with_other_procedure\n"); break; + case S1AP_CauseRadioNetwork_unknown_E_RAB_ID: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_unknown_E_RAB_ID\n"); break; + case S1AP_CauseRadioNetwork_multiple_E_RAB_ID_instances: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_multiple_E_RAB_ID_instances\n"); break; + case S1AP_CauseRadioNetwork_encryption_and_or_integrity_protection_algorithms_not_supported: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_encryption_and_or_integrity_protection_algorithms_not_supported\n"); break; + case S1AP_CauseRadioNetwork_s1_intra_system_handover_triggered: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_s1_intra_system_handover_triggered\n"); break; + case S1AP_CauseRadioNetwork_s1_inter_system_handover_triggered: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_s1_inter_system_handover_triggered\n"); break; + case S1AP_CauseRadioNetwork_x2_handover_triggered: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_x2_handover_triggered\n"); break; + case S1AP_CauseRadioNetwork_redirection_towards_1xRTT: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_redirection_towards_1xRTT\n"); break; + case S1AP_CauseRadioNetwork_not_supported_QCI_value: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_not_supported_QCI_value\n"); break; #if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) + case S1AP_CauseRadioNetwork_invalid_CSG_Id: S1AP_WARN("Received S1 Error indication S1AP_CauseRadioNetwork_invals1ap_id_CSG_Id\n"); break; @@ -575,6 +589,7 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, default: S1AP_WARN("Received S1 Error indication cause radio network case not handled\n"); } + break; case S1AP_Cause_PR_transport: @@ -582,12 +597,15 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, case S1AP_CauseTransport_transport_resource_unavailable: S1AP_WARN("Received S1 Error indication S1AP_CauseTransport_transport_resource_unavailable\n"); break; + case S1AP_CauseTransport_unspecified: S1AP_WARN("Received S1 Error indication S1AP_CauseTransport_unspecified\n"); break; + default: S1AP_WARN("Received S1 Error indication cause transport case not handled\n"); } + break; case S1AP_Cause_PR_nas: @@ -595,20 +613,25 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, case S1AP_CauseNas_normal_release: S1AP_WARN("Received S1 Error indication S1AP_CauseNas_normal_release\n"); break; + case S1AP_CauseNas_authentication_failure: S1AP_WARN("Received S1 Error indication S1AP_CauseNas_authentication_failure\n"); break; + case S1AP_CauseNas_detach: S1AP_WARN("Received S1 Error indication S1AP_CauseNas_detach\n"); break; + case S1AP_CauseNas_unspecified: S1AP_WARN("Received S1 Error indication S1AP_CauseNas_unspecified\n"); break; #if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) + case S1AP_CauseNas_csg_subscription_expiry: S1AP_WARN("Received S1 Error indication S1AP_CauseNas_csg_subscription_expiry\n"); break; #endif /* #if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) */ + default: S1AP_WARN("Received S1 Error indication cause nas case not handled\n"); } @@ -620,27 +643,35 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, case S1AP_CauseProtocol_transfer_syntax_error: S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_transfer_syntax_error\n"); break; + case S1AP_CauseProtocol_abstract_syntax_error_reject: S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_abstract_syntax_error_reject\n"); break; + case S1AP_CauseProtocol_abstract_syntax_error_ignore_and_notify: S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_abstract_syntax_error_ignore_and_notify\n"); break; + case S1AP_CauseProtocol_message_not_compatible_with_receiver_state: S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_message_not_compatible_with_receiver_state\n"); break; + case S1AP_CauseProtocol_semantic_error: S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_semantic_error\n"); break; + case S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message: S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_abstract_syntax_error_falsely_constructed_message\n"); break; + case S1AP_CauseProtocol_unspecified: S1AP_WARN("Received S1 Error indication S1AP_CauseProtocol_unspecified\n"); break; + default: S1AP_WARN("Received S1 Error indication cause protocol case not handled\n"); } + break; case S1AP_Cause_PR_misc: @@ -648,24 +679,31 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, case S1AP_CauseMisc_control_processing_overload: S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_control_processing_overload\n"); break; + case S1AP_CauseMisc_not_enough_user_plane_processing_resources: S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_not_enough_user_plane_processing_resources\n"); break; + case S1AP_CauseMisc_hardware_failure: S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_hardware_failure\n"); break; + case S1AP_CauseMisc_om_intervention: S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_om_intervention\n"); break; + case S1AP_CauseMisc_unspecified: S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_unspecified\n"); break; + case S1AP_CauseMisc_unknown_PLMN: S1AP_WARN("Received S1 Error indication S1AP_CauseMisc_unknown_PLMN\n"); break; + default: S1AP_WARN("Received S1 Error indication cause misc case not handled\n"); } + break; } } @@ -676,8 +714,8 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, if (ie) { // TODO continue } - // TODO continue + // TODO continue return 0; } @@ -685,8 +723,7 @@ int s1ap_eNB_handle_error_indication(uint32_t assoc_id, static int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + S1AP_S1AP_PDU_t *pdu) { int i; s1ap_eNB_mme_data_t *mme_desc_p = NULL; s1ap_eNB_ue_context_t *ue_desc_p = NULL; @@ -695,9 +732,7 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, S1AP_InitialContextSetupRequestIEs_t *ie; S1AP_ENB_UE_S1AP_ID_t enb_ue_s1ap_id; S1AP_MME_UE_S1AP_ID_t mme_ue_s1ap_id; - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage.value.choice.InitialContextSetupRequest; if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { @@ -710,14 +745,13 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; - /* id-eNB-UE-S1AP-ID */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, - enb_ue_s1ap_id)) == NULL) { + enb_ue_s1ap_id)) == NULL) { S1AP_ERROR("[SCTP %d] Received initial context setup request for non " "existing UE context 0x%06lx\n", assoc_id, enb_ue_s1ap_id); @@ -732,16 +766,11 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, } ue_desc_p->rx_stream = stream; - ue_desc_p->mme_ue_s1ap_id = mme_ue_s1ap_id; - message_p = itti_alloc_new_message(TASK_S1AP, S1AP_INITIAL_CONTEXT_SETUP_REQ); - S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_initial_id = ue_desc_p->ue_initial_id; ue_desc_p->ue_initial_id = 0; - S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).eNB_ue_s1ap_id = ue_desc_p->eNB_ue_s1ap_id; - /* id-uEaggregateMaximumBitrate */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_uEaggregateMaximumBitrate, true); @@ -749,11 +778,9 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, &(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_ul)); asn_INTEGER2ulong(&(ie->value.choice.UEAggregateMaximumBitrate.uEaggregateMaximumBitRateDL), &(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).ue_ambr.br_dl)); - /* id-E-RABToBeSetupListCtxtSUReq */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_E_RABToBeSetupListCtxtSUReq, true); - S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).nb_of_e_rabs = ie->value.choice.E_RABToBeSetupListCtxtSUReq.list.count; @@ -765,10 +792,8 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, if (item_p->nAS_PDU != NULL) { /* Only copy NAS pdu if present */ S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.length = item_p->nAS_PDU->size; - S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer = malloc(sizeof(uint8_t) * item_p->nAS_PDU->size); - memcpy(S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].nas_pdu.buffer, item_p->nAS_PDU->buf, item_p->nAS_PDU->size); S1AP_DEBUG("Received NAS message with the E_RAB setup procedure\n"); @@ -782,13 +807,10 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, item_p->transportLayerAddress.buf, item_p->transportLayerAddress.size); S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].sgw_addr.length = item_p->transportLayerAddress.size * 8 - item_p->transportLayerAddress.bits_unused; - /* GTP tunnel endpoint ID */ OCTET_STRING_TO_INT32(&item_p->gTP_TEID, S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].gtp_teid); - /* Set the QOS informations */ S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.qci = item_p->e_RABlevelQoSParameters.qCI; - S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.allocation_retention_priority.priority_level = item_p->e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel; S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).e_rab_param[i].qos.allocation_retention_priority.pre_emp_capability = @@ -804,15 +826,12 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.encryptionAlgorithms); S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_capabilities.integrity_algorithms = BIT_STRING_to_uint16(&ie->value.choice.UESecurityCapabilities.integrityProtectionAlgorithms); - /* id-SecurityKey : Copy the security key */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_InitialContextSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_SecurityKey, true); memcpy(&S1AP_INITIAL_CONTEXT_SETUP_REQ(message_p).security_key, ie->value.choice.SecurityKey.buf, ie->value.choice.SecurityKey.size); - itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); - return 0; } @@ -820,8 +839,7 @@ int s1ap_eNB_handle_initial_context_request(uint32_t assoc_id, static int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + S1AP_S1AP_PDU_t *pdu) { s1ap_eNB_mme_data_t *mme_desc_p = NULL; s1ap_eNB_ue_context_t *ue_desc_p = NULL; MessageDef *message_p = NULL; @@ -829,9 +847,7 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, S1AP_ENB_UE_S1AP_ID_t enb_ue_s1ap_id; S1AP_UEContextReleaseCommand_t *container; S1AP_UEContextReleaseCommand_IEs_t *ie; - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage.value.choice.UEContextReleaseCommand; if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { @@ -847,7 +863,6 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, case S1AP_UE_S1AP_IDs_PR_uE_S1AP_ID_pair: enb_ue_s1ap_id = ie->value.choice.UE_S1AP_IDs.choice.uE_S1AP_ID_pair.eNB_UE_S1AP_ID; mme_ue_s1ap_id = ie->value.choice.UE_S1AP_IDs.choice.uE_S1AP_ID_pair.mME_UE_S1AP_ID; - MSC_LOG_RX_MESSAGE( MSC_S1AP_ENB, MSC_S1AP_MME, @@ -858,16 +873,11 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, mme_ue_s1ap_id); if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, - enb_ue_s1ap_id)) == NULL) { + enb_ue_s1ap_id)) == NULL) { S1AP_ERROR("[SCTP %d] Received UE context release command for non " "existing UE context 0x%06lx\n", assoc_id, enb_ue_s1ap_id); - /*MessageDef *msg_complete_p; - msg_complete_p = itti_alloc_new_message(TASK_RRC_ENB, S1AP_UE_CONTEXT_RELEASE_COMPLETE); - S1AP_UE_CONTEXT_RELEASE_COMPLETE(msg_complete_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; - itti_send_msg_to_task(TASK_S1AP, ue_desc_p->eNB_instance->instance <=> 0, msg_complete_p); - */ return -1; } else { MSC_LOG_TX_MESSAGE( @@ -877,6 +887,11 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, "0 S1AP_UE_CONTEXT_RELEASE_COMMAND/%d eNB_ue_s1ap_id "S1AP_UE_ID_FMT" ", enb_ue_s1ap_id); message_p = itti_alloc_new_message(TASK_S1AP, S1AP_UE_CONTEXT_RELEASE_COMMAND); + + if (ue_desc_p->mme_ue_s1ap_id == 0) { // case of Detach Request and switch off from RRC_IDLE mode + ue_desc_p->mme_ue_s1ap_id = mme_ue_s1ap_id; + } + S1AP_UE_CONTEXT_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); return 0; @@ -905,8 +920,7 @@ int s1ap_eNB_handle_ue_context_release_command(uint32_t assoc_id, static int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + S1AP_S1AP_PDU_t *pdu) { int i; S1AP_MME_UE_S1AP_ID_t mme_ue_s1ap_id; S1AP_ENB_UE_S1AP_ID_t enb_ue_s1ap_id; @@ -915,9 +929,7 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, MessageDef *message_p = NULL; S1AP_E_RABSetupRequest_t *container; S1AP_E_RABSetupRequestIEs_t *ie; - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage.value.choice.E_RABSetupRequest; if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { @@ -930,14 +942,13 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; - /* id-eNB-UE-S1AP-ID */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, - enb_ue_s1ap_id)) == NULL) { + enb_ue_s1ap_id)) == NULL) { S1AP_ERROR("[SCTP %d] Received initial context setup request for non " "existing UE context 0x%06lx\n", assoc_id, enb_ue_s1ap_id); @@ -959,11 +970,9 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, } message_p = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_SETUP_REQ); - S1AP_E_RAB_SETUP_REQ(message_p).ue_initial_id = ue_desc_p->ue_initial_id; S1AP_E_RAB_SETUP_REQ(message_p).mme_ue_s1ap_id = mme_ue_s1ap_id; S1AP_E_RAB_SETUP_REQ(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; - S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABSetupRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_E_RABToBeSetupListBearerSUReq, true); S1AP_E_RAB_SETUP_REQ(message_p).nb_e_rabs_tosetup = @@ -971,24 +980,19 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, for (i = 0; i < ie->value.choice.E_RABToBeSetupListBearerSUReq.list.count; i++) { S1AP_E_RABToBeSetupItemBearerSUReq_t *item_p; - item_p = &(((S1AP_E_RABToBeSetupItemBearerSUReqIEs_t *)ie->value.choice.E_RABToBeSetupListBearerSUReq.list.array[i])->value.choice.E_RABToBeSetupItemBearerSUReq); - S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].e_rab_id = item_p->e_RAB_ID; // check for the NAS PDU if (item_p->nAS_PDU.size > 0 ) { S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length = item_p->nAS_PDU.size; - S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer = malloc(sizeof(uint8_t) * item_p->nAS_PDU.size); - memcpy(S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer, item_p->nAS_PDU.buf, item_p->nAS_PDU.size); // S1AP_INFO("received a NAS PDU with size %d (%02x.%02x)\n",S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length, item_p->nAS_PDU.buf[0], item_p->nAS_PDU.buf[1]); } else { S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.length = 0; S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].nas_pdu.buffer = NULL; - S1AP_WARN("NAS PDU is not provided, generate a E_RAB_SETUP Failure (TBD) back to MME \n"); // return -1; } @@ -998,7 +1002,6 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, item_p->transportLayerAddress.buf, item_p->transportLayerAddress.size); S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.length = item_p->transportLayerAddress.size * 8 - item_p->transportLayerAddress.bits_unused; - /* S1AP_INFO("sgw addr %s len: %d (size %d, index %d)\n", S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.buffer, S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].sgw_addr.length, @@ -1006,10 +1009,8 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, */ /* GTP tunnel endpoint ID */ OCTET_STRING_TO_INT32(&item_p->gTP_TEID, S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].gtp_teid); - /* Set the QOS informations */ S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.qci = item_p->e_RABlevelQoSParameters.qCI; - S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.allocation_retention_priority.priority_level = item_p->e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel; S1AP_E_RAB_SETUP_REQ(message_p).e_rab_setup_params[i].qos.allocation_retention_priority.pre_emp_capability = @@ -1019,32 +1020,27 @@ int s1ap_eNB_handle_e_rab_setup_request(uint32_t assoc_id, } itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); - return 0; } static int s1ap_eNB_handle_paging(uint32_t assoc_id, uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + S1AP_S1AP_PDU_t *pdu) { s1ap_eNB_mme_data_t *mme_desc_p = NULL; s1ap_eNB_instance_t *s1ap_eNB_instance = NULL; MessageDef *message_p = NULL; S1AP_Paging_t *container; S1AP_PagingIEs_t *ie; - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage.value.choice.Paging; - // received Paging Message from MME S1AP_DEBUG("[SCTP %d] Received Paging Message From MME\n",assoc_id); /* Paging procedure -> stream != 0 */ if (stream == 0) { LOG_W(S1AP,"[SCTP %d] Received Paging procedure on stream (%d)\n", - assoc_id, stream); + assoc_id, stream); return -1; } @@ -1055,6 +1051,7 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, } s1ap_eNB_instance = mme_desc_p->s1ap_eNB_instance; + if (s1ap_eNB_instance == NULL) { S1AP_ERROR("[SCTP %d] Received Paging for non existing MME context : s1ap_eNB_instance is NULL\n", assoc_id); @@ -1062,7 +1059,6 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, } message_p = itti_alloc_new_message(TASK_S1AP, S1AP_PAGING_IND); - /* convert S1AP_PagingIEs_t to s1ap_paging_ind_t */ /* id-UEIdentityIndexValue : convert UE Identity Index value */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, @@ -1070,13 +1066,12 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, S1AP_PAGING_IND(message_p).ue_index_value = BIT_STRING_to_uint32(&ie->value.choice.UEIdentityIndexValue); S1AP_DEBUG("[SCTP %d] Received Paging ue_index_value (%d)\n", assoc_id,(uint32_t)S1AP_PAGING_IND(message_p).ue_index_value); - S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.mme_code = 0; S1AP_PAGING_IND(message_p).ue_paging_identity.choice.s_tmsi.m_tmsi = 0; - /* id-UEPagingID */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, S1AP_ProtocolIE_ID_id_UEPagingID, true); + /* convert UE Paging Identity */ if (ie->value.choice.UEPagingID.present == S1AP_UEPagingID_PR_s_TMSI) { S1AP_PAGING_IND(message_p).ue_paging_identity.presenceMask = UE_PAGING_IDENTITY_s_tmsi; @@ -1115,7 +1110,6 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, } S1AP_PAGING_IND(message_p).paging_drx = PAGING_DRX_256; - /* id-pagingDRX */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, S1AP_ProtocolIE_ID_id_pagingDRX, false); @@ -1145,7 +1139,6 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, memset (&S1AP_PAGING_IND(message_p).plmn_identity[0], 0, sizeof(plmn_identity_t)*256); memset (&S1AP_PAGING_IND(message_p).tac[0], 0, sizeof(int16_t)*256); S1AP_PAGING_IND(message_p).tai_size = 0; - /* id-TAIList */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_PagingIEs_t, ie, container, S1AP_ProtocolIE_ID_id_TAIList, true); @@ -1165,7 +1158,6 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, S1AP_PAGING_IND(message_p).tac[i]); } - //paging parameter values S1AP_DEBUG("[SCTP %d] Received Paging parameters: ue_index_value %d cn_domain %d paging_drx %d paging_priority %d\n",assoc_id, S1AP_PAGING_IND(message_p).ue_index_value, S1AP_PAGING_IND(message_p).cn_domain, @@ -1176,18 +1168,15 @@ int s1ap_eNB_handle_paging(uint32_t assoc_id, S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[0], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[1], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[2], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[3], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[4], S1AP_PAGING_IND(message_p).ue_paging_identity.choice.imsi.buffer[5]); - /* send message to RRC */ itti_send_msg_to_task(TASK_RRC_ENB, s1ap_eNB_instance->instance, message_p); - return 0; } static int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, - uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + uint32_t stream, + S1AP_S1AP_PDU_t *pdu) { int i, nb_of_e_rabs_failed; s1ap_eNB_mme_data_t *mme_desc_p = NULL; s1ap_eNB_ue_context_t *ue_desc_p = NULL; @@ -1196,9 +1185,7 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, S1AP_E_RABModifyRequestIEs_t *ie; S1AP_ENB_UE_S1AP_ID_t enb_ue_s1ap_id; S1AP_MME_UE_S1AP_ID_t mme_ue_s1ap_id; - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage.value.choice.E_RABModifyRequest; if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { @@ -1211,14 +1198,13 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; - /* id-eNB-UE-S1AP-ID */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, - enb_ue_s1ap_id)) == NULL) { + enb_ue_s1ap_id)) == NULL) { S1AP_ERROR("[SCTP %d] Received E-RAB modify request for non " "existing UE context 0x%06lx\n", assoc_id, enb_ue_s1ap_id); @@ -1238,9 +1224,7 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, S1AP_WARN("UE context mme_ue_s1ap_id is different form that of the message (%d != %ld)", ue_desc_p->mme_ue_s1ap_id, mme_ue_s1ap_id); message_p = itti_alloc_new_message (TASK_RRC_ENB, S1AP_E_RAB_MODIFY_RESP); - S1AP_E_RAB_MODIFY_RESP (message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; - S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, true); @@ -1252,22 +1236,18 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[nb_of_e_rabs_failed].cause = S1AP_Cause_PR_radioNetwork; S1AP_E_RAB_MODIFY_RESP(message_p).e_rabs_failed[nb_of_e_rabs_failed].cause_value = S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id; } - S1AP_E_RAB_MODIFY_RESP(message_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; + S1AP_E_RAB_MODIFY_RESP(message_p).nb_of_e_rabs_failed = nb_of_e_rabs_failed; s1ap_eNB_e_rab_modify_resp(mme_desc_p->s1ap_eNB_instance->instance, &S1AP_E_RAB_MODIFY_RESP(message_p)); - message_p = NULL; return -1; } message_p = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_MODIFY_REQ); - S1AP_E_RAB_MODIFY_REQ(message_p).ue_initial_id = ue_desc_p->ue_initial_id; - S1AP_E_RAB_MODIFY_REQ(message_p).mme_ue_s1ap_id = mme_ue_s1ap_id; S1AP_E_RAB_MODIFY_REQ(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; - /* id-E-RABToBeModifiedListBearerModReq */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABModifyRequestIEs_t, ie, container, S1AP_ProtocolIE_ID_id_E_RABToBeModifiedListBearerModReq, true); @@ -1282,9 +1262,7 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, // check for the NAS PDU if (item_p->nAS_PDU.size > 0 ) { S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.length = item_p->nAS_PDU.size; - S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.buffer = malloc(sizeof(uint8_t) * item_p->nAS_PDU.size); - memcpy(S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].nas_pdu.buffer, item_p->nAS_PDU.buf, item_p->nAS_PDU.size); } else { @@ -1295,26 +1273,22 @@ int s1ap_eNB_handle_e_rab_modify_request(uint32_t assoc_id, /* Set the QOS informations */ S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.qci = item_p->e_RABLevelQoSParameters.qCI; - S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.priority_level = item_p->e_RABLevelQoSParameters.allocationRetentionPriority.priorityLevel; S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.pre_emp_capability = item_p->e_RABLevelQoSParameters.allocationRetentionPriority.pre_emptionCapability; S1AP_E_RAB_MODIFY_REQ(message_p).e_rab_modify_params[i].qos.allocation_retention_priority.pre_emp_vulnerability = item_p->e_RABLevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability; - } itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); - return 0; } // handle e-rab release command and send it to rrc_end static int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, - uint32_t stream, - S1AP_S1AP_PDU_t *pdu) -{ + uint32_t stream, + S1AP_S1AP_PDU_t *pdu) { int i; s1ap_eNB_mme_data_t *mme_desc_p = NULL; s1ap_eNB_ue_context_t *ue_desc_p = NULL; @@ -1323,9 +1297,7 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, S1AP_E_RABReleaseCommandIEs_t *ie; S1AP_ENB_UE_S1AP_ID_t enb_ue_s1ap_id; S1AP_MME_UE_S1AP_ID_t mme_ue_s1ap_id; - DevAssert(pdu != NULL); - container = &pdu->choice.initiatingMessage.value.choice.E_RABReleaseCommand; if ((mme_desc_p = s1ap_eNB_get_MME(NULL, assoc_id, 0)) == NULL) { @@ -1337,14 +1309,13 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container, S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; - /* id-eNB-UE-S1AP-ID */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container, S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; if ((ue_desc_p = s1ap_eNB_get_ue_context(mme_desc_p->s1ap_eNB_instance, - enb_ue_s1ap_id)) == NULL) { + enb_ue_s1ap_id)) == NULL) { S1AP_ERROR("[SCTP %d] Received E-RAB release command for non existing UE context 0x%06lx\n", assoc_id, ie->value.choice.ENB_UE_S1AP_ID); return -1; @@ -1366,14 +1337,13 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, S1AP_DEBUG("[SCTP %d] Received E-RAB release command for eNB_UE_S1AP_ID %ld mme_ue_s1ap_id %ld\n", assoc_id, enb_ue_s1ap_id, mme_ue_s1ap_id); - message_p = itti_alloc_new_message(TASK_S1AP, S1AP_E_RAB_RELEASE_COMMAND); S1AP_E_RAB_RELEASE_COMMAND(message_p).eNB_ue_s1ap_id = enb_ue_s1ap_id; S1AP_E_RAB_RELEASE_COMMAND(message_p).mme_ue_s1ap_id = mme_ue_s1ap_id; - /* id-NAS-PDU */ S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_E_RABReleaseCommandIEs_t, ie, container, S1AP_ProtocolIE_ID_id_NAS_PDU, false); + if(ie && ie->value.choice.NAS_PDU.size > 0) { S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.length = ie->value.choice.NAS_PDU.size; S1AP_E_RAB_RELEASE_COMMAND(message_p).nas_pdu.buffer = @@ -1399,6 +1369,5 @@ int s1ap_eNB_handle_e_rab_release_command(uint32_t assoc_id, } itti_send_msg_to_task(TASK_RRC_ENB, ue_desc_p->eNB_instance->instance, message_p); - return 0; } diff --git a/openair3/S1AP/s1ap_eNB_nas_procedures.c b/openair3/S1AP/s1ap_eNB_nas_procedures.c index 80266a4d9ca5546766d0bcbfc81e702f8f6899f9..2189140dad0213e506d46b86ab26fcb488fd0714 100644 --- a/openair3/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair3/S1AP/s1ap_eNB_nas_procedures.c @@ -61,13 +61,10 @@ int s1ap_eNB_handle_nas_first_req( S1AP_InitialUEMessage_IEs_t *ie; uint8_t *buffer = NULL; uint32_t length = 0; - DevAssert(s1ap_nas_first_req_p != NULL); - /* Retrieve the S1AP eNB instance associated with Mod_id */ instance_p = s1ap_eNB_get_instance(instance); DevAssert(instance_p != NULL); - memset(&pdu, 0, sizeof(pdu)); pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage; pdu.choice.initiatingMessage.procedureCode = S1AP_ProcedureCode_id_initialUEMessage; @@ -81,6 +78,7 @@ int s1ap_eNB_handle_nas_first_req( instance_p, s1ap_nas_first_req_p->establishment_cause, s1ap_nas_first_req_p->ue_identity.gummei); + if (mme_desc_p) { S1AP_INFO("[eNB %d] Chose MME '%s' (assoc_id %d) through GUMMEI MCC %d MNC %d MMEGI %d MMEC %d\n", instance, @@ -101,6 +99,7 @@ int s1ap_eNB_handle_nas_first_req( s1ap_nas_first_req_p->establishment_cause, s1ap_nas_first_req_p->selected_plmn_identity, s1ap_nas_first_req_p->ue_identity.s_tmsi.mme_code); + if (mme_desc_p) { S1AP_INFO("[eNB %d] Chose MME '%s' (assoc_id %d) through S-TMSI MMEC %d and selected PLMN Identity index %d MCC %d MNC %d\n", instance, @@ -121,6 +120,7 @@ int s1ap_eNB_handle_nas_first_req( instance_p, s1ap_nas_first_req_p->establishment_cause, s1ap_nas_first_req_p->selected_plmn_identity); + if (mme_desc_p) { S1AP_INFO("[eNB %d] Chose MME '%s' (assoc_id %d) through selected PLMN Identity index %d MCC %d MNC %d\n", instance, @@ -140,6 +140,7 @@ int s1ap_eNB_handle_nas_first_req( mme_desc_p = s1ap_eNB_nnsf_select_mme( instance_p, s1ap_nas_first_req_p->establishment_cause); + if (mme_desc_p) { S1AP_INFO("[eNB %d] Chose MME '%s' (assoc_id %d) through highest relative capacity\n", instance, @@ -153,7 +154,6 @@ int s1ap_eNB_handle_nas_first_req( * In case eNB has no MME associated, the eNB should inform RRC and discard * this request. */ - S1AP_WARN("No MME is associated to the eNB\n"); // TODO: Inform RRC return -1; @@ -164,7 +164,6 @@ int s1ap_eNB_handle_nas_first_req( */ ue_desc_p = s1ap_eNB_allocate_new_UE_context(); DevAssert(ue_desc_p != NULL); - /* Keep a reference to the selected MME */ ue_desc_p->mme_ref = mme_desc_p; ue_desc_p->ue_initial_id = s1ap_nas_first_req_p->ue_initial_id; @@ -173,7 +172,6 @@ int s1ap_eNB_handle_nas_first_req( do { struct s1ap_eNB_ue_context_s *collision_p; - /* Peek a random value for the eNB_ue_s1ap_id */ ue_desc_p->eNB_ue_s1ap_id = (random() + random()) & 0x00ffffff; @@ -194,7 +192,6 @@ int s1ap_eNB_handle_nas_first_req( ie->value.present = S1AP_InitialUEMessage_IEs__value_PR_ENB_UE_S1AP_ID; ie->value.choice.ENB_UE_S1AP_ID = ue_desc_p->eNB_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_NAS_PDU; @@ -210,7 +207,6 @@ int s1ap_eNB_handle_nas_first_req( #endif ie->value.choice.NAS_PDU.size = s1ap_nas_first_req_p->nas_pdu.length; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_TAI; @@ -223,7 +219,6 @@ int s1ap_eNB_handle_nas_first_req( instance_p->mnc_digit_length[ue_desc_p->selected_plmn_identity], &ie->value.choice.TAI.pLMNidentity); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_EUTRAN_CGI; @@ -242,11 +237,9 @@ int s1ap_eNB_handle_nas_first_req( instance_p->mnc_digit_length[ue_desc_p->selected_plmn_identity], &ie->value.choice.EUTRAN_CGI.pLMNidentity); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* Set the establishment cause according to those provided by RRC */ DevCheck(s1ap_nas_first_req_p->establishment_cause < RRC_CAUSE_LAST, s1ap_nas_first_req_p->establishment_cause, RRC_CAUSE_LAST, 0); - /* mandatory */ ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_RRC_Establishment_Cause; @@ -300,6 +293,7 @@ int s1ap_eNB_handle_nas_first_req( /* optional */ #if (S1AP_VERSION >= MAKE_VERSION(9, 0, 0)) + if (0) { ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_CellAccessMode; @@ -311,6 +305,7 @@ int s1ap_eNB_handle_nas_first_req( /* optional */ #if (S1AP_VERSION >= MAKE_VERSION(10, 0, 0)) + if (0) { ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_GW_TransportLayerAddress; @@ -331,6 +326,7 @@ int s1ap_eNB_handle_nas_first_req( } #if (S1AP_VERSION >= MAKE_VERSION(11, 0, 0)) + /* optional */ if (0) { ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); @@ -372,6 +368,7 @@ int s1ap_eNB_handle_nas_first_req( } #if (S1AP_VERSION >= MAKE_VERSION(13, 0, 0)) + /* optional */ if (0) { ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); @@ -403,6 +400,7 @@ int s1ap_eNB_handle_nas_first_req( } #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) + /* optional */ if (0) { ie = (S1AP_InitialUEMessage_IEs_t *)calloc(1, sizeof(S1AP_InitialUEMessage_IEs_t)); @@ -422,6 +420,7 @@ int s1ap_eNB_handle_nas_first_req( // ie->value.choice.Coverage_Level = ue_release_req_p->eNB_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } + #endif /* #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) */ #endif /* #if (S1AP_VERSION >= MAKE_VERSION(13, 0, 0)) */ #endif /* #if (S1AP_VERSION >= MAKE_VERSION(11, 0, 0)) */ @@ -435,7 +434,6 @@ int s1ap_eNB_handle_nas_first_req( /* Update the current S1AP UE state */ ue_desc_p->ue_state = S1AP_UE_WAITING_CSR; - /* Assign a stream for this UE : * From 3GPP 36.412 7)Transport layers: * Within the SCTP association established between one MME and eNB pair: @@ -455,7 +453,6 @@ int s1ap_eNB_handle_nas_first_req( } ue_desc_p->tx_stream = mme_desc_p->nextstream; - MSC_LOG_TX_MESSAGE( MSC_S1AP_ENB, MSC_S1AP_MME, @@ -464,11 +461,9 @@ int s1ap_eNB_handle_nas_first_req( MSC_AS_TIME_FMT" initialUEMessage initiatingMessage eNB_ue_s1ap_id %u", 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), ue_desc_p->eNB_ue_s1ap_id); - /* Send encoded message over sctp */ s1ap_eNB_itti_send_sctp_data_req(instance_p->instance, mme_desc_p->assoc_id, buffer, length, ue_desc_p->tx_stream); - return 0; } @@ -502,20 +497,17 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, } s1ap_eNB_instance = mme_desc_p->s1ap_eNB_instance; - /* Prepare the S1AP message to encode */ container = &pdu->choice.initiatingMessage.value.choice.DownlinkNASTransport; - S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; - S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance, - enb_ue_s1ap_id)) == NULL) { + enb_ue_s1ap_id)) == NULL) { MSC_LOG_RX_DISCARDED_MESSAGE( MSC_S1AP_ENB, MSC_S1AP_MME, @@ -563,7 +555,6 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, MSC_AS_TIME_FMT" downlinkNASTransport eNB_ue_s1ap_id %u mme_ue_s1ap_id %u", assoc_id, mme_ue_s1ap_id); - S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_ProtocolIE_ID_id_NAS_PDU, true); /* Forward the NAS PDU to RRC */ @@ -572,10 +563,6 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, ue_desc_p->eNB_ue_s1ap_id, ie->value.choice.NAS_PDU.buf, ie->value.choice.NAS_PDU.size); - - // LG: Why set to 0 ?? - //ue_desc_p->ue_initial_id = 0; - return 0; } @@ -590,9 +577,7 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ S1AP_UplinkNASTransport_IEs_t *ie; uint8_t *buffer; uint32_t length; - DevAssert(s1ap_uplink_nas_p != NULL); - /* Retrieve the S1AP eNB instance associated with Mod_id */ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); DevAssert(s1ap_eNB_instance_p != NULL); @@ -622,7 +607,6 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore; pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_UplinkNASTransport; out = &pdu.choice.initiatingMessage.value.choice.UplinkNASTransport; - /* mandatory */ ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID; @@ -630,7 +614,6 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_MME_UE_S1AP_ID; ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID; @@ -638,7 +621,6 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ ie->value.present = S1AP_UplinkNASTransport_IEs__value_PR_ENB_UE_S1AP_ID; ie->value.choice.ENB_UE_S1AP_ID = ue_context_p->eNB_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_NAS_PDU; @@ -647,7 +629,6 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ ie->value.choice.NAS_PDU.buf = s1ap_uplink_nas_p->nas_pdu.buffer; ie->value.choice.NAS_PDU.size = s1ap_uplink_nas_p->nas_pdu.length; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_EUTRAN_CGI; @@ -663,7 +644,6 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ 0, &ie->value.choice.EUTRAN_CGI.cell_ID); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_TAI; @@ -676,9 +656,9 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ &ie->value.choice.TAI.pLMNidentity); TAC_TO_ASN1(s1ap_eNB_instance_p->tac, &ie->value.choice.TAI.tAC); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* optional */ #if (S1AP_VERSION >= MAKE_VERSION(10, 0, 0)) + if (0) { ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_GW_TransportLayerAddress; @@ -690,6 +670,7 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ /* optional */ #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) + if (0) { ie = (S1AP_UplinkNASTransport_IEs_t *)calloc(1, sizeof(S1AP_UplinkNASTransport_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_SIPTO_L_GW_TransportLayerAddress; @@ -708,6 +689,7 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ // ie->value.choice.LHN_ID =; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } + #endif /* #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) */ #endif /* #if (S1AP_VERSION >= MAKE_VERSION(10, 0, 0)) */ @@ -726,12 +708,10 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), ue_context_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id); - /* UE associated signalling -> use the allocated stream */ s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, ue_context_p->mme_ref->assoc_id, buffer, length, ue_context_p->tx_stream); - return 0; } @@ -748,9 +728,7 @@ int s1ap_eNB_nas_non_delivery_ind(instance_t instance, S1AP_NASNonDeliveryIndication_IEs_t *ie; uint8_t *buffer; uint32_t length; - DevAssert(s1ap_nas_non_delivery_ind != NULL); - /* Retrieve the S1AP eNB instance associated with Mod_id */ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); DevAssert(s1ap_eNB_instance_p != NULL); @@ -773,7 +751,6 @@ int s1ap_eNB_nas_non_delivery_ind(instance_t instance, pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore; pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_NASNonDeliveryIndication; out = &pdu.choice.initiatingMessage.value.choice.NASNonDeliveryIndication; - /* mandatory */ ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID; @@ -781,7 +758,6 @@ int s1ap_eNB_nas_non_delivery_ind(instance_t instance, ie->value.present = S1AP_NASNonDeliveryIndication_IEs__value_PR_MME_UE_S1AP_ID; ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID; @@ -789,7 +765,6 @@ int s1ap_eNB_nas_non_delivery_ind(instance_t instance, ie->value.present = S1AP_NASNonDeliveryIndication_IEs__value_PR_ENB_UE_S1AP_ID; ie->value.choice.ENB_UE_S1AP_ID = ue_context_p->eNB_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_NAS_PDU; @@ -797,9 +772,7 @@ int s1ap_eNB_nas_non_delivery_ind(instance_t instance, ie->value.present = S1AP_NASNonDeliveryIndication_IEs__value_PR_NAS_PDU; ie->value.choice.NAS_PDU.buf = s1ap_nas_non_delivery_ind->nas_pdu.buffer; ie->value.choice.NAS_PDU.size = s1ap_nas_non_delivery_ind->nas_pdu.length; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_NASNonDeliveryIndication_IEs_t *)calloc(1, sizeof(S1AP_NASNonDeliveryIndication_IEs_t)); ie->id = S1AP_ProtocolIE_ID_id_Cause; @@ -828,7 +801,6 @@ int s1ap_eNB_nas_non_delivery_ind(instance_t instance, 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), ue_context_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id); - /* UE associated signalling -> use the allocated stream */ s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, ue_context_p->mme_ref->assoc_id, buffer, @@ -849,10 +821,8 @@ int s1ap_eNB_initial_ctxt_resp( uint8_t *buffer = NULL; uint32_t length; int i; - /* Retrieve the S1AP eNB instance associated with Mod_id */ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); - DevAssert(initial_ctxt_resp_p != NULL); DevAssert(s1ap_eNB_instance_p != NULL); @@ -882,7 +852,6 @@ int s1ap_eNB_initial_ctxt_resp( pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject; pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_InitialContextSetupResponse; out = &pdu.choice.successfulOutcome.value.choice.InitialContextSetupResponse; - /* mandatory */ ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID; @@ -890,7 +859,6 @@ int s1ap_eNB_initial_ctxt_resp( ie->value.present = S1AP_InitialContextSetupResponseIEs__value_PR_MME_UE_S1AP_ID; ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID; @@ -898,7 +866,6 @@ int s1ap_eNB_initial_ctxt_resp( ie->value.present = S1AP_InitialContextSetupResponseIEs__value_PR_ENB_UE_S1AP_ID; ie->value.choice.ENB_UE_S1AP_ID = initial_ctxt_resp_p->eNB_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_InitialContextSetupResponseIEs_t *)calloc(1, sizeof(S1AP_InitialContextSetupResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_E_RABSetupListCtxtSURes; @@ -915,7 +882,7 @@ int s1ap_eNB_initial_ctxt_resp( item->value.choice.E_RABSetupItemCtxtSURes.e_RAB_ID = initial_ctxt_resp_p->e_rabs[i].e_rab_id; GTP_TEID_TO_ASN1(initial_ctxt_resp_p->e_rabs[i].gtp_teid, &item->value.choice.E_RABSetupItemCtxtSURes.gTP_TEID); item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf = malloc(initial_ctxt_resp_p->e_rabs[i].eNB_addr.length); - memcpy(item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf, + memcpy(item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.buf, initial_ctxt_resp_p->e_rabs[i].eNB_addr.buffer, initial_ctxt_resp_p->e_rabs[i].eNB_addr.length); item->value.choice.E_RABSetupItemCtxtSURes.transportLayerAddress.size = initial_ctxt_resp_p->e_rabs[i].eNB_addr.length; @@ -949,23 +916,27 @@ int s1ap_eNB_initial_ctxt_resp( item->value.choice.E_RABItem.e_RAB_ID = initial_ctxt_resp_p->e_rabs_failed[i].e_rab_id; item->value.choice.E_RABItem.cause.present = initial_ctxt_resp_p->e_rabs_failed[i].cause; - switch(item->value.choice.E_RABItem.cause.present) - { + switch(item->value.choice.E_RABItem.cause.present) { case S1AP_Cause_PR_radioNetwork: item->value.choice.E_RABItem.cause.choice.radioNetwork = initial_ctxt_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_transport: item->value.choice.E_RABItem.cause.choice.transport = initial_ctxt_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_nas: item->value.choice.E_RABItem.cause.choice.nas = initial_ctxt_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_protocol: item->value.choice.E_RABItem.cause.choice.protocol = initial_ctxt_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_misc: item->value.choice.E_RABItem.cause.choice.misc = initial_ctxt_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_NOTHING: default: break; @@ -1003,12 +974,10 @@ int s1ap_eNB_initial_ctxt_resp( 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), initial_ctxt_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id); - /* UE associated signalling -> use the allocated stream */ s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, ue_context_p->mme_ref->assoc_id, buffer, length, ue_context_p->tx_stream); - return 0; } @@ -1024,10 +993,8 @@ int s1ap_eNB_ue_capabilities(instance_t instance, S1AP_UECapabilityInfoIndicationIEs_t *ie; uint8_t *buffer; uint32_t length; - /* Retrieve the S1AP eNB instance associated with Mod_id */ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); - DevAssert(ue_cap_info_ind_p != NULL); DevAssert(s1ap_eNB_instance_p != NULL); @@ -1057,7 +1024,6 @@ int s1ap_eNB_ue_capabilities(instance_t instance, pdu.choice.initiatingMessage.criticality = S1AP_Criticality_ignore; pdu.choice.initiatingMessage.value.present = S1AP_InitiatingMessage__value_PR_UECapabilityInfoIndication; out = &pdu.choice.initiatingMessage.value.choice.UECapabilityInfoIndication; - /* mandatory */ ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID; @@ -1065,7 +1031,6 @@ int s1ap_eNB_ue_capabilities(instance_t instance, ie->value.present = S1AP_UECapabilityInfoIndicationIEs__value_PR_MME_UE_S1AP_ID; ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID; @@ -1073,7 +1038,6 @@ int s1ap_eNB_ue_capabilities(instance_t instance, ie->value.present = S1AP_UECapabilityInfoIndicationIEs__value_PR_ENB_UE_S1AP_ID; ie->value.choice.ENB_UE_S1AP_ID = ue_cap_info_ind_p->eNB_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_UERadioCapability; @@ -1082,9 +1046,9 @@ int s1ap_eNB_ue_capabilities(instance_t instance, ie->value.choice.UERadioCapability.buf = ue_cap_info_ind_p->ue_radio_cap.buffer; ie->value.choice.UERadioCapability.size = ue_cap_info_ind_p->ue_radio_cap.length; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* optional */ #if (S1AP_VERSION >= MAKE_VERSION(12, 0, 0)) + if (0) { ie = (S1AP_UECapabilityInfoIndicationIEs_t *)calloc(1, sizeof(S1AP_UECapabilityInfoIndicationIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_UERadioCapabilityForPaging; @@ -1093,6 +1057,7 @@ int s1ap_eNB_ue_capabilities(instance_t instance, // ie->value.choice.UERadioCapabilityForPaging = ; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } + #endif /* #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) */ if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) { @@ -1110,12 +1075,10 @@ int s1ap_eNB_ue_capabilities(instance_t instance, 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), ue_cap_info_ind_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id); - /* UE associated signalling -> use the allocated stream */ s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, ue_context_p->mme_ref->assoc_id, buffer, length, ue_context_p->tx_stream); - return 0; } @@ -1132,15 +1095,13 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, uint8_t *buffer = NULL; uint32_t length; int i; - /* Retrieve the S1AP eNB instance associated with Mod_id */ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); - DevAssert(e_rab_setup_resp_p != NULL); DevAssert(s1ap_eNB_instance_p != NULL); if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, - e_rab_setup_resp_p->eNB_ue_s1ap_id)) == NULL) { + e_rab_setup_resp_p->eNB_ue_s1ap_id)) == NULL) { /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */ S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: 0x%06x\n", e_rab_setup_resp_p->eNB_ue_s1ap_id); @@ -1165,7 +1126,6 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject; pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_E_RABSetupResponse; out = &pdu.choice.successfulOutcome.value.choice.E_RABSetupResponse; - /* mandatory */ ie = (S1AP_E_RABSetupResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID; @@ -1173,7 +1133,6 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_MME_UE_S1AP_ID; ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_E_RABSetupResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID; @@ -1234,23 +1193,27 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, item->value.choice.E_RABItem.e_RAB_ID = e_rab_setup_resp_p->e_rabs_failed[i].e_rab_id; item->value.choice.E_RABItem.cause.present = e_rab_setup_resp_p->e_rabs_failed[i].cause; - switch(item->value.choice.E_RABItem.cause.present) - { + switch(item->value.choice.E_RABItem.cause.present) { case S1AP_Cause_PR_radioNetwork: item->value.choice.E_RABItem.cause.choice.radioNetwork = e_rab_setup_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_transport: item->value.choice.E_RABItem.cause.choice.transport = e_rab_setup_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_nas: item->value.choice.E_RABItem.cause.choice.nas = e_rab_setup_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_protocol: item->value.choice.E_RABItem.cause.choice.protocol = e_rab_setup_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_misc: item->value.choice.E_RABItem.cause.choice.misc = e_rab_setup_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_NOTHING: default: break; @@ -1280,6 +1243,7 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_S1AP_E_RABSetupListBearerSURes, &e_RABSetupListBearerSURes); */ fprintf(stderr, "start encode\n"); + if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) { S1AP_ERROR("Failed to encode uplink transport\n"); /* Encode procedure has failed... */ @@ -1295,12 +1259,10 @@ int s1ap_eNB_e_rab_setup_resp(instance_t instance, 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), e_rab_setup_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id); - /* UE associated signalling -> use the allocated stream */ s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, ue_context_p->mme_ref->assoc_id, buffer, length, ue_context_p->tx_stream); - return 0; } @@ -1314,19 +1276,16 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance, S1AP_S1AP_PDU_t pdu; S1AP_E_RABModifyResponse_t *out; S1AP_E_RABModifyResponseIEs_t *ie; - uint8_t *buffer = NULL; uint32_t length; int i; - /* Retrieve the S1AP eNB instance associated with Mod_id */ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); - DevAssert(e_rab_modify_resp_p != NULL); DevAssert(s1ap_eNB_instance_p != NULL); if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, - e_rab_modify_resp_p->eNB_ue_s1ap_id)) == NULL) { + e_rab_modify_resp_p->eNB_ue_s1ap_id)) == NULL) { /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */ S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: 0x%06x\n", e_rab_modify_resp_p->eNB_ue_s1ap_id); @@ -1351,7 +1310,6 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance, pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject; pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_E_RABModifyResponse; out = &pdu.choice.successfulOutcome.value.choice.E_RABModifyResponse; - /* mandatory */ ie = (S1AP_E_RABModifyResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABModifyResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID; @@ -1359,7 +1317,6 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance, ie->value.present = S1AP_E_RABModifyResponseIEs__value_PR_MME_UE_S1AP_ID; ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_E_RABModifyResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABModifyResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID; @@ -1405,23 +1362,27 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance, item->value.choice.E_RABItem.e_RAB_ID = e_rab_modify_resp_p->e_rabs_failed[i].e_rab_id; item->value.choice.E_RABItem.cause.present = e_rab_modify_resp_p->e_rabs_failed[i].cause; - switch(item->value.choice.E_RABItem.cause.present) - { + switch(item->value.choice.E_RABItem.cause.present) { case S1AP_Cause_PR_radioNetwork: item->value.choice.E_RABItem.cause.choice.radioNetwork = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_transport: item->value.choice.E_RABItem.cause.choice.transport = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_nas: item->value.choice.E_RABItem.cause.choice.nas = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_protocol: item->value.choice.E_RABItem.cause.choice.protocol = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_misc: item->value.choice.E_RABItem.cause.choice.misc = e_rab_modify_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_NOTHING: default: break; @@ -1445,6 +1406,7 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance, } fprintf(stderr, "start encode\n"); + if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) { S1AP_ERROR("Failed to encode uplink transport\n"); /* Encode procedure has failed... */ @@ -1460,7 +1422,6 @@ int s1ap_eNB_e_rab_modify_resp(instance_t instance, 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), e_rab_modify_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id); - /* UE associated signalling -> use the allocated stream */ s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, ue_context_p->mme_ref->assoc_id, buffer, @@ -1480,14 +1441,13 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance, uint8_t *buffer = NULL; uint32_t length; int i; - /* Retrieve the S1AP eNB instance associated with Mod_id */ s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance); DevAssert(e_rab_release_resp_p != NULL); DevAssert(s1ap_eNB_instance_p != NULL); if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p, - e_rab_release_resp_p->eNB_ue_s1ap_id)) == NULL) { + e_rab_release_resp_p->eNB_ue_s1ap_id)) == NULL) { /* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */ S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n", e_rab_release_resp_p->eNB_ue_s1ap_id); @@ -1501,7 +1461,6 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance, pdu.choice.successfulOutcome.criticality = S1AP_Criticality_reject; pdu.choice.successfulOutcome.value.present = S1AP_SuccessfulOutcome__value_PR_E_RABReleaseResponse; out = &pdu.choice.successfulOutcome.value.choice.E_RABReleaseResponse; - /* mandatory */ ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID; @@ -1509,7 +1468,6 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance, ie->value.present = S1AP_E_RABReleaseResponseIEs__value_PR_MME_UE_S1AP_ID; ie->value.choice.MME_UE_S1AP_ID = ue_context_p->mme_ue_s1ap_id; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - /* mandatory */ ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID; @@ -1555,23 +1513,27 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance, item->value.choice.E_RABItem.e_RAB_ID = e_rab_release_resp_p->e_rabs_failed[i].e_rab_id; item->value.choice.E_RABItem.cause.present = e_rab_release_resp_p->e_rabs_failed[i].cause; - switch(item->value.choice.E_RABItem.cause.present) - { + switch(item->value.choice.E_RABItem.cause.present) { case S1AP_Cause_PR_radioNetwork: item->value.choice.E_RABItem.cause.choice.radioNetwork = e_rab_release_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_transport: item->value.choice.E_RABItem.cause.choice.transport = e_rab_release_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_nas: item->value.choice.E_RABItem.cause.choice.nas = e_rab_release_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_protocol: item->value.choice.E_RABItem.cause.choice.protocol = e_rab_release_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_misc: item->value.choice.E_RABItem.cause.choice.misc = e_rab_release_resp_p->e_rabs_failed[i].cause_value; break; + case S1AP_Cause_PR_NOTHING: default: break; @@ -1595,6 +1557,7 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance, /* optional */ #if (S1AP_VERSION >= MAKE_VERSION(12, 0, 0)) + if(0) { ie = (S1AP_E_RABReleaseResponseIEs_t *)calloc(1, sizeof(S1AP_E_RABReleaseResponseIEs_t)); ie->id = S1AP_ProtocolIE_ID_id_UserLocationInformation; @@ -1603,9 +1566,10 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance, // ie->value.choice.UserLocationInformation = ; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } -#endif /* #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) */ +#endif /* #if (S1AP_VERSION >= MAKE_VERSION(14, 0, 0)) */ fprintf(stderr, "start encode\n"); + if (s1ap_eNB_encode_pdu(&pdu, &buffer, &length) < 0) { S1AP_ERROR("Failed to encode release response\n"); /* Encode procedure has failed... */ @@ -1621,14 +1585,11 @@ int s1ap_eNB_e_rab_release_resp(instance_t instance, 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), e_rab_release_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id); - /* UE associated signalling -> use the allocated stream */ s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance, ue_context_p->mme_ref->assoc_id, buffer, length, ue_context_p->tx_stream); - S1AP_INFO("e_rab_release_response sended eNB_UE_S1AP_ID %d mme_ue_s1ap_id %d nb_of_e_rabs_released %d nb_of_e_rabs_failed %d\n", e_rab_release_resp_p->eNB_ue_s1ap_id, ue_context_p->mme_ue_s1ap_id,e_rab_release_resp_p->nb_of_e_rabs_released,e_rab_release_resp_p->nb_of_e_rabs_failed); - return 0; } diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf index ba2e7f1ada542e7df2d29af491890c7b30cf6e4c..750936cfea4a8b7ca72c391e8b8d1307992f757e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf @@ -31,9 +31,9 @@ log_config = { global_log_verbosity ="medium"; hw_log_level ="info"; hw_log_verbosity ="medium"; - phy_log_level ="debug"; + phy_log_level ="info"; phy_log_verbosity ="medium"; - mac_log_level ="debug"; + mac_log_level ="info"; mac_log_verbosity ="high"; rlc_log_level ="info"; rlc_log_verbosity ="medium"; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 6bda86d6032e4bb37a604408463e0696e588ef76..aad542b3d260f9d6b7e4c5ea4056926f879127b3 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -77,16 +77,16 @@ #ifndef OPENAIR2 -#include "UTIL/OTG/otg_extern.h" + #include "UTIL/OTG/otg_extern.h" #endif #if defined(ENABLE_ITTI) -# if defined(ENABLE_USE_MME) -# include "s1ap_eNB.h" -#ifdef PDCP_USE_NETLINK -# include "SIMULATION/ETH_TRANSPORT/proto.h" -#endif -# endif + #if defined(ENABLE_USE_MME) + #include "s1ap_eNB.h" + #ifdef PDCP_USE_NETLINK + #include "SIMULATION/ETH_TRANSPORT/proto.h" + #endif + #endif #endif #include "T.h" @@ -106,8 +106,8 @@ struct timing_info_t { #if defined(ENABLE_ITTI) -extern volatile int start_eNB; -extern volatile int start_UE; + extern volatile int start_eNB; + extern volatile int start_UE; #endif extern volatile int oai_exit; @@ -147,10 +147,8 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc); void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) -void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); + void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #endif -extern PARALLEL_CONF_t get_thread_parallel_conf(void); -extern WORKER_CONF_t get_thread_worker_conf(void); extern uint8_t nfapi_mode; extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); @@ -166,13 +164,10 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // ******************************************************************* if (nfapi_mode == 1) { - // I am a PNF and I need to let nFAPI know that we have a (sub)frame tick uint16_t frame = proc->frame_rx; uint16_t subframe = proc->subframe_rx; - //add_subframe(&frame, &subframe, 4); - //oai_subframe_ind(proc->frame_tx, proc->subframe_tx); //LOG_D(PHY, "oai_subframe_ind(frame:%u, subframe:%d) - NOT CALLED ********\n", frame, subframe); start_meas(&nfapi_meas); @@ -185,14 +180,14 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || eNB->UL_INFO.cqi_ind.number_of_cqis ) { - LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d num_pdcch_symbols:%d\n", - NFAPI_SFNSF2DEC(eNB->UL_INFO.rx_ind.sfn_sf), eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, - NFAPI_SFNSF2DEC(eNB->UL_INFO.harq_ind.sfn_sf), eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, - NFAPI_SFNSF2DEC(eNB->UL_INFO.crc_ind.sfn_sf), eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, - NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, - eNB->UL_INFO.cqi_ind.number_of_cqis, - proc->frame_rx, proc->subframe_rx, - proc->frame_tx, proc->subframe_tx, eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols); + LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d num_pdcch_symbols:%d\n", + NFAPI_SFNSF2DEC(eNB->UL_INFO.rx_ind.sfn_sf), eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, + NFAPI_SFNSF2DEC(eNB->UL_INFO.harq_ind.sfn_sf), eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, + NFAPI_SFNSF2DEC(eNB->UL_INFO.crc_ind.sfn_sf), eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, + NFAPI_SFNSF2DEC(eNB->UL_INFO.rach_ind.sfn_sf), eNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, + eNB->UL_INFO.cqi_ind.number_of_cqis, + proc->frame_rx, proc->subframe_rx, + proc->frame_tx, proc->subframe_tx, eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols); } } @@ -203,7 +198,6 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // **************************************** // Common RX procedures subframe n - T(T_ENB_PHY_DL_TICK, T_INT(eNB->Mod_id), T_INT(proc->frame_tx), T_INT(proc->subframe_tx)); // if this is IF5 or 3GPP_eNB @@ -220,103 +214,97 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if (nfapi_mode == 0 || nfapi_mode == 1) { phy_procedures_eNB_uespec_RX(eNB, proc); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 ); - if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT){ + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, 1 ); + + if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) { if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) { LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx); return(-1); } + if (release_thread(&proc[1].mutex_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) return(-1); } pthread_mutex_lock(&eNB->UL_INFO_mutex); - eNB->UL_INFO.frame = proc->frame_rx; eNB->UL_INFO.subframe = proc->subframe_rx; eNB->UL_INFO.module_id = eNB->Mod_id; eNB->UL_INFO.CC_id = eNB->CC_id; - eNB->if_inst->UL_indication(&eNB->UL_INFO); - pthread_mutex_unlock(&eNB->UL_INFO_mutex); /* this conflict resolution may be totally wrong, to be tested */ /* CONFLICT RESOLUTION: BEGIN */ - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, 0 ); + if(oai_exit) return(-1); - if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD){ + + if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD) { #ifndef PHY_TX_THREAD phy_procedures_eNB_TX(eNB, proc, 1); #endif } + /* CONFLICT RESOLUTION: what about this release_thread call, has it to be done? if yes, where? */ //if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1); /* CONFLICT RESOLUTION: END */ - stop_meas( &softmodem_stats_rxtx_sf ); - LOG_D(PHY,"%s() Exit proc[rx:%d%d tx:%d%d]\n", __FUNCTION__, proc->frame_rx, proc->subframe_rx, proc->frame_tx, proc->subframe_tx); - LOG_D(PHY, "rxtx:%lld nfapi:%lld tx:%lld rx:%lld prach:%lld ofdm:%lld ", - softmodem_stats_rxtx_sf.p_time, nfapi_meas.p_time, - TICK_TO_US(eNB->phy_proc_tx), - TICK_TO_US(eNB->phy_proc_rx), - TICK_TO_US(eNB->rx_prach), - TICK_TO_US(eNB->ofdm_mod_stats) - ); + softmodem_stats_rxtx_sf.p_time, nfapi_meas.p_time, + TICK_TO_US(eNB->phy_proc_tx), + TICK_TO_US(eNB->phy_proc_rx), + TICK_TO_US(eNB->rx_prach), + TICK_TO_US(eNB->ofdm_mod_stats) + ); LOG_D(PHY, - "dlsch[enc:%lld mod:%lld scr:%lld rm:%lld t:%lld i:%lld] rx_dft:%lld ", - TICK_TO_US(eNB->dlsch_encoding_stats), - TICK_TO_US(eNB->dlsch_modulation_stats), - TICK_TO_US(eNB->dlsch_scrambling_stats), - TICK_TO_US(eNB->dlsch_rate_matching_stats), - TICK_TO_US(eNB->dlsch_turbo_encoding_stats), - TICK_TO_US(eNB->dlsch_interleaving_stats), - TICK_TO_US(eNB->rx_dft_stats)); - + "dlsch[enc:%lld mod:%lld scr:%lld rm:%lld t:%lld i:%lld] rx_dft:%lld ", + TICK_TO_US(eNB->dlsch_encoding_stats), + TICK_TO_US(eNB->dlsch_modulation_stats), + TICK_TO_US(eNB->dlsch_scrambling_stats), + TICK_TO_US(eNB->dlsch_rate_matching_stats), + TICK_TO_US(eNB->dlsch_turbo_encoding_stats), + TICK_TO_US(eNB->dlsch_interleaving_stats), + TICK_TO_US(eNB->rx_dft_stats)); LOG_D(PHY," ulsch[ch:%lld freq:%lld dec:%lld demod:%lld ru:%lld ", - TICK_TO_US(eNB->ulsch_channel_estimation_stats), - TICK_TO_US(eNB->ulsch_freq_offset_estimation_stats), - TICK_TO_US(eNB->ulsch_decoding_stats), - TICK_TO_US(eNB->ulsch_demodulation_stats), - TICK_TO_US(eNB->ulsch_rate_unmatching_stats)); - + TICK_TO_US(eNB->ulsch_channel_estimation_stats), + TICK_TO_US(eNB->ulsch_freq_offset_estimation_stats), + TICK_TO_US(eNB->ulsch_decoding_stats), + TICK_TO_US(eNB->ulsch_demodulation_stats), + TICK_TO_US(eNB->ulsch_rate_unmatching_stats)); LOG_D(PHY, "td:%lld dei:%lld dem:%lld llr:%lld tci:%lld ", - TICK_TO_US(eNB->ulsch_turbo_decoding_stats), - TICK_TO_US(eNB->ulsch_deinterleaving_stats), - TICK_TO_US(eNB->ulsch_demultiplexing_stats), - TICK_TO_US(eNB->ulsch_llr_stats), - TICK_TO_US(eNB->ulsch_tc_init_stats)); - LOG_D(PHY, "tca:%lld tcb:%lld tcg:%lld tce:%lld l1:%lld l2:%lld]\n\n", - TICK_TO_US(eNB->ulsch_tc_alpha_stats), - TICK_TO_US(eNB->ulsch_tc_beta_stats), - TICK_TO_US(eNB->ulsch_tc_gamma_stats), - TICK_TO_US(eNB->ulsch_tc_ext_stats), - TICK_TO_US(eNB->ulsch_tc_intl1_stats), - TICK_TO_US(eNB->ulsch_tc_intl2_stats) - ); - + TICK_TO_US(eNB->ulsch_turbo_decoding_stats), + TICK_TO_US(eNB->ulsch_deinterleaving_stats), + TICK_TO_US(eNB->ulsch_demultiplexing_stats), + TICK_TO_US(eNB->ulsch_llr_stats), + TICK_TO_US(eNB->ulsch_tc_init_stats)); + LOG_D(PHY, "tca:%lld tcb:%lld tcg:%lld tce:%lld l1:%lld l2:%lld]\n\n", + TICK_TO_US(eNB->ulsch_tc_alpha_stats), + TICK_TO_US(eNB->ulsch_tc_beta_stats), + TICK_TO_US(eNB->ulsch_tc_gamma_stats), + TICK_TO_US(eNB->ulsch_tc_ext_stats), + TICK_TO_US(eNB->ulsch_tc_intl1_stats), + TICK_TO_US(eNB->ulsch_tc_intl2_stats) + ); return(0); } -static void* tx_thread(void* param) { - - eNB_proc_t *eNB_proc = (eNB_proc_t*)param; +static void *tx_thread(void *param) { + eNB_proc_t *eNB_proc = (eNB_proc_t *)param; eNB_rxtx_proc_t *proc = &eNB_proc->proc_rxtx[1]; PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; - char thread_name[100]; sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); thread_top_init(thread_name,1,470000,500000,500000); - + //wait_sync("tx_thread"); - - while (!oai_exit) { - + while (!oai_exit) { if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - if (oai_exit) break; + + if (oai_exit) break; + // ***************************************** // TX processing for subframe n+4 // run PHY TX procedures the one after the other for all CCs to avoid race conditions @@ -326,17 +314,19 @@ static void* tx_thread(void* param) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX1_ENB,proc->subframe_rx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_ENB,proc->frame_tx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx); - phy_procedures_eNB_TX(eNB, proc, 1); + if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - + pthread_mutex_lock( &proc->mutex_rxtx ); proc->pipe_ready++; + // the thread can now be woken up if (pthread_cond_signal(&proc->cond_rxtx) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); } + pthread_mutex_unlock( &proc->mutex_rxtx ); wakeup_txfh(proc,eNB_proc->ru_proc); } @@ -350,44 +340,32 @@ static void* tx_thread(void* param) { * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* eNB_thread_rxtx( void* param ) { - +static void *eNB_thread_rxtx( void *param ) { static int eNB_thread_rxtx_status; //eNB_proc_t *eNB_proc = (eNB_proc_t*)param; eNB_rxtx_proc_t *proc; // Working - if(nfapi_mode ==2){ - proc = (eNB_rxtx_proc_t*)param; - } - else{ - eNB_proc_t *eNB_proc = (eNB_proc_t*)param; - proc = &eNB_proc->proc_rxtx[0]; + if(nfapi_mode ==2) { + proc = (eNB_rxtx_proc_t *)param; + } else { + eNB_proc_t *eNB_proc = (eNB_proc_t *)param; + proc = &eNB_proc->proc_rxtx[0]; } - PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; //RU_proc_t *ru_proc = NULL; - char thread_name[100]; - cpu_set_t cpuset; CPU_ZERO(&cpuset); - // set default return value eNB_thread_rxtx_status = 0; - - sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); thread_top_init(thread_name,1,470000,500000,500000); pthread_setname_np( pthread_self(),"rxtx processing"); LOG_I(PHY,"thread rxtx created id=%ld\n", syscall(__NR_gettid)); - - while (!oai_exit) { - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); @@ -395,61 +373,55 @@ static void* eNB_thread_rxtx( void* param ) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_ENB_THREAD_RXTX,sched_getcpu()); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 1 ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB,proc->subframe_tx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_ENB,proc->subframe_rx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB,proc->frame_tx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB,proc->frame_rx); - if (oai_exit) break; - if (eNB->CC_id==0) - { + if (eNB->CC_id==0) { if (rxtx(eNB,proc,thread_name) < 0) break; } if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + pthread_mutex_lock( &proc->mutex_rxtx ); proc->pipe_ready++; + // the thread can now be woken up if (pthread_cond_signal(&proc->cond_rxtx) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); } + pthread_mutex_unlock( &proc->mutex_rxtx ); - if (nfapi_mode!=2){ - if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB,eNB->proc.ru_proc); - else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) - { - phy_procedures_eNB_TX(eNB, proc, 1); - wakeup_txfh(proc,eNB->proc.ru_proc); - } - } + if (nfapi_mode!=2) { + if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB,eNB->proc.ru_proc); + else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) { + phy_procedures_eNB_TX(eNB, proc, 1); + wakeup_txfh(proc,eNB->proc.ru_proc); + } + } } // while !oai_exit VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); - LOG_D(PHY, " *** Exiting eNB thread RXn_TXnp4\n"); - eNB_thread_rxtx_status = 0; return &eNB_thread_rxtx_status; } -void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru) -{ +void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru) { eNB_proc_t *proc = &eNB->proc; eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; RU_proc_t *ru_proc=&ru->proc; - proc->frame_rx = frame_rx; proc->subframe_rx = subframe_rx; if (!oai_exit) { T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); - proc_rxtx->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); proc_rxtx->frame_rx = ru_proc->frame_rx; proc_rxtx->subframe_rx = ru_proc->subframe_rx; @@ -457,6 +429,7 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + sf_ahead)%10; if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); + ru_proc->timestamp_tx = proc_rxtx->timestamp_tx; ru_proc->subframe_tx = proc_rxtx->subframe_tx; ru_proc->frame_tx = proc_rxtx->frame_tx; @@ -464,66 +437,60 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t } int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { - - if(ru_proc == NULL) - return(0); + if(ru_proc == NULL) + return(0); + struct timespec wait; wait.tv_sec=0; wait.tv_nsec=5000000L; - if(wait_on_condition(&ru_proc->mutex_eNBs,&ru_proc->cond_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) { LOG_E(PHY,"Frame %d, subframe %d: TX FH not ready\n", ru_proc->frame_tx, ru_proc->subframe_tx); return(-1); } + if (release_thread(&ru_proc->mutex_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) return(-1); - + if (ru_proc->instance_cnt_eNBs == 0) { LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc->frame_rx, proc->subframe_rx); return(-1); } + if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", ru_proc->subframe_rx&1,ru_proc->instance_cnt_eNBs ); exit_fun( "error locking mutex_eNB" ); return(-1); } - ++ru_proc->instance_cnt_eNBs; - ru_proc->timestamp_tx = proc->timestamp_tx; - ru_proc->subframe_tx = proc->subframe_tx; - ru_proc->frame_tx = proc->frame_tx; - + ++ru_proc->instance_cnt_eNBs; + ru_proc->timestamp_tx = proc->timestamp_tx; + ru_proc->subframe_tx = proc->subframe_tx; + ru_proc->frame_tx = proc->frame_tx; + // the thread can now be woken up if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - - pthread_mutex_unlock( &ru_proc->mutex_eNBs ); + pthread_mutex_unlock( &ru_proc->mutex_eNBs ); return(0); } int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { - eNB_proc_t *proc=&eNB->proc; - eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; - - struct timespec wait; wait.tv_sec=0; wait.tv_nsec=5000000L; - - - + if (proc_rxtx1->instance_cnt_rxtx == 0) { LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); return(-1); } - + if (pthread_mutex_timedlock(&proc_rxtx1->mutex_rxtx,&wait) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", proc_rxtx1->subframe_rx&1,proc_rxtx1->instance_cnt_rxtx ); exit_fun( "error locking mutex_tx" ); @@ -531,72 +498,62 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { } ++proc_rxtx1->instance_cnt_rxtx; - - proc_rxtx1->subframe_rx = proc_rxtx0->subframe_rx; proc_rxtx1->frame_rx = proc_rxtx0->frame_rx; proc_rxtx1->subframe_tx = proc_rxtx0->subframe_tx; proc_rxtx1->frame_tx = proc_rxtx0->frame_tx; proc_rxtx1->timestamp_tx = proc_rxtx0->timestamp_tx; - + // the thread can now be woken up if (pthread_cond_signal(&proc_rxtx1->cond_rxtx) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - - pthread_mutex_unlock( &proc_rxtx1->mutex_rxtx ); + pthread_mutex_unlock( &proc_rxtx1->mutex_rxtx ); return(0); } int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { - eNB_proc_t *proc=&eNB->proc; RU_proc_t *ru_proc=&ru->proc; - eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; //eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; - - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - int i; struct timespec wait; - pthread_mutex_lock(&proc->mutex_RU); - for (i=0;i<eNB->num_RU;i++) { + + for (i=0; i<eNB->num_RU; i++) { if (ru == eNB->RU_list[i]) { if ((proc->RU_mask&(1<<i)) > 0) - LOG_E(PHY,"eNB %d frame %d, subframe %d : previous information from RU %d (num_RU %d,mask %x) has not been served yet!\n", - eNB->Mod_id,proc->frame_rx,proc->subframe_rx,ru->idx,eNB->num_RU,proc->RU_mask); + LOG_E(PHY,"eNB %d frame %d, subframe %d : previous information from RU %d (num_RU %d,mask %x) has not been served yet!\n", + eNB->Mod_id,proc->frame_rx,proc->subframe_rx,ru->idx,eNB->num_RU,proc->RU_mask); + proc->RU_mask |= (1<<i); } } + if (proc->RU_mask != (1<<eNB->num_RU)-1) { // not all RUs have provided their information so return LOG_E(PHY,"Not all RUs have provided their info\n"); pthread_mutex_unlock(&proc->mutex_RU); return(0); - } - else { // all RUs have provided their information so continue on and wakeup eNB processing + } else { // all RUs have provided their information so continue on and wakeup eNB processing proc->RU_mask = 0; pthread_mutex_unlock(&proc->mutex_RU); } - - - wait.tv_sec=0; wait.tv_nsec=5000000L; - if(wait_on_condition(&proc_rxtx0->mutex_rxtx,&proc_rxtx0->cond_rxtx,&proc_rxtx0->pipe_ready,"wakeup_rxtx")<0) { LOG_E(PHY,"Frame %d, subframe %d: RXTX0 not ready\n",proc_rxtx0->frame_rx,proc_rxtx0->subframe_rx); return(-1); } + if (release_thread(&proc_rxtx0->mutex_rxtx,&proc_rxtx0->pipe_ready,"wakeup_rxtx")<0) return(-1); - + if (proc_rxtx0->instance_cnt_rxtx == 0) { LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx0->frame_rx,proc_rxtx0->subframe_rx); return(-1); @@ -609,14 +566,12 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { exit_fun( "error locking mutex_rxtx" ); return(-1); } - ++proc_rxtx0->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 + // 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). - // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, + // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, // we want to generate subframe (n+sf_ahead), so TS_tx = TX_rx+sf_ahead*samples_per_tti, // and proc->subframe_tx = proc->subframe_rx+sf_ahead proc_rxtx0->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); @@ -631,129 +586,132 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - - pthread_mutex_unlock( &proc_rxtx0->mutex_rxtx ); + pthread_mutex_unlock( &proc_rxtx0->mutex_rxtx ); return(0); } void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { - eNB_proc_t *proc = &eNB->proc; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; int i; if (ru!=NULL) { pthread_mutex_lock(&proc->mutex_RU_PRACH); - for (i=0;i<eNB->num_RU;i++) { + + for (i=0; i<eNB->num_RU; i++) { if (ru == eNB->RU_list[i]) { - LOG_D(PHY,"frame %d, subframe %d: RU %d for eNB %d signals PRACH (mask %x, num_RU %d)\n",frame,subframe,i,eNB->Mod_id,proc->RU_mask_prach,eNB->num_RU); - if ((proc->RU_mask_prach&(1<<i)) > 0) - LOG_E(PHY,"eNB %d frame %d, subframe %d : previous information (PRACH) from RU %d (num_RU %d, mask %x) has not been served yet!\n", - eNB->Mod_id,frame,subframe,ru->idx,eNB->num_RU,proc->RU_mask_prach); - proc->RU_mask_prach |= (1<<i); + LOG_D(PHY,"frame %d, subframe %d: RU %d for eNB %d signals PRACH (mask %x, num_RU %d)\n",frame,subframe,i,eNB->Mod_id,proc->RU_mask_prach,eNB->num_RU); + + if ((proc->RU_mask_prach&(1<<i)) > 0) + LOG_E(PHY,"eNB %d frame %d, subframe %d : previous information (PRACH) from RU %d (num_RU %d, mask %x) has not been served yet!\n", + eNB->Mod_id,frame,subframe,ru->idx,eNB->num_RU,proc->RU_mask_prach); + + proc->RU_mask_prach |= (1<<i); } } + if (proc->RU_mask_prach != (1<<eNB->num_RU)-1) { // not all RUs have provided their information so return pthread_mutex_unlock(&proc->mutex_RU_PRACH); return; - } - else { // all RUs have provided their information so continue on and wakeup eNB processing + } else { // all RUs have provided their information so continue on and wakeup eNB processing proc->RU_mask_prach = 0; pthread_mutex_unlock(&proc->mutex_RU_PRACH); } } - + // check if we have to detect PRACH first - if (is_prach_subframe(fp,frame,subframe)>0) { + if (is_prach_subframe(fp,frame,subframe)>0) { LOG_D(PHY,"Triggering prach processing, frame %d, subframe %d\n",frame,subframe); + if (proc->instance_cnt_prach == 0) { LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH\n", frame,subframe); return; } - + // wake up thread for PRACH RX if (pthread_mutex_lock(&proc->mutex_prach) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB PRACH thread %d (IC %d)\n", proc->thread_index, proc->instance_cnt_prach); exit_fun( "error locking mutex_prach" ); return; } - + ++proc->instance_cnt_prach; // set timing for prach thread proc->frame_prach = frame; proc->subframe_prach = subframe; - + // the thread can now be woken up if (pthread_cond_signal(&proc->cond_prach) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB PRACH thread %d\n", proc->thread_index); exit_fun( "ERROR pthread_cond_signal" ); return; } - + pthread_mutex_unlock( &proc->mutex_prach ); } - } #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { - eNB_proc_t *proc = &eNB->proc; LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms; int i; if (ru!=NULL) { pthread_mutex_lock(&proc->mutex_RU_PRACH_br); - for (i=0;i<eNB->num_RU;i++) { + + for (i=0; i<eNB->num_RU; i++) { if (ru == eNB->RU_list[i]) { - LOG_D(PHY,"frame %d, subframe %d: RU %d for eNB %d signals PRACH BR (mask %x, num_RU %d)\n",frame,subframe,i,eNB->Mod_id,proc->RU_mask_prach_br,eNB->num_RU); - if ((proc->RU_mask_prach_br&(1<<i)) > 0) - LOG_E(PHY,"eNB %d frame %d, subframe %d : previous information (PRACH BR) from RU %d (num_RU %d, mask %x) has not been served yet!\n", - eNB->Mod_id,frame,subframe,ru->idx,eNB->num_RU,proc->RU_mask_prach_br); - proc->RU_mask_prach_br |= (1<<i); + LOG_D(PHY,"frame %d, subframe %d: RU %d for eNB %d signals PRACH BR (mask %x, num_RU %d)\n",frame,subframe,i,eNB->Mod_id,proc->RU_mask_prach_br,eNB->num_RU); + + if ((proc->RU_mask_prach_br&(1<<i)) > 0) + LOG_E(PHY,"eNB %d frame %d, subframe %d : previous information (PRACH BR) from RU %d (num_RU %d, mask %x) has not been served yet!\n", + eNB->Mod_id,frame,subframe,ru->idx,eNB->num_RU,proc->RU_mask_prach_br); + + proc->RU_mask_prach_br |= (1<<i); } } + if (proc->RU_mask_prach_br != (1<<eNB->num_RU)-1) { // not all RUs have provided their information so return pthread_mutex_unlock(&proc->mutex_RU_PRACH_br); return; - } - else { // all RUs have provided their information so continue on and wakeup eNB processing + } else { // all RUs have provided their information so continue on and wakeup eNB processing proc->RU_mask_prach_br = 0; pthread_mutex_unlock(&proc->mutex_RU_PRACH_br); } } - + // check if we have to detect PRACH first - if (is_prach_subframe(fp,frame,subframe)>0) { + if (is_prach_subframe(fp,frame,subframe)>0) { LOG_D(PHY,"Triggering prach br processing, frame %d, subframe %d\n",frame,subframe); + if (proc->instance_cnt_prach_br == 0) { LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH BR\n", frame,subframe); return; } - + // wake up thread for PRACH RX if (pthread_mutex_lock(&proc->mutex_prach_br) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB PRACH thread %d (IC %d)\n", proc->thread_index, proc->instance_cnt_prach_br); exit_fun( "error locking mutex_prach" ); return; } - + ++proc->instance_cnt_prach_br; // set timing for prach thread proc->frame_prach_br = frame; proc->subframe_prach_br = subframe; - + // the thread can now be woken up if (pthread_cond_signal(&proc->cond_prach_br) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB PRACH BR thread %d\n", proc->thread_index); exit_fun( "ERROR pthread_cond_signal" ); return; } - + pthread_mutex_unlock( &proc->mutex_prach_br ); } - } #endif @@ -763,39 +721,32 @@ void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) { * \param param is a \ref eNB_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* eNB_thread_prach( void* param ) { +static void *eNB_thread_prach( void *param ) { static int eNB_thread_prach_status; - - PHY_VARS_eNB *eNB= (PHY_VARS_eNB *)param; eNB_proc_t *proc = &eNB->proc; - // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach",1,500000,1000000,20000000); //wait_sync("eNB_thread_prach"); while (!oai_exit) { - - - if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; + if (oai_exit) break; LOG_D(PHY,"Running eNB prach procedures\n"); prach_procedures(eNB #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - ,0 + ,0 #endif - ); - + ); + if (release_thread(&proc->mutex_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; } LOG_I(PHY, "Exiting eNB thread PRACH\n"); - eNB_thread_prach_status = 0; return &eNB_thread_prach_status; } @@ -806,33 +757,26 @@ static void* eNB_thread_prach( void* param ) { * \param param is a \ref eNB_proc_t structure which contains the info what to process. * \returns a pointer to an int. The storage is not on the heap and must not be freed. */ -static void* eNB_thread_prach_br( void* param ) { +static void *eNB_thread_prach_br( void *param ) { static int eNB_thread_prach_status; - - PHY_VARS_eNB *eNB= (PHY_VARS_eNB *)param; eNB_proc_t *proc = &eNB->proc; - // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach_br",1,500000,1000000,20000000); while (!oai_exit) { - - - if (wait_on_condition(&proc->mutex_prach_br,&proc->cond_prach_br,&proc->instance_cnt_prach_br,"eNB_prach_thread_br") < 0) break; + if (oai_exit) break; LOG_D(PHY,"Running eNB prach procedures for BL/CE UEs\n"); prach_procedures(eNB,1); - + if (release_thread(&proc->mutex_prach_br,&proc->instance_cnt_prach_br,"eNB_prach_thread_br") < 0) break; } LOG_I(PHY, "Exiting eNB thread PRACH BR\n"); - eNB_thread_prach_status = 0; return &eNB_thread_prach_status; } @@ -846,39 +790,40 @@ extern void init_te_thread(PHY_VARS_eNB *); extern void kill_td_thread(PHY_VARS_eNB *); extern void kill_te_thread(PHY_VARS_eNB *); -static void* process_stats_thread(void* param) { - - PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)param; - +static void *process_stats_thread(void *param) { + PHY_VARS_eNB *eNB = (PHY_VARS_eNB *)param; wait_sync("process_stats_thread"); while (!oai_exit) { sleep(1); - if (opp_enabled == 1) { - if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); - if (eNB->te) - { - print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL); - print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL); - print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); - print_meas(&eNB->dlsch_turbo_encoding_signal_stats,"coding_signal",NULL,NULL); - print_meas(&eNB->dlsch_turbo_encoding_main_stats,"coding_main",NULL,NULL); - print_meas(&eNB->dlsch_turbo_encoding_stats,"turbo_encoding",NULL,NULL); - print_meas(&eNB->dlsch_interleaving_stats,"turbo_interleaving",NULL,NULL); - print_meas(&eNB->dlsch_rate_matching_stats,"turbo_rate_matching",NULL,NULL); - print_meas(&eNB->dlsch_turbo_encoding_waiting_stats,"coding_wait",NULL,NULL); - print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0,"coding_worker_0",NULL,NULL); - print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1,"coding_worker_1",NULL,NULL); - } - print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL); - } + + if (opp_enabled == 1) { + if ( eNB->ulsch_decoding_stats.trials>0) + print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); + + if (eNB->dlsch_encoding_stats.trials >0) { + print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL); + print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_signal_stats,"coding_signal",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_main_stats,"coding_main",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_stats,"turbo_encoding",NULL,NULL); + print_meas(&eNB->dlsch_interleaving_stats,"turbo_interleaving",NULL,NULL); + print_meas(&eNB->dlsch_rate_matching_stats,"turbo_rate_matching",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_waiting_stats,"coding_wait",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0,"coding_worker_0",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1,"coding_worker_1",NULL,NULL); + } + + print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL); + } } + return(NULL); } void init_eNB_proc(int inst) { - /*int i=0;*/ int CC_id; PHY_VARS_eNB *eNB; @@ -888,7 +833,6 @@ void init_eNB_proc(int inst) { #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_attr_t *attr_prach_br=NULL; #endif - LOG_I(PHY,"%s(inst:%d) RC.nb_CC[inst]:%d \n",__FUNCTION__,inst,RC.nb_CC[inst]); for (CC_id=0; CC_id<RC.nb_CC[inst]; CC_id++) { @@ -897,7 +841,6 @@ void init_eNB_proc(int inst) { LOG_I(PHY,"Initializing eNB processes instance:%d CC_id %d \n",inst,CC_id); #endif proc = &eNB->proc; - proc_rxtx = proc->proc_rxtx; proc_rxtx[0].instance_cnt_rxtx = -1; proc_rxtx[1].instance_cnt_rxtx = -1; @@ -906,27 +849,22 @@ void init_eNB_proc(int inst) { proc->instance_cnt_prach = -1; proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_synch = -1; - proc->CC_id = CC_id; - + proc->CC_id = CC_id; proc->first_rx=1; proc->first_tx=1; proc->RU_mask=0; proc->RU_mask_prach=0; - pthread_mutex_init( &eNB->UL_INFO_mutex, NULL); pthread_mutex_init( &proc_rxtx[0].mutex_rxtx, NULL); pthread_mutex_init( &proc_rxtx[1].mutex_rxtx, NULL); pthread_cond_init( &proc_rxtx[0].cond_rxtx, NULL); pthread_cond_init( &proc_rxtx[1].cond_rxtx, NULL); - pthread_mutex_init( &proc->mutex_prach, NULL); pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_RU,NULL); pthread_mutex_init( &proc->mutex_RU_PRACH,NULL); - pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); - pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_asynch_rxtx); pthread_attr_init( &proc_rxtx[0].attr_rxtx); @@ -946,24 +884,22 @@ void init_eNB_proc(int inst) { #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) attr_prach_br = &proc->attr_prach_br; #endif - // attr_td = &proc->attr_td; - // attr_te = &proc->attr_te; + // attr_te = &proc->attr_te; #endif - if(get_thread_worker_conf() == WORKER_ENABLE) - { + if(get_thread_worker_conf() == WORKER_ENABLE) { init_te_thread(eNB); init_td_thread(eNB); } - LOG_I(PHY,"eNB->single_thread_flag:%d\n", eNB->single_thread_flag); if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) { pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc); } + pthread_create( &proc->pthread_prach, attr_prach, eNB_thread_prach, eNB ); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) pthread_create( &proc->pthread_prach_br, attr_prach_br, eNB_thread_prach_br, eNB ); @@ -975,17 +911,13 @@ void init_eNB_proc(int inst) { snprintf( name, sizeof(name), "RXTX1 %d", i ); pthread_setname_np( proc_rxtx[1].pthread_rxtx, name ); }*/ - AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); - - if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); - - + if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void *)eNB); } //for multiple CCs: setup master and slaves - /* + /* for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { eNB = PHY_vars_eNB_g[inst][CC_id]; @@ -1000,13 +932,10 @@ void init_eNB_proc(int inst) { } } */ - /* setup PHY proc TX sync mechanism */ pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); sync_phy_proc.phy_proc_CC_id = 0; - - } @@ -1015,15 +944,14 @@ void init_eNB_proc(int inst) { * \brief Terminate eNB TX and RX threads. */ void kill_eNB_proc(int inst) { - int *status; PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; int i; + for (int CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { eNB=RC.eNB[inst][CC_id]; - proc = &eNB->proc; proc_rxtx = &proc->proc_rxtx[0]; @@ -1031,7 +959,9 @@ void kill_eNB_proc(int inst) { kill_td_thread(eNB); kill_te_thread(eNB); } + LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst ); + for (i=0; i<2; i++) { pthread_mutex_lock(&proc_rxtx[i].mutex_rxtx); proc_rxtx[i].instance_cnt_rxtx = 0; @@ -1039,32 +969,31 @@ void kill_eNB_proc(int inst) { pthread_cond_signal(&proc_rxtx[i].cond_rxtx); pthread_mutex_unlock(&proc_rxtx[i].mutex_rxtx); } + pthread_mutex_lock(&proc->mutex_prach); proc->instance_cnt_prach = 0; pthread_cond_signal( &proc->cond_prach ); pthread_mutex_unlock(&proc->mutex_prach); - pthread_cond_signal( &proc->cond_asynch_rxtx ); pthread_cond_broadcast(&sync_phy_proc.cond_phy_proc_tx); - LOG_D(PHY, "joining pthread_prach\n"); - pthread_join( proc->pthread_prach, (void**)&status ); - + pthread_join( proc->pthread_prach, (void **)&status ); LOG_I(PHY, "Destroying prach mutex/cond\n"); pthread_mutex_destroy( &proc->mutex_prach ); pthread_cond_destroy( &proc->cond_prach ); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) proc->instance_cnt_prach_br = 0; pthread_cond_signal( &proc->cond_prach_br ); - pthread_join( proc->pthread_prach_br, (void**)&status ); + pthread_join( proc->pthread_prach_br, (void **)&status ); pthread_mutex_destroy( &proc->mutex_prach_br ); pthread_cond_destroy( &proc->cond_prach_br ); #endif LOG_I(PHY, "Destroying UL_INFO mutex\n"); pthread_mutex_destroy(&eNB->UL_INFO_mutex); - for (i=0;i<2;i++) { + + for (i=0; i<2; i++) { LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); - pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); + pthread_join( proc_rxtx[i].pthread_rxtx, (void **)&status ); LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); @@ -1078,7 +1007,6 @@ void kill_eNB_proc(int inst) { pthread_mutex_destroy(&proc->mutex_RU_PRACH_br); pthread_attr_destroy(&proc->attr_prach_br); #endif - } } @@ -1086,11 +1014,10 @@ void kill_eNB_proc(int inst) { void reset_opp_meas(void) { - int sfn; reset_meas(&softmodem_stats_mt); reset_meas(&softmodem_stats_hw); - + for (sfn=0; sfn < 10; sfn++) { reset_meas(&softmodem_stats_rxtx_sf); reset_meas(&softmodem_stats_rx_sf); @@ -1099,194 +1026,174 @@ void reset_opp_meas(void) { void print_opp_meas(void) { - int sfn=0; print_meas(&softmodem_stats_mt, "Main ENB Thread", NULL, NULL); print_meas(&softmodem_stats_hw, "HW Acquisation", NULL, NULL); - + for (sfn=0; sfn < 10; sfn++) { print_meas(&softmodem_stats_rxtx_sf,"[eNB][total_phy_proc_rxtx]",NULL, NULL); print_meas(&softmodem_stats_rx_sf,"[eNB][total_phy_proc_rx]",NULL,NULL); } } -void free_transport(PHY_VARS_eNB *eNB) -{ +void free_transport(PHY_VARS_eNB *eNB) { int i; int j; for (i=0; i<NUMBER_OF_UE_MAX; i++) { LOG_D(PHY, "Freeing Transport Channel Buffers for DLSCH, UE %d\n",i); + for (j=0; j<2; j++) free_eNB_dlsch(eNB->dlsch[i][j]); LOG_D(PHY, "Freeing Transport Channel Buffer for ULSCH, UE %d\n",i); free_eNB_ulsch(eNB->ulsch[1+i]); } + free_eNB_ulsch(eNB->ulsch[0]); } void init_transport(PHY_VARS_eNB *eNB) { - int i; int j; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; - LOG_I(PHY, "Initialise transport\n"); for (i=0; i<NUMBER_OF_UE_MAX; i++) { LOG_D(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i); + for (j=0; j<2; j++) { eNB->dlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL,0,fp); + if (!eNB->dlsch[i][j]) { - LOG_E(PHY,"Can't get eNB dlsch structures for UE %d \n", i); - exit(-1); + LOG_E(PHY,"Can't get eNB dlsch structures for UE %d \n", i); + exit(-1); } else { - eNB->dlsch[i][j]->rnti=0; - LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,eNB->dlsch[i][j], eNB->dlsch[i][j]->rnti); + eNB->dlsch[i][j]->rnti=0; + LOG_D(PHY,"dlsch[%d][%d] => %p rnti:%d\n",i,j,eNB->dlsch[i][j], eNB->dlsch[i][j]->rnti); } } - + LOG_D(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); eNB->ulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); - + if (!eNB->ulsch[1+i]) { LOG_E(PHY,"Can't get eNB ulsch structures\n"); exit(-1); } - + // this is the transmission mode for the signalling channels // this will be overwritten with the real transmission mode by the RRC once the UE is connected eNB->transmission_mode[i] = fp->nb_antenna_ports_eNB==1 ? 1 : 2; } + // ULSCH for RA eNB->ulsch[0] = new_eNB_ulsch(MAX_TURBO_ITERATIONS, fp->N_RB_UL, 0); - + if (!eNB->ulsch[0]) { LOG_E(PHY,"Can't get eNB ulsch structures\n"); exit(-1); } + eNB->dlsch_SI = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp); LOG_D(PHY,"eNB %d.%d : SI %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_SI); eNB->dlsch_ra = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp); LOG_D(PHY,"eNB %d.%d : RA %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_ra); eNB->dlsch_MCH = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL, 0, fp); LOG_D(PHY,"eNB %d.%d : MCH %p\n",eNB->Mod_id,eNB->CC_id,eNB->dlsch_MCH); - - eNB->rx_total_gain_dB=130; - + for(i=0; i<NUMBER_OF_UE_MAX; i++) eNB->mu_mimo_mode[i].dl_pow_off = 2; - + eNB->check_for_total_transmissions = 0; - eNB->check_for_MUMIMO_transmissions = 0; - eNB->FULL_MUMIMO_transmissions = 0; - eNB->check_for_SUMIMO_transmissions = 0; - fp->pucch_config_common.deltaPUCCH_Shift = 1; - -} +} void init_eNB_afterRU(void) { - int inst,CC_id,ru_id,i,aa; PHY_VARS_eNB *eNB; - LOG_I(PHY,"%s() RC.nb_inst:%d\n", __FUNCTION__, RC.nb_inst); - for (inst=0;inst<RC.nb_inst;inst++) { + for (inst=0; inst<RC.nb_inst; inst++) { LOG_I(PHY,"RC.nb_CC[inst]:%d\n", RC.nb_CC[inst]); - for (CC_id=0;CC_id<RC.nb_CC[inst];CC_id++) { + for (CC_id=0; CC_id<RC.nb_CC[inst]; CC_id++) { LOG_I(PHY,"RC.nb_CC[inst:%d][CC_id:%d]:%p\n", inst, CC_id, RC.eNB[inst][CC_id]); - eNB = RC.eNB[inst][CC_id]; phy_init_lte_eNB(eNB,0,0); + // map antennas and PRACH signals to eNB RX if (0) AssertFatal(eNB->num_RU>0,"Number of RU attached to eNB %d is zero\n",eNB->Mod_id); + LOG_I(PHY,"Mapping RX ports from %d RUs to eNB %d\n",eNB->num_RU,eNB->Mod_id); eNB->frame_parms.nb_antennas_rx = 0; - LOG_I(PHY,"Overwriting eNB->prach_vars.rxsigF[0]:%p\n", eNB->prach_vars.rxsigF[0]); - - eNB->prach_vars.rxsigF[0] = (int16_t**)malloc16(64*sizeof(int16_t*)); + eNB->prach_vars.rxsigF[0] = (int16_t **)malloc16(64*sizeof(int16_t *)); #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - for (int ce_level=0;ce_level<4;ce_level++) { + + for (int ce_level=0; ce_level<4; ce_level++) { LOG_I(PHY,"Overwriting eNB->prach_vars_br.rxsigF.rxsigF[0]:%p\n", eNB->prach_vars_br.rxsigF[ce_level]); - eNB->prach_vars_br.rxsigF[ce_level] = (int16_t**)malloc16(64*sizeof(int16_t*)); + eNB->prach_vars_br.rxsigF[ce_level] = (int16_t **)malloc16(64*sizeof(int16_t *)); } -#endif +#endif LOG_I(PHY,"eNB->num_RU:%d\n", eNB->num_RU); - for (ru_id=0,aa=0;ru_id<eNB->num_RU;ru_id++) { - eNB->frame_parms.nb_antennas_rx += eNB->RU_list[ru_id]->nb_rx; - - AssertFatal(eNB->RU_list[ru_id]->common.rxdataF!=NULL, - "RU %d : common.rxdataF is NULL\n", - eNB->RU_list[ru_id]->idx); + for (ru_id=0,aa=0; ru_id<eNB->num_RU; ru_id++) { + eNB->frame_parms.nb_antennas_rx += eNB->RU_list[ru_id]->nb_rx; + AssertFatal(eNB->RU_list[ru_id]->common.rxdataF!=NULL, + "RU %d : common.rxdataF is NULL\n", + eNB->RU_list[ru_id]->idx); + AssertFatal(eNB->RU_list[ru_id]->prach_rxsigF!=NULL, + "RU %d : prach_rxsigF is NULL\n", + eNB->RU_list[ru_id]->idx); + + for (i=0; i<eNB->RU_list[ru_id]->nb_rx; aa++,i++) { + LOG_I(PHY,"Attaching RU %d antenna %d to eNB antenna %d\n",eNB->RU_list[ru_id]->idx,i,aa); + eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[ru_id]->prach_rxsigF[i]; +#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - AssertFatal(eNB->RU_list[ru_id]->prach_rxsigF!=NULL, - "RU %d : prach_rxsigF is NULL\n", - eNB->RU_list[ru_id]->idx); + for (int ce_level=0; ce_level<4; ce_level++) + eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[ru_id]->prach_rxsigF_br[ce_level][i]; - for (i=0;i<eNB->RU_list[ru_id]->nb_rx;aa++,i++) { - LOG_I(PHY,"Attaching RU %d antenna %d to eNB antenna %d\n",eNB->RU_list[ru_id]->idx,i,aa); - eNB->prach_vars.rxsigF[0][aa] = eNB->RU_list[ru_id]->prach_rxsigF[i]; -#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - for (int ce_level=0;ce_level<4;ce_level++) - eNB->prach_vars_br.rxsigF[ce_level][aa] = eNB->RU_list[ru_id]->prach_rxsigF_br[ce_level][i]; #endif - eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; - } + eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; + } } - - /* TODO: review this code, there is something wrong. * In monolithic mode, we come here with nb_antennas_rx == 0 * (not tested in other modes). */ - if (eNB->frame_parms.nb_antennas_rx < 1) - { + if (eNB->frame_parms.nb_antennas_rx < 1) { LOG_I(PHY, "%s() ************* DJP ***** eNB->frame_parms.nb_antennas_rx:%d - GOING TO HARD CODE TO 1", __FUNCTION__, eNB->frame_parms.nb_antennas_rx); eNB->frame_parms.nb_antennas_rx = 1; - } - else - { + } else { //LOG_I(PHY," Delete code\n"); } - if (eNB->frame_parms.nb_antennas_tx < 1) - { + if (eNB->frame_parms.nb_antennas_tx < 1) { LOG_I(PHY, "%s() ************* DJP ***** eNB->frame_parms.nb_antennas_tx:%d - GOING TO HARD CODE TO 1", __FUNCTION__, eNB->frame_parms.nb_antennas_tx); eNB->frame_parms.nb_antennas_tx = 1; - } - else - { + } else { //LOG_I(PHY," Delete code\n"); } - - - AssertFatal(eNB->frame_parms.nb_antennas_rx >0, - "inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,eNB->frame_parms.nb_antennas_rx); + "inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,eNB->frame_parms.nb_antennas_rx); LOG_I(PHY,"inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,eNB->frame_parms.nb_antennas_rx); - init_transport(eNB); //init_precoding_weights(RC.eNB[inst][CC_id]); } + init_eNB_proc(inst); } - for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { - + for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { AssertFatal(RC.ru[ru_id]!=NULL,"ru_id %d is null\n",ru_id); - RC.ru[ru_id]->wakeup_rxtx = wakeup_rxtx; RC.ru[ru_id]->wakeup_prach_eNB = wakeup_prach_eNB; #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) @@ -1297,40 +1204,34 @@ void init_eNB_afterRU(void) { } void init_eNB(int single_thread_flag,int wait_for_sync) { - int CC_id; int inst; PHY_VARS_eNB *eNB; - LOG_I(PHY,"[lte-softmodem.c] eNB structure about to allocated RC.nb_L1_inst:%d RC.nb_L1_CC[0]:%d\n",RC.nb_L1_inst,RC.nb_L1_CC[0]); - if (RC.eNB == NULL) RC.eNB = (PHY_VARS_eNB***) malloc(RC.nb_L1_inst*sizeof(PHY_VARS_eNB **)); + if (RC.eNB == NULL) RC.eNB = (PHY_VARS_eNB ** *) malloc(RC.nb_L1_inst*sizeof(PHY_VARS_eNB **)); + LOG_I(PHY,"[lte-softmodem.c] eNB structure RC.eNB allocated\n"); - for (inst=0;inst<RC.nb_L1_inst;inst++) { - if (RC.eNB[inst] == NULL) RC.eNB[inst] = (PHY_VARS_eNB**) malloc(RC.nb_CC[inst]*sizeof(PHY_VARS_eNB *)); - for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) { - if (RC.eNB[inst][CC_id] == NULL) RC.eNB[inst][CC_id] = (PHY_VARS_eNB*) malloc(sizeof(PHY_VARS_eNB)); - eNB = RC.eNB[inst][CC_id]; - eNB->abstraction_flag = 0; - eNB->single_thread_flag = single_thread_flag; + for (inst=0; inst<RC.nb_L1_inst; inst++) { + if (RC.eNB[inst] == NULL) RC.eNB[inst] = (PHY_VARS_eNB **) malloc(RC.nb_CC[inst]*sizeof(PHY_VARS_eNB *)); + + for (CC_id=0; CC_id<RC.nb_L1_CC[inst]; CC_id++) { + if (RC.eNB[inst][CC_id] == NULL) RC.eNB[inst][CC_id] = (PHY_VARS_eNB *) malloc(sizeof(PHY_VARS_eNB)); + eNB = RC.eNB[inst][CC_id]; + eNB->abstraction_flag = 0; + eNB->single_thread_flag = single_thread_flag; LOG_I(PHY,"Initializing eNB %d CC_id %d single_thread_flag:%d\n",inst,CC_id,single_thread_flag); #ifndef OCP_FRAMEWORK LOG_I(PHY,"Initializing eNB %d CC_id %d\n",inst,CC_id); #endif - - - eNB->td = ulsch_decoding_data_all; - eNB->te = dlsch_encoding_all; - - LOG_I(PHY,"Registering with MAC interface module\n"); AssertFatal((eNB->if_inst = IF_Module_init(inst))!=NULL,"Cannot register interface"); eNB->if_inst->schedule_response = schedule_response; eNB->if_inst->PHY_config_req = phy_config_request; - memset((void*)&eNB->UL_INFO,0,sizeof(eNB->UL_INFO)); - memset((void*)&eNB->Sched_INFO,0,sizeof(eNB->Sched_INFO)); + memset((void *)&eNB->UL_INFO,0,sizeof(eNB->UL_INFO)); + memset((void *)&eNB->Sched_INFO,0,sizeof(eNB->Sched_INFO)); LOG_I(PHY,"Setting indication lists\n"); eNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list = eNB->rx_pdu_list; eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list = eNB->crc_pdu_list; @@ -1340,7 +1241,6 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { eNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = eNB->cqi_raw_pdu_list; eNB->prach_energy_counter = 0; } - } LOG_I(PHY,"[lte-softmodem.c] eNB structure allocated\n"); @@ -1348,8 +1248,7 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { void stop_eNB(int nb_inst) { - - for (int inst=0;inst<nb_inst;inst++) { + for (int inst=0; inst<nb_inst; inst++) { LOG_I(PHY,"Killing eNB %d processing threads\n",inst); kill_eNB_proc(inst); } diff --git a/targets/RT/USER/lte-softmodem-common.c b/targets/RT/USER/lte-softmodem-common.c index 4eb0d3e888815207dfcf51776ad2e481cb721225..7e1235b3103b8e4b35cd6d62ca2aa386c61dc694 100644 --- a/targets/RT/USER/lte-softmodem-common.c +++ b/targets/RT/USER/lte-softmodem-common.c @@ -35,6 +35,8 @@ #include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" static softmodem_params_t softmodem_params; +char *parallel_config=NULL; +char *worker_config=NULL; uint64_t get_softmodem_optmask(void) { return softmodem_params.optmask; @@ -49,31 +51,8 @@ softmodem_params_t* get_softmodem_params(void) { return &softmodem_params; } -void set_parallel_conf(char *parallel_conf) -{ - if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) softmodem_params.thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) softmodem_params.thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT; - else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) softmodem_params.thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT; - printf("[CONFIG] parallel conf is set to %d\n",softmodem_params.thread_struct.parallel_conf); -} -void set_worker_conf(char *worker_conf) -{ - if(strcmp(worker_conf,"WORKER_DISABLE")==0) softmodem_params.thread_struct.worker_conf = WORKER_DISABLE; - else if(strcmp(worker_conf,"WORKER_ENABLE")==0) softmodem_params.thread_struct.worker_conf = WORKER_ENABLE; - printf("[CONFIG] worker conf is set to %d\n",softmodem_params.thread_struct.worker_conf); -} -PARALLEL_CONF_t get_thread_parallel_conf(void) -{ - return softmodem_params.thread_struct.parallel_conf; -} -WORKER_CONF_t get_thread_worker_conf(void) -{ - return softmodem_params.thread_struct.worker_conf; -} void get_common_options(void) { -char *parallel_config=NULL; -char *worker_config=NULL; uint32_t online_log_messages; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 4cf257f3535cc65908efa872f35e172fbe7c1c0e..99a402d441cef381b50bb154c58bc327ace22cd8 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -79,11 +79,11 @@ unsigned short config_frames[4] = {2,9,11,13}; //#include "PHY/TOOLS/time_meas.h" #ifndef OPENAIR2 -#include "UTIL/OTG/otg_vars.h" + #include "UTIL/OTG/otg_vars.h" #endif #if defined(ENABLE_ITTI) -#include "create_tasks.h" + #include "create_tasks.h" #endif #include "PHY/INIT/phy_init.h" @@ -91,24 +91,24 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "system.h" #ifdef XFORMS -#include "PHY/TOOLS/lte_phy_scope.h" -#include "stats.h" + #include "PHY/TOOLS/lte_phy_scope.h" + #include "stats.h" #endif #include "lte-softmodem.h" #include "NB_IoT_interface.h" #ifdef XFORMS -// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) -// at eNB 0, an UL scope for every UE -FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; -FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; -char title[255]; -unsigned char scope_enb_num_ue = 2; -static pthread_t forms_thread; //xforms + // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) + // at eNB 0, an UL scope for every UE + FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; + FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; + char title[255]; + unsigned char scope_enb_num_ue = 2; + static pthread_t forms_thread; //xforms #endif //XFORMS #ifndef ENABLE_USE_MME -#define EPC_MODE_ENABLED 0 + #define EPC_MODE_ENABLED 0 #endif pthread_cond_t nfapi_sync_cond; @@ -128,8 +128,8 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] #if defined(ENABLE_ITTI) -volatile int start_eNB = 0; -volatile int start_UE = 0; + volatile int start_eNB = 0; + volatile int start_UE = 0; #endif volatile int oai_exit = 0; @@ -171,9 +171,9 @@ char channels[128] = "0"; int rx_input_level_dBm; #ifdef XFORMS -extern int otg_enabled; + extern int otg_enabled; #else -int otg_enabled; + int otg_enabled; #endif //int number_of_cards = 1; @@ -190,7 +190,9 @@ extern void init_eNB_afterRU(void); int transmission_mode=1; - +THREAD_STRUCT thread_struct; +/* struct for ethernet specific parameters given in eNB conf file */ +eth_params_t *eth_params; double cpuf; @@ -206,6 +208,7 @@ struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; struct timespec clock_difftime(struct timespec start, struct timespec end) { struct timespec temp; + if ((end.tv_nsec-start.tv_nsec)<0) { temp.tv_sec = end.tv_sec-start.tv_sec-1; temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; @@ -213,6 +216,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) { temp.tv_sec = end.tv_sec-start.tv_sec; temp.tv_nsec = end.tv_nsec-start.tv_nsec; } + return temp; } @@ -228,16 +232,21 @@ void update_difftimes(struct timespec start, struct timespec end) { struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 }; int changed = 0; diff_time = clock_difftime(start, end); + if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) { min_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; } + if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) { max_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; } + #if 1 + if (changed) print_difftimes(); + #endif } @@ -258,23 +267,18 @@ void signal_handler(int sig) { if (sig==SIGSEGV) { // get void*'s for all entries on the stack size = backtrace(array, 10); - // print out all the frames to stderr fprintf(stderr, "Error: signal %d:\n", sig); backtrace_symbols_fd(array, size, 2); exit(-1); } else { - printf("Linux signal %s...\n",strsignal(sig)); - exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n"); - - + printf("Linux signal %s...\n",strsignal(sig)); + exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n"); } } -void exit_function(const char* file, const char* function, const int line, const char* s) -{ - +void exit_function(const char *file, const char *function, const int line, const char *s) { int ru_id; if (s != NULL) { @@ -283,50 +287,46 @@ void exit_function(const char* file, const char* function, const int line, const oai_exit = 1; + if (RC.ru == NULL) + exit(-1); // likely init not completed, prevent crash or hang, exit now... - if (RC.ru == NULL) - exit(-1); // likely init not completed, prevent crash or hang, exit now... - for (ru_id=0; ru_id<RC.nb_RU;ru_id++) { - if (RC.ru[ru_id] && RC.ru[ru_id]->rfdevice.trx_end_func) { - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - RC.ru[ru_id]->rfdevice.trx_end_func = NULL; - } - if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - RC.ru[ru_id]->ifdevice.trx_end_func = NULL; - } + for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { + if (RC.ru[ru_id] && RC.ru[ru_id]->rfdevice.trx_end_func) { + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; } + if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; + } + } - sleep(1); //allow lte-softmodem threads to exit first + sleep(1); //allow lte-softmodem threads to exit first #if defined(ENABLE_ITTI) - itti_terminate_tasks (TASK_UNKNOWN); + itti_terminate_tasks (TASK_UNKNOWN); #endif - exit(1); - + exit(1); } #ifdef XFORMS -void reset_stats(FL_OBJECT *button, long arg) -{ +void reset_stats(FL_OBJECT *button, long arg) { int i,j,k; PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0]; for (i=0; i<NUMBER_OF_UE_MAX; i++) { for (k=0; k<8; k++) { //harq_processes for (j=0; j<phy_vars_eNB->dlsch[i][0]->Mlimit; j++) { - phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; } phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0; phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0; phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0; - - phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0; phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0; phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0; @@ -335,54 +335,47 @@ void reset_stats(FL_OBJECT *button, long arg) } static void *scope_thread(void *arg) { - # ifdef ENABLE_XFORMS_WRITE_STATS FILE *eNB_stats; # endif struct sched_param sched_param; int UE_id, CC_id; int ue_cnt=0; - sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; sched_setscheduler(0, SCHED_FIFO,&sched_param); - printf("Scope thread has priority %d\n",sched_param.sched_priority); - # ifdef ENABLE_XFORMS_WRITE_STATS - eNB_stats = fopen("eNB_stats.txt", "w"); - #endif while (!oai_exit) { + ue_cnt=0; + + for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + if ((ue_cnt<scope_enb_num_ue)) { + phy_scope_eNB(form_enb[CC_id][ue_cnt], + RC.eNB[0][CC_id], + UE_id); + ue_cnt++; + } + } + } - ue_cnt=0; - for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - if ((ue_cnt<scope_enb_num_ue)) { - phy_scope_eNB(form_enb[CC_id][ue_cnt], - RC.eNB[0][CC_id], - UE_id); - ue_cnt++; - } - } - } sleep(1); } // printf("%s",stats_buffer); - # ifdef ENABLE_XFORMS_WRITE_STATS - if (eNB_stats) { - rewind (eNB_stats); - fwrite (stats_buffer, 1, len, eNB_stats); - fclose (eNB_stats); - } + if (eNB_stats) { + rewind (eNB_stats); + fwrite (stats_buffer, 1, len, eNB_stats); + fclose (eNB_stats); + } # endif - - pthread_exit((void*)arg); + pthread_exit((void *)arg); } #endif @@ -393,44 +386,43 @@ static void *scope_thread(void *arg) { void *l2l1_task(void *arg) { MessageDef *message_p = NULL; int result; - itti_set_task_real_time(TASK_L2L1); itti_mark_task_ready(TASK_L2L1); - /* Wait for the initialize message */ printf("Wait for the ITTI initialize message\n"); + while (1) { itti_receive_msg (TASK_L2L1, &message_p); switch (ITTI_MSG_ID(message_p)) { - case INITIALIZE_MESSAGE: - /* Start eNB thread */ - LOG_D(PHY, "L2L1 TASK received %s\n", ITTI_MSG_NAME(message_p)); - start_eNB = 1; - break; - - case TERMINATE_MESSAGE: - LOG_W(PHY, " *** Exiting L2L1 thread\n"); - oai_exit=1; - start_eNB = 0; - itti_exit_task (); - break; - - case ACTIVATE_MESSAGE: - start_UE = 1; - break; - - case DEACTIVATE_MESSAGE: - start_UE = 0; - break; - - case MESSAGE_TEST: - printf("Received %s\n", ITTI_MSG_NAME(message_p)); - break; - - default: - printf("Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); - break; + case INITIALIZE_MESSAGE: + /* Start eNB thread */ + LOG_D(PHY, "L2L1 TASK received %s\n", ITTI_MSG_NAME(message_p)); + start_eNB = 1; + break; + + case TERMINATE_MESSAGE: + LOG_W(PHY, " *** Exiting L2L1 thread\n"); + oai_exit=1; + start_eNB = 0; + itti_exit_task (); + break; + + case ACTIVATE_MESSAGE: + start_UE = 1; + break; + + case DEACTIVATE_MESSAGE: + start_UE = 0; + break; + + case MESSAGE_TEST: + printf("Received %s\n", ITTI_MSG_NAME(message_p)); + break; + + default: + printf("Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); + break; } result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); @@ -444,28 +436,26 @@ void *l2l1_task(void *arg) { static void get_options(void) { - - CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); get_common_options(); CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) { - memset((void*)&RC,0,sizeof(RC)); - /* Read RC configuration file */ - RCConfig(); - NB_eNB_INST = RC.nb_inst; - printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,RC.nb_RU); - if (!SOFTMODEM_NONBIOT) { - load_NB_IoT(); - printf(" nb_nbiot_rrc_inst %d, nb_nbiot_L1_inst %d, nb_nbiot_macrlc_inst %d\n", - RC.nb_nb_iot_rrc_inst, RC.nb_nb_iot_L1_inst, RC.nb_nb_iot_macrlc_inst); - } else { - printf("All Nb-IoT instances disabled\n"); - RC.nb_nb_iot_rrc_inst=RC.nb_nb_iot_L1_inst=RC.nb_nb_iot_macrlc_inst=0; - } - } - + memset((void *)&RC,0,sizeof(RC)); + /* Read RC configuration file */ + RCConfig(); + NB_eNB_INST = RC.nb_inst; + printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,RC.nb_RU); + + if (!SOFTMODEM_NONBIOT) { + load_NB_IoT(); + printf(" nb_nbiot_rrc_inst %d, nb_nbiot_L1_inst %d, nb_nbiot_macrlc_inst %d\n", + RC.nb_nb_iot_rrc_inst, RC.nb_nb_iot_L1_inst, RC.nb_nb_iot_macrlc_inst); + } else { + printf("All Nb-IoT instances disabled\n"); + RC.nb_nb_iot_rrc_inst=RC.nb_nb_iot_L1_inst=RC.nb_nb_iot_macrlc_inst=0; + } + } } @@ -473,11 +463,10 @@ static void get_options(void) { void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { - int CC_id; for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - frame_parms[CC_id] = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms[CC_id] = (LTE_DL_FRAME_PARMS *) malloc(sizeof(LTE_DL_FRAME_PARMS)); /* Set some default values that may be overwritten while reading options */ frame_parms[CC_id]->frame_type = FDD; frame_parms[CC_id]->tdd_config = 3; @@ -491,9 +480,7 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { frame_parms[CC_id]->nb_antenna_ports_eNB = 1; frame_parms[CC_id]->nb_antennas_tx = 1; frame_parms[CC_id]->nb_antennas_rx = 1; - frame_parms[CC_id]->nushift = 0; - frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; frame_parms[CC_id]->phich_config_common.phich_duration = normal; // UL RS Config @@ -501,61 +488,55 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; - frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; - -// downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. -// downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; -// downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; -// downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; + // downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. + // downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; + // downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; + // downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; //printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0]; - } - } void wait_RUs(void) { - LOG_I(PHY,"Waiting for RUs to be configured ... RC.ru_mask:%02lx\n", RC.ru_mask); - // wait for all RUs to be configured over fronthaul pthread_mutex_lock(&RC.ru_mutex); + while (RC.ru_mask>0) { pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); printf("RC.ru_mask:%02lx\n", RC.ru_mask); } - pthread_mutex_unlock(&RC.ru_mutex); + pthread_mutex_unlock(&RC.ru_mutex); LOG_I(PHY,"RUs configured\n"); } void wait_eNBs(void) { - int i,j; int waiting=1; - while (waiting==1) { printf("Waiting for eNB L1 instances to all get configured ... sleeping 50ms (nb_L1_inst %d)\n",RC.nb_L1_inst); usleep(50*1000); waiting=0; - for (i=0;i<RC.nb_L1_inst;i++) { + for (i=0; i<RC.nb_L1_inst; i++) { printf("RC.nb_L1_CC[%d]:%d\n", i, RC.nb_L1_CC[i]); - for (j=0;j<RC.nb_L1_CC[i];j++) { - if (RC.eNB[i][j]->configured==0) { - waiting=1; - break; - } + for (j=0; j<RC.nb_L1_CC[i]; j++) { + if (RC.eNB[i][j]->configured==0) { + waiting=1; + break; + } } } } + printf("eNB L1 are configured\n"); } @@ -563,20 +544,18 @@ void wait_eNBs(void) { /* * helper function to terminate a certain ITTI task */ -void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) -{ +void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) { LOG_I(ENB_APP, "sending TERMINATE_MESSAGE from task %s (%d) to task %s (%d)\n", - itti_get_task_name(from), from, itti_get_task_name(to), to); + itti_get_task_name(from), from, itti_get_task_name(to), to); MessageDef *msg; msg = itti_alloc_new_message (from, TERMINATE_MESSAGE); itti_send_msg_to_task (to, ENB_MODULE_ID_TO_INSTANCE(mod_id), msg); } extern void free_transport(PHY_VARS_eNB *); -extern void phy_free_RU(RU_t*); +extern void phy_free_RU(RU_t *); -int stop_L1L2(module_id_t enb_id) -{ +int stop_L1L2(module_id_t enb_id) { LOG_W(ENB_APP, "stopping lte-softmodem\n"); if (!RC.ru) { @@ -593,10 +572,12 @@ int stop_L1L2(module_id_t enb_id) LOG_I(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id); kill_eNB_proc(enb_id); oai_exit = 0; + for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) { free_transport(RC.eNB[enb_id][cc_id]); phy_free_lte_eNB(RC.eNB[enb_id][cc_id]); } + phy_free_RU(RC.ru[enb_id]); free_lte_top(); return 0; @@ -605,14 +586,11 @@ int stop_L1L2(module_id_t enb_id) /* * Restart the lte-softmodem after it has been soft-stopped with stop_L1L2() */ -int restart_L1L2(module_id_t enb_id) -{ +int restart_L1L2(module_id_t enb_id) { RU_t *ru = RC.ru[enb_id]; int cc_id; MessageDef *msg_p = NULL; - LOG_W(ENB_APP, "restarting lte-softmodem\n"); - /* block threads */ pthread_mutex_lock(&sync_mutex); sync_var = -1; @@ -630,14 +608,15 @@ int restart_L1L2(module_id_t enb_id) /* reset the list of connected UEs in the MAC, since in this process with * loose all UEs (have to reconnect) */ init_UE_list(&RC.mac[enb_id]->UE_list); - LOG_I(ENB_APP, "attempting to create ITTI tasks\n"); + if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) { LOG_E(RRC, "Create task for RRC eNB failed\n"); return -1; } else { LOG_I(RRC, "Re-created task for RRC eNB successfully\n"); } + if (itti_create_task (TASK_L2L1, l2l1_task, NULL) < 0) { LOG_E(PDCP, "Create task for L2L1 failed\n"); return -1; @@ -652,101 +631,88 @@ int restart_L1L2(module_id_t enb_id) itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); /* TODO XForms might need to be restarted, but it is currently (09/02/18) * broken, so we cannot test it */ - wait_eNBs(); init_RU_proc(ru); ru->rf_map.card = 0; ru->rf_map.chain = 0; /* CC_id + chain_offset;*/ wait_RUs(); init_eNB_afterRU(); - printf("Sending sync to all threads\n"); pthread_mutex_lock(&sync_mutex); sync_var=0; pthread_cond_broadcast(&sync_cond); pthread_mutex_unlock(&sync_mutex); - return 0; } #endif static void wait_nfapi_init(char *thread_name) { - printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); pthread_mutex_lock( &nfapi_sync_mutex ); - + while (nfapi_sync_var<0) pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); - + pthread_mutex_unlock(&nfapi_sync_mutex); - printf( "NFAPI: got sync (%s)\n", thread_name); } -int main( int argc, char **argv ) -{ +int main( int argc, char **argv ) { int i; #if defined (XFORMS) void *status; #endif - int CC_id; int ru_id; #if defined (XFORMS) int ret; #endif + if ( load_configmodule(argc,argv,0) == NULL) { exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); - } - + } mode = normal_txrx; - set_latency_target(); - logInit(); - printf("Reading in command-line options\n"); - CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); get_options (); + if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { - fprintf(stderr,"Getting configuration failed\n"); - exit(-1); + fprintf(stderr,"Getting configuration failed\n"); + exit(-1); } - #if T_TRACER - T_Config_Init(); #endif - ret=config_check_cmdlineopt(NULL); + if (ret != 0) { - LOG_E(ENB_APP, "%i unknown options in command line\n",ret); - exit_fun(""); + LOG_E(ENB_APP, "%i unknown options in command line\n",ret); + exit_fun(""); } + CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT); //randominit (0); set_taus_seed (0); - printf("configuring for RAU/RRU\n"); if (opp_enabled ==1) { reset_opp_meas(); } - cpuf=get_cpu_freq_GHz(); + cpuf=get_cpu_freq_GHz(); #if defined(ENABLE_ITTI) - printf("ITTI init, useMME: %i\n" ,EPC_MODE_ENABLED); - itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); // initialize mscgen log after ITTI if (get_softmodem_params()->start_msc) { - load_module_shlib("msc",NULL,0,&msc_interface); + load_module_shlib("msc",NULL,0,&msc_interface); } + MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); #endif @@ -762,56 +728,50 @@ int main( int argc, char **argv ) pdcp_netlink_init(); #endif #endif - - // to make a graceful exit when ctrl-c is pressed signal(SIGSEGV, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); signal(SIGABRT, signal_handler); - - - check_clock(); - #ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif - LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - printf("Runtime table\n"); fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); - - #ifndef DEADLINE_SCHEDULER - printf("NO deadline scheduler\n"); /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ - cpu_set_t cpuset; int s; char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + if (get_nprocs() > 2) { CPU_SET(0, &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun("Error setting processor affinity"); } + LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); } + #endif - /* Check the actual affinity mask assigned to the thread */ s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { perror( "pthread_getaffinity_np"); exit_fun("Error getting processor affinity "); } + memset(cpu_affinity, 0 , sizeof(cpu_affinity)); + for (int j = 0; j < CPU_SETSIZE; j++) { if (CPU_ISSET(j, &cpuset)) { char temp[1024]; @@ -819,30 +779,28 @@ int main( int argc, char **argv ) strcat(cpu_affinity, temp); } } + LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); #endif - - - - #if defined(ENABLE_ITTI) + if (RC.nb_inst > 0) { - // don't create if node doesn't connect to RRC/S1/GTP - if (create_tasks(1) < 0) { - printf("cannot create ITTI tasks\n"); - exit(-1); // need a softer mode - } + if (create_tasks(1) < 0) { + printf("cannot create ITTI tasks\n"); + exit(-1); // need a softer mode + } + printf("ITTI tasks created\n"); - } - else { + } else { printf("No ITTI, Initializing L1\n"); RCconfig_L1(); } -#endif +#endif /* Start the agent. If it is turned off in the configuration, it won't start */ RCconfig_flexran(); + for (i = 0; i < RC.nb_L1_inst; i++) { flexran_agent_start(i); } @@ -850,55 +808,48 @@ int main( int argc, char **argv ) // init UE_PF_PO and mutex lock pthread_mutex_init(&ue_pf_po_mutex, NULL); memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs); - mlockall(MCL_CURRENT | MCL_FUTURE); - pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); - #ifdef XFORMS int UE_id; - printf("XFORMS\n"); if (get_softmodem_params()->do_forms==1) { fl_initialize (&argc, argv, NULL, 0, 0); - - form_stats_l2 = create_form_stats_form(); - fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); - form_stats = create_form_stats_form(); - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - - for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - form_enb[CC_id][UE_id] = create_lte_phy_scope_enb(); - sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id); - fl_show_form (form_enb[CC_id][UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - - if (otg_enabled) { - fl_set_button(form_enb[CC_id][UE_id]->button_0,1); - fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic ON"); - } else { - fl_set_button(form_enb[CC_id][UE_id]->button_0,0); - fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic OFF"); - } - } // CC_id - } // UE_id - + form_stats_l2 = create_form_stats_form(); + fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); + form_stats = create_form_stats_form(); + fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); + + for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + form_enb[CC_id][UE_id] = create_lte_phy_scope_enb(); + sprintf (title, "LTE UL SCOPE eNB for CC_id %d, UE %d",CC_id,UE_id); + fl_show_form (form_enb[CC_id][UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + + if (otg_enabled) { + fl_set_button(form_enb[CC_id][UE_id]->button_0,1); + fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic ON"); + } else { + fl_set_button(form_enb[CC_id][UE_id]->button_0,0); + fl_set_object_label(form_enb[CC_id][UE_id]->button_0,"DL Traffic OFF"); + } + } // CC_id + } // UE_id + ret = pthread_create(&forms_thread, NULL, scope_thread, NULL); - + if (ret == 0) pthread_setname_np( forms_thread, "xforms" ); - + printf("Scope thread created, ret=%d\n",ret); } - + #endif - rt_sleep_ns(10*100000000ULL); - if (nfapi_mode) - { + if (nfapi_mode) { printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); @@ -910,96 +861,91 @@ int main( int argc, char **argv ) case 0: nfapi_mode_str = "MONOLITHIC"; break; + case 1: nfapi_mode_str = "PNF"; break; + case 2: nfapi_mode_str = "VNF"; break; + default: nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; break; } + printf("NFAPI MODE:%s\n", nfapi_mode_str); if (nfapi_mode==2) // VNF wait_nfapi_init("main?"); printf("START MAIN THREADS\n"); - // start the main threads + number_of_cards = 1; + printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); + + if (RC.nb_L1_inst > 0) { + printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); + init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); + // for (inst=0;inst<RC.nb_L1_inst;inst++) + // for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0); + } - number_of_cards = 1; - printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); - if (RC.nb_L1_inst > 0) { - printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); - init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); - // for (inst=0;inst<RC.nb_L1_inst;inst++) - // for (CC_id=0;CC_id<RC.nb_L1_CC[inst];CC_id++) phy_init_lte_eNB(RC.eNB[inst][CC_id],0,0); - } + printf("wait_eNBs()\n"); + wait_eNBs(); + printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); - printf("wait_eNBs()\n"); - wait_eNBs(); + if (RC.nb_RU >0) { + printf("Initializing RU threads\n"); + init_RU(get_softmodem_params()->rf_config_file); - printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); - if (RC.nb_RU >0) { - printf("Initializing RU threads\n"); - init_RU(get_softmodem_params()->rf_config_file); - for (ru_id=0;ru_id<RC.nb_RU;ru_id++) { - RC.ru[ru_id]->rf_map.card=0; - RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); - } + for (ru_id=0; ru_id<RC.nb_RU; ru_id++) { + RC.ru[ru_id]->rf_map.card=0; + RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); } + } - config_sync_var=0; + config_sync_var=0; - if (nfapi_mode==1) { // PNF - wait_nfapi_init("main?"); - } + if (nfapi_mode==1) { // PNF + wait_nfapi_init("main?"); + } - printf("wait RUs\n"); - fflush(stdout); - fflush(stderr); - wait_RUs(); - printf("ALL RUs READY!\n"); - printf("RC.nb_RU:%d\n", RC.nb_RU); - // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) - printf("ALL RUs ready - init eNBs\n"); - - if (nfapi_mode != 1 && nfapi_mode != 2) - { - printf("Not NFAPI mode - call init_eNB_afterRU()\n"); - init_eNB_afterRU(); - } - else - { - printf("NFAPI mode - DO NOT call init_eNB_afterRU()\n"); - } - - printf("ALL RUs ready - ALL eNBs ready\n"); - - + printf("wait RUs\n"); + fflush(stdout); + fflush(stderr); + wait_RUs(); + printf("ALL RUs READY!\n"); + printf("RC.nb_RU:%d\n", RC.nb_RU); + // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) + printf("ALL RUs ready - init eNBs\n"); + + if (nfapi_mode != 1 && nfapi_mode != 2) { + printf("Not NFAPI mode - call init_eNB_afterRU()\n"); + init_eNB_afterRU(); + } else { + printf("NFAPI mode - DO NOT call init_eNB_afterRU()\n"); + } + + printf("ALL RUs ready - ALL eNBs ready\n"); // connect the TX/RX buffers - sleep(1); /* wait for thread activation */ - printf("Sending sync to all threads\n"); - pthread_mutex_lock(&sync_mutex); sync_var=0; pthread_cond_broadcast(&sync_cond); pthread_mutex_unlock(&sync_mutex); - ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS); + if (ret != 0) { - LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); - exit_fun(""); + LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); + exit_fun(""); } // wait for end of program printf("TYPE <CTRL-C> TO TERMINATE\n"); //getchar(); - #if defined(ENABLE_ITTI) printf("Entering ITTI signals handler\n"); itti_wait_tasks_end(); @@ -1010,10 +956,9 @@ int main( int argc, char **argv ) while (oai_exit==0) rt_sleep_ns(100000000ULL); - printf("Terminating application - oai_exit=%d\n",oai_exit); + printf("Terminating application - oai_exit=%d\n",oai_exit); #endif - // stop threads #ifdef XFORMS printf("waiting for XFORMS thread\n"); @@ -1022,24 +967,22 @@ int main( int argc, char **argv ) pthread_join(forms_thread,&status); fl_hide_form(form_stats->stats_form); fl_free_form(form_stats->stats_form); + fl_hide_form(form_stats_l2->stats_form); + fl_free_form(form_stats_l2->stats_form); - fl_hide_form(form_stats_l2->stats_form); - fl_free_form(form_stats_l2->stats_form); - - for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - fl_hide_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); - fl_free_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); - } + for(UE_id=0; UE_id<scope_enb_num_ue; UE_id++) { + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + fl_hide_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); + fl_free_form(form_enb[CC_id][UE_id]->lte_phy_scope_enb); } + } } #endif - printf("stopping MODEM threads\n"); - stop_eNB(NB_eNB_INST); stop_RU(RC.nb_RU); + /* release memory used by the RU/eNB threads (incomplete), after all * threads have been stopped (they partially use the same memory) */ for (int inst = 0; inst < NB_eNB_INST; inst++) { @@ -1048,41 +991,37 @@ int main( int argc, char **argv ) phy_free_lte_eNB(RC.eNB[inst][cc_id]); } } + for (int inst = 0; inst < RC.nb_RU; inst++) { phy_free_RU(RC.ru[inst]); } - free_lte_top(); + free_lte_top(); printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); end_configmodule(); printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - pthread_cond_destroy(&sync_cond); pthread_mutex_destroy(&sync_mutex); - pthread_cond_destroy(&nfapi_sync_cond); pthread_mutex_destroy(&nfapi_sync_mutex); - pthread_mutex_destroy(&ue_pf_po_mutex); + for(ru_id=0; ru_id<RC.nb_RU; ru_id++) { + if (RC.ru[ru_id]->rfdevice.trx_end_func) { + RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); + RC.ru[ru_id]->rfdevice.trx_end_func = NULL; + } - for(ru_id=0; ru_id<RC.nb_RU; ru_id++) { - if (RC.ru[ru_id]->rfdevice.trx_end_func) { - RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); - RC.ru[ru_id]->rfdevice.trx_end_func = NULL; - } - if (RC.ru[ru_id]->ifdevice.trx_end_func) { - RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); - RC.ru[ru_id]->ifdevice.trx_end_func = NULL; - } + if (RC.ru[ru_id]->ifdevice.trx_end_func) { + RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); + RC.ru[ru_id]->ifdevice.trx_end_func = NULL; } - + } + if (opt_enabled == 1) terminate_opt(); - - logClean(); + logClean(); printf("Bye.\n"); - return 0; } diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 593b64ea40001af5e7b3936ab65d6c4bdc93597d..1cd0b24f81d703ec31ada01866ed16c46bf89502 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -75,18 +75,18 @@ #include "UTIL/OPT/opt.h" #ifndef OPENAIR2 -#include "UTIL/OTG/otg_vars.h" + #include "UTIL/OTG/otg_vars.h" #endif #if defined(ENABLE_ITTI) -#include "create_tasks.h" + #include "create_tasks.h" #endif #include "system.h" #ifdef XFORMS -#include "PHY/TOOLS/lte_phy_scope.h" -#include "stats.h" + #include "PHY/TOOLS/lte_phy_scope.h" + #include "stats.h" #endif #include "lte-softmodem.h" @@ -95,14 +95,14 @@ /* temporary compilation wokaround (UE/eNB split */ uint16_t sf_ahead; #ifdef XFORMS -// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) -// at eNB 0, an UL scope for every UE -FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; -FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; -FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; -char title[255]; -unsigned char scope_enb_num_ue = 2; -static pthread_t forms_thread; //xforms + // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) + // at eNB 0, an UL scope for every UE + FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; + FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; + FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; + char title[255]; + unsigned char scope_enb_num_ue = 2; + static pthread_t forms_thread; //xforms #endif //XFORMS pthread_cond_t nfapi_sync_cond; @@ -125,8 +125,8 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] #if defined(ENABLE_ITTI) -volatile int start_eNB = 0; -volatile int start_UE = 0; + volatile int start_eNB = 0; + volatile int start_UE = 0; #endif volatile int oai_exit = 0; @@ -181,7 +181,7 @@ char channels[128] = "0"; int rx_input_level_dBm; #ifdef XFORMS -extern int otg_enabled; + extern int otg_enabled; #endif //int number_of_cards = 1; @@ -195,9 +195,9 @@ uint64_t num_missed_slots=0; // counter for the number of missed slots file */ extern void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface); -extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t UE_id, - uint8_t abstraction_flag); +extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, + uint8_t UE_id, + uint8_t abstraction_flag); extern void get_uethreads_params(void); @@ -205,11 +205,10 @@ int transmission_mode=1; -char* usrp_args=NULL; -char* usrp_clksrc=NULL; - - +char *usrp_args=NULL; +char *usrp_clksrc=NULL; +THREAD_STRUCT thread_struct; /* struct for ethernet specific parameters given in eNB conf file */ eth_params_t *eth_params; @@ -238,6 +237,7 @@ struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; struct timespec clock_difftime(struct timespec start, struct timespec end) { struct timespec temp; + if ((end.tv_nsec-start.tv_nsec)<0) { temp.tv_sec = end.tv_sec-start.tv_sec-1; temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; @@ -245,6 +245,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) { temp.tv_sec = end.tv_sec-start.tv_sec; temp.tv_nsec = end.tv_nsec-start.tv_nsec; } + return temp; } @@ -260,16 +261,21 @@ void update_difftimes(struct timespec start, struct timespec end) { struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 }; int changed = 0; diff_time = clock_difftime(start, end); + if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) { min_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; } + if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) { max_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; } + #if 1 + if (changed) print_difftimes(); + #endif } @@ -291,43 +297,38 @@ void signal_handler(int sig) { if (sig==SIGSEGV) { // get void*'s for all entries on the stack size = backtrace(array, 10); - // print out all the frames to stderr fprintf(stderr, "Error: signal %d:\n", sig); backtrace_symbols_fd(array, size, 2); exit(-1); } else { - char msg[64]; - sprintf(msg,"Received linux signal %s...\n",strsignal(sig)); - exit_function(__FILE__, __FUNCTION__, __LINE__,msg); - - + char msg[64]; + sprintf(msg,"Received linux signal %s...\n",strsignal(sig)); + exit_function(__FILE__, __FUNCTION__, __LINE__,msg); } } -void exit_function(const char* file, const char* function, const int line, const char* s) -{ +void exit_function(const char *file, const char *function, const int line, const char *s) { int CC_id; - logClean(); printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, ((s==NULL)?"":s)); - - oai_exit = 1; for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - if (PHY_vars_UE_g) + if (PHY_vars_UE_g) if (PHY_vars_UE_g[0]) - if (PHY_vars_UE_g[0][CC_id]) - if (PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func) - PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][CC_id]->rfdevice); - } + if (PHY_vars_UE_g[0][CC_id]) + if (PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func) + PHY_vars_UE_g[0][CC_id]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][CC_id]->rfdevice); + } - sleep(1); //allow lte-softmodem threads to exit first + sleep(1); //allow lte-softmodem threads to exit first #if defined(ENABLE_ITTI) - if(PHY_vars_UE_g != NULL ) - itti_terminate_tasks (TASK_UNKNOWN); + + if(PHY_vars_UE_g != NULL ) + itti_terminate_tasks (TASK_UNKNOWN); + #endif exit(1); } @@ -335,24 +336,21 @@ void exit_function(const char* file, const char* function, const int line, const #ifdef XFORMS -void reset_stats(FL_OBJECT *button, long arg) -{ +void reset_stats(FL_OBJECT *button, long arg) { int i,j,k; PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0]; for (i=0; i<NUMBER_OF_UE_MAX; i++) { for (k=0; k<8; k++) { //harq_processes for (j=0; j<phy_vars_eNB->dlsch[i][0]->Mlimit; j++) { - phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; - phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_NAK[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_ACK[k][j]=0; + phy_vars_eNB->UE_stats[i].dlsch_trials[k][j]=0; } phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0; phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0; phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0; - - phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0; phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0; phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0; @@ -366,43 +364,35 @@ static void *scope_thread(void *arg) { FILE *UE_stats, *eNB_stats; # endif struct sched_param sched_param; - - sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; sched_setscheduler(0, SCHED_FIFO,&sched_param); - printf("Scope thread has priority %d\n",sched_param.sched_priority); - # ifdef ENABLE_XFORMS_WRITE_STATS - UE_stats = fopen("UE_stats.txt", "w"); - #endif while (!oai_exit) { // dump_ue_stats (PHY_vars_UE_g[0][0], &PHY_vars_UE_g[0][0]->proc.proc_rxtx[0],stats_buffer, 0, mode,rx_input_level_dBm); - //fl_set_object_label(form_stats->stats_text, stats_buffer); - fl_clear_browser(form_stats->stats_text); - fl_add_browser_line(form_stats->stats_text, stats_buffer); - - phy_scope_UE(form_ue[0], - PHY_vars_UE_g[0][0], - 0, - 0,7); + //fl_set_object_label(form_stats->stats_text, stats_buffer); + fl_clear_browser(form_stats->stats_text); + fl_add_browser_line(form_stats->stats_text, stats_buffer); + phy_scope_UE(form_ue[0], + PHY_vars_UE_g[0][0], + 0, + 0,7); + // printf("%s",stats_buffer); + } - // printf("%s",stats_buffer); - } # ifdef ENABLE_XFORMS_WRITE_STATS - if (UE_stats) { - rewind (UE_stats); - fwrite (stats_buffer, 1, len, UE_stats); - fclose (UE_stats); - } + if (UE_stats) { + rewind (UE_stats); + fwrite (stats_buffer, 1, len, UE_stats); + fclose (UE_stats); + } # endif - - pthread_exit((void*)arg); + pthread_exit((void *)arg); } #endif @@ -412,36 +402,34 @@ static void *scope_thread(void *arg) { void *l2l1_task(void *arg) { MessageDef *message_p = NULL; int result; - itti_set_task_real_time(TASK_L2L1); itti_mark_task_ready(TASK_L2L1); - do { // Wait for a message itti_receive_msg (TASK_L2L1, &message_p); switch (ITTI_MSG_ID(message_p)) { - case TERMINATE_MESSAGE: - oai_exit=1; - itti_exit_task (); - break; + case TERMINATE_MESSAGE: + oai_exit=1; + itti_exit_task (); + break; - case ACTIVATE_MESSAGE: - start_UE = 1; - break; + case ACTIVATE_MESSAGE: + start_UE = 1; + break; - case DEACTIVATE_MESSAGE: - start_UE = 0; - break; + case DEACTIVATE_MESSAGE: + start_UE = 0; + break; - case MESSAGE_TEST: - LOG_I(SIM, "Received %s\n", ITTI_MSG_NAME(message_p)); - break; + case MESSAGE_TEST: + LOG_I(SIM, "Received %s\n", ITTI_MSG_NAME(message_p)); + break; - default: - LOG_E(SIM, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); - break; + default: + LOG_E(SIM, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); + break; } result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); @@ -460,79 +448,88 @@ static void get_options(void) { char *loopfile=NULL; int dumpframe; int timingadv; - set_default_frame_parms(frame_parms); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); -/* unknown parameters on command line will be checked in main - after all init have been performed */ - CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); + /* unknown parameters on command line will be checked in main + after all init have been performed */ + CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); get_common_options(); get_uethreads_params(); - paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; - - config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); - config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); + if (loopfile != NULL) { - printf("Input file for hardware emulation: %s",loopfile); - mode=loop_through_memory; - input_fd = fopen(loopfile,"r"); - AssertFatal(input_fd != NULL,"Please provide a valid input file\n"); + printf("Input file for hardware emulation: %s",loopfile); + mode=loop_through_memory; + input_fd = fopen(loopfile,"r"); + AssertFatal(input_fd != NULL,"Please provide a valid input file\n"); } + get_softmodem_params()->hw_timing_advance = timingadv; + if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; + if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med; + if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp; + if (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) - if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach; + if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach; + if (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) - if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect; - if (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) - if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx; + if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect; + + if (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) + if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx; + if (dumpframe > 0) mode = rx_dump_frame; - + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; } + UE_scan=0; - - if (tddflag > 0) { - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) - frame_parms[CC_id]->frame_type = TDD; + + if (tddflag > 0) { + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) + frame_parms[CC_id]->frame_type = TDD; } if (frame_parms[0]->N_RB_DL !=0) { - if ( frame_parms[0]->N_RB_DL < 6 ) { - frame_parms[0]->N_RB_DL = 6; - printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL); - } - if ( frame_parms[0]->N_RB_DL > 100 ) { - frame_parms[0]->N_RB_DL = 100; - printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL); - } - if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) { - frame_parms[0]->N_RB_DL = 50; - printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL); - } - if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) { - frame_parms[0]->N_RB_DL = 25; - printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL); - } - UE_scan = 0; - frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL; - for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) { - frame_parms[CC_id]->N_RB_DL=frame_parms[0]->N_RB_DL; - frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL; - } - } + if ( frame_parms[0]->N_RB_DL < 6 ) { + frame_parms[0]->N_RB_DL = 6; + printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL); + } + + if ( frame_parms[0]->N_RB_DL > 100 ) { + frame_parms[0]->N_RB_DL = 100; + printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL); + } + if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) { + frame_parms[0]->N_RB_DL = 50; + printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL); + } + + if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) { + frame_parms[0]->N_RB_DL = 25; + printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL); + } - for (CC_id=1;CC_id<MAX_NUM_CCs;CC_id++) { - rx_gain[0][CC_id] = rx_gain[0][0]; - tx_gain[0][CC_id] = tx_gain[0][0]; + UE_scan = 0; + frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL; + + for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) { + frame_parms[CC_id]->N_RB_DL=frame_parms[0]->N_RB_DL; + frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL; + } + } + + for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) { + rx_gain[0][CC_id] = rx_gain[0][0]; + tx_gain[0][CC_id] = tx_gain[0][0]; } /* @@ -542,17 +539,16 @@ static void get_options(void) { sprintf(uecap_xer,"%stargets/PROJECTS/GENERIC-LTE-EPC/CONF/UE_config.xml",getenv("OPENAIR_HOME")); printf("%s\n",uecap_xer); if(nfapi_mode!=3) - uecap_xer_in=1; - } *//* UE with config file */ + uecap_xer_in=1; + } *//* UE with config file */ } void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { - int CC_id; for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - frame_parms[CC_id] = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); + frame_parms[CC_id] = (LTE_DL_FRAME_PARMS *) malloc(sizeof(LTE_DL_FRAME_PARMS)); /* Set some default values that may be overwritten while reading options */ frame_parms[CC_id]->frame_type = FDD; frame_parms[CC_id]->tdd_config = 3; @@ -566,9 +562,7 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { frame_parms[CC_id]->nb_antenna_ports_eNB = 1; frame_parms[CC_id]->nb_antennas_tx = 1; frame_parms[CC_id]->nb_antennas_rx = 1; - frame_parms[CC_id]->nushift = 0; - frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; frame_parms[CC_id]->phich_config_common.phich_duration = normal; // UL RS Config @@ -576,45 +570,38 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; - frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; - downlink_frequency[CC_id][0] = DEFAULT_DLF; // Use float to avoid issue with frequency over 2^31. downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; - frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0]; - } - } void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { - int card; int i; for (card=0; card<MAX_CARDS; card++) { - openair0_cfg[card].mmapped_dma=mmapped_dma; openair0_cfg[card].configFilename = NULL; if(frame_parms->N_RB_DL == 100) { if (frame_parms->threequarter_fs) { - openair0_cfg[card].sample_rate=23.04e6; - openair0_cfg[card].samples_per_frame = 230400; - openair0_cfg[card].tx_bw = 10e6; - openair0_cfg[card].rx_bw = 10e6; + openair0_cfg[card].sample_rate=23.04e6; + openair0_cfg[card].samples_per_frame = 230400; + openair0_cfg[card].tx_bw = 10e6; + openair0_cfg[card].rx_bw = 10e6; } else { - openair0_cfg[card].sample_rate=30.72e6; - openair0_cfg[card].samples_per_frame = 307200; - openair0_cfg[card].tx_bw = 10e6; - openair0_cfg[card].rx_bw = 10e6; + openair0_cfg[card].sample_rate=30.72e6; + openair0_cfg[card].samples_per_frame = 307200; + openair0_cfg[card].tx_bw = 10e6; + openair0_cfg[card].rx_bw = 10e6; } } else if(frame_parms->N_RB_DL == 50) { openair0_cfg[card].sample_rate=15.36e6; @@ -633,67 +620,58 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { openair0_cfg[card].rx_bw = 1.5e6; } - - - if (frame_parms->frame_type==TDD) openair0_cfg[card].duplex_mode = duplex_mode_TDD; else //FDD openair0_cfg[card].duplex_mode = duplex_mode_FDD; openair0_cfg[card].Mod_id = 0; - openair0_cfg[card].num_rb_dl=frame_parms->N_RB_DL; - openair0_cfg[card].clock_source = clock_source; - - openair0_cfg[card].tx_num_channels=min(2,frame_parms->nb_antennas_tx); openair0_cfg[card].rx_num_channels=min(2,frame_parms->nb_antennas_rx); for (i=0; i<4; i++) { - if (i<openair0_cfg[card].tx_num_channels) - openair0_cfg[card].tx_freq[i] = downlink_frequency[0][i]+uplink_frequency_offset[0][i]; + openair0_cfg[card].tx_freq[i] = downlink_frequency[0][i]+uplink_frequency_offset[0][i]; else - openair0_cfg[card].tx_freq[i]=0.0; + openair0_cfg[card].tx_freq[i]=0.0; if (i<openair0_cfg[card].rx_num_channels) - openair0_cfg[card].rx_freq[i] = downlink_frequency[0][i]; + openair0_cfg[card].rx_freq[i] = downlink_frequency[0][i]; else - openair0_cfg[card].rx_freq[i]=0.0; + openair0_cfg[card].rx_freq[i]=0.0; openair0_cfg[card].autocal[i] = 1; openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off; - - openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", - card,i, openair0_cfg[card].tx_gain[i], - openair0_cfg[card].rx_gain[i], - openair0_cfg[card].tx_freq[i], - openair0_cfg[card].rx_freq[i]); + card,i, openair0_cfg[card].tx_gain[i], + openair0_cfg[card].rx_gain[i], + openair0_cfg[card].tx_freq[i], + openair0_cfg[card].rx_freq[i]); } if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args; + if (usrp_clksrc) { if (strcmp(usrp_clksrc, "internal") == 0) { - openair0_cfg[card].clock_source = internal; - LOG_D(PHY, "USRP clock source set as internal\n"); + openair0_cfg[card].clock_source = internal; + LOG_D(PHY, "USRP clock source set as internal\n"); } else if (strcmp(usrp_clksrc, "external") == 0) { - openair0_cfg[card].clock_source = external; - LOG_D(PHY, "USRP clock source set as external\n"); + openair0_cfg[card].clock_source = external; + LOG_D(PHY, "USRP clock source set as external\n"); } else if (strcmp(usrp_clksrc, "gpsdo") == 0) { - openair0_cfg[card].clock_source = gpsdo; - LOG_D(PHY, "USRP clock source set as gpsdo\n"); + openair0_cfg[card].clock_source = gpsdo; + LOG_D(PHY, "USRP clock source set as gpsdo\n"); } else { - openair0_cfg[card].clock_source = internal; - LOG_I(PHY, "USRP clock source unknown ('%s'). defaulting to internal\n", usrp_clksrc); + openair0_cfg[card].clock_source = internal; + LOG_I(PHY, "USRP clock source unknown ('%s'). defaulting to internal\n", usrp_clksrc); } } else { openair0_cfg[card].clock_source = internal; - LOG_I(PHY, "USRP clock source not specified. defaulting to internal\n"); + LOG_I(PHY, "USRP clock source not specified. defaulting to internal\n"); } } } @@ -705,8 +683,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { /* * helper function to terminate a certain ITTI task */ -void terminate_task(task_id_t task_id, module_id_t mod_id) -{ +void terminate_task(task_id_t task_id, module_id_t mod_id) { LOG_I(ENB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id); MessageDef *msg; msg = itti_alloc_new_message (ENB_APP, TERMINATE_MESSAGE); @@ -720,7 +697,6 @@ void terminate_task(task_id_t task_id, module_id_t mod_id) static inline void wait_nfapi_init(char *thread_name) { - printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); pthread_mutex_lock( &nfapi_sync_mutex ); @@ -728,98 +704,72 @@ static inline void wait_nfapi_init(char *thread_name) { pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); pthread_mutex_unlock(&nfapi_sync_mutex); - printf( "NFAPI: got sync (%s)\n", thread_name); } -int stop_L1L2(module_id_t enb_id) -{ - return 0; +int stop_L1L2(module_id_t enb_id) { + return 0; } -int restart_L1L2(module_id_t enb_id) -{ - return 0; +int restart_L1L2(module_id_t enb_id) { + return 0; } -int main( int argc, char **argv ) -{ +int main( int argc, char **argv ) { #if defined (XFORMS) void *status; #endif - int CC_id; uint8_t abstraction_flag=0; - // Default value for the number of UEs. It will hold, // if not changed from the command line option --num-ues NB_UE_INST=1; - #if defined (XFORMS) int ret; #endif - start_background_system(); + if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) { exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); - } - - + } mode = normal_txrx; memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); - - set_latency_target(); - logInit(); - printf("Reading in command-line options\n"); - for (int i=0;i<MAX_NUM_CCs;i++) tx_max_power[i]=23; - CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); - get_options (); - - - + for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23; + CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); + get_options (); printf("Running with %d UE instances\n",NB_UE_INST); + if (NB_UE_INST > 1 && simL1flag != 1) { printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n"); abort(); } printf("NFAPI_MODE value: %d \n", nfapi_mode); - - - - #if T_TRACER T_Config_Init(); #endif - CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT); - - + CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT); //randominit (0); set_taus_seed (0); - cpuf=get_cpu_freq_GHz(); - pthread_cond_init(&sync_cond,NULL); pthread_mutex_init(&sync_mutex, NULL); - #if defined(ENABLE_ITTI) - - - printf("ITTI init\n"); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); // initialize mscgen log after ITTI if (get_softmodem_params()->start_msc) { - load_module_shlib("msc",NULL,0,&msc_interface); + load_module_shlib("msc",NULL,0,&msc_interface); } + MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); #endif @@ -835,128 +785,117 @@ int main( int argc, char **argv ) pdcp_netlink_init(); #endif #endif - -//TTN for D2D + //TTN for D2D #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) printf ("RRC control socket\n"); rrc_control_socket_init(); printf ("PDCP PC5S socket\n"); pdcp_pc5_socket_init(); #endif - // to make a graceful exit when ctrl-c is pressed signal(SIGSEGV, signal_handler); signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); signal(SIGABRT, signal_handler); - check_clock(); - #ifndef PACKAGE_VERSION # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" #endif - LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); // init the parameters for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - frame_parms[CC_id]->nb_antennas_tx = nb_antenna_tx; - frame_parms[CC_id]->nb_antennas_rx = nb_antenna_rx; - frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later + frame_parms[CC_id]->nb_antennas_tx = nb_antenna_tx; + frame_parms[CC_id]->nb_antennas_rx = nb_antenna_rx; + frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later } + NB_INST=1; + if(nfapi_mode == 3) { + PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE **)*NB_UE_INST); - NB_INST=1; - if(nfapi_mode == 3){ - PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)*NB_UE_INST); - for (int i=0; i<NB_UE_INST; i++) { - for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); - PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag); - - - if (get_softmodem_params()->phy_test==1) - PHY_vars_UE_g[i][CC_id]->mac_enabled = 0; - else - PHY_vars_UE_g[i][CC_id]->mac_enabled = 1; - } - } - } - else init_openair0(frame_parms[0],(int)rx_gain[0][0]); + for (int i=0; i<NB_UE_INST; i++) { + for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE *)*MAX_NUM_CCs); + PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag); + if (get_softmodem_params()->phy_test==1) + PHY_vars_UE_g[i][CC_id]->mac_enabled = 0; + else + PHY_vars_UE_g[i][CC_id]->mac_enabled = 1; + } + } + } else init_openair0(frame_parms[0],(int)rx_gain[0][0]); if (simL1flag==1) { AssertFatal(NULL!=load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY), "[SOFTMODEM] Error, configuration module init failed\n"); - RCConfig_sim(); } // start the main UE threads int eMBMS_active = 0; - if (nfapi_mode==3) // UE-STUB-PNF - { - config_sync_var=0; - wait_nfapi_init("main?"); - //Panos: Temporarily we will be using single set of threads for multiple UEs. - //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); - init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); - } - else { - init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], - frame_parms[0]); + if (nfapi_mode==3) { // UE-STUB-PNF + config_sync_var=0; + wait_nfapi_init("main?"); + //Panos: Temporarily we will be using single set of threads for multiple UEs. + //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); + init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); + } else { + init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], + frame_parms[0]); } - if (get_softmodem_params()->phy_test==0) { printf("Filling UE band info\n"); fill_ue_band_info(); dl_phy_sync_success (0, 0, 0, 1); } - if (nfapi_mode!=3){ - number_of_cards = 1; - for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id]->rf_map.card=0; - PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); - } + if (nfapi_mode!=3) { + number_of_cards = 1; + + for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[0][CC_id]->rf_map.card=0; + PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); + } } - cpuf=get_cpu_freq_GHz(); - - - #ifndef DEADLINE_SCHEDULER - printf("NO deadline scheduler\n"); /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ - cpu_set_t cpuset; int s; char cpu_affinity[1024]; CPU_ZERO(&cpuset); #ifdef CPU_AFFINITY + if (get_nprocs() > 2) { CPU_SET(0, &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { perror( "pthread_setaffinity_np"); exit_fun("Error setting processor affinity"); } + LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); } + #endif - /* Check the actual affinity mask assigned to the thread */ s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + if (s != 0) { perror( "pthread_getaffinity_np"); exit_fun("Error getting processor affinity "); } + memset(cpu_affinity, 0 , sizeof(cpu_affinity)); + for (int j = 0; j < CPU_SETSIZE; j++) { if (CPU_ISSET(j, &cpuset)) { char temp[1024]; @@ -964,146 +903,134 @@ int main( int argc, char **argv ) strcat(cpu_affinity, temp); } } + LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); #endif - - - - #if defined(ENABLE_ITTI) - if (create_tasks_ue(1) < 0) { - printf("cannot create ITTI tasks\n"); - exit(-1); // need a softer mode - } - if(nfapi_mode==3){ // Here we should add another nfapi_mode for the case of Supervised LTE-D2D - UE_config_stub_pnf(); - } - printf("ITTI tasks created\n"); -#endif - + if (create_tasks_ue(1) < 0) { + printf("cannot create ITTI tasks\n"); + exit(-1); // need a softer mode + } + + if(nfapi_mode==3) { // Here we should add another nfapi_mode for the case of Supervised LTE-D2D + UE_config_stub_pnf(); + } + + printf("ITTI tasks created\n"); +#endif mlockall(MCL_CURRENT | MCL_FUTURE); - - rt_sleep_ns(10*100000000ULL); - const char *nfapi_mode_str = "<UNKNOWN>"; - switch(nfapi_mode) - { - case 0: - nfapi_mode_str = "MONOLITHIC"; - break; - case 1: - nfapi_mode_str = "PNF"; - break; - case 2: - nfapi_mode_str = "VNF"; - break; - case 3: - nfapi_mode_str = "UE_STUB_PNF"; - break; - case 4: - nfapi_mode_str = "UE_STUB_OFFNET"; - break; - default: - nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; - break; - } - printf("NFAPI MODE:%s\n", nfapi_mode_str); + switch(nfapi_mode) { + case 0: + nfapi_mode_str = "MONOLITHIC"; + break; + + case 1: + nfapi_mode_str = "PNF"; + break; + case 2: + nfapi_mode_str = "VNF"; + break; + + case 3: + nfapi_mode_str = "UE_STUB_PNF"; + break; + + case 4: + nfapi_mode_str = "UE_STUB_OFFNET"; + break; + + default: + nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; + break; + } + + printf("NFAPI MODE:%s\n", nfapi_mode_str); // connect the TX/RX buffers - - /* - if(nfapi_mode!=3) { - if (setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0])!=0) { - printf("Error setting up eNB buffer\n"); - exit(-1); - } - } - */ - - - - if (input_fd) { - printf("Reading in from file to antenna buffer %d\n",0); - if (fread(PHY_vars_UE_g[0][0]->common_vars.rxdata[0], - sizeof(int32_t), - frame_parms[0]->samples_per_tti*10, - input_fd) != frame_parms[0]->samples_per_tti*10) - printf("error reading from file\n"); + /* + if(nfapi_mode!=3) { + if (setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0])!=0) { + printf("Error setting up eNB buffer\n"); + exit(-1); } - //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; + } + */ - - if (simL1flag==1) { - init_ocm((double)snr_dB,0); - PHY_vars_UE_g[0][0]->no_timing_correction = 1; + if (input_fd) { + printf("Reading in from file to antenna buffer %d\n",0); + + if (fread(PHY_vars_UE_g[0][0]->common_vars.rxdata[0], + sizeof(int32_t), + frame_parms[0]->samples_per_tti*10, + input_fd) != frame_parms[0]->samples_per_tti*10) + printf("error reading from file\n"); } - + //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; + + if (simL1flag==1) { + init_ocm((double)snr_dB,0); + PHY_vars_UE_g[0][0]->no_timing_correction = 1; + } #ifdef XFORMS int UE_id; - printf("XFORMS\n"); if (get_softmodem_params()->do_forms==1) { fl_initialize (&argc, argv, NULL, 0, 0); - - form_stats = create_form_stats_form(); - fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); - UE_id = 0; - form_ue[UE_id] = create_lte_phy_scope_ue(); - sprintf (title, "LTE DL SCOPE UE"); - fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - - /* - if (openair_daq_vars.use_ia_receiver) { - fl_set_button(form_ue[UE_id]->button_0,1); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); - } else { - fl_set_button(form_ue[UE_id]->button_0,0); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); - }*/ - fl_set_button(form_ue[UE_id]->button_0,0); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); + form_stats = create_form_stats_form(); + fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); + UE_id = 0; + form_ue[UE_id] = create_lte_phy_scope_ue(); + sprintf (title, "LTE DL SCOPE UE"); + fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + /* + if (openair_daq_vars.use_ia_receiver) { + fl_set_button(form_ue[UE_id]->button_0,1); + fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); + } else { + fl_set_button(form_ue[UE_id]->button_0,0); + fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); + }*/ + fl_set_button(form_ue[UE_id]->button_0,0); + fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver OFF"); ret = pthread_create(&forms_thread, NULL, scope_thread, NULL); - + if (ret == 0) pthread_setname_np( forms_thread, "xforms" ); - + printf("Scope thread created, ret=%d\n",ret); } - + #endif ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS); + if (ret != 0) { - LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); - exit_fun(""); + LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); + exit_fun(""); } printf("Sending sync to all threads (%p,%p,%p)\n",&sync_var,&sync_cond,&sync_mutex); - - pthread_mutex_lock(&sync_mutex); sync_var=0; pthread_cond_broadcast(&sync_cond); pthread_mutex_unlock(&sync_mutex); - printf("sync sent\n"); -/* - printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - end_configmodule(); - printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); -*/ + /* + printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); + end_configmodule(); + printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); + */ // wait for end of program printf("TYPE <CTRL-C> TO TERMINATE\n"); //getchar(); - - #if defined(ENABLE_ITTI) printf("Entering ITTI signals handler\n"); itti_wait_tasks_end(); @@ -1112,12 +1039,11 @@ int main( int argc, char **argv ) printf("oai_exit=%d\n",oai_exit); #else - while (oai_exit==0) - rt_sleep_ns(100000000ULL); - printf("Terminating application - oai_exit=%d\n",oai_exit); + while (oai_exit==0) + rt_sleep_ns(100000000ULL); + printf("Terminating application - oai_exit=%d\n",oai_exit); #endif - // stop threads #ifdef XFORMS printf("waiting for XFORMS thread\n"); @@ -1131,9 +1057,7 @@ int main( int argc, char **argv ) } #endif - printf("stopping MODEM threads\n"); - pthread_cond_destroy(&sync_cond); pthread_mutex_destroy(&sync_mutex); @@ -1142,13 +1066,11 @@ int main( int argc, char **argv ) // *** Handle per CC_id openair0 if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func) PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice); - + if (opt_enabled == 1) terminate_opt(); - - logClean(); + logClean(); printf("Bye.\n"); - return 0; }