diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/charts/physims/Chart.yaml b/charts/physims/Chart.yaml new file mode 100644 index 0000000000..bef28aac27 --- /dev/null +++ b/charts/physims/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-physim +description: A Helm chart for physical simulators network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulators + - RAN + - 4G + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/dlsim/Chart.yaml b/charts/physims/charts/dlsim/Chart.yaml new file mode 100644 index 0000000000..de7f5958b2 --- /dev/null +++ b/charts/physims/charts/dlsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-dlsim +description: A Helm subchart for dlsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - dlsim + - RAN + - 4G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/dlsim/templates/NOTES.txt b/charts/physims/charts/dlsim/templates/NOTES.txt new file mode 100644 index 0000000000..75b79e3dd4 --- /dev/null +++ b/charts/physims/charts/dlsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-dlsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-dlsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-dlsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-dlsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/dlsim/templates/_helpers.tpl b/charts/physims/charts/dlsim/templates/_helpers.tpl new file mode 100644 index 0000000000..7ae142b671 --- /dev/null +++ b/charts/physims/charts/dlsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-dlsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-dlsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-dlsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-dlsim.labels" -}} +helm.sh/chart: {{ include "oai-dlsim.chart" . }} +{{ include "oai-dlsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-dlsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-dlsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-dlsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-dlsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/dlsim/templates/deployment.yaml b/charts/physims/charts/dlsim/templates/deployment.yaml new file mode 100644 index 0000000000..9cbdd383b3 --- /dev/null +++ b/charts/physims/charts/dlsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-dlsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-dlsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-dlsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-dlsim + # volumeMounts: + # - mountPath: /opt/oai-dlsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015100" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/dlsim/templates/service.yaml b/charts/physims/charts/dlsim/templates/service.yaml new file mode 100644 index 0000000000..6aeb0dbf53 --- /dev/null +++ b/charts/physims/charts/dlsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-dlsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-dlsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-dlsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/dlsim/values.yaml b/charts/physims/charts/dlsim/values.yaml new file mode 100644 index 0000000000..c0142b50ae --- /dev/null +++ b/charts/physims/charts/dlsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-dlsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-dlsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/ldpctest/Chart.yaml b/charts/physims/charts/ldpctest/Chart.yaml new file mode 100644 index 0000000000..667bd3d8aa --- /dev/null +++ b/charts/physims/charts/ldpctest/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-ldpctest +description: A Helm subchart for ldpctest network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - ldpctest + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/ldpctest/templates/NOTES.txt b/charts/physims/charts/ldpctest/templates/NOTES.txt new file mode 100644 index 0000000000..bda83c2f9e --- /dev/null +++ b/charts/physims/charts/ldpctest/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-ldpctest.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-ldpctest.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-ldpctest.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-ldpctest.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/ldpctest/templates/_helpers.tpl b/charts/physims/charts/ldpctest/templates/_helpers.tpl new file mode 100644 index 0000000000..018eaa5af5 --- /dev/null +++ b/charts/physims/charts/ldpctest/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-ldpctest.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-ldpctest.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-ldpctest.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-ldpctest.labels" -}} +helm.sh/chart: {{ include "oai-ldpctest.chart" . }} +{{ include "oai-ldpctest.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-ldpctest.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-ldpctest.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-ldpctest.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-ldpctest.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/ldpctest/templates/deployment.yaml b/charts/physims/charts/ldpctest/templates/deployment.yaml new file mode 100644 index 0000000000..ef30d9c08a --- /dev/null +++ b/charts/physims/charts/ldpctest/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-ldpctest.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-ldpctest.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-ldpctest.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-ldpctest + # volumeMounts: + # - mountPath: /opt/oai-ldpctest/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015102" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/ldpctest/templates/service.yaml b/charts/physims/charts/ldpctest/templates/service.yaml new file mode 100644 index 0000000000..eb0db8ce00 --- /dev/null +++ b/charts/physims/charts/ldpctest/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-ldpctest.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-ldpctest + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-ldpctest.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/ldpctest/values.yaml b/charts/physims/charts/ldpctest/values.yaml new file mode 100644 index 0000000000..91eab91af5 --- /dev/null +++ b/charts/physims/charts/ldpctest/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-ldpctest. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-ldpctest-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/nr-dlschsim/Chart.yaml b/charts/physims/charts/nr-dlschsim/Chart.yaml new file mode 100644 index 0000000000..3837f0cd2b --- /dev/null +++ b/charts/physims/charts/nr-dlschsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-nr-dlschsim +description: A Helm subchart for nr-dlschsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - nr-dlschsim + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/nr-dlschsim/templates/NOTES.txt b/charts/physims/charts/nr-dlschsim/templates/NOTES.txt new file mode 100644 index 0000000000..1f88d64976 --- /dev/null +++ b/charts/physims/charts/nr-dlschsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-nr-dlschsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-nr-dlschsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-nr-dlschsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-nr-dlschsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/nr-dlschsim/templates/_helpers.tpl b/charts/physims/charts/nr-dlschsim/templates/_helpers.tpl new file mode 100644 index 0000000000..6b6a5181e9 --- /dev/null +++ b/charts/physims/charts/nr-dlschsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-nr-dlschsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-nr-dlschsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-nr-dlschsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-nr-dlschsim.labels" -}} +helm.sh/chart: {{ include "oai-nr-dlschsim.chart" . }} +{{ include "oai-nr-dlschsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-nr-dlschsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-nr-dlschsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-nr-dlschsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-nr-dlschsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/nr-dlschsim/templates/deployment.yaml b/charts/physims/charts/nr-dlschsim/templates/deployment.yaml new file mode 100644 index 0000000000..06f01a0f0b --- /dev/null +++ b/charts/physims/charts/nr-dlschsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-dlschsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-nr-dlschsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-nr-dlschsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-nr-dlschsim + # volumeMounts: + # - mountPath: /opt/oai-nr-dlschsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015106" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/nr-dlschsim/templates/service.yaml b/charts/physims/charts/nr-dlschsim/templates/service.yaml new file mode 100644 index 0000000000..0dd065c9e0 --- /dev/null +++ b/charts/physims/charts/nr-dlschsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-dlschsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-nr-dlschsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-nr-dlschsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/nr-dlschsim/values.yaml b/charts/physims/charts/nr-dlschsim/values.yaml new file mode 100644 index 0000000000..e96541102c --- /dev/null +++ b/charts/physims/charts/nr-dlschsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-nr-dlschsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-nr-dlschsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/nr-dlsim/Chart.yaml b/charts/physims/charts/nr-dlsim/Chart.yaml new file mode 100644 index 0000000000..2ec4b7eabd --- /dev/null +++ b/charts/physims/charts/nr-dlsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-nr-dlsim +description: A Helm subchart for nr-dlsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - nr-dlsim + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/nr-dlsim/templates/NOTES.txt b/charts/physims/charts/nr-dlsim/templates/NOTES.txt new file mode 100644 index 0000000000..79027454cf --- /dev/null +++ b/charts/physims/charts/nr-dlsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-nr-dlsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-nr-dlsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-nr-dlsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-nr-dlsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/nr-dlsim/templates/_helpers.tpl b/charts/physims/charts/nr-dlsim/templates/_helpers.tpl new file mode 100644 index 0000000000..1dd7fbd3fd --- /dev/null +++ b/charts/physims/charts/nr-dlsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-nr-dlsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-nr-dlsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-nr-dlsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-nr-dlsim.labels" -}} +helm.sh/chart: {{ include "oai-nr-dlsim.chart" . }} +{{ include "oai-nr-dlsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-nr-dlsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-nr-dlsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-nr-dlsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-nr-dlsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/nr-dlsim/templates/deployment.yaml b/charts/physims/charts/nr-dlsim/templates/deployment.yaml new file mode 100644 index 0000000000..4c38664e61 --- /dev/null +++ b/charts/physims/charts/nr-dlsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-dlsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-nr-dlsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-nr-dlsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-nr-dlsim + # volumeMounts: + # - mountPath: /opt/oai-nr-dlsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015105" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/nr-dlsim/templates/service.yaml b/charts/physims/charts/nr-dlsim/templates/service.yaml new file mode 100644 index 0000000000..c58433f3b2 --- /dev/null +++ b/charts/physims/charts/nr-dlsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-dlsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-nr-dlsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-nr-dlsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/nr-dlsim/values.yaml b/charts/physims/charts/nr-dlsim/values.yaml new file mode 100644 index 0000000000..c86fc96cff --- /dev/null +++ b/charts/physims/charts/nr-dlsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-nr-dlsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-nr-dlsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/nr-pbchsim/Chart.yaml b/charts/physims/charts/nr-pbchsim/Chart.yaml new file mode 100644 index 0000000000..6d8359598d --- /dev/null +++ b/charts/physims/charts/nr-pbchsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-nr-pbchsim +description: A Helm subchart for nr-pbchsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - nr-pbchsim + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/nr-pbchsim/templates/NOTES.txt b/charts/physims/charts/nr-pbchsim/templates/NOTES.txt new file mode 100644 index 0000000000..cee233d4f3 --- /dev/null +++ b/charts/physims/charts/nr-pbchsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-nr-pbchsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-nr-pbchsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-nr-pbchsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-nr-pbchsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/nr-pbchsim/templates/_helpers.tpl b/charts/physims/charts/nr-pbchsim/templates/_helpers.tpl new file mode 100644 index 0000000000..0e31033343 --- /dev/null +++ b/charts/physims/charts/nr-pbchsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-nr-pbchsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-nr-pbchsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-nr-pbchsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-nr-pbchsim.labels" -}} +helm.sh/chart: {{ include "oai-nr-pbchsim.chart" . }} +{{ include "oai-nr-pbchsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-nr-pbchsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-nr-pbchsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-nr-pbchsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-nr-pbchsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/nr-pbchsim/templates/deployment.yaml b/charts/physims/charts/nr-pbchsim/templates/deployment.yaml new file mode 100644 index 0000000000..551785abc0 --- /dev/null +++ b/charts/physims/charts/nr-pbchsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-pbchsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-nr-pbchsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-nr-pbchsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-nr-pbchsim + # volumeMounts: + # - mountPath: /opt/oai-nr-pbchsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015104" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/nr-pbchsim/templates/service.yaml b/charts/physims/charts/nr-pbchsim/templates/service.yaml new file mode 100644 index 0000000000..35faf3c33d --- /dev/null +++ b/charts/physims/charts/nr-pbchsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-pbchsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-nr-pbchsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-nr-pbchsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/nr-pbchsim/values.yaml b/charts/physims/charts/nr-pbchsim/values.yaml new file mode 100644 index 0000000000..62d89f9632 --- /dev/null +++ b/charts/physims/charts/nr-pbchsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-nr-pbchsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-nr-pbchsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/nr-prachsim/Chart.yaml b/charts/physims/charts/nr-prachsim/Chart.yaml new file mode 100644 index 0000000000..8c88587a7f --- /dev/null +++ b/charts/physims/charts/nr-prachsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-nr-prachsim +description: A Helm subchart for nr-prachsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - nr-prachsim + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/nr-prachsim/templates/NOTES.txt b/charts/physims/charts/nr-prachsim/templates/NOTES.txt new file mode 100644 index 0000000000..376694e7e4 --- /dev/null +++ b/charts/physims/charts/nr-prachsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-nr-prachsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-nr-prachsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-nr-prachsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-nr-prachsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/nr-prachsim/templates/_helpers.tpl b/charts/physims/charts/nr-prachsim/templates/_helpers.tpl new file mode 100644 index 0000000000..6362c72b2a --- /dev/null +++ b/charts/physims/charts/nr-prachsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-nr-prachsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-nr-prachsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-nr-prachsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-nr-prachsim.labels" -}} +helm.sh/chart: {{ include "oai-nr-prachsim.chart" . }} +{{ include "oai-nr-prachsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-nr-prachsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-nr-prachsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-nr-prachsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-nr-prachsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/nr-prachsim/templates/deployment.yaml b/charts/physims/charts/nr-prachsim/templates/deployment.yaml new file mode 100644 index 0000000000..52bc030c45 --- /dev/null +++ b/charts/physims/charts/nr-prachsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-prachsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-nr-prachsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-nr-prachsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-nr-prachsim + # volumeMounts: + # - mountPath: /opt/oai-nr-prachsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015112" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/nr-prachsim/templates/service.yaml b/charts/physims/charts/nr-prachsim/templates/service.yaml new file mode 100644 index 0000000000..71bfe7b9fe --- /dev/null +++ b/charts/physims/charts/nr-prachsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-prachsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-nr-prachsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-nr-prachsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/nr-prachsim/values.yaml b/charts/physims/charts/nr-prachsim/values.yaml new file mode 100644 index 0000000000..3ea9787f7a --- /dev/null +++ b/charts/physims/charts/nr-prachsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-nr-prachsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-nr-prachsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/nr-pucchsim/Chart.yaml b/charts/physims/charts/nr-pucchsim/Chart.yaml new file mode 100644 index 0000000000..bb0033175f --- /dev/null +++ b/charts/physims/charts/nr-pucchsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-nr-pucchsim +description: A Helm subchart for nr-pucchsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - nr-pucchsim + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/nr-pucchsim/templates/NOTES.txt b/charts/physims/charts/nr-pucchsim/templates/NOTES.txt new file mode 100644 index 0000000000..7c2cfa9155 --- /dev/null +++ b/charts/physims/charts/nr-pucchsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-nr-pucchsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-nr-pucchsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-nr-pucchsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-nr-pucchsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/nr-pucchsim/templates/_helpers.tpl b/charts/physims/charts/nr-pucchsim/templates/_helpers.tpl new file mode 100644 index 0000000000..210ba26db2 --- /dev/null +++ b/charts/physims/charts/nr-pucchsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-nr-pucchsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-nr-pucchsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-nr-pucchsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-nr-pucchsim.labels" -}} +helm.sh/chart: {{ include "oai-nr-pucchsim.chart" . }} +{{ include "oai-nr-pucchsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-nr-pucchsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-nr-pucchsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-nr-pucchsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-nr-pucchsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/nr-pucchsim/templates/deployment.yaml b/charts/physims/charts/nr-pucchsim/templates/deployment.yaml new file mode 100644 index 0000000000..d783991e0b --- /dev/null +++ b/charts/physims/charts/nr-pucchsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-pucchsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-nr-pucchsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-nr-pucchsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-nr-pucchsim + # volumeMounts: + # - mountPath: /opt/oai-nr-pucchsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015109" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/nr-pucchsim/templates/service.yaml b/charts/physims/charts/nr-pucchsim/templates/service.yaml new file mode 100644 index 0000000000..9e8760e76b --- /dev/null +++ b/charts/physims/charts/nr-pucchsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-pucchsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-nr-pucchsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-nr-pucchsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/nr-pucchsim/values.yaml b/charts/physims/charts/nr-pucchsim/values.yaml new file mode 100644 index 0000000000..cf50c0bd3c --- /dev/null +++ b/charts/physims/charts/nr-pucchsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-nr-pucchsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-nr-pucchsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/nr-ulschsim/Chart.yaml b/charts/physims/charts/nr-ulschsim/Chart.yaml new file mode 100644 index 0000000000..e2525f0032 --- /dev/null +++ b/charts/physims/charts/nr-ulschsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-nr-ulschsim +description: A Helm subchart for nr-ulschsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - nr-ulschsim + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/nr-ulschsim/templates/NOTES.txt b/charts/physims/charts/nr-ulschsim/templates/NOTES.txt new file mode 100644 index 0000000000..65566932cd --- /dev/null +++ b/charts/physims/charts/nr-ulschsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-nr-ulschsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-nr-ulschsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-nr-ulschsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-nr-ulschsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/nr-ulschsim/templates/_helpers.tpl b/charts/physims/charts/nr-ulschsim/templates/_helpers.tpl new file mode 100644 index 0000000000..9aa13a81f0 --- /dev/null +++ b/charts/physims/charts/nr-ulschsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-nr-ulschsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-nr-ulschsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-nr-ulschsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-nr-ulschsim.labels" -}} +helm.sh/chart: {{ include "oai-nr-ulschsim.chart" . }} +{{ include "oai-nr-ulschsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-nr-ulschsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-nr-ulschsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-nr-ulschsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-nr-ulschsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/nr-ulschsim/templates/deployment.yaml b/charts/physims/charts/nr-ulschsim/templates/deployment.yaml new file mode 100644 index 0000000000..56fb0de5b8 --- /dev/null +++ b/charts/physims/charts/nr-ulschsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-ulschsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-nr-ulschsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-nr-ulschsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-nr-ulschsim + # volumeMounts: + # - mountPath: /opt/oai-nr-ulschsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015108" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/nr-ulschsim/templates/service.yaml b/charts/physims/charts/nr-ulschsim/templates/service.yaml new file mode 100644 index 0000000000..d34882700e --- /dev/null +++ b/charts/physims/charts/nr-ulschsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-ulschsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-nr-ulschsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-nr-ulschsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/nr-ulschsim/values.yaml b/charts/physims/charts/nr-ulschsim/values.yaml new file mode 100644 index 0000000000..420b154596 --- /dev/null +++ b/charts/physims/charts/nr-ulschsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-nr-ulschsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-nr-ulschsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/nr-ulsim/Chart.yaml b/charts/physims/charts/nr-ulsim/Chart.yaml new file mode 100644 index 0000000000..ede87ea7e4 --- /dev/null +++ b/charts/physims/charts/nr-ulsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-nr-ulsim +description: A Helm subchart for nr-ulsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - nr-ulsim + - RAN + - 5G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/nr-ulsim/templates/NOTES.txt b/charts/physims/charts/nr-ulsim/templates/NOTES.txt new file mode 100644 index 0000000000..6865eeaedf --- /dev/null +++ b/charts/physims/charts/nr-ulsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-nr-ulsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-nr-ulsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-nr-ulsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-nr-ulsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/nr-ulsim/templates/_helpers.tpl b/charts/physims/charts/nr-ulsim/templates/_helpers.tpl new file mode 100644 index 0000000000..90f0bd0e36 --- /dev/null +++ b/charts/physims/charts/nr-ulsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-nr-ulsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-nr-ulsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-nr-ulsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-nr-ulsim.labels" -}} +helm.sh/chart: {{ include "oai-nr-ulsim.chart" . }} +{{ include "oai-nr-ulsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-nr-ulsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-nr-ulsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-nr-ulsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-nr-ulsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/nr-ulsim/templates/deployment.yaml b/charts/physims/charts/nr-ulsim/templates/deployment.yaml new file mode 100644 index 0000000000..c0fa5ceb3b --- /dev/null +++ b/charts/physims/charts/nr-ulsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-ulsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-nr-ulsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-nr-ulsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-nr-ulsim + # volumeMounts: + # - mountPath: /opt/oai-nr-ulsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015111" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/nr-ulsim/templates/service.yaml b/charts/physims/charts/nr-ulsim/templates/service.yaml new file mode 100644 index 0000000000..95f198d1b1 --- /dev/null +++ b/charts/physims/charts/nr-ulsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-nr-ulsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-nr-ulsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-nr-ulsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/nr-ulsim/values.yaml b/charts/physims/charts/nr-ulsim/values.yaml new file mode 100644 index 0000000000..7eb8e33fcb --- /dev/null +++ b/charts/physims/charts/nr-ulsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-nr-ulsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-nr-ulsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/polartest/Chart.yaml b/charts/physims/charts/polartest/Chart.yaml new file mode 100644 index 0000000000..ae5f5ca263 --- /dev/null +++ b/charts/physims/charts/polartest/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-polartest +description: A Helm subchart for polartest network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - polartest + - RAN + - 4G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/polartest/templates/NOTES.txt b/charts/physims/charts/polartest/templates/NOTES.txt new file mode 100644 index 0000000000..9c2c978de0 --- /dev/null +++ b/charts/physims/charts/polartest/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-polartest.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-polartest.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-polartest.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-polartest.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/polartest/templates/_helpers.tpl b/charts/physims/charts/polartest/templates/_helpers.tpl new file mode 100644 index 0000000000..ce81dbe525 --- /dev/null +++ b/charts/physims/charts/polartest/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-polartest.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-polartest.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-polartest.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-polartest.labels" -}} +helm.sh/chart: {{ include "oai-polartest.chart" . }} +{{ include "oai-polartest.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-polartest.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-polartest.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-polartest.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-polartest.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/polartest/templates/deployment.yaml b/charts/physims/charts/polartest/templates/deployment.yaml new file mode 100644 index 0000000000..01a6efc815 --- /dev/null +++ b/charts/physims/charts/polartest/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-polartest.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-polartest.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-polartest.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-polartest + # volumeMounts: + # - mountPath: /opt/oai-polartest/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015103" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/polartest/templates/service.yaml b/charts/physims/charts/polartest/templates/service.yaml new file mode 100644 index 0000000000..40abb6769e --- /dev/null +++ b/charts/physims/charts/polartest/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-polartest.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-polartest + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-polartest.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/polartest/values.yaml b/charts/physims/charts/polartest/values.yaml new file mode 100644 index 0000000000..496dc8afba --- /dev/null +++ b/charts/physims/charts/polartest/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-polartest. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-polartest-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/smallblocktest/Chart.yaml b/charts/physims/charts/smallblocktest/Chart.yaml new file mode 100644 index 0000000000..74092783ae --- /dev/null +++ b/charts/physims/charts/smallblocktest/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-smallblocktest +description: A Helm subchart for smallblocktest network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - smallblocktest + - RAN + - 4G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/smallblocktest/templates/NOTES.txt b/charts/physims/charts/smallblocktest/templates/NOTES.txt new file mode 100644 index 0000000000..c593dbfe22 --- /dev/null +++ b/charts/physims/charts/smallblocktest/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-smallblocktest.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-smallblocktest.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-smallblocktest.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-smallblocktest.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/smallblocktest/templates/_helpers.tpl b/charts/physims/charts/smallblocktest/templates/_helpers.tpl new file mode 100644 index 0000000000..a3c264b33e --- /dev/null +++ b/charts/physims/charts/smallblocktest/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-smallblocktest.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-smallblocktest.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-smallblocktest.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-smallblocktest.labels" -}} +helm.sh/chart: {{ include "oai-smallblocktest.chart" . }} +{{ include "oai-smallblocktest.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-smallblocktest.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-smallblocktest.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-smallblocktest.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-smallblocktest.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/smallblocktest/templates/deployment.yaml b/charts/physims/charts/smallblocktest/templates/deployment.yaml new file mode 100644 index 0000000000..3439c2597e --- /dev/null +++ b/charts/physims/charts/smallblocktest/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-smallblocktest.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-smallblocktest.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-smallblocktest.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-smallblock + # volumeMounts: + # - mountPath: /opt/oai-smallblocktest/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015107" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/smallblocktest/templates/service.yaml b/charts/physims/charts/smallblocktest/templates/service.yaml new file mode 100644 index 0000000000..d51bf21ce4 --- /dev/null +++ b/charts/physims/charts/smallblocktest/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-smallblocktest.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-smallblocktest + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-smallblocktest.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/smallblocktest/values.yaml b/charts/physims/charts/smallblocktest/values.yaml new file mode 100644 index 0000000000..9dd791265f --- /dev/null +++ b/charts/physims/charts/smallblocktest/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-smallblocktest. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-smallblocktest-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/charts/ulsim/Chart.yaml b/charts/physims/charts/ulsim/Chart.yaml new file mode 100644 index 0000000000..2311d729b4 --- /dev/null +++ b/charts/physims/charts/ulsim/Chart.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +name: oai-ulsim +description: A Helm subchart for ulsim network function + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +icon: http://www.openairinterface.org/wp-content/uploads/2015/06/cropped-oai_final_logo.png + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: v1 + +keywords: + - Physical Simulator + - ulsim + - RAN + - 4G + +sources: + - https://gitlab.eurecom.fr/oai/openairinterface5g + +maintainers: + - name: OPENAIRINTERFACE + email: contact@openairinterface.org diff --git a/charts/physims/charts/ulsim/templates/NOTES.txt b/charts/physims/charts/ulsim/templates/NOTES.txt new file mode 100644 index 0000000000..91ab3ce0b7 --- /dev/null +++ b/charts/physims/charts/ulsim/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "oai-ulsim.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "oai-ulsim.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "oai-ulsim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "oai-ulsim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/physims/charts/ulsim/templates/_helpers.tpl b/charts/physims/charts/ulsim/templates/_helpers.tpl new file mode 100644 index 0000000000..67b6500479 --- /dev/null +++ b/charts/physims/charts/ulsim/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "oai-ulsim.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "oai-ulsim.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "oai-ulsim.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "oai-ulsim.labels" -}} +helm.sh/chart: {{ include "oai-ulsim.chart" . }} +{{ include "oai-ulsim.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "oai-ulsim.selectorLabels" -}} +app.kubernetes.io/name: {{ include "oai-ulsim.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "oai-ulsim.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "oai-ulsim.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/physims/charts/ulsim/templates/deployment.yaml b/charts/physims/charts/ulsim/templates/deployment.yaml new file mode 100644 index 0000000000..e8c90dabc1 --- /dev/null +++ b/charts/physims/charts/ulsim/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-ulsim.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "oai-ulsim.selectorLabels" . | nindent 6 }} + strategy: + type: Recreate + template: + metadata: + labels: + {{- include "oai-ulsim.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: physim + image: "{{ .Values.global.image.repository }}:{{ .Values.global.image.version }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - containerPort: 80 + name: oai-ulsim + # volumeMounts: + # - mountPath: /opt/oai-ulsim/certs + # name: certs + command: ["/bin/sh", "-c"] + args: + - > + export OPENAIR_DIR=/opt/oai-physim && + cd cmake_targets/autotests && + ./run_exec_autotests.bash -g "015101" -q -np -b && + echo "FINISHED" && + sleep infinity + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + serviceAccountName: {{ .Values.global.serviceAccountName }} + terminationGracePeriodSeconds: 30 diff --git a/charts/physims/charts/ulsim/templates/service.yaml b/charts/physims/charts/ulsim/templates/service.yaml new file mode 100644 index 0000000000..dcc37d6299 --- /dev/null +++ b/charts/physims/charts/ulsim/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }} + labels: + {{- include "oai-ulsim.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} +{{- if contains "ClusterIP" .Values.service.type }} + clusterIP: None +{{- end }} + ports: + - name: oai-ulsim + # Port accessible outside cluster + port: {{ .Values.service.port }} + # Port to forward to inside the pod + targetPort: {{ .Values.service.Port }} + protocol: TCP + selector: + {{- include "oai-ulsim.selectorLabels" . | nindent 4 }} diff --git a/charts/physims/charts/ulsim/values.yaml b/charts/physims/charts/ulsim/values.yaml new file mode 100644 index 0000000000..f5110989d8 --- /dev/null +++ b/charts/physims/charts/ulsim/values.yaml @@ -0,0 +1,63 @@ +# Default values for oai-ulsim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +namespace: "oaicicd-ran-tmp" + +image: + registry: local + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: temp + # pullPolicy: IfNotPresent or Never or Always + pullPolicy: Always + +imagePullSecrets: [] + +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "oai-ulsim-sa" + +podSecurityContext: + runAsUser: 0 + runAsGroup: 0 + +securityContext: + privileged: true + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/physims/templates/rbac.yaml b/charts/physims/templates/rbac.yaml new file mode 100644 index 0000000000..35f956a203 --- /dev/null +++ b/charts/physims/templates/rbac.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: {{ .Chart.Name }}-{{ .Values.global.namespace }}-rbac +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- kind: ServiceAccount + name: {{ .Values.global.serviceAccountName }} + namespace: {{ .Values.global.namespace }} diff --git a/charts/physims/templates/serviceaccount.yaml b/charts/physims/templates/serviceaccount.yaml new file mode 100644 index 0000000000..21d094ad38 --- /dev/null +++ b/charts/physims/templates/serviceaccount.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.global.serviceAccountName }} diff --git a/charts/physims/values.yaml b/charts/physims/values.yaml new file mode 100644 index 0000000000..b348e822bb --- /dev/null +++ b/charts/physims/values.yaml @@ -0,0 +1,84 @@ +# Default values for oai-physim. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + serviceAccountName: oai-physim-sa + namespace: "oaicicd-ran-tmp" + image: + repository: image-registry.openshift-image-registry.svc:5000/oaicicd-ran-tmp/oai-physim + version: TAG + +## Declaring values specific to coressponding physim to overwrite + +dlsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +ulsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +ldpctest: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +polartest: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +nr-pbchsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +nr-dlsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +nr-dlschsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +smallblocktest: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +nr-ulschsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +nr-pucchsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +nr-ulsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 + +nr-prachsim: + replicaCount: 1 + service: + type: ClusterIP + port: 80 diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index dd9dba2e66..a4d7a4bf92 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -176,6 +176,30 @@ pipeline { } } } + stage ("Image Test Processes") { + parallel { + stage ("Physical Simulators") { + when { expression {doMandatoryTests} } + steps { + script { + triggerSlaveJob ('RAN-PhySim-Cluster', 'Test-Physim-Cluster') + } + } + post { + always { + script { + finalizeSlaveJob('RAN-PhySim-Cluster') + } + } + failure { + script { + currentBuild.result = 'FAILURE' + } + } + } + } + } + } } post { always { diff --git a/ci-scripts/Jenkinsfile-gitlab b/ci-scripts/Jenkinsfile-gitlab index bb78a21ca0..576ae7b055 100644 --- a/ci-scripts/Jenkinsfile-gitlab +++ b/ci-scripts/Jenkinsfile-gitlab @@ -30,8 +30,6 @@ def sendSocialMediaMessage(pipeChannel, pipeColor, pipeMessage) { } } -def doFlexranCtrlTest = false - // Location of the executor node def nodeExecutor = params.nodeExecutor @@ -66,9 +64,6 @@ pipeline { echo "Platform is ${env.TESTPLATFORM_OWNER}" } - if (params.FlexRanRtcGitLabRepository_Credentials != null) { - doFlexranCtrlTest = true - } if (fileExists("flexran")) { sh "rm -Rf flexran > /dev/null 2>&1" } @@ -141,15 +136,13 @@ pipeline { // For the moment, there is no fail criteria. Just a notification of number of files that do not follow sh "./ci-scripts/checkCodingFormattingRules.sh" } - if (doFlexranCtrlTest && doMandatoryTests) { + // With Mosaic 5G being part of OSA and making all it's repositories public + // No need to pass credentials to clone flexran-rtc + if (doMandatoryTests) { sh "mkdir flexran" dir ('flexran') { - withCredentials([ - [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.FlexRanRtcGitLabRepository_Credentials}", usernameVariable: 'git_username', passwordVariable: 'git_password'] - ]) { - sh "git clone https://${git_username}:${git_password}@gitlab.eurecom.fr/flexran/flexran-rtc.git . > ../git_clone.log 2>&1" - sh "git checkout develop >> ../git_clone.log 2>&1" - } + sh "git clone https://gitlab.eurecom.fr/flexran/flexran-rtc.git . > ../git_clone.log 2>&1" + sh "git checkout develop >> ../git_clone.log 2>&1" sh "zip -r -qq flexran.zip ." } } @@ -196,16 +189,6 @@ pipeline { } } - stage ("Start VM -- phy-sim") { - steps { - lock (vmResource) { - timeout (time: 5, unit: 'MINUTES') { - sh "./ci-scripts/oai-ci-vm-tool build --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --daemon" - } - } - } - } - stage ("Start VM -- enb-ethernet") { steps { lock (vmResource) { @@ -255,15 +238,6 @@ pipeline { } } } - stage ("Build physical simulators") { - steps { - gitlabCommitStatus(name: "Build phy-sim") { - timeout (time: 45, unit: 'MINUTES') { - sh "./ci-scripts/oai-ci-vm-tool wait --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID} --keep-vm-alive" - } - } - } - } stage ("Build eNB-ethernet") { steps { gitlabCommitStatus(name: "Build eNB-ethernet") { @@ -296,9 +270,9 @@ pipeline { script { dir ('archives') { if (fileExists('red_hat')) { - sh "zip -r -qq vm_build_logs.zip basic_sim phy_sim enb_eth ue_eth gnb_usrp nr_ue_usrp red_hat" + sh "zip -r -qq vm_build_logs.zip basic_sim enb_eth ue_eth gnb_usrp nr_ue_usrp red_hat" } else { - sh "zip -r -qq vm_build_logs.zip basic_sim phy_sim enb_eth ue_eth gnb_usrp nr_ue_usrp" + sh "zip -r -qq vm_build_logs.zip basic_sim enb_eth ue_eth gnb_usrp nr_ue_usrp" } } if(fileExists('archives/vm_build_logs.zip')) { @@ -332,29 +306,9 @@ pipeline { parallel { stage ("VM-based tests") { stages { - stage ("Test physical simulators") { - when { - expression {doMandatoryTests} - } - steps { - lock (vmResource) { - script { - timeout (time: 90, unit: 'MINUTES') { - try { - gitlabCommitStatus(name: "Test phy-sim") { - sh "./ci-scripts/oai-ci-vm-tool test --workspace $WORKSPACE --variant phy-sim --job-name ${JOB_NAME} --build-id ${BUILD_ID}" - } - } catch (Exception e) { - currentBuild.result = 'FAILURE' - } - } - } - } - } - } stage ("Build Flexran Controller") { when { - expression {doFlexranCtrlTest && doMandatoryTests} + expression {doMandatoryTests} } steps { lock (vmResource) { @@ -716,7 +670,7 @@ pipeline { script { if (doMandatoryTests) { dir ('archives') { - sh "if [ -d basic_sim/test ] || [ -d phy_sim/test ] || [ -d l2_sim/test ]; then zip -r -qq vm_tests_logs.zip */test ; fi" + sh "if [ -d basic_sim/test ] || [ -d rf_sim/test ] || [ -d l2_sim/test ]; then zip -r -qq vm_tests_logs.zip */test ; fi" } if(fileExists('archives/vm_tests_logs.zip')) { archiveArtifacts artifacts: 'archives/vm_tests_logs.zip' diff --git a/ci-scripts/Jenkinsfile-physim-deploy b/ci-scripts/Jenkinsfile-physim-deploy new file mode 100644 index 0000000000..eac572e6cd --- /dev/null +++ b/ci-scripts/Jenkinsfile-physim-deploy @@ -0,0 +1,233 @@ +#!/bin/groovy +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +// Location of the executor node +def pythonExecutor = params.pythonExecutor + +// Location of the test XML file to be run +def testXMLFile = params.pythonTestXmlFile +def mainPythonAllXmlFiles = "" +def buildStageStatus = true + +// Name of the test stage +def testStageName = params.pipelineTestStageName + +// Name of the resource +def ciEpcResource = params.epcResource + +// Global Parameters. Normally they should be populated when the master job +// triggers the slave job with parameters +def eNB_Repository +def eNB_Branch +def eNB_CommitID +def eNB_AllowMergeRequestProcess = false +def eNB_TargetBranch + +// Flags +def scmEvent = false +def upstreamEvent = false + +//------------------------------------------------------------------------------- +// Pipeline start +pipeline { + agent { + label pythonExecutor + } + options { + disableConcurrentBuilds() + timestamps() + ansiColor('xterm') + lock(ciEpcResource) + } + + stages { + stage ('Verify Parameters') { + steps { + script { + echo '\u2705 \u001B[32mVerify Parameters\u001B[0m' + + JOB_TIMESTAMP = sh returnStdout: true, script: 'date --utc --rfc-3339=seconds | sed -e "s#+00:00##"' + JOB_TIMESTAMP = JOB_TIMESTAMP.trim() + + def allParametersPresent = true + + // It is already to late to check it + if (params.pythonExecutor != null) { + echo "eNB CI executor node : ${pythonExecutor}" + } + // If not present picking a default Stage Name + if (params.pipelineTestStageName == null) { + // picking default + testStageName = 'Template Test Stage' + } + + if (params.smartphonesResource == null) { + allParametersPresent = false + } + if (params.eNB_IPAddress == null) { + allParametersPresent = false + } + if (params.eNB_SourceCodePath == null) { + allParametersPresent = false + } + if (params.eNB_Credentials == null) { + allParametersPresent = false + } + // the following 4 parameters should be pushed by the master trigger + // if not present, take the job GIT variables (used for developing) + if (params.eNB_Repository == null) { + eNB_Repository = env.GIT_URL + } else { + eNB_Repository = params.eNB_Repository + } + echo "eNB_Repository : ${eNB_Repository}" + if (params.eNB_Branch == null) { + eNB_Branch = env.GIT_BRANCH + } else { + eNB_Branch = params.eNB_Branch + } + echo "eNB_Branch : ${eNB_Branch}" + if (params.eNB_CommitID == null) { + eNB_CommitID = env.GIT_COMMIT + } else { + eNB_CommitID = params.eNB_CommitID + } + echo "eNB_CommitID : ${eNB_CommitID}" + if (params.eNB_mergeRequest != null) { + eNB_AllowMergeRequestProcess = params.eNB_mergeRequest + if (eNB_AllowMergeRequestProcess) { + if (params.eNB_TargetBranch != null) { + eNB_TargetBranch = params.eNB_TargetBranch + } else { + eNB_TargetBranch = 'develop' + } + echo "eNB_TargetBranch : ${eNB_TargetBranch}" + } + } + + if (params.EPC_IPAddress == null) { + allParametersPresent = false + } + if (params.EPC_Type == null) { + allParametersPresent = false + } + if (params.EPC_SourceCodePath == null) { + allParametersPresent = false + } + if (params.EPC_Credentials == null) { + allParametersPresent = false + } + + if (params.ADB_IPAddress == null) { + allParametersPresent = false + } + if (params.ADB_Credentials == null) { + allParametersPresent = false + } + if (params.OC_Credentials == null) { + allParametersPresent = false + } + if (params.OC_ProjectName == null) { + allParametersPresent = false + } + if (allParametersPresent) { + echo "All parameters are present" + if (eNB_AllowMergeRequestProcess) { + sh "git fetch" + sh "./ci-scripts/doGitLabMerge.sh --src-branch ${eNB_Branch} --src-commit ${eNB_CommitID} --target-branch ${eNB_TargetBranch} --target-commit latest" + } else { + sh "git fetch" + sh "git checkout -f ${eNB_CommitID}" + } + } else { + echo "Some parameters are missing" + sh "./ci-scripts/fail.sh" + } + } + } + } + + stage ("Deploy and Test") { + steps { + script { + dir ('ci-scripts') { + echo "\u2705 \u001B[32m${testStageName}\u001B[0m" + // If not present picking a default XML file + if (params.pythonTestXmlFile == null) { + // picking default + testXMLFile = 'xml_files/enb_usrpB210_band7_50PRB.xml' + echo "Test XML file(default): ${testXMLFile}" + mainPythonAllXmlFiles += "--XMLTestFile=" + testXMLFile + " " + } else { + String[] myXmlTestSuite = testXMLFile.split("\\r?\\n") + for (xmlFile in myXmlTestSuite) { + if (fileExists(xmlFile)) { + mainPythonAllXmlFiles += "--XMLTestFile=" + xmlFile + " " + echo "Test XML file : ${xmlFile}" + } + } + } + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.OC_Credentials}", usernameVariable: 'OC_Username', passwordVariable: 'OC_Password'] + ]) { + sh "python3 main.py --mode=InitiateHtml --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} ${mainPythonAllXmlFiles}" + String[] myXmlTestSuite = testXMLFile.split("\\r?\\n") + for (xmlFile in myXmlTestSuite) { + if (fileExists(xmlFile)) { + try { + sh "python3 main.py --mode=TesteNB --eNBIPAddress=${params.eNB_IPAddress} --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --EPCIPAddress=${params.EPC_IPAddress} --EPCType=${params.EPC_Type} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --XMLTestFile=${xmlFile} --OCUserName=${OC_Username} --OCPassword=${OC_Password} --OCProjectName=${OC_ProjectName}" + } catch (Exception e) { + currentBuild.result = 'FAILURE' + buildStageStatus = false + } + } + } + sh "python3 main.py --mode=FinalizeHtml --finalStatus=${buildStageStatus} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password}" + } + } + } + } + } + stage ("Log Collection") { + steps { + script { + dir ('ci-scripts') { + // Zipping all archived log files + sh "zip -r -qq physim_deploytest_logs_${env.BUILD_ID}.zip physim_test_logs_*/*" + sh "rm -rf physim_test_logs_*/" + if (fileExists("physim_deploytest_logs_${env.BUILD_ID}.zip")) { + archiveArtifacts artifacts: "physim_deploytest_logs_${env.BUILD_ID}.zip" + } + if (fileExists("test_results.html")) { + sh "mv test_results.html test_results-${env.JOB_NAME}.html" + sh "sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's@build #TEMPLATE_BUILD_ID@build #${BUILD_ID}@' -e 's#Build-ID: TEMPLATE_BUILD_ID#Build-ID: ${BUILD_ID}#' -e 's#TEMPLATE_STAGE_NAME#${testStageName}#' test_results-${JOB_NAME}.html" + archiveArtifacts artifacts: "test_results-${env.JOB_NAME}.html" + } + } + } + } + } + } +} diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-benetel-long b/ci-scripts/Jenkinsfile-tmp-multi-enb-benetel-long new file mode 100644 index 0000000000..fb7f3738d2 --- /dev/null +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-benetel-long @@ -0,0 +1,304 @@ +#!/bin/groovy +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +// Template Jenkins Declarative Pipeline script to run Test w/ RF HW + +// Location of the python executor node shall be in the same subnet as the others servers +def pythonExecutor = params.pythonExecutor + +// Location of the test XML file to be run +def testXMLFile = params.pythonTestXmlFile +def mainPythonAllXmlFiles = "" +def buildStageStatus = true + +// Name of the test stage +def testStageName = params.pipelineTestStageName + +// Name of the phone resource +def ciSmartPhonesResource1 = params.SmartPhonesResource1 +def ciSmartPhonesResource2 = params.SmartPhonesResource2 + +// Global Parameters. Populated when the master job +// triggers the slave job with parameters +def eNB_Repository = "https://gitlab.eurecom.fr/oai/openairinterface5g.git" +def eNB_Branch = "develop" +def eNB_CommitID +def eNB_AllowMergeRequestProcess = false +def eNB_TargetBranch = "develop" +def eNB_MR = "develop" + +pipeline { + agent { + label pythonExecutor + } + options { + disableConcurrentBuilds() + ansiColor('xterm') + lock(extra: [[resource: ciSmartPhonesResource2]], resource: ciSmartPhonesResource1) + } + stages { + stage("Build Init") { + steps { + script { + //retrieve latest commit ID from branch + latest_commit_from_branch= sh returnStdout: true, script: 'git log -1 origin/${eNB_Branch} | grep commit' + echo "Branch ${eNB_Branch}" + echo "${latest_commit_from_branch}" + tmp=latest_commit_from_branch.split() + echo "${tmp}" + eNB_CommitID = tmp[1] + echo "eNB_CommitID ${eNB_CommitID}" + // update the build name and description + buildName "${params.eNB_MR}" + buildDescription "Commit : ${eNB_CommitID}" + } + } + } + stage ("Verify Parameters") { + steps { + script { + echo '\u2705 \u001B[32mVerify Parameters\u001B[0m' + def allParametersPresent = true + + // It is already to late to check it + if (params.pythonExecutor != null) { + echo "eNB CI executor node : ${pythonExecutor}" + } + // If not present picking a default Stage Name + if (params.pipelineTestStageName == null) { + // picking default + testStageName = 'Template Test Stage' + } + + if (params.SmartPhonesResource1 == null) { + allParametersPresent = false + } + if (params.SmartPhonesResource2 == null) { + allParametersPresent = false + } + // 1st eNB parameters + if (params.eNB_IPAddress == null) { + allParametersPresent = false + } + if (params.eNB_SourceCodePath == null) { + allParametersPresent = false + } + if (params.eNB_Credentials == null) { + allParametersPresent = false + } + // 2nd eNB parameters + if (params.eNB1_IPAddress == null) { + allParametersPresent = false + } + if (params.eNB1_SourceCodePath == null) { + allParametersPresent = false + } + if (params.eNB1_Credentials == null) { + allParametersPresent = false + } + // 3rd eNB parameters + if (params.eNB2_IPAddress == null) { + allParametersPresent = false + } + if (params.eNB2_SourceCodePath == null) { + allParametersPresent = false + } + if (params.eNB2_Credentials == null) { + allParametersPresent = false + } + // the following 4 parameters should be pushed by the master trigger + // if not present, take the job GIT variables (used for developing) + if (params.eNB_Repository == null) { + eNB_Repository = env.GIT_URL + } else { + eNB_Repository = params.eNB_Repository + } + echo "eNB_Repository : ${eNB_Repository}" + if (params.eNB_Branch == null) { + eNB_Branch = env.GIT_BRANCH + } else { + eNB_Branch = params.eNB_Branch + } + echo "eNB_Branch : ${eNB_Branch}" + //if (params.eNB_CommitID == null) { + // eNB_CommitID = env.GIT_COMMIT + //} else { + // eNB_CommitID = params.eNB_CommitID + //} + echo "eNB_CommitID : ${eNB_CommitID}" + if (params.eNB_AllowMergeRequestProcess!= null) { + eNB_AllowMergeRequestProcess = params.eNB_AllowMergeRequestProcess + if (eNB_AllowMergeRequestProcess) { + if (params.eNB_TargetBranch != null) { + eNB_TargetBranch = params.eNB_TargetBranch + } else { + eNB_TargetBranch = 'develop' + } + echo "eNB_TargetBranch : ${eNB_TargetBranch}" + } + } + + if (params.EPC_IPAddress == null) { + allParametersPresent = false + } + if (params.EPC_Type == null) { + allParametersPresent = false + } + if (params.EPC_SourceCodePath == null) { + allParametersPresent = false + } + if (params.EPC_Credentials == null) { + allParametersPresent = false + } + + if (params.ADB_IPAddress == null) { + allParametersPresent = false + } + if (params.ADB_Credentials == null) { + allParametersPresent = false + } + + if (allParametersPresent) { + echo "All parameters are present" + if (eNB_AllowMergeRequestProcess) { + sh "git fetch" + sh "./ci-scripts/doGitLabMerge.sh --src-branch ${eNB_Branch} --src-commit ${eNB_CommitID} --target-branch ${eNB_TargetBranch} --target-commit latest" + } else { + sh "git fetch" + sh "git checkout -f ${eNB_CommitID}" + } + } else { + echo "Some parameters are missing" + sh "./ci-scripts/fail.sh" + } + } + } + } + stage ("Build and Test") { + steps { + script { + dir ('ci-scripts') { + echo "\u2705 \u001B[32m${testStageName}\u001B[0m" + // If not present picking a default XML file + if (params.pythonTestXmlFile == null) { + // picking default + testXMLFile = 'xml_files/enb_usrpB210_band7_50PRB.xml' + echo "Test XML file(default): ${testXMLFile}" + mainPythonAllXmlFiles += "--XMLTestFile=" + testXMLFile + " " + } else { + String[] myXmlTestSuite = testXMLFile.split("\\r?\\n") + for (xmlFile in myXmlTestSuite) { + if (fileExists(xmlFile)) { + mainPythonAllXmlFiles += "--XMLTestFile=" + xmlFile + " " + echo "Test XML file : ${xmlFile}" + } + } + } + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB1_Credentials}", usernameVariable: 'eNB1_Username', passwordVariable: 'eNB1_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB2_Credentials}", usernameVariable: 'eNB2_Username', passwordVariable: 'eNB2_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.EPC_Credentials}", usernameVariable: 'EPC_Username', passwordVariable: 'EPC_Password'], + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.ADB_Credentials}", usernameVariable: 'ADB_Username', passwordVariable: 'ADB_Password'] + ]) { + sh "python3 main.py --mode=InitiateHtml --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} ${mainPythonAllXmlFiles}" + String[] myXmlTestSuite = testXMLFile.split("\\r?\\n") + for (xmlFile in myXmlTestSuite) { + if (fileExists(xmlFile)) { + try { + sh "python3 main.py --mode=TesteNB --ranRepository=${eNB_Repository} --ranBranch=${eNB_Branch} --ranCommitID=${eNB_CommitID} --ranAllowMerge=${eNB_AllowMergeRequestProcess} --ranTargetBranch=${eNB_TargetBranch} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath} --eNB1IPAddress=${params.eNB1_IPAddress} --eNB1UserName=${eNB1_Username} --eNB1Password=${eNB1_Password} --eNB1SourceCodePath=${params.eNB1_SourceCodePath} --eNB2IPAddress=${params.eNB2_IPAddress} --eNB2UserName=${eNB2_Username} --eNB2Password=${eNB2_Password} --eNB2SourceCodePath=${params.eNB2_SourceCodePath} --EPCIPAddress=${params.EPC_IPAddress} --EPCType=${params.EPC_Type} --EPCUserName=${EPC_Username} --EPCPassword=${EPC_Password} --EPCSourceCodePath=${params.EPC_SourceCodePath} --ADBIPAddress=${params.ADB_IPAddress} --ADBUserName=${ADB_Username} --ADBPassword=${ADB_Password} --XMLTestFile=${xmlFile}" + } catch (Exception e) { + currentBuild.result = 'FAILURE' + buildStageStatus = false + } + } + } + sh "python3 main.py --mode=FinalizeHtml --finalStatus=${buildStageStatus} --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password}" + } + } + } + } + } + stage('Log Collection') { + parallel { + stage('Log Collection (eNB - Build)') { + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (eNB - Build)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollectBuild --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}" + + echo '\u2705 \u001B[32mLog Transfer (eNB - Build)\u001B[0m' + sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/build.log.zip ./build.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("build.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "build.log.${env.BUILD_ID}.zip" + } + } + } + } + stage('Log Collection (eNB - Run)') { + steps { + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.eNB_Credentials}", usernameVariable: 'eNB_Username', passwordVariable: 'eNB_Password'] + ]) { + echo '\u2705 \u001B[32mLog Collection (eNB - Run)\u001B[0m' + sh "python3 ci-scripts/main.py --mode=LogCollecteNB --eNBIPAddress=${params.eNB_IPAddress} --eNBUserName=${eNB_Username} --eNBPassword=${eNB_Password} --eNBSourceCodePath=${params.eNB_SourceCodePath}" + + echo '\u2705 \u001B[32mLog Transfer (eNB - Run)\u001B[0m' + sh "sshpass -p \'${eNB_Password}\' scp -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 10' ${eNB_Username}@${params.eNB_IPAddress}:${eNB_SourceCodePath}/cmake_targets/enb.log.zip ./enb.log.${env.BUILD_ID}.zip || true" + } + script { + if(fileExists("enb.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "enb.log.${env.BUILD_ID}.zip" + } + if(fileExists("ci-scripts/test_results.html")) { + sh "mv ci-scripts/test_results.html test_results-${JOB_NAME}.html" + sh "sed -i -e 's#TEMPLATE_JOB_NAME#${JOB_NAME}#' -e 's@build #TEMPLATE_BUILD_ID@build #${BUILD_ID}@' -e 's#Build-ID: TEMPLATE_BUILD_ID#Build-ID: ${BUILD_ID}#' -e 's#TEMPLATE_STAGE_NAME#${testStageName}#' test_results-${JOB_NAME}.html" + archiveArtifacts "test_results-${JOB_NAME}.html" + } + } + } + } + } + } + } + + post { + always { + script { + if (params.pipelineZipsConsoleLog != null) { + if (params.pipelineZipsConsoleLog) { + echo "Archiving Jenkins console log" + sh "wget --no-check-certificate --no-proxy ${env.JENKINS_URL}/job/${env.JOB_NAME}/${env.BUILD_ID}/consoleText -O consoleText.log || true" + sh "zip -m consoleText.log.${env.BUILD_ID}.zip consoleText.log || true" + if(fileExists("consoleText.log.${env.BUILD_ID}.zip")) { + archiveArtifacts "consoleText.log.${env.BUILD_ID}.zip" + } + } + } + } + } + } +} diff --git a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa index 66d12eed33..1e4933838b 100644 --- a/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa +++ b/ci-scripts/Jenkinsfile-tmp-multi-enb-nsa @@ -33,10 +33,9 @@ def buildStageStatus = true // Name of the test stage def testStageName = params.pipelineTestStageName -// Name of the phone resource +// Name of the phone/server resource def ciSmartPhonesResource1 = params.SmartPhonesResource1 def ciSmartPhonesResource2 = params.SmartPhonesResource2 -def ciSmartPhonesResource3 = params.SmartPhonesResource3 // Global Parameters. Normally they should be populated when the master job // triggers the slave job with parameters @@ -53,7 +52,7 @@ pipeline { options { disableConcurrentBuilds() ansiColor('xterm') - lock(extra: [[resource: ciSmartPhonesResource2],[resource: ciSmartPhonesResource3]], resource: ciSmartPhonesResource1) + lock(extra: [[resource: ciSmartPhonesResource2]], resource: ciSmartPhonesResource1) } stages { stage("Build Init") { @@ -85,9 +84,6 @@ pipeline { if (params.SmartPhonesResource2 == null) { allParametersPresent = false } - if (params.SmartPhonesResource3== null) { - allParametersPresent = false - } // 1st eNB parameters if (params.eNB_IPAddress == null) { allParametersPresent = false diff --git a/ci-scripts/Jenkinsfile-trig-nsa b/ci-scripts/Jenkinsfile-trig-nsa index 3dd5ce3b50..44527a1a38 100644 --- a/ci-scripts/Jenkinsfile-trig-nsa +++ b/ci-scripts/Jenkinsfile-trig-nsa @@ -36,8 +36,8 @@ pipeline { stage ("Launcher") { steps { script { - //retrieve MR that are opened nd with tag READY_TO_BE_MERGED - MR_LIST= sh returnStdout: true, script: 'curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100&labels=READY_TO_BE_MERGED" | jq ".[].iid" || true ' + //retrieve MR that are opened nd with tag NSA + MR_LIST= sh returnStdout: true, script: 'curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100&labels=NSA" | jq ".[].iid" || true ' echo "List of selected MR:\n${MR_LIST}" def MR_ARRAY = MR_LIST.split('\n') //for every selected MR, retrieve the branch name and the latest commit @@ -48,21 +48,30 @@ pipeline { COMMIT_ID=COMMIT_ID.trim() echo "Testing NSA on : ${MR} ${SRC_BRANCH} ${COMMIT_ID}" //calling NSA sub job - build job: "RAN-CI-NSA-B210", wait : false, propagate : false, parameters: [ + build job: "RAN-NSA-Mini-Module", wait : true, propagate : false, parameters: [ string(name: 'eNB_MR', value: String.valueOf(MR)), string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) ] - //calling Benetel sub job - build job: "RAN-CI-BENETEL", wait : false, propagate : false, parameters: [ + //calling NSA long sub job + build job: "RAN-NSA-Mini-Module-Long", wait : true, propagate : false, parameters: [ string(name: 'eNB_MR', value: String.valueOf(MR)), string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) ] + //calling NSA attach/detach job + build job: "RAN-NSA-Mini-Module-Attach-Detach", wait : true, propagate : false, parameters: [ + string(name: 'eNB_MR', value: String.valueOf(MR)), + string(name: 'eNB_Branch', value: String.valueOf(SRC_BRANCH)), + string(name: 'eNB_CommitID', value: String.valueOf(COMMIT_ID)), + string(name: 'eNB_TargetBranch', value: String.valueOf(TARGET_BRANCH)), + booleanParam(name: 'eNB_AllowMergeRequestProcess', value: Boolean.valueOf(ALLOW_MERGE)) + ] + } } } diff --git a/ci-scripts/args_parse.py b/ci-scripts/args_parse.py index 288e0b4885..0ed12bfc08 100644 --- a/ci-scripts/args_parse.py +++ b/ci-scripts/args_parse.py @@ -41,7 +41,7 @@ import constants as CONST #----------------------------------------------------------- -def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): +def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM): py_param_file_present = False @@ -81,6 +81,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.ranRepository=matchReg.group(1) CONTAINERS.ranRepository=matchReg.group(1) SCA.ranRepository=matchReg.group(1) + PHYSIM.ranRepository=matchReg.group(1) elif re.match('^\-\-eNB_AllowMerge=(.+)$|^\-\-ranAllowMerge=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB_AllowMerge=(.+)$', myArgv, re.IGNORECASE) @@ -94,6 +95,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): HTML.ranAllowMerge=True CONTAINERS.ranAllowMerge=True SCA.ranAllowMerge=True + PHYSIM.ranAllowMerge=True elif re.match('^\-\-eNBBranch=(.+)$|^\-\-ranBranch=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBBranch=(.+)$', myArgv, re.IGNORECASE) @@ -105,6 +107,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.ranBranch=matchReg.group(1) CONTAINERS.ranBranch=matchReg.group(1) SCA.ranBranch=matchReg.group(1) + PHYSIM.ranBranch=matchReg.group(1) elif re.match('^\-\-eNBCommitID=(.*)$|^\-\-ranCommitID=(.*)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBCommitID=(.*)$', myArgv, re.IGNORECASE) @@ -116,6 +119,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.ranCommitID=matchReg.group(1) CONTAINERS.ranCommitID=matchReg.group(1) SCA.ranCommitID=matchReg.group(1) + PHYSIM.ranCommitID=matchReg.group(1) elif re.match('^\-\-eNBTargetBranch=(.*)$|^\-\-ranTargetBranch=(.*)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBTargetBranch=(.*)$', myArgv, re.IGNORECASE) @@ -127,6 +131,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.ranTargetBranch=matchReg.group(1) CONTAINERS.ranTargetBranch=matchReg.group(1) SCA.ranTargetBranch=matchReg.group(1) + PHYSIM.ranTargetBranch=matchReg.group(1) elif re.match('^\-\-eNBIPAddress=(.+)$|^\-\-eNB[1-2]IPAddress=(.+)$', myArgv, re.IGNORECASE): if re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNBIPAddress=(.+)$', myArgv, re.IGNORECASE) @@ -134,6 +139,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.eNBIpAddr=matchReg.group(1) CONTAINERS.eNBIPAddress=matchReg.group(1) SCA.eNBIPAddress=matchReg.group(1) + PHYSIM.eNBIPAddress=matchReg.group(1) elif re.match('^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1IPAddress=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1IPAddress=matchReg.group(1) @@ -149,6 +155,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.eNBUserName=matchReg.group(1) CONTAINERS.eNBUserName=matchReg.group(1) SCA.eNBUserName=matchReg.group(1) + PHYSIM.eNBUserName=matchReg.group(1) elif re.match('^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1UserName=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1UserName=matchReg.group(1) @@ -164,6 +171,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.eNBPassWord=matchReg.group(1) CONTAINERS.eNBPassword=matchReg.group(1) SCA.eNBPassword=matchReg.group(1) + PHYSIM.eNBPassword=matchReg.group(1) elif re.match('^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1Password=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1Password=matchReg.group(1) @@ -179,6 +187,7 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): ldpc.eNBSourceCodePath=matchReg.group(1) CONTAINERS.eNBSourceCodePath=matchReg.group(1) SCA.eNBSourceCodePath=matchReg.group(1) + PHYSIM.eNBSourceCodePath=matchReg.group(1) elif re.match('^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE): matchReg = re.match('^\-\-eNB1SourceCodePath=(.+)$', myArgv, re.IGNORECASE) RAN.eNB1SourceCodePath=matchReg.group(1) @@ -248,6 +257,15 @@ def ArgsParse(argvs,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA): finalStatus = matchReg.group(1) if ((finalStatus == 'true') or (finalStatus == 'True')): CiTestObj.finalStatus = True + elif re.match('^\-\-OCUserName=(.+)$', myArgv, re.IGNORECASE): + matchReg = re.match('^\-\-OCUserName=(.+)$', myArgv, re.IGNORECASE) + PHYSIM.OCUserName = matchReg.group(1) + elif re.match('^\-\-OCPassword=(.+)$', myArgv, re.IGNORECASE): + matchReg = re.match('^\-\-OCPassword=(.+)$', myArgv, re.IGNORECASE) + PHYSIM.OCPassword = matchReg.group(1) + elif re.match('^\-\-OCProjectName=(.+)$', myArgv, re.IGNORECASE): + matchReg = re.match('^\-\-OCProjectName=(.+)$', myArgv, re.IGNORECASE) + PHYSIM.OCProjectName = matchReg.group(1) else: HELP.GenericHelp(CONST.Version) sys.exit('Invalid Parameter: ' + myArgv) diff --git a/ci-scripts/auto_start_gnb.sh b/ci-scripts/auto_start_gnb.sh new file mode 100644 index 0000000000..86ffc66d18 --- /dev/null +++ b/ci-scripts/auto_start_gnb.sh @@ -0,0 +1,7 @@ +#!/bin/bash +while true +do + echo "gNB will be started automatically..." + sleep 1 + sudo .././cmake_targets/ran_build/build/nr-softmodem -E -O ../targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf +done diff --git a/ci-scripts/buildOnVM.sh b/ci-scripts/buildOnVM.sh index 31e9653769..f4cf3931dd 100755 --- a/ci-scripts/buildOnVM.sh +++ b/ci-scripts/buildOnVM.sh @@ -62,7 +62,7 @@ function build_on_vm { echo "ARCHIVES_LOC = $ARCHIVES_LOC" echo "BUILD_OPTIONS = $BUILD_OPTIONS" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] then echo "This VM type is no longer supported in the pipeline framework" return diff --git a/ci-scripts/build_fr1_template.yaml b/ci-scripts/build_fr1_template.yaml index 2a8f9cc6a0..02e49bc4b5 100755 --- a/ci-scripts/build_fr1_template.yaml +++ b/ci-scripts/build_fr1_template.yaml @@ -1,15 +1,15 @@ ranRepository : https://gitlab.eurecom.fr/oai/openairinterface5g.git -ranBranch : BRANCH_NAME -ranCommitID : COMMIT_ID -ranAllowMerge : 'true' +ranBranch : integration_2021_wk13_a +ranCommitID : 104aa7eed5d6702c1b9da663414079ef698da206 +ranAllowMerge : 'yes' ranTargetBranch : develop steps: - InitiateHtml,none - TesteNB,xml_files/fr1_multi_node_build.xml - TesteNB,xml_files/fr1_epc_start.xml - - TesteNB,xml_files/fr1_ran_ue_base.xml #ue toggle, nodes initialize, ue toggle, ping, nodes terminate + - TesteNB,xml_files/fr1_nsa_base_next.xml #ue toggle, nodes initialize, ue toggle, ping, nodes terminate - TesteNB,xml_files/fr1_epc_closure.xml diff --git a/ci-scripts/ci_ctl_qtel.py b/ci-scripts/ci_ctl_qtel.py new file mode 100644 index 0000000000..3785d7ee89 --- /dev/null +++ b/ci-scripts/ci_ctl_qtel.py @@ -0,0 +1,86 @@ +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Required Python Version +# Python 3.x +# +#--------------------------------------------------------------------- + +#usage example: +#sudo python3 ci_ctl_qtel.py /dev/ttyUSB2 wup +#sudo python3 ci_ctl_qtel.py /dev/ttyUSB2 detach + + +import sys +import time +import serial + + +class qtel_ctl: + #--------------- + #private methods + #--------------- + def __init__(self, usb_port_at): + self.QUECTEL_USB_PORT_AT = usb_port_at #ex : '/dev/ttyUSB2' + self.modem = serial.Serial(self.QUECTEL_USB_PORT_AT, timeout=1) + self.cmd_dict= {"wup": self.wup,"detach":self.detach}#dictionary of function pointers + + def __set_modem_state(self,ser,state): + self.__send_command(ser,"AT+CFUN={}\r".format(state)) + + def __send_command(self,ser,com): + ser.write(com.encode()) + time.sleep(0.1) + ret=[] + while ser.inWaiting()>0: + print("waiting") + msg=ser.readline() + msg=msg.decode("utf-8") + msg=msg.replace("\r","") + msg=msg.replace("\n","") + print(msg) + if msg!="": + ret.append(msg) + else: + print("msg empty") + return ret + + #-------------- + #public methods + #-------------- + def wup(self):#sending AT+CFUN=0, then AT+CFUN=1 + self.__set_modem_state(self.modem,'0') + time.sleep(3) + self.__set_modem_state(self.modem,'1') + + def detach(self):#sending AT+CFUN=0 + self.__set_modem_state(self.modem,'0') + + + + +if __name__ == "__main__": + #argv[1] : usb port + #argv[2] : qtel command (see function pointers dict "wup", "detach" etc ...) + command = sys.argv[2] + Module=qtel_ctl(sys.argv[1]) + #calling the function to be applied + Module.cmd_dict[command]() diff --git a/ci-scripts/ci_ueinfra.yaml b/ci-scripts/ci_ueinfra.yaml new file mode 100644 index 0000000000..67331fdfb2 --- /dev/null +++ b/ci-scripts/ci_ueinfra.yaml @@ -0,0 +1,32 @@ +idefix: + ID: idefix + State : enabled + Kind : quectel + Process : + Name : quectel-CM + Cmd : /home/oaicicd/quectel-CM/quectel-CM -s oai.ipv4 -4 + WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup + DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach + PLMN : 22201 + UENetwork : wwan0 + HostIPAddress : 192.168.18.188 + HostUsername : oaicicd + HostPassword : oaicicd + HostSourceCodePath : none +dummy: + ID: '' + State : '' + Kind : '' + Process : + Name : '' + Cmd : '' + WakeupScript : '' + DetachScript : '' + PLMN : 22201 + UENetwork : wwan0 + HostIPAddress : 192.168.18.188 + HostUsername : oaicicd + HostPassword : oaicicd + HostSourceCodePath : none + + diff --git a/ci-scripts/cls_ci_ueinfra.py b/ci-scripts/cls_ci_ueinfra.py new file mode 100644 index 0000000000..0326a92a4f --- /dev/null +++ b/ci-scripts/cls_ci_ueinfra.py @@ -0,0 +1,57 @@ +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Required Python Version +# Python 3.x +# +#--------------------------------------------------------------------- + +#to use isfile +import os +import sys +import logging +#to create a SSH object locally in the methods +import sshconnection +#time.sleep +import time +#to load ue infrastructure dictionary +import yaml + +class InfraUE: + def __init__(self): + self.ci_ue_infra ={} + + +#-----------------$ +#PUBLIC Methods$ +#-----------------$ + + #This method reads the yaml file describing the multi-UE infrastructure + #and stores the infra permanently in the related class attribute self.ci_ue_infra + def Get_UE_Infra(self,ue_infra_filename): + f_yaml=ue_infra_filename + with open(f_yaml,'r') as file: + logging.debug('Loading UE infrastructure from file '+f_yaml) + #load it permanently in the class attribute + self.ci_ue_infra = yaml.load(file,Loader=yaml.FullLoader) + + + diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index e5011dcd46..f32e8b3864 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -88,6 +88,7 @@ class Containerize(): self.host = '' self.allImagesSize = {} self.collectInfo = {} + #----------------------------------------------------------- # Container management functions #----------------------------------------------------------- @@ -149,6 +150,8 @@ class Containerize(): imageNames.append(('oai-nr-ue', 'nrUE')) if self.host == 'Red Hat': imageNames.append(('oai-physim', 'phySim')) + if self.host == 'Ubuntu': + imageNames.append(('oai-lte-ru', 'lteRU')) if len(imageNames) == 0: imageNames.append(('oai-enb', 'eNB')) @@ -161,7 +164,7 @@ class Containerize(): # on RedHat/CentOS .git extension is mandatory result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) if result is not None: - full_ran_repo_name = self.ranRepository + full_ran_repo_name = self.ranRepository.replace('git/', 'git') else: full_ran_repo_name = self.ranRepository + '.git' mySSH.command('mkdir -p ' + lSourcePath, '\$', 5) @@ -175,7 +178,7 @@ class Containerize(): mySSH.command('mkdir -p cmake_targets/log', '\$', 5) # if the commit ID is provided use it to point to it if self.ranCommitID != '': - mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 5) + mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 30) # if the branch is not develop, then it is a merge request and we need to do # the potential merge. Note that merge conflicts should already been checked earlier imageTag = 'develop' @@ -335,6 +338,31 @@ class Containerize(): errorandwarnings['warnings'] = warningsNo errorandwarnings['status'] = status files[fil] = errorandwarnings + # Let analyze the target image creation part + if os.path.isfile('build_log_{}/{}.log'.format(self.testCase_id,image)): + errorandwarnings = {} + with open('build_log_{}/{}.log'.format(self.testCase_id,image), mode='r') as inputfile: + startOfTargetImageCreation = False + buildStatus = False + for line in inputfile: + result = re.search('FROM .* [aA][sS] ' + image + '$', str(line)) + if result is not None: + startOfTargetImageCreation = True + if startOfTargetImageCreation: + result = re.search('Successfully tagged ' + image + ':', str(line)) + if result is not None: + buildStatus = True + result = re.search('COMMIT ' + image + ':', str(line)) + if result is not None: + buildStatus = True + inputfile.close() + if buildStatus: + errorandwarnings['errors'] = 0 + else: + errorandwarnings['errors'] = 1 + errorandwarnings['warnings'] = 0 + errorandwarnings['status'] = buildStatus + files['Target Image Creation'] = errorandwarnings self.collectInfo[image] = files if status: diff --git a/ci-scripts/cls_log_mgt.py b/ci-scripts/cls_log_mgt.py new file mode 100644 index 0000000000..36e7d51a4b --- /dev/null +++ b/ci-scripts/cls_log_mgt.py @@ -0,0 +1,103 @@ +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Required Python Version +# Python 3.x +# +#--------------------------------------------------------------------- + +#USAGE: +# log=Log_Mgt(IPAddress,Password,Path) +# log.LogRotation() + + + + +import re +import subprocess +import logging +import math + +class Log_Mgt: + + def __init__(self,IPAddress,Password,Path): + self.IPAddress=IPAddress + self.Password=Password + self.path=Path + +#-----------------$ +#PRIVATE# Methods$ +#-----------------$ + + + def __CheckAvailSpace(self): + HOST=self.IPAddress + COMMAND="df "+ self.path + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + result = ssh.stdout.readlines() + s=result[1].decode('utf-8').rstrip()#result[1] is the second line with the results we are looking for + tmp=s.split() + return tmp[3] #return avail space from the line + + def __GetOldestFile(self): + HOST=self.IPAddress + COMMAND="ls -rtl "+ self.path #-rtl will bring oldest file on top + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + result = ssh.stdout.readlines() + s=result[1].decode('utf-8').rstrip() + tmp=s.split() + return tmp[8]#return filename from the line + + + def __AvgSize(self): + HOST=self.IPAddress + COMMAND="ls -rtl "+ self.path + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + result = ssh.stdout.readlines() + total_size=0 + for i in range(1,len(result)): + s=result[i].decode('utf-8').rstrip() + tmp=s.split() + total_size+=int(tmp[4]) #get filesize + return math.floor(total_size/(len(result)-1)) #compute average file/artifact size + + +#-----------------$ +#PUBLIC Methods$ +#-----------------$ + + + def LogRotation(self): + avail_space =int(self.__CheckAvailSpace())*1000 #avail space in target folder, initially displayed in Gb + avg_size=self.__AvgSize() #average size of artifacts in the target folder + logging.debug("Avail Space : " + str(avail_space) + " / Artifact Avg Size : " + str(avg_size)) + if avail_space < 2*avg_size: #reserved space is 2x artifact file ; oldest file will be deleted + oldestfile=self.__GetOldestFile() + HOST=self.IPAddress + COMMAND="echo " + self.Password + " | sudo -S rm "+ self.path + "/" + oldestfile + logging.debug(COMMAND) + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + else: + logging.debug("Still some space left for artifacts storage") + + + + diff --git a/ci-scripts/cls_module_ue.py b/ci-scripts/cls_module_ue.py new file mode 100644 index 0000000000..75b628fd1f --- /dev/null +++ b/ci-scripts/cls_module_ue.py @@ -0,0 +1,175 @@ +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Required Python Version +# Python 3.x +# +#--------------------------------------------------------------------- + +#to use isfile +import os +import sys +import logging +#to create a SSH object locally in the methods +import sshconnection +#time.sleep +import time + + +import re +import subprocess + +from datetime import datetime + +#for log rotation mgt +import cls_log_mgt + +class Module_UE: + + def __init__(self,Module): + #create attributes as in the Module dictionary + for k, v in Module.items(): + setattr(self, k, v) + self.UEIPAddress = "" + #dictionary linking command names and related module scripts + self.cmd_dict= {"wup": self.WakeupScript,"detach":self.DetachScript}#dictionary of function scripts + self.ue_trace='' + + + +#-----------------$ +#PUBLIC Methods$ +#-----------------$ + + #this method checks if the specified Process is running on the server hosting the module + #if not it will be started + def CheckCMProcess(self): + HOST=self.HostIPAddress + COMMAND="ps aux | grep " + self.Process['Name'] + " | grep -v grep " + logging.debug(COMMAND) + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + result = ssh.stdout.readlines() + if len(result)!=0: + logging.debug(self.Process['Name'] + " process found") + return True + else:#start process and check again + logging.debug(self.Process['Name'] + " process NOT found") + #starting the process + logging.debug('Starting ' + self.Process['Name']) + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + mySSH.command('echo $USER; echo ' + self.HostPassword + ' | nohup sudo -S ' + self.Process['Cmd'] + ' &','\$',5) + mySSH.close() + #checking the process + time.sleep(5) + HOST=self.HostIPAddress + COMMAND="ps aux | grep " + self.Process['Name'] + " | grep -v grep " + logging.debug(COMMAND) + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + result = ssh.stdout.readlines() + if len(result)!=0: + logging.debug(self.Process['Name'] + " process found") + return True + else: + logging.debug(self.Process['Name'] + " process NOT found") + return False + + #Generic command function, using function pointers dictionary + def Command(self,cmd): + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.cmd_dict[cmd],'\$',10) + time.sleep(5) + logging.debug("Module "+ cmd) + mySSH.close() + + + #this method retrieves the Module IP address (not the Host IP address) + def GetModuleIPAddress(self): + HOST=self.HostIPAddress + response= [] + tentative = 3 + while (len(response)==0) and (tentative>0): + COMMAND="ip a show dev " + self.UENetwork + " | grep inet | grep " + self.UENetwork + logging.debug(COMMAND) + ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + response = ssh.stdout.readlines() + tentative-=1 + time.sleep(10) + if (tentative==0) and (len(response)==0): + logging.debug('\u001B[1;37;41m Module IP Address Not Found! Time expired \u001B[0m') + return -1 + else: #check response + result = re.search('inet (?P[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', response[0].decode("utf-8") ) + if result is not None: + if result.group('moduleipaddress') is not None: + self.UEIPAddress = result.group('moduleipaddress') + logging.debug('\u001B[1mUE Module IP Address is ' + self.UEIPAddress + '\u001B[0m') + return 0 + else: + logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m') + return -1 + else: + logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m') + return -1 + + def EnableTrace(self): + if self.ue_trace=="yes": + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + #delete old artifacts + mySSH.command('echo ' + self.HostPassword + ' | sudo -S rm -rf ci_qlog','\$',5) + #start Trace, artifact is created in home dir + mySSH.command('echo $USER; nohup sudo -E QLog/QLog -s ci_qlog -f NR5G.cfg &','\$', 5) + mySSH.close() + + def DisableTrace(self): + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + mySSH.command('echo ' + self.HostPassword + ' | sudo -S killall --signal=SIGINT *QLog*', '\$',5) + mySSH.close() + + + def DisableCM(self): + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + mySSH.command('echo ' + self.HostPassword + ' | sudo -S killall --signal SIGKILL *'+self.Process['Name']+'*', '\$', 5) + mySSH.close() + + + def LogCollect(self): + if self.ue_trace=="yes": + mySSH = sshconnection.SSHConnection() + mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) + #archive qlog to USB stick in /media/usb-drive/ci_qlogs with datetime suffix + now=datetime.now() + now_string = now.strftime("%Y%m%d-%H%M") + source='ci_qlog' + destination='/media/usb-drive/ci_qlogs/ci_qlog_'+now_string+'.zip' + #qlog artifact is zipped into the target folder + mySSH.command('echo $USER; echo ' + self.HostPassword + ' | nohup sudo -S zip -r '+destination+' '+source+' &','\$', 10) + mySSH.close() + #post action : log cleaning to make sure enough space is reserved for the next run + Log_Mgt=cls_log_mgt.Log_Mgt(self.HostIPAddress, self.HostPassword, "/media/usb-drive/ci_qlogs") + Log_Mgt.LogRotation() + else: + destination="" + return destination diff --git a/ci-scripts/cls_oaicitest.py b/ci-scripts/cls_oaicitest.py index 7da829b7f7..377592781d 100644 --- a/ci-scripts/cls_oaicitest.py +++ b/ci-scripts/cls_oaicitest.py @@ -54,7 +54,8 @@ import helpreadme as HELP import constants as CONST import sshconnection - +import cls_module_ue +import cls_ci_ueinfra #class defining the multi Ue infrastrucure #----------------------------------------------------------- @@ -129,6 +130,7 @@ class OaiCiTest(): self.iperf_packetloss_threshold = '' self.iperf_profile = '' self.iperf_options = '' + self.iperf_direction = '' self.nbMaxUEtoAttach = -1 self.UEDevices = [] self.UEDevicesStatus = [] @@ -157,6 +159,8 @@ class OaiCiTest(): self.clean_repository = True self.air_interface='' self.expectedNbOfConnectedUEs = 0 + self.ue_id = '' #used for module identification + self.ue_trace ='' #used to enable QLog trace for Module UE, passed to Module UE object at InitializeUE() def BuildOAIUE(self,HTML): @@ -174,7 +178,7 @@ class OaiCiTest(): ue_prefix = '' result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) if result is not None: - full_ran_repo_name = self.ranRepository + full_ran_repo_name = self.ranRepository.replace('git/', 'git') else: full_ran_repo_name = self.ranRepository + '.git' SSH.command('mkdir -p ' + self.UESourceCodePath, '\$', 5) @@ -217,7 +221,7 @@ class OaiCiTest(): # if the commit ID is provided use it to point to it if self.ranCommitID != '': - SSH.command('git checkout -f ' + self.ranCommitID, '\$', 5) + SSH.command('git checkout -f ' + self.ranCommitID, '\$', 30) # if the branch is not develop, then it is a merge request and we need to do # the potential merge. Note that merge conflicts should already been checked earlier if self.ranAllowMerge: @@ -364,29 +368,50 @@ class OaiCiTest(): except: os.kill(os.getppid(),signal.SIGUSR1) - def InitializeUE(self,HTML,COTS_UE): - if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - multi_jobs = [] - i = 0 - for device_id in self.UEDevices: - p = Process(target = self.InitializeUE_common, args = (device_id,i,COTS_UE,)) - p.daemon = True - p.start() - multi_jobs.append(p) - i += 1 - for job in multi_jobs: - job.join() - HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + def InitializeUE(self,HTML,RAN,EPC, COTS_UE, InfraUE,ue_trace): + if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB + if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + multi_jobs = [] + i = 0 + for device_id in self.UEDevices: + p = Process(target = self.InitializeUE_common, args = (device_id,i,COTS_UE,)) + p.daemon = True + p.start() + multi_jobs.append(p) + i += 1 + for job in multi_jobs: + job.join() + HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + else: #if an ID is specified, it is a module from the yaml infrastructure file + #RH + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.ue_trace=ue_trace + is_module=Module_UE.CheckCMProcess() + if is_module: + Module_UE.EnableTrace() + time.sleep(5) + Module_UE.Command("wup") + logging.debug("Waiting for IP address to be assigned") + time.sleep(20) + logging.debug("Retrieve IP address") + status=Module_UE.GetModuleIPAddress() + if status==0: + HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) + logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress) + else: #status==-1 failed to retrieve IP address + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + return - - - def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE): + def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE,InfraUE): if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '': HELP.GenericHelp(CONST.Version) sys.exit('Insufficient Parameter') + + if self.air_interface == 'lte-uesoftmodem': result = re.search('--no-L2-connect', str(self.Initialize_OAI_UE_args)) if result is None: @@ -403,13 +428,13 @@ class OaiCiTest(): SSH = sshconnection.SSHConnection() SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword) # b2xx_fx3_utils reset procedure - SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 60) + SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 90) result = re.search('type: b200', SSH.getBefore()) if result is not None: logging.debug('Found a B2xx device --> resetting it') SSH.command('echo ' + self.UEPassword + ' | sudo -S b2xx_fx3_utils --reset-device', '\$', 10) # Reloading FGPA bin firmware - SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 60) + SSH.command('echo ' + self.UEPassword + ' | sudo -S uhd_find_devices', '\$', 90) result = re.search('type: n3xx', str(SSH.getBefore())) if result is not None: logging.debug('Found a N3xx device --> resetting it') @@ -563,7 +588,7 @@ class OaiCiTest(): SSH.command('ifconfig oaitun_ue1', '\$', 4) SSH.command('ifconfig oaitun_ue1', '\$', 4) # ifconfig output is different between ubuntu 16 and ubuntu 18 - result = re.search('inet addr:1|inet 1', SSH.getBefore()) + result = re.search('inet addr:[0-9]|inet [0-9]', SSH.getBefore()) if result is not None: logging.debug('\u001B[1m oaitun_ue1 interface is mounted and configured\u001B[0m') tunnelInterfaceStatus = True @@ -605,7 +630,7 @@ class OaiCiTest(): HTML.htmlUEFailureMsg='nr-uesoftmodem did NOT synced' HTML.CreateHtmlTestRow(self.air_interface + ' ' + self.Initialize_OAI_UE_args, 'KO', CONST.OAI_UE_PROCESS_COULD_NOT_SYNC, 'OAI UE') logging.error('\033[91mInitialize OAI UE Failed! \033[0m') - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) def checkDevTTYisUnlocked(self): SSH = sshconnection.SSHConnection() @@ -683,7 +708,7 @@ class OaiCiTest(): HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) self.checkDevTTYisUnlocked() - def AttachCatM(self,HTML,RAN,COTS_UE,EPC): + def AttachCatM(self,HTML,RAN,COTS_UE,EPC,InfraUE): if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': HELP.GenericHelp(CONST.Version) sys.exit('Insufficient Parameter') @@ -756,9 +781,9 @@ class OaiCiTest(): html_cell = '
CAT-M module Attachment Failed
' html_queue.put(html_cell) HTML.CreateHtmlTestRowQueue('N/A', 'KO', 1, html_queue) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) - def PingCatM(self,HTML,RAN,EPC,COTS_UE): + def PingCatM(self,HTML,RAN,EPC,COTS_UE,InfraUE): if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '': HELP.GenericHelp(CONST.Version) sys.exit('Insufficient Parameter') @@ -767,7 +792,7 @@ class OaiCiTest(): pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) if (pStatus < 0): HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) return try: statusQueue = SimpleQueue() @@ -788,7 +813,7 @@ class OaiCiTest(): moduleIPAddr = result.group('ipaddr') else: HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) return ping_time = re.findall("-c (\d+)",str(self.ping_args)) device_id = 'catm' @@ -852,7 +877,7 @@ class OaiCiTest(): HTML.CreateHtmlTestRowQueue(self.ping_args, 'OK', 1, statusQueue) else: HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', 1, statusQueue) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) except: os.kill(os.getppid(),signal.SIGUSR1) @@ -944,64 +969,82 @@ class OaiCiTest(): except: os.kill(os.getppid(),signal.SIGUSR1) - def AttachUE(self,HTML,RAN,EPC,COTS_UE): - if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - check_eNB = True - check_OAI_UE = False - pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) - if (pStatus < 0): - HTML.CreateHtmlTestRow('N/A', 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) - return - multi_jobs = [] - status_queue = SimpleQueue() - lock = Lock() - nb_ue_to_connect = 0 - for device_id in self.UEDevices: - if (self.nbMaxUEtoAttach == -1) or (nb_ue_to_connect < self.nbMaxUEtoAttach): - self.UEDevicesStatus[nb_ue_to_connect] = CONST.UE_STATUS_ATTACHING - p = Process(target = self.AttachUE_common, args = (device_id, status_queue, lock,nb_ue_to_connect,COTS_UE,)) - p.daemon = True - p.start() - multi_jobs.append(p) - nb_ue_to_connect = nb_ue_to_connect + 1 - for job in multi_jobs: - job.join() + def AttachUE(self,HTML,RAN,EPC,COTS_UE,InfraUE): + if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB + if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + check_eNB = True + check_OAI_UE = False + pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) + if (pStatus < 0): + HTML.CreateHtmlTestRow('N/A', 'KO', pStatus) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + return + multi_jobs = [] + status_queue = SimpleQueue() + lock = Lock() + nb_ue_to_connect = 0 + for device_id in self.UEDevices: + if (self.nbMaxUEtoAttach == -1) or (nb_ue_to_connect < self.nbMaxUEtoAttach): + self.UEDevicesStatus[nb_ue_to_connect] = CONST.UE_STATUS_ATTACHING + p = Process(target = self.AttachUE_common, args = (device_id, status_queue, lock,nb_ue_to_connect,COTS_UE,)) + p.daemon = True + p.start() + multi_jobs.append(p) + nb_ue_to_connect = nb_ue_to_connect + 1 + for job in multi_jobs: + job.join() - if (status_queue.empty()): - HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ALL_PROCESSES_OK) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) - return - else: - attach_status = True - html_queue = SimpleQueue() - while (not status_queue.empty()): - count = status_queue.get() - if (count < 0): - attach_status = False - device_id = status_queue.get() - message = status_queue.get() - if (count < 0): - html_cell = '
UE (' + device_id + ')\n' + message + '
' - else: - html_cell = '
UE (' + device_id + ')\n' + message + ' in ' + str(count + 2) + ' seconds
' - html_queue.put(html_cell) - if (attach_status): - cnt = 0 - while cnt < len(self.UEDevices): - if self.UEDevicesStatus[cnt] == CONST.UE_STATUS_ATTACHING: - self.UEDevicesStatus[cnt] = CONST.UE_STATUS_ATTACHED - cnt += 1 - HTML.CreateHtmlTestRowQueue('N/A', 'OK', len(self.UEDevices), html_queue) - result = re.search('T_stdout', str(RAN.Initialize_eNB_args)) - if result is not None: - logging.debug('Waiting 5 seconds to fill up record file') - time.sleep(5) + if (status_queue.empty()): + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ALL_PROCESSES_OK) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + return else: - HTML.CreateHtmlTestRowQueue('N/A', 'KO', len(self.UEDevices), html_queue) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + attach_status = True + html_queue = SimpleQueue() + while (not status_queue.empty()): + count = status_queue.get() + if (count < 0): + attach_status = False + device_id = status_queue.get() + message = status_queue.get() + if (count < 0): + html_cell = '
UE (' + device_id + ')\n' + message + '
' + else: + html_cell = '
UE (' + device_id + ')\n' + message + ' in ' + str(count + 2) + ' seconds
' + html_queue.put(html_cell) + if (attach_status): + cnt = 0 + while cnt < len(self.UEDevices): + if self.UEDevicesStatus[cnt] == CONST.UE_STATUS_ATTACHING: + self.UEDevicesStatus[cnt] = CONST.UE_STATUS_ATTACHED + cnt += 1 + HTML.CreateHtmlTestRowQueue('N/A', 'OK', len(self.UEDevices), html_queue) + result = re.search('T_stdout', str(RAN.Initialize_eNB_args)) + if result is not None: + logging.debug('Waiting 5 seconds to fill up record file') + time.sleep(5) + else: + HTML.CreateHtmlTestRowQueue('N/A', 'KO', len(self.UEDevices), html_queue) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + + else: #if an ID is specified, it is a module from the yaml infrastructure file + #Attention, as opposed to InitializeUE, the connect manager process is not checked as it is supposed to be active already + #only 1- module wakeup, 2- check IP address + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.Command("wup") + logging.debug("Waiting for IP address to be assigned") + time.sleep(20) + logging.debug("Retrieve IP address") + status=Module_UE.GetModuleIPAddress() + if status==0: + HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) + logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress) + else: #status==-1 failed to retrieve IP address + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + return def DetachUE_common(self, device_id, idx,COTS_UE): try: @@ -1025,37 +1068,44 @@ class OaiCiTest(): except: os.kill(os.getppid(),signal.SIGUSR1) - def DetachUE(self,HTML,RAN,EPC,COTS_UE): - if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': - HELP.GenericHelp(CONST.Version) - sys.exit('Insufficient Parameter') - check_eNB = True - check_OAI_UE = False - pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) - if (pStatus < 0): - HTML.CreateHtmlTestRow('N/A', 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) - return - multi_jobs = [] - cnt = 0 - for device_id in self.UEDevices: - self.UEDevicesStatus[cnt] = CONST.UE_STATUS_DETACHING - p = Process(target = self.DetachUE_common, args = (device_id,cnt,COTS_UE,)) - p.daemon = True - p.start() - multi_jobs.append(p) - cnt += 1 - for job in multi_jobs: - job.join() - HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) - result = re.search('T_stdout', str(RAN.Initialize_eNB_args)) - if result is not None: - logging.debug('Waiting 5 seconds to fill up record file') - time.sleep(5) - cnt = 0 - while cnt < len(self.UEDevices): - self.UEDevicesStatus[cnt] = CONST.UE_STATUS_DETACHED - cnt += 1 + def DetachUE(self,HTML,RAN,EPC,COTS_UE,InfraUE): + if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB + if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + check_eNB = True + check_OAI_UE = False + pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) + if (pStatus < 0): + HTML.CreateHtmlTestRow('N/A', 'KO', pStatus) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + return + multi_jobs = [] + cnt = 0 + for device_id in self.UEDevices: + self.UEDevicesStatus[cnt] = CONST.UE_STATUS_DETACHING + p = Process(target = self.DetachUE_common, args = (device_id,cnt,COTS_UE,)) + p.daemon = True + p.start() + multi_jobs.append(p) + cnt += 1 + for job in multi_jobs: + job.join() + HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + result = re.search('T_stdout', str(RAN.Initialize_eNB_args)) + if result is not None: + logging.debug('Waiting 5 seconds to fill up record file') + time.sleep(5) + cnt = 0 + while cnt < len(self.UEDevices): + self.UEDevicesStatus[cnt] = CONST.UE_STATUS_DETACHED + cnt += 1 + else:#if an ID is specified, it is a module from the yaml infrastructure file + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.Command("detach") + HTML.CreateHtmlTestRow('NA', 'OK', CONST.ALL_PROCESSES_OK) + + def RebootUE_common(self, device_id): try: @@ -1303,7 +1353,7 @@ class OaiCiTest(): except: os.kill(os.getppid(),signal.SIGUSR1) - def CheckStatusUE(self,HTML,RAN,EPC,COTS_UE): + def CheckStatusUE(self,HTML,RAN,EPC,COTS_UE,InfraUE): if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': HELP.GenericHelp(CONST.Version) sys.exit('Insufficient Parameter') @@ -1350,7 +1400,7 @@ class OaiCiTest(): if (status_queue.empty()): HTML.CreateHtmlTestRow(htmlOptions, 'KO', CONST.ALL_PROCESSES_OK) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) else: check_status = True html_queue = SimpleQueue() @@ -1366,7 +1416,7 @@ class OaiCiTest(): HTML.CreateHtmlTestRowQueue(htmlOptions, 'OK', len(self.UEDevices), html_queue) else: HTML.CreateHtmlTestRowQueue(htmlOptions, 'KO', len(self.UEDevices), html_queue) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) def GetAllUEIPAddresses(self): SSH = sshconnection.SSHConnection() @@ -1437,14 +1487,20 @@ class OaiCiTest(): statusQueue.put(message) lock.release() - def Ping_common(self, lock, UE_IPAddress, device_id, statusQueue,EPC): + def Ping_common(self, lock, UE_IPAddress, device_id, statusQueue,EPC, Module_UE): try: SSH = sshconnection.SSHConnection() # Launch ping on the EPC side (true for ltebox and old open-air-cn) # But for OAI-Rel14-CUPS, we launch from python executor launchFromEpc = True + launchFromModule = False if re.match('OAI-Rel14-CUPS', EPC.Type, re.IGNORECASE): launchFromEpc = False + #if module, ping from module to EPC + if self.ue_id!='': + launchFromEpc = False + launchfromModule = True + ping_time = re.findall("-c (\d+)",str(self.ping_args)) if launchFromEpc: @@ -1462,21 +1518,34 @@ class OaiCiTest(): #copy the ping log file to have it locally for analysis (ping stats) SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath + '/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '.') else: - #ping log file is on the python executor - cmd = 'ping ' + self.ping_args + ' ' + UE_IPAddress + ' 2>&1 > ping_' + self.testCase_id + '_' + device_id + '.log' - message = cmd + '\n' - logging.debug(cmd) - ret = subprocess.run(cmd, shell=True) - ping_status = ret.returncode - #copy the ping log file to an other folder for log collection (source and destination are EPC) - SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password, 'ping_' + self.testCase_id + '_' + device_id + '.log', EPC.SourceCodePath + '/scripts') - #copy the ping log file to have it locally for analysis (ping stats) - logging.debug(EPC.SourceCodePath + 'ping_' + self.testCase_id + '_' + device_id + '.log') - SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath +'/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '.') + if launchfromModule == False: + #ping log file is on the python executor + cmd = 'ping ' + self.ping_args + ' ' + UE_IPAddress + ' 2>&1 > ping_' + self.testCase_id + '_' + device_id + '.log' + message = cmd + '\n' + logging.debug(cmd) + ret = subprocess.run(cmd, shell=True) + ping_status = ret.returncode + #copy the ping log file to an other folder for log collection (source and destination are EPC) + SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password, 'ping_' + self.testCase_id + '_' + device_id + '.log', EPC.SourceCodePath + '/scripts') + #copy the ping log file to have it locally for analysis (ping stats) + logging.debug(EPC.SourceCodePath + 'ping_' + self.testCase_id + '_' + device_id + '.log') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath +'/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '.') + + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + #cat is executed on EPC + SSH.command('cat ' + EPC.SourceCodePath + '/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '\$', 5) + else: #launch from Module + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + #ping from module NIC rather than IP address to make sure round trip is over the air + cmd = 'ping -I ' + Module_UE.UENetwork + ' ' + self.ping_args + ' ' + EPC.IPAddress + ' 2>&1 > ping_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',int(ping_time[0])*1.5) + #copy the ping log file to have it locally for analysis (ping stats) + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'ping_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + + #cat is executed locally + SSH.command('cat ping_' + self.testCase_id + '_' + self.ue_id + '.log', '\$', 5) + ping_status=0 - SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) - #cat is executed on EPC - SSH.command('cat ' + EPC.SourceCodePath + '/scripts/ping_' + self.testCase_id + '_' + device_id + '.log', '\$', 5) # TIMEOUT CASE if ping_status < 0: message = 'Ping with UE (' + str(UE_IPAddress) + ') crashed due to TIMEOUT!' @@ -1567,14 +1636,14 @@ class OaiCiTest(): html_queue.put(html_cell) HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', len(self.UEDevices), html_queue) - def PingNoS1(self,HTML,RAN,EPC,COTS_UE): + def PingNoS1(self,HTML,RAN,EPC,COTS_UE,InfraUE): SSH=sshconnection.SSHConnection() check_eNB = True check_OAI_UE = True pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) if (pStatus < 0): HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) return ping_from_eNB = re.search('oaitun_enb1', str(self.ping_args)) if ping_from_eNB is not None: @@ -1660,10 +1729,10 @@ class OaiCiTest(): except: os.kill(os.getppid(),signal.SIGUSR1) - def Ping(self,HTML,RAN,EPC,COTS_UE): + def Ping(self,HTML,RAN,EPC,COTS_UE, InfraUE): result = re.search('noS1', str(RAN.Initialize_eNB_args)) if result is not None: - self.PingNoS1(HTML,RAN,EPC,COTS_UE) + self.PingNoS1(HTML,RAN,EPC,COTS_UE,InfraUE) return if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '': HELP.GenericHelp(CONST.Version) @@ -1676,20 +1745,32 @@ class OaiCiTest(): pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) if (pStatus < 0): HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) - return - ueIpStatus = self.GetAllUEIPAddresses() - if (ueIpStatus < 0): - HTML.CreateHtmlTestRow(self.ping_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) return + + if self.ue_id=="": + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra['dummy']) #RH, temporary, we need a dummy Module_UE object to pass to Ping_common + ueIpStatus = self.GetAllUEIPAddresses() + if (ueIpStatus < 0): + HTML.CreateHtmlTestRow(self.ping_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + return + else: + self.UEIPAddresses=[] + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.GetModuleIPAddress() + self.UEIPAddresses.append(Module_UE.UEIPAddress) + logging.debug(self.UEIPAddresses) multi_jobs = [] i = 0 lock = Lock() status_queue = SimpleQueue() for UE_IPAddress in self.UEIPAddresses: - device_id = self.UEDevices[i] - p = Process(target = self.Ping_common, args = (lock,UE_IPAddress,device_id,status_queue,EPC,)) + if self.ue_id=="": + device_id = self.UEDevices[i] + else: + device_id = Module_UE.ID + "-" + Module_UE.Kind + p = Process(target = self.Ping_common, args = (lock,UE_IPAddress,device_id,status_queue,EPC,Module_UE,)) p.daemon = True p.start() multi_jobs.append(p) @@ -1699,7 +1780,7 @@ class OaiCiTest(): if (status_queue.empty()): HTML.CreateHtmlTestRow(self.ping_args, 'KO', CONST.ALL_PROCESSES_OK) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) else: ping_status = True html_queue = SimpleQueue() @@ -1716,7 +1797,7 @@ class OaiCiTest(): HTML.CreateHtmlTestRowQueue(self.ping_args, 'OK', len(self.UEDevices), html_queue) else: HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', len(self.UEDevices), html_queue) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) def Iperf_ComputeTime(self): result = re.search('-t (?P\d+)', str(self.iperf_args)) @@ -1864,8 +1945,8 @@ class OaiCiTest(): else: return -2 - def Iperf_analyzeV2Server(self, lock, UE_IPAddress, device_id, statusQueue, iperf_real_options): - if (not os.path.isfile('iperf_server_' + self.testCase_id + '_' + device_id + '.log')): + def Iperf_analyzeV2Server(self, lock, UE_IPAddress, device_id, statusQueue, iperf_real_options, filename,type): + if (not os.path.isfile(filename)): self.ping_iperf_wrong_exit(lock, UE_IPAddress, device_id, statusQueue, 'Could not analyze from server log') return # Computing the requested bandwidth in float @@ -1890,14 +1971,18 @@ class OaiCiTest(): req_bandwidth = '%.1f Gbits/sec' % req_bw req_bw = req_bw * 1000000000 - server_file = open('iperf_server_' + self.testCase_id + '_' + device_id + '.log', 'r') + server_file = open(filename, 'r') br_sum = 0.0 ji_sum = 0.0 pl_sum = 0 ps_sum = 0 row_idx = 0 for line in server_file.readlines(): - result = re.search('(?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(?P[0-9]+)/ +(?P[0-9]+)', str(line)) + if type==0: + result = re.search('(?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(?P[0-9]+)/ +(?P[0-9]+)', str(line)) + else: + result = re.search('^\[ \d\].+ +(?P[0-9\.]+ [KMG]bits\/sec) +(?P[0-9\.]+ ms) +(?P[0-9]+)\/(?P[0-9]+)', str(line)) + if result is not None: bitrate = result.group('bitrate') jitter = result.group('jitter') @@ -2127,12 +2212,72 @@ class OaiCiTest(): SSH.command('docker cp prod-trf-gen:/iperf-2.0.5/iperf_server_' + self.testCase_id + '_' + device_id + '.log ' + EPC.SourceCodePath + '/scripts', '\$', 5) SSH.close() SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, EPC.SourceCodePath+ '/scripts/iperf_server_' + self.testCase_id + '_' + device_id + '.log', '.') - self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, modified_options) + filename='iperf_server_' + self.testCase_id + '_' + device_id + '.log' + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, modified_options,filename,0) # in case of OAI-UE if (device_id == 'OAI-UE'): SSH.copyin(self.UEIPAddress, self.UEUserName, self.UEPassword, self.UESourceCodePath + '/cmake_targets/iperf_' + self.testCase_id + '_' + device_id + '.log', '.') SSH.copyout(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_' + self.testCase_id + '_' + device_id + '.log', EPC.SourceCodePath + '/scripts') + + def Iperf_Module(self, lock, UE_IPAddress, device_id, idx, ue_num, statusQueue,EPC, Module_UE): + SSH = sshconnection.SSHConnection() + iperf_time = self.Iperf_ComputeTime() + if self.iperf_direction=="DL": + logging.debug("Iperf for Module in DL mode detected") + #server side UE + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + cmd = 'echo $USER; nohup /opt/iperf-2.0.10/iperf -s -B ' + UE_IPAddress + ' -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + #client side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + cmd = 'iperf -c ' + UE_IPAddress + ' ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',int(iperf_time)*5.0) + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + #send for analysis + filename='iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) + + elif self.iperf_direction=="UL":#does not work at the moment + logging.debug("Iperf for Module in UL mode detected") + #server side EPC + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + cmd = 'rm iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + cmd = 'echo $USER; nohup iperf -s -u 2>&1 > iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + + #client side UE + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'rm iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + SSH.command(cmd,'\$',5) + SSH.command('/opt/iperf-2.0.10/iperf -c 192.172.0.1 ' + self.iperf_args + ' 2>&1 > iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '\$', int(iperf_time)*5.0) + + #copy the 2 resulting files locally + SSH.copyin(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword, 'iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + SSH.copyin(EPC.IPAddress, EPC.UserName, EPC.Password, 'iperf_server_' + self.testCase_id + '_' + self.ue_id + '.log', '.') + #send for analysis + filename='iperf_client_' + self.testCase_id + '_' + self.ue_id + '.log' + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, self.iperf_args,filename,1) + else : + logging.debug("Incorrect or missing IPERF direction in XML") + + SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword) + cmd = 'killall --signal=SIGKILL iperf' + SSH.command(cmd,'\$',5) + SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) + cmd = 'killall --signal=SIGKILL iperf' + SSH.command(cmd,'\$',5) + + SSH.close() + return + def Iperf_common(self, lock, UE_IPAddress, device_id, idx, ue_num, statusQueue,EPC): try: SSH = sshconnection.SSHConnection() @@ -2229,8 +2374,13 @@ class OaiCiTest(): # Launch the IPERF client on the EPC side for DL (true for ltebox and old open-air-cn # But for OAI-Rel14-CUPS, we launch from python executor launchFromEpc = True + launchFromModule = False if re.match('OAI-Rel14-CUPS', EPC.Type, re.IGNORECASE): launchFromEpc = False + #if module + if self.ue_id!='' and self.iperf : + launchFromEpc = False + launchfromModule = True # When using a docker-based deployment, IPERF client shall be launched from trf container launchFromTrfContainer = False if re.match('OAI-Rel14-Docker', EPC.Type, re.IGNORECASE): @@ -2334,7 +2484,8 @@ class OaiCiTest(): subprocess.run(cmd, shell=True) except: pass - self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, modified_options) + filename='iperf_server_' + self.testCase_id + '_' + device_id + '.log' + self.Iperf_analyzeV2Server(lock, UE_IPAddress, device_id, statusQueue, modified_options,filename,0) # in case of OAI UE: if (device_id == 'OAI-UE'): @@ -2347,7 +2498,7 @@ class OaiCiTest(): except: os.kill(os.getppid(),signal.SIGUSR1) - def IperfNoS1(self,HTML,RAN,EPC,COTS_UE): + def IperfNoS1(self,HTML,RAN,EPC,COTS_UE,InfraUE): SSH = sshconnection.SSHConnection() if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '': HELP.GenericHelp(CONST.Version) @@ -2357,7 +2508,7 @@ class OaiCiTest(): pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) if (pStatus < 0): HTML.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) return server_on_enb = re.search('-R', str(self.iperf_args)) if server_on_enb is not None: @@ -2422,7 +2573,8 @@ class OaiCiTest(): if (os.path.isfile('iperf_server_' + self.testCase_id + '.log')): os.remove('iperf_server_' + self.testCase_id + '.log') SSH.copyin(iServerIPAddr, iServerUser, iServerPasswd, '/tmp/tmp_iperf_server_' + self.testCase_id + '.log', 'iperf_server_' + self.testCase_id + '_OAI-UE.log') - self.Iperf_analyzeV2Server(lock, '10.0.1.2', 'OAI-UE', status_queue, modified_options) + filename='iperf_server_' + self.testCase_id + '_OAI-UE.log' + self.Iperf_analyzeV2Server(lock, '10.0.1.2', 'OAI-UE', status_queue, modified_options,filename,0) # copying on the EPC server for logCollection if (clientStatus == -1): @@ -2455,12 +2607,12 @@ class OaiCiTest(): HTML.CreateHtmlTestRowQueue(self.iperf_args, 'OK', len(self.UEDevices), html_queue) else: HTML.CreateHtmlTestRowQueue(self.iperf_args, 'KO', len(self.UEDevices), html_queue) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) - def Iperf(self,HTML,RAN,EPC,COTS_UE): + def Iperf(self,HTML,RAN,EPC,COTS_UE, InfraUE): result = re.search('noS1', str(RAN.Initialize_eNB_args)) if result is not None: - self.IperfNoS1(HTML,RAN,EPC,COTS_UE) + self.IperfNoS1(HTML,RAN,EPC,COTS_UE,InfraUE) return if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '' or self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': HELP.GenericHelp(CONST.Version) @@ -2473,15 +2625,24 @@ class OaiCiTest(): pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) if (pStatus < 0): HTML.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) - return - ueIpStatus = self.GetAllUEIPAddresses() - if (ueIpStatus < 0): - logging.debug('going here') - HTML.CreateHtmlTestRow(self.iperf_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) return + if self.ue_id=="":#is not a module, follow legacy code + ueIpStatus = self.GetAllUEIPAddresses() + if (ueIpStatus < 0): + HTML.CreateHtmlTestRow(self.iperf_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) + return + else: #is a module + self.UEIPAddresses=[] + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.GetModuleIPAddress() + self.UEIPAddresses.append(Module_UE.UEIPAddress) + + + + self.dummyIperfVersion = '2.0.10' #cmd = 'iperf --version' #logging.debug(cmd + '\n') @@ -2498,9 +2659,15 @@ class OaiCiTest(): ue_num = len(self.UEIPAddresses) lock = Lock() status_queue = SimpleQueue() + logging.debug(self.UEIPAddresses) for UE_IPAddress in self.UEIPAddresses: device_id = self.UEDevices[i] - p = Process(target = self.Iperf_common, args = (lock,UE_IPAddress,device_id,i,ue_num,status_queue,EPC,)) + #special quick and dirty treatment for modules, iperf to be restructured + if self.ue_id!="": #is module + device_id = Module_UE.ID + "-" + Module_UE.Kind + p = Process(target = self.Iperf_Module ,args = (lock, UE_IPAddress, device_id, i, ue_num, status_queue, EPC, Module_UE,)) + else: #legacy code + p = Process(target = self.Iperf_common, args = (lock, UE_IPAddress, device_id, i, ue_num, status_queue, EPC, )) p.daemon = True p.start() multi_jobs.append(p) @@ -2510,7 +2677,7 @@ class OaiCiTest(): if (status_queue.empty()): HTML.CreateHtmlTestRow(self.iperf_args, 'KO', CONST.ALL_PROCESSES_OK) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfaUE) else: iperf_status = True iperf_noperf = False @@ -2532,7 +2699,7 @@ class OaiCiTest(): HTML.CreateHtmlTestRowQueue(self.iperf_args, 'OK', len(self.UEDevices), html_queue) else: HTML.CreateHtmlTestRowQueue(self.iperf_args, 'KO', len(self.UEDevices), html_queue) - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) def CheckProcessExist(self, check_eNB, check_OAI_UE,RAN,EPC): multi_jobs = [] @@ -2937,22 +3104,34 @@ class OaiCiTest(): except: os.kill(os.getppid(),signal.SIGUSR1) - def TerminateUE(self,HTML,COTS_UE): - terminate_ue_flag = False - self.GetAllUEDevices(terminate_ue_flag) - multi_jobs = [] - i = 0 - for device_id in self.UEDevices: - p = Process(target= self.TerminateUE_common, args = (device_id,i,COTS_UE,)) - p.daemon = True - p.start() - multi_jobs.append(p) - i += 1 - for job in multi_jobs: - job.join() - HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + def TerminateUE(self,HTML,COTS_UE,InfraUE,ue_trace): + if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB + terminate_ue_flag = False + self.GetAllUEDevices(terminate_ue_flag) + multi_jobs = [] + i = 0 + for device_id in self.UEDevices: + p = Process(target= self.TerminateUE_common, args = (device_id,i,COTS_UE,)) + p.daemon = True + p.start() + multi_jobs.append(p) + i += 1 + for job in multi_jobs: + job.join() + HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + else: #if an ID is specified, it is a module from the yaml infrastructure file + Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) + Module_UE.ue_trace=ue_trace + Module_UE.Command("detach") + Module_UE.DisableTrace() + Module_UE.DisableCM() + archive_destination=Module_UE.LogCollect() + if Module_UE.ue_trace=='yes': + HTML.CreateHtmlTestRow('QLog at : '+archive_destination, 'OK', CONST.ALL_PROCESSES_OK) + else: + HTML.CreateHtmlTestRow('QLog trace is disabled', 'OK', CONST.ALL_PROCESSES_OK) - def TerminateOAIUE(self,HTML,RAN,COTS_UE,EPC): + def TerminateOAIUE(self,HTML,RAN,COTS_UE,EPC, InfraUE): SSH = sshconnection.SSHConnection() SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword) SSH.command('cd ' + self.UESourceCodePath + '/cmake_targets', '\$', 5) @@ -2993,11 +3172,11 @@ class OaiCiTest(): # Not an error then if (logStatus != CONST.OAI_UE_PROCESS_COULD_NOT_SYNC) or (ueAction != 'Sniffing'): self.Initialize_OAI_UE_args = '' - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) else: if (logStatus == CONST.OAI_UE_PROCESS_COULD_NOT_SYNC): self.Initialize_OAI_UE_args = '' - self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC) + self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE) else: logging.debug('\u001B[1m' + ueAction + ' Completed \u001B[0m') HTML.htmlUEFailureMsg='' + ueAction + ' Completed\n' + HTML.htmlUEFailureMsg @@ -3006,21 +3185,21 @@ class OaiCiTest(): else: HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) - def AutoTerminateUEandeNB(self,HTML,RAN,COTS_UE,EPC): + def AutoTerminateUEandeNB(self,HTML,RAN,COTS_UE,EPC,InfraUE): if (self.ADBIPAddress != 'none'): self.testCase_id = 'AUTO-KILL-UE' HTML.testCase_id=self.testCase_id self.desc = 'Automatic Termination of UE' HTML.desc='Automatic Termination of UE' self.ShowTestID() - self.TerminateUE(HTML,COTS_UE) + self.TerminateUE(HTML,COTS_UE,InfraUE,self.ue_trace) if (self.Initialize_OAI_UE_args != ''): self.testCase_id = 'AUTO-KILL-OAI-UE' HTML.testCase_id=self.testCase_id self.desc = 'Automatic Termination of OAI-UE' HTML.desc='Automatic Termination of OAI-UE' self.ShowTestID() - self.TerminateOAIUE(HTML,RAN,COTS_UE,EPC) + self.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE) if (RAN.Initialize_eNB_args != ''): self.testCase_id = 'AUTO-KILL-RAN' HTML.testCase_id=self.testCase_id @@ -3273,7 +3452,7 @@ class OaiCiTest(): UhdVersion = result.group('uhd_version') logging.debug('UHD Version is: ' + UhdVersion) HTML.UhdVersion[idx]=UhdVersion - SSH.command('echo ' + Password + ' | sudo -S uhd_find_devices', '\$', 60) + SSH.command('echo ' + Password + ' | sudo -S uhd_find_devices', '\$', 90) usrp_boards = re.findall('product: ([0-9A-Za-z]+)\\\\r\\\\n', SSH.getBefore()) count = 0 for board in usrp_boards: diff --git a/ci-scripts/cls_physim.py b/ci-scripts/cls_physim.py index 4ca36b8cf0..e825b2f7bd 100644 --- a/ci-scripts/cls_physim.py +++ b/ci-scripts/cls_physim.py @@ -1,191 +1,191 @@ -# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more -# * contributor license agreements. See the NOTICE file distributed with -# * this work for additional information regarding copyright ownership. -# * The OpenAirInterface Software Alliance licenses this file to You under -# * the OAI Public License, Version 1.1 (the "License"); you may not use this file -# * except in compliance with the License. -# * You may obtain a copy of the License at -# * -# * http://www.openairinterface.org/?page_id=698 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# *------------------------------------------------------------------------------- -# * For more information about the OpenAirInterface (OAI) Software Alliance: -# * contact@openairinterface.org -# */ -#--------------------------------------------------------------------- -# Python for CI of OAI-eNB + COTS-UE -# -# Required Python Version -# Python 3.x -# -# Required Python Package -# pexpect -#--------------------------------------------------------------------- - -#to use logging.info() -import logging -#to create a SSH object locally in the methods -import sshconnection -#to update the HTML object -import html -from multiprocessing import SimpleQueue -#for log folder maintenance -import os - -class PhySim: - def __init__(self): - self.buildargs = "" - self.runargs = "" - self.eNBIpAddr = "" - self.eNBUserName = "" - self.eNBPassWord = "" - self.eNBSourceCodePath = "" - self.ranRepository = "" - self.ranBranch = "" - self.ranCommitID= "" - self.ranAllowMerge= "" - self.ranTargetBranch= "" - self.exitStatus=0 - self.forced_workspace_cleanup=False - #private attributes - self.__workSpacePath='' - self.__buildLogFile='compile_phy_sim.log' - self.__runLogFile='' - self.__runResults=[] - self.__runLogPath='phy_sim_logs' - - -#----------------- -#PRIVATE Methods -#----------------- - - def __CheckResults_PhySim(self,HTML,CONST,testcase_id): - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - #retrieve run log file and store it locally$ - mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__runLogFile, '.') - mySSH.close() - #parse results looking for Encoding and Decoding mean values - self.__runResults=[] - with open(self.__runLogFile) as f: - for line in f: - if 'mean' in line: - self.__runResults.append(line) - #the values are appended for each mean value (2), so we take these 2 values from the list - info=self.__runResults[0]+self.__runResults[1] - - #once parsed move the local logfile to its folder for tidiness - os.system('mv '+self.__runLogFile+' '+ self.__runLogPath+'/.') - - #updating the HTML with results - html_cell = '
' + info  + '
' - html_queue=SimpleQueue() - html_queue.put(html_cell) - HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', 1, html_queue) - return HTML - - - def __CheckBuild_PhySim(self, HTML, CONST): - self.__workSpacePath=self.eNBSourceCodePath+'/cmake_targets/' - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - #retrieve compile log file and store it locally - mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__buildLogFile, '.') - #delete older run log file - mySSH.command('rm ' + self.__workSpacePath+self.__runLogFile, '\$', 5) - mySSH.close() - #check build result from local compile log file - buildStatus=False - with open(self.__buildLogFile) as f: - #nr_prachsim is the last compile step - if 'nr_prachsim compiled' in f.read(): - buildStatus=True - #update HTML based on build status - if buildStatus: - HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'LDPC') - self.exitStatus=0 - else: - logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m') - HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC') - HTML.CreateHtmlTabFooter(False) - #exitStatus=1 will do a sys.exit in main - self.exitStatus=1 - return HTML - - -#-----------------$ -#PUBLIC Methods$ -#-----------------$ - - def Build_PhySim(self,htmlObj,constObj): - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - - #create working dir - mySSH.command('mkdir -p ' + self.eNBSourceCodePath, '\$', 5) - mySSH.command('cd ' + self.eNBSourceCodePath, '\$', 5) - - if not self.ranRepository.lower().endswith('.git'): - self.ranRepository+='.git' - - #git clone - mySSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + self.ranRepository + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) - #git config - mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) - mySSH.command('git config user.name "OAI Jenkins"', '\$', 5) - - #git clean depending on self.forced_workspace_cleanup captured in xml - if self.forced_workspace_cleanup==True: - logging.info('Cleaning workspace ...') - mySSH.command('echo ' + self.eNBPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30) - else: - logging.info('Workspace cleaning was disabled') - - # if the commit ID is provided, use it to point to it - if self.ranCommitID != '': - mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 5) - # if the branch is not develop, then it is a merge request and we need to do - # the potential merge. Note that merge conflicts should have already been checked earlier - if (self.ranAllowMerge): - if self.ranTargetBranch == '': - if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'): - mySSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) - else: - logging.info('Merging with the target branch: ' + self.ranTargetBranch) - mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) - - #build - mySSH.command('source oaienv', '\$', 5) - mySSH.command('cd cmake_targets', '\$', 5) - mySSH.command('mkdir -p log', '\$', 5) - mySSH.command('chmod 777 log', '\$', 5) - mySSH.command('stdbuf -o0 ./build_oai ' + self.buildargs + ' 2>&1 | stdbuf -o0 tee ' + self.__buildLogFile, 'Bypassing the Tests|build have failed', 1500) - - mySSH.close() - #check build status and update HTML object - lHTML = html.HTMLManagement() - lHTML=self.__CheckBuild_PhySim(htmlObj,constObj) - return lHTML - - - def Run_PhySim(self,htmlObj,constObj,testcase_id): - #create run logs folder locally - os.system('mkdir -p ./'+self.__runLogPath) - #log file is tc_.log remotely - self.__runLogFile='physim_'+str(testcase_id)+'.log' - #open a session for test run - mySSH = sshconnection.SSHConnection() - mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) - mySSH.command('cd '+self.__workSpacePath,'\$',5) - #run and redirect the results to a log file - mySSH.command(self.__workSpacePath+'phy_simulators/build/ldpctest ' + self.runargs + ' >> '+self.__runLogFile, '\$', 30) - mySSH.close() - #return updated HTML to main - lHTML = html.HTMLManagement() - lHTML=self.__CheckResults_PhySim(htmlObj,constObj,testcase_id) - return lHTML +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# Python for CI of OAI-eNB + COTS-UE +# +# Required Python Version +# Python 3.x +# +# Required Python Package +# pexpect +#--------------------------------------------------------------------- + +#to use logging.info() +import logging +#to create a SSH object locally in the methods +import sshconnection +#to update the HTML object +import html +from multiprocessing import SimpleQueue +#for log folder maintenance +import os + +class PhySim: + def __init__(self): + self.buildargs = "" + self.runargs = "" + self.eNBIpAddr = "" + self.eNBUserName = "" + self.eNBPassWord = "" + self.eNBSourceCodePath = "" + self.ranRepository = "" + self.ranBranch = "" + self.ranCommitID= "" + self.ranAllowMerge= "" + self.ranTargetBranch= "" + self.exitStatus=0 + self.forced_workspace_cleanup=False + #private attributes + self.__workSpacePath='' + self.__buildLogFile='compile_phy_sim.log' + self.__runLogFile='' + self.__runResults=[] + self.__runLogPath='phy_sim_logs' + + +#----------------- +#PRIVATE Methods +#----------------- + + def __CheckResults_PhySim(self,HTML,CONST,testcase_id): + mySSH = sshconnection.SSHConnection() + mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) + #retrieve run log file and store it locally$ + mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__runLogFile, '.') + mySSH.close() + #parse results looking for Encoding and Decoding mean values + self.__runResults=[] + with open(self.__runLogFile) as f: + for line in f: + if 'mean' in line: + self.__runResults.append(line) + #the values are appended for each mean value (2), so we take these 2 values from the list + info=self.__runResults[0]+self.__runResults[1] + + #once parsed move the local logfile to its folder for tidiness + os.system('mv '+self.__runLogFile+' '+ self.__runLogPath+'/.') + + #updating the HTML with results + html_cell = '
' + info  + '
' + html_queue=SimpleQueue() + html_queue.put(html_cell) + HTML.CreateHtmlTestRowQueue(self.runargs, 'OK', 1, html_queue) + return HTML + + + def __CheckBuild_PhySim(self, HTML, CONST): + self.__workSpacePath=self.eNBSourceCodePath+'/cmake_targets/' + mySSH = sshconnection.SSHConnection() + mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) + #retrieve compile log file and store it locally + mySSH.copyin(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord, self.__workSpacePath+self.__buildLogFile, '.') + #delete older run log file + mySSH.command('rm ' + self.__workSpacePath+self.__runLogFile, '\$', 5) + mySSH.close() + #check build result from local compile log file + buildStatus=False + with open(self.__buildLogFile) as f: + #nr_prachsim is the last compile step + if 'nr_prachsim compiled' in f.read(): + buildStatus=True + #update HTML based on build status + if buildStatus: + HTML.CreateHtmlTestRow(self.buildargs, 'OK', CONST.ALL_PROCESSES_OK, 'LDPC') + self.exitStatus=0 + else: + logging.error('\u001B[1m Building Physical Simulators Failed\u001B[0m') + HTML.CreateHtmlTestRow(self.buildargs, 'KO', CONST.ALL_PROCESSES_OK, 'LDPC') + HTML.CreateHtmlTabFooter(False) + #exitStatus=1 will do a sys.exit in main + self.exitStatus=1 + return HTML + + +#-----------------$ +#PUBLIC Methods$ +#-----------------$ + + def Build_PhySim(self,htmlObj,constObj): + mySSH = sshconnection.SSHConnection() + mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) + + #create working dir + mySSH.command('mkdir -p ' + self.eNBSourceCodePath, '\$', 5) + mySSH.command('cd ' + self.eNBSourceCodePath, '\$', 5) + + if not self.ranRepository.lower().endswith('.git'): + self.ranRepository+='.git' + + #git clone + mySSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + self.ranRepository + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) + #git config + mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) + mySSH.command('git config user.name "OAI Jenkins"', '\$', 5) + + #git clean depending on self.forced_workspace_cleanup captured in xml + if self.forced_workspace_cleanup==True: + logging.info('Cleaning workspace ...') + mySSH.command('echo ' + self.eNBPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30) + else: + logging.info('Workspace cleaning was disabled') + + # if the commit ID is provided, use it to point to it + if self.ranCommitID != '': + mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 30) + # if the branch is not develop, then it is a merge request and we need to do + # the potential merge. Note that merge conflicts should have already been checked earlier + if (self.ranAllowMerge): + if self.ranTargetBranch == '': + if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'): + mySSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) + else: + logging.info('Merging with the target branch: ' + self.ranTargetBranch) + mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + + #build + mySSH.command('source oaienv', '\$', 5) + mySSH.command('cd cmake_targets', '\$', 5) + mySSH.command('mkdir -p log', '\$', 5) + mySSH.command('chmod 777 log', '\$', 5) + mySSH.command('stdbuf -o0 ./build_oai ' + self.buildargs + ' 2>&1 | stdbuf -o0 tee ' + self.__buildLogFile, 'Bypassing the Tests|build have failed', 1500) + + mySSH.close() + #check build status and update HTML object + lHTML = html.HTMLManagement() + lHTML=self.__CheckBuild_PhySim(htmlObj,constObj) + return lHTML + + + def Run_PhySim(self,htmlObj,constObj,testcase_id): + #create run logs folder locally + os.system('mkdir -p ./'+self.__runLogPath) + #log file is tc_.log remotely + self.__runLogFile='physim_'+str(testcase_id)+'.log' + #open a session for test run + mySSH = sshconnection.SSHConnection() + mySSH.open(self.eNBIpAddr, self.eNBUserName, self.eNBPassWord) + mySSH.command('cd '+self.__workSpacePath,'\$',5) + #run and redirect the results to a log file + mySSH.command(self.__workSpacePath+'phy_simulators/build/ldpctest ' + self.runargs + ' >> '+self.__runLogFile, '\$', 30) + mySSH.close() + #return updated HTML to main + lHTML = html.HTMLManagement() + lHTML=self.__CheckResults_PhySim(htmlObj,constObj,testcase_id) + return lHTML diff --git a/ci-scripts/cls_physim1.py b/ci-scripts/cls_physim1.py new file mode 100644 index 0000000000..1c82526831 --- /dev/null +++ b/ci-scripts/cls_physim1.py @@ -0,0 +1,337 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# Python for CI of OAI-eNB + COTS-UE +# +# Required Python Version +# Python 3.x +# +# Required Python Package +# pexpect +#--------------------------------------------------------------------- + +#----------------------------------------------------------- +# Import +#----------------------------------------------------------- +import logging +import sshconnection as SSH +import html +import os +import re +import time +import sys +import constants as CONST +import helpreadme as HELP + +class PhySim: + def __init__(self): + self.eNBIpAddr = "" + self.eNBUserName = "" + self.eNBPassword = "" + self.OCUserName = "" + self.OCPassword = "" + self.OCProjectName = "" + self.eNBSourceCodePath = "" + self.ranRepository = "" + self.ranBranch = "" + self.ranCommitID= "" + self.ranAllowMerge= False + self.ranTargetBranch= "" + self.testResult = {} + self.testCount = [0,0,0] + self.testSummary = {} + self.testStatus = False + +#-----------------$ +#PUBLIC Methods$ +#-----------------$ + + def Deploy_PhySim(self, HTML, RAN): + if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + lIpAddr = self.eNBIPAddress + lUserName = self.eNBUserName + lPassWord = self.eNBPassword + lSourcePath = self.eNBSourceCodePath + ocUserName = self.OCUserName + ocPassword = self.OCPassword + ocProjectName = self.OCProjectName + + if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '' or ocUserName == '' or ocPassword == '' or ocProjectName == '': + HELP.GenericHelp(CONST.Version) + sys.exit('Insufficient Parameter') + logging.debug('Building on server: ' + lIpAddr) + mySSH = SSH.SSHConnection() + mySSH.open(lIpAddr, lUserName, lPassWord) + + self.testCase_id = HTML.testCase_id + + # on RedHat/CentOS .git extension is mandatory + result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) + if result is not None: + full_ran_repo_name = self.ranRepository.replace('git/', 'git') + else: + full_ran_repo_name = self.ranRepository + '.git' + mySSH.command('echo ' + lPassWord + ' | sudo rm -Rf ' + lSourcePath, '\$', 30) + mySSH.command('mkdir -p ' + lSourcePath, '\$', 5) + mySSH.command('cd ' + lSourcePath, '\$', 5) + mySSH.command('if [ ! -e .git ]; then stdbuf -o0 git clone ' + full_ran_repo_name + ' .; else stdbuf -o0 git fetch --prune; fi', '\$', 600) + # Raphael: here add a check if git clone or git fetch went smoothly + mySSH.command('git config user.email "jenkins@openairinterface.org"', '\$', 5) + mySSH.command('git config user.name "OAI Jenkins"', '\$', 5) + + mySSH.command('echo ' + lPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30) + mySSH.command('mkdir -p cmake_targets/log', '\$', 5) + # if the commit ID is provided use it to point to it + if self.ranCommitID != '': + mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 30) + if self.ranAllowMerge: + imageTag = "ci-temp" + if self.ranTargetBranch == '': + if (self.ranBranch != 'develop') and (self.ranBranch != 'origin/develop'): + mySSH.command('git merge --ff origin/develop -m "Temporary merge for CI"', '\$', 5) + else: + logging.debug('Merging with the target branch: ' + self.ranTargetBranch) + mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + else: + imageTag = "develop" + # Check if image is exist on the Red Hat server, before pushing it to OC cluster + mySSH.command("sudo podman image inspect --format='Size = {{.Size}} bytes' oai-physim:" + imageTag, '\$', 60) + if mySSH.getBefore().count('no such image') != 0: + logging.error('\u001B[1m No such image oai-physim\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.PHYSIM_IMAGE_ABSENT) + RAN.prematureExit = True + return + else: + result = re.search('Size *= *(?P[0-9\-]+) *bytes', mySSH.getBefore()) + if result is not None: + imageSize = float(result.group('size')) + imageSize = imageSize / 1000 + if imageSize < 1000: + logging.debug('\u001B[1m oai-physim size is ' + ('%.0f' % imageSize) + ' kbytes\u001B[0m') + else: + imageSize = imageSize / 1000 + if imageSize < 1000: + logging.debug('\u001B[1m oai-physim size is ' + ('%.0f' % imageSize) + ' Mbytes\u001B[0m') + else: + imageSize = imageSize / 1000 + logging.debug('\u001B[1m oai-physim is ' + ('%.3f' % imageSize) + ' Gbytes\u001B[0m') + else: + logging.debug('oai-physim size is unknown') + + # logging to OC Cluster and then switch to corresponding project + mySSH.command(f'oc login -u {ocUserName} -p {ocPassword}', '\$', 6) + if mySSH.getBefore().count('Login successful.') == 0: + logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) + RAN.prematureExit = True + return + else: + logging.debug('\u001B[1m Login to OC Cluster Successfully\u001B[0m') + mySSH.command(f'oc project {ocProjectName}', '\$', 6) + if mySSH.getBefore().count(f'Already on project "{ocProjectName}"') == 0 and mySSH.getBefore().count(f'Now using project "{self.OCProjectName}"') == 0: + logging.error(f'\u001B[1m Unable to access OC project {ocProjectName}\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PROJECT_FAIL) + RAN.prematureExit = True + return + else: + logging.debug(f'\u001B[1m Now using project {ocProjectName}\u001B[0m') + + # Tag the image and push to the OC cluster + mySSH.command('oc whoami -t | sudo podman login -u ' + ocUserName + ' --password-stdin https://default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/ --tls-verify=false', '\$', 6) + if mySSH.getBefore().count('Login Succeeded!') == 0: + logging.error('\u001B[1m Podman Login to OC Cluster Registry Failed\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL) + RAN.prematureExit = True + return + else: + logging.debug('\u001B[1m Podman Login to OC Cluster Registry Successfully\u001B[0m') + time.sleep(2) + mySSH.command('oc create -f openshift/oai-physim-image-stream.yml', '\$', 6) + if mySSH.getBefore().count('(AlreadyExists):') == 0 and mySSH.getBefore().count('created') == 0: + logging.error(f'\u001B[1m Image Stream "oai-physim" Creation Failed on OC Cluster {ocProjectName}\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL) + RAN.prematureExit = True + return + else: + logging.debug(f'\u001B[1m Image Stream "oai-physim" created on OC project {ocProjectName}\u001B[0m') + time.sleep(2) + mySSH.command(f'sudo podman tag oai-physim:{imageTag} default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) + time.sleep(2) + mySSH.command(f'sudo podman push default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag} --tls-verify=false', '\$', 30) + if mySSH.getBefore().count('Storing signatures') == 0: + logging.error('\u001B[1m Image "oai-physim" push to OC Cluster Registry Failed\u001B[0m') + mySSH.close() + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_IS_FAIL) + RAN.prematureExit = True + return + else: + logging.debug('\u001B[1m Image "oai-physim" push to OC Cluster Registry Successfully\u001B[0m') + + # Using helm charts deployment + time.sleep(5) + mySSH.command(f'sed -i -e "s#TAG#{imageTag}#g" ./charts/physims/values.yaml', '\$', 6) + mySSH.command('helm install physim ./charts/physims/ | tee -a cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6) + if mySSH.getBefore().count('STATUS: deployed') == 0: + logging.error('\u001B[1m Deploying PhySim Failed using helm chart on OC Cluster\u001B[0m') + mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6) + isFinished1 = False + while(isFinished1 == False): + time.sleep(20) + mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True) + if re.search('No resources found', mySSH.getBefore()): + isFinished1 = True + mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) + mySSH.command('oc delete is oai-physim', '\$', 6) + mySSH.close() + self.AnalyzeLogFile_phySim(HTML) + RAN.prematureExit = True + return + else: + logging.debug('\u001B[1m Deployed PhySim Successfully using helm chart\u001B[0m') + isRunning = False + count = 0 + while(count < 2 and isRunning == False): + time.sleep(60) + mySSH.command('oc get pods -o wide -l app.kubernetes.io/instance=physim | tee -a cmake_targets/log/physim_pods_summary.txt', '\$', 6, resync=True) + if mySSH.getBefore().count('Running') == 12: + logging.debug('\u001B[1m Running the physim test Scenarios\u001B[0m') + isRunning = True + podNames = re.findall('oai-[\S\d\w]+', mySSH.getBefore()) + count +=1 + if isRunning == False: + logging.error('\u001B[1m Some PODS Running FAILED \u001B[0m') + mySSH.command('oc get pods -l app.kubernetes.io/instance=physim 2>&1 | tee -a cmake_targets/log/physim_pods_summary.txt', '\$', 6) + mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6) + self.AnalyzeLogFile_phySim(HTML) + isFinished1 = False + while(isFinished1 == False): + time.sleep(20) + mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True) + if re.search('No resources found', mySSH.getBefore()): + isFinished1 = True + mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) + mySSH.command('oc delete is oai-physim', '\$', 6) + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_PHYSIM_DEPLOY_FAIL) + HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult) + RAN.prematureExit = True + return + # Waiting to complete the running test + count = 0 + isFinished = False + # doing a deep copy! + tmpPodNames = podNames.copy() + while(count < 28 and isFinished == False): + time.sleep(60) + for podName in tmpPodNames: + mySSH.command2(f'oc logs --tail=1 {podName} 2>&1', 6, silent=True) + if mySSH.cmd2Results.count('FINISHED') != 0: + logging.debug(podName + ' is finished') + tmpPodNames.remove(podName) + if not tmpPodNames: + isFinished = True + count += 1 + if isFinished: + logging.debug('\u001B[1m PhySim test is Complete\u001B[0m') + + # Getting the logs of each executables running in individual pods + for podName in podNames: + mySSH.command(f'oc logs {podName} >> cmake_targets/log/physim_test.txt 2>&1', '\$', 15, resync=True) + time.sleep(30) + + # UnDeploy the physical simulator pods + mySSH.command('helm uninstall physim | tee -a cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6) + isFinished1 = False + while(isFinished1 == False): + time.sleep(20) + mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True) + if re.search('No resources found', mySSH.getBefore()): + isFinished1 = True + if isFinished1 == True: + logging.debug('\u001B[1m UnDeployed PhySim Successfully on OC Cluster\u001B[0m') + mySSH.command(f'sudo podman rmi default-route-openshift-image-registry.apps.5glab.nsa.eurecom.fr/{self.OCProjectName}/oai-physim:{imageTag}', '\$', 6) + mySSH.command('oc delete is oai-physim', '\$', 6) + logging.debug('\u001B[1m Deleted the Image and ImageStream\u001B[0m') + mySSH.command('oc logout', '\$', 6) + mySSH.close() + self.AnalyzeLogFile_phySim(HTML) + if self.testStatus: + HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult) + logging.info('\u001B[1m Physical Simulator Pass\u001B[0m') + else: + RAN.prematureExit = True + HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ALL_PROCESSES_OK) + HTML.CreateHtmlTestRowPhySimTestResult(self.testSummary,self.testResult) + logging.info('\u001B[1m Physical Simulator Fail\u001B[0m') + + def AnalyzeLogFile_phySim(self, HTML): + lIpAddr = self.eNBIPAddress + lUserName = self.eNBUserName + lPassWord = self.eNBPassword + lSourcePath = self.eNBSourceCodePath + mySSH = SSH.SSHConnection() + mySSH.open(lIpAddr, lUserName, lPassWord) + mySSH.command('cd ' + lSourcePath, '\$', 5) + mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) + mySSH.command('mkdir -p physim_test_log_' + self.testCase_id, '\$', 5) + mySSH.command('cp log/physim_* ' + 'physim_test_log_' + self.testCase_id, '\$', 5) + if not os.path.exists(f'./physim_test_logs_{self.testCase_id}'): + os.mkdir(f'./physim_test_logs_{self.testCase_id}') + mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/physim_test_log_' + self.testCase_id + '/*', './physim_test_logs_' + self.testCase_id) + mySSH.command('rm -rf ./physim_test_log_'+ self.testCase_id, '\$', 5) + mySSH.close() + # physim test log analysis + nextt = 0 + if (os.path.isfile(f'./physim_test_logs_{self.testCase_id}/physim_test.txt')): + with open(f'./physim_test_logs_{self.testCase_id}/physim_test.txt', 'r') as logfile: + for line in logfile: + if re.search('execution 015', str(line)) or re.search('Bypassing compilation', str(line)): + nextt = 1 + elif nextt == 1: + if not re.search('Test Results', str(line)): + nextt = 0 + ret2 = re.search('T[^\n]*', str(line)) + if ret2 is not None: + ret3 = ret2.group() + ret3 = ret3.replace("", "") + if re.search('execution 015', str(line)): + self.testCount[0] += 1 + testName = line.split() + ret1 = re.search('Result = PASS', str(line)) + if ret1 is not None: + self.testResult[testName[1]] = [ret3, 'PASS'] + self.testCount[1] += 1 + else: + self.testResult[testName[1]] = [ret3, 'FAIL'] + self.testCount[2] += 1 + self.testSummary['Nbtests'] = self.testCount[0] + self.testSummary['Nbpass'] = self.testCount[1] + self.testSummary['Nbfail'] = self.testCount[2] + if self.testSummary['Nbfail'] == 0: + self.testStatus = True + return 0 diff --git a/ci-scripts/cls_static_code_analysis.py b/ci-scripts/cls_static_code_analysis.py index 980efb4f8a..1680f3e560 100644 --- a/ci-scripts/cls_static_code_analysis.py +++ b/ci-scripts/cls_static_code_analysis.py @@ -101,7 +101,7 @@ class StaticCodeAnalysis(): # on RedHat/CentOS .git extension is mandatory result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) if result is not None: - full_ran_repo_name = self.ranRepository + full_ran_repo_name = self.ranRepository.replace('git/', 'git') else: full_ran_repo_name = self.ranRepository + '.git' mySSH.command('mkdir -p ' + lSourcePath, '\$', 5) @@ -115,7 +115,7 @@ class StaticCodeAnalysis(): mySSH.command('mkdir -p cmake_targets/log', '\$', 5) # if the commit ID is provided use it to point to it if self.ranCommitID != '': - mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 5) + mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 30) mySSH.command('docker image rm oai-cppcheck:bionic oai-cppcheck:xenial || true', '\$', 60) mySSH.command('docker build --tag oai-cppcheck:xenial --file ci-scripts/docker/Dockerfile.cppcheck.xenial . > cmake_targets/log/cppcheck-xenial.txt 2>&1', '\$', 600) diff --git a/ci-scripts/conf_files/benetel-5g.conf b/ci-scripts/conf_files/benetel-5g.conf index c9f0a579e1..9adead3a68 100644 --- a/ci-scripts/conf_files/benetel-5g.conf +++ b/ci-scripts/conf_files/benetel-5g.conf @@ -92,9 +92,9 @@ gNBs = prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 74; zeroCorrelationZoneConfig = 13; - preambleReceivedTargetPower = -118; + #preambleReceivedTargetPower = -118; #preambleReceivedTargetPower = -104; - #preambleReceivedTargetPower = -108; + preambleReceivedTargetPower = -108; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -124,13 +124,13 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 initialULBWPstartSymbolAndLength_0 = 55; # this is SS=0 L=12 - initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPk2_1 = 2; # used for mixed slot initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; diff --git a/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf b/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf index 33aae14dac..fff3cd1b9a 100644 --- a/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf @@ -244,7 +244,7 @@ MACRLCs = ( THREAD_STRUCT = ( { parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; - worker_config = "ENABLE"; + worker_config = "WORKER_ENABLE"; } ); @@ -260,11 +260,11 @@ RUs = ( local_rf = "yes" nb_tx = 1 nb_rx = 1 - att_tx = 0 + att_tx = 3 att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 118; + max_rxgain = 115; eNB_instances = [0]; # clock_src = "external"; } diff --git a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf index 0da833b3f7..e7dd563e45 100644 --- a/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band261.tm1.32PRB.usrpn300.conf @@ -58,27 +58,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_3 = 0; #for mixed slot + initialDLBWPmappingType_3 = 0; + initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 261; @@ -136,7 +123,7 @@ gNBs = initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; @@ -243,6 +230,7 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; + ulsch_max_slots_inactivity = 1; } ); diff --git a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf index b8a601ce41..1209a6f227 100644 --- a/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band66.tm1.106PRB.usrpn300.conf @@ -56,27 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_3 = 0; #for mixed slot + initialDLBWPmappingType_3 = 0; + initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 66; @@ -132,20 +119,18 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpb210.conf new file mode 100644 index 0000000000..f2da2e9fe3 --- /dev/null +++ b/ci-scripts/conf_files/gnb.band78.sa.fr1.106PRB.usrpb210.conf @@ -0,0 +1,297 @@ +Active_gNBs = ( "gNB-Eurecom-DU"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +gNBs = +( + { + ////////// Identification parameters: + gNB_ID = 0xe00; + gNB_name = "gNB-Eurecom-DU"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ + mcc = 222; + mnc = 01; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + + }); + + nr_cellid = 12345678L; + + ////////// Physical parameters: + + ssb_SubcarrierOffset = 0; + pdsch_AntennaPorts = 1; + pusch_AntennaPorts = 1; + + pdcch_ConfigSIB1 = ( + { + controlResourceSetZero = 12; + searchSpaceZero = 0; + } + ); + + servingCellConfigCommon = ( + { + #spCellConfigCommon + + physCellId = 0; + +# downlinkConfigCommon + #frequencyInfoDL + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + absoluteFrequencySSB = 641280; + dl_frequencyBand = 78; + # this is 3600 MHz + dl_absoluteFrequencyPointA = 640008; + #scs-SpecificCarrierList + dl_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + dl_subcarrierSpacing = 1; + dl_carrierBandwidth = 106; + #initialDownlinkBWP + #genericParameters + # this is RBstart=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialDLBWPsubcarrierSpacing = 1; + #pdcch-ConfigCommon + initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPsearchSpaceZero = 0; + #pdsch-ConfigCommon + #pdschTimeDomainAllocationList (up to 16 entries) + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 + + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 + + #uplinkConfigCommon + #frequencyInfoUL + ul_frequencyBand = 78; + #scs-SpecificCarrierList + ul_offstToCarrier = 0; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + ul_subcarrierSpacing = 1; + ul_carrierBandwidth = 106; + pMax = 20; + #initialUplinkBWP + #genericParameters + initialULBWPlocationAndBandwidth = 12952; +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + initialULBWPsubcarrierSpacing = 1; + #rach-ConfigCommon + #rach-ConfigGeneric + prach_ConfigurationIndex = 98; +#prach_msg1_FDM +#0 = one, 1=two, 2=four, 3=eight + prach_msg1_FDM = 0; + prach_msg1_FrequencyStart = 0; + zeroCorrelationZoneConfig = 13; + preambleReceivedTargetPower = -96; +#preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) + preambleTransMax = 6; +#powerRampingStep +# 0=dB0,1=dB2,2=dB4,3=dB6 + powerRampingStep = 1; +#ra_ReponseWindow +#1,2,4,8,10,20,40,80 + ra_ResponseWindow = 4; +#ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR +#1=oneeighth,2=onefourth,3=half,4=one,5=two,6=four,7=eight,8=sixteen + ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR = 4; +#oneHalf (0..15) 4,8,12,16,...60,64 + ssb_perRACH_OccasionAndCB_PreamblesPerSSB = 14; +#ra_ContentionResolutionTimer +#(0..7) 8,16,24,32,40,48,56,64 + ra_ContentionResolutionTimer = 7; + rsrp_ThresholdSSB = 19; +#prach-RootSequenceIndex_PR +#1 = 839, 2 = 139 + prach_RootSequenceIndex_PR = 2; + prach_RootSequenceIndex = 1; + # SCS for msg1, can only be 15 for 30 kHz < 6 GHz, takes precendence over the one derived from prach-ConfigIndex + # + msg1_SubcarrierSpacing = 1, +# restrictedSetConfig +# 0=unrestricted, 1=restricted type A, 2=restricted type B + restrictedSetConfig = 0, + + # pusch-ConfigCommon (up to 16 elements) + initialULBWPk2_0 = 6; # used for UL slot + initialULBWPmappingType_0 = 1 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + + msg3_DeltaPreamble = 1; + p0_NominalWithGrant =-90; + +# pucch-ConfigCommon setup : +# pucchGroupHopping +# 0 = neither, 1= group hopping, 2=sequence hopping + pucchGroupHopping = 0; + hoppingId = 40; + p0_nominal = -90; +# ssb_PositionsInBurs_BitmapPR +# 1=short, 2=medium, 3=long + ssb_PositionsInBurst_PR = 2; + ssb_PositionsInBurst_Bitmap = 1; + +# ssb_periodicityServingCell +# 0 = ms5, 1=ms10, 2=ms20, 3=ms40, 4=ms80, 5=ms160, 6=spare2, 7=spare1 + ssb_periodicityServingCell = 2; + +# dmrs_TypeA_position +# 0 = pos2, 1 = pos3 + dmrs_TypeA_Position = 0; + +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + subcarrierSpacing = 1; + + + #tdd-UL-DL-ConfigurationCommon +# subcarrierSpacing +# 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 + referenceSubcarrierSpacing = 1; + # pattern1 + # dl_UL_TransmissionPeriodicity + # 0=ms0p5, 1=ms0p625, 2=ms1, 3=ms1p25, 4=ms2, 5=ms2p5, 6=ms5, 7=ms10 + dl_UL_TransmissionPeriodicity = 6; + nrofDownlinkSlots = 7; + nrofDownlinkSymbols = 6; + nrofUplinkSlots = 2; + nrofUplinkSymbols = 4; + + ssPBCH_BlockPower = -25; + } + + ); + + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + amf_ip_address = ( { ipv4 = "CI_MME_IP_ADDR"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NGU = "eth0"; + GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + pusch_proc_threads = 8; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 114; + eNB_instances = [0]; + #beamforming 1x4 matrix: + bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000]; + clock_src = "internal"; + } +); + +THREAD_STRUCT = ( + { + #three config for level of parallelism "PARALLEL_SINGLE_THREAD", "PARALLEL_RU_L1_SPLIT", or "PARALLEL_RU_L1_TRX_SPLIT" + parallel_config = "PARALLEL_SINGLE_THREAD"; + #two option for worker "WORKER_DISABLE" or "WORKER_ENABLE" + worker_config = "WORKER_ENABLE"; + } +); + +rfsimulator : +{ + serveraddr = "server"; + serverport = "4043"; + options = (); #("saviq"); or/and "chanmod" + modelname = "AWGN"; + IQfile = "/tmp/rfsimulator.iqs"; +}; + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + ngap_log_level ="debug"; + ngap_log_verbosity ="medium"; + }; + diff --git a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf index b1d72c2269..8d32e8b792 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.106PRB.usrpn300.conf @@ -56,27 +56,13 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -132,20 +118,17 @@ gNBs = restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -228,6 +211,7 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; + ulsch_max_slots_inactivity = 1; } ); @@ -248,7 +232,7 @@ RUs = ( att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 75; + max_rxgain = 50; eNB_instances = [0]; ## beamforming 1x2 matrix: 1 layer x 2 antennas bf_weights = [0x00007fff, 0x0000]; @@ -259,7 +243,7 @@ RUs = ( ## beamforming 4x4 matrix: #bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff]; - sdr_addrs = "addr=192.168.10.2,mgmt_addr=192.168.10.2,second_addr=192.168.20.2"; + sdr_addrs = "addr=192.168.30.2,mgmt_addr=192.168.30.2,second_addr=192.168.50.2"; clock_src = "external"; } ); diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf index 7be25a24fa..205922af0c 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf @@ -58,27 +58,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -133,20 +120,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_2 = 7; + initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -260,11 +244,11 @@ RUs = ( local_rf = "yes" nb_tx = 1 nb_rx = 1 - att_tx = 0 + att_tx = 3 att_rx = 0; bands = [7]; max_pdschReferenceSignalPower = -27; - max_rxgain = 114; + max_rxgain = 111; eNB_instances = [0]; # clock_src = "external"; } diff --git a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf index 809203f672..cb3e69faf3 100644 --- a/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf +++ b/ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf @@ -61,24 +61,15 @@ gNBs = initialDLBWPk0_0 = 0; #initialULBWPmappingType #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; + initialDLBWPmappingType_0 = 0;#for DL slot #this is SS=1,L=13 initialDLBWPstartSymbolAndLength_0 = 40; - initialDLBWPk0_1 = 0; + initialDLBWPk0_1 = 0;#for mixed slot initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + #this is SS=1,L=5 + initialDLBWPstartSymbolAndLength_1 = 57; - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -103,7 +94,7 @@ gNBs = prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 0; zeroCorrelationZoneConfig = 13; - preambleReceivedTargetPower = -100; + preambleReceivedTargetPower = -90; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -136,7 +127,7 @@ gNBs = initialULBWPk2_0 = 2; initialULBWPmappingType_0 = 1 # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; initialULBWPk2_1 = 2; initialULBWPmappingType_1 = 1; @@ -188,7 +179,7 @@ gNBs = nrofUplinkSlots = 2; nrofUplinkSymbols = 4; //0; //4; - ssPBCH_BlockPower = -25; + ssPBCH_BlockPower = -15; } ); diff --git a/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf b/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf index 419598647b..7f6bff304d 100644 --- a/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band40.tm1.25PRB.FairScheduler.usrpb210.conf @@ -19,54 +19,54 @@ eNBs = tracking_area_code = 1; plmn_list = ( { mcc = 208; mnc = 92; mnc_length = 2; } ); - ////////// Physical parameters: + ////////// Physical parameters: component_carriers = ( { - node_function = "NGFI_RCC_IF4p5"; - node_timing = "synch_to_ext_device"; - node_synch_ref = 0; - frame_type = "TDD"; - tdd_config = 1; - tdd_config_s = 0; - prefix_type = "NORMAL"; - eutra_band = 40; - downlink_frequency = 2350000000L; - uplink_frequency_offset = 0; - Nid_cell = 0; - N_RB_DL = 25; - Nid_cell_mbsfn = 0; - nb_antenna_ports = 1; - nb_antennas_tx = 1; - nb_antennas_rx = 1; - tx_gain = 90; - rx_gain = 125; - prach_root = 0; - prach_config_index = 0; - prach_high_speed = "DISABLE"; - prach_zero_correlation = 1; - prach_freq_offset = 2; - pucch_delta_shift = 1; - pucch_nRB_CQI = 1; - pucch_nCS_AN = 0; - pucch_n1_AN = 0; - pdsch_referenceSignalPower =-27; - pdsch_p_b = 0; - pusch_n_SB = 1; - pusch_enable64QAM = "DISABLE"; - pusch_hoppingMode = "interSubFrame"; - pusch_hoppingOffset = 0; - pusch_groupHoppingEnabled = "ENABLE"; - pusch_groupAssignment = 0; - pusch_sequenceHoppingEnabled = "DISABLE"; - pusch_nDMRS1 = 1; - phich_duration = "NORMAL"; - phich_resource = "ONESIXTH"; - srs_enable = "DISABLE"; - /* srs_BandwidthConfig =; - srs_SubframeConfig =; - srs_ackNackST =; - srs_MaxUpPts =;*/ + node_function = "NGFI_RCC_IF4p5"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "TDD"; + tdd_config = 1; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 40; + downlink_frequency = 2350000000L; + uplink_frequency_offset = 0; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 0; + pdsch_referenceSignalPower =-27; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ pusch_p0_Nominal = -96; pusch_alpha = "AL1"; @@ -76,7 +76,7 @@ eNBs = pucch_deltaF_Format1b = "deltaF3"; pucch_deltaF_Format2 = "deltaF0"; pucch_deltaF_Format2a = "deltaF0"; - pucch_deltaF_Format2b = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; rach_numberOfRA_Preambles = 64; rach_preamblesGroupAConfig = "DISABLE"; @@ -92,17 +92,17 @@ eNBs = rach_macContentionResolutionTimer = 48; rach_maxHARQ_Msg3Tx = 4; - pcch_default_PagingCycle = 128; - pcch_nB = "oneT"; - bcch_modificationPeriodCoeff = 2; - ue_TimersAndConstants_t300 = 1000; - ue_TimersAndConstants_t301 = 1000; - ue_TimersAndConstants_t310 = 1000; - ue_TimersAndConstants_t311 = 10000; - ue_TimersAndConstants_n310 = 20; - ue_TimersAndConstants_n311 = 1; + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; - ue_TransmissionMode = 1; + ue_TransmissionMode = 1; } ); @@ -148,7 +148,7 @@ eNBs = enable_measurement_reports = "no"; ///X2 - enable_x2 = "no"; + enable_x2 = "no"; t_reloc_prep = 1000; /* unit: millisecond */ tx2_reloc_overall = 2000; /* unit: millisecond */ t_dc_prep = 1000; /* unit: millisecond */ @@ -186,41 +186,41 @@ eNBs = } ); MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - scheduler_mode = "fairRR"; - puSch10xSnr = 200; - puCch10xSnr = 200; - } + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + scheduler_mode = "fairRR"; + puSch10xSnr = 200; + puCch10xSnr = 200; + } ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - } + { + num_cc = 1; + tr_n_preference = "local_mac"; + } ); RUs = ( - { - local_if_name = "lo"; - remote_address = "127.0.0.2"; - local_address = "127.0.0.1"; - local_portc = 50000; - remote_portc = 50000; - local_portd = 50001; - remote_portd = 50001; - local_rf = "no" - tr_preference = "udp_if4p5" - nb_tx = 1 - nb_rx = 1 - att_tx = 0 - att_rx = 0; - eNB_instances = [0]; - } -); + { + local_if_name = "lo"; + remote_address = "127.0.0.2"; + local_address = "127.0.0.1"; + local_portc = 50000; + remote_portc = 50000; + local_portd = 50001; + remote_portd = 50001; + local_rf = "no" + tr_preference = "udp_if4p5" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + eNB_instances = [0]; + } +); THREAD_STRUCT = ( { diff --git a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf index 2c3c11b84f..574c8b2545 100644 --- a/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf +++ b/ci-scripts/conf_files/rcc.band7.tm1.if4p5.lo.25PRB.usrpb210.conf @@ -25,51 +25,51 @@ eNBs = component_carriers = ( { - node_function = "NGFI_RCC_IF4p5"; - node_timing = "synch_to_ext_device"; - node_synch_ref = 0; - frame_type = "FDD"; - tdd_config = 3; - tdd_config_s = 0; - prefix_type = "NORMAL"; - eutra_band = 7; - downlink_frequency = 2680000000L; - uplink_frequency_offset = -120000000; - Nid_cell = 0; - N_RB_DL = 25; - Nid_cell_mbsfn = 0; - nb_antenna_ports = 1; - nb_antennas_tx = 1; - nb_antennas_rx = 1; - tx_gain = 90; - rx_gain = 125; - pbch_repetition = "FALSE"; - prach_root = 0; - prach_config_index = 0; - prach_high_speed = "DISABLE"; - prach_zero_correlation = 1; - prach_freq_offset = 2; - pucch_delta_shift = 1; - pucch_nRB_CQI = 0; - pucch_nCS_AN = 0; - pucch_n1_AN = 0; - pdsch_referenceSignalPower = -25; - pdsch_p_b = 0; - pusch_n_SB = 1; - pusch_enable64QAM = "DISABLE"; - pusch_hoppingMode = "interSubFrame"; - pusch_hoppingOffset = 0; - pusch_groupHoppingEnabled = "ENABLE"; - pusch_groupAssignment = 0; - pusch_sequenceHoppingEnabled = "DISABLE"; - pusch_nDMRS1 = 1; - phich_duration = "NORMAL"; - phich_resource = "ONESIXTH"; - srs_enable = "DISABLE"; - /* srs_BandwidthConfig =; - srs_SubframeConfig =; - srs_ackNackST =; - srs_MaxUpPts =;*/ + node_function = "NGFI_RCC_IF4p5"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2680000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 25; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 0; + pucch_nCS_AN = 0; + pucch_n1_AN = 0; + pdsch_referenceSignalPower = -25; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ pusch_p0_Nominal = -96; pusch_alpha = "AL1"; @@ -79,7 +79,7 @@ eNBs = pucch_deltaF_Format1b = "deltaF3"; pucch_deltaF_Format2 = "deltaF0"; pucch_deltaF_Format2a = "deltaF0"; - pucch_deltaF_Format2b = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; rach_numberOfRA_Preambles = 64; rach_preamblesGroupAConfig = "DISABLE"; @@ -97,25 +97,25 @@ eNBs = pcch_default_PagingCycle = 128; pcch_nB = "oneT"; - bcch_modificationPeriodCoeff = 2; - ue_TimersAndConstants_t300 = 1000; - ue_TimersAndConstants_t301 = 1000; - ue_TimersAndConstants_t310 = 1000; - ue_TimersAndConstants_t311 = 10000; - ue_TimersAndConstants_n310 = 20; - ue_TimersAndConstants_n311 = 1; - ue_TransmissionMode = 1; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; //Parameters for SIB18 - rxPool_sc_CP_Len = "normal"; - rxPool_sc_Period = "sf40"; - rxPool_data_CP_Len = "normal"; - rxPool_ResourceConfig_prb_Num = 20; - rxPool_ResourceConfig_prb_Start = 5; - rxPool_ResourceConfig_prb_End = 44; - rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; - rxPool_ResourceConfig_offsetIndicator_choice = 0; - rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; + rxPool_sc_CP_Len = "normal"; + rxPool_sc_Period = "sf40"; + rxPool_data_CP_Len = "normal"; + rxPool_ResourceConfig_prb_Num = 20; + rxPool_ResourceConfig_prb_Start = 5; + rxPool_ResourceConfig_prb_End = 44; + rxPool_ResourceConfig_offsetIndicator_present = "prSmall"; + rxPool_ResourceConfig_offsetIndicator_choice = 0; + rxPool_ResourceConfig_subframeBitmap_present = "prBs40"; rxPool_ResourceConfig_subframeBitmap_choice_bs_buf = "00000000000000000000"; rxPool_ResourceConfig_subframeBitmap_choice_bs_size = 5; rxPool_ResourceConfig_subframeBitmap_choice_bs_bits_unused = 0; @@ -185,7 +185,7 @@ eNBs = enable_measurement_reports = "no"; ///X2 - enable_x2 = "no"; + enable_x2 = "no"; t_reloc_prep = 1000; /* unit: millisecond */ tx2_reloc_overall = 2000; /* unit: millisecond */ t_dc_prep = 1000; /* unit: millisecond */ @@ -205,21 +205,21 @@ eNBs = ); MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - phy_test_mode = 0; - puSch10xSnr = 160; - puCch10xSnr = 160; - } + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + phy_test_mode = 0; + puSch10xSnr = 160; + puCch10xSnr = 160; + } ); L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - } + { + num_cc = 1; + tr_n_preference = "local_mac"; + } ); RUs = ( @@ -260,20 +260,20 @@ NETWORK_CONTROLLER : FLEXRAN_AWAIT_RECONF = "no"; }; - log_config : - { - global_log_level ="info"; - global_log_verbosity ="medium"; - hw_log_level ="info"; - hw_log_verbosity ="medium"; - phy_log_level ="info"; - phy_log_verbosity ="medium"; - mac_log_level ="info"; - mac_log_verbosity ="high"; - rlc_log_level ="info"; - rlc_log_verbosity ="medium"; - pdcp_log_level ="info"; - pdcp_log_verbosity ="medium"; - rrc_log_level ="info"; - rrc_log_verbosity ="medium"; - }; +log_config : +{ + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="high"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; +}; diff --git a/ci-scripts/constants.py b/ci-scripts/constants.py index a0e1ac5c45..bb110bc0e8 100644 --- a/ci-scripts/constants.py +++ b/ci-scripts/constants.py @@ -60,6 +60,11 @@ OAI_UE_PROCESS_SEG_FAULT = -25 OAI_UE_PROCESS_NO_MBMS_MSGS = -26 OAI_UE_PROCESS_OK = +6 INVALID_PARAMETER = -50 +PHYSIM_IMAGE_ABSENT = -60 +OC_LOGIN_FAIL = -61 +OC_PROJECT_FAIL = -62 +OC_IS_FAIL = -63 +OC_PHYSIM_DEPLOY_FAIL = -64 UE_STATUS_DETACHED = 0 UE_STATUS_DETACHING = 1 diff --git a/ci-scripts/createVM.sh b/ci-scripts/createVM.sh index ab859c10d7..f3f8ddaca2 100755 --- a/ci-scripts/createVM.sh +++ b/ci-scripts/createVM.sh @@ -87,7 +87,7 @@ function create_vm { echo "VM_CPU = $VM_CPU" echo "VM_DISK = $VM_DISK GBytes" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] then echo "This VM type is no longer supported in the pipeline framework" return diff --git a/ci-scripts/datalog_rt_stats.yaml b/ci-scripts/datalog_rt_stats.yaml new file mode 100644 index 0000000000..3680d2a19b --- /dev/null +++ b/ci-scripts/datalog_rt_stats.yaml @@ -0,0 +1,33 @@ +#this is a configuration file +#used to build real time processing statistics +#for 5G NR phy test (gNB terminate) +Title : Processing Time (us) +ColNames : + - Metric + - Average + - Max + - Average vs Reference Deviation (Reference Value ; Acceptability Threshold) +Ref : + feprx : 60.0 + feptx_prec : 8.0 + feptx_ofdm : 85.0 + feptx_total : 75.0 + L1 Tx processing : 300.0 + DLSCH encoding : 230.0 + L1 Rx processing : 175.0 + PUSCH inner-receiver : 100.0 + PUSCH decoding : 140.0 + DL & UL scheduling timing stats : 15.0 + UL Indication : 20.0 +Threshold : + feprx : 1.25 + feptx_prec : 1.25 + feptx_ofdm : 1.25 + feptx_total : 1.25 + L1 Tx processing : 1.25 + DLSCH encoding : 1.25 + L1 Rx processing : 1.25 + PUSCH inner-receiver : 1.25 + PUSCH decoding : 1.25 + DL & UL scheduling timing stats : 1.25 + UL Indication : 1.25 diff --git a/ci-scripts/html.py b/ci-scripts/html.py index a0ac638573..9eadf30279 100644 --- a/ci-scripts/html.py +++ b/ci-scripts/html.py @@ -47,7 +47,7 @@ import constants as CONST class HTMLManagement(): def __init__(self): - + self.htmlFile = '' self.htmlHeaderCreated = False self.htmlFooterCreated = False @@ -86,13 +86,13 @@ class HTMLManagement(): #----------------------------------------------------------- # Setters and Getters #----------------------------------------------------------- - + def SethtmlUEConnected(self, nbUEs): if nbUEs > 0: self.htmlUEConnected = nbUEs else: self.htmlUEConnected = 1 - + #----------------------------------------------------------- @@ -365,6 +365,16 @@ class HTMLManagement(): self.htmlFile.write(' KO - SPGW process not found\n') elif (processesStatus == CONST.UE_IP_ADDRESS_ISSUE): self.htmlFile.write(' KO - Could not retrieve UE IP address\n') + elif (processesStatus == CONST.PHYSIM_IMAGE_ABSENT): + self.htmlFile.write(' KO - No such image oai-physim\n') + elif (processesStatus == CONST.OC_LOGIN_FAIL): + self.htmlFile.write(' KO - Could not log onto cluster\n') + elif (processesStatus == CONST.OC_PROJECT_FAIL): + self.htmlFile.write(' KO - Could not register into cluster project\n') + elif (processesStatus == CONST.OC_IS_FAIL): + self.htmlFile.write(' KO - Could not create Image Stream\n') + elif (processesStatus == CONST.OC_PHYSIM_DEPLOY_FAIL): + self.htmlFile.write(' KO - Could not properly deploy physim on cluster\n') else: self.htmlFile.write(' ' + str(status) + '\n') else: @@ -412,7 +422,12 @@ class HTMLManagement(): for image in collectInfo: files = collectInfo[image] # TabHeader for image logs on built shared and target images - self.htmlFile.write(' \n') + if allImagesSize[image].count('unknown') > 0: + self.htmlFile.write(' \n') + elif allImagesSize[image].count('Build Failed') > 0: + self.htmlFile.write(' \n') + else: + self.htmlFile.write(' \n') self.htmlFile.write(' ---- ' + image + ' IMAGE STATUS ----> Size ' + allImagesSize[image] + ' \n') self.htmlFile.write(' \n') self.htmlFile.write(' \n') @@ -431,21 +446,54 @@ class HTMLManagement(): self.htmlFile.write(' ' + str(parameters['errors']) + '\n') else: self.htmlFile.write(' ' + str(parameters['errors']) + '\n') - if (parameters['warnings'] == 0): + if (parameters['errors'] > 0): + self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') + elif (parameters['warnings'] == 0): self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') elif ((parameters['warnings'] > 0) and (parameters['warnings'] <= 20)): self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') else: - self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') + self.htmlFile.write(' ' + str(parameters['warnings']) + '\n') if (parameters['errors'] == 0) and (parameters['warnings'] == 0): self.htmlFile.write(' OK \n') elif (parameters['errors'] == 0) and ((parameters['warnings'] > 0) and (parameters['warnings'] <= 20)): self.htmlFile.write(' OK \n') else: - self.htmlFile.write(' NOT OK \n') + self.htmlFile.write(' NOT OK \n') self.htmlFile.write(' \n') self.htmlFile.close() + #for the moment it is limited to 4 columns, to be made generic later + def CreateHtmlDataLogTable(self, DataLog): + if (self.htmlFooterCreated or (not self.htmlHeaderCreated)): + return + self.htmlFile = open('test_results.html', 'a') + + # TabHeader + self.htmlFile.write(' \n') + self.htmlFile.write(' ---- ' + DataLog['Title'] + ' ---- \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' '+ DataLog['ColNames'][0] +'\n') + self.htmlFile.write(' ' + DataLog['ColNames'][1] + '\n') + self.htmlFile.write(' ' + DataLog['ColNames'][2] + '\n') + self.htmlFile.write(' '+ DataLog['ColNames'][3] +'\n') + self.htmlFile.write(' \n') + + for k in DataLog['Data']: + # TestRow + self.htmlFile.write(' \n') + self.htmlFile.write(' ' + k + ' \n') + self.htmlFile.write(' ' + DataLog['Data'][k][0] + ' \n') + self.htmlFile.write(' ' + DataLog['Data'][k][1] + ' \n') + if float(DataLog['Data'][k][2])> DataLog['Threshold'][k]: + self.htmlFile.write(' ' + DataLog['Data'][k][2] + ' (Ref = ' + str(DataLog['Ref'][k]) + ' ; Thres = ' +str(DataLog['Threshold'][k])+') ' + '\n') + else: + self.htmlFile.write(' ' + DataLog['Data'][k][2] + ' (Ref = ' + str(DataLog['Ref'][k]) + ' ; Thres = ' +str(DataLog['Threshold'][k])+') ' + '\n') + self.htmlFile.write(' \n') + self.htmlFile.close() + + def CreateHtmlTestRowQueue(self, options, status, ue_status, ue_queue): if ((not self.htmlFooterCreated) and (self.htmlHeaderCreated)): self.htmlFile = open('test_results.html', 'a') @@ -562,5 +610,57 @@ class HTMLManagement(): self.htmlFile.write(' ' + str(CCR.nbWrongScanfArg[vId]) + '\n') self.htmlFile.write(' \n') vId += 1 - + + def CreateHtmlTestRowPhySimTestResult(self, testSummary, testResult): + if (self.htmlFooterCreated or (not self.htmlHeaderCreated)): + return + self.htmlFile = open('test_results.html', 'a') + if bool(testResult) == False and bool(testSummary) == False: + self.htmlFile.write(' \n') + self.htmlFile.write(' ----PHYSIM TESTING FAILED - Unable to recover the test logs ---- \n') + self.htmlFile.write(' \n') + else: + # Tab header + self.htmlFile.write(' \n') + self.htmlFile.write(' ---- PHYSIM TEST SUMMARY---- \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' LogFile Name\n') + self.htmlFile.write(' Nb Tests\n') + self.htmlFile.write(' Nb Failure\n') + self.htmlFile.write(' Nb Pass\n') + self.htmlFile.write(' \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' physim_test.txt \n') + self.htmlFile.write(' ' + str(testSummary['Nbtests']) + ' \n') + if testSummary['Nbfail'] == 0: + self.htmlFile.write(' ' + str(testSummary['Nbfail']) + ' \n') + else: + self.htmlFile.write(' ' + str(testSummary['Nbfail']) + ' \n') + self.htmlFile.write(' ' + str(testSummary['Nbpass']) + ' \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' ---- PHYSIM TEST DETAIL INFO---- \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' \n') + self.htmlFile.write(' Test Name\n') + self.htmlFile.write(' Test Description\n') + self.htmlFile.write(' Result\n') + self.htmlFile.write(' \n') + y = '' + for key, value in testResult.items(): + x = key.split(".") + if x[0] != y: + self.htmlFile.write(' \n') + self.htmlFile.write(' "' + x[0] + '" series \n') + self.htmlFile.write(' \n') + y = x[0] + self.htmlFile.write(' \n') + self.htmlFile.write(' ' + key + ' \n') + self.htmlFile.write(' ' + value[0] + '\n') + if 'PASS' in value: + self.htmlFile.write(' ' + value[1] + '\n') + else: + self.htmlFile.write(' ' + value[1] + '\n') + self.htmlFile.close() diff --git a/ci-scripts/main.py b/ci-scripts/main.py index f13df9beb5..0718ee6396 100644 --- a/ci-scripts/main.py +++ b/ci-scripts/main.py @@ -43,7 +43,8 @@ import cls_physim #class PhySim for physical simulators build and import cls_cots_ue #class CotsUe for Airplane mode control import cls_containerize #class Containerize for all container-based operations on RAN/UE objects import cls_static_code_analysis #class for static code analysis - +import cls_ci_ueinfra #class defining the multi Ue infrastrucure +import cls_physim1 #class PhySim for physical simulators deploy and run import sshconnection import epc @@ -151,6 +152,7 @@ def GetParametersFromXML(action): RAN.eNB_serverId[RAN.eNB_instance]=eNB_serverId elif action == 'Initialize_eNB': + RAN.eNB_Trace=test.findtext('eNB_Trace') RAN.Initialize_eNB_args=test.findtext('Initialize_eNB_args') eNB_instance=test.findtext('eNB_instance') if (eNB_instance is None): @@ -193,13 +195,41 @@ def GetParametersFromXML(action): else : RAN.air_interface[RAN.eNB_instance] = 'ocp-enb' + elif action == 'Initialize_UE': + ue_id = test.findtext('id') + CiTestObj.ue_trace=test.findtext('UE_Trace')#temporary variable, to be passed to Module_UE in Initialize_UE call + if (ue_id is None): + CiTestObj.ue_id = "" + else: + CiTestObj.ue_id = ue_id + + elif action == 'Detach_UE': + ue_id = test.findtext('id') + if (ue_id is None): + CiTestObj.ue_id = "" + else: + CiTestObj.ue_id = ue_id + elif action == 'Attach_UE': + ue_id = test.findtext('id') + if (ue_id is None): + CiTestObj.ue_id = "" + else: + CiTestObj.ue_id = ue_id nbMaxUEtoAttach = test.findtext('nbMaxUEtoAttach') if (nbMaxUEtoAttach is None): CiTestObj.nbMaxUEtoAttach = -1 else: CiTestObj.nbMaxUEtoAttach = int(nbMaxUEtoAttach) + elif action == 'Terminate_UE': + ue_id = test.findtext('id') + if (ue_id is None): + CiTestObj.ue_id = "" + else: + CiTestObj.ue_id = ue_id + + elif action == 'CheckStatusUE': expectedNBUE = test.findtext('expectedNbOfConnectedUEs') if (expectedNBUE is None): @@ -253,9 +283,20 @@ def GetParametersFromXML(action): elif (action == 'Ping') or (action == 'Ping_CatM_module'): CiTestObj.ping_args = test.findtext('ping_args') CiTestObj.ping_packetloss_threshold = test.findtext('ping_packetloss_threshold') + ue_id = test.findtext('id') + if (ue_id is None): + CiTestObj.ue_id = "" + else: + CiTestObj.ue_id = ue_id elif action == 'Iperf': CiTestObj.iperf_args = test.findtext('iperf_args') + ue_id = test.findtext('id') + if (ue_id is None): + CiTestObj.ue_id = "" + else: + CiTestObj.ue_id = ue_id + CiTestObj.iperf_direction = test.findtext('direction')#used for modules only CiTestObj.iperf_packetloss_threshold = test.findtext('iperf_packetloss_threshold') CiTestObj.iperf_profile = test.findtext('iperf_profile') if (CiTestObj.iperf_profile is None): @@ -370,6 +411,20 @@ with open(yaml_file,'r') as f: +#loading UE infrastructure from yaml +ue_infra_file='ci_ueinfra.yaml' +if (os.path.isfile(ue_infra_file)): + yaml_file=ue_infra_file +elif (os.path.isfile('ci-scripts/'+ue_infra_file)): + yaml_file='ci-scripts/'+ue_infra_file +else: + logging.error("UE infrastructure yaml file cannot be found") + sys.exit("UE infrastructure file cannot be found") +InfraUE=cls_ci_ueinfra.InfraUE() #initialize UE infrastructure class +InfraUE.Get_UE_Infra(yaml_file) #read the UE infra, filename is hardcoded and unique for the moment but should be passed as parameter from the test suite + + + mode = '' CiTestObj = cls_oaicitest.OaiCiTest() @@ -380,17 +435,17 @@ RAN = ran.RANManagement() HTML = html.HTMLManagement() CONTAINERS = cls_containerize.Containerize() SCA = cls_static_code_analysis.StaticCodeAnalysis() +PHYSIM = cls_physim1.PhySim() ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU build - #----------------------------------------------------------- # Parsing Command Line Arguments #----------------------------------------------------------- import args_parse -py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA) +py_param_file_present, py_params, mode = args_parse.ArgsParse(sys.argv,CiTestObj,RAN,HTML,EPC,ldpc,CONTAINERS,HELP,SCA,PHYSIM) @@ -428,13 +483,13 @@ elif re.match('^TerminateUE$', mode, re.IGNORECASE): HELP.GenericHelp(CONST.Version) sys.exit('Insufficient Parameter') signal.signal(signal.SIGUSR1, receive_signal) - CiTestObj.TerminateUE(HTML,COTS_UE) + CiTestObj.TerminateUE(HTML,COTS_UE,InfraUE,CiTestObj.ue_trace) elif re.match('^TerminateOAIUE$', mode, re.IGNORECASE): if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '': HELP.GenericHelp(CONST.Version) sys.exit('Insufficient Parameter') signal.signal(signal.SIGUSR1, receive_signal) - CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC) + CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE) elif re.match('^TerminateHSS$', mode, re.IGNORECASE): if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '': HELP.GenericHelp(CONST.Version) @@ -673,39 +728,39 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re elif action == 'Terminate_eNB': RAN.TerminateeNB(HTML, EPC) elif action == 'Initialize_UE': - CiTestObj.InitializeUE(HTML,COTS_UE) + CiTestObj.InitializeUE(HTML,RAN, EPC, COTS_UE, InfraUE, CiTestObj.ue_trace) elif action == 'Terminate_UE': - CiTestObj.TerminateUE(HTML,COTS_UE) + CiTestObj.TerminateUE(HTML,COTS_UE, InfraUE, CiTestObj.ue_trace) elif action == 'Attach_UE': - CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE) + CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE,InfraUE) elif action == 'Detach_UE': - CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE) + CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE,InfraUE) elif action == 'DataDisable_UE': CiTestObj.DataDisableUE(HTML) elif action == 'DataEnable_UE': CiTestObj.DataEnableUE(HTML) elif action == 'CheckStatusUE': - CiTestObj.CheckStatusUE(HTML,RAN,EPC,COTS_UE) + CiTestObj.CheckStatusUE(HTML,RAN,EPC,COTS_UE,InfraUE) elif action == 'Build_OAI_UE': CiTestObj.BuildOAIUE(HTML) elif action == 'Initialize_OAI_UE': - CiTestObj.InitializeOAIUE(HTML,RAN,EPC,COTS_UE) + CiTestObj.InitializeOAIUE(HTML,RAN,EPC,COTS_UE,InfraUE) elif action == 'Terminate_OAI_UE': - CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC) + CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE) elif action == 'Initialize_CatM_module': CiTestObj.InitializeCatM(HTML) elif action == 'Terminate_CatM_module': CiTestObj.TerminateCatM(HTML) elif action == 'Attach_CatM_module': - CiTestObj.AttachCatM(HTML,RAN,COTS_UE,EPC) + CiTestObj.AttachCatM(HTML,RAN,COTS_UE,EPC,InfraUE) elif action == 'Detach_CatM_module': CiTestObj.TerminateCatM(HTML) elif action == 'Ping_CatM_module': - CiTestObj.PingCatM(HTML,RAN,EPC,COTS_UE,EPC) + CiTestObj.PingCatM(HTML,RAN,EPC,COTS_UE,EPC,InfraUE) elif action == 'Ping': - CiTestObj.Ping(HTML,RAN,EPC,COTS_UE) + CiTestObj.Ping(HTML,RAN,EPC,COTS_UE, InfraUE) elif action == 'Iperf': - CiTestObj.Iperf(HTML,RAN,EPC,COTS_UE) + CiTestObj.Iperf(HTML,RAN,EPC,COTS_UE, InfraUE) elif action == 'Reboot_UE': CiTestObj.RebootUE(HTML,RAN,EPC) elif action == 'Initialize_HSS': @@ -745,6 +800,8 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re CONTAINERS.UndeployObject(HTML, RAN) elif action == 'Cppcheck_Analysis': SCA.CppCheckAnalysis(HTML) + elif action == 'Deploy_Run_PhySim': + PHYSIM.Deploy_PhySim(HTML, RAN) else: sys.exit('Invalid class (action) from xml') if not RAN.prematureExit: diff --git a/ci-scripts/ran.py b/ci-scripts/ran.py index f1f79a2435..470572f2ff 100644 --- a/ci-scripts/ran.py +++ b/ci-scripts/ran.py @@ -37,6 +37,8 @@ import logging import os import time from multiprocessing import Process, Lock, SimpleQueue +import yaml + #----------------------------------------------------------- # OAI Testing modules @@ -90,6 +92,8 @@ class RANManagement(): self.testCase_id = '' self.epcPcapFile = '' self.runtime_stats= '' + self.datalog_rt_stats={} + self.eNB_Trace = '' #if 'yes', Tshark will be launched at initialization @@ -127,12 +131,16 @@ class RANManagement(): result = re.search('--eNBocp', self.Build_eNB_args) if result is not None: self.air_interface[self.eNB_instance] = 'ocp-enb' - else: - result = re.search('--gNB', self.Build_eNB_args) + else: + result = re.search('--RU', self.Build_eNB_args) if result is not None: - self.air_interface[self.eNB_instance] = 'nr-softmodem' + self.air_interface[self.eNB_instance] = 'oairu' else: - self.air_interface[self.eNB_instance] = 'lte-softmodem' + result = re.search('--gNB', self.Build_eNB_args) + if result is not None: + self.air_interface[self.eNB_instance] = 'nr-softmodem' + else: + self.air_interface[self.eNB_instance] = 'lte-softmodem' # Worakround for some servers, we need to erase completely the workspace if self.Build_eNB_forced_workspace_cleanup: @@ -141,7 +149,7 @@ class RANManagement(): # on RedHat/CentOS .git extension is mandatory result = re.search('([a-zA-Z0-9\:\-\.\/])+\.git', self.ranRepository) if result is not None: - full_ran_repo_name = self.ranRepository + full_ran_repo_name = self.ranRepository.replace('git/', 'git') else: full_ran_repo_name = self.ranRepository + '.git' mySSH.command('mkdir -p ' + lSourcePath, '\$', 5) @@ -184,7 +192,7 @@ class RANManagement(): mySSH.command('echo ' + lPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30) # if the commit ID is provided use it to point to it if self.ranCommitID != '': - mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 5) + mySSH.command('git checkout -f ' + self.ranCommitID, '\$', 30) # if the branch is not develop, then it is a merge request and we need to do # the potential merge. Note that merge conflicts should already been checked earlier if (self.ranAllowMerge): @@ -239,7 +247,6 @@ class RANManagement(): while (count > 0) and buildOAIprocess: mySSH.command('ps aux | grep --color=never build_ | grep -v grep', '\$', 6) result = re.search('build_oai', mySSH.getBefore()) - print(result) if result is None: buildOAIprocess = False else: @@ -294,7 +301,7 @@ class RANManagement(): mySSH.open(self.eNBIPAddress, self.eNBUserName, self.eNBPassword) mySSH.command('cd ' + self.eNBSourceCodePath + '/cmake_targets', '\$', 5) #-qq quiet / -u update orcreate files - mySSH.command('unzip -u -qq -DD tmp_build' + testcaseId + '.zip', '\$', 5) + mySSH.command('unzip -o -u -qq -DD tmp_build' + testcaseId + '.zip', '\$', 5) mySSH.command('rm -f tmp_build' + testcaseId + '.zip', '\$', 5) mySSH.close() else: @@ -338,6 +345,22 @@ class RANManagement(): HTML.CreateHtmlTestRow(self.air_interface[self.eNB_instance] + ' ' + self.Initialize_eNB_args, 'KO', self.pStatus) HTML.CreateHtmlTabFooter(False) sys.exit(1) + #Get pcap on S1 and X2 eNB interface, if enabled in the xml + #will not work for gNB at this stage + if ((self.air_interface[self.eNB_instance] == 'lte-softmodem') or (self.air_interface[self.eNB_instance] == 'ocp-enb')) and self.eNB_Trace=='yes': + mySSH.open(lIpAddr, lUserName, lPassWord) + mySSH.command('ip addr show | awk -f /tmp/active_net_interfaces.awk | egrep -v "lo|tun"', '\$', 5) + result = re.search('interfaceToUse=(?P[a-zA-Z0-9\-\_]+)done', mySSH.getBefore()) + if result is not None: + eth_interface = result.group('eth_interface') + logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + '\u001B[0m') + pcapfile = 'enb_' + self.testCase_id + '_s1x2log.pcap' + mySSH.command('echo ' + lPassWord + ' | sudo -S rm -f /tmp/' + pcapfile , '\$', 5) + mySSH.command('echo $USER; nohup sudo -E tshark -i ' + eth_interface + ' -w /tmp/' + pcapfile + ' 2>&1 &','\$', 5) + mySSH.close() + + + # If tracer options is on, running tshark on EPC side and capture traffic b/ EPC and eNB result = re.search('T_stdout', str(self.Initialize_eNB_args)) if (result is not None): @@ -382,13 +405,13 @@ class RANManagement(): # do not reset board twice in IF4.5 case result = re.search('^rru|^enb|^du.band', str(config_file)) if result is not None: - mySSH.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 60) + mySSH.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 90) result = re.search('type: b200', mySSH.getBefore()) if result is not None: logging.debug('Found a B2xx device --> resetting it') mySSH.command('echo ' + lPassWord + ' | sudo -S b2xx_fx3_utils --reset-device', '\$', 10) # Reloading FGPA bin firmware - mySSH.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 60) + mySSH.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 90) # Make a copy and adapt to EPC / eNB IP addresses mySSH.command('cp ' + full_config_file + ' ' + ci_full_config_file, '\$', 5) localMmeIpAddr = EPC.MmeIPAddress @@ -573,6 +596,10 @@ class RANManagement(): mySSH.command('echo ' + lPassWord + ' | sudo -S killall --signal SIGKILL -r .*-softmodem ocp-enb || true', '\$', 5) time.sleep(5) mySSH.command('rm -f my-lte-softmodem-run' + str(self.eNB_instance) + '.sh', '\$', 5) + #stopping tshark (valid if eNB and enabled in xml, will not harm otherwise) + logging.debug('\u001B[1m Stopping tshark \u001B[0m') + mySSH.command('echo ' + lPassWord + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5) + time.sleep(1) mySSH.close() # If tracer options is on, stopping tshark on EPC side result = re.search('T_stdout', str(self.Initialize_eNB_args)) @@ -591,6 +618,7 @@ class RANManagement(): mySSH.close() logging.debug('\u001B[1m Replaying RAW record file\u001B[0m') mySSH.open(lIpAddr, lUserName, lPassWord) + mySSH.command('killall --signal SIGKILL record', '\$', 5) mySSH.command('cd ' + lSourcePath + '/common/utils/T/tracer/', '\$', 5) enbLogFile = self.eNBLogFiles[int(self.eNB_instance)] raw_record_file = enbLogFile.replace('.log', '_record.raw') @@ -633,6 +661,9 @@ class RANManagement(): HTML.CreateHtmlTestRow(self.runtime_stats, 'OK', CONST.ALL_PROCESSES_OK) else: HTML.CreateHtmlTestRow(self.runtime_stats, 'OK', CONST.ALL_PROCESSES_OK) + #display rt stats for gNB only + if len(self.datalog_rt_stats)!=0 and nodeB_prefix == 'g': + HTML.CreateHtmlDataLogTable(self.datalog_rt_stats) self.eNBmbmsEnables[int(self.eNB_instance)] = False self.eNBstatuses[int(self.eNB_instance)] = -1 @@ -641,9 +672,10 @@ class RANManagement(): mySSH.open(self.eNBIPAddress, self.eNBUserName, self.eNBPassword) mySSH.command('cd ' + self.eNBSourceCodePath, '\$', 5) mySSH.command('cd cmake_targets', '\$', 5) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S mv /tmp/enb_*_s1x2log.pcap .','\$',20) mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm -f enb.log.zip', '\$', 5) - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log core* enb_*record.raw enb_*.pcap enb_*txt physim_*.log', '\$', 60) - mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap enb_*txt', '\$', 5) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S zip enb.log.zip enb*.log core* enb_*record.raw enb_*.pcap enb_*txt physim_*.log *stats.log', '\$', 60) + mySSH.command('echo ' + self.eNBPassword + ' | sudo -S rm enb*.log core* enb_*record.raw enb_*.pcap enb_*txt physim_*.log *stats.log', '\$', 5) mySSH.close() def AnalyzeLogFile_eNB(self, eNBlogFile, HTML): @@ -698,8 +730,28 @@ class RANManagement(): real_time_stats = {} #count "problem receiving samples" msg pb_receiving_samples_cnt = 0 + #count "removing UE" msg + removing_ue = 0 + #NSA specific log markers + nsa_markers ={'SgNBReleaseRequestAcknowledge': [],'FAILURE': [], 'scgFailureInformationNR-r15': [], 'SgNBReleaseRequest': []} + #the datalog config file has to be loaded + datalog_rt_stats_file='datalog_rt_stats.yaml' + if (os.path.isfile(datalog_rt_stats_file)): + yaml_file=datalog_rt_stats_file + elif (os.path.isfile('ci-scripts/'+datalog_rt_stats_file)): + yaml_file='ci-scripts/'+datalog_rt_stats_file + else: + logging.error("Datalog RT stats yaml file cannot be found") + sys.exit("Datalog RT stats yaml file cannot be found") + + with open(yaml_file,'r') as f: + datalog_rt_stats = yaml.load(f,Loader=yaml.FullLoader) + rt_keys = datalog_rt_stats['Ref'] #we use the keys from the Ref field + + line_cnt=0 #log file line counter for line in enb_log_file.readlines(): + line_cnt+=1 # Runtime statistics result = re.search('Run time:' ,str(line)) if result is not None: @@ -857,25 +909,35 @@ class RANManagement(): #keys below are the markers we are loooking for, loop over this keys list #everytime these markers are found in the log file, the previous ones are overwritten in the dict #eventually we record and print only the last occurence - keys = {'UE ID','dlsch_rounds','dlsch_total_bytes','ulsch_rounds','ulsch_total_bytes_scheduled', 'scheduling timing stats'} + keys = {'UE ID','dlsch_rounds','dlsch_total_bytes','ulsch_rounds','ulsch_total_bytes_scheduled'} for k in keys: result = re.search(k, line) if result is not None: #remove 1- all useless char before relevant info (ulsch or dlsch) 2- trailing char dlsch_ulsch_stats[k]=re.sub(r'^.*\]\s+', r'' , line.rstrip()) - #real time statistics - #same method as above - keys = {'feprx','feptx_prec','feptx_ofdm','feptx_total','L1 Tx processing','DLSCH encoding','L1 Rx processing','PUSCH inner-receiver','PUSCH decoding'} - for k in keys: + #real time statistics for gNB + for k in rt_keys: result = re.search(k, line) if result is not None: #remove 1- all useless char before relevant info 2- trailing char + line=line.replace('[0m','') tmp=re.match(rf'^.*?(\b{k}\b.*)',line.rstrip()) #from python 3.6 we can use literal string interpolation for the variable k, using rf' in the regex real_time_stats[k]=tmp.group(1) + #count "problem receiving samples" msg result = re.search('\[PHY\]\s+problem receiving samples', str(line)) if result is not None: - pb_receiving_samples_cnt += 1 + pb_receiving_samples_cnt += 1 + #count "Removing UE" msg + result = re.search('\[MAC\]\s+Removing UE', str(line)) + if result is not None: + removing_ue += 1 + + #nsa markers logging + for k in nsa_markers: + result = re.search(k, line) + if result is not None: + nsa_markers[k].append(line_cnt) enb_log_file.close() logging.debug(' File analysis completed') @@ -884,7 +946,7 @@ class RANManagement(): else: nodeB_prefix = 'g' - if self.air_interface[self.eNB_instance] == 'nr-softmodem': + if nodeB_prefix == 'g': if ulschReceiveOK > 0: statMsg = nodeB_prefix + 'NB showed ' + str(ulschReceiveOK) + ' "ULSCH received ok" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') @@ -911,6 +973,22 @@ class RANManagement(): htmlMsg = statMsg+'\n' logging.debug(statMsg) htmleNBFailureMsg += htmlMsg + #nsa markers + statMsg = 'logfile line count = ' + str(line_cnt) + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg + if len(nsa_markers['SgNBReleaseRequestAcknowledge'])!=0: + statMsg = 'SgNBReleaseRequestAcknowledge = ' + str(len(nsa_markers['SgNBReleaseRequestAcknowledge'])) + ' occurences , starting line ' + str(nsa_markers['SgNBReleaseRequestAcknowledge'][0]) + else: + statMsg = 'SgNBReleaseRequestAcknowledge = ' + str(len(nsa_markers['SgNBReleaseRequestAcknowledge'])) + ' occurences' + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg + statMsg = 'FAILURE = ' + str(len(nsa_markers['FAILURE'])) + ' occurences' + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg #ulsch and dlsch statistics if len(dlsch_ulsch_stats)!=0: #check if dictionary is not empty @@ -920,18 +998,52 @@ class RANManagement(): logging.debug(dlsch_ulsch_stats[key]) htmleNBFailureMsg += statMsg - #real time statistics statistics + #real time statistics + datalog_rt_stats['Data']={} if len(real_time_stats)!=0: #check if dictionary is not empty - statMsg='' - for key in real_time_stats: #for each dictionary key - statMsg += real_time_stats[key] + '\n' - logging.debug(real_time_stats[key]) - htmleNBFailureMsg += statMsg + for k in real_time_stats: + tmp=re.match(r'^(?P.*):\s+(?P\d+\.\d+) us;\s+\d+;\s+(?P\d+\.\d+) us;',real_time_stats[k]) + if tmp is not None: + metric=tmp.group('metric') + avg=float(tmp.group('avg')) + max=float(tmp.group('max')) + datalog_rt_stats['Data'][metric]=["{:.0f}".format(avg),"{:.0f}".format(max),"{:.2f}".format(avg/datalog_rt_stats['Ref'][metric])] + #once all metrics are collected, store the data as a class attribute to build a dedicated HTML table afterward + self.datalog_rt_stats=datalog_rt_stats + #check if there is a fail => will render the test as failed + for k in datalog_rt_stats['Data']: + if float(datalog_rt_stats['Data'][k][2])> datalog_rt_stats['Threshold'][k]: #condition for fail : avg/ref is greater than the fixed threshold + #setting prematureExit is ok although not the best option + self.prematureExit=True else: statMsg = 'No real time stats found in the log file\n' logging.debug('No real time stats found in the log file') htmleNBFailureMsg += statMsg + else: + #Removing UE log + statMsg = '[MAC] Removing UE msg count = '+str(removing_ue) + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg + #nsa markers + statMsg = 'logfile line count = ' + str(line_cnt) + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg + if len(nsa_markers['SgNBReleaseRequest'])!=0: + statMsg = 'SgNBReleaseRequest = ' + str(len(nsa_markers['SgNBReleaseRequest'])) + ' occurences , starting line ' + str(nsa_markers['SgNBReleaseRequest'][0]) + else: + statMsg = 'SgNBReleaseRequest = ' + str(len(nsa_markers['SgNBReleaseRequest'])) + ' occurences' + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg + statMsg = 'scgFailureInformationNR-r15 = ' + str(len(nsa_markers['scgFailureInformationNR-r15'])) + ' occurences' + htmlMsg = statMsg+'\n' + logging.debug(statMsg) + htmleNBFailureMsg += htmlMsg + + if uciStatMsgCount > 0: statMsg = nodeB_prefix + 'NB showed ' + str(uciStatMsgCount) + ' "uci->stat" message(s)' logging.debug('\u001B[1;30;43m ' + statMsg + ' \u001B[0m') diff --git a/ci-scripts/ran_dashboard.py b/ci-scripts/ran_dashboard.py index 601cda1722..4f18638e68 100644 --- a/ci-scripts/ran_dashboard.py +++ b/ci-scripts/ran_dashboard.py @@ -40,6 +40,8 @@ import shlex #lexical analysis import json #json structures import datetime #now() and date formating from datetime import datetime +import re +import gitlab #----------------------------------------------------------- # Class Declaration @@ -79,7 +81,7 @@ class gDashboard: #line 2 empty #line 3 is for the column names i=3 - row =["MR","Created_at","Author","Title","Assignee", "Reviewer", "CAN START","IN PROGRESS","COMPLETED","OK MERGE","Merge conflicts"] + row =["MR","Created_at","Author","Title","Assignee", "Reviewer", "CAN START","IN PROGRESS","COMPLETED","Review Form","OK MERGE","Merge conflicts"] self.sheet.insert_row(row, index=i, value_input_option='RAW') #line 4 onward, MR data lines @@ -120,10 +122,32 @@ class gDashboard: else: conflicts = "" + + #add a column flagging that the review form is present + #we use gitlab API to parse the MR notes + gl = gitlab.Gitlab.from_config('OAI') + project_id = 223 + project = gl.projects.get(project_id) + #get the opened MR in the project + mrs = project.mergerequests.list(state='opened') + for m in range (0,len(mrs)): + if mrs[m].iid==self.d[x]['iid']:#check the iid is the one we are on + mr_notes = mrs[m].notes.list(all=True) + n=0 + found=False + review_form="" + while found==False and nUbuntu 16.04 LTS -- Summary" >> ./build_results.html - if [ -f ./archives/cppcheck/cppcheck.xml ] - then - sca_summary_table_header ./archives/cppcheck/cppcheck.xml "OAI Static Code Analysis with CPPCHECK" - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Uninitialized variable" uninitvar - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Uninitialized struct member" uninitStructMember - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Memory leak" memleak - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Memory is freed twice" doubleFree - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Resource leak" resourceLeak - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Possible null pointer dereference" nullPointer - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Array access out of bounds" arrayIndexOutOfBounds - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Buffer is accessed out of bounds" bufferAccessOutOfBounds - sca_summary_table_row ./archives/cppcheck/cppcheck.xml "Expression depends on order of evaluation of side effects" unknownEvaluationOrder - sca_summary_table_footer ./archives/cppcheck/cppcheck.xml - fi - -# summary_table_header "OAI Build: 4G LTE eNB -- USRP option" ./archives/enb_usrp -# summary_table_row "LTE SoftModem - Release 15" ./archives/enb_usrp/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./enb_usrp_row1.html -# summary_table_row "Coding - Release 15" ./archives/enb_usrp/coding.Rel15.txt "Built target coding" ./enb_usrp_row2.html -# summary_table_row "OAI USRP device if - Release 15" ./archives/enb_usrp/oai_usrpdevif.Rel15.txt "Built target oai_usrpdevif" ./enb_usrp_row3.html -# summary_table_row "OAI ETHERNET transport - Release 15" ./archives/enb_usrp/oai_eth_transpro.Rel15.txt "Built target oai_eth_transpro" ./enb_usrp_row4.html -# summary_table_row "Parameters Lib Config - Release 15" ./archives/enb_usrp/params_libconfig.Rel15.txt "Built target params_libconfig" ./enb_usrp_row5.html -# summary_table_row "NASMESH - Release 15" ./archives/enb_usrp/nasmesh.Rel15.txt "Built target nasmesh" ./enb_usrp_row6.html -# summary_table_row "RB Tool - Release 15" ./archives/enb_usrp/rb_tool.Rel15.txt "Built target rb_tool" ./enb_usrp_row7.html -# summary_table_row "RF Simulator - Release 15" ./archives/enb_usrp/rfsimulator.Rel15.txt "Built target rfsimulator" ./enb_usrp_row8.html -# summary_table_row "TCP Bridge - Release 15" ./archives/enb_usrp/tcp_bridge_oai.Rel15.txt "Built target tcp_bridge_oai" ./enb_usrp_row9.html -# summary_table_footer -# summary_table_header "OAI Build: 4G LTE eNB -- USRP option" ./archives/enb_eth summary_table_row "LTE SoftModem - Release 15" ./archives/enb_eth/lte-softmodem.Rel15.txt "Built target lte-softmodem" ./enb_eth_row1.html summary_table_row "Coding - Release 15" ./archives/enb_eth/coding.Rel15.txt "Built target coding" ./enb_eth_row2.html @@ -637,48 +610,6 @@ function report_build { summary_table_row "NVRAM - Release 15" ./archives/basic_sim/nvram.Rel15.txt "Built target nvram" ./basic_sim_row13.html summary_table_footer - summary_table_header "OAI Build: 4G LTE / 5G NR Physical simulators option" ./archives/phy_sim - summary_table_row "LTE DL Simulator - Release 15" ./archives/phy_sim/dlsim.Rel15.txt "Built target dlsim" ./phy_sim_row1.html - summary_table_row "LTE UL Simulator - Release 15" ./archives/phy_sim/ulsim.Rel15.txt "Built target ulsim" ./phy_sim_row2.html - summary_table_row "Coding - Release 15" ./archives/phy_sim/coding.Rel15.txt "Built target coding" ./phy_sim_row3.html - if [ -f ./archives/phy_sim/ldpctest.Rel15.txt ] - then - summary_table_row "NR LDPC Test - Release 15" ./archives/phy_sim/ldpctest.Rel15.txt "Built target ldpctest" ./phy_sim_row4.html - fi - if [ -f ./archives/phy_sim/polartest.Rel15.txt ] - then - summary_table_row "NR Polar Test - Release 15" ./archives/phy_sim/polartest.Rel15.txt "Built target polartest" ./phy_sim_row5.html - fi - if [ -f ./archives/phy_sim/nr_pbchsim.Rel15.txt ] - then - summary_table_row "NR PBCH Test - Release 15" ./archives/phy_sim/nr_pbchsim.Rel15.txt "Built target nr_pbchsim" ./phy_sim_row6.html - fi - if [ -f ./archives/phy_sim/nr_dlschsim.Rel15.txt ] - then - summary_table_row "NR DLSCH Test - Release 15" ./archives/phy_sim/nr_dlschsim.Rel15.txt "Built target nr_dlschsim" ./phy_sim_row7.html - fi - if [ -f ./archives/phy_sim/nr_pucchsim.Rel15.txt ] - then - summary_table_row "NR PUCCH Test - Release 15" ./archives/phy_sim/nr_pucchsim.Rel15.txt "Built target nr_pucchsim" ./phy_sim_row8.html - fi - if [ -f ./archives/phy_sim/smallblocktest.Rel15.txt ] - then - summary_table_row "NR Small Block Test - Release 15" ./archives/phy_sim/smallblocktest.Rel15.txt "Built target smallblocktest" ./phy_sim_row9.html - fi - if [ -f ./archives/phy_sim/nr_dlsim.Rel15.txt ] - then - summary_table_row "NR DL Sim Test - Release 15" ./archives/phy_sim/nr_dlsim.Rel15.txt "Built target nr_dlsim" ./phy_sim_row10.html - fi - if [ -f ./archives/phy_sim/nr_ulschsim.Rel15.txt ] - then - summary_table_row "NR ULSCH Test - Release 15" ./archives/phy_sim/nr_ulschsim.Rel15.txt "Built target nr_ulschsim" ./phy_sim_row11.html - fi - if [ -f ./archives/phy_sim/nr_ulsim.Rel15.txt ] - then - summary_table_row "NR UL Sim Test - Release 15" ./archives/phy_sim/nr_ulsim.Rel15.txt "Built target nr_ulsim" ./phy_sim_row12.html - fi - summary_table_footer - if [ -f archives/gnb_usrp/nr-softmodem.Rel15.txt ] then summary_table_header "OAI Build: 5G NR gNB -- USRP option" ./archives/gnb_usrp @@ -721,13 +652,6 @@ function report_build { echo " " >> ./build_results.html echo "
" >> ./build_results.html -# if [ -f ./enb_usrp_row1.html ] || [ -f ./enb_usrp_row2.html ] || [ -f ./enb_usrp_row3.html ] || [ -f ./enb_usrp_row4.html ] -# then -# for DETAILS_TABLE in `ls ./enb_usrp_row*.html` -# do -# cat $DETAILS_TABLE >> ./build_results.html -# done -# fi if [ -f ./enb_eth_row1.html ] || [ -f ./enb_eth_row2.html ] || [ -f ./enb_eth_row3.html ] || [ -f ./enb_eth_row4.html ] || [ -f ./enb_eth_row5.html ] || [ -f ./enb_eth_row6.html ] || [ -f ./enb_eth_row7.html ] || [ -f ./enb_eth_row8.html ] || [ -f ./enb_eth_row9.html ] then for DETAILS_TABLE in `ls ./enb_eth_row*.html` @@ -749,13 +673,6 @@ function report_build { cat $DETAILS_TABLE >> ./build_results.html done fi - if [ -f ./phy_sim_row1.html ] || [ -f ./phy_sim_row2.html ] || [ -f ./phy_sim_row3.html ] || [ -f ./phy_sim_row4.html ] || [ -f ./phy_sim_row5.html ] || [ -f ./phy_sim_row6.html ] || [ -f ./phy_sim_row7.html ] || [ -f ./phy_sim_row8.html ] - then - for DETAILS_TABLE in `ls ./phy_sim_row*.html` - do - cat $DETAILS_TABLE >> ./build_results.html - done - fi if [ -f ./gnb_usrp_row1.html ] || [ -f ./gnb_usrp_row2.html ] || [ -f ./gnb_usrp_row3.html ] || [ -f ./gnb_usrp_row4.html ] then for DETAILS_TABLE in `ls ./gnb_usrp_row*.html` @@ -770,13 +687,6 @@ function report_build { cat $DETAILS_TABLE >> ./build_results.html done fi - if [ -f ./enb_usrp_rh_row1.html ] || [ -f ./enb_usrp_rh_row2.html ] || [ -f ./enb_usrp_rh_row3.html ] || [ -f ./enb_usrp_rh_row4.html ] - then - for DETAILS_TABLE in `ls ./enb_usrp_rh_row*.html` - do - cat $DETAILS_TABLE >> ./build_results.html - done - fi rm -f ./*_row*.html echo "
" >> ./build_results.html diff --git a/ci-scripts/reportTestLocally.sh b/ci-scripts/reportTestLocally.sh index c4fa817b06..7290507b4e 100755 --- a/ci-scripts/reportTestLocally.sh +++ b/ci-scripts/reportTestLocally.sh @@ -309,14 +309,14 @@ function report_test { NB_ENB_GOT_SYNC=`egrep -c "got sync" $ENB_LOG` NB_UE_GOT_SYNC=`egrep -c "got sync" $UE_LOG` NB_ENB_SYNCED_WITH_UE=`egrep -c "got UE capabilities for UE" $ENB_LOG` - if [ $NB_ENB_GOT_SYNC -eq 1 ] && [ $NB_UE_GOT_SYNC -eq 2 ] && [ $NB_ENB_SYNCED_WITH_UE -eq 1 ] + if [ $NB_ENB_GOT_SYNC -gt 0 ] && [ $NB_UE_GOT_SYNC -eq 2 ] && [ $NB_ENB_SYNCED_WITH_UE -eq 1 ] then echo " OK" >> ./test_simulator_results.html else echo " KO" >> ./test_simulator_results.html fi echo "
" >> ./test_simulator_results.html
-                    if [ $NB_ENB_GOT_SYNC -eq 1 ]
+                    if [ $NB_ENB_GOT_SYNC -gt 0 ]
                     then
                         echo "- eNB --> got sync" >> ./test_simulator_results.html
                     else
@@ -748,6 +748,82 @@ function report_test {
         echo "        Statistics" >> ./test_simulator_results.html
         echo "      " >> ./test_simulator_results.html
 
+        #SA
+        EPC_CONFIGS=("noS1")
+        TRANS_MODES=("tdd")
+        FR_MODE=("SA")
+        BW_CASES=(106)
+        for CN_CONFIG in ${EPC_CONFIGS[@]}
+        do
+          for TMODE in ${TRANS_MODES[@]}
+          do
+            for BW in ${BW_CASES[@]}
+            do
+                echo "      " >> ./test_simulator_results.html
+                if [[ $CN_CONFIG =~ .*wS1.* ]]
+                then
+                    echo "          Test with EPC (aka withS1): ${TMODE} -- ${BW}PRB -- ${FR_MODE}" >> ./test_simulator_results.html
+                else
+                    echo "          Test without EPC (aka noS1): ${TMODE} -- ${BW}PRB -- ${FR_MODE}" >> ./test_simulator_results.html
+                fi
+                echo "      " >> ./test_simulator_results.html
+
+
+                #SA test (--sa option)
+
+                SA_ENB_LOG=$ARCHIVES_LOC/${TMODE}_${BW}prb_${CN_CONFIG}_gnb_sa_test.log
+                SA_UE_LOG=$ARCHIVES_LOC/${TMODE}_${BW}prb_${CN_CONFIG}_ue_sa_test.log
+                if [ -f $RA_ENB_LOG ] && [ -f $RA_UE_LOG ]
+                then
+                    #get rid of full path
+                    NAME_ENB=`echo $SA_ENB_LOG | sed -e "s#$ARCHIVES_LOC/##"`
+                    NAME_UE=`echo $SA_UE_LOG | sed -e "s#$ARCHIVES_LOC/##"`
+                    echo "      " >> ./test_simulator_results.html
+                    echo "        $NAME_ENB --- $NAME_UE" >> ./test_simulator_results.html
+                    echo "        Check if SA proc succeeded" >> ./test_simulator_results.html
+
+
+                    RRC_CHECK=`egrep -c "Received rrcSetupComplete" $SA_ENB_LOG`
+                    CBRA_CHECK=`egrep -c "Received Ack of RA-Msg4\. CBRA procedure succeeded" $SA_ENB_LOG`
+                    SIB1_CHECK=`egrep -c "SIB1 decoded" $SA_UE_LOG`
+
+
+                    if [ $RRC_CHECK -gt 0 ] && [ $CBRA_CHECK -gt 0 ] && [ $SIB1_CHECK -gt 0 ]
+                    then
+                        echo "        OK" >> ./test_simulator_results.html
+                    else
+                        echo "        KO" >> ./test_simulator_results.html
+                    fi
+
+                    echo "        
" >> ./test_simulator_results.html
+                    if [ $RRC_CHECK -gt 0 ]
+                    then
+                        echo "- Received rrcSetupComplete OK" >> ./test_simulator_results.html
+                    else
+                        echo "- Received rrcSetupComplete KO" >> ./test_simulator_results.html
+                    fi
+                    if [ $CBRA_CHECK -gt 0 ]
+                    then
+                        echo "- CBRA procedure succeeded OK" >> ./test_simulator_results.html
+                    else
+                        echo "- CBRA procedure succeeded KO" >> ./test_simulator_results.html
+                    fi
+                    if [ $SIB1_CHECK -gt 0 ]
+                    then
+                        echo "- SIB1 decoded OK" >> ./test_simulator_results.html
+                    else
+                        echo "- SIB1 decoded KO" >> ./test_simulator_results.html
+                    fi
+
+                    echo "        
" >> ./test_simulator_results.html + echo " " >> ./test_simulator_results.html + fi + + done + done + done + + EPC_CONFIGS=("noS1") TRANS_MODES=("tdd") FR_MODE=("FR2") diff --git a/ci-scripts/runTestOnVM.sh b/ci-scripts/runTestOnVM.sh index 6725d2f62b..058d64b0ba 100755 --- a/ci-scripts/runTestOnVM.sh +++ b/ci-scripts/runTestOnVM.sh @@ -277,6 +277,46 @@ function check_ping_result { } +function check_sa_result { + local LOC_GNB_LOG=$1 + local LOC_UE_LOG=$2 + + #if log files exist + if [ -f $LOC_GNB_LOG ] && [ -f $LOC_UE_LOG ] + then + + #gNB SA test + #console check + echo "Checking gNB Log for SA success" + egrep "Received rrcSetupComplete" $1 + egrep "Received Ack of RA-Msg4\. CBRA procedure succeeded" $1 + + #script check + local RRC_CHECK=`egrep -c "Received rrcSetupComplete" $1` + local CBRA_CHECK=`egrep -c "Received Ack of RA-Msg4\. CBRA procedure succeeded" $1` + + #UE SA test + #console check + echo 'Checking UE Log for SA success' + egrep "SIB1 decoded" $2 + #script check + local SIB1_CHECK=`egrep -c "SIB1 decoded" $2` + + #generate status + if [ $RRC_CHECK -eq 0 ] || [ $CBRA_CHECK -eq 0 ] || [ $SIB1_CHECK -eq 0 ] + then + SA_STATUS=-1 + echo "SA test FAILED, could not find the markers" + fi + #case where log files do not exist + else + echo "SA test log files not present" + SA_STATUS=-1 + fi + +} + + function check_ra_result { local LOC_GNB_LOG=$1 local LOC_UE_LOG=$2 @@ -964,6 +1004,12 @@ function start_l2_sim_ue { echo "ifconfig" > $1 ssh -T -o StrictHostKeyChecking=no ubuntu@$LOC_UE_VM_IP_ADDR < $1 rm $1 + else + echo "Setting Routes for all UEs" + echo "cd /home/ubuntu/tmp/cmake_targets/tools" > $1 + echo "./setup_routes.sh $LOC_NB_UES" >> $1 + ssh -T -o StrictHostKeyChecking=no ubuntu@$LOC_UE_VM_IP_ADDR < $1 + rm $1 fi } @@ -1209,8 +1255,8 @@ function start_rf_sim_gnb { local LOC_CONF_FILE=$5 # 1 is with S1 and 0 without S1 aka noS1 local LOC_S1_CONFIGURATION=$6 - #LOC_RA_TEST=1 will run the RA test check - local LOC_RA_TEST=$7 + #LOC_RA_SA_TEST=1 will run the RA test check ; =2 will run the SA test + local LOC_RA_SA_TEST=$7 if [ -e rbconfig.raw ]; then rm -f rbconfig.raw; fi if [ -e reconfig.raw ]; then rm -f reconfig.raw; fi @@ -1233,11 +1279,14 @@ function start_rf_sim_gnb { echo "sudo rm -f r*config.raw" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option + if [ $LOC_RA_SA_TEST -eq 0 ] #no RA test => use --phy-test option then - echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test\" > ./my-nr-softmodem-run.sh " >> $1 - else #RA test => use --do-ra option - echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --rfsim --do-ra\" > ./my-nr-softmodem-run.sh " >> $1 + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --noS1 --nokrnmod 1 --rfsim --phy-test --lowmem --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + elif [ $LOC_RA_SA_TEST -eq 1 ] #RA test => use --do-ra option + then + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --rfsim --do-ra --lowmem --noS1\" > ./my-nr-softmodem-run.sh " >> $1 + else #SA test => use --sa option + echo "echo \"./nr-softmodem -O /home/ubuntu/tmp/ci-scripts/conf_files/ci-$LOC_CONF_FILE --log_config.global_log_options level,nocolor --parallel-config PARALLEL_SINGLE_THREAD --rfsim --sa --lowmem \" > ./my-nr-softmodem-run.sh " >> $1 fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 @@ -1273,7 +1322,7 @@ function start_rf_sim_gnb { fi # check noS1 config only outside RA test (as it does not support noS1) - if [ $LOC_S1_CONFIGURATION -eq 0 ] && [ $LOC_RA_TEST -eq 0 ] + if [ $LOC_S1_CONFIGURATION -eq 0 ] && [ $LOC_RA_SA_TEST -eq 0 ] then echo "ifconfig oaitun_enb1 | egrep -c \"inet addr\"" > $1 # Checking oaitun_enb1 interface has now an IP address @@ -1318,8 +1367,8 @@ function start_rf_sim_nr_ue { local LOC_FREQUENCY=$6 # 1 is with S1 and 0 without S1 aka noS1 local LOC_S1_CONFIGURATION=$7 - #LOC_RA_TEST=1 will run the RA test check - local LOC_RA_TEST=$8 + #LOC_RA_SA_TEST=1 will run the RA test check ; =2 will run the SA test + local LOC_RA_SA_TEST=$8 # Copy the RAW files from the gNB run scp -o StrictHostKeyChecking=no rbconfig.raw ubuntu@$LOC_NR_UE_VM_IP_ADDR:/home/ubuntu/tmp @@ -1336,11 +1385,14 @@ function start_rf_sim_nr_ue { echo "cd /home/ubuntu/tmp/cmake_targets/ran_build/build/" >> $1 if [ $LOC_S1_CONFIGURATION -eq 0 ] then - if [ $LOC_RA_TEST -eq 0 ] #no RA test => use --phy-test option + if [ $LOC_RA_SA_TEST -eq 0 ] #no RA test => use --phy-test option then echo "echo \"./nr-uesoftmodem --nokrnmod 1 --rfsim --phy-test --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/ --log_config.global_log_options level,nocolor --noS1\" > ./my-nr-softmodem-run.sh " >> $1 - else #RA test => use --do-ra option + elif [ $LOC_RA_SA_TEST -eq 1 ] #RA test => use --do-ra option + then echo "echo \"./nr-uesoftmodem --rfsim --do-ra --log_config.global_log_options level,nocolor --rrc_config_path /home/ubuntu/tmp/cmake_targets/ran_build/build/\" > ./my-nr-softmodem-run.sh " >> $1 + else #SA test => use --sa option + echo "echo \"./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --log_config.global_log_options level,nocolor\" > ./my-nr-softmodem-run.sh " >> $1 fi fi echo "chmod 775 ./my-nr-softmodem-run.sh" >> $1 @@ -1375,7 +1427,7 @@ function start_rf_sim_nr_ue { echo "RF-SIM NR-UE is sync'ed w/ gNB" fi # Checking oaitun_ue1 interface has now an IP address (only outside RA test) - if [ $LOC_RA_TEST -eq 0 ] + if [ $LOC_RA_SA_TEST -eq 0 ] then i="0" echo "ifconfig oaitun_ue1 | egrep -c \"inet addr\"" > $1 @@ -1478,13 +1530,13 @@ function run_test_on_vm { echo "$VM_NAME has for IP addr = $VM_IP_ADDR" fi - if [ "$RUN_OPTIONS" == "none" ] + if [ "$RUN_OPTIONS" == "none" ] || [[ $RUN_OPTIONS =~ .*run_exec_autotests.* ]] then echo "No run on VM testing for this variant currently" return fi - if [[ $RUN_OPTIONS =~ .*run_exec_autotests.* ]] + if [[ $RUN_OPTIONS =~ .*run_XXXX_autotests.* ]] then echo "############################################################" echo "Running test script on VM ($VM_NAME)" @@ -2189,6 +2241,88 @@ function run_test_on_vm { if [[ "$RUN_OPTIONS" == "complex" ]] && [[ $VM_NAME =~ .*-rf-sim.* ]] then + echo "############################################################" + echo "SA TEST" + echo "############################################################" + #SA test, attention : has a different config file from the rest of the test + CN_CONFIG="noS1" + CONF_FILE=gnb.band78.sa.fr1.106PRB.usrpb210.conf + S1_NOS1_CFG=0 + PRB=106 + FREQUENCY=3510 + + if [ ! -d $ARCHIVES_LOC ] + then + mkdir --parents $ARCHIVES_LOC + fi + + local try_cnt=0 + NR_STATUS=0 + + ######### start of SA TEST loop + while [ $try_cnt -lt 5 ] #5 because it hardly succeed within CI + do + + SYNC_STATUS=0 + SA_STATUS=0 + rm -f $ARCHIVES_LOC/tdd_${PRB}prb_${CN_CONFIG}*sa_test.log + + echo "############################################################" + echo "${CN_CONFIG} : Starting the gNB" + echo "############################################################" + CURRENT_GNB_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_gnb_sa_test.log + #last argument = 2 is to enable --sa for SA test + start_rf_sim_gnb $GNB_VM_CMDS "$GNB_VM_IP_ADDR" $CURRENT_GNB_LOG_FILE $PRB $CONF_FILE $S1_NOS1_CFG 2 + + echo "############################################################" + echo "${CN_CONFIG} : Starting the NR-UE" + echo "############################################################" + CURRENT_NR_UE_LOG_FILE=tdd_${PRB}prb_${CN_CONFIG}_ue_sa_test.log + #last argument = 2 is to enable --sa for SA test + start_rf_sim_nr_ue $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR $GNB_VM_IP_ADDR $CURRENT_NR_UE_LOG_FILE $PRB $FREQUENCY $S1_NOS1_CFG 2 + if [ $NR_UE_SYNC -eq 0 ] + then + echo "Problem w/ gNB and NR-UE not syncing" + terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 + terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1 + scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC + scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC + SYNC_STATUS=-1 + try_cnt=$((try_cnt+1)) + continue + fi + + echo "############################################################" + echo "${CN_CONFIG} : Terminate gNB/NR-UE simulators" + echo "############################################################" + sleep 20 + terminate_enb_ue_basic_sim $NR_UE_VM_CMDS $NR_UE_VM_IP_ADDR 2 + terminate_enb_ue_basic_sim $GNB_VM_CMDS $GNB_VM_IP_ADDR 1 + scp -o StrictHostKeyChecking=no ubuntu@$GNB_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC + scp -o StrictHostKeyChecking=no ubuntu@$NR_UE_VM_IP_ADDR:/home/ubuntu/tmp/cmake_targets/log/$CURRENT_NR_UE_LOG_FILE $ARCHIVES_LOC + + #check SA markers in gNB and NR UE log files + echo "############################################################" + echo "${CN_CONFIG} : Checking SA on gNB / NR-UE" + echo "############################################################" + + # Proper check to be done when SA test is working! + check_sa_result $ARCHIVES_LOC/$CURRENT_GNB_LOG_FILE $ARCHIVES_LOC/$CURRENT_NR_UE_LOG_FILE + if [ $SA_STATUS -ne 0 ] + then + echo "SA test NOT OK" + echo "try_cnt = " $try_cnt + try_cnt=$((try_cnt+1)) + else + try_cnt=$((try_cnt+10)) + fi + done + ########### end SA test + + sleep 30 + + + echo "############################################################" echo "RA TEST FR2" echo "############################################################" @@ -2493,6 +2627,7 @@ function run_test_on_vm { echo "Checking run status" echo "############################################################" + if [ $SA_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $RA_FR2_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $RA_STATUS -ne 0 ]; then NR_STATUS=-1; fi if [ $SYNC_STATUS -ne 0 ]; then NR_STATUS=-1; fi diff --git a/ci-scripts/sshconnection.py b/ci-scripts/sshconnection.py index 5bfe5da70f..b4087c9695 100644 --- a/ci-scripts/sshconnection.py +++ b/ci-scripts/sshconnection.py @@ -35,6 +35,7 @@ import pexpect # pexpect import logging import time # sleep import re +import subprocess import sys #----------------------------------------------------------- @@ -44,6 +45,9 @@ class SSHConnection(): def __init__(self): self.ssh = '' self.picocom_closure = False + self.ipaddress = '' + self.username = '' + self.cmd2Results = '' def disablePicocomClosure(self): self.picocom_closure = False @@ -98,6 +102,8 @@ class SSHConnection(): pass else: sys.exit('SSH Connection Failed') + self.ipaddress = ipaddress + self.username = username @@ -111,11 +117,20 @@ class SSHConnection(): self.sshresponse = self.ssh.expect(expected) return self.sshresponse - def command(self, commandline, expectedline, timeout): - logging.debug(commandline) + def command(self, commandline, expectedline, timeout, silent=False, resync=False): + if not silent: + logging.debug(commandline) self.ssh.timeout = timeout - self.ssh.sendline(commandline) - self.sshresponse = self.ssh.expect([expectedline, pexpect.EOF, pexpect.TIMEOUT]) + # Nasty patch when pexpect output is out of sync. + # Much pronounced when running back-to-back-back oc commands + if resync: + self.ssh.send(commandline) + self.ssh.expect([commandline, pexpect.TIMEOUT]) + self.ssh.send('\r\n') + self.sshresponse = self.ssh.expect([expectedline, pexpect.EOF, pexpect.TIMEOUT]) + else: + self.ssh.sendline(commandline) + self.sshresponse = self.ssh.expect([expectedline, pexpect.EOF, pexpect.TIMEOUT]) if self.sshresponse == 0: return 0 elif self.sshresponse == 1: @@ -137,10 +152,23 @@ class SSHConnection(): logging.debug('Expected Line : ' + expectedline) sys.exit(self.sshresponse) + def command2(self, commandline, timeout, silent=False): + if not silent: + logging.debug(commandline) + self.cmd2Results = '' + myHost = self.username + '@' + self.ipaddress + # CAUTION: THIS METHOD IMPLIES THAT THERE ARE VALID SSH KEYS + # BETWEEN THE PYTHON EXECUTOR NODE AND THE REMOTE HOST + # OTHERWISE IT WON'T WORK + lSsh = subprocess.Popen(["ssh", "%s" % myHost, commandline],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + self.cmd2Results = str(lSsh.stdout.readlines()) + def close(self): self.ssh.timeout = 5 self.ssh.sendline('exit') self.sshresponse = self.ssh.expect([pexpect.EOF, pexpect.TIMEOUT]) + self.ipaddress = '' + self.username = '' if self.sshresponse == 0: pass elif self.sshresponse == 1: diff --git a/ci-scripts/waitBuildOnVM.sh b/ci-scripts/waitBuildOnVM.sh index f7e300edf4..4a604a1fe9 100755 --- a/ci-scripts/waitBuildOnVM.sh +++ b/ci-scripts/waitBuildOnVM.sh @@ -47,7 +47,7 @@ function wait_on_vm_build { echo "ARCHIVES_LOC = $ARCHIVES_LOC" echo "BUILD_OPTIONS = $BUILD_OPTIONS" - if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] then echo "This VM type is no longer supported in the pipeline framework" return @@ -93,7 +93,7 @@ function wait_on_vm_build { } function check_on_vm_build { - if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] + if [[ "$VM_NAME" == *"-enb-usrp"* ]] || [[ "$VM_NAME" == *"-cppcheck"* ]] || [[ "$VM_NAME" == *"-phy-sim"* ]] then echo "This VM type is no longer supported in the pipeline framework" return diff --git a/ci-scripts/xml_class_list.yml b/ci-scripts/xml_class_list.yml index de16116124..2282e101e5 100755 --- a/ci-scripts/xml_class_list.yml +++ b/ci-scripts/xml_class_list.yml @@ -38,3 +38,4 @@ - Deploy_Object - Undeploy_Object - Cppcheck_Analysis + - Deploy_Run_PhySim \ No newline at end of file diff --git a/ci-scripts/xml_files/benetel_nsa_base.xml b/ci-scripts/xml_files/benetel_nsa_quectel.xml similarity index 72% rename from ci-scripts/xml_files/benetel_nsa_base.xml rename to ci-scripts/xml_files/benetel_nsa_quectel.xml index 0aed28dffa..ed93f59e81 100644 --- a/ci-scripts/xml_files/benetel_nsa_base.xml +++ b/ci-scripts/xml_files/benetel_nsa_quectel.xml @@ -21,49 +21,40 @@ --> - TEST-FR1-TM1 - FR1 + TEST-NSA-FR1-TM1 + NSA Ping DL UL with QUECTEL tasks + 3 - 010000 030000 040000 - 010001 - 000001 + 000002 + 010000 050000 050001 000001 - 060000 - 060001 - 000001 070000 + 000001 070001 + 000001 010002 000001 080001 080000 - 010003 Initialize_UE - Initialize UE + Initialize Quectel + idefix - - Terminate_UE - Terminate UE - - - - Attach_UE - Attach UE - Detach_UE Detach UE + idefix @@ -74,27 +65,35 @@ 0 0 lte - + Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/benetel-5g.conf + -O ci-scripts/conf_files/benetel-5g.conf -q 1 1 nr + IdleSleep + Sleep + 5 + + + IdleSleep Sleep 20 + Ping Ping: 20pings in 20sec + idefix -c 20 50 @@ -102,46 +101,32 @@ Ping Ping: 100pings in 20sec + idefix -c 100 -i 0.2 50 - - - Iperf - iperf (DL/2.5Mbps/UDP)(60 sec)(single-ue profile) - -u -b 2.5M -t 60 -i 1 - 50 - single-ue - - - - Iperf - iperf (UL/1.5Mbps/UDP)(60 sec)(single-ue profile) - -u -b 1.5M -t 60 -i 1 -R - 50 - single-ue - - - Iperf - iperf (DL/20Mbps/UDP)(20 sec)(single-ue profile) - -u -b 20M -t 20 -i 1 + iperf (DL/20Mbps/UDP)(60 sec)(single-ue profile) + -u -b 20M -t 60 -i 1 + DL + idefix 50 single-ue Iperf - iperf (UL/3Mbps/UDP)(20 sec)(single-ue profile) - -u -b 3M -t 20 -i 1 -R + iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile) + -u -b 3M -t 60 -i 1 + UL + idefix 50 single-ue - Terminate_eNB Terminate eNB diff --git a/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml b/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml new file mode 100644 index 0000000000..93c0c5a00a --- /dev/null +++ b/ci-scripts/xml_files/benetel_nsa_quectel_longrun.xml @@ -0,0 +1,149 @@ + + + TEST-NSA-FR1-TM1 + NSA Ping DL UL with QUECTEL + tasks + 3 + + 030000 + 040000 + 000002 + 010000 + 000001 + 050000 + 050001 + 000001 + 070000 + 000001 + 070001 + 000001 + 010002 + 000001 + 080001 + 080000 + + + + + + Initialize_UE + Initialize Quectel + idefix + + + + + Detach_UE + Detach UE + idefix + + + + + Initialize_eNB + Initialize eNB + -O ci-scripts/conf_files/benetel-4g.conf + 0 + 0 + lte + + + + + Initialize_eNB + Initialize gNB + -O ci-scripts/conf_files/benetel-5g.conf -q + 1 + 1 + nr + + + + IdleSleep + Sleep + 10 + + + + IdleSleep + Sleep + 30 + + + + + Ping + Ping: 20pings in 20sec + idefix + -c 20 + 50 + + + + Ping + Ping: 100pings in 20sec + idefix + -c 100 -i 0.2 + 50 + + + + Iperf + iperf (DL/20Mbps/UDP)(20 min)(single-ue profile) + -u -b 20M -t 1200 -i 1 + DL + idefix + 50 + single-ue + + + + Iperf + iperf (UL/3Mbps/UDP)(20 min)(single-ue profile) + -u -b 2M -t 1200 -i 1 + UL + idefix + 50 + single-ue + + + + + Terminate_eNB + Terminate eNB + 0 + 0 + lte + + + + Terminate_eNB + Terminate gNB + 1 + 1 + nr + + + + diff --git a/ci-scripts/xml_files/container_image_build.xml b/ci-scripts/xml_files/container_image_build.xml index 430729c49c..e7eabc0794 100644 --- a/ci-scripts/xml_files/container_image_build.xml +++ b/ci-scripts/xml_files/container_image_build.xml @@ -35,6 +35,7 @@ all 0 0 + True diff --git a/ci-scripts/xml_files/enb_ue_usrp210_band7_build.xml b/ci-scripts/xml_files/enb_ue_usrp210_band7_build.xml index 64c3517166..bfaaceaa2d 100644 --- a/ci-scripts/xml_files/enb_ue_usrp210_band7_build.xml +++ b/ci-scripts/xml_files/enb_ue_usrp210_band7_build.xml @@ -32,7 +32,7 @@ Build_eNB Build eNB (USRP) - -w USRP -c --eNB + -w USRP -c --eNB --ninja diff --git a/ci-scripts/xml_files/enb_usrp210_band13_build.xml b/ci-scripts/xml_files/enb_usrp210_band13_build.xml index 888a1230ae..53066573c8 100644 --- a/ci-scripts/xml_files/enb_usrp210_band13_build.xml +++ b/ci-scripts/xml_files/enb_usrp210_band13_build.xml @@ -33,7 +33,7 @@ Build_eNB Build eNB (USRP) - -w USRP -c --eNB + -w USRP -c --eNB --ninja diff --git a/ci-scripts/xml_files/enb_usrp210_band40_build.xml b/ci-scripts/xml_files/enb_usrp210_band40_build.xml index 64c3517166..bfaaceaa2d 100644 --- a/ci-scripts/xml_files/enb_usrp210_band40_build.xml +++ b/ci-scripts/xml_files/enb_usrp210_band40_build.xml @@ -32,7 +32,7 @@ Build_eNB Build eNB (USRP) - -w USRP -c --eNB + -w USRP -c --eNB --ninja diff --git a/ci-scripts/xml_files/enb_usrp210_band7_build.xml b/ci-scripts/xml_files/enb_usrp210_band7_build.xml index 64c3517166..bfaaceaa2d 100644 --- a/ci-scripts/xml_files/enb_usrp210_band7_build.xml +++ b/ci-scripts/xml_files/enb_usrp210_band7_build.xml @@ -32,7 +32,7 @@ Build_eNB Build eNB (USRP) - -w USRP -c --eNB + -w USRP -c --eNB --ninja diff --git a/ci-scripts/xml_files/fr1_nsa_quectel.xml b/ci-scripts/xml_files/fr1_nsa_quectel.xml new file mode 100644 index 0000000000..7ec3a5f140 --- /dev/null +++ b/ci-scripts/xml_files/fr1_nsa_quectel.xml @@ -0,0 +1,149 @@ + + + TEST-NSA-FR1-TM1 + NSA Ping DL UL with QUECTEL + tasks + 1 + + 030000 + 040000 + 000002 + 010000 + 000001 + 050000 + 050001 + 000001 + 070000 + 000001 + 070001 + 000001 + 010002 + 080001 + 080000 + + + + + Initialize_UE + Initialize Quectel + idefix + yes + + + + + Terminate_UE + Terminate Quectel + idefix + + + + + Initialize_eNB + Initialize eNB + -O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf + 0 + 0 + lte + yes + + + + + Initialize_eNB + Initialize gNB + -O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q + 1 + 1 + nr + + + + IdleSleep + Sleep + 5 + + + + IdleSleep + Sleep + 20 + + + + + Ping + Ping: 20pings in 20sec + idefix + -c 20 + 50 + + + + Ping + Ping: 100pings in 20sec + idefix + -c 100 -i 0.2 + 50 + + + + Iperf + iperf (DL/20Mbps/UDP)(60 sec)(single-ue profile) + -u -b 20M -t 60 + DL + idefix + 50 + single-ue + + + + Iperf + iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile) + -u -b 3M -t 60 + UL + idefix + 50 + single-ue + + + + + Terminate_eNB + Terminate eNB + 0 + 0 + lte + + + + Terminate_eNB + Terminate gNB + 1 + 1 + nr + + + + diff --git a/ci-scripts/xml_files/fr1_nsa_base_ref.xml b/ci-scripts/xml_files/fr1_nsa_quectel_attach_detach.xml similarity index 76% rename from ci-scripts/xml_files/fr1_nsa_base_ref.xml rename to ci-scripts/xml_files/fr1_nsa_quectel_attach_detach.xml index fd47db10b2..2263f731c5 100644 --- a/ci-scripts/xml_files/fr1_nsa_base_ref.xml +++ b/ci-scripts/xml_files/fr1_nsa_quectel_attach_detach.xml @@ -22,48 +22,60 @@ --> TEST-NSA-FR1-TM1 - NSA FULL + NSA Ping Attach Detach with QUECTEL tasks + 1 - 010000 030000 040000 - 010001 + 000002 + 010000 000001 050000 - 050001 000001 - 060000 - 060001 + 010004 + 000001 + 010003 + 000001 + 050000 + 000001 + 010004 + 000001 + 010003 + 000001 + 050000 000001 - 070000 010002 - 000001 080001 080000 - 010003 Initialize_UE - Initialize UE + Initialize Quectel + idefix + yes + + + + + Terminate_UE + Terminate Quectel + idefix - Terminate_UE - Terminate UE - - - Attach_UE - Attach UE + Attach Quectel + idefix - + Detach_UE - Detach UE - + Detach Quectel + idefix + @@ -73,27 +85,36 @@ 0 0 lte - + yes + Initialize_eNB Initialize gNB - -O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E + -O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q 1 1 nr + IdleSleep + Sleep + 5 + + + IdleSleep Sleep 20 + Ping Ping: 20pings in 20sec + idefix -c 20 50 @@ -101,46 +122,32 @@ Ping Ping: 100pings in 20sec + idefix -c 100 -i 0.2 50 - - - Iperf - iperf (DL/3Mbps/UDP)(20 sec)(single-ue profile) - -u -b 3M -t 20 -i 1 - 50 - single-ue - - - - Iperf - iperf (UL/1Mbps/UDP)(20 sec)(single-ue profile) - -u -b 1M -t 20 -i 1 -R - 50 - single-ue - - - Iperf - iperf (DL/20Mbps/UDP)(20 sec)(single-ue profile) - -u -b 20M -t 20 -i 1 + iperf (DL/20Mbps/UDP)(60 sec)(single-ue profile) + -u -b 20M -t 60 + DL + idefix 50 single-ue Iperf - iperf (UL/3Mbps/UDP)(20 sec)(single-ue profile) - -u -b 3M -t 20 -i 1 -R + iperf (UL/3Mbps/UDP)(60 sec)(single-ue profile) + -u -b 3M -t 60 + UL + idefix 50 single-ue - Terminate_eNB Terminate eNB diff --git a/ci-scripts/xml_files/fr1_nsa_quectel_long.xml b/ci-scripts/xml_files/fr1_nsa_quectel_long.xml new file mode 100644 index 0000000000..21ff7a63c5 --- /dev/null +++ b/ci-scripts/xml_files/fr1_nsa_quectel_long.xml @@ -0,0 +1,148 @@ + + + TEST-NSA-FR1-TM1 + NSA Ping DL UL with QUECTEL (Longer) + tasks + 1 + + 030000 + 040000 + 000002 + 010000 + 000001 + 050000 + 050001 + 000001 + 070000 + 000001 + 070001 + 000001 + 010002 + 080001 + 080000 + + + + + Initialize_UE + Initialize Quectel + idefix + + + + + Terminate_UE + Terminate Quectel + idefix + + + + + Initialize_eNB + Initialize eNB + -O ci-scripts/conf_files/enb.band7.tm1.fr1.25PRB.usrpb210.conf + 0 + 0 + lte + yes + + + + + Initialize_eNB + Initialize gNB + -O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E -q + 1 + 1 + nr + + + + IdleSleep + Sleep + 5 + + + + IdleSleep + Sleep + 20 + + + + + Ping + Ping: 20pings in 20sec + idefix + -c 20 + 50 + + + + Ping + Ping: 100pings in 20sec + idefix + -c 100 -i 0.2 + 50 + + + + Iperf + iperf (DL/20Mbps/UDP)(600 sec)(single-ue profile) + -u -b 20M -t 600 + DL + idefix + 50 + single-ue + + + + Iperf + iperf (UL/3Mbps/UDP)(600 sec)(single-ue profile) + -u -b 3M -t 600 + UL + idefix + 50 + single-ue + + + + + Terminate_eNB + Terminate eNB + 0 + 0 + lte + + + + Terminate_eNB + Terminate gNB + 1 + 1 + nr + + + + diff --git a/ci-scripts/xml_files/gnb_phytest_usrp_run.xml b/ci-scripts/xml_files/gnb_phytest_usrp_run.xml index 00610d430e..9e798afdc4 100644 --- a/ci-scripts/xml_files/gnb_phytest_usrp_run.xml +++ b/ci-scripts/xml_files/gnb_phytest_usrp_run.xml @@ -24,7 +24,7 @@ gNB-PHY-Test Run-gNB-PHY-Test tasks - 2 + 3 090101 000001 090109 @@ -40,7 +40,7 @@ IdleSleep Sleep - 180 + 300 diff --git a/ci-scripts/xml_files/if4p5_usrp210_band40_build.xml b/ci-scripts/xml_files/if4p5_usrp210_band40_build.xml index ab221c918d..d383dbb61b 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band40_build.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band40_build.xml @@ -33,7 +33,7 @@ Build_eNB Build eNB (USRP -- Ethernet Fronthaul) - -w USRP -c --eNB + -w USRP -c --eNB --ninja diff --git a/ci-scripts/xml_files/if4p5_usrp210_band7_build.xml b/ci-scripts/xml_files/if4p5_usrp210_band7_build.xml index ab221c918d..d383dbb61b 100644 --- a/ci-scripts/xml_files/if4p5_usrp210_band7_build.xml +++ b/ci-scripts/xml_files/if4p5_usrp210_band7_build.xml @@ -33,7 +33,7 @@ Build_eNB Build eNB (USRP -- Ethernet Fronthaul) - -w USRP -c --eNB + -w USRP -c --eNB --ninja diff --git a/ci-scripts/xml_files/multi_rru_band38_build.xml b/ci-scripts/xml_files/multi_rru_band38_build.xml index ba45eab10a..1370a3a396 100644 --- a/ci-scripts/xml_files/multi_rru_band38_build.xml +++ b/ci-scripts/xml_files/multi_rru_band38_build.xml @@ -26,7 +26,7 @@ wrench 010101 010102 010103 - 000101 000102 000103 + 000102 000103 000101 @@ -50,7 +50,7 @@ Build_eNB Build Master RRU - -w USRP -c --eNB --ninja + -w USRP -c --RU --ninja 1 1 True @@ -59,7 +59,7 @@ WaitEndBuild_eNB Wait for end of Build Master RRU - -w USRP -c --eNB --ninja + -w USRP -c --RU --ninja 1 1 @@ -67,7 +67,7 @@ Build_eNB Build Slave RRU - -w USRP -c --eNB --ninja + -w USRP -c --RU --ninja 2 2 True @@ -76,7 +76,7 @@ WaitEndBuild_eNB Wait for end of Build Slave RRU - -w USRP -c --eNB --ninja + -w USRP -c --RU --ninja 2 2 diff --git a/ci-scripts/xml_files/physim_deploy_run.xml b/ci-scripts/xml_files/physim_deploy_run.xml new file mode 100644 index 0000000000..63152c1fb5 --- /dev/null +++ b/ci-scripts/xml_files/physim_deploy_run.xml @@ -0,0 +1,37 @@ + + + build-tab + Physical Simulators Check + wrench + + 010201 + + + + + Deploy_Run_PhySim + Deploy and run physical simulator on openshift + + + diff --git a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_build.xml b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_build.xml index c5a912a33d..0ac6bfcc0d 100644 --- a/ci-scripts/xml_files/x2ho_enb_usrp210_band13_build.xml +++ b/ci-scripts/xml_files/x2ho_enb_usrp210_band13_build.xml @@ -42,7 +42,7 @@ Build_eNB Build Slave eNB (USRP) - -w USRP -c --eNB + -w USRP -c --eNB --ninja 1 1 diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 775110a774..e7c2cbc6cd 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -62,6 +62,8 @@ elseif (${RF_BOARD} STREQUAL "OAI_IRIS") endif (${RF_BOARD} STREQUAL "OAI_USRP") +message("RU=${RU}") + pkg_search_module(OPENPGM openpgm-5.1 openpgm-5.2) if(NOT ${OPENPGM_FOUND}) message("PACKAGE openpgm-5.1 is required by binaries such as oaisim: will fail later if this target is built") @@ -318,7 +320,7 @@ if (CUDA_FOUND) set(CUDA_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_FLAGS_PROCESSOR} -Wno-packed-bitfield-compat -fPIC -Wall -fno-strict-aliasing -rdynamic -std=c++11 -D CUDA_FLAG" ) - + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_STRERROR=1 -DHAVE_SOCKET=1 -DHAVE_MEMSET=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_LIBSCTP -D${MKVER} -D CUDA_FLAG" ) @@ -412,7 +414,6 @@ add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace") add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace") add_boolean_option(DEBUG_CONSOLE False "makes debugging easier, disables stdout/stderr buffering") -add_boolean_option(NEW_GTPU True "NEW_GTP") set (OCP_ITTI ${OPENAIR_DIR}/common/utils/ocp_itti) add_library(ITTI @@ -437,7 +438,6 @@ set(asn1_generated_dir ${OPENAIR_BIN_DIR}) set(protoc_call "${OPENAIR_CMAKE}/tools/generate_protobuf") set(protobuf_generated_dir ${OPENAIR_BIN_DIR}) - # RRC ###### set (RRC_ASN1_VERSION "Rel15") @@ -448,15 +448,18 @@ add_definitions(-DLTE_RRC_VERSION=${LTE_RRC_VERSION}) set (RRC_FULL_DIR ${asn1_generated_dir}/RRC_${RRC_ASN1_VERSION}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${RRC_FULL_DIR}" "${RRC_GRAMMAR}" "LTE_" - RESULT_VARIABLE ret) +if (${RU} STREQUAL 0) + execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "LTE_" " " "${RRC_FULL_DIR}" "${RRC_GRAMMAR}" + RESULT_VARIABLE ret) +endif (${RU} STREQUAL 0) + if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${ret}: error") endif (NOT ${ret} STREQUAL 0) file(GLOB rrc_source ${RRC_FULL_DIR}/*.c) add_custom_target ( rrc_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${RRC_FULL_DIR}" "${RRC_GRAMMAR}" "LTE_" + ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "LTE_" " " "${RRC_FULL_DIR}" "${RRC_GRAMMAR}" DEPENDS ${RRC_GRAMMAR} ) @@ -477,20 +480,22 @@ add_definitions(-DNR_RRC_VERSION=${NR_RRC_VERSION}) set (NR_RRC_FULL_DIR ${asn1_generated_dir}/RRC_${NR_RRC_ASN1_VERSION}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" "NR_" "-findirect-choice" - RESULT_VARIABLE ret) + execute_process( + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${ret}: error") endif () file(GLOB nr_rrc_source ${NR_RRC_FULL_DIR}/*.c) file(GLOB nr_rrc_h ${NR_RRC_FULL_DIR}/*.h) + add_custom_target ( nr_rrc_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" "NR_" "-findirect-choice" + ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NR_" "-findirect-choice" "${NR_RRC_FULL_DIR}" "${NR_RRC_GRAMMAR}" DEPENDS ${NR_RRC_GRAMMAR} ) -add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source} +add_library(NR_RRC_LIB ${nr_rrc_h} ${nr_rrc_source} ${OPENAIR2_DIR}/RRC/NR/MESSAGES/asn1_msg.c ) add_dependencies(NR_RRC_LIB nr_rrc_flag) @@ -511,18 +516,21 @@ set(S1AP_ASN_DIR ${S1AP_DIR}/MESSAGES/ASN1/${S1AP_RELEASE}) set(S1AP_C_DIR ${asn1_generated_dir}/S1AP_${S1AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" "S1AP_" -fno-include-deps - RESULT_VARIABLE ret) -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") -endif (NOT ${ret} STREQUAL 0) -file(GLOB S1AP_source ${S1AP_C_DIR}/*.c) +if (${RU} STREQUAL 0) + execute_process( + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "S1AP_" -fno-include-deps "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" + RESULT_VARIABLE ret) + if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${ret}: error") + endif (NOT ${ret} STREQUAL 0) + file(GLOB S1AP_source ${S1AP_C_DIR}/*.c) +endif (${RU} STREQUAL 0) -add_custom_target ( - s1ap_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" "S1AP_" -fno-include-deps - DEPENDS "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" -) + add_custom_target ( + s1ap_flag ALL + ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "S1AP_" -fno-include-deps "${S1AP_C_DIR}" "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" + DEPENDS "${S1AP_ASN_DIR}/${S1AP_ASN_FILES}" + ) add_library(S1AP_LIB ${S1AP_source} @@ -565,8 +573,9 @@ set(NGAP_ASN_DIR ${NGAP_DIR}/MESSAGES/ASN1/ASN1_files) set(NGAP_C_DIR ${asn1_generated_dir}/NGAP_${NGAP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" "NGAP_" -fno-include-deps -findirect-choice - RESULT_VARIABLE ret) +execute_process( + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" + RESULT_VARIABLE ret) if (NOT ${ret} STREQUAL 0) message(FATAL_ERROR "${ret}: error") endif (NOT ${ret} STREQUAL 0) @@ -574,8 +583,8 @@ file(GLOB NGAP_source ${NGAP_C_DIR}/*.c) add_custom_target ( ngap_flag ALL - ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" "NGAP_" -fno-include-deps - DEPENDS "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" + ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "NGAP_" "-fno-include-deps -findirect-choice" "${NGAP_C_DIR}" "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" + DEPENDS "${NGAP_ASN_DIR}/${NGAP_ASN_FILES}" ) add_library(NGAP_LIB @@ -631,17 +640,20 @@ set(M2AP_ASN_DIR ${M2AP_DIR}/MESSAGES/ASN1/${M2AP_RELEASE}) set(M2AP_C_DIR ${asn1_generated_dir}/M2AP_${M2AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" "M2AP_" -fno-include-deps -DEMIT_ASN_DEBUG=1 - RESULT_VARIABLE ret) -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") -endif (NOT ${ret} STREQUAL 0) +if (${RU} STREQUAL 0) + execute_process( + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" + RESULT_VARIABLE ret) + if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${ret}: error") + endif (NOT ${ret} STREQUAL 0) +endif (${RU} STREQUAL 0) file(GLOB M2AP_source ${M2AP_C_DIR}/*.c) add_custom_target ( m2_flag ALL - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" "M2AP_" -fno-include-deps + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M2AP_" "-fno-include-deps -DEMIT_ASN_DEBUG=1" "${M2AP_C_DIR}" "${M2AP_ASN_DIR}/${M2AP_ASN_FILES}" DEPENDS ${M2AP_ASN_DIR}/${M2AP_ASN_FILES} ) @@ -701,17 +713,20 @@ set(M3AP_ASN_DIR ${M3AP_DIR}/MESSAGES/ASN1/${M3AP_RELEASE}) set(M3AP_C_DIR ${asn1_generated_dir}/M3AP_${M3AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" "M3AP_" -fno-include-deps - RESULT_VARIABLE ret) -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") -endif (NOT ${ret} STREQUAL 0) +if (${RU} STREQUAL 0) + execute_process( + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M3AP_" -fno-include-deps "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" + RESULT_VARIABLE ret) + if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${ret}: error") + endif (NOT ${ret} STREQUAL 0) +endif (${RU} STREQUAL 0) file(GLOB M3AP_source ${M3AP_C_DIR}/*.c) add_custom_target ( m3_flag ALL - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" "M3AP_" -fno-include-deps + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "M3AP_" -fno-include-deps "${M3AP_C_DIR}" "${M3AP_ASN_DIR}/${M3AP_ASN_FILES}" DEPENDS ${M3AP_ASN_DIR}/${M3AP_ASN_FILES} ) @@ -755,17 +770,20 @@ add_definitions(-DX2AP_VERSION=${X2AP_VERSION}) set(X2AP_ASN_DIR ${X2AP_DIR}/MESSAGES/ASN1/${X2AP_RELEASE}) set(X2AP_C_DIR ${asn1_generated_dir}/X2AP_${X2AP_RELEASE}) # Warning: if you modify ASN.1 source file to generate new C files, cmake should be re-run instead of make -execute_process(COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" "X2AP_" -fno-include-deps - RESULT_VARIABLE ret) -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "${ret}: error") -endif (NOT ${ret} STREQUAL 0) +if (${RU} STREQUAL 0) + execute_process( + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" + RESULT_VARIABLE ret) + if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "${ret}: error") + endif (NOT ${ret} STREQUAL 0) +endif (${RU} STREQUAL 0) file(GLOB X2AP_source ${X2AP_C_DIR}/*.c) add_custom_target ( x2_flag ALL - COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" "X2AP_" -fno-include-deps + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "X2AP_" -fno-include-deps "${X2AP_C_DIR}" "${X2AP_ASN_DIR}/${X2AP_ASN_FILES}" DEPENDS ${X2AP_ASN_DIR}/${X2AP_ASN_FILES} ) @@ -794,6 +812,7 @@ add_dependencies(X2AP_ENB X2AP_LIB rrc_flag x2_flag) # F1AP ############## +set (F1AP_RELEASE R16) add_list1_option(F1AP_RELEASE R16 "F1AP ASN.1 grammar version" R16) set(F1AP_DIR ${OPENAIR2_DIR}/F1AP) if (${F1AP_RELEASE} STREQUAL "R16") @@ -811,22 +830,28 @@ set(F1AP_ASN_FILES ${F1AP_ASN_DIR}/F1AP-Containers.asn ) -set(F1AP_ASN_GENERATED_C_DIR ${asn1_generated_dir}/F1AP_${ASN1RELDIR}) -message("calling ASN1C_PREFIX=F1AP_ asn1c -gen-PER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES}") -execute_process(COMMAND mkdir -p ${F1AP_ASN_GENERATED_C_DIR} - COMMAND env "ASN1C_PREFIX=F1AP_" asn1c -gen-PER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES} - RESULT_VARIABLE ret - OUTPUT_QUIET - ERROR_QUIET) +if (${RU} STREQUAL 0) + set(F1AP_ASN_GENERATED_C_DIR ${asn1_generated_dir}/F1AP_${ASN1RELDIR}) + message("calling ASN1C_PREFIX=F1AP_ asn1c -gen-PER -no-gen-OER -fcompound-names -no-gen-example -findirect-choice -fno-include-deps -D ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES}") + execute_process( + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES} + RESULT_VARIABLE ret + ) -if (NOT ${ret} STREQUAL 0) - message(FATAL_ERROR "asn1c: error") -endif (NOT ${ret} STREQUAL 0) + if (NOT ${ret} STREQUAL 0) + message(FATAL_ERROR "asn1c: error") + endif (NOT ${ret} STREQUAL 0) -file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c) -add_library(F1AP_LIB - ${F1AP_ASN_GENERATED_C_FILES} -) + add_custom_target ( + f1_flag ALL + COMMAND ${OPENAIR_CMAKE}/tools/make_asn1c_includes.sh "F1AP_" "-findirect-choice -fno-include-deps" ${F1AP_ASN_GENERATED_C_DIR} ${F1AP_ASN_FILES} + DEPENDS ${F1AP_ASN_FILES} + ) + file(GLOB F1AP_ASN_GENERATED_C_FILES ${F1AP_ASN_GENERATED_C_DIR}/*.c) + add_library(F1AP_LIB + ${F1AP_ASN_GENERATED_C_FILES} + ) + add_dependencies (F1AP_LIB f1_flag) include_directories ("${F1AP_ASN_GENERATED_C_DIR}") include_directories ("${F1AP_DIR}") @@ -836,6 +861,7 @@ add_library(F1AP ${F1AP_C_FILES} ) +endif (${RU} STREQUAL 0) # Hardware dependant options ################################### @@ -844,8 +870,6 @@ add_list1_option(NB_ANTENNAS_TX "4" "Number of antennas in transmission" "1" "2" add_list2_option(RF_BOARD "EXMIMO" "RF head type" "None" "OAI_USRP" "OAI_BLADERF" "OAI_LMSSDR" "OAI_SIMU") - - add_list2_option(TRANSP_PRO "None" "Transport protocol type" "None" "ETHERNET") #NOKIA config enhancement set (CONFIG_ROOTDIR @@ -997,7 +1021,7 @@ add_boolean_option(PHY_TX_THREAD False "enable UE_EXPANSION w add_boolean_option(PRE_SCD_THREAD False "enable UE_EXPANSION with max 256 UE") add_boolean_option(UESIM_EXPANSION False "enable UESIM_EXPANSION with max 256 UE") add_boolean_option(ITTI_SIM False "enable itti simulator") -add_boolean_option(RFSIM_NAS False "enable rfsim nas") + ######################## # Include order ########################## @@ -1478,11 +1502,11 @@ add_dependencies(SCHED_UE_LIB rrc_flag) set(SCHED_SRC_NR_UE ${OPENAIR1_DIR}/SCHED_NR_UE/phy_procedures_nr_ue.c ${OPENAIR1_DIR}/SCHED_NR/phy_procedures_nr_common.c - ${OPENAIR1_DIR}/SCHED_NR_UE/fapi_nr_ue_l1.c + ${OPENAIR1_DIR}/SCHED_NR_UE/fapi_nr_ue_l1.c ${OPENAIR1_DIR}/SCHED_NR_UE/phy_frame_config_nr_ue.c ${OPENAIR1_DIR}/SCHED_NR_UE/harq_nr.c ${OPENAIR1_DIR}/SCHED_NR_UE/pucch_uci_ue_nr.c - ${OPENAIR1_DIR}/SCHED_NR_UE/pucch_power_control_ue_nr.c + ${OPENAIR1_DIR}/SCHED_NR_UE/pucch_power_control_ue_nr.c ) add_library(SCHED_NR_UE_LIB ${SCHED_SRC_NR_UE}) @@ -1642,7 +1666,6 @@ set(PHY_SRC_COMMON ${OPENAIR1_DIR}/PHY/CODING/viterbi_lte.c ${OPENAIR1_DIR}/PHY/INIT/init_top.c ${OPENAIR1_DIR}/PHY/INIT/lte_parms.c - ${OPENAIR1_DIR}/PHY/INIT/lte_param_init.c ${OPENAIR1_DIR}/PHY/TOOLS/cadd_vv.c ${OPENAIR1_DIR}/PHY/TOOLS/dfts_load.c ${OPENAIR1_DIR}/PHY/TOOLS/log2_approx.c @@ -1793,7 +1816,7 @@ set(PHY_SRC_UE ${PHY_POLARSRC} ${PHY_SMALLBLOCKSRC} ${PHY_NR_CODINGIF} - ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/pucch_rx.c + ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/pucch_rx.c ${OPENAIR1_DIR}/PHY/NR_TRANSPORT/nr_uci_tools_common.c ) set(PHY_NR_UE_SRC @@ -1972,7 +1995,7 @@ set(NR_RLC_SRC ${OPENAIR2_DIR}/LAYER2/nr_rlc/nr_rlc_sdu.c ${OPENAIR2_DIR}/LAYER2/nr_rlc/nr_rlc_ue_manager.c ) - + set(NR_PDCP_SRC ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_oai_api.c ${OPENAIR2_DIR}/LAYER2/nr_pdcp/nr_pdcp_ue_manager.c @@ -2005,7 +2028,7 @@ set(L2_SRC ${RRC_DIR}/L2_interface_common.c ${RRC_DIR}/L2_interface_ue.c ) - + set(L2_RRC_SRC ${OPENAIR2_DIR}/LAYER2/openair2_proc.c # ${RRC_DIR}/rrc_UE.c @@ -2051,14 +2074,14 @@ set(L2_SRC_UE ${RRC_DIR}/L2_interface_common.c ${RRC_DIR}/L2_interface_ue.c ) - + set(L2_RRC_SRC_UE ${RRC_DIR}/rrc_UE.c ${RRC_DIR}/rrc_common.c ${RRC_DIR}/L2_interface_common.c ${RRC_DIR}/L2_interface_ue.c - ) - + ) + set(NR_L2_SRC_UE ${NR_RLC_SRC} ${NR_PDCP_SRC} @@ -2116,7 +2139,7 @@ set (MAC_SRC_UE ${MAC_DIR}/rar_tools_ue.c ${MAC_DIR}/config_ue.c ) - + set (MAC_NR_SRC_UE ${NR_UE_PHY_INTERFACE_DIR}/NR_IF_Module.c ${NR_UE_MAC_DIR}/config_ue.c @@ -2188,6 +2211,7 @@ add_library(L2_NR ${MAC_NR_SRC} ${GNB_APP_SRC} ) +target_compile_definitions(L2_NR PUBLIC NEW_GTPU) add_library(L2_LTE_NR ${L2_RRC_SRC} @@ -2195,7 +2219,8 @@ add_library(L2_LTE_NR ${ENB_APP_SRC} ${MCE_APP_SRC} ) - +target_compile_definitions(L2_LTE_NR PUBLIC NEW_GTPU) + add_dependencies(L2_NR rrc_flag nr_rrc_flag s1ap_flag x2_flag) add_library(L2_UE @@ -2242,6 +2267,7 @@ add_library (GTPV1U_OCP ${RRC_DIR}/rrc_eNB_GTPV1U.c ${OPENAIR3_DIR}/ocp-gtpu/gtp_itf.cpp ) +target_compile_definitions(GTPV1U_OCP PUBLIC NEW_GTPU) add_dependencies(GTPV1U_OCP rrc_flag) include_directories(${OPENAIR3_DIR}/ocp-gtp) @@ -2260,12 +2286,6 @@ set (NR_GTPV1U_SRC add_library(NR_GTPV1U ${NR_GTPV1U_SRC}) add_dependencies(NR_GTPV1U rrc_flag) -if (${NEW_GTPU}) -set(GTPV1U GTPV1U_OCP) -else() -set(GTPV1U NR_GTPV1U) -endif() - set (MME_APP_SRC ${OPENAIR3_DIR}/MME_APP/mme_app.c ${OPENAIR3_DIR}/MME_APP/mme_config.c @@ -2443,108 +2463,6 @@ set (libnas_utils_OBJS ${NAS_SRC}COMMON/UTIL/OctetString.c ) -if(NAS_UE) - set(libnas_ue_api_OBJS - ${NAS_SRC}UE/API/USER/at_command.c - ${NAS_SRC}UE/API/USER/at_error.c - ${NAS_SRC}UE/API/USER/at_response.c - ${NAS_SRC}UE/API/USER/user_api.c - ${NAS_SRC}UE/API/USER/user_indication.c - ${NAS_SRC}UE/API/USIM/aka_functions.c - ${NAS_SRC}UE/API/USIM/usim_api.c - ) - set(libnas_ue_emm_OBJS - ${NAS_SRC}UE/EMM/Attach.c - ${NAS_SRC}UE/EMM/Authentication.c - ${NAS_SRC}UE/EMM/Detach.c - ${NAS_SRC}UE/EMM/emm_main.c - ${NAS_SRC}UE/EMM/EmmStatusHdl.c - ${NAS_SRC}UE/EMM/Identification.c - ${NAS_SRC}UE/EMM/IdleMode.c - ${NAS_SRC}UE/EMM/LowerLayer.c - ${NAS_SRC}UE/EMM/SecurityModeControl.c - ${NAS_SRC}UE/EMM/ServiceRequestHdl.c - ${NAS_SRC}UE/EMM/TrackingAreaUpdate.c - ) - set(libnas_ue_emm_sap_OBJS - ${NAS_SRC}UE/EMM/SAP/emm_as.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredAttachNeeded.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredAttemptingToAttach.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregistered.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredInitiated.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredLimitedService.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredNoCellAvailable.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredNoImsi.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredNormalService.c - ${NAS_SRC}UE/EMM/SAP/EmmDeregisteredPlmnSearch.c - ${NAS_SRC}UE/EMM/SAP/emm_esm.c - ${NAS_SRC}UE/EMM/SAP/emm_fsm.c - ${NAS_SRC}UE/EMM/SAP/EmmNull.c - ${NAS_SRC}UE/EMM/SAP/emm_recv.c - ${NAS_SRC}UE/EMM/SAP/emm_reg.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredAttemptingToUpdate.c - ${NAS_SRC}UE/EMM/SAP/EmmRegistered.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredImsiDetachInitiated.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredInitiated.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredLimitedService.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredNoCellAvailable.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredNormalService.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredPlmnSearch.c - ${NAS_SRC}UE/EMM/SAP/EmmRegisteredUpdateNeeded.c - ${NAS_SRC}UE/EMM/SAP/emm_sap.c - ${NAS_SRC}UE/EMM/SAP/emm_send.c - ${NAS_SRC}UE/EMM/SAP/EmmServiceRequestInitiated.c - ${NAS_SRC}UE/EMM/SAP/EmmTrackingAreaUpdatingInitiated.c - ) - set (libnas_ue_esm_OBJS - ${NAS_SRC}UE/ESM/DedicatedEpsBearerContextActivation.c - ${NAS_SRC}UE/ESM/DefaultEpsBearerContextActivation.c - ${NAS_SRC}UE/ESM/EpsBearerContextDeactivation.c - ${NAS_SRC}UE/ESM/esm_ebr.c - ${NAS_SRC}UE/ESM/esm_ebr_context.c - ${NAS_SRC}UE/ESM/esm_ip.c - ${NAS_SRC}UE/ESM/esm_main.c - ${NAS_SRC}UE/ESM/esm_pt.c - ${NAS_SRC}UE/ESM/EsmStatusHdl.c - ${NAS_SRC}UE/ESM/PdnConnectivity.c - ${NAS_SRC}UE/ESM/PdnDisconnect.c - ) - set(libnas_ue_esm_sap_OBJS - ${NAS_SRC}UE/ESM/SAP/esm_recv.c - ${NAS_SRC}UE/ESM/SAP/esm_send.c - ${NAS_SRC}UE/ESM/SAP/esm_sap.c - ) - add_library(LIB_NAS_UE - ${NAS_SRC}UE/nas_itti_messaging.c - ${NAS_SRC}UE/nas_network.c - ${NAS_SRC}UE/nas_parser.c - ${NAS_SRC}UE/nas_proc.c - ${NAS_SRC}UE/nas_user.c - ${libnas_api_OBJS} - ${libnas_ue_api_OBJS} - ${libnas_emm_msg_OBJS} - ${libnas_esm_msg_OBJS} - ${libnas_ies_OBJS} - ${libnas_utils_OBJS} - ${libnas_ue_emm_OBJS} - ${libnas_ue_emm_sap_OBJS} - ${libnas_ue_esm_OBJS} - ${libnas_ue_esm_sap_OBJS} - ) - add_dependencies(LIB_NAS_UE rrc_flag) - set(NAS_UE_LIB LIB_NAS_UE) - - include_directories(${NAS_SRC}UE) - include_directories(${NAS_SRC}UE/API/USER) - include_directories(${NAS_SRC}UE/API/USIM) - include_directories(${NAS_SRC}UE/EMM) - include_directories(${NAS_SRC}UE/EMM/SAP) - include_directories(${NAS_SRC}UE/ESM) - include_directories(${NAS_SRC}UE/ESM/SAP) -endif() - - -#if(ITTI_SIM OR RFSIM_NAS) set(libnas_ue_api_OBJS ${NAS_SRC}UE/API/USER/at_command.c ${NAS_SRC}UE/API/USER/at_error.c @@ -2662,6 +2580,27 @@ endif() add_dependencies(LIB_NAS_SIMUE rrc_flag) set(NAS_SIM_LIB LIB_NAS_SIMUE) + add_library(LIB_NAS_UE + ${NAS_SRC}UE/nas_itti_messaging.c + ${NAS_SRC}UE/nas_network.c + ${NAS_SRC}UE/nas_parser.c + ${NAS_SRC}UE/nas_proc.c + ${NAS_SRC}UE/nas_user.c + ${libnas_api_OBJS} + ${libnas_ue_api_OBJS} + ${libnas_emm_msg_OBJS} + ${libnas_esm_msg_OBJS} + ${libnas_ies_OBJS} + ${libnas_utils_OBJS} + ${libnas_ue_emm_OBJS} + ${libnas_ue_emm_sap_OBJS} + ${libnas_ue_esm_OBJS} + ${libnas_ue_esm_sap_OBJS} + ) + add_dependencies(LIB_NAS_UE rrc_flag) + set(NAS_UE_LIB LIB_NAS_UE) + + include_directories(${NAS_SRC}NR_UE) include_directories(${NAS_SRC}UE) include_directories(${NAS_SRC}UE/API/USER) @@ -2670,7 +2609,6 @@ endif() include_directories(${NAS_SRC}UE/EMM/SAP) include_directories(${NAS_SRC}UE/ESM) include_directories(${NAS_SRC}UE/ESM/SAP) -#endif() # nbiot add_definitions("-DNUMBER_OF_UE_MAX_NB_IoT=16") @@ -2737,7 +2675,7 @@ add_library(SIMU_COMMON # Simulation library ########################## -set (SIMUSRC +set (SIMUSRC ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_channel.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/multipath_tv_channel.c @@ -2800,7 +2738,7 @@ add_library(nrscope MODULE ${XFORMS_SOURCE_NR}) target_link_libraries(nrscope ${XFORMS_LIBRARIES}) -add_library(rfsimulator MODULE +add_library(rfsimulator MODULE ${OPENAIR_TARGETS}/ARCH/rfsimulator/simulator.c ${OPENAIR_TARGETS}/ARCH/rfsimulator/apply_channelmod.c ${OPENAIR_TARGETS}/ARCH/rfsimulator/new_channel_sim.c @@ -2808,7 +2746,7 @@ add_library(rfsimulator MODULE ) target_link_libraries(rfsimulator SIMU_COMMON ${ATLAS_LIBRARIES}) -add_library(oai_iqplayer MODULE +add_library(oai_iqplayer MODULE ${OPENAIR_TARGETS}/ARCH/iqplayer/iqplayer_lib.c ) set(CMAKE_MODULE_PATH "${OPENAIR_DIR}/cmake_targets/tools/MODULES" "${CMAKE_MODULE_PATH}") @@ -2878,7 +2816,7 @@ add_executable(measurement_display ${OPENAIR_DIR}/common/utils/threadPool/measurement_display.c) target_link_libraries (measurement_display minimal_lib) -add_executable(test5Gnas +add_executable(test5Gnas ${OPENAIR_DIR}/openair3/TEST/test5Gnas.c ) target_link_libraries (test5Gnas LIB_5GNAS_GNB CONFIG_LIB minimal_lib ) @@ -2903,12 +2841,15 @@ add_executable(lte-softmodem ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c ${OPENAIR2_DIR}/RRC/NAS/nas_config.c ${OPENAIR2_DIR}/RRC/NAS/rb_config.c + ${OPENAIR2_DIR}/F1AP/dummy_enb.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/multicast_link.c ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/socket.c ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c + ${OPENAIR_DIR}/common/utils/lte/ue_power.c + ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${XFORMSINTERFACE_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} @@ -2919,11 +2860,11 @@ add_dependencies(lte-softmodem rrc_flag s1ap_flag x2_flag oai_iqplayer) target_link_libraries (lte-softmodem -Wl,--start-group - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB ${GTPV1U} SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB NR_GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} -Wl,--end-group z dl) - + target_link_libraries (lte-softmodem ${LIBXML2_LIBRARIES}) target_link_libraries (lte-softmodem pthread m ${CONFIG_LIB} rt crypt ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} sctp ${PROTOBUF_LIB} ${CMAKE_DL_LIBS} ${LIBYAML_LIBRARIES}) target_link_libraries (lte-softmodem ${LIB_LMS_LIBRARIES}) @@ -2950,6 +2891,8 @@ add_executable(ocp-enb ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c + ${OPENAIR_DIR}/common/utils/lte/ue_power.c + ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${XFORMSINTERFACE_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} @@ -2960,7 +2903,7 @@ add_dependencies(ocp-enb rrc_flag s1ap_flag x2_flag oai_iqplayer coding params_l target_link_libraries (ocp-enb -Wl,--start-group - RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB ${GTPV1U} SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB + RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB NR_GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB SCHED_RU_LIB PHY_COMMON PHY PHY_RU LFDS L2 L2_LTE NFAPI_COMMON_LIB NFAPI_LIB MISC_NFAPI_LTE_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB LFDS7 SIMU_COMMON ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} ${FSPT_MSG_LIB} ${PROTO_AGENT_LIB} -Wl,--end-group z dl) @@ -2994,6 +2937,33 @@ target_link_libraries(du_test ${PROTO_AGENT_LIB} pthread UTIL ${T_LIB} dl ${ITTI_LIB} ) +add_executable(oairu + ${OPENAIR_TARGETS}/RT/USER/lte-ru.c + ${OPENAIR_TARGETS}/RT/USER/ru_control.c + ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c + ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c + ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c + ${OPENAIR_DIR}/executables/softmodem-common.c + ${OPENAIR_DIR}/openair1/SCHED/phy_procedures_lte_common.c + ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c + ${OPENAIR_DIR}/executables/main_ru.c + ${T_SOURCE} + ${OPENAIR_DIR}/common/utils/LOG/log.c + ${CONFIG_SOURCES} + ${OPENAIR_DIR}/common/utils/utils.c + ${OPENAIR_DIR}/common/utils/system.c + ${OPENAIR_DIR}/common/utils/lte/prach_utils.c + ${SHLIB_LOADER_SOURCES} +) +target_link_libraries (oairu + -Wl,--start-group + SCHED_RU_LIB + PHY_COMMON PHY_RU + -Wl,--end-group z dl) + +target_link_libraries (oairu pthread m ${CONFIG_LIB} rt ${CMAKE_DL_LIBS} ${T_LIB}) + + # lte-uesoftmodem is UE implementation ####################################### @@ -3002,9 +2972,6 @@ add_executable(lte-uesoftmodem ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-uesoftmodem.c ${OPENAIR_DIR}/executables/softmodem-common.c - ${OPENAIR_TARGETS}/RT/USER/lte-ru.c - ${OPENAIR_TARGETS}/RT/USER/ru_control.c - ${OPENAIR_TARGETS}/RT/USER/rfsim.c ${OPENAIR_TARGETS}/COMMON/create_tasks_ue.c ${OPENAIR_TARGETS}/ARCH/COMMON/common_lib.c ${OPENAIR_TARGETS}/ARCH/COMMON/record_player.c @@ -3016,6 +2983,8 @@ add_executable(lte-uesoftmodem ${OPENAIR3_DIR}/NAS/UE/nas_ue_task.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c + ${OPENAIR_DIR}/common/utils/lte/ue_power.c + ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${XFORMSINTERFACE_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} @@ -3031,7 +3000,7 @@ target_link_libraries (lte-uesoftmodem -Wl,--start-group RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP F1AP_LIB - ${GTPV1U} SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON + NR_GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_UE PHY_RU LFDS L2_UE L2_LTE LFDS7 SIMU_COMMON SIMU NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_LTE_LIB ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${ATLAS_LIBRARIES} -Wl,--end-group z dl) @@ -3062,6 +3031,8 @@ add_executable(nr-softmodem ${OPENAIR1_DIR}/SIMULATION/ETH_TRANSPORT/netlink_init.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c + ${OPENAIR_DIR}/common/utils/lte/ue_power.c + ${OPENAIR_DIR}/common/utils/lte/prach_utils.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${XFORMSINTERFACE_SOURCE} ${T_SOURCE} @@ -3070,10 +3041,11 @@ add_executable(nr-softmodem ${OPENAIR2_DIR}/ENB_APP/flexran_agent_ran_api_to_fix.c ) +target_compile_definitions(nr-softmodem PUBLIC NEW_GTPU) target_link_libraries (nr-softmodem -Wl,--start-group - UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS ${GTPV1U} SECU_CN SECU_OSA - ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB + UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U_OCP SECU_CN SECU_OSA + ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB} -Wl,--end-group z dl) @@ -3111,8 +3083,8 @@ add_executable(ocp-gnb target_link_libraries (ocp-gnb -Wl,--start-group - UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS ${GTPV1U} SECU_CN SECU_OSA - ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB + UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U_OCP SECU_CN SECU_OSA + ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB SIMU_COMMON -Wl,--end-group z dl) @@ -3158,7 +3130,9 @@ target_link_libraries (nr-uesoftmodem RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_RU_LIB SCHED_UE_LIB SCHED_NR_UE_LIB PHY_COMMON PHY_NR_COMMON PHY_UE PHY_NR_UE PHY_RU LFDS NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_USER_LIB MISC_NFAPI_NR_LIB S1AP_LIB S1AP_ENB - ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} LIB_5GNAS_GNB LIB_NAS_SIMUE + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} + NFAPI_USER_LIB S1AP_LIB S1AP_ENB + ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} LFDS7 ${ATLAS_LIBRARIES} LIB_5GNAS_GNB LIB_NAS_SIMUE ${NAS_SIM_LIB} -Wl,--end-group z dl) target_link_libraries (nr-uesoftmodem ${LIBXML2_LIBRARIES}) @@ -3188,7 +3162,7 @@ target_link_libraries (dlsim_tm4 pthread m rt ${CONFIG_LIB} ${ATLAS_LIBRARIES} ${T_LIB} ) -add_executable(rftest +add_executable(rftest ${OPENAIR_DIR}/openair1/PHY/TOOLS/calibration_test.c ${OPENAIR_DIR}/openair1/PHY/TOOLS/calibration_scope.c ${OPENAIR_DIR}/common/utils/system.c @@ -3199,7 +3173,7 @@ add_executable(rftest ) target_link_libraries(rftest minimal_lib PHY_NR_COMMON pthread dl m forms ${T_LIB} ) -add_executable(polartest +add_executable(polartest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/polartest.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c @@ -3212,7 +3186,7 @@ target_link_libraries(polartest m pthread ${ATLAS_LIBRARIES} dl ) -add_executable(smallblocktest +add_executable(smallblocktest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/smallblocktest.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c @@ -3230,17 +3204,17 @@ target_link_libraries(smallblocktest # temp_C_flag = CMAKE_C_FLAGS #set(CMAKE_C_FLAGS " ") -set (TEMP_C_FLAG ${CMAKE_C_FLAGS}) +set (TEMP_C_FLAG ${CMAKE_C_FLAGS}) set (CMAKE_C_FLAGS ${CUDA_CMAKE_C_FLAGS}) -set (TEMP_CXX_FLAG ${CMAKE_CXX_FLAGS}) +set (TEMP_CXX_FLAG ${CMAKE_CXX_FLAGS}) set (CMAKE_CXX_FLAGS ${CUDA_CMAKE_CXX_FLAGS}) if (CUDA_FOUND) ################################################### -# For CUDA library +# For CUDA library ################################################### - - CUDA_ADD_LIBRARY(LDPC_CU + + CUDA_ADD_LIBRARY(LDPC_CU ${OPENAIR1_DIR}/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.cu ) CUDA_ADD_CUFFT_TO_TARGET(LDPC_CU) @@ -3250,14 +3224,14 @@ if (CUDA_FOUND) ${SHLIB_LOADER_SOURCES} ) target_link_libraries(ldpctest -ldl - -Wl,--start-group - LDPC_CU UTIL SIMU PHY_NR CONFIG_LIB + -Wl,--start-group + LDPC_CU UTIL SIMU PHY_NR CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} dl ) else (CUDA_FOUND) - add_executable(ldpctest + add_executable(ldpctest ${PHY_NR_CODINGIF} ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c ${T_SOURCE} @@ -3269,21 +3243,21 @@ set (CMAKE_C_FLAGS ${TEMP_C_FLAG}) set (CMAKE_CXX_FLAGS ${TEMP_CXX_FLAG}) -# add_executable(ldpctest +# add_executable(ldpctest # ${PHY_NR_CODINGIF} # ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c # ${T_SOURCE} # ${SHLIB_LOADER_SOURCES} # ) -add_dependencies( ldpctest ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) +add_dependencies( ldpctest ldpc_orig ldpc_optim ldpc_optim8seg ldpc ) target_link_libraries(ldpctest -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_NR PHY_COMMON PHY_NR_COMMON CONFIG_LIB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} dl ) -add_executable(nr_dlschsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c +add_executable(nr_dlschsim + ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/utils.c @@ -3292,13 +3266,13 @@ add_executable(nr_dlschsim ${T_SOURCE} ${SHLIB_LOADER_SOURCES} ) -target_link_libraries(nr_dlschsim +target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB CONFIG_LIB MAC_NR_COMMON -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} dl ) -add_executable(nr_pbchsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c +add_executable(nr_pbchsim + ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/utils.c @@ -3313,8 +3287,8 @@ target_link_libraries(nr_pbchsim ) #PUCCH ---> Prashanth -add_executable(nr_pucchsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c +add_executable(nr_pucchsim + ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pucchsim.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/system.c @@ -3342,7 +3316,7 @@ add_executable(nr_dlsim ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES} - ) + ) target_link_libraries(nr_dlsim -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN NGAP_GNB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} ${OPENSSL_LIBRARIES} dl @@ -3350,7 +3324,7 @@ target_link_libraries(nr_dlsim target_compile_definitions(nr_dlsim PUBLIC -DPHYSICAL_SIMULATOR) add_executable(nr_prachsim - ${OPENAIR1_DIR}/SIMULATION/NR_PHY/prachsim.c + ${OPENAIR1_DIR}/SIMULATION/NR_PHY/prachsim.c ${OPENAIR_DIR}/common/utils/utils.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c @@ -3362,7 +3336,7 @@ add_executable(nr_prachsim ${UTIL_SRC} ${T_SOURCE} ${SHLIB_LOADER_SOURCES}) -target_link_libraries(nr_prachsim +target_link_libraries(nr_prachsim -Wl,--start-group UTIL SIMU_COMMON SIMU PHY_COMMON PHY_NR_COMMON PHY_NR PHY_RU PHY_NR_UE MAC_NR_COMMON SCHED_NR_LIB SCHED_NR_UE_LIB MAC_NR MAC_UE_NR MAC_NR_COMMON RRC_LIB NR_RRC_LIB CONFIG_LIB L2_LTE_NR L2_NR HASHTABLE X2AP_ENB X2AP_LIB SECU_CN NGAP_GNB -Wl,--end-group m pthread ${ATLAS_LIBRARIES} ${T_LIB} ${ITTI_LIB} ${OPENSSL_LIBRARIES} dl) @@ -3402,13 +3376,16 @@ target_link_libraries(nr_ulsim target_compile_definitions(nr_ulsim PUBLIC -DPHYSICAL_SIMULATOR) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) - + add_executable(${myExe} ${OPENAIR1_DIR}/SIMULATION/LTE_PHY/${myExe}.c ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c ${OPENAIR_DIR}/common/utils/backtrace.c ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/utils.c + ${OPENAIR_DIR}/common/utils/lte/ue_power.c + ${OPENAIR_DIR}/common/utils/lte/prach_utils.c + ${OPENAIR1_DIR}/PHY/INIT/lte_param_init.c ${XFORMS_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} @@ -3419,7 +3396,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr -Wl,--start-group SIMU_COMMON SIMU UTIL SCHED_LIB SCHED_RU_LIB SCHED_UE_LIB PHY_COMMON PHY_NR_COMMON PHY PHY_UE PHY_RU LFDS ${ITTI_LIB} LFDS7 -Wl,--end-group pthread m rt ${CONFIG_LIB} ${ATLAS_LIBRARIES} ${XFORMS_LIBRARIES} ${T_LIB} dl ) - + endforeach(myExe) add_executable(test_epc_generate_scenario @@ -3431,7 +3408,7 @@ add_executable(test_epc_generate_scenario ${OPENAIR3_DIR}/S1AP/s1ap_eNB_defs.h ) target_link_libraries (test_epc_generate_scenario - -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP ${GTPV1U} LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP NR_GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY LFDS ${ITTI_LIB} ${MSC_LIB} L2 -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) add_executable(test_epc_play_scenario @@ -3450,7 +3427,7 @@ add_executable(test_epc_play_scenario ) target_include_directories(test_epc_play_scenario PUBLIC /usr/local/share/asn1c) target_link_libraries (test_epc_play_scenario - -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP ${GTPV1U} LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} + -Wl,--start-group RRC_LIB S1AP_LIB X2AP_LIB X2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP NR_GTPV1U LIB_NAS_UE SECU_CN UTIL HASHTABLE SCTP_CLIENT MME_APP UDP SCHED_LIB PHY_NR_COMMON PHY_COMMON PHY PHY_UE LFDS ${ITTI_LIB} ${MSC_LIB} -Wl,--end-group pthread m rt crypt sctp ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} ${CONFIG_LIB} ) @@ -3482,13 +3459,13 @@ endforeach(myExe) if (${T_TRACER}) foreach(i #all "add_executable" definitions (except tests, rb_tool, updatefw) - lte-softmodem lte-uesoftmodem nr-softmodem + lte-softmodem lte-uesoftmodem nr-softmodem nr-uesoftmodem dlsim dlsim_tm4 dlsim_tm7 nr-ittisim ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim nr_ulsim nr_dlsim nr_dlschsim nr_pbchsim nr_pucchsim nr_ulschsim ldpctest polartest smallblocktest cu_test du_test #all "add_library" definitions - ITTI RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP + ITTI RRC_LIB NR_RRC_LIB S1AP_LIB S1AP_ENB X2AP_LIB X2AP_ENB M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB F1AP_LIB F1AP params_libconfig oai_exmimodevif oai_usrpdevif oai_bladerfdevif oai_lmssdrdevif oai_iqplayer oai_eth_transpro oai_mobipass tcp_bridge tcp_bridge_oai coding FLPT_MSG ASYNC_IF FLEXRAN_AGENT HASHTABLE MSC UTIL OMG_SUMO @@ -3496,7 +3473,7 @@ if (${T_TRACER}) NFAPI_COMMON_LIB NFAPI_LIB NFAPI_PNF_LIB NFAPI_VNF_LIB NFAPI_USER_LIB PHY_COMMON PHY PHY_UE PHY_NR PHY_NR_COMMON PHY_NR_UE PHY_RU PHY_MEX L2 L2_LTE L2_NR L2_LTE_NR L2_UE NR_L2_UE L2_UE_LTE_NR MAC_NR_COMMON MAC_NR MAC_UE_NR NGAP_GNB - CN_UTILS ${GTPV1U} SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB + CN_UTILS NR_GTPV1U GTPV1U_OCP SCTP_CLIENT MME_APP UDP LIB_NAS_UE NB_IoT LFDS LFDS7 SIMU_COMMON SIMU SIMU_ETH OPENAIR0_LIB ldpc_orig ldpc_optim ldpc_optim8seg ldpc PROTO_AGENT dfts) if (TARGET ${i}) add_dependencies(${i} generate_T) @@ -3593,16 +3570,20 @@ add_executable(nr-ittisim ${OPENAIR_DIR}/common/utils/system.c ${OPENAIR_DIR}/common/utils/nr/nr_common.c ${OPENAIR_DIR}/common/utils/threadPool/thread-pool.c + ${OPENAIR_DIR}/common/utils/lte/ue_power.c + ${OPENAIR_DIR}/common/utils/lte/prach_utils.c + ${OPENAIR2_DIR}/ENB_APP/flexran_agent_ran_api_to_fix.c ${XFORMSINTERFACE_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} ${SHLIB_LOADER_SOURCES} ) +target_compile_definitions(nr-ittisim PUBLIC NEW_GTPU) target_link_libraries (nr-ittisim -Wl,--start-group - UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS ${GTPV1U} SECU_CN SECU_OSA - ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_SIM_LIB} RRC_LIB NR_RRC_LIB + UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB SCHED_RU_LIB SCHED_NR_LIB PHY_NR PHY PHY_COMMON PHY_NR_COMMON PHY_RU LFDS GTPV1U_OCP SECU_CN SECU_OSA + ${ITTI_LIB} ${FLPT_MSG_LIB} ${ASYNC_IF_LIB} ${FLEXRAN_AGENT_LIB} LFDS7 ${MSC_LIB} ${RAL_LIB} ${NAS_SIM_LIB} RRC_LIB NR_RRC_LIB NGAP_LIB NGAP_GNB S1AP_LIB S1AP_ENB L2_LTE_NR L2_NR MAC_NR_COMMON NFAPI_COMMON_LIB NFAPI_LIB NFAPI_VNF_LIB NFAPI_PNF_LIB NFAPI_USER_LIB X2AP_LIB X2AP_ENB F1AP_LIB F1AP M2AP_LIB M2AP_ENB M3AP_LIB M3AP_ENB ${PROTO_AGENT_LIB} ${FSPT_MSG_LIB} PHY_NR_UE SCHED_NR_UE_LIB NR_L2_UE diff --git a/cmake_targets/at_commands/CMakeLists.txt b/cmake_targets/at_commands/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/README.txt b/cmake_targets/autotests/README.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/core.py b/cmake_targets/autotests/core.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/log.py b/cmake_targets/autotests/log.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/openair.py b/cmake_targets/autotests/openair.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/templates/index.html b/cmake_targets/autotests/templates/index.html old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/templates/testcase_report.html b/cmake_targets/autotests/templates/testcase_report.html old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/test_case_list.xml b/cmake_targets/autotests/test_case_list.xml old mode 100644 new mode 100755 index b0511f63cc..29257e482f --- a/cmake_targets/autotests/test_case_list.xml +++ b/cmake_targets/autotests/test_case_list.xml @@ -1099,8 +1099,9 @@ (Test14: 3 PTRS, 8 Interpolated Symbols), (Test15: 6 PTRS, 5 Interpolated Symbols), (Test16: 11 PTRS, 0 Interpolated Symbols), - (Test17: 2 DMRS Symbols), - (Test18: 3 DMRS Symbols) + (Test17: Mapping type A, 2 DMRS Symbols), + (Test18: Mapping type A, 3 DMRS Symbols), + (Test19: Mapping type B, 4 DMRS Symbols) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1124,8 +1125,9 @@ -n100 -s5 -T 2 1 2 -n100 -s5 -T 2 0 4 -n100 -s2 -U 2 0 1 - -n100 -s2 -U 2 0 2 - nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 nr_dlsim.test12 nr_dlsim.test13 nr_dlsim.test14 nr_dlsim.test15 nr_dlsim.test16 nr_dlsim.test17 nr_dlsim.test18 + -n100 -s2 -U 2 0 2 + -n100 -s2 -U 2 1 3 + nr_dlsim.test1 nr_dlsim.test2 nr_dlsim.test3 nr_dlsim.test4 nr_dlsim.test5 nr_dlsim.test6 nr_dlsim.test7 nr_dlsim.test8 nr_dlsim.test9 nr_dlsim.test10 nr_dlsim.test11 nr_dlsim.test12 nr_dlsim.test13 nr_dlsim.test14 nr_dlsim.test15 nr_dlsim.test16 nr_dlsim.test17 nr_dlsim.test18 nr_dlsim.test19 PDSCH test OK segmentation fault|assertion|exiting|fatal 3 @@ -1287,15 +1289,16 @@ (Test3: MCS 28 50 PRBs), (Test4: MCS 9 217 PRBs), (Test5: MCS 9 273 PRBs), - (Test6: DMRS Type A, 3 DMRS, 4 PTRS, 5 Interpolated Symbols), - (Test7: DMRS Type B, 3 DMRS, 2 PTRS, 7 Interpolated Symbols), - (Test8: DMRS Type B, 3 DMRS, 2 PTRS, 3 Interpolated Symbols), - (Test9: SC-FDMA, 50 PRBs), - (Test10: SC-FDMA, 75 PRBs), - (Test11: SC-FDMA, 216 PRBs), - (Test12: SC-FDMA, 273 PRBs), - (Test13: SC-FDMA, 3 DMRS), - (Test14: MCS 16 50 PRBs 2 RX_Antenna) + (Test6: DMRS Type A, 2 DMRS Symbols), + (Test7: DMRS Type A, 3 DMRS, 4 PTRS, 5 Interpolated Symbols), + (Test8: DMRS Type B, 3 DMRS, 2 PTRS, 7 Interpolated Symbols), + (Test9: DMRS Type B, 3 DMRS, 2 PTRS, 3 Interpolated Symbols), + (Test10: SC-FDMA, 50 PRBs), + (Test11: SC-FDMA, 75 PRBs), + (Test12: SC-FDMA, 216 PRBs), + (Test13: SC-FDMA, 273 PRBs), + (Test14: SC-FDMA, 3 DMRS), + (Test15: MCS 16 50 PRBs 2 RX_Antenna) $OPENAIR_DIR/cmake_targets/build_oai --phy_simulators -c @@ -1307,6 +1310,7 @@ -n100 -m28 -s20 -n100 -m9 -R217 -r217 -s5 -n100 -m9 -R273 -r273 -s5 + -n100 -s5 -U 2 0 1 -n100 -s5 -T 2 1 2 -U 2 0 2 -n100 -s5 -T 2 2 2 -U 2 1 2 -n100 -s5 -a4 -b8 -T 2 1 2 -U 2 1 3 @@ -1317,7 +1321,7 @@ -n100 -s2 -Z -U 2 0 2 -n100 -m16 -s10 -z2 - nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5 nr_ulsim.test6 nr_ulsim.test7 nr_ulsim.test8 nr_ulsim.test9 nr_ulsim.test10 nr_ulsim.test11 nr_ulsim.test12 nr_ulsim.test13 nr_ulsim.test14 + nr_ulsim.test1 nr_ulsim.test2 nr_ulsim.test3 nr_ulsim.test4 nr_ulsim.test5 nr_ulsim.test6 nr_ulsim.test7 nr_ulsim.test8 nr_ulsim.test9 nr_ulsim.test10 nr_ulsim.test11 nr_ulsim.test12 nr_ulsim.test13 nr_ulsim.test14 nr_ulsim.test15 PUSCH test OK segmentation fault|assertion|exiting|fatal 3 diff --git a/cmake_targets/autotests/testsuite_ue_noS1.xml b/cmake_targets/autotests/testsuite_ue_noS1.xml old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/testsuite_ue_noS1_TCL.xml b/cmake_targets/autotests/testsuite_ue_noS1_TCL.xml old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/tools/lib_autotest.py b/cmake_targets/autotests/tools/lib_autotest.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/tools/lib_autotest_analyser.py b/cmake_targets/autotests/tools/lib_autotest_analyser.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/tools/wdial.bandrich.conf b/cmake_targets/autotests/tools/wdial.bandrich.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/3276.txt b/cmake_targets/autotests/v2/actions/3276.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/alu_epc.bash b/cmake_targets/autotests/v2/actions/alu_epc.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/alu_epc_stop.bash b/cmake_targets/autotests/v2/actions/alu_epc_stop.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/alu_hss.bash b/cmake_targets/autotests/v2/actions/alu_hss.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/bandrich.txt b/cmake_targets/autotests/v2/actions/bandrich.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/client_tcp.bash b/cmake_targets/autotests/v2/actions/client_tcp.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/client_udp.bash b/cmake_targets/autotests/v2/actions/client_udp.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/clone_repository.bash b/cmake_targets/autotests/v2/actions/clone_repository.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/compilation.bash b/cmake_targets/autotests/v2/actions/compilation.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/execution.bash b/cmake_targets/autotests/v2/actions/execution.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/execution_compile.bash b/cmake_targets/autotests/v2/actions/execution_compile.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/modem.py b/cmake_targets/autotests/v2/actions/modem.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/run_enb.bash b/cmake_targets/autotests/v2/actions/run_enb.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/server_tcp.bash b/cmake_targets/autotests/v2/actions/server_tcp.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/server_udp.bash b/cmake_targets/autotests/v2/actions/server_udp.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/start_3276.bash b/cmake_targets/autotests/v2/actions/start_3276.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/start_3276.py b/cmake_targets/autotests/v2/actions/start_3276.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/start_bandrich.bash b/cmake_targets/autotests/v2/actions/start_bandrich.bash old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/start_bandrich.py b/cmake_targets/autotests/v2/actions/start_bandrich.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/stop_3276.py b/cmake_targets/autotests/v2/actions/stop_3276.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/stop_bandrich.py b/cmake_targets/autotests/v2/actions/stop_bandrich.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/wvdial.3276.conf b/cmake_targets/autotests/v2/actions/wvdial.3276.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/actions/wvdial.bandrich.conf b/cmake_targets/autotests/v2/actions/wvdial.bandrich.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/alu_test.py b/cmake_targets/autotests/v2/alu_test.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/enb.band38.tm1.usrpb210.tdd.10MHz.conf b/cmake_targets/autotests/v2/config/enb.band38.tm1.usrpb210.tdd.10MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/enb.band38.tm1.usrpb210.tdd.20MHz.conf b/cmake_targets/autotests/v2/config/enb.band38.tm1.usrpb210.tdd.20MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/enb.band38.tm1.usrpb210.tdd.5MHz.conf b/cmake_targets/autotests/v2/config/enb.band38.tm1.usrpb210.tdd.5MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/enb.band7.tm1.usrpb210.fdd.10MHz.conf b/cmake_targets/autotests/v2/config/enb.band7.tm1.usrpb210.fdd.10MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/enb.band7.tm1.usrpb210.fdd.20MHz.conf b/cmake_targets/autotests/v2/config/enb.band7.tm1.usrpb210.fdd.20MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/enb.band7.tm1.usrpb210.fdd.5MHz.conf b/cmake_targets/autotests/v2/config/enb.band7.tm1.usrpb210.fdd.5MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/rcc.band7.tm1.if4p5.10MHz.conf b/cmake_targets/autotests/v2/config/rcc.band7.tm1.if4p5.10MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/rcc.band7.tm1.if4p5.20MHz.conf b/cmake_targets/autotests/v2/config/rcc.band7.tm1.if4p5.20MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/rcc.band7.tm1.if4p5.5MHz.conf b/cmake_targets/autotests/v2/config/rcc.band7.tm1.if4p5.5MHz.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/rru.band7.tm1.if4p5.10MHz.udp.usrpb210.conf b/cmake_targets/autotests/v2/config/rru.band7.tm1.if4p5.10MHz.udp.usrpb210.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/rru.band7.tm1.if4p5.20MHz.udp.usrpb210.conf b/cmake_targets/autotests/v2/config/rru.band7.tm1.if4p5.20MHz.udp.usrpb210.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/config/rru.band7.tm1.if4p5.5MHz.udp.usrpb210.conf b/cmake_targets/autotests/v2/config/rru.band7.tm1.if4p5.5MHz.udp.usrpb210.conf old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/connection.py b/cmake_targets/autotests/v2/connection.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/machine_list.py b/cmake_targets/autotests/v2/machine_list.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/main.py b/cmake_targets/autotests/v2/main.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/task.py b/cmake_targets/autotests/v2/task.py old mode 100644 new mode 100755 diff --git a/cmake_targets/autotests/v2/utils.py b/cmake_targets/autotests/v2/utils.py old mode 100644 new mode 100755 diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 358053a060..7e7556248e 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -68,9 +68,9 @@ USRP_REC_PLAY="False" BUILD_ECLIPSE=0 NR="False" ITTI_SIM="False" -RFSIM_NAS="False" SANITIZE_ADDRESS="False" OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc" +RU=0 trap handle_ctrl_c INT function print_help() { @@ -105,6 +105,8 @@ Options Makes the NR softmodem --nrUE Makes the NR UE softmodem +--RU + Makes the OAI RRU (without full stack) --UE Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file --UE-conf-nvram [configuration file] @@ -242,29 +244,37 @@ function main() { shift;; --eNB) eNB=1 + RU=0 echo_info "Will compile eNB" shift;; --eNBocp) eNBocp=1 + RU=0 echo_info "Will compile OCP eNB" shift;; --gNB) gNB=1 + RU=0 NR="True" echo_info "Will compile gNB" shift;; + --RU) + RU=1 + echo_info "Will compile RRU" + shift;; -a | --agent) echo_info "FlexRAN support is always compiled into the eNB" shift;; --UE) + RU=0 UE=1 echo_info "Will compile UE" shift;; --nrUE) + RU=0 nrUE=1 - NR="True" rfsimNas=1 - RFSIM_NAS="True" + NR="True" echo_info "Will compile NR UE" shift;; --mu) @@ -299,6 +309,7 @@ function main() { shift 2;; -P | --phy_simulators) SIMUS_PHY=1 + RU=0 echo_info "Will compile dlsim, ulsim, ..." shift;; -S | --core_simulators) @@ -467,7 +478,7 @@ function main() { ######################################################## # to be discussed - if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" ] ; then + if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" -o "$RU" = "1" ] ; then if [ "$HW" = "None" -a "$TP" = "None" ] ; then echo_info "No local radio head and no transport protocol selected" fi @@ -594,7 +605,7 @@ function main() { config_libconfig_shlib=params_libconfig # first generate the CMakefile in the right directory - if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$nrUE" = "1" -o "$HW" = "EXMIMO" -o "$ittiSIM" = "1" -o "$rfsimNas" = "1" ] ; then + if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$RU" = "1" -o "$nrUE" = "1" -o "$HW" = "EXMIMO" -o "$ittiSIM" = "1" -o "$rfsimNas" = "1" ] ; then # softmodem compilation @@ -618,8 +629,8 @@ function main() { echo "set ( UE_TIMING_TRACE $UE_TIMING_TRACE )" >> $cmake_file echo "set ( USRP_REC_PLAY $USRP_REC_PLAY )" >> $cmake_file echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )" >> $cmake_file + echo "set ( RU $RU )" >> $cmake_file echo "set ( ITTI_SIM $ITTI_SIM )" >> $cmake_file - echo "set ( RFSIM_NAS $RFSIM_NAS )" >> $cmake_file echo "set ( SANITIZE_ADDRESS $SANITIZE_ADDRESS )" >> $cmake_file echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file cd $DIR/$build_dir/build @@ -635,6 +646,9 @@ function main() { if [ "$gNB" = "1" ] ; then execlist="$execlist nr-softmodem" fi + if [ "$RU" = "1" ] ; then + execlist="$execlist oairu" + fi if [ "$UE" = 1 ] ; then execlist="$execlist lte-uesoftmodem" fi @@ -663,28 +677,29 @@ function main() { $build_dir $config_libconfig_shlib \ lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so - compilations \ - $build_dir coding \ - libcoding.so $dbin/libcoding.so - - - #check if we run inside a container or not - #IS_CONTAINER variable is defined in build_helper file - #compile nasmesh and rb_tool only if NOT running in a container - if [ $IS_CONTAINER -eq 0 ] - then - compilations \ - $build_dir nasmesh \ - CMakeFiles/nasmesh/nasmesh.ko $dbin/nasmesh.ko + if [ "$RU" = "0" ] ; then compilations \ - $build_dir rb_tool \ - rb_tool $dbin/rb_tool + $build_dir coding \ + libcoding.so $dbin/libcoding.so - cp $OPENAIR_DIR/cmake_targets/tools/init_nas_nos1 $dbin - fi #IS_CONTAINER + #check if we run inside a container or not + #IS_CONTAINER variable is defined in build_helper file + #compile nasmesh and rb_tool only if NOT running in a container + if [ $IS_CONTAINER -eq 0 ] + then + compilations \ + $build_dir nasmesh \ + CMakeFiles/nasmesh/nasmesh.ko $dbin/nasmesh.ko + + compilations \ + $build_dir rb_tool \ + rb_tool $dbin/rb_tool + + cp $OPENAIR_DIR/cmake_targets/tools/init_nas_nos1 $dbin + fi #IS_CONTAINER + fi fi - fi if [ "$UE" = 1 ] ; then @@ -866,7 +881,7 @@ function main() { #################################################### # Build RF device and transport protocol libraries # #################################################### - if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$nrUE" = "1" -o "$HWLAT" = "1" ] ; then + if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$RU" = "1" -o "$nrUE" = "1" -o "$HWLAT" = "1" ] ; then # build RF device libraries if [ "$HW" != "None" ] ; then diff --git a/cmake_targets/doxygen/CMakeLists.txt b/cmake_targets/doxygen/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/epc_test/CMakeLists.template b/cmake_targets/epc_test/CMakeLists.template old mode 100644 new mode 100755 diff --git a/cmake_targets/install_external_packages.ubuntu20 b/cmake_targets/install_external_packages.ubuntu20 index 4b1cda42f8..95293198b9 100755 --- a/cmake_targets/install_external_packages.ubuntu20 +++ b/cmake_targets/install_external_packages.ubuntu20 @@ -159,16 +159,8 @@ install_protobuf_from_source(){ #cd protobuf-2.6.1/ rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 wget --tries=3 --retry-connrefused https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz - tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $(id -u) --group $(id -g) --no-same-owner - cd protobuf-3.3.0/ - else - export LD_LIBRARY_PATH=/usr/local/lib #protoc needs to know where toclook for shared libs - rm -rf /tmp/protobuf - git clone --depth=1 --branch=v3.3.0 https://github.com/protocolbuffers/protobuf.git /tmp/protobuf - cd /tmp/protobuf - git submodule update --init --recursive - ./autogen.sh - fi + tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner "$USER" --group "$(groups | cut -d" " -f1)" --no-same-owner + cd protobuf-3.3.0/ || exit ./configure echo "Compiling protobuf" make -j"$(nproc)" @@ -339,6 +331,10 @@ check_install_ubuntu_packages() { $SUDO apt install -y software-properties-common case "$(get_distribution_release)" in "ubuntu20.04") + specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" + LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" + LAPACK_TARGET="/usr/lib/x86_64-linux-gnu/atlas/liblapack.so" + ;; "ubuntu21.04") specific_packages="libtasn1-6-dev libgnutls28-dev iproute2 libconfig-dev" LAPACK_LIBNAME="liblapack.so-x86_64-linux-gnu" diff --git a/cmake_targets/nas_sim_tools/CMakeLists.txt b/cmake_targets/nas_sim_tools/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/phy_simulators/CMakeLists.txt b/cmake_targets/phy_simulators/CMakeLists.txt old mode 100644 new mode 100755 index 447e90bcab..f8c659959f --- a/cmake_targets/phy_simulators/CMakeLists.txt +++ b/cmake_targets/phy_simulators/CMakeLists.txt @@ -17,4 +17,5 @@ set ( UE_TIMING_TRACE False ) set ( USRP_REC_PLAY False ) set ( SKIP_SHARED_LIB_FLAG False ) set ( PHYSIM True) +set ( RU 0) include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt) diff --git a/cmake_targets/s1c_mme_test/CMakeLists.template b/cmake_targets/s1c_mme_test/CMakeLists.template old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/Kbuild.cmake b/cmake_targets/tools/Kbuild.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/CMakeParseArguments.cmake b/cmake_targets/tools/MODULES/CMakeParseArguments.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/CMakeUserFindMySQL.cmake b/cmake_targets/tools/MODULES/CMakeUserFindMySQL.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/CMakeUserUseBison.cmake b/cmake_targets/tools/MODULES/CMakeUserUseBison.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/CMakeUserUseFlex.cmake b/cmake_targets/tools/MODULES/CMakeUserUseFlex.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindFreeDiameter.cmake b/cmake_targets/tools/MODULES/FindFreeDiameter.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindGCCXML.cmake b/cmake_targets/tools/MODULES/FindGCCXML.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindGcrypt.cmake b/cmake_targets/tools/MODULES/FindGcrypt.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindGnuTLS.cmake b/cmake_targets/tools/MODULES/FindGnuTLS.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindKbuild.cmake b/cmake_targets/tools/MODULES/FindKbuild.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindLibXml2.cmake b/cmake_targets/tools/MODULES/FindLibXml2.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindMySQL.cmake b/cmake_targets/tools/MODULES/FindMySQL.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindNettle.cmake b/cmake_targets/tools/MODULES/FindNettle.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindPostgreSQL.cmake b/cmake_targets/tools/MODULES/FindPostgreSQL.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/FindSCTP.cmake b/cmake_targets/tools/MODULES/FindSCTP.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/Kbuild.cmake b/cmake_targets/tools/MODULES/Kbuild.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/cmake_useful.cmake b/cmake_targets/tools/MODULES/cmake_useful.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/kbuild_system.cmake b/cmake_targets/tools/MODULES/kbuild_system.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/kmodule.cmake b/cmake_targets/tools/MODULES/kmodule.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/MODULES/path_prefixes.cmake b/cmake_targets/tools/MODULES/path_prefixes.cmake old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/asn1tostruct.py b/cmake_targets/tools/asn1tostruct.py old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/example_enb_exmimo_mme_hss.txt b/cmake_targets/tools/example_enb_exmimo_mme_hss.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/example_oaisim_enb_ue_mme_virtual.txt b/cmake_targets/tools/example_oaisim_enb_ue_mme_virtual.txt old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/exmimo2_2arxg.lime b/cmake_targets/tools/exmimo2_2arxg.lime old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/exmimo2_2brxg.lime b/cmake_targets/tools/exmimo2_2brxg.lime old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/exmimo_stop_octave.m b/cmake_targets/tools/exmimo_stop_octave.m old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff b/cmake_targets/tools/fix_asn1.data/RRC.rel10/SystemInformation-r8-IEs.h.diff old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-NB-r13-IEs.h.diff b/cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-NB-r13-IEs.h.diff old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff b/cmake_targets/tools/fix_asn1.data/RRC.rel14/SystemInformation-r8-IEs.h.diff old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff b/cmake_targets/tools/fix_asn1.data/X2AP.rel11.2/X2ap-CriticalityDiagnostics-IE-List.h.diff old mode 100644 new mode 100755 diff --git a/cmake_targets/tools/make_asn1c_includes.sh b/cmake_targets/tools/make_asn1c_includes.sh index 1598678a73..00c88d6497 100755 --- a/cmake_targets/tools/make_asn1c_includes.sh +++ b/cmake_targets/tools/make_asn1c_includes.sh @@ -1,13 +1,19 @@ #!/bin/bash -GENERATED_FULL_DIR=$1 -shift -ASN1_SOURCE_DIR=$1 -shift export ASN1C_PREFIX=$1 shift -options=$* +options=$1 +shift +GENERATED_FULL_DIR=$1 +shift +ASN1_SOURCE_DIR=$* done_flag="$GENERATED_FULL_DIR"/done -if [ "$done_flag" -ot $ASN1_SOURCE_DIR ] ; then +rebuild=0 +for f in $ASN1_SOURCE_DIR ; do + if [ "$done_flag" -ot "$f" ] ; then + rebuild=1 + fi +done +if [ $rebuild -eq 1 ] ; then rm -f "$GENERATED_FULL_DIR"/${ASN1C_PREFIX}*.c "$GENERATED_FULL_DIR"/${ASN1C_PREFIX}*.h mkdir -p "$GENERATED_FULL_DIR" asn1c -pdu=all -fcompound-names -gen-PER -no-gen-OER -no-gen-example $options -D $GENERATED_FULL_DIR $ASN1_SOURCE_DIR |& egrep -v "^Copied|^Compiled" | sort -u diff --git a/cmake_targets/tools/setup_routes.sh b/cmake_targets/tools/setup_routes.sh new file mode 100755 index 0000000000..67fe250be7 --- /dev/null +++ b/cmake_targets/tools/setup_routes.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +for i in $(seq 1 $1); +do + let table=1000+$i + echo "sudo ip route add 10.0.1.0/24 dev oaitun_ue$i table $table" + sudo ip route add 10.0.1.0/24 dev oaitun_ue$i table $table + echo "sudo ip route add default via 10.0.1.1 dev oaitun_ue$i table $table" + sudo ip route add default via 10.0.1.1 dev oaitun_ue$i table $table + let octet=$i+1 + echo "sudo ip rule add from 10.0.1.$octet table $table" + sudo ip rule add from 10.0.1.$octet table $table +done diff --git a/cmake_targets/tools/test_helper b/cmake_targets/tools/test_helper old mode 100644 new mode 100755 diff --git a/common/config/config_cmdline.c b/common/config/config_cmdline.c index 1df1bc16f7..f5dfae06b6 100644 --- a/common/config/config_cmdline.c +++ b/common/config/config_cmdline.c @@ -211,7 +211,7 @@ int config_process_cmdline(paramdef_t *cfgoptions,int numoptions, char *prefix) while (c > 0 ) { char *oneargv = strdup(config_get_if()->argv[i]); /* we use strtok_r which modifies its string paramater, and we don't want argv to be modified */ - + if(!oneargv) abort(); /* first check help options, either --help, -h or --help_
*/ if (strncmp(oneargv, "-h",2) == 0 || strncmp(oneargv, "--help",6) == 0 ) { char *tokctx = NULL; diff --git a/common/ran_context.h b/common/ran_context.h index 3f57c000a0..db981e9182 100644 --- a/common/ran_context.h +++ b/common/ran_context.h @@ -39,7 +39,7 @@ #include "PHY/types.h" #include "PHY/impl_defs_top.h" -#include "ENB_APP/enb_config.h" +//#include "ENB_APP/enb_config.h" #include "flexran_agent_defs.h" #include "gtpv1u.h" @@ -122,5 +122,5 @@ typedef struct { pthread_cond_t ru_cond; } RAN_CONTEXT_t; - +extern RAN_CONTEXT_t RC; #endif diff --git a/common/utils/lte/prach_utils.c b/common/utils/lte/prach_utils.c new file mode 100644 index 0000000000..9ef29e55a5 --- /dev/null +++ b/common/utils/lte/prach_utils.c @@ -0,0 +1,425 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file common/utils/lte/prach_utils.c + * \brief utils for PRACH common to both PHY and MAC + * \author R. Knopp + * \date 2020 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + +#include + + +#include "PHY/LTE_TRANSPORT/transport_common.h" + +// This is table 5.7.1-4 from 36.211 +PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7] = { + // TDD Configuration Index 0 + { {1,{{0,1,0,2}}},{1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {1,{{0,1,0,2}}}}, + // TDD Configuration Index 1 + { {1,{{0,2,0,2}}},{1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {1,{{0,2,0,2}}}}, + // TDD Configuration Index 2 + { {1,{{0,1,1,2}}},{1,{{0,1,1,1}}}, {1,{{0,1,1,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,1}}}}, + // TDD Configuration Index 3 + { {1,{{0,0,0,2}}},{1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {1,{{0,0,0,2}}}}, + // TDD Configuration Index 4 + { {1,{{0,0,1,2}}},{1,{{0,0,1,1}}}, {1,{{0,0,1,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,1}}}}, + // TDD Configuration Index 5 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + // TDD Configuration Index 6 + { {2,{{0,0,0,2},{0,0,1,2}}}, {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {2,{{0,0,0,1},{0,0,0,2}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {2,{{0,0,0,2},{0,0,1,1}}}}, + // TDD Configuration Index 7 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,2}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + // TDD Configuration Index 8 + { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,0,1}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{0,0,1,1}}}}, + // TDD Configuration Index 9 + { {3,{{0,0,0,1},{0,0,0,2},{0,0,1,2}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,0,2}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {3,{{0,0,0,1},{0,0,0,2},{0,0,1,1}}}}, + // TDD Configuration Index 10 + { {3,{{0,0,0,0},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,2},{0,0,1,0}}}}, + // TDD Configuration Index 11 + { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{0,0,0,1},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{0,0,1,1}}}}, + // TDD Configuration Index 12 + { {4,{{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, + {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,2}}}, + {4,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {4,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 13 + { {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1}}} + }, + // TDD Configuration Index 14 + { {4,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 15 + { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1}}}, + {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,1},{1,0,0,2}}}, + {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,1}}}, {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, + {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1}}} + }, + // TDD Configuration Index 16 + { {5,{{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,1,1}}}, + {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,1,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,2}}}, + {5,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} + }, + // TDD Configuration Index 17 + { {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,2}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} + }, + // TDD Configuration Index 18 + { {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{0,0,1,2}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{1,0,0,0},{1,0,0,1},{1,0,0,2}}}, + {6,{{0,0,0,0},{0,0,0,1},{1,0,0,0},{1,0,0,1},{2,0,0,0},{2,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,0,2}}} + }, + // TDD Configuration Index 19 + { {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,1,0},{0,0,1,1},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,0},{0,0,0,1},{0,0,0,2},{0,0,1,0},{0,0,1,1},{1,0,1,1}}} + }, + // TDD Configuration Index 20 + { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, + // TDD Configuration Index 21 + { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, + + // TDD Configuration Index 22 + { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, + + // TDD Configuration Index 23 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + + // TDD Configuration Index 24 + { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, + + // TDD Configuration Index 25 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + + // TDD Configuration Index 26 + { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, + + // TDD Configuration Index 27 + { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} + }, + + // TDD Configuration Index 28 + { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, + {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} + }, + + // TDD Configuration Index 29 + { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} + }, + + + // TDD Configuration Index 30 + { {1,{{0,1,0,1}}},{1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,1}}}}, + + // TDD Configuration Index 31 + { {1,{{0,2,0,1}}},{1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,1}}}}, + + // TDD Configuration Index 32 + { {1,{{0,1,1,1}}},{1,{{0,1,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,1,0}}}}, + + // TDD Configuration Index 33 + { {1,{{0,0,0,1}}},{1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,1}}}}, + + // TDD Configuration Index 34 + { {1,{{0,0,1,1}}},{1,{{0,0,1,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,1,0}}}}, + + // TDD Configuration Index 35 + { {2,{{0,0,0,1},{0,0,1,1}}}, {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{1,0,0,1}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,1},{0,0,1,0}}}}, + + // TDD Configuration Index 36 + { {3,{{0,0,0,1},{0,0,1,1},{1,0,0,1}}}, {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{1,0,0,1},{2,0,0,1}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,1},{0,0,1,0},{1,0,0,1}}}}, + + // TDD Configuration Index 37 + { {4,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1}}}, {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0}}} + }, + + // TDD Configuration Index 38 + { {5,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1}}}, {5,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {5,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1}}}, + {5,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {5,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1}}} + }, + + // TDD Configuration Index 39 + { {6,{{0,0,0,1},{0,0,1,1},{1,0,0,1},{1,0,1,1},{2,0,0,1},{2,0,1,1}}}, + {6,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0},{2,0,0,0},{2,0,1,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{1,0,0,1},{2,0,0,1},{3,0,0,1},{4,0,0,1},{5,0,0,1}}}, + {6,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0},{4,0,0,0},{5,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {6,{{0,0,0,1},{0,0,1,0},{1,0,0,1},{1,0,1,0},{2,0,0,1},{2,0,1,0}}} + }, + + // TDD Configuration Index 40 + { {1,{{0,1,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,1,0,0}}}}, + // TDD Configuration Index 41 + { {1,{{0,2,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,2,0,0}}}}, + + // TDD Configuration Index 42 + { {1,{{0,1,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, + + // TDD Configuration Index 43 + { {1,{{0,0,0,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {1,{{0,0,0,0}}}}, + + // TDD Configuration Index 44 + { {1,{{0,0,1,0}}},{0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}, {0,{{0,0,0,0}}}}, + + // TDD Configuration Index 45 + { {2,{{0,0,0,0},{0,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0}}}, {2,{{0,0,0,0},{1,0,0,0}}}}, + + // TDD Configuration Index 46 + { {3,{{0,0,0,0},{0,0,1,0},{1,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, {3,{{0,0,0,0},{1,0,0,0},{2,0,0,0}}}}, + + // TDD Configuration Index 47 + { {4,{{0,0,0,0},{0,0,1,0},{1,0,0,0},{1,0,1,0}}}, {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {0,{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}}, + {4,{{0,0,0,0},{1,0,0,0},{2,0,0,0},{3,0,0,0}}} + } +}; + + +uint8_t get_prach_fmt(int prach_ConfigIndex,int frame_type) { + if (frame_type == FDD) // FDD + return(prach_ConfigIndex>>4); + else { + if (prach_ConfigIndex < 20) + return (0); + + if (prach_ConfigIndex < 30) + return (1); + + if (prach_ConfigIndex < 40) + return (2); + + if (prach_ConfigIndex < 48) + return (3); + else + return (4); + } +} + +uint8_t get_prach_prb_offset(int frame_type, + int tdd_config, + int N_RB_UL, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf) { + uint8_t n_ra_prb; + uint8_t f_ra,t1_ra; + uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); + uint8_t Nsp=2; + + if (frame_type == TDD) { // TDD + if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { + LOG_E(PHY, "Illegal prach_ConfigIndex %"PRIu8"", prach_ConfigIndex); + return(-1); + } + + // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) + f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; + + if (prach_fmt < 4) { + if ((f_ra&1) == 0) { + n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); + } else { + n_ra_prb = N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); + } + } else { + if ((tdd_config >2) && (tdd_config<6)) + Nsp = 2; + + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + + if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { + n_ra_prb = 6*f_ra; + } else { + n_ra_prb = N_RB_UL - 6*(f_ra+1); + } + } + } else { //FDD + n_ra_prb = n_ra_prboffset; + } + + return(n_ra_prb); +} + +int is_prach_subframe0(int tdd_config,int frame_type,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe) { + uint8_t t0_ra; + uint8_t t1_ra; + uint8_t t2_ra; + int prach_mask = 0; + + if (frame_type == FDD) { //FDD + //implement Table 5.7.1-2 from 36.211 (Rel-10, p.41) + if ((((frame&1) == 1) && (subframe < 9)) || + (((frame&1) == 0) && (subframe == 9))) // This is an odd frame, ignore even-only PRACH frames + if (((prach_ConfigIndex&0xf)<3) || // 0,1,2,16,17,18,32,33,34,48,49,50 + ((prach_ConfigIndex&0x1f)==18) || // 18,50 + ((prach_ConfigIndex&0xf)==15)) // 15,47 + return(0); + + switch (prach_ConfigIndex&0x1f) { + case 0: + case 3: + if (subframe==1) prach_mask = 1; + + break; + + case 1: + case 4: + if (subframe==4) prach_mask = 1; + + break; + + case 2: + case 5: + if (subframe==7) prach_mask = 1; + + break; + + case 6: + if ((subframe==1) || (subframe==6)) prach_mask=1; + + break; + + case 7: + if ((subframe==2) || (subframe==7)) prach_mask=1; + + break; + + case 8: + if ((subframe==3) || (subframe==8)) prach_mask=1; + + break; + + case 9: + if ((subframe==1) || (subframe==4) || (subframe==7)) prach_mask=1; + + break; + + case 10: + if ((subframe==2) || (subframe==5) || (subframe==8)) prach_mask=1; + + break; + + case 11: + if ((subframe==3) || (subframe==6) || (subframe==9)) prach_mask=1; + + break; + + case 12: + if ((subframe&1)==0) prach_mask=1; + + break; + + case 13: + if ((subframe&1)==1) prach_mask=1; + + break; + + case 14: + prach_mask=1; + break; + + case 15: + if (subframe==9) prach_mask=1; + + break; + } + } else { // TDD + AssertFatal(prach_ConfigIndex<64, + "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); + AssertFatal(tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach>0, + "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); + t0_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t0_ra; + t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; + t2_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t2_ra; +#ifdef PRACH_DEBUG + LOG_I(PHY,"[PRACH] Checking for PRACH format (ConfigIndex %d) in TDD subframe %d (%d,%d,%d)\n", + prach_ConfigIndex, + subframe, + t0_ra,t1_ra,t2_ra); +#endif + + if ((((t0_ra == 1) && ((frame &1)==0))|| // frame is even and PRACH is in even frames + ((t0_ra == 2) && ((frame &1)==1))|| // frame is odd and PRACH is in odd frames + (t0_ra == 0)) && // PRACH is in all frames + (((subframe<5)&&(t1_ra==0)) || // PRACH is in 1st half-frame + (((subframe>4)&&(t1_ra==1))))) { // PRACH is in 2nd half-frame + if ((prach_ConfigIndex<48) && // PRACH only in normal UL subframe + (((subframe%5)-2)==t2_ra)) prach_mask=1; + else if ((prach_ConfigIndex>47) && (((subframe%5)-1)==t2_ra)) prach_mask=1; // PRACH can be in UpPTS + } + } + + return(prach_mask); +} + diff --git a/common/utils/lte/prach_utils.h b/common/utils/lte/prach_utils.h new file mode 100644 index 0000000000..995805fbd2 --- /dev/null +++ b/common/utils/lte/prach_utils.h @@ -0,0 +1,40 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file common/utils/prach_utils.h +* \brief computation of some PRACH variables used in both MAC and PHY +* \author R. Knopp +* \date 2020 +* \version 0.1 +* \company Eurecom +* \email: raymond.knopp@eurecom.fr, florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it +* \note +* \warning +*/ +uint8_t get_prach_fmt(int prach_ConfigIndex,int frame_type); + +uint8_t get_prach_prb_offset(int frame_type, + int tdd_config, + int N_RB_UL, + uint8_t prach_ConfigIndex, + uint8_t n_ra_prboffset, + uint8_t tdd_mapindex, uint16_t Nf); +int is_prach_subframe0(int tdd_config,int frame_type,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe); diff --git a/common/utils/lte/ue_power.c b/common/utils/lte/ue_power.c new file mode 100644 index 0000000000..b377abf2ff --- /dev/null +++ b/common/utils/lte/ue_power.c @@ -0,0 +1,108 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file ue_power.c +* \brief Routines to compute UE TX power according to 36.213 +* \author R. Knopp, F. Kaltenberger +* \date 2020 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr +* \note +* \warning +*/ + +#include +#include +#include "PHY/defs_eNB.h" +#include "PHY/TOOLS/dB_routines.h" + +extern int16_t hundred_times_delta_TF[100]; +extern uint16_t hundred_times_log10_NPRB[100]; + +int16_t estimate_ue_tx_power(int norm,uint32_t tbs, uint32_t nb_rb, uint8_t control_only, int ncp, uint8_t use_srs) +{ + + /// The payload + CRC size in bits, "B" + uint32_t B; + /// Number of code segments + uint32_t C; + /// Number of "small" code segments + uint32_t Cminus; + /// Number of "large" code segments + uint32_t Cplus; + /// Number of bits in "small" code segments (<6144) + uint32_t Kminus; + /// Number of bits in "large" code segments (<6144) + uint32_t Kplus; + /// Total number of bits across all segments + uint32_t sumKr; + /// Number of "Filler" bits + uint32_t F; + // num resource elements + uint32_t num_re=0.0; + // num symbols + uint32_t num_symb=0.0; + /// effective spectral efficiency of the PUSCH + uint32_t MPR_x100=0; + /// beta_offset + uint16_t beta_offset_pusch_x8=8; + /// delta mcs + float delta_mcs=0.0; + /// bandwidth factor + float bw_factor=0.0; + + B= tbs+24; + lte_segmentation(NULL, + NULL, + B, + &C, + &Cplus, + &Cminus, + &Kplus, + &Kminus, + &F); + + + sumKr = Cminus*Kminus + Cplus*Kplus; + num_symb = 12-(ncp<<1)-(use_srs==0?0:1); + num_re = num_symb * nb_rb * 12; + + if (num_re == 0) + return(0); + + MPR_x100 = 100*sumKr/num_re; + + if (control_only == 1 ) + beta_offset_pusch_x8=8; // fixme + + //(beta_offset_pusch_x8=ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; + + // if deltamcs_enabledm + delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_times10((beta_offset_pusch_x8)>>3))/100.0); + + bw_factor = (norm!=0) ? 0 : (hundred_times_log10_NPRB[nb_rb-1]/100.0); + LOG_D(PHY,"estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n", + (int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor); + return (int16_t)ceil(delta_mcs + bw_factor); + +} + diff --git a/common/utils/lte/ue_power.h b/common/utils/lte/ue_power.h new file mode 100644 index 0000000000..caeebec2c8 --- /dev/null +++ b/common/utils/lte/ue_power.h @@ -0,0 +1,34 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file ue_power.h +* \brief support routines used in MAC and PHY +* \author R. Knopp, F. Kaltenberger +* \date 2020 +* \version 0.1 +* \company Eurecom +* \email: knopp@eurecom.fr,florian.kaltenberger@eurecom.fr +* \note +* \warning +*/ + +int16_t estimate_ue_tx_power(int norm,uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs); + diff --git a/common/utils/ocp_itti/intertask_interface.cpp b/common/utils/ocp_itti/intertask_interface.cpp index c774da57e6..4e5323aec9 100644 --- a/common/utils/ocp_itti/intertask_interface.cpp +++ b/common/utils/ocp_itti/intertask_interface.cpp @@ -136,7 +136,7 @@ extern "C" { LOG_E(TMR,"Queue for %s task contains %ld messages\n", itti_get_task_name(destination_task_id), s ); if ( s > 50 ) - LOG_I(TMR,"Queue for %s task size: %ld\n",itti_get_task_name(destination_task_id), s+1); + LOG_I(TMR,"Queue for %s task size: %ld (last message %s)\n",itti_get_task_name(destination_task_id), s+1,ITTI_MSG_NAME(message)); t->message_queue.insert(t->message_queue.begin(), message); eventfd_t sem_counter = 1; diff --git a/common/utils/system.c b/common/utils/system.c index 4c6c1a4dc0..d8b66c51d3 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -96,6 +96,54 @@ static void read_pipe(int p, char *b, int size) { } } +static int baseRunTimeCommand(char* cmd, size_t cmdSize) { + FILE *fp; + size_t retSize = 0; + + fp = popen(cmd, "r"); + if(fp) { + memset(cmd, 0, cmdSize); + retSize = fread(cmd, 1, cmdSize, fp); + fclose(fp); + } else { + LOG_D(HW,"%s:%d:%s: Cannot open %s\n", __FILE__, __LINE__, __FUNCTION__, cmd); + } + + if (retSize == 0) { + return 0; + } + return atoi(cmd); +} + +int checkIfFedoraDistribution(void) { + char cmd[200]; + + memset(cmd, 0, 200); + sprintf(cmd, "cat /etc/os-release | grep ID_LIKE | grep -ic fedora || true"); + return baseRunTimeCommand(cmd, 200); +} + +int checkIfGenericKernelOnFedora(void) { + char cmd[200]; + + memset(cmd, 0, 200); + sprintf(cmd, "uname -a | grep -c rt || true"); + return (1 - baseRunTimeCommand(cmd, 200)); +} + +int checkIfInsideContainer(void) { + char cmd[200]; + int res = 0; + + memset(cmd, 0, 200); + sprintf(cmd, "cat /proc/self/cgroup | egrep -c 'libpod|podman|kubepods' || true"); + res = baseRunTimeCommand(cmd, 200); + if (res > 0) + return 1; + else + return 0; +} + /********************************************************************/ /* background process */ /********************************************************************/ @@ -200,29 +248,38 @@ void start_background_system(void) { void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){ pthread_attr_t attr; int ret; + int settingPriority = 1; ret=pthread_attr_init(&attr); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); ret=pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); ret=pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); - ret=pthread_attr_setschedpolicy(&attr, SCHED_OAI); - AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); - if(prioritysched_get_priority_max(SCHED_FIFO)) { - LOG_E(TMR,"Prio not possible: %d, min is %d, max: %d, forced in the range\n", - priority, - sched_get_priority_min(SCHED_OAI), - sched_get_priority_max(SCHED_OAI)); - if(prioritysched_get_priority_max(SCHED_OAI)) - priority=sched_get_priority_max(SCHED_OAI); + if (checkIfFedoraDistribution()) + if (checkIfGenericKernelOnFedora()) + if (checkIfInsideContainer()) + settingPriority = 0; + + if (settingPriority) { + ret=pthread_attr_setschedpolicy(&attr, SCHED_OAI); + AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); + if(prioritysched_get_priority_max(SCHED_FIFO)) { + LOG_E(TMR,"Prio not possible: %d, min is %d, max: %d, forced in the range\n", + priority, + sched_get_priority_min(SCHED_OAI), + sched_get_priority_max(SCHED_OAI)); + if(prioritysched_get_priority_max(SCHED_OAI)) + priority=sched_get_priority_max(SCHED_OAI); + } + AssertFatal(priority<=sched_get_priority_max(SCHED_OAI),""); + struct sched_param sparam={0}; + sparam.sched_priority = priority; + ret=pthread_attr_setschedparam(&attr, &sparam); + AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); } - AssertFatal(priority<=sched_get_priority_max(SCHED_OAI),""); - struct sched_param sparam={0}; - sparam.sched_priority = priority; - ret=pthread_attr_setschedparam(&attr, &sparam); - AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); + ret=pthread_create(t, &attr, func, param); AssertFatal(ret==0,"ret: %d, errno: %d\n",ret, errno); diff --git a/common/utils/system.h b/common/utils/system.h index fbfd338a1a..c76fef9144 100644 --- a/common/utils/system.h +++ b/common/utils/system.h @@ -58,6 +58,14 @@ void thread_top_init(char *thread_name, uint64_t deadline, uint64_t period); +/**************************************************** + * Functions to check system at runtime. + ****************************************************/ + +int checkIfFedoraDistribution(void); +int checkIfGenericKernelOnFedora(void); +int checkIfInsideContainer(void); + #ifdef __cplusplus } #endif diff --git a/common/utils/telnetsrv/telnetsrv.h b/common/utils/telnetsrv/telnetsrv.h index b66641d5c8..59655501d3 100644 --- a/common/utils/telnetsrv/telnetsrv.h +++ b/common/utils/telnetsrv/telnetsrv.h @@ -31,6 +31,7 @@ #ifndef TELNETSRV_H #define TELNETSRV_H +#include #define TELNETSRV_MODNAME "telnetsrv" #define TELNET_PORT 9090 diff --git a/common/utils/utils.h b/common/utils/utils.h index da7c453b03..16631586c4 100644 --- a/common/utils/utils.h +++ b/common/utils/utils.h @@ -7,6 +7,7 @@ extern "C" { #endif +#define sizeofArray(a) (sizeof(a)/sizeof(*(a))) void *calloc_or_fail(size_t size); void *malloc_or_fail(size_t size); diff --git a/configuration/bladeRF/enb-band7-5mhz.conf b/configuration/bladeRF/enb-band7-5mhz.conf index 9156a74fb0..9d19207522 100644 --- a/configuration/bladeRF/enb-band7-5mhz.conf +++ b/configuration/bladeRF/enb-band7-5mhz.conf @@ -238,7 +238,7 @@ MACRLCs = ( THREAD_STRUCT = ( { parallel_config = "PARALLEL_RU_L1_TRX_SPLITaaaaaa"; - worker_config = "ENABLE"; + worker_config = "WORKER_ENABLE"; } ); diff --git a/doc/RUNMODEM.md b/doc/RUNMODEM.md index 8d84646e07..dc7a982310 100644 --- a/doc/RUNMODEM.md +++ b/doc/RUNMODEM.md @@ -134,22 +134,24 @@ With the RF simulator (on the same machine): ## SA setup with OAI -The sa flag is used to run gNB in standalone mode. Currently OAI in NR standalone mode transmits and receives SIB1 and triggers the RA procedure for initial access. +The sa flag is used to run gNB in standalone mode. -In order to run gNB in standalone mode, the following flag is needed at gNB: +In order to run gNB and UE in standalone mode, the following flag is needed: `--sa` -### Run OAI in sa mode - -At the gNB the --sa flag does the following -- it reads the RRC configuration from the configuration file -- it encodes the RRCConfiguration and the RBconfig message and stores them in the binary files rbconfig.raw and reconfig.raw -- the RRC encodes SIB1 according the configuration file and transmits it through PDSCH +At the gNB the --sa flag does the following: +- The RRC encodes SIB1 according to the configuration file and transmits it through NR-BCCH-DL-SCH. At the UE the --sa flag will: -- Read the binary files rbconfig.raw and reconfig.raw from the current directory (a different directory can be specified with the flag --rrc_config_path) and process them -- After the successful decoding of a SIB1 at RRC, the UE will start the 5G NR Initial Access Procedure by triggering the RA procedure. +- Decode SIB1 and starts the 5G NR Initial Access Procedure for SA: + 1) 5G-NR RRC Connection Setup + 2) NAS Authentication and Security + 3) 5G-NR AS Security Procedure + 4) 5G-NR RRC Reconfiguration + 5) Start Downlink and Uplink Data Transfer + +### Run OAI in SA mode From the `cmake_targets/ran_build/build` folder: @@ -159,13 +161,13 @@ gNB on machine 1: UE on machine 2: -`sudo ./nr-uesoftmodem --rrc_config_path . --sa` +`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --sa` With the RF simulator (on the same machine): `sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim --sa` -`sudo ./nr-uesoftmodem --rrc_config_path . --rfsim --sa` +`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa` ## IF setup with OAI diff --git a/doc/SW_archi.md b/doc/SW_archi.md index 0d03591891..e5856d63bc 100644 --- a/doc/SW_archi.md +++ b/doc/SW_archi.md @@ -171,24 +171,31 @@ NR_sched_pusch_t (for values changing every TTI, e.g., frequency domain allocation) and NR_sched_pusch_save_t (for values changing less frequently, at least in FR1 [to my understanding], e.g., DMRS fields when the time domain allocation stays between TTIs) structures. Furthermore, the preprocessor is an -exchangeable module that might schedule differently, e.g., one user for -phytest, multiple users in FR1, or maybe FR2: phytest is in -nr_ul_preprocessor_phytest(), for FR1 is nr_simple_ulsch_preprocessor() [under -development], for FR2 does not exist yet. +exchangeable module that schedules differently based on a particular +use-case/deployment type, e.g., one user for phytest [in +nr_ul_preprocessor_phytest()], multiple users in FR1 +[nr_fr1_ulsch_preprocessor()], or maybe FR2 [does not exist yet]: * calls preprocessor via pre_processor_ul(): the preprocessor is responsible - for allocating CCEs (using allocate_nr_CCEs()). Note that we do not yet have - scheduling requests or buffer status reports, and only one UE. E.g., - nr_simple_ulsch_preprocessor(): + for allocating CCEs (using allocate_nr_CCEs()) and deciding on resource + allocation for the UEs including TB size. Note that we do not yet have + scheduling requests. What it typically does: 1) check whether the current frame/slot plus K2 is an UL slot, and return if not. 2) Find first free start RB in vrb_map_UL, and as many free consecutive RBs as possible. - 3) allocate a CCE for the UE (and return if it is not possible) - 4) Calculate DMRS stuff (nr_save_pusch_fields()) and the TBS. - 5) Mark used resources in vrb_map_UL. -* loop through all users: get a free HARQ PID and - update statistics. Fill nFAPI structures directly for PUSCH, and call - config_uldci() and fill_dci_pdu_rel15() for DCI filling and PDCCH messages. + 3) Either set up resource allocation directly (e.g., for a single UE, + phytest), or call into a function to perform actual resource allocation. + Currently, this is done using pf_ul() which implements a basic + proportional fair scheduler: + * for every UE, check for retransmission and allocate as necessary + * Calculate DMRS stuff (nr_set_pusch_semi_static()) + * Calculate the PF coefficient and put eligible UEs into a list + * Allocate resources to the UE(s) with the highest coefficient + 4) Mark used resources in vrb_map_UL. +* loop through all users: get a HARQ process as indicated through the + preprocessor, update statistics, fill nFAPI structures directly for PUSCH, + and call config_uldci() and fill_dci_pdu_rel15() for DCI filling and PDCCH + messages. Calls nr_schedule_ue_spec(). It is divided into the "preprocessor" and the "postprocessor": the first makes the scheduling decisions, the second fills @@ -196,29 +203,28 @@ nFAPI structures to indicate to the PHY what it is supposed to do. To signal which users have how many resources, the preprocessor populates the NR_UE_sched_ctrl_t structure of affected users. In particular, the field rbSize decides whether a user is to be allocated. Furthermore, the preprocessor is an -exchangeable module that might schedule differently, e.g., one user for -phytest, multiple users in FR1, or maybe FR2: phytest is in -nr_preprocessor_phytest(), for FR1 is nr_simple_dlsch_preprocessor() [under -development], for FR2 does not exist yet. +exchangeable module that schedules differently based on a particular +use-case/deployment type, e.g., one user for phytest [in +nr_preprocessor_phytest()], multiple users in FR1 +[nr_fr1_dlsch_preprocessor()], or maybe FR2 [does not exist yet]. * calls preprocessor via pre_processor_dl(): the preprocessor is responsible for allocating CCEs and PUCCH (using allocate_nr_CCEs() and nr_acknack_scheduling()) and deciding on the frequency/time domain - allocation. E.g., nr_simple_dlsch_preprocessor(): - 1) mac_rlc_status_ind() locks and checks directly inside rlc data the - quantity of waiting data. - 2) return from the preprocessor if there is no data and no timing advance to - send, - 3) otherwise, allocate a CCE for the UE (and return if it is not possible) - 4) find a PUCCH occasion for HARQ - 5a) check if there is a retransmission: if yes, find free resources to - transmit using the same resources, else - 5b) calculate the necessary RBs needed to get a TBS large enough to hold all - data, or until no more resources are available - 6) Mark taken resources in the vrb_map + allocation including the TB size. What it typically does: + 1) Check available resources in the vrb_map + 2) Checks the quantity of waiting data in RLC + 3) Either set up resource allocation directly (e.g., for a single UE, + phytest), or call into a function to perform actual resource allocation. + Currently, this is done using pf_dl() which implements a basic + proportional fair scheduler: + * for every UE, check for retransmission and allocate as necessary + * Calculate the PF coefficient and put eligible UEs into a list + * Allocate resources to the UE(s) with the highest coefficient + 4) Mark taken resources in the vrb_map * loop through all users: check if a new TA is necessary. Then, if a user has - allocated resources, compute its TBS, and fill nFAPI structures - (nr_fill_nfapi_dl_pdu() to populate what should be done by the lower layers - to make the Tx subframe). Update statistics (round, sent bytes). + allocated resources, update statistics (round, sent bytes), update HARQ + process information, and fill nFAPI structures (allocate a DCI and PDCCH + messages, TX_req, ...) # RRC RRC is a regular thread with itti loop on queue: TASK_RRC_GNB diff --git a/doc/TESTING_5GSA_setup.md b/doc/TESTING_5GSA_setup.md new file mode 100644 index 0000000000..786af5e27c --- /dev/null +++ b/doc/TESTING_5GSA_setup.md @@ -0,0 +1,162 @@ + +# OAI 5G SA tutorial [Under construction] + +In the following tutorial we describe how to deploy configure and test the two SA OAI setups: + + - SA setup with OAI gNB and COTS UE + - SA setup with OAI gNB and OAI UE + +The operating system and hardware requirements to support OAI 5G NR are described [here](https://gitlab.eurecom.fr/oai/openairinterface5g/-/wikis/5g-nr-development-and-setup). + +# 1. SA setup with COTS UE +At the moment of writing this document interoperability with the following COTS UE devices is being tested: + + - [Quectel RM500Q-GL](https://www.quectel.com/product/5g-rm500q-gl/) + - [Simcom SIMCOM8200EA](https://www.simcom.com/product/SIM8200G.html) + - Huawei Mate 30 Pro + + End-to-end control plane signaling to achieve a 5G SA connection, UE registration and PDU session establishment with the CN, as well as some basic user-plane traffic tests have been validated so far using the Quectel module and Huawei Mate 30 pro and partially validated with SIMCOM module. In terms of interoperability with different 5G Core Networks, so far this setup has been tested with: + + + - [OAI CN](https://openairinterface.org/oai-5g-core-network-project/) + - Nokia SA Box + - [Free CN](https://www.free5gc.org/) + + + ## 1.1 gNB build and configuration +At the moment of writing this document, most of the code to support the SA setup is not merged into develop branch yet, but it is accessible through the following branches: + + - NR_SA_F1AP_5GRECORDS + - develop-NR_SA_F1AP_5GRECORDS (up-to-date with latest develop branch) + +To build the gNB executable: +```bash + cd cmake_targets + ./build_oai -I -w USRP #For OAI first time installation only to install software dependencies + ./build_oai --gNB -w USRP +``` + +A reference configuration file for the gNB is provided [here](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop-NR_SA_F1AP_5GRECORDS/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf). + + +In the following, we highlight the fields of the file that have to be configured according to the configuration and interfaces of the Core Network. First, the PLMN section has to be filled with the proper values that match the configuration of the AMF and the UE USIM. +```bash + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = 1; + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); + }); +``` +Then, the source and destination IP interfaces for the communication with +the Core Network also need to be set as shown below. + +```bash + ////////// MME parameters: + amf_ip_address = ( { ipv4 = "192.168.70.132"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + NETWORK_INTERFACES : + { + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; + GNB_PORT_FOR_S1U = 2152; # Spec 2152 + }; +``` +In the first part (*amf_ip_address*) we specify the IP of the AMF and in the second part (*NETWORK_INTERFACES*) we specify the gNB local interface with AMF (N2 interface) and the UPF (N3 interface). + +### **gNB configuration in CU/DU split mode** +For the configuration of the gNB in CU and DU blocks the following sample configuration files are provided for the CU and DU entities respectively. +...... +At the point of writing this document the control-plane exchanges between the CU and the DU over *F1-C* interface have been validated. The integration of *F1-U* over gtp-u for the support of data plane traffic is ongoing. + +## 1.2 OAI 5G Core Network installation and configuration +The instructions for the installation of OAI CN components (AMF, SMF, NRF, UPF) using docker compose can be found [here](https://gitlab.eurecom.fr/oai/cn5g). Below are some complementary instructions which can be useful for the deployment. + + ## 1.3 Execution of SA scenario + +After having configured the gNB, we can start the individual components in the following sequence: + + - Launch Core Network + - Launch gNB + - Launch COTS UE (disable airplane mode) + +The execution command to start the gNB (in monolithic mode) is the following: +```bash +cd cmake_targets/ran_build/build +sudo ./nr-softmodem -E --sa -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +``` + +# 2. SA Setup with OAI UE +The SA setup with OAI UE has been validated with RFSIMULATOR for the moment. The control plane for the successful UE registration and PDU Session establishment has been verified with OAI and Nokia SA Box CNs. User-plane traffic validation after the establishment of the 5G connection is still pending for this setup. + +In the following, we provide the instructions on how to build, configure and execute this SA setup. + +## 2.1 Build and configuration +To build the gNB and OAI UE executables: + +```bash + cd cmake_targets + ./build_oai -I #For OAI first time installation only to install software dependencies + ./build_oai --gNB --nrUE -w SIMU +``` +The gNB configuration can be performed according to what is described in section 1.1, using the same reference configuration file as with the RF scenario. + +### NAS configuration for the OAI UE +At the moment, the NAS configuration parameters of the OAI UE are hardcoded in ***openair3/NAS/NR_UE/nr_nas_msg_sim.c***. More specifically: + + - The SUCI (*Subscription Concealed Identifier*) corresponding to default IMSI 2089900007487 is hardcoded in functions *generateRegistrationRequest()* and *generateIdentityResponse()* through the following lines: +```bash + mm_msg->registration_request.fgsmobileidentity.suci.typeofidentity = FGS_MOBILE_IDENTITY_SUCI; + mm_msg->registration_request.fgsmobileidentity.suci.mncdigit1 = 9; + mm_msg->registration_request.fgsmobileidentity.suci.mncdigit2 = 9; + mm_msg->registration_request.fgsmobileidentity.suci.mncdigit3 = 0xf; + mm_msg->registration_request.fgsmobileidentity.suci.mccdigit1 = 2; + mm_msg->registration_request.fgsmobileidentity.suci.mccdigit2 = 0; + mm_msg->registration_request.fgsmobileidentity.suci.mccdigit3 = 8; + mm_msg->registration_request.fgsmobileidentity.suci.schemeoutput = 0x4778; +``` + - USIM_API_K and OPc keys are hardcoded at the beginning of the file: +```bash +// USIM_API_K: fe c8 6b a6 eb 70 7e d0 89 05 75 7b 1b b4 4b 8f +uint8_t k[16] = {0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0, 0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f}; +// OPC: c4 24 49 36 3b ba d0 2b 66 d1 6b c9 75 d7 7c c1 +const uint8_t opc[16] = {0xc4, 0x24, 0x49, 0x36, 0x3b, 0xba, 0xd0, 0x2b, 0x66, 0xd1, 0x6b, 0xc9, 0x75, 0xd7, 0x7c, 0xc1}; +``` +- The NSSAI (*Network Slice Assistance Information*) and DNN (*Data Network Name*) are hardcoded in function *generatePduSessionEstablishRequest()* +```bash + uint8_t nssai[]={1,0,0,1}; //Corresponding to SST:1, SD:1 + uint8_t dnn[4]={0x4,0x6f,0x61,0x69}; //Corresponding to dnn:"oai" +``` +For interoperability with OAI or other CNs, it should be ensured that the configuration of the aforementioned parameters match the configuration of the corresponding subscribed user at the core network. +Hardcoding of the USIM information will soon be substituted with parsing those parameters from a configuration file. + +## 2.2 Execution of SA scenario + +The order of starting the different components should be the same as the one described in section 1.3. + + - To launch the gNB: + ```bash + sudo RFSIMULATOR=server ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim --sa + ``` +- To launch the OAI UE: + ```bash +sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --nokrnmod +``` +The IP address at the execution command of the OAI UE corresponds to the target IP of the gNB host that the RFSIMULATOR at the UE will connect to. In the above example, we assume that the gNB and UE are running on the same host so the specified address (127.0.0.1) is the one of the loopback interface. diff --git a/doc/TESTING_GNB_W_COTS_UE.md b/doc/TESTING_GNB_W_COTS_UE.md index 5f9299f0ef..84f43bfc27 100644 --- a/doc/TESTING_GNB_W_COTS_UE.md +++ b/doc/TESTING_GNB_W_COTS_UE.md @@ -44,6 +44,7 @@ Our code might not work with all 5G phones yet, but we are constantly improving * Oppo Reno 5G * Samsung A90 5G +* Samsung A42 5G * Google Pixel 5G (note1) * Simcom SIMCOM8200EA * Quectel RM500Q-GL diff --git a/doc/testing_gnb_w_cots_ue_resources/enb.conf b/doc/testing_gnb_w_cots_ue_resources/enb.conf index 35249aac25..a6bbd98bda 100755 --- a/doc/testing_gnb_w_cots_ue_resources/enb.conf +++ b/doc/testing_gnb_w_cots_ue_resources/enb.conf @@ -238,7 +238,7 @@ MACRLCs = ( THREAD_STRUCT = ( { parallel_config = "PARALLEL_RU_L1_TRX_SPLITaaaaaa"; - worker_config = "ENABLE"; + worker_config = "WORKER_ENABLE"; } ); diff --git a/docker/Dockerfile.eNB.rhel8.2 b/docker/Dockerfile.eNB.rhel8.2 index aa8b9aa228..cf012502e0 100644 --- a/docker/Dockerfile.eNB.rhel8.2 +++ b/docker/Dockerfile.eNB.rhel8.2 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM localhost/ran-build:latest AS enb-build +FROM ran-build:latest AS enb-build RUN rm -Rf /oai-ran WORKDIR /oai-ran @@ -37,10 +37,9 @@ RUN /bin/sh oaienv && \ mkdir -p log && \ ./build_oai --eNB --ninja -w USRP --verbose-ci -# debug -#RUN ldconfig -v && ldd /oai-ran/targets/bin/lte-softmodem.Rel15 -#RUN ls -ls /oai-ran/targets/bin -#RUN ls -ls /oai-ran/cmake_targets/ran_build/build/*.so +RUN yum install -y python3-pip && \ + pip3 install --ignore-installed pyyaml && \ + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-enb @@ -59,6 +58,7 @@ RUN yum update -y && \ WORKDIR /opt/oai-enb/bin COPY --from=enb-build /oai-ran/targets/bin/lte-softmodem.Rel15 . +COPY --from=enb-build /oai-ran/docker/scripts/enb_entrypoint.sh entrypoint.sh WORKDIR /usr/local/lib/ COPY --from=enb-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . @@ -93,34 +93,16 @@ COPY --from=enb-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 RUN ldconfig -#debug -#RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -#RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 -#RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -#RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -#RUN ldd /usr/local/lib/libcoding.so -#RUN ldd /usr/local/lib/libparams_libconfig.so -#RUN ldd /usr/local/lib/libdfts.so -#RUN ldd /usr/local/lib/liboai_iqplayer.so -#RUN ldd /opt/oai-enb/bin/lte-softmodem.Rel15 - # Copy the relevant configuration files for eNB WORKDIR /opt/oai-enb/etc -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/enb.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/rcc.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/cu.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/du.* . -COPY --from=enb-build /oai-ran/ci-scripts/conf_files/rru.* . +COPY --from=enb-build /oai-ran/docker/etc . WORKDIR /opt/oai-enb -#EXPOSE 2152/udp # S1U, GTP/UDP -#EXPOSE 22100/tcp # ? -#EXPOSE 36412/udp # S1C, SCTP/UDP -#EXPOSE 36422/udp # X2C, SCTP/UDP -#EXPOSE 50000/udp # IF5 / ORI (control) -#EXPOSE 50001/udp # IF5 / ECPRI (data) +# 2152 --> S1U, GTP/UDP +# 36412 --> S1C, SCTP/UDP +# 36422 --> X2C, SCTP/UDP +EXPOSE 2152/udp 36412/udp 36422/udp -#CMD ["/opt/oai-enb/bin/lte-softmodem", "-O", "/opt/oai-enb/etc/enb.conf"] -#ENTRYPOINT ["/opt/oai-enb/bin/entrypoint.sh"] -CMD ["sleep", "infinity"] +ENTRYPOINT ["/opt/oai-enb/bin/entrypoint.sh"] +CMD ["/opt/oai-enb/bin/lte-softmodem.Rel15", "-O", "/opt/oai-enb/etc/enb.conf"] diff --git a/docker/Dockerfile.eNB.ubuntu18 b/docker/Dockerfile.eNB.ubuntu18 index 95d7194c31..1f276094d5 100644 --- a/docker/Dockerfile.eNB.ubuntu18 +++ b/docker/Dockerfile.eNB.ubuntu18 @@ -41,11 +41,6 @@ RUN apt-get install -y python3-pip && \ pip3 install --ignore-installed pyyaml && \ python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml -# debug -#RUN ldconfig -v && ldd /oai-ran/targets/bin/lte-softmodem.Rel15 -#RUN ls -ls /oai-ran/targets/bin -#RUN ls -ls /oai-ran/cmake_targets/ran_build/build/*.so - #start from scratch for target executable FROM ubuntu:bionic as oai-enb ENV DEBIAN_FRONTEND=noninteractive @@ -98,17 +93,6 @@ COPY --from=enb-build /usr/local/lib/libprotobuf-c.so.1 . RUN ldconfig -#debug -#RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -#RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 -#RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -#RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -#RUN ldd /usr/local/lib/libcoding.so -#RUN ldd /usr/local/lib/libparams_libconfig.so -#RUN ldd /usr/local/lib/libdfts.so -#RUN ldd /usr/local/lib/liboai_iqplayer.so -#RUN ldd /opt/oai-enb/bin/lte-softmodem.Rel15 - # Copy the relevant configuration files for eNB WORKDIR /opt/oai-enb/etc COPY --from=enb-build /oai-ran/docker/etc . diff --git a/docker/Dockerfile.lteRU.rhel8.2 b/docker/Dockerfile.lteRU.rhel8.2 new file mode 100644 index 0000000000..35078de007 --- /dev/null +++ b/docker/Dockerfile.lteRU.rhel8.2 @@ -0,0 +1,99 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Dockerfile for the Open-Air-Interface BUILD service +# Valid for RHEL8 +# +#--------------------------------------------------------------------- + +FROM ran-build:latest AS ru-build + +RUN rm -Rf /oai-ran +WORKDIR /oai-ran +COPY . . + +#run build_oai to build the target image +RUN /bin/sh oaienv && \ + cd cmake_targets && \ + mkdir -p log && \ + ./build_oai --RU --ninja -w USRP --verbose-ci + +RUN yum install -y python3-pip && \ + pip3 install --ignore-installed pyyaml && \ + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml + +#start from scratch for target executable +FROM registry.access.redhat.com/ubi8/ubi:latest as oai-lte-ru +ENV TZ=Europe/Paris + +RUN yum update -y && \ + yum install -y --enablerepo="ubi-8-codeready-builder" \ + tzdata \ + atlas \ + net-tools \ + iputils \ + iproute && \ + echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \ + echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf + +WORKDIR /opt/oai-lte-ru/bin +COPY --from=ru-build /oai-ran/targets/bin/oairu.Rel15 . +COPY --from=ru-build /oai-ran/docker/scripts/lte_ru_entrypoint.sh entrypoint.sh + +WORKDIR /usr/local/lib/ +COPY --from=ru-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/libparams_libconfig.so . +COPY --from=ru-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . + +# Copying from the ran-build image the USRP needed packages +COPY --from=ru-build /lib64/libconfig.so.9 /lib64 +COPY --from=ru-build /lib64/libblas.so.3 /lib64 +COPY --from=ru-build /lib64/liblapack.so.3 /lib64 +COPY --from=ru-build /lib64/liblapacke.so.3 /lib64 +COPY --from=ru-build /lib64/libboost_chrono.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_date_time.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_filesystem.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_program_options.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_serialization.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_thread.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_system.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_unit_test_framework.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_atomic.so.1.66.0 /lib64 +COPY --from=ru-build /lib64/libboost_timer.so.1.66.0 /lib64 +COPY --from=ru-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 + +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" && \ + /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" && \ + /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" && \ + ldconfig + +# Copy the relevant configuration files for RRU +WORKDIR /opt/oai-lte-ru/etc +COPY --from=ru-build /oai-ran/docker/etc/rru* ./ + +WORKDIR /opt/oai-lte-ru + +ENTRYPOINT ["/opt/oai-lte-ru/bin/entrypoint.sh"] +CMD ["/opt/oai-lte-ru/bin/oairu.Rel15", "-O", "/opt/oai-lte-ru/etc/rru.conf"] diff --git a/docker/Dockerfile.lteRU.ubuntu18 b/docker/Dockerfile.lteRU.ubuntu18 new file mode 100644 index 0000000000..381d63d9f3 --- /dev/null +++ b/docker/Dockerfile.lteRU.ubuntu18 @@ -0,0 +1,94 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Dockerfile for the Open-Air-Interface BUILD service +# Valid for Ubuntu 18.04 +# +#--------------------------------------------------------------------- + +FROM ran-build:latest AS ru-build + +RUN rm -Rf /oai-ran +WORKDIR /oai-ran +COPY . . + +#run build_oai to build the target image +RUN /bin/sh oaienv && \ + cd cmake_targets && \ + mkdir -p log && \ + ./build_oai --RU --ninja -w USRP --verbose-ci + +RUN apt-get install -y python3-pip && \ + pip3 install --ignore-installed pyyaml && \ + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/enb_parameters.yaml + +#start from scratch for target executable +FROM ubuntu:bionic as oai-lte-ru +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=Europe/Paris + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ + DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + tzdata \ + software-properties-common \ + libblas3 \ + libatlas3-base \ + libconfig9 \ + net-tools \ + iputils-ping \ + iproute2 && \ + # Install UHD driver from ettus ppa + # At time of writing, it is 3.14 + add-apt-repository ppa:ettusresearch/uhd --yes && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install --yes \ + python \ + libusb-1.0-0 \ + libuhd003 \ + uhd-host && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /opt/oai-lte-ru/bin +COPY --from=ru-build /oai-ran/targets/bin/oairu.Rel15 . +COPY --from=ru-build /oai-ran/docker/scripts/lte_ru_entrypoint.sh entrypoint.sh + +WORKDIR /usr/local/lib/ +COPY --from=ru-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/libtcp_bridge_oai.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/librfsimulator.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/liboai_usrpdevif.so.Rel15 . +COPY --from=ru-build /oai-ran/targets/bin/libparams_libconfig.so . +COPY --from=ru-build /oai-ran/cmake_targets/ran_build/build/libdfts.so . +RUN /bin/bash -c "ln -s /usr/local/lib/liboai_eth_transpro.so.Rel15 /usr/local/lib/liboai_transpro.so" && \ + /bin/bash -c "ln -s /usr/local/lib/liboai_usrpdevif.so.Rel15 /usr/local/lib/liboai_device.so" && \ + /bin/bash -c "ln -s /usr/local/lib/librfsimulator.so.Rel15 /usr/local/lib/librfsimulator.so" && \ + ldconfig + +# Copy the relevant configuration files for RRU +WORKDIR /opt/oai-lte-ru/etc +COPY --from=ru-build /oai-ran/docker/etc/rru* ./ + +WORKDIR /opt/oai-lte-ru + +ENTRYPOINT ["/opt/oai-lte-ru/bin/entrypoint.sh"] +CMD ["/opt/oai-lte-ru/bin/oairu.Rel15", "-O", "/opt/oai-lte-ru/etc/rru.conf"] diff --git a/docker/Dockerfile.lteUE.rhel8.2 b/docker/Dockerfile.lteUE.rhel8.2 index e22343d63c..731abed1a8 100644 --- a/docker/Dockerfile.lteUE.rhel8.2 +++ b/docker/Dockerfile.lteUE.rhel8.2 @@ -25,7 +25,7 @@ # #--------------------------------------------------------------------- -FROM localhost/ran-build:latest AS lte-ue-build +FROM ran-build:latest AS lte-ue-build RUN rm -Rf /oai-ran WORKDIR /oai-ran @@ -37,10 +37,10 @@ RUN /bin/sh oaienv && \ mkdir -p log && \ ./build_oai --UE --ninja -w USRP --verbose-ci -# debug -#RUN ldconfig -v && ldd /oai-ran/targets/bin/lte-uesoftmodem.Rel15 -#RUN ls -lst /oai-ran/targets/bin -#RUN ls -lst /oai-ran/cmake_targets/ran_build/build/*.so +RUN yum install -y python3-pip && \ + pip3 install --ignore-installed pyyaml && \ + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_parameters.yaml && \ + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_sim_parameters.yaml #start from scratch for target executable FROM registry.access.redhat.com/ubi8/ubi:latest as oai-lte-ue @@ -59,12 +59,10 @@ RUN yum update -y && \ WORKDIR /opt/oai-lte-ue/bin COPY --from=lte-ue-build /oai-ran/targets/bin/lte-uesoftmodem.Rel15 . +COPY --from=lte-ue-build /oai-ran/docker/scripts/lte_ue_entrypoint.sh entrypoint.sh COPY --from=lte-ue-build /oai-ran/targets/bin/conf2uedata . COPY --from=lte-ue-build /oai-ran/targets/bin/nvram . COPY --from=lte-ue-build /oai-ran/targets/bin/usim . -COPY --from=lte-ue-build /oai-ran/targets/bin/.ue_emm.nvram0 . -COPY --from=lte-ue-build /oai-ran/targets/bin/.ue.nvram0 . -COPY --from=lte-ue-build /oai-ran/targets/bin/.usim.nvram0 . WORKDIR /usr/local/lib/ COPY --from=lte-ue-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . @@ -99,26 +97,10 @@ COPY --from=lte-ue-build /usr/local/lib64/libuhd.so.4.0.0 /usr/local/lib64 RUN ldconfig -#debug -#RUN ldd /opt/oai-lte-ue/bin/lte-uesoftmodem.Rel15 -#RUN ldd /opt/oai-lte-ue/bin/conf2uedata -#RUN ldd /opt/oai-lte-ue/bin/nvram -#RUN ldd /opt/oai-lte-ue/bin/usim -#RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -#RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 -#RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -#RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -#RUN ldd /usr/local/lib/libcoding.so -#RUN ldd /usr/local/lib/libparams_libconfig.so -#RUN ldd /usr/local/lib/libSIMU.so -#RUN ldd /usr/local/lib/libdfts.so - -# Copy the relevant configuration files for eNB +# Copy the relevant configuration files for UE WORKDIR /opt/oai-lte-ue/etc -COPY --from=lte-ue-build /oai-ran/ci-scripts/conf_files/ue.* . -COPY --from=lte-ue-build /oai-ran/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf ./ue_usim.conf +COPY --from=lte-ue-build /oai-ran/docker/etc . WORKDIR /opt/oai-lte-ue -#CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem", "-O", "/opt/oai-lte-ue/etc/enb.conf"] -#ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] -CMD ["sleep", "infinity"] +CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem.Rel15"] +ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] diff --git a/docker/Dockerfile.lteUE.ubuntu18 b/docker/Dockerfile.lteUE.ubuntu18 index 6af2e61991..6575a81899 100644 --- a/docker/Dockerfile.lteUE.ubuntu18 +++ b/docker/Dockerfile.lteUE.ubuntu18 @@ -37,11 +37,10 @@ RUN /bin/sh oaienv && \ mkdir -p log && \ ./build_oai --UE --ninja -w USRP --verbose-ci -# debug -#RUN ldconfig -v -#RUN ldd /oai-ran/targets/bin/lte-uesoftmodem.Rel15 -#RUN ls -lst /oai-ran/targets/bin -#RUN ls -lst /oai-ran/cmake_targets/ran_build/build/*.so +RUN apt-get install -y python3-pip && \ + pip3 install --ignore-installed pyyaml && \ + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_parameters.yaml && \ + python3 ./docker/scripts/generateTemplate.py ./docker/scripts/lte_ue_sim_parameters.yaml #start from scratch for target executable FROM ubuntu:bionic as oai-lte-ue @@ -76,12 +75,10 @@ RUN apt-get update && \ WORKDIR /opt/oai-lte-ue/bin COPY --from=lte-ue-build /oai-ran/targets/bin/lte-uesoftmodem.Rel15 . +COPY --from=lte-ue-build /oai-ran/docker/scripts/lte_ue_entrypoint.sh entrypoint.sh COPY --from=lte-ue-build /oai-ran/targets/bin/conf2uedata . COPY --from=lte-ue-build /oai-ran/targets/bin/nvram . COPY --from=lte-ue-build /oai-ran/targets/bin/usim . -COPY --from=lte-ue-build /oai-ran/targets/bin/.ue_emm.nvram0 . -COPY --from=lte-ue-build /oai-ran/targets/bin/.ue.nvram0 . -COPY --from=lte-ue-build /oai-ran/targets/bin/.usim.nvram0 . WORKDIR /usr/local/lib/ COPY --from=lte-ue-build /oai-ran/targets/bin/liboai_eth_transpro.so.Rel15 . @@ -100,26 +97,10 @@ COPY --from=lte-ue-build /usr/local/lib/libprotobuf-c.so.1 . RUN ldconfig -#debug -#RUN ldd /opt/oai-lte-ue/bin/lte-uesoftmodem.Rel15 -#RUN ldd /opt/oai-lte-ue/bin/conf2uedata -#RUN ldd /opt/oai-lte-ue/bin/nvram -#RUN ldd /opt/oai-lte-ue/bin/usim -#RUN ldd /usr/local/lib/liboai_eth_transpro.so.Rel15 -#RUN ldd /usr/local/lib/libtcp_bridge_oai.so.Rel15 -#RUN ldd /usr/local/lib/librfsimulator.so.Rel15 -#RUN ldd /usr/local/lib/liboai_usrpdevif.so.Rel15 -#RUN ldd /usr/local/lib/libcoding.so -#RUN ldd /usr/local/lib/libparams_libconfig.so -#RUN ldd /usr/local/lib/libSIMU.so -#RUN ldd /usr/local/lib/libdfts.so - -# Copy the relevant configuration files for eNB +# Copy the relevant configuration files for UE WORKDIR /opt/oai-lte-ue/etc -COPY --from=lte-ue-build /oai-ran/ci-scripts/conf_files/ue.* ./ -COPY --from=lte-ue-build /oai-ran/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf ./ue_usim.conf +COPY --from=lte-ue-build /oai-ran/docker/etc . WORKDIR /opt/oai-lte-ue -#CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem", "-O", "/opt/oai-lte-ue/etc/enb.conf"] -#ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] -CMD ["sleep", "infinity"] +CMD ["/opt/oai-lte-ue/bin/lte-uesoftmodem.Rel15"] +ENTRYPOINT ["/opt/oai-lte-ue/bin/entrypoint.sh"] diff --git a/docker/scripts/enb_entrypoint.sh b/docker/scripts/enb_entrypoint.sh index 31d99b2a67..6810a86416 100755 --- a/docker/scripts/enb_entrypoint.sh +++ b/docker/scripts/enb_entrypoint.sh @@ -2,17 +2,22 @@ set -euo pipefail +PREFIX=/opt/oai-enb +RRC_INACTIVITY_THRESHOLD=${RRC_INACTIVITY_THRESHOLD:-0} + # Based another env var, pick one template to use -if [[ -v USE_FDD_CU ]]; then ln -s /opt/oai-enb/etc/cu.fdd.conf /opt/oai-enb/etc/enb.conf; fi -if [[ -v USE_FDD_DU ]]; then ln -s /opt/oai-enb/etc/du.fdd.conf /opt/oai-enb/etc/enb.conf; fi -if [[ -v USE_FDD_MONO ]]; then ln -s /opt/oai-enb/etc/enb.fdd.conf /opt/oai-enb/etc/enb.conf; fi -if [[ -v USE_TDD_MONO ]]; then ln -s /opt/oai-enb/etc/enb.tdd.conf /opt/oai-enb/etc/enb.conf; fi -if [[ -v USE_FDD_RCC ]]; then ln -s /opt/oai-enb/etc/rcc.if4p5.enb.fdd.conf /opt/oai-enb/etc/enb.conf; fi -if [[ -v USE_FDD_RRU ]]; then ln -s /opt/oai-enb/etc/rru.fdd.conf /opt/oai-enb/etc/enb.conf; fi -if [[ -v USE_TDD_RRU ]]; then ln -s /opt/oai-enb/etc/rru.tdd.conf /opt/oai-enb/etc/enb.conf; fi +if [[ -v USE_FDD_CU ]]; then ln -s $PREFIX/etc/cu.fdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_FDD_DU ]]; then ln -s $PREFIX/etc/du.fdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_FDD_MONO ]]; then ln -s $PREFIX/etc/enb.fdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_TDD_MONO ]]; then ln -s $PREFIX/etc/enb.tdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_FDD_FAPI_RCC ]]; then ln -s $PREFIX/etc/rcc.nfapi.fdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_FDD_IF4P5_RCC ]]; then ln -s $PREFIX/etc/rcc.if4p5.fdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_TDD_IF4P5_RCC ]]; then ln -s $PREFIX/etc/rcc.if4p5.tdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_FDD_RRU ]]; then ln -s $PREFIX/etc/rru.fdd.conf $PREFIX/etc/enb.conf; fi +if [[ -v USE_TDD_RRU ]]; then ln -s $PREFIX/etc/rru.tdd.conf $PREFIX/etc/enb.conf; fi # Only this template will be manipulated -CONFIG_FILES=`ls /opt/oai-enb/etc/enb.conf` +CONFIG_FILES=`ls $PREFIX/etc/enb.conf || true` for c in ${CONFIG_FILES}; do # grep variable names (format: ${VAR}) from template to be rendered diff --git a/docker/scripts/enb_parameters.yaml b/docker/scripts/enb_parameters.yaml index a60fc20e29..749600f47d 100644 --- a/docker/scripts/enb_parameters.yaml +++ b/docker/scripts/enb_parameters.yaml @@ -25,7 +25,7 @@ dest_dir: docker/etc - configurations: - - filePrefix: cu + - filePrefix: cu.band7.tm1.25PRB outputfilename: "cu.fdd.conf" config: - key: Active_eNBs @@ -68,7 +68,7 @@ - key: ENB_IPV4_ADDRESS_FOR_X2C env: "@F1_CU_IP_ADDRESS@" - - filePrefix: du + - filePrefix: du.band7.tm1.25PRB outputfilename: "du.fdd.conf" config: - key: Active_eNBs @@ -159,6 +159,8 @@ env: "@ENB_S1U_IP_ADDRESS@" - key: ENB_IPV4_ADDRESS_FOR_X2C env: "@ENB_X2_IP_ADDRESS@" + - key: rrc_inactivity_threshold + env: "@RRC_INACTIVITY_THRESHOLD@" - key: FLEXRAN_ENABLED env: "@FLEXRAN_ENABLED@" - key: FLEXRAN_INTERFACE_NAME @@ -204,7 +206,7 @@ env: "@F1_CU_IP_ADDRESS@" - filePrefix: "rcc.band7.tm1.nfapi" - outputfilename: "rcc.if4p5.enb.fdd.conf" + outputfilename: "rcc.nfapi.fdd.conf" config: - key: Active_eNBs env: "@ENB_NAME@" @@ -246,3 +248,89 @@ - key: ENB_IPV4_ADDRESS_FOR_X2C env: "@F1_CU_IP_ADDRESS@" + - filePrefix: "rcc.band7.tm1.if4p5.lo.25PRB" + outputfilename: "rcc.if4p5.fdd.conf" + config: + - key: Active_eNBs + env: "@ENB_NAME@" + - key: eNB_name + env: "@ENB_NAME@" + - key: plmn_list + env: + mcc: "@MCC@" + mnc: "@MNC@" + mnc_length: "@MNC_LENGTH@" + - key: tracking_area_code + env: "@TAC@" + - key: eutra_band + env: "@UTRA_BAND_ID@" + - key: downlink_frequency + env: "@DL_FREQUENCY_IN_MHZ@000000" + - key: uplink_frequency_offset + env: "@UL_FREQUENCY_OFFSET_IN_MHZ@000000" + - key: Nid_cell + env: "@NID_CELL@" + - key: N_RB_DL + env: "@NB_PRB@" + - key: ipv4 + env: "@MME_S1C_IP_ADDRESS@" + - key: ENB_INTERFACE_NAME_FOR_S1_MME + env: "@RCC_IF_NAME@" + - key: ENB_IPV4_ADDRESS_FOR_S1_MME + env: "@RCC_S1C_IP_ADDRESS@" + - key: ENB_INTERFACE_NAME_FOR_S1U + env: "@RCC_IF_NAME@" + - key: ENB_IPV4_ADDRESS_FOR_S1U + env: "@RCC_IP_ADDRESS@" + - key: ENB_IPV4_ADDRESS_FOR_X2C + env: "@RCC_IP_ADDRESS@" + - key: local_if_name + env: "@IF4P5_IF_NAME@" + - key: remote_address + env: "@IF4P5_RRU_IP_ADDRESS@" + - key: local_address + env: "@IF4P5_RCC_IP_ADDRESS@" + + - filePrefix: "rcc.band40.tm1.25PRB" + outputfilename: "rcc.if4p5.tdd.conf" + config: + - key: Active_eNBs + env: "@ENB_NAME@" + - key: eNB_name + env: "@ENB_NAME@" + - key: plmn_list + env: + mcc: "@MCC@" + mnc: "@MNC@" + mnc_length: "@MNC_LENGTH@" + - key: tracking_area_code + env: "@TAC@" + - key: eutra_band + env: "@UTRA_BAND_ID@" + - key: downlink_frequency + env: "@DL_FREQUENCY_IN_MHZ@000000" + - key: uplink_frequency_offset + env: "@UL_FREQUENCY_OFFSET_IN_MHZ@000000" + - key: Nid_cell + env: "@NID_CELL@" + - key: N_RB_DL + env: "@NB_PRB@" + - key: ipv4 + env: "@MME_S1C_IP_ADDRESS@" + - key: ENB_INTERFACE_NAME_FOR_S1_MME + env: "@RCC_IF_NAME@" + - key: ENB_IPV4_ADDRESS_FOR_S1_MME + env: "@RCC_S1C_IP_ADDRESS@" + - key: ENB_INTERFACE_NAME_FOR_S1U + env: "@RCC_IF_NAME@" + - key: ENB_IPV4_ADDRESS_FOR_S1U + env: "@RCC_IP_ADDRESS@" + - key: ENB_IPV4_ADDRESS_FOR_X2C + env: "@RCC_IP_ADDRESS@" + - key: local_if_name + env: "@IF4P5_IF_NAME@" + - key: remote_address + env: "@IF4P5_RRU_IP_ADDRESS@" + - key: local_address + env: "@IF4P5_RCC_IP_ADDRESS@" + diff --git a/docker/scripts/generateTemplate.py b/docker/scripts/generateTemplate.py index 4949e9cf21..5ce0d146e5 100644 --- a/docker/scripts/generateTemplate.py +++ b/docker/scripts/generateTemplate.py @@ -35,21 +35,28 @@ def main(): data = yaml.full_load(f) dir = os.listdir(f'{data[0]["paths"]["source_dir"]}') - #identify configs, read and replace corresponding values for config in data[1]["configurations"]: filePrefix = config["filePrefix"] outputfilename = config["outputfilename"] + print('================================================') + print('filePrefix = ' + filePrefix) + print('outputfilename = ' + outputfilename) for inputfile in dir: if inputfile.find(filePrefix) >=0: - prefix_outputfile = {"cu": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', - "du": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + prefix_outputfile = {"cu.band7.tm1.25PRB": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "du.band7.tm1.25PRB": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "rru.fdd": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "rru.tdd": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "enb.band7.tm1.25PRB.usrpb210": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', "enb.band40.tm1.25PRB.FairScheduler.usrpb210": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', - "rcc.band7.tm1.nfapi": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}' + "rcc.band7.tm1.nfapi": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "rcc.band7.tm1.if4p5.lo.25PRB": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "rcc.band40.tm1.25PRB": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "ue.nfapi": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}', + "ue_sim_ci": f'{data[0]["paths"]["dest_dir"]}/{outputfilename}' } + print('inputfile = ' + inputfile) if filePrefix in prefix_outputfile: outputfile1 = prefix_outputfile[filePrefix] @@ -61,6 +68,9 @@ def main(): open(outputfile1, mode='w') as outputfile: for line in inputfile: count = 0 + if re.search(r'EHPLMN_LIST', line): + outputfile.write(line) + continue for key in config["config"]: if line.find(key["key"]) >= 0: count += 1 diff --git a/docker/scripts/lte_ru_entrypoint.sh b/docker/scripts/lte_ru_entrypoint.sh new file mode 100755 index 0000000000..f466e25ec2 --- /dev/null +++ b/docker/scripts/lte_ru_entrypoint.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +set -euo pipefail + +PREFIX=/opt/oai-lte-ru + +# Based another env var, pick one template to use +if [[ -v USE_FDD_RRU ]]; then ln -s $PREFIX/etc/rru.fdd.conf $PREFIX/etc/rru.conf; fi +if [[ -v USE_TDD_RRU ]]; then ln -s $PREFIX/etc/rru.tdd.conf $PREFIX/etc/rru.conf; fi + +# Only this template will be manipulated +CONFIG_FILES=`ls $PREFIX/etc/rru.conf || true` + +for c in ${CONFIG_FILES}; do + # grep variable names (format: ${VAR}) from template to be rendered + VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs) + + # create sed expressions for substituting each occurrence of ${VAR} + # with the value of the environment variable "VAR" + EXPRESSIONS="" + for v in ${VARS}; do + NEW_VAR=`echo $v | sed -e "s#@##g"` + if [[ "${!NEW_VAR}x" == "x" ]]; then + echo "Error: Environment variable '${NEW_VAR}' is not set." \ + "Config file '$(basename $c)' requires all of $VARS." + exit 1 + fi + EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g" + done + EXPRESSIONS="${EXPRESSIONS#';'}" + + # render template and inline replace config file + sed -i "${EXPRESSIONS}" ${c} +done + +# Load the USRP binaries +if [[ -v USE_B2XX ]]; then + /usr/lib/uhd/utils/uhd_images_downloader.py -t b2xx +elif [[ -v USE_X3XX ]]; then + /usr/lib/uhd/utils/uhd_images_downloader.py -t x3xx +elif [[ -v USE_N3XX ]]; then + /usr/lib/uhd/utils/uhd_images_downloader.py -t n3xx +fi + +echo "==================================" +echo "== Starting eNB soft modem" +if [[ -v USE_ADDITIONAL_OPTIONS ]]; then + echo "Additional option(s): ${USE_ADDITIONAL_OPTIONS}" + new_args=() + while [[ $# -gt 0 ]]; do + new_args+=("$1") + shift + done + for word in ${USE_ADDITIONAL_OPTIONS}; do + new_args+=("$word") + done + echo "${new_args[@]}" + exec "${new_args[@]}" +else + echo "$@" + exec "$@" +fi diff --git a/docker/scripts/lte_ue_entrypoint.sh b/docker/scripts/lte_ue_entrypoint.sh new file mode 100755 index 0000000000..235128f738 --- /dev/null +++ b/docker/scripts/lte_ue_entrypoint.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +set -euo pipefail + +PREFIX=/opt/oai-lte-ue + +# Based another env var, pick one template to use +if [[ -v USE_NFAPI ]]; then ln -s $PREFIX/etc/ue.nfapi.conf $PREFIX/etc/ue.conf; fi + +# Only this template will be manipulated and the USIM one! +CONFIG_FILES=`ls $PREFIX/etc/ue.conf $PREFIX/etc/ue_usim.conf || true` + +for c in ${CONFIG_FILES}; do + # grep variable names (format: ${VAR}) from template to be rendered + VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs) + + # create sed expressions for substituting each occurrence of ${VAR} + # with the value of the environment variable "VAR" + EXPRESSIONS="" + for v in ${VARS}; do + NEW_VAR=`echo $v | sed -e "s#@##g"` + if [[ "${!NEW_VAR}x" == "x" ]]; then + echo "Error: Environment variable '${NEW_VAR}' is not set." \ + "Config file '$(basename $c)' requires all of $VARS." + exit 1 + fi + EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g" + done + EXPRESSIONS="${EXPRESSIONS#';'}" + + # render template and inline replace config file + sed -i "${EXPRESSIONS}" ${c} +done + +#now generate USIM files +# At this point all operations will be run from $PREFIX! +cd $PREFIX +$PREFIX/bin/conf2uedata -c $PREFIX/etc/ue_usim.conf -o $PREFIX + +# Load the USRP binaries +if [[ -v USE_B2XX ]]; then + /usr/lib/uhd/utils/uhd_images_downloader.py -t b2xx +elif [[ -v USE_X3XX ]]; then + /usr/lib/uhd/utils/uhd_images_downloader.py -t x3xx +elif [[ -v USE_N3XX ]]; then + /usr/lib/uhd/utils/uhd_images_downloader.py -t n3xx +fi + +# in case we have conf file, append +new_args=() +while [[ $# -gt 0 ]]; do + new_args+=("$1") + shift +done +if [[ -v USE_NFAPI ]]; then + new_args+=("-O") + new_args+=("$PREFIX/etc/ue.conf") +fi + +echo "==================================" +echo "== Starting LTE UE soft modem" +if [[ -v USE_ADDITIONAL_OPTIONS ]]; then + echo "Additional option(s): ${USE_ADDITIONAL_OPTIONS}" + for word in ${USE_ADDITIONAL_OPTIONS}; do + new_args+=("$word") + done + echo "${new_args[@]}" + exec "${new_args[@]}" +else + echo "${new_args[@]}" + exec "${new_args[@]}" +fi diff --git a/docker/scripts/lte_ue_parameters.yaml b/docker/scripts/lte_ue_parameters.yaml new file mode 100644 index 0000000000..977659bb54 --- /dev/null +++ b/docker/scripts/lte_ue_parameters.yaml @@ -0,0 +1,37 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ + +--- +- paths: + source_dir: "ci-scripts/conf_files/" + dest_dir: docker/etc + +- configurations: + - filePrefix: ue.nfapi + outputfilename: "ue.nfapi.conf" + config: + - key: remote_n_address + env: "@ENB_IP_ADDRESS@" + - key: local_n_address + env: "@LTE_UE_IP_ADDRESS@" + - key: local_n_if_name + env: "@UE_NFAPI_IF_NAME@" + diff --git a/docker/scripts/lte_ue_sim_parameters.yaml b/docker/scripts/lte_ue_sim_parameters.yaml new file mode 100644 index 0000000000..a339ed7504 --- /dev/null +++ b/docker/scripts/lte_ue_sim_parameters.yaml @@ -0,0 +1,47 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ + +--- +- paths: + source_dir: "openair3/NAS/TOOLS/" + dest_dir: docker/etc + +- configurations: + - filePrefix: ue_sim_ci + outputfilename: "ue_usim.conf" + config: + - key: MNC + env: "@MNC@" + - key: MCC + env: "@MCC@" + - key: MSIN + env: "@SHORT_IMSI@" + - key: USIM_API_K + env: "@LTE_KEY@" + - key: OPC + env: "@OPC@" + - key: MSISDN + env: "@MSISDN@" + - key: HPLMN + env: "@HPLMN@" + - key: OPLMN_LIST + env: "@HPLMN@" + diff --git a/executables/main-fs6.c b/executables/main-fs6.c index 5283ce5eaa..438edb4044 100644 --- a/executables/main-fs6.c +++ b/executables/main-fs6.c @@ -750,7 +750,7 @@ void phy_procedures_eNB_uespec_RX_fromsplit(uint8_t *bufferZone, int nbBlocks,PH recvFs6Ul(bufferZone, nbBlocks, eNB, ul_propa); // dirty memory allocation in OAI... - for (int i = 0; i < NUMBER_OF_UCI_VARS_MAX; i++) + for (int i = 0; i < NUMBER_OF_UCI_MAX; i++) if ( eNB->uci_vars[i].frame == proc->frame_rx && eNB->uci_vars[i].subframe == proc->subframe_rx ) eNB->uci_vars[i].active=0; @@ -1145,7 +1145,7 @@ void appendFs6DLUEcch(uint8_t *bufferZone, PHY_VARS_eNB *eNB, int frame, int sub commonUDP_t *newUDPheader=(commonUDP_t *) firstFreeByte; bool first_UE=true; - for (int i = 0; i < NUMBER_OF_UCI_VARS_MAX; i++) { + for (int i = 0; i < NUMBER_OF_UCI_MAX; i++) { LTE_eNB_UCI *uci = &(eNB->uci_vars[i]); if ((uci->active == 1) && (uci->frame == frame) && (uci->subframe == subframe)) { diff --git a/executables/main-ocp.c b/executables/main-ocp.c index 0712dfbf57..0355582b2b 100644 --- a/executables/main-ocp.c +++ b/executables/main-ocp.c @@ -204,7 +204,6 @@ void init_eNB_afterRU(void) { for (int inst=0; instframe_parms.nb_antennas_rx = 0; eNB->frame_parms.nb_antennas_tx = 0; eNB->prach_vars.rxsigF[0] = (int16_t **)malloc16(64*sizeof(int16_t *)); @@ -230,12 +229,26 @@ void init_eNB_afterRU(void) { 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]; - eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; } } - AssertFatal( eNB->frame_parms.nb_antennas_rx > 0 && eNB->frame_parms.nb_antennas_rx < 4, ""); - AssertFatal( eNB->frame_parms.nb_antennas_tx > 0 && eNB->frame_parms.nb_antennas_rx < 4, ""); + + AssertFatal( eNB->frame_parms.nb_antennas_rx > 0 && eNB->frame_parms.nb_antennas_rx < 5, ""); + AssertFatal( eNB->frame_parms.nb_antennas_tx > 0 && eNB->frame_parms.nb_antennas_rx < 5, ""); + + phy_init_lte_eNB(eNB,0,0); + + // need to copy rxdataF after L1 variables are allocated + for (int inst=0; instnum_RU; ru_id++) { + for (int i=0; iRU_list[ru_id]->nb_rx; aa++,i++) + eNB->common_vars.rxdataF[aa] = eNB->RU_list[ru_id]->common.rxdataF[i]; + } + } + } + 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]); @@ -802,7 +815,7 @@ int init_rf(RU_t *ru) { pthread_setname_np(pthread_self(),name); return ret; } - + void ocp_init_RU(RU_t *ru, char *rf_config_file, int send_dmrssync) { PHY_VARS_eNB *eNB0= (PHY_VARS_eNB *)NULL; int i; diff --git a/executables/main_ru.c b/executables/main_ru.c new file mode 100644 index 0000000000..93a580560e --- /dev/null +++ b/executables/main_ru.c @@ -0,0 +1,382 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file oairu.c + * \brief Top-level threads for radio-unit + * \author R. Knopp + * \date 2020 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ + + +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include + + + + +#include "assertions.h" +#include "PHY/types.h" + +#include "PHY/defs_RU.h" +#include "common/config/config_userapi.h" +#include "common/utils/load_module_shlib.h" + + +#include "../../ARCH/COMMON/common_lib.h" +#include "../../ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" + + +#include "PHY/phy_vars.h" +#include "SCHED/sched_common_vars.h" +#include "PHY/TOOLS/phy_scope_interface.h" +#include "common/utils/LOG/log.h" +#include "common/utils/LOG/vcd_signal_dumper.h" +#include "PHY/INIT/phy_init.h" +#include "openair2/ENB_APP/enb_paramdef.h" +#include "system.h" + +#include +#include +#include + +static int DEFBANDS[] = {7}; +static int DEFENBS[] = {0}; +static int DEFBFW[] = {0x00007fff}; + +THREAD_STRUCT thread_struct; + +pthread_cond_t sync_cond; +pthread_mutex_t sync_mutex; +int sync_var=-1; //!< protected by mutex \ref sync_mutex. +int config_sync_var=-1; + +volatile int oai_exit = 0; +uint16_t sf_ahead = 4; +RU_t ru_m; + + +extern void init_RU0(RU_t *ru,int ru_id,char *rf_config_file, int send_dmrssync); +extern void init_RU_proc(RU_t *ru); +extern void kill_RU_proc(RU_t *ru); +extern void set_function_spec_param(RU_t *ru); + +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; + + +void nfapi_setmode(nfapi_mode_t nfapi_mode) { return; } +void exit_function(const char *file, const char *function, const int line, const char *s) { + + if (s != NULL) { + printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s); + } + close_log_mem(); + oai_exit = 1; + + if (ru_m.rfdevice.trx_end_func) { + ru_m.rfdevice.trx_end_func(&ru_m.rfdevice); + ru_m.rfdevice.trx_end_func = NULL; + } + + if (ru_m.ifdevice.trx_end_func) { + ru_m.ifdevice.trx_end_func(&ru_m.ifdevice); + ru_m.ifdevice.trx_end_func = NULL; + } + + pthread_mutex_destroy(ru_m.ru_mutex); + pthread_cond_destroy(ru_m.ru_cond); + sleep(1); //allow lte-softmodem threads to exit first + exit(1); +} + + +static void get_options(void) { + CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); + get_common_options(SOFTMODEM_ENB_BIT ); + CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); + + //RCConfig(); + +} + + + + + +extern void phy_free_RU(RU_t *); + +nfapi_mode_t nfapi_getmode(void) { + return(NFAPI_MODE_PNF); +} + +void oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind) { + + AssertFatal(1==0,"This is bad ... please check why we get here\n"); +} + +void wait_eNBs(void){ return; } + +uint64_t downlink_frequency[MAX_NUM_CCs][4]; + + +int main ( int argc, char **argv ) +{ + + if ( load_configmodule(argc,argv,0) == NULL) { + exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); + } + + logInit(); + printf("Reading in command-line options\n"); + get_options (); + + if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { + fprintf(stderr,"Getting configuration failed\n"); + exit(-1); + } + +#if T_TRACER + T_Config_Init(); +#endif + printf("configuring for RRU\n"); + +#ifndef PACKAGE_VERSION +# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" +#endif + LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); + + /* Read configuration */ + + printf("About to Init RU threads\n"); + + + RU_t *ru=&ru_m; + + paramdef_t RUParams[] = RUPARAMS_DESC; + paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; + config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL); + + int j=0; + uint64_t ru_mask=1; + pthread_mutex_t ru_mutex; pthread_mutex_init(&ru_mutex,NULL); + pthread_cond_t ru_cond; pthread_cond_init(&ru_cond,NULL); + + ru->ru_mask= &ru_mask; + ru->ru_mutex = &ru_mutex; + ru->ru_cond = &ru_cond; + + ru->if_timing = synch_to_ext_device; + ru->num_eNB = 0; + ru->has_ctrl_prt = 1; + if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) { + ru->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr)); + } + + if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) { + if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) { + ru->openair0_cfg.clock_source = internal; + LOG_D(PHY, "RU clock source set as internal\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) { + ru->openair0_cfg.clock_source = external; + LOG_D(PHY, "RU clock source set as external\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) { + ru->openair0_cfg.clock_source = gpsdo; + LOG_D(PHY, "RU clock source set as gpsdo\n"); + } else { + LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); + } + } + else { + ru->openair0_cfg.clock_source = unset; + } + + if (config_isparamset(RUParamList.paramarray[j], RU_SDR_TME_SRC)) { + if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "internal") == 0) { + ru->openair0_cfg.time_source = internal; + LOG_D(PHY, "RU time source set as internal\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "external") == 0) { + ru->openair0_cfg.time_source = external; + LOG_D(PHY, "RU time source set as external\n"); + } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "gpsdo") == 0) { + ru->openair0_cfg.time_source = gpsdo; + LOG_D(PHY, "RU time source set as gpsdo\n"); + } else { + LOG_E(PHY, "Erroneous RU time source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); + } + } + else { + ru->openair0_cfg.time_source = unset; + } + + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { + if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { + AssertFatal(1==0,"IF_NAME is required\n"); + } else { + ru->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); + ru->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); + ru->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); + ru->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); + ru->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); + + // Check if control port set + if (!(config_isparamset(RUParamList.paramarray[j],RU_REMOTE_PORTC_IDX)) ) { + printf("Removing control port for RU %d\n",j); + ru->has_ctrl_prt = 0; + } else { + ru->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); + ru->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + printf(" Control port %u \n",ru->eth_params.my_portc); + } + + if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { + ru->if_south = LOCAL_RF; + ru->function = NGFI_RRU_IF5; + ru->eth_params.transp_preference = ETH_UDP_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF5 (udp)\n",j); + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { + ru->if_south = LOCAL_RF; + ru->function = NGFI_RRU_IF5; + ru->eth_params.transp_preference = ETH_RAW_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF5 (raw)\n",j); + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { + ru->if_south = LOCAL_RF; + ru->function = NGFI_RRU_IF4p5; + ru->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF4p5 (udp)\n",j); + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { + ru->if_south = LOCAL_RF; + ru->function = NGFI_RRU_IF4p5; + ru->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF4p5 (raw)\n",j); + } + + printf("RU %d is_slave=%s\n",j,*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr)); + + if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) ru->is_slave=1; + else ru->is_slave=0; + + printf("RU %d ota_sync_enabled=%s\n",j,*(RUParamList.paramarray[j][RU_OTA_SYNC_ENABLE_IDX].strptr)); + + if (strcmp(*(RUParamList.paramarray[j][RU_OTA_SYNC_ENABLE_IDX].strptr), "yes") == 0) ru->ota_sync_enable=1; + else ru->ota_sync_enable=0; + } + + ru->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; + ru->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); + ru->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; + /* sf_extension is in unit of samples for 30.72MHz here, has to be scaled later */ + ru->sf_extension = *(RUParamList.paramarray[j][RU_SF_EXTENSION_IDX].uptr); + + for (int i=0; inum_bands; i++) ru->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; + } //strcmp(local_rf, "yes") == 0 + else { + printf("RU %d: Transport %s\n",j,*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr)); + ru->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); + ru->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); + ru->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); + ru->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); + ru->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + ru->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); + ru->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); + + if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { + ru->if_south = REMOTE_IF5; + ru->function = NGFI_RAU_IF5; + ru->eth_params.transp_preference = ETH_UDP_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { + ru->if_south = REMOTE_IF5; + ru->function = NGFI_RAU_IF5; + ru->eth_params.transp_preference = ETH_RAW_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { + ru->if_south = REMOTE_IF4p5; + ru->function = NGFI_RAU_IF4p5; + ru->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; + } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { + ru->if_south = REMOTE_IF4p5; + ru->function = NGFI_RAU_IF4p5; + ru->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; + } + + if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) ru->is_slave=1; + else ru->is_slave=0; + } /* strcmp(local_rf, "yes") != 0 */ + + ru->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); + ru->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); + ru->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + ru->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); + + + set_worker_conf("WORKER_ENABLE"); + + mlockall(MCL_CURRENT | MCL_FUTURE); + pthread_cond_init(&sync_cond,NULL); + pthread_mutex_init(&sync_mutex, NULL); + + init_RU0(ru,0,get_softmodem_params()->rf_config_file,get_softmodem_params()->send_dmrs_sync); + ru->rf_map.card=0; + ru->rf_map.chain=(get_softmodem_params()->chain_offset); + + LOG_I(PHY, "Initializing RRU descriptor : (%s,%s,%d)\n", ru_if_types[ru->if_south], NB_timing[ru->if_timing], ru->function); + set_function_spec_param(ru); + LOG_I(PHY, "Starting ru_thread , is_slave %d, send_dmrs %d\n", ru->is_slave, ru->generate_dmrs_sync); + init_RU_proc(ru); + + pthread_mutex_lock(&ru_mutex); + while (ru_mask>0) + pthread_cond_wait(&ru_cond,&ru_mutex); + pthread_mutex_unlock(&ru_mutex); + LOG_I(PHY,"RU configured, unlocking threads\n"); + config_sync_var=0; + pthread_mutex_lock(&sync_mutex); + sync_var=0; + pthread_cond_broadcast(&sync_cond); + pthread_mutex_unlock(&sync_mutex); + + while (oai_exit==0) sleep(1); + // stop threads + + kill_RU_proc(ru); + phy_free_RU(ru); + + free_lte_top(); + end_configmodule(); + + if (ru->rfdevice.trx_end_func) { + ru->rfdevice.trx_end_func(&ru->rfdevice); + ru->rfdevice.trx_end_func = NULL; + } + + if (ru->ifdevice.trx_end_func) { + ru->ifdevice.trx_end_func(&ru->ifdevice); + ru->ifdevice.trx_end_func = NULL; + } + + + + logClean(); + printf("Bye.\n"); + return 0; +} diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index f5e49b73b8..e9319f9d3c 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -86,6 +86,8 @@ #include "T.h" #include "nfapi/oai_integration/vendor_ext.h" #include +#include +#include //#define DEBUG_THREADS 1 //#define USRP_DEBUG 1 @@ -354,10 +356,10 @@ void *nrL1_stats_thread(void *param) { while (!oai_exit) { sleep(1); fd=fopen("nrL1_stats.log","w"); - AssertFatal(fd!=NULL,"Cannot open ngL1_stats.log\n"); + AssertFatal(fd!=NULL,"Cannot open nrL1_stats.log\n"); dump_nr_I0_stats(fd,gNB); dump_pusch_stats(fd,gNB); - // dump_uci_stats(fd,eNB,eNB->proc.L1_proc_tx.frame_tx); + // nr_dump_uci_stats(fd,eNB,eNB->proc.L1_proc_tx.frame_tx); fclose(fd); } return(NULL); @@ -371,7 +373,9 @@ void init_gNB_Tpool(int inst) { // ULSCH decoding threadpool gNB->threadPool = (tpool_t*)malloc(sizeof(tpool_t)); int numCPU = sysconf(_SC_NPROCESSORS_ONLN); + LOG_I(PHY,"Number of threads requested in config file: %d, Number of threads available on this machine: %d\n",gNB->pusch_proc_threads,numCPU); int threadCnt = min(numCPU, gNB->pusch_proc_threads); + if (threadCnt < 2) LOG_E(PHY,"Number of threads for gNB should be more than 1. Allocated only %d\n",threadCnt); char ul_pool[80]; sprintf(ul_pool,"-1"); int s_offset = 0; @@ -401,7 +405,6 @@ void init_gNB_Tpool(int inst) { if(opp_enabled == 1) threadCreate(&proc->process_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW); threadCreate(&proc->L1_stats_thread,nrL1_stats_thread,(void*)gNB,"L1_stats",-1,OAI_PRIORITY_RT_LOW); - } @@ -490,8 +493,6 @@ printf("after %p\n", gNB->common_vars.rxdataF[aa]); } - - void init_gNB(int single_thread_flag,int wait_for_sync) { int inst; diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 6d5b0ec8a3..088c636c7a 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -24,14 +24,8 @@ #include #include #include -#include -#include -#include #include #include -#include -#include -#include #include #include @@ -39,7 +33,6 @@ #include "common/utils/assertions.h" #include "common/utils/system.h" -#include "msc.h" #include "../../ARCH/COMMON/common_lib.h" #include "../../ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" @@ -50,20 +43,15 @@ #include "PHY/types.h" #include "PHY/defs_nr_common.h" #include "PHY/phy_extern.h" -#include "PHY/LTE_TRANSPORT/transport_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_proto.h" #include "PHY/INIT/phy_init.h" -#include "SCHED/sched_eNB.h" #include "SCHED_NR/sched_nr.h" #include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" -#include "RRC/LTE/rrc_extern.h" -#include "PHY_INTERFACE/phy_interface.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#include "enb_config.h" #include #ifdef SMBV @@ -112,6 +100,7 @@ void configure_ru(int idx, void *arg); void configure_rru(int idx, void *arg); int attach_rru(RU_t *ru); int connect_rau(RU_t *ru); +static void NRRCconfig_RU(void); uint16_t sf_ahead; uint16_t slot_ahead; @@ -757,9 +746,9 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { // currently we switch beams every 10 slots (should = 1 TDD period in FR2) and we take the beam index of the first symbol of the first slot of this period int beam=0; if (slot%10==0) { - if (ru->common.beam_id[0][slot*fp->symbols_per_slot] < 8) { - beam = ru->common.beam_id[0][slot*fp->symbols_per_slot] | 8; - } + if ( ru->common.beam_id && (ru->common.beam_id[0][slot*fp->symbols_per_slot] < 8)) { + beam = ru->common.beam_id[0][slot*fp->symbols_per_slot] | 8; + } } /* if (slot==0 || slot==40) beam=0|8; @@ -1397,6 +1386,7 @@ void *ru_thread( void *param ) { } } + // At this point, all information for subframe has been received on FH interface res = pullTpool(gNB->resp_L1, gNB->threadPool); syncMsg = (processingData_L1_t *)NotifiedFifoData(res); @@ -1409,6 +1399,7 @@ void *ru_thread( void *param ) { res->key = proc->tti_rx; pushTpool(gNB->threadPool, res); + } printf( "Exiting ru_thread \n"); @@ -1849,7 +1840,7 @@ void init_NR_RU(char *rf_config_file) pthread_cond_init(&RC.ru_cond,NULL); // read in configuration file) printf("configuring RU from file\n"); - RCconfig_RU(); + NRRCconfig_RU(); LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",RC.nb_nr_L1_inst,RC.nb_RU,get_nprocs()); LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); @@ -1924,7 +1915,7 @@ void stop_RU(int nb_ru) /* --------------------------------------------------------*/ /* from here function to use configuration module */ -void RCconfig_RU(void) +static void NRRCconfig_RU(void) { int i = 0, j = 0; paramdef_t RUParams[] = RUPARAMS_DESC; @@ -1991,9 +1982,9 @@ void RCconfig_RU(void) } else { LOG_I(PHY,"Setting time source to internal\n"); - RC.ru[j]->openair0_cfg.time_source = internal; + RC.ru[j]->openair0_cfg.time_source = internal; } - + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { RC.ru[j]->if_south = LOCAL_RF; @@ -2063,7 +2054,7 @@ void RCconfig_RU(void) RC.ru[j]->if_south = REMOTE_IF4p5; RC.ru[j]->function = NGFI_RAU_IF4p5; RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; - } + } } /* strcmp(local_rf, "yes") != 0 */ RC.ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); @@ -2072,6 +2063,7 @@ void RCconfig_RU(void) RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); RC.ru[j]->if_frequency = *(RUParamList.paramarray[j][RU_IF_FREQUENCY].u64ptr); RC.ru[j]->if_freq_offset = *(RUParamList.paramarray[j][RU_IF_FREQ_OFFSET].iptr); + RC.ru[j]->do_precoding = *(RUParamList.paramarray[j][RU_DO_PRECODING].iptr); if (config_isparamset(RUParamList.paramarray[j], RU_BF_WEIGHTS_LIST_IDX)) { RC.ru[j]->nb_bfw = RUParamList.paramarray[j][RU_BF_WEIGHTS_LIST_IDX].numelt; diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index c38d1249d2..16daddc22e 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -75,8 +75,10 @@ #define CONFIG_HLP_ULMCS_PHYTEST "Set the uplink MCS for PHYTEST mode\n" #define CONFIG_HLP_DLBW_PHYTEST "Set the number of PRBs used for DLSCH in PHYTEST mode\n" #define CONFIG_HLP_ULBW_PHYTEST "Set the number of PRBs used for ULSCH in PHYTEST mode\n" +#define CONFIG_HLP_PRB "Set the number of PRBs for SA\n" #define CONFIG_HLP_DLBM_PHYTEST "Bitmap for DLSCH slots (slot 0 starts at LSB)\n" #define CONFIG_HLP_ULBM_PHYTEST "Bitmap for ULSCH slots (slot 0 starts at LSB)\n" +#define CONFIG_HLP_SSC "Set the start subcarrier \n" #define CONFIG_HLP_TDD "Set hardware to TDD mode (default: FDD). Used only with -U (otherwise set in config file).\n" #define CONFIG_HLP_UE "Set the lte softmodem as a UE\n" #define CONFIG_HLP_L2MONW "Enable L2 wireshark messages on localhost \n" diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index c7e636736b..4727d09b04 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -163,10 +163,17 @@ int otg_enabled; uint32_t timing_advance = 0; uint64_t num_missed_slots=0; // counter for the number of missed slots +#include +#include + int split73=0; void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { AssertFatal(false, "Must not be called in this context\n"); } +void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, uint16_t rnti, int32_t stat) { + AssertFatal(false, "Must not be called in this context\n"); +} + extern void reset_opp_meas(void); extern void print_opp_meas(void); @@ -363,35 +370,10 @@ int create_gNB_tasks(uint32_t gnb_nb) { } } - if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) { + /*if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) { LOG_E(GTPU, "Create task for GTPV1U failed\n"); return -1; - } - } - } - - if (AMF_MODE_ENABLED && (get_softmodem_params()->phy_test==0 && get_softmodem_params()->do_ra==1)){ - if (gnb_nb > 0) { - if(NGAP_CONF_MODE){ - if (itti_create_task (TASK_NGAP, ngap_gNB_task, NULL) < 0) { - LOG_E(NGAP, "Create task for NGAP failed\n"); - return -1; - } - } else { - LOG_E(NGAP, "Ngap task not created\n"); - } - - if(!emulate_rf){ - if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { - LOG_E(UDP_, "Create task for UDP failed\n"); - return -1; - } - } - - if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) { - LOG_E(GTPU, "Create task for GTPV1U failed\n"); - return -1; - } + }*/ } } @@ -406,6 +388,13 @@ int create_gNB_tasks(uint32_t gnb_nb) { LOG_E(NR_RRC, "Create task for NR RRC gNB failed\n"); return -1; } + //Use check on x2ap to consider the NSA scenario and check on AMF_MODE_ENABLED for the SA scenario + if(is_x2ap_enabled() || AMF_MODE_ENABLED){ + if (itti_create_task (TASK_GTPV1_U, &nr_gtpv1u_gNB_task, NULL) < 0) { + LOG_E(GTPU, "Create task for GTPV1U failed\n"); + return -1; + } + } } return 0; @@ -643,7 +632,6 @@ static void wait_nfapi_init(char *thread_name) { void init_pdcp(void) { if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) { // pdcp_layer_init(); - // pdcp_layer_init_for_CU(); uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; if (IS_SOFTMODEM_NOS1) { @@ -739,20 +727,12 @@ if(!IS_SOFTMODEM_NOS1) #endif LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); - - if(IS_SOFTMODEM_NOS1) - init_pdcp(); - if (RC.nb_nr_L1_inst > 0) RCconfig_NR_L1(); // don't create if node doesn't connect to RRC/S1/GTP AssertFatal(create_gNB_tasks(1) == 0,"cannot create ITTI tasks\n"); - - - - /* Start the agent. If it is turned off in the configuration, it won't start */ /* RCconfig_nr_flexran(); diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 9bfeac3f95..1912dea225 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -27,6 +27,8 @@ #include "SCHED_NR_UE/phy_frame_config_nr.h" #include "SCHED_NR_UE/defs.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" +#include "executables/softmodem-common.h" +#include "SCHED_NR_UE/pucch_uci_ue_nr.h" /* * NR SLOT PROCESSING SEQUENCE @@ -85,6 +87,14 @@ * */ +#ifndef NO_RAT_NR + #define DURATION_RX_TO_TX (NR_UE_CAPABILITY_SLOT_RX_TO_TX) /* for NR this will certainly depends to such UE capability which is not yet defined */ +#else + #define DURATION_RX_TO_TX (6) /* For LTE, this duration is fixed to 4 and it is linked to LTE standard for both modes FDD/TDD */ +#endif +#define RX_JOB_ID 0x1010 +#define TX_JOB_ID 100 + typedef enum { pss = 0, pbch = 1, @@ -101,6 +111,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, ue->Mod_id = UE_id; ue->mac_enabled = 1; ue->if_inst = nr_ue_if_module_init(0); + ue->dci_thres = 0; // Setting UE mode to NOT_SYNCHED by default for (gNB_id = 0; gNB_id < nb_connected_gNB; gNB_id++){ @@ -123,10 +134,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, * \param arg is a pointer to a \ref PHY_VARS_NR_UE structure. */ -typedef struct syncData_s { - UE_nr_rxtx_proc_t proc; - PHY_VARS_NR_UE *UE; -} syncData_t; +typedef nr_rxtx_thread_data_t syncData_t; static void UE_synch(void *arg) { syncData_t *syncD=(syncData_t *) arg; @@ -273,7 +281,11 @@ static void UE_synch(void *arg) { } } -void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { +void processSlotTX(void *arg) { + + nr_rxtx_thread_data_t *rxtxD = (nr_rxtx_thread_data_t *) arg; + UE_nr_rxtx_proc_t *proc = &rxtxD->proc; + PHY_VARS_NR_UE *UE = rxtxD->UE; fapi_nr_config_request_t *cfg = &UE->nrUE_config; int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_slot_tx); uint8_t gNB_id = 0; @@ -305,10 +317,14 @@ void processSlotTX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { } } -void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { +void processSlotRX(void *arg) { + nr_rxtx_thread_data_t *rxtxD = (nr_rxtx_thread_data_t *) arg; + UE_nr_rxtx_proc_t *proc = &rxtxD->proc; + PHY_VARS_NR_UE *UE = rxtxD->UE; fapi_nr_config_request_t *cfg = &UE->nrUE_config; int rx_slot_type = nr_ue_slot_select(cfg, proc->frame_rx, proc->nr_slot_rx); + int tx_slot_type = nr_ue_slot_select(cfg, proc->frame_tx, proc->nr_slot_tx); uint8_t gNB_id = 0; if (rx_slot_type == NR_DOWNLINK_SLOT || rx_slot_type == NR_MIXED_SLOT){ @@ -324,7 +340,7 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, no_relay, NULL ); #else uint64_t a=rdtsc(); - phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel); + phy_procedures_nrUE_RX(UE, proc, gNB_id, get_nrUE_params()->nr_dlsch_parallel, &rxtxD->txFifo); LOG_D(PHY, "In %s: slot %d, time %lu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc()-a)/3500); #endif @@ -342,34 +358,38 @@ void processSlotRX( PHY_VARS_NR_UE *UE, UE_nr_rxtx_proc_t *proc) { nr_pdcp_tick(proc->frame_rx, proc->nr_slot_rx / UE->frame_parms.slots_per_subframe); } } + + // Wait for PUSCH processing to finish + notifiedFIFO_elt_t *res; + res = pullTpool(&rxtxD->txFifo,&(get_nrUE_params()->Tpool)); + delNotifiedFIFO_elt(res); + + } else { + processSlotTX(rxtxD); } -} + if (tx_slot_type == NR_UPLINK_SLOT || tx_slot_type == NR_MIXED_SLOT){ + if (UE->UE_mode[gNB_id] <= PUSCH) { + if (get_softmodem_params()->usim_test==0) { + pucch_procedures_ue_nr(UE, + gNB_id, + proc, + FALSE); + } -/*! - * \brief This is the UE thread for RX subframe n and TX subframe n+4. - * This thread performs the phy_procedures_UE_RX() on every received slot. - * then, if TX is enabled it performs TX for n+4. - * \param arg is a pointer to a \ref PHY_VARS_NR_UE structure. - * \returns a pointer to an int. The storage is not on the heap and must not be freed. - */ + LOG_D(PHY, "Sending Uplink data \n"); + nr_ue_pusch_common_procedures(UE, + proc->nr_slot_tx, + &UE->frame_parms,1); + } -typedef struct processingData_s { - UE_nr_rxtx_proc_t proc; - PHY_VARS_NR_UE *UE; -} processingData_t; - -void UE_processing(void *arg) { - processingData_t *rxtxD = (processingData_t *) arg; - UE_nr_rxtx_proc_t *proc = &rxtxD->proc; - PHY_VARS_NR_UE *UE = rxtxD->UE; - int slot_tx = proc->nr_slot_tx; - int frame_tx = proc->frame_tx; - - processSlotRX(UE, proc); - processSlotTX(UE, proc); - ue_ta_procedures(UE, slot_tx, frame_tx); + if (UE->UE_mode[gNB_id] > NOT_SYNCHED && UE->UE_mode[gNB_id] < PUSCH) { + nr_ue_prach_procedures(UE, proc, gNB_id); + } + LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", proc->frame_tx, proc->nr_slot_tx); + } + ue_ta_procedures(UE, proc->nr_slot_tx, proc->frame_tx); } void dummyWrite(PHY_VARS_NR_UE *UE,openair0_timestamp timestamp, int writeBlockSize) { @@ -486,25 +506,44 @@ void *UE_thread(void *arg) { int start_rx_stream = 0; AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), ""); UE->rfdevice.host_type = RAU_HOST; + UE->lost_sync = 0; + UE->is_synchronized = 0; AssertFatal(UE->rfdevice.trx_start_func(&UE->rfdevice) == 0, "Could not start the device\n"); + notifiedFIFO_t nf; initNotifiedFIFO(&nf); - int nbSlotProcessing=0; - int thread_idx=0; + notifiedFIFO_t freeBlocks; initNotifiedFIFO_nothreadSafe(&freeBlocks); + + int nbSlotProcessing=0; + int thread_idx=0; NR_UE_MAC_INST_t *mac = get_mac_inst(0); int timing_advance = UE->timing_advance; - for (int i=0; iframe_parms.slots_per_frame; int absolute_slot=0, decoded_frame_rx=INT_MAX, trashed_frames=0; + for (int i=0; itxFifo); + pushNotifiedFIFO_nothreadSafe(&freeBlocks, newElt); + } + while (!oai_exit) { + if (UE->lost_sync) { + int nb = abortTpool(&(get_nrUE_params()->Tpool),RX_JOB_ID); + nb += abortNotifiedFIFO(&nf, RX_JOB_ID); + LOG_I(PHY,"Number of aborted slots %d\n",nb); + for (int i=0; iis_synchronized = 0; + UE->lost_sync = 0; + } + if (syncRunning) { notifiedFIFO_elt_t *res=tryPullTpool(&nf,&(get_nrUE_params()->Tpool)); @@ -514,9 +553,10 @@ void *UE_thread(void *arg) { if (UE->is_synchronized) { decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx); // shift the frame index with all the frames we trashed meanwhile we perform the synch search - decoded_frame_rx=(decoded_frame_rx + (!UE->init_sync_frame) + trashed_frames) % MAX_FRAME_NUMBER; + decoded_frame_rx=(decoded_frame_rx + UE->init_sync_frame + trashed_frames) % MAX_FRAME_NUMBER; } delNotifiedFIFO_elt(res); + start_rx_stream=0; } else { readFrame(UE, ×tamp, true); trashed_frames+=2; @@ -563,13 +603,13 @@ void *UE_thread(void *arg) { // whatever means thread_idx // Fix me: will be wrong when slot 1 is slow, as slot 2 finishes - // Slot 3 will overlap if RX_NB_TH is 2 + // Slot 3 will overlap if NR_RX_NB_TH is 2 // this is general failure in UE !!! - thread_idx = absolute_slot % RX_NB_TH; + thread_idx = absolute_slot % NR_RX_NB_TH; int slot_nr = absolute_slot % nb_slot_frame; notifiedFIFO_elt_t *msgToPush; AssertFatal((msgToPush=pullNotifiedFIFO_nothreadSafe(&freeBlocks)) != NULL,"chained list failure"); - processingData_t *curMsg=(processingData_t *)NotifiedFifoData(msgToPush); + nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(msgToPush); curMsg->UE=UE; // update thread index for received subframe curMsg->proc.thread_id = thread_idx; @@ -597,18 +637,18 @@ void *UE_thread(void *arg) { for (int i=0; iframe_parms.nb_antennas_tx; i++) txp[i] = (void *)&UE->common_vars.txdata[i][UE->frame_parms.get_samples_slot_timestamp( - ((slot_nr + DURATION_RX_TO_TX - RX_NB_TH)%nb_slot_frame),&UE->frame_parms,0)]; + ((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH)%nb_slot_frame),&UE->frame_parms,0)]; int readBlockSize, writeBlockSize; if (slot_nr<(nb_slot_frame - 1)) { readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms); - writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - RX_NB_TH) % nb_slot_frame, &UE->frame_parms); + writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms); } else { UE->rx_offset_diff = computeSamplesShift(UE); readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) - UE->rx_offset_diff; - writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - RX_NB_TH) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff; + writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff; } AssertFatal(readBlockSize == @@ -640,27 +680,27 @@ void *UE_thread(void *arg) { notifiedFIFO_elt_t *res; - while (nbSlotProcessing >= RX_NB_TH) { + while (nbSlotProcessing >= NR_RX_NB_TH) { res=pullTpool(&nf, &(get_nrUE_params()->Tpool)); nbSlotProcessing--; - processingData_t *tmp=(processingData_t *)res->msgData; + nr_rxtx_thread_data_t *tmp=(nr_rxtx_thread_data_t *)res->msgData; if (tmp->proc.decoded_frame_rx != -1) decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx); - else + else decoded_frame_rx=-1; pushNotifiedFIFO_nothreadSafe(&freeBlocks,res); } - if ( decoded_frame_rx>0 && decoded_frame_rx != curMsg->proc.frame_rx) + if (decoded_frame_rx>0 && decoded_frame_rx != curMsg->proc.frame_rx) LOG_E(PHY,"Decoded frame index (%d) is not compatible with current context (%d), UE should go back to synch mode\n", - decoded_frame_rx, curMsg->proc.frame_rx ); + decoded_frame_rx, curMsg->proc.frame_rx); // use previous timing_advance value to compute writeTimestamp writeTimestamp = timestamp+ UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX - - RX_NB_TH) - firstSymSamp - openair0_cfg[0].tx_sample_advance - + - NR_RX_NB_TH) - firstSymSamp - openair0_cfg[0].tx_sample_advance - UE->N_TA_offset - timing_advance; // but use current UE->timing_advance value to compute writeBlockSize @@ -670,7 +710,7 @@ void *UE_thread(void *arg) { } int flags = 0; - int slot_tx_usrp = slot_nr + DURATION_RX_TO_TX - RX_NB_TH; + int slot_tx_usrp = slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH; if (openair0_cfg[0].duplex_mode == duplex_mode_TDD) { @@ -685,6 +725,7 @@ void *UE_thread(void *arg) { nrofUplinkSymbols = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; } uint8_t num_UL_slots = nrofUplinkSlots + (nrofUplinkSymbols != 0); + uint8_t first_tx_slot = tdd_period - num_UL_slots; if (slot_tx_usrp % tdd_period == first_tx_slot) @@ -710,26 +751,9 @@ void *UE_thread(void *arg) { memset(txp[i], 0, writeBlockSize); nbSlotProcessing++; - msgToPush->key=slot_nr; + LOG_D(PHY,"Number of slots being processed at the moment: %d\n",nbSlotProcessing); pushTpool(&(get_nrUE_params()->Tpool), msgToPush); - if (IS_SOFTMODEM_RFSIM) { //getenv("RFSIMULATOR") - // FixMe: Wait previous thread is done, because race conditions seems too bad - // in case of actual RF board, the overlap between threads mitigate the issue - // We must receive one message, that proves the slot processing is done - res=pullTpool(&nf, &(get_nrUE_params()->Tpool)); - nbSlotProcessing--; - processingData_t *tmp=(processingData_t *)res->msgData; - - if (tmp->proc.decoded_frame_rx != -1) - decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx); - else - decoded_frame_rx=-1; - //decoded_frame_rx=tmp->proc.decoded_frame_rx; - - pushNotifiedFIFO_nothreadSafe(&freeBlocks,res); - } - } // while !oai_exit return NULL; diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 21534734ad..1f9dabf255 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -83,17 +83,15 @@ unsigned short config_frames[4] = {2,9,11,13}; // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) #include "PHY/TOOLS/phy_scope_interface.h" #include "PHY/TOOLS/nr_phy_scope.h" -#define NRUE_MAIN #include #include "executables/softmodem-common.h" #include "executables/thread-common.h" -#if defined(ITTI_SIM) || defined(RFSIM_NAS) #include "nr_nas_msg_sim.h" -#endif extern const char *duplex_mode[]; THREAD_STRUCT thread_struct; +nrUE_params_t nrUE_params; // Thread variables pthread_cond_t nfapi_sync_cond; @@ -154,8 +152,9 @@ int transmission_mode = 1; int numerology = 0; int oaisim_flag = 0; int emulate_rf = 0; -uint32_t N_RB_DL=106; -char uecap_xer[1024],uecap_xer_in=0; +uint32_t N_RB_DL = 106; +char uecap_xer_in = 0; +char uecap_xer[1024]; /* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed * this is very hackish - find a proper solution @@ -184,6 +183,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) { void print_difftimes(void) { LOG_I(HW,"difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec); } + int create_tasks_nrue(uint32_t ue_nb) { LOG_D(NR_RRC, "%s(ue_nb:%d)\n", __FUNCTION__, ue_nb); itti_wait_ready(1); @@ -194,12 +194,10 @@ int create_tasks_nrue(uint32_t ue_nb) { LOG_E(NR_RRC, "Create task for RRC UE failed\n"); return -1; } -#if defined(ITTI_SIM) || defined(RFSIM_NAS) if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) { LOG_E(NR_RRC, "Create task for NAS UE failed\n"); return -1; } -#endif } itti_wait_ready(0); @@ -240,9 +238,16 @@ nrUE_params_t *get_nrUE_params(void) { } /* initialie thread pools used for NRUE processing paralleliation */ void init_tpools(uint8_t nun_dlsch_threads) { - char *params=calloc(1,(RX_NB_TH*3)+1); - for (int i=0; inode_type = ngran_gNB; - init_NR_UE(1,rrc_config_path); if(IS_SOFTMODEM_NOS1 || get_softmodem_params()->sa) init_pdcp(); @@ -518,14 +519,6 @@ int main( int argc, char **argv ) { // wait for end of program printf("TYPE TO TERMINATE\n"); - //Don't understand why generation of RRCSetupRequest is called here. It seems wrong - protocol_ctxt_t ctxt_pP = {0}; - ctxt_pP.enb_flag = ENB_FLAG_NO; - ctxt_pP.rnti = 0x1234; - RC.nrrrc = (gNB_RRC_INST **)malloc(1*sizeof(gNB_RRC_INST *)); - RC.nrrrc[0] = (gNB_RRC_INST*)malloc(sizeof(gNB_RRC_INST)); - RC.nrrrc[0]->node_type = ngran_gNB; - nr_rrc_ue_generate_RRCSetupRequest(ctxt_pP.module_id, 0); if (create_tasks_nrue(1) < 0) { printf("cannot create ITTI tasks\n"); exit(-1); // need a softer mode diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index faa1e3eca6..52c0ee234c 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -73,9 +73,6 @@ extern uint64_t get_nrUE_optmask(void); extern uint64_t set_nrUE_optmask(uint64_t bitmask); extern nrUE_params_t *get_nrUE_params(void); -#ifdef NRUE_MAIN -nrUE_params_t nrUE_params; -#endif // In nr-ue.c extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg); diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index 43a91449ff..61e7f32da4 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -73,6 +73,7 @@ extern "C" #define CONFIG_HLP_STMON "Enable processing timing measurement of lte softmodem on per subframe basis \n" #define CONFIG_HLP_256QAM "Use the 256 QAM mcs table for PDSCH\n" +#define CONFIG_HLP_NONSTOP "Go back to frame sync mode after 100 consecutive PBCH failures\n" //#define CONFIG_HLP_NUMUES "Set the number of UEs for the emulation" #define CONFIG_HLP_MSLOTS "Skip the missed slots/subframes \n" #define CONFIG_HLP_ULMCS "Set the maximum uplink MCS\n" @@ -88,6 +89,8 @@ extern "C" #define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n" #define CONFIG_HLP_PARALLEL_CMD "three config for level of parallelism 'PARALLEL_SINGLE_THREAD', 'PARALLEL_RU_L1_SPLIT', or 'PARALLEL_RU_L1_TRX_SPLIT'\n" #define CONFIG_HLP_WORKER_CMD "two option for worker 'WORKER_DISABLE' or 'WORKER_ENABLE'\n" +#define CONFIG_HLP_USRP_THREAD "having extra thead for usrp tx\n" + #define CONFIG_HLP_NOS1 "Disable s1 interface\n" #define CONFIG_HLP_RFSIM "Run in rf simulator mode (also known as basic simulator)\n" #define CONFIG_HLP_NOKRNMOD "(noS1 only): Use tun instead of namesh module \n" @@ -117,6 +120,7 @@ extern "C" #define USIM_TEST softmodem_params.usim_test #define USE_256QAM_TABLE softmodem_params.use_256qam_table #define NFAPI softmodem_params.nfapi +#define NON_STOP softmodem_params.non_stop #define DEFAULT_RFCONFIG_FILE "/usr/local/etc/syriq/ue.band7.tm1.PRB100.NR40.dat"; @@ -138,7 +142,7 @@ extern int usrp_tx_thread; {"a" , CONFIG_HLP_CHOFF, 0, iptr:&CHAIN_OFFSET, defintval:0, TYPE_INT, 0}, \ {"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ - {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:0, TYPE_INT, 0}, \ + {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&NUMEROLOGY, defintval:1, TYPE_INT, 0}, \ {"band" , CONFIG_HLP_BAND, PARAMFLAG_BOOL, iptr:&BAND, defintval:78, TYPE_INT, 0}, \ {"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&EMULATE_RF, defintval:0, TYPE_INT, 0}, \ {"parallel-config", CONFIG_HLP_PARALLEL_CMD, 0, strptr:(char **)¶llel_config, defstrval:NULL, TYPE_STRING, 0}, \ @@ -151,6 +155,7 @@ extern int usrp_tx_thread; {"use-256qam-table", CONFIG_HLP_256QAM, PARAMFLAG_BOOL, iptr:&USE_256QAM_TABLE, defintval:0, TYPE_INT, 0}, \ {"usrp-tx-thread-config",CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \ {"nfapi", CONFIG_HLP_NFAPI, 0, u8ptr:&nfapi_mode, defintval:0, TYPE_UINT8, 0}, \ + {"non-stop", CONFIG_HLP_NONSTOP, PARAMFLAG_BOOL, iptr:&NON_STOP, defintval:0, TYPE_INT, 0}, \ } @@ -242,6 +247,7 @@ typedef struct { uint32_t send_dmrs_sync; int use_256qam_table; uint8_t nfapi; + int non_stop; } softmodem_params_t; extern uint64_t get_softmodem_optmask(void); @@ -253,6 +259,7 @@ extern char *get_softmodem_function(uint64_t *sofmodemfunc_mask_ptr); extern void set_softmodem_sighandler(void); extern uint64_t downlink_frequency[MAX_NUM_CCs][4]; extern int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; +extern int usrp_tx_thread; extern uint16_t sl_ahead; extern uint16_t sf_ahead; extern volatile int oai_exit; diff --git a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h index fc9cd66077..8520a5d162 100644 --- a/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h +++ b/nfapi/open-nFAPI/pnf/public_inc/nfapi_pnf_interface.h @@ -27,7 +27,6 @@ extern "C" { #include #include "nfapi_nr_interface.h" #include "nfapi_nr_interface_scf.h" - #include #include "openair1/PHY/defs_gNB.h" diff --git a/openair1/PHY/CODING/TESTBENCH/coding_unitary_defs.h b/openair1/PHY/CODING/TESTBENCH/coding_unitary_defs.h new file mode 100644 index 0000000000..f77ffff2eb --- /dev/null +++ b/openair1/PHY/CODING/TESTBENCH/coding_unitary_defs.h @@ -0,0 +1,53 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#ifndef __CODING_UNITARY_DEFS__h__ +#define __CODING_UNITARY_DEFS__h__ +int oai_exit=0; +unsigned int NB_UE_INST = 1; +#include "openair1/PHY/defs_UE.h" +PHY_VARS_UE ***PHY_vars_UE_g; +#include "common/ran_context.h" +RAN_CONTEXT_t RC; + +void exit_function(const char* file, const char* function, const int line, const char *s) { + const char * msg= s==NULL ? "no comment": s; + printf("Exiting at: %s:%d %s(), %s\n", file, line, function, msg); + exit(-1); +} + +signed char quantize(double D, double x, unsigned char B) { + double qxd; + short maxlev; + qxd = floor(x / D); + maxlev = 1 << (B - 1); //(char)(pow(2,B-1)); + + if (qxd <= -maxlev) + qxd = -maxlev; + else if (qxd >= maxlev) + qxd = maxlev - 1; + + return ((char) qxd); +} + + +#endif + diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index f6769251cd..91c5d59611 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -26,9 +26,11 @@ #include "assertions.h" #include "SIMULATION/TOOLS/sim.h" #include "PHY/CODING/nrLDPC_extern.h" -#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" +//#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/PHY/CODING/nrLDPC_decoder_LYC/nrLDPC_decoder_LYC.h" -#define MAX_NUM_DLSCH_SEGMENTS 16 +#include "openair1/PHY/defs_nr_common.h" +#include "coding_unitary_defs.h" + #define MAX_BLOCK_LENGTH 8448 #ifndef malloc16 @@ -81,9 +83,6 @@ typedef struct { int n_iter_max; } n_iter_stats_t; -RAN_CONTEXT_t RC; -PHY_VARS_UE ***PHY_vars_UE_g; -uint16_t NB_UE_INST = 1; nrLDPC_encoderfunc_t encoder_orig; short lift_size[51]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,20,22,24,26,28,30,32,36,40,44,48,52,56,60,64,72,80,88,96,104,112,120,128,144,160,176,192,208,224,240,256,288,320,352,384}; @@ -117,7 +116,7 @@ int test_ldpc(short No_iteration, sigma = 1.0/sqrt(2*SNR); opp_enabled=1; //short test_input[block_length]; - unsigned char *test_input[MAX_NUM_DLSCH_SEGMENTS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};; + unsigned char *test_input[MAX_NUM_NR_DLSCH_SEGMENTS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};; //short *c; //padded codeword unsigned char *estimated_output[MAX_NUM_DLSCH_SEGMENTS]; unsigned char *estimated_output_bit[MAX_NUM_DLSCH_SEGMENTS]; diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index e43ba507ab..8e7e377542 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,16 +11,12 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" -#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" //#include "common/utils/LOG/log.h" - +#include "coding_unitary_defs.h" //#define DEBUG_DCI_POLAR_PARAMS //#define DEBUG_POLAR_TIMING //#define DEBUG_POLARTEST -RAN_CONTEXT_t RC; -PHY_VARS_UE ***PHY_vars_UE_g; -uint16_t NB_UE_INST = 1; int main(int argc, char *argv[]) { diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c index f750d24977..c9ed678a8f 100644 --- a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -1,13 +1,10 @@ #include #include "SIMULATION/TOOLS/sim.h" #include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" -#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" +#include "coding_unitary_defs.h" //#define DEBUG_SMALLBLOCKTEST -RAN_CONTEXT_t RC; -PHY_VARS_UE ***PHY_vars_UE_g; -uint16_t NB_UE_INST = 1; int main(int argc, char *argv[]) { diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c index 18db8a01fb..8fe115b23a 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_decoder.c @@ -40,9 +40,9 @@ #include "assertions.h" int8_t polar_decoder(double *input, - uint32_t *out, - t_nrPolar_params *polarParams, - uint8_t listSize) + uint32_t *out, + const t_nrPolar_params *polarParams, + uint8_t listSize) { //Assumes no a priori knowledge. uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); @@ -299,7 +299,7 @@ int8_t polar_decoder(double *input, int8_t polar_decoder_dci(double *input, uint32_t *out, - t_nrPolar_params *polarParams, + const t_nrPolar_params *polarParams, uint8_t listSize, uint16_t n_RNTI) { uint8_t ***bit = nr_alloc_uint8_3D_array(polarParams->N, (polarParams->n+1), 2*listSize); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h index a44a08a701..c2e9fd9381 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_defs.h @@ -138,22 +138,22 @@ typedef struct nrPolar_params t_nrPolar_params; void polar_encoder(uint32_t *input, uint32_t *output, - t_nrPolar_params *polarParams); + const t_nrPolar_params *polarParams); void polar_encoder_dci(uint32_t *in, uint32_t *out, - t_nrPolar_params *polarParams, + const t_nrPolar_params *polarParams, uint16_t n_RNTI); void polar_encoder_fast(uint64_t *A, void *out, int32_t crcmask, uint8_t ones_flag, - t_nrPolar_params *polarParams); + const t_nrPolar_params *polarParams); int8_t polar_decoder(double *input, - uint32_t *output, - t_nrPolar_params *polarParams, + uint32_t *output, + const t_nrPolar_params *polarParams, uint8_t listSize); uint32_t polar_decoder_int16(int16_t *input, @@ -163,21 +163,21 @@ uint32_t polar_decoder_int16(int16_t *input, int8_t polar_decoder_dci(double *input, uint32_t *out, - t_nrPolar_params *polarParams, + const t_nrPolar_params *polarParams, uint8_t listSize, uint16_t n_RNTI); void generic_polar_decoder(const t_nrPolar_params *pp, - decoder_node_t *node); + decoder_node_t *node); void applyFtoleft(const t_nrPolar_params *pp, - decoder_node_t *node); + decoder_node_t *node); void applyGtoright(const t_nrPolar_params *pp, - decoder_node_t *node); + decoder_node_t *node); void computeBeta(const t_nrPolar_params *pp, - decoder_node_t *node); + decoder_node_t *node); void build_decoder_tree(t_nrPolar_params *pp); void build_polar_tables(t_nrPolar_params *polarParams); diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c index 27c062c217..e61b3dff9b 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_encoder.c @@ -43,7 +43,7 @@ void polar_encoder(uint32_t *in, uint32_t *out, - t_nrPolar_params *polarParams) { + const t_nrPolar_params *polarParams) { if (1) {//polarParams->idx == 0 || polarParams->idx == 1) { //PBCH or PDCCH /* uint64_t B = (((uint64_t)*in)&((((uint64_t)1)<<32)-1)) | (((uint64_t)crc24c((uint8_t*)in,polarParams->payloadBits)>>8)<payloadBits); @@ -154,7 +154,7 @@ void polar_encoder(uint32_t *in, void polar_encoder_dci(uint32_t *in, uint32_t *out, - t_nrPolar_params *polarParams, + const t_nrPolar_params *polarParams, uint16_t n_RNTI) { #ifdef DEBUG_POLAR_ENCODER_DCI printf("[polar_encoder_dci] in: [0]->0x%08x \t [1]->0x%08x \t [2]->0x%08x \t [3]->0x%08x\n", in[0], in[1], in[2], in[3]); @@ -251,9 +251,9 @@ void polar_encoder_dci(uint32_t *in, #endif } -static inline void polar_rate_matching(t_nrPolar_params *polarParams,void *in,void *out) __attribute__((always_inline)); +static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void *in,void *out) __attribute__((always_inline)); -static inline void polar_rate_matching(t_nrPolar_params *polarParams,void *in,void *out) { +static inline void polar_rate_matching(const t_nrPolar_params *polarParams,void *in,void *out) { // handle rate matching with a single 128 bit word using bit shuffling // can be done with SIMD intrisics if needed @@ -411,7 +411,7 @@ void polar_encoder_fast(uint64_t *A, void *out, int32_t crcmask, uint8_t ones_flag, - t_nrPolar_params *polarParams) { + const t_nrPolar_params *polarParams) { // AssertFatal(polarParams->K > 32, "K = %d < 33, is not supported yet\n",polarParams->K); AssertFatal(polarParams->K < 129, "K = %d > 128, is not supported yet\n",polarParams->K); AssertFatal(polarParams->payloadBits < 65, "payload bits = %d > 64, is not supported yet\n",polarParams->payloadBits); diff --git a/openair1/PHY/CODING/nr_rate_matching.c b/openair1/PHY/CODING/nr_rate_matching.c index 0553bc19bf..b1ce6ab0de 100644 --- a/openair1/PHY/CODING/nr_rate_matching.c +++ b/openair1/PHY/CODING/nr_rate_matching.c @@ -493,8 +493,8 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, } ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z; -// AssertFatal(Foffset <= E,"Foffset %d > E %d\n",Foffset,E); -// AssertFatal(Foffset <= Ncb,"Foffset %d > Ncb %d\n",Foffset,Ncb); + AssertFatal(Foffset <= E,"Foffset %d > E %d\n",Foffset,E); + AssertFatal(Foffset <= Ncb,"Foffset %d > Ncb %d\n",Foffset,Ncb); #ifdef RM_DEBUG printf("nr_rate_matching_ldpc_rx: Clear %d, E %d, k0 %d, Ncb %d, rvidx %d\n", clear, E, ind, Ncb, rvidx); diff --git a/openair1/PHY/INIT/init_top.c b/openair1/PHY/INIT/init_top.c index 0990a58266..81fb28cc98 100644 --- a/openair1/PHY/INIT/init_top.c +++ b/openair1/PHY/INIT/init_top.c @@ -73,7 +73,6 @@ void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) { init_unscrambling_lut(); init_scrambling_lut(); //set_taus_seed(1328); - init_sss(); } void free_lte_top(void) { diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 2c7e3e88eb..1daeb72187 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -35,7 +35,7 @@ #include "assertions.h" #include #include "nfapi/oai_integration/vendor_ext.h" - +#include extern uint32_t from_earfcn(int eutra_bandP,uint32_t dl_earfcn); extern int32_t get_uldl_offset(int eutra_bandP); @@ -46,6 +46,17 @@ uint8_t dmrs1_tab[8] = { 0, 2, 3, 4, 6, 8, 9, 10 }; int N_RB_DL_array[6] = { 6, 15, 25, 50, 75, 100 }; +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + +void pdsch_procedures(PHY_VARS_eNB *eNB, + L1_rxtx_proc_t *proc, + int harq_pid, + LTE_eNB_DLSCH_t *dlsch, + LTE_eNB_DLSCH_t *dlsch1); + +void init_sss(void); + int l1_north_init_eNB () { int i,j; @@ -347,6 +358,33 @@ void phy_config_sib13_eNB(module_id_t Mod_id,int CC_id,int mbsfn_Area_idx, lte_gold_mbsfn_khz_1dot25 (fp, RC.eNB[Mod_id][CC_id]->lte_gold_mbsfn_khz_1dot25_table, fp->Nid_cell_mbsfn); } +void fill_subframe_mask(PHY_VARS_eNB *eNB) { + + AssertFatal(eNB->subframe_mask!=NULL,"Subframe mask is null\n"); + int32_t **dummy_tx=eNB->common_vars.txdataF; + eNB->common_vars.txdataF = eNB->subframe_mask; + + for (int sf=0;sf<10;sf++) { + if (subframe_select(&eNB->frame_parms,sf)==SF_DL) { + LTE_DL_eNB_HARQ_t *dlsch_harq=eNB->dlsch[0][0]->harq_processes[0]; + L1_rxtx_proc_t proc; + proc.frame_tx=0; + proc.subframe_tx=sf; + eNB->dlsch[0][0]->harq_ids[0][sf]=0; + eNB->dlsch[0][0]->rnti=0x1234; + dlsch_harq->nb_rb=48; + dlsch_harq->rb_alloc[0]=(uint32_t)0xffffffff; + dlsch_harq->Qm=2; + dlsch_harq->Nl=1; + dlsch_harq->pdsch_start=1; + dlsch_harq->mimo_mode=(eNB->frame_parms.nb_antenna_ports_eNB>1) ? ALAMOUTI : SISO; + dlsch_harq->dl_power_off = 1; + computeRhoB_eNB(4,eNB->frame_parms.pdsch_config_common.p_b,eNB->frame_parms.nb_antenna_ports_eNB,eNB->dlsch[0][0],dlsch_harq->dl_power_off); + pdsch_procedures(eNB,&proc,0,eNB->dlsch[0][0],NULL); + } + } + eNB->common_vars.txdataF = dummy_tx; +} int phy_init_lte_eNB(PHY_VARS_eNB *eNB, unsigned char is_secondary_eNB, @@ -385,7 +423,9 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, lte_gold (fp, eNB->lte_gold_table, fp->Nid_cell); generate_pcfich_reg_mapping (fp); generate_phich_reg_mapping (fp); + init_sss(); + init_fde(); for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { eNB->first_run_timing_advance[UE_id] = 1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here. @@ -397,9 +437,13 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, eNB->first_run_I0_measurements = 1; ///This flag used to be static. With multiple eNBs this does no longer work, hence we put it in the structure. However it has to be initialized with 1, which is performed here. + eNB->use_DTX=1; if (NFAPI_MODE!=NFAPI_MODE_VNF) { common_vars->rxdata = (int32_t **)NULL; common_vars->txdataF = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t *)); + if (eNB->use_DTX==0) { + eNB->subframe_mask = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t *)); + } common_vars->rxdataF = (int32_t **)malloc16(64*sizeof(int32_t *)); LOG_I(PHY,"[INIT] NB_ANTENNA_PORTS_ENB:%d fp->nb_antenna_ports_eNB:%d\n", NB_ANTENNA_PORTS_ENB, fp->nb_antenna_ports_eNB); @@ -409,17 +453,19 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, LOG_I(PHY,"[INIT] common_vars->txdataF[%d] = %p (%lu bytes)\n", i,common_vars->txdataF[i], fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t)); + if (eNB->use_DTX==0 && inb_antenna_ports_eNB) eNB->subframe_mask[i] = malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) ); } } + LOG_I(PHY,"[INIT]SRS allocation\n"); // Channel estimates for SRS - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - srs_vars[UE_id].srs_ch_estimates = (int32_t **) malloc16 (64 * sizeof (int32_t *)); - srs_vars[UE_id].srs_ch_estimates_time = (int32_t **) malloc16 (64 * sizeof (int32_t *)); + for (int srs_id = 0; srs_id < NUMBER_OF_SRS_MAX; srs_id++) { + srs_vars[srs_id].srs_ch_estimates = (int32_t **) malloc16 (64 * sizeof (int32_t *)); + srs_vars[srs_id].srs_ch_estimates_time = (int32_t **) malloc16 (64 * sizeof (int32_t *)); for (i = 0; i < 64; i++) { - srs_vars[UE_id].srs_ch_estimates[i] = (int32_t *) malloc16_clear (sizeof (int32_t) * fp->ofdm_symbol_size); - srs_vars[UE_id].srs_ch_estimates_time[i] = (int32_t *) malloc16_clear (sizeof (int32_t) * fp->ofdm_symbol_size * 2); + srs_vars[srs_id].srs_ch_estimates[i] = (int32_t *) malloc16_clear (sizeof (int32_t) * fp->ofdm_symbol_size); + srs_vars[srs_id].srs_ch_estimates_time[i] = (int32_t *) malloc16_clear (sizeof (int32_t) * fp->ofdm_symbol_size * 2); } } //UE_id @@ -427,10 +473,11 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, init_ulsch_power_LUT (); // SRS - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - srs_vars[UE_id].srs = (int32_t *) malloc16_clear (2 * fp->ofdm_symbol_size * sizeof (int32_t)); + for (int srs_id = 0; srs_id < NUMBER_OF_SRS_MAX; srs_id++) { + srs_vars[srs_id].srs = (int32_t *) malloc16_clear (2 * fp->ofdm_symbol_size * sizeof (int32_t)); } + LOG_I(PHY,"PRACH allocation\n"); // PRACH prach_vars->prachF = (int16_t *) malloc16_clear (1024 * 2 * sizeof (int16_t)); // assume maximum of 64 RX antennas for PRACH receiver @@ -461,34 +508,33 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB, LOG_D(PHY,"[INIT] prach_vars->rxsigF[%d] = %p\n",i,prach_vars->rxsigF[i]); }*/ - for (UE_id=0; UE_idrxdataF_ext = (int32_t **) malloc16 (2 * sizeof (int32_t *)); - pusch_vars[UE_id]->rxdataF_ext2 = (int32_t **) malloc16 (2 * sizeof (int32_t *)); - pusch_vars[UE_id]->drs_ch_estimates = (int32_t **) malloc16 (2 * sizeof (int32_t *)); - pusch_vars[UE_id]->drs_ch_estimates_time = (int32_t **) malloc16 (2 * sizeof (int32_t *)); - pusch_vars[UE_id]->rxdataF_comp = (int32_t **) malloc16 (2 * sizeof (int32_t *)); - pusch_vars[UE_id]->ul_ch_mag = (int32_t **) malloc16 (2 * sizeof (int32_t *)); - pusch_vars[UE_id]->ul_ch_magb = (int32_t **) malloc16 (2 * sizeof (int32_t *)); + pusch_vars[ULSCH_id] = (LTE_eNB_PUSCH *) malloc16_clear (NUMBER_OF_ULSCH_MAX * sizeof (LTE_eNB_PUSCH)); + pusch_vars[ULSCH_id]->rxdataF_ext = (int32_t **) malloc16 (4 * sizeof (int32_t *)); + pusch_vars[ULSCH_id]->rxdataF_ext2 = (int32_t **) malloc16 (4 * sizeof (int32_t *)); + pusch_vars[ULSCH_id]->drs_ch_estimates = (int32_t **) malloc16 (4 * sizeof (int32_t *)); + pusch_vars[ULSCH_id]->drs_ch_estimates_time = (int32_t **) malloc16 (4 * sizeof (int32_t *)); + pusch_vars[ULSCH_id]->rxdataF_comp = (int32_t **) malloc16 (4 * sizeof (int32_t *)); + pusch_vars[ULSCH_id]->ul_ch_mag = (int32_t **) malloc16 (4 * sizeof (int32_t *)); + pusch_vars[ULSCH_id]->ul_ch_magb = (int32_t **) malloc16 (4 * sizeof (int32_t *)); AssertFatal (fp->ofdm_symbol_size > 127, "fp->ofdm_symbol_size %d<128\n", fp->ofdm_symbol_size); AssertFatal (fp->symbols_per_tti > 11, "fp->symbols_per_tti %d < 12\n", fp->symbols_per_tti); AssertFatal (fp->N_RB_UL > 5, "fp->N_RB_UL %d < 6\n", fp->N_RB_UL); - - for (i = 0; i < 2; i++) { - // RK 2 times because of output format of FFT! + AssertFatal (fp->nb_antennas_rx > 0,"fp->nb_antennas_rx = %d\n",fp->nb_antennas_rx); + for (i = 0; i < fp->nb_antennas_rx; i++) { // FIXME We should get rid of this - pusch_vars[UE_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->rxdataF_ext2[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->drs_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->drs_ch_estimates_time[i] = (int32_t *)malloc16_clear( 2*sizeof(int32_t)*fp->ofdm_symbol_size ); - pusch_vars[UE_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); - pusch_vars[UE_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); - pusch_vars[UE_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); + pusch_vars[ULSCH_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); + pusch_vars[ULSCH_id]->drs_ch_estimates[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); + pusch_vars[ULSCH_id]->drs_ch_estimates_time[i] = (int32_t *)malloc16_clear( 4*sizeof(int32_t)*fp->ofdm_symbol_size ); + pusch_vars[ULSCH_id]->rxdataF_comp[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*fp->N_RB_UL*12*fp->symbols_per_tti ); + pusch_vars[ULSCH_id]->ul_ch_mag[i] = (int32_t *)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); + pusch_vars[ULSCH_id]->ul_ch_magb[i] = (int32_t *)malloc16_clear( fp->symbols_per_tti*sizeof(int32_t)*fp->N_RB_UL*12 ); } - pusch_vars[UE_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); - } //UE_id + pusch_vars[ULSCH_id]->llr = (int16_t *)malloc16_clear( (8*((3*8*6144)+12))*sizeof(int16_t) ); + } //ULSCH_id for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) eNB->UE_stats_ptr[UE_id] = &eNB->UE_stats[UE_id]; @@ -518,19 +564,19 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) { free_and_zero(common_vars->rxdataF); // Channel estimates for SRS - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { + for (int srs_id = 0; srs_id < NUMBER_OF_SRS_MAX; srs_id++) { for (i=0; i<64; i++) { - free_and_zero(srs_vars[UE_id].srs_ch_estimates[i]); - free_and_zero(srs_vars[UE_id].srs_ch_estimates_time[i]); + free_and_zero(srs_vars[srs_id].srs_ch_estimates[i]); + free_and_zero(srs_vars[srs_id].srs_ch_estimates_time[i]); } - free_and_zero(srs_vars[UE_id].srs_ch_estimates); - free_and_zero(srs_vars[UE_id].srs_ch_estimates_time); + free_and_zero(srs_vars[srs_id].srs_ch_estimates); + free_and_zero(srs_vars[srs_id].srs_ch_estimates_time); } //UE_id free_ul_ref_sigs(); - for (UE_id=0; UE_idprachF); @@ -548,26 +594,26 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) { free_and_zero(prach_vars_br->prachF); free_and_zero(prach_vars->rxsigF[0]); - for (UE_id=0; UE_idrxdataF_ext[i]); - free_and_zero(pusch_vars[UE_id]->rxdataF_ext2[i]); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates[i]); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time[i]); - free_and_zero(pusch_vars[UE_id]->rxdataF_comp[i]); - free_and_zero(pusch_vars[UE_id]->ul_ch_mag[i]); - free_and_zero(pusch_vars[UE_id]->ul_ch_magb[i]); + for (int ULSCH_id=0; ULSCH_idnb_antennas_rx; i++) { + free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext[i]); + free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2[i]); + free_and_zero(pusch_vars[ULSCH_id]->drs_ch_estimates[i]); + free_and_zero(pusch_vars[ULSCH_id]->drs_ch_estimates_time[i]); + free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp[i]); + free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag[i]); + free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb[i]); } - free_and_zero(pusch_vars[UE_id]->rxdataF_ext); - free_and_zero(pusch_vars[UE_id]->rxdataF_ext2); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates); - free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time); - free_and_zero(pusch_vars[UE_id]->rxdataF_comp); - free_and_zero(pusch_vars[UE_id]->ul_ch_mag); - free_and_zero(pusch_vars[UE_id]->ul_ch_magb); - free_and_zero(pusch_vars[UE_id]->llr); - free_and_zero(pusch_vars[UE_id]); + free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext); + free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2); + free_and_zero(pusch_vars[ULSCH_id]->drs_ch_estimates); + free_and_zero(pusch_vars[ULSCH_id]->drs_ch_estimates_time); + free_and_zero(pusch_vars[ULSCH_id]->rxdataF_comp); + free_and_zero(pusch_vars[ULSCH_id]->ul_ch_mag); + free_and_zero(pusch_vars[ULSCH_id]->ul_ch_magb); + free_and_zero(pusch_vars[ULSCH_id]->llr); + free_and_zero(pusch_vars[ULSCH_id]); } //UE_id for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) eNB->UE_stats_ptr[UE_id] = NULL; diff --git a/openair1/PHY/INIT/lte_init_ru.c b/openair1/PHY/INIT/lte_init_ru.c index 8ad928f8a0..a856c33999 100644 --- a/openair1/PHY/INIT/lte_init_ru.c +++ b/openair1/PHY/INIT/lte_init_ru.c @@ -21,9 +21,8 @@ #include "phy_init.h" #include "SCHED/sched_eNB.h" -#include "PHY/phy_extern.h" #include "PHY/LTE_REFSIG/lte_refsig.h" -#include "SIMULATION/TOOLS/sim.h" +//#include "SIMULATION/TOOLS/sim.h" #include "LTE_RadioResourceConfigCommonSIB.h" #include "LTE_RadioResourceConfigDedicated.h" #include "LTE_TDD-Config.h" @@ -34,6 +33,8 @@ void init_7_5KHz(void); +extern const char ru_if_types[MAX_RU_IF_TYPES][20]; + int phy_init_RU(RU_t *ru) { LTE_DL_FRAME_PARMS *fp = ru->frame_parms; RU_CALIBRATION *calibration = &ru->calibration; @@ -44,6 +45,7 @@ int phy_init_RU(RU_t *ru) { if (ru->is_slave == 1) { generate_ul_ref_sigs_rx(); } + else generate_ul_ref_sigs(); if (ru->if_south <= REMOTE_IF5) { // this means REMOTE_IF5 or LOCAL_RF, so allocate memory for time-domain signals // Time-domain signals @@ -135,14 +137,14 @@ int phy_init_RU(RU_t *ru) { } } - AssertFatal(RC.nb_L1_inst <= NUMBER_OF_eNB_MAX,"eNB instances %d > %d\n", - RC.nb_L1_inst,NUMBER_OF_eNB_MAX); - LOG_D(PHY,"[INIT] %s() RC.nb_L1_inst:%d \n", __FUNCTION__, RC.nb_L1_inst); + AssertFatal(ru->num_eNB <= NUMBER_OF_eNB_MAX,"eNB instances %d > %d\n", + ru->num_eNB,NUMBER_OF_eNB_MAX); + LOG_D(PHY,"[INIT] %s() ru->num_eNB:%d \n", __FUNCTION__, ru->num_eNB); int starting_antenna_index=0; for (i=0; iidx; i++) starting_antenna_index+=ru->nb_tx; - for (i=0; inum_eNB; i++) { for (p=0; p<15; p++) { LOG_D(PHY,"[INIT] %s() nb_antenna_ports_eNB:%d \n", __FUNCTION__, ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB); @@ -240,7 +242,7 @@ void phy_free_RU(RU_t *ru) { free_and_zero(ru->prach_rxsigF[0]); /* ru->prach_rxsigF_br is not allocated -> don't free */ - for (i = 0; i < RC.nb_L1_inst; i++) { + for (i = 0; i < ru->num_eNB; i++) { for (p = 0; p < 15; p++) { if (p < ru->eNB_list[i]->frame_parms.nb_antenna_ports_eNB || p == 5) { for (j=0; jnb_tx; j++) free_and_zero(ru->beam_weights[i][p][j]); diff --git a/openair1/PHY/INIT/lte_init_ue.c b/openair1/PHY/INIT/lte_init_ue.c index 64a5992a64..b756735816 100644 --- a/openair1/PHY/INIT/lte_init_ue.c +++ b/openair1/PHY/INIT/lte_init_ue.c @@ -39,6 +39,7 @@ void init_7_5KHz(void); uint8_t dmrs1_tab_ue[8] = {0,2,3,4,6,8,9,10}; +void init_sss(void); void phy_config_sib1_ue(module_id_t Mod_id,int CC_id, uint8_t eNB_id, @@ -629,6 +630,7 @@ int init_lte_ue_signal(PHY_VARS_UE *ue, init_frame_parms(&ue->frame_parms,1); lte_sync_time_init(&ue->frame_parms); init_lte_top(&ue->frame_parms); + init_sss(); init_7_5KHz(); init_ul_hopping(&ue->frame_parms); // many memory allocation sizes are hard coded diff --git a/openair1/PHY/INIT/lte_param_init.c b/openair1/PHY/INIT/lte_param_init.c index 1505ee018e..504c8fa80a 100644 --- a/openair1/PHY/INIT/lte_param_init.c +++ b/openair1/PHY/INIT/lte_param_init.c @@ -25,7 +25,6 @@ #include #include -#include "SIMULATION/TOOLS/sim.h" #include "PHY/types.h" #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" @@ -33,7 +32,9 @@ #include "phy_init.h" #include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/LTE_TRANSPORT/transport_common_proto.h" -#include "targets/RT/USER/lte-softmodem.h" +#include "executables/softmodem-common.h" +#include "SIMULATION/TOOLS/sim.h" + extern PHY_VARS_eNB *eNB; extern PHY_VARS_UE *UE; extern RU_t *ru; diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index 83f9eeecc5..c15e94b7b6 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -74,7 +74,7 @@ int l1_north_init_gNB() { int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, - unsigned char abstraction_flag) { + unsigned char lowmem_flag) { // shortcuts NR_DL_FRAME_PARMS *const fp = &gNB->frame_parms; nfapi_nr_config_request_scf_t *cfg = &gNB->gNB_config; @@ -92,6 +92,15 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, while(gNB->configured == 0) usleep(10000); + if (lowmem_flag == 1) { + gNB->number_of_nr_dlsch_max = 2; + gNB->number_of_nr_ulsch_max = 2; + } + else { + gNB->number_of_nr_dlsch_max = NUMBER_OF_NR_DLSCH_MAX; + gNB->number_of_nr_ulsch_max = NUMBER_OF_NR_ULSCH_MAX; + } + load_dftslib(); LOG_D(PHY,"[MSC_NEW][FRAME 00000][PHY_gNB][MOD %02"PRIu8"][]\n", gNB->Mod_id); @@ -251,7 +260,7 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB, int N_RB_UL = cfg->carrier_config.ul_grid_size[cfg->ssb_config.scs_common.value].value; - for (int ULSCH_id=0; ULSCH_idnumber_of_nr_ulsch_max; ULSCH_id++) { pusch_vars[ULSCH_id] = (NR_gNB_PUSCH *)malloc16_clear( sizeof(NR_gNB_PUSCH) ); pusch_vars[ULSCH_id]->rxdataF_ext = (int32_t **)malloc16(Prx*sizeof(int32_t *) ); pusch_vars[ULSCH_id]->rxdataF_ext2 = (int32_t **)malloc16(Prx*sizeof(int32_t *) ); @@ -336,7 +345,7 @@ void phy_free_nr_gNB(PHY_VARS_gNB *gNB) free_and_zero(prach_vars->prach_ifft[0]); free_and_zero(prach_vars->rxsigF[0]); */ - for (int ULSCH_id=0; ULSCH_idnumber_of_nr_ulsch_max; ULSCH_id++) { for (int i = 0; i < 2; i++) { free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext[i]); free_and_zero(pusch_vars[ULSCH_id]->rxdataF_ext2[i]); @@ -527,9 +536,9 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { AssertFatal(gNB->pucch[i]!=NULL,"Can't initialize pucch %d \n", i); } - for (i=0; inumber_of_nr_dlsch_max; i++) { - LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH %d/%d\n",i,NUMBER_OF_NR_DLSCH_MAX); + LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH %d/%d\n",i,gNB->number_of_nr_dlsch_max); for (j=0; j<2; j++) { gNB->dlsch[i][j] = new_gNB_dlsch(fp,1,16,NSOFT,0,grid_size); @@ -537,9 +546,9 @@ void init_nr_transport(PHY_VARS_gNB *gNB) { } } - for (i=0; inumber_of_nr_ulsch_max; i++) { - LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i); + LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,gNB->number_of_nr_ulsch_max); for (j=0; j<2; j++) { // ULSCH for data diff --git a/openair1/PHY/INIT/nr_init_ru.c b/openair1/PHY/INIT/nr_init_ru.c index 2bd7d90620..b2abf27d00 100644 --- a/openair1/PHY/INIT/nr_init_ru.c +++ b/openair1/PHY/INIT/nr_init_ru.c @@ -21,9 +21,6 @@ #include "phy_init.h" #include "SCHED/sched_common.h" -#include "PHY/phy_extern.h" -#include "PHY/NR_TRANSPORT/nr_transport_proto.h" -#include "SIMULATION/TOOLS/sim.h" /*#include "RadioResourceConfigCommonSIB.h" #include "RadioResourceConfigDedicated.h" #include "TDD-Config.h" @@ -33,6 +30,10 @@ #include #include "openair1/PHY/defs_RU.h" +void init_prach_ru_list(RU_t *ru); + +extern const char ru_if_types[MAX_RU_IF_TYPES][20]; + int nr_phy_init_RU(RU_t *ru) { NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; @@ -44,7 +45,7 @@ int nr_phy_init_RU(RU_t *ru) { nfapi_nr_config_request_scf_t *cfg; ru->nb_log_antennas=0; - for (int n=0;nnum_gNB;n++) { cfg = &ru->config; if (cfg->carrier_config.num_tx_ant.value > ru->nb_log_antennas) ru->nb_log_antennas = cfg->carrier_config.num_tx_ant.value; } @@ -117,40 +118,43 @@ int nr_phy_init_RU(RU_t *ru) { } } - AssertFatal(RC.nb_nr_L1_inst <= NUMBER_OF_eNB_MAX,"gNB instances %d > %d\n", - RC.nb_nr_L1_inst,NUMBER_OF_gNB_MAX); + AssertFatal(ru->num_gNB <= NUMBER_OF_gNB_MAX,"gNB instances %d > %d\n", + ru->num_gNB,NUMBER_OF_gNB_MAX); - LOG_E(PHY,"[INIT] %s() RC.nb_nr_L1_inst:%d \n", __FUNCTION__, RC.nb_nr_L1_inst); - - int beam_count = 0; - if (ru->nb_tx>1) {//Enable beamforming when nb_tx > 1 - for (p=0;pnb_log_antennas;p++) { - //if ((fp->L_ssb >> (63-p)) & 0x01)//64 bit-map with the MSB @2⁶³ corresponds to SSB ssb_index 0 - beam_count++; - } - AssertFatal(ru->nb_bfw==(beam_count*ru->nb_tx),"Number of beam weights from config file is %d while the expected number is %d",ru->nb_bfw,(beam_count*ru->nb_tx)); - - int l_ind = 0; - for (i=0; inum_gNB:%d \n", __FUNCTION__, ru->num_gNB); + + if (ru->do_precoding == 1) { + int beam_count = 0; + if (ru->nb_tx>1) {//Enable beamforming when nb_tx > 1 for (p=0;pnb_log_antennas;p++) { + //if ((fp->L_ssb >> (63-p)) & 0x01)//64 bit-map with the MSB @2⁶³ corresponds to SSB ssb_index 0 + beam_count++; + } + AssertFatal(ru->nb_bfw==(beam_count*ru->nb_tx),"Number of beam weights from config file is %d while the expected number is %d",ru->nb_bfw,(beam_count*ru->nb_tx)); + + int l_ind = 0; + for (i=0; inum_gNB; i++) { + for (p=0;pnb_log_antennas;p++) { //if ((fp->L_ssb >> (63-p)) & 0x01) { - ru->beam_weights[i][p] = (int32_t **)malloc16_clear(ru->nb_tx*sizeof(int32_t*)); - for (j=0; jnb_tx; j++) { - ru->beam_weights[i][p][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t)); - for (re=0; reofdm_symbol_size; re++) - ru->beam_weights[i][p][j][re] = ru->bw_list[j][l_ind]; + ru->beam_weights[i][p] = (int32_t **)malloc16_clear(ru->nb_tx*sizeof(int32_t*)); + for (j=0; jnb_tx; j++) { + ru->beam_weights[i][p][j] = (int32_t *)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t)); + AssertFatal(ru->bw_list[i],"ru->bw_list[%d] is null\n",i); + for (re=0; reofdm_symbol_size; re++) + ru->beam_weights[i][p][j][re] = ru->bw_list[i][l_ind]; //printf("Beam Weight %08x for beam %d and tx %d\n",ru->bw_list[i][l_ind],p,j); - l_ind++; - } // for j - //} - } // for p - } //for i - } + l_ind++; + } // for j + //} + } // for p + } //for i + } - ru->common.beam_id = (uint8_t**)malloc16_clear(ru->nb_tx*sizeof(uint8_t*)); - for(i=0; i< ru->nb_tx; ++i) { - ru->common.beam_id[i] = (uint8_t*)malloc16_clear(fp->symbols_per_slot*fp->slots_per_frame*sizeof(uint8_t)); - memset(ru->common.beam_id[i],255,fp->symbols_per_slot*fp->slots_per_frame); + ru->common.beam_id = (uint8_t**)malloc16_clear(ru->nb_tx*sizeof(uint8_t*)); + for(i=0; i< ru->nb_tx; ++i) { + ru->common.beam_id[i] = (uint8_t*)malloc16_clear(fp->symbols_per_slot*fp->slots_per_frame*sizeof(uint8_t)); + memset(ru->common.beam_id[i],255,fp->symbols_per_slot*fp->slots_per_frame); + } } } // !=IF5 @@ -199,8 +203,7 @@ void nr_phy_free_RU(RU_t *ru) free_and_zero(ru->prach_rxsigF[j][i]); } } - - for (i = 0; i < RC.nb_nr_L1_inst; i++) { + for (i = 0; i < ru->num_gNB; i++) { for (p = 0; p < 15; p++) { for (j=0; jnb_tx; j++) free_and_zero(ru->beam_weights[i][p][j]); free_and_zero(ru->beam_weights[i][p]); diff --git a/openair1/PHY/INIT/nr_init_ue.c b/openair1/PHY/INIT/nr_init_ue.c index 855acc01ff..a9c71d1582 100644 --- a/openair1/PHY/INIT/nr_init_ue.c +++ b/openair1/PHY/INIT/nr_init_ue.c @@ -28,6 +28,7 @@ #include "TDD-Config.h" #include "MBSFN-SubframeConfigList.h"*/ #include "openair1/PHY/defs_RU.h" +#include "openair1/PHY/impl_defs_nr.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "assertions.h" #include @@ -196,7 +197,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, } for (i=0;iPDSCH_Config.pdsch_TimeDomainResourceAllocation[i] = (NR_PDSCH_TimeDomainResourceAllocation_t *)malloc16(sizeof(NR_PDSCH_TimeDomainResourceAllocation_t)); + ue->PDSCH_Config.pdsch_TimeDomainResourceAllocation[i] = (PDSCH_TimeDomainResourceAllocation_t *)malloc16(sizeof(PDSCH_TimeDomainResourceAllocation_t)); ue->PDSCH_Config.pdsch_TimeDomainResourceAllocation[i]->mappingType = typeA; } diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c index 2f3d9455d2..686762ce1b 100644 --- a/openair1/PHY/INIT/nr_parms.c +++ b/openair1/PHY/INIT/nr_parms.c @@ -268,11 +268,11 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, LOG_I(PHY, "Initializing frame parms: set nb_antenna_ports_gNB %d, tdd_config, %d, Nid_cell %d\n", fp->nb_antenna_ports_gNB, fp->tdd_config, fp->Nid_cell); - uint64_t dl_bw_khz = (12*config->carrier_config.dl_grid_size[config->ssb_config.scs_common])*(15<ssb_config.scs_common); - LOG_I(PHY,"dl_bw_kHz %lu\n",dl_bw_khz); fp->dl_CarrierFreq = ((dl_bw_khz>>1) + config->carrier_config.dl_frequency)*1000 ; - LOG_I(PHY,"dl_CarrierFreq %lu\n",fp->dl_CarrierFreq); + + LOG_D(PHY,"dl_bw_kHz %lu\n",dl_bw_khz); + LOG_D(PHY,"dl_CarrierFreq %lu\n",fp->dl_CarrierFreq); uint64_t ul_bw_khz = (12*config->carrier_config.ul_grid_size[config->ssb_config.scs_common])*(15<ssb_config.scs_common); fp->ul_CarrierFreq = ((ul_bw_khz>>1) + config->carrier_config.uplink_frequency)*1000 ; diff --git a/openair1/PHY/INIT/phy_init.h b/openair1/PHY/INIT/phy_init.h index e80f404762..85101a3080 100644 --- a/openair1/PHY/INIT/phy_init.h +++ b/openair1/PHY/INIT/phy_init.h @@ -399,7 +399,7 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue,int nb_connected_eNB,uint8_t abstractio void init_nr_ue_transport(PHY_VARS_NR_UE *ue,int abstraction_flag); void init_N_TA_offset(PHY_VARS_NR_UE *ue); void nr_dump_frame_parms(NR_DL_FRAME_PARMS *frame_parms); -int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char abstraction_flag); +int phy_init_nr_gNB(PHY_VARS_gNB *gNB, unsigned char is_secondary_gNB, unsigned char lowmem_flag); void nr_phy_config_request(NR_PHY_Config_t *gNB); void nr_phy_config_request_sim(PHY_VARS_gNB *gNB,int N_RB_DL,int N_RB_UL,int mu,int Nid_cell,uint64_t position_in_burst); void phy_free_nr_gNB(PHY_VARS_gNB *gNB); @@ -408,6 +408,7 @@ void init_nr_transport(PHY_VARS_gNB *gNB); void init_dfts(void); +void fill_subframe_mask(PHY_VARS_eNB *eNB); /** @} */ #endif diff --git a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c index 3fd58a4989..6d382bdd63 100644 --- a/openair1/PHY/LTE_ESTIMATION/freq_equalization.c +++ b/openair1/PHY/LTE_ESTIMATION/freq_equalization.c @@ -20,11 +20,11 @@ */ #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" -// This is 512/(1:256) in __m128i format -int16_t inv_ch[256*8] = {512,512,512,512,512,512,512,512, +// This is 4096/(1:4096) in __m128i format +__m128i inv_ch[4096];/* = {512,512,512,512,512,512,512,512, 256,256,256,256,256,256,256,256, 170,170,170,170,170,170,170,170, 128,128,128,128,128,128,128,128, @@ -280,7 +280,11 @@ int16_t inv_ch[256*8] = {512,512,512,512,512,512,512,512, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, - }; + };*/ + +void init_fde() { + for (int i=1;i<4096;i++) inv_ch[i] = _mm_set1_epi16(4096/i); +} void freq_equalization(LTE_DL_FRAME_PARMS *frame_parms, int32_t **rxdataF_comp, @@ -313,12 +317,12 @@ void freq_equalization(LTE_DL_FRAME_PARMS *frame_parms, amp=(*((int16_t*)&ul_ch_mag128[re])); - if (amp>255) - amp=255; + if (amp>4095) + amp=4095; - // printf("freq_eq: symbol %d re %d => %d,%d,%d, (%d) (%d,%d) => ",symbol,re,*((int16_t*)(&ul_ch_mag128[re])),amp,inv_ch[8*amp],*((int16_t*)(&ul_ch_mag128[re]))*inv_ch[8*amp],*(int16_t*)&(rxdataF_comp128[re]),*(1+(int16_t*)&(rxdataF_comp128[re]))); + //printf("freq_eq: symbol %d re %d => mag %d,amp %d,inv %d, prod %d (%d,%d)\n",symbol,re,*((int16_t*)(&ul_ch_mag128[re])),amp,_mm_extract_epi16(inv_ch[amp],0),(*((int16_t*)(&ul_ch_mag128[re]))*_mm_extract_epi16(inv_ch[amp],0))>>3,*(int16_t*)&(rxdataF_comp128[re]),*(1+(int16_t*)&(rxdataF_comp128[re]))); #if defined(__x86_64__) || defined(__i386__) - rxdataF_comp128[re] = _mm_mullo_epi16(rxdataF_comp128[re],*((__m128i *)&inv_ch[8*amp])); + rxdataF_comp128[re] = _mm_srai_epi16(_mm_mullo_epi16(rxdataF_comp128[re],inv_ch[amp]),3); if (Qm==4) ul_ch_mag128[re] = _mm_set1_epi16(324); // this is 512*2/sqrt(10) @@ -327,7 +331,7 @@ void freq_equalization(LTE_DL_FRAME_PARMS *frame_parms, ul_ch_magb128[re] = _mm_set1_epi16(158); // this is 512*2/sqrt(42) } #elif defined(__arm__) - rxdataF_comp128[re] = vmulq_s16(rxdataF_comp128[re],*((int16x8_t *)&inv_ch[8*amp])); + rxdataF_comp128[re] = vmulq_s16(rxdataF_comp128[re],inv_ch[amp]); if (Qm==4) ul_ch_mag128[re] = vdupq_n_s16(324); // this is 512*2/sqrt(10) diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c index f85162e095..aac8e71828 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c @@ -21,7 +21,6 @@ #include "PHY/types.h" #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" #include "common/utils/LOG/vcd_signal_dumper.h" @@ -118,12 +117,12 @@ int lte_est_timing_advance_pusch(LTE_DL_FRAME_PARMS *frame_parms, int temp, i, aa, max_pos=0, max_val=0; short Re,Im; - uint8_t cyclic_shift = 0; - int sync_pos = (frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); + // uint8_t cyclic_shift = 0; + int sync_pos = 0;//(frame_parms->ofdm_symbol_size-cyclic_shift*frame_parms->ofdm_symbol_size/12)%(frame_parms->ofdm_symbol_size); AssertFatal(frame_parms->ofdm_symbol_size > 127,"frame_parms->ofdm_symbol_size %d<128\n",frame_parms->ofdm_symbol_size); - AssertFatal(frame_parms->nb_antennas_rx >0 && frame_parms->nb_antennas_rx<3,"frame_parms->nb_antennas_rx %d not in [0,1]\n", - frame_parms->nb_antennas_rx); + AssertFatal(frame_parms->nb_antennas_rx >0 && frame_parms->nb_antennas_rx<=4,"frame_parms->nb_antennas_rx %d not in [1...%d]\n", + frame_parms->nb_antennas_rx,4); for (i = 0; i < frame_parms->ofdm_symbol_size; i++) { temp = 0; @@ -142,9 +141,5 @@ int lte_est_timing_advance_pusch(LTE_DL_FRAME_PARMS *frame_parms, if (max_pos>frame_parms->ofdm_symbol_size/2) max_pos = max_pos-frame_parms->ofdm_symbol_size; - //#ifdef DEBUG_PHY - LOG_D(PHY,"max_pos = %d, sync_pos=%d\n",max_pos,sync_pos); - //#endif //DEBUG_PHY - return max_pos - sync_pos; } diff --git a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c index 2d79158920..7eeeb998ba 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_eNB_measurements.c @@ -32,6 +32,30 @@ int32_t rx_power_avg_eNB[3]; +void dump_I0_stats(FILE *fd,PHY_VARS_eNB *eNB) { + + + int min_I0=1000,max_I0=0; + int amin=0,amax=0; + for (int i=0; iframe_parms.N_RB_UL; i++) { + if (i==(eNB->frame_parms.N_RB_UL>>1) - 1) i+=2; + + if (eNB->measurements.n0_subband_power_tot_dB[i]measurements.n0_subband_power_tot_dB[i]; amin=i;} + + if (eNB->measurements.n0_subband_power_tot_dB[i]>max_I0) {max_I0 = eNB->measurements.n0_subband_power_tot_dB[i]; amax=i;} + } + + for (int i=0; iframe_parms.N_RB_UL; i++) { + fprintf(fd,"%2d.",eNB->measurements.n0_subband_power_tot_dB[i]-eNB->measurements.n0_subband_power_avg_dB); + if (i%25 == 24) fprintf(fd,"\n"); + } + + fprintf(fd,"\nmax_I0 %d (rb %d), min_I0 %d (rb %d), avg I0 %d\n", max_I0, amax, min_I0, amin, eNB->measurements.n0_subband_power_avg_dB); + + fprintf(fd,"prach_I0 = %d.%d dB\n",eNB->measurements.prach_I0/10,eNB->measurements.prach_I0%10); + + +} void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB, int subframe, module_id_t eNB_id, @@ -87,46 +111,45 @@ void lte_eNB_I0_measurements(PHY_VARS_eNB *eNB, nb_rb++; for (aarx=0; aarxnb_antennas_rx; aarx++) { measurements->n0_subband_power[aarx][rb] = 0; - for (int s=0;s<14-(frame_parms->Ncp<<1);s++) { - // select the 7th symbol in an uplink subframe - offset = offset0 + (s*frame_parms->ofdm_symbol_size); - ul_ch = &common_vars->rxdataF[aarx][offset]; - len = 12; + for (int s=0;s<(14-(frame_parms->Ncp<<1));s++) { + offset = offset0 + (s*frame_parms->ofdm_symbol_size); + ul_ch = &common_vars->rxdataF[aarx][offset]; + len = 12; // just do first half of middle PRB for odd number of PRBs - if (((frame_parms->N_RB_UL&1) == 1) && - (rb==(frame_parms->N_RB_UL>>1))) { - len=6; - } + if (((frame_parms->N_RB_UL&1) == 1) && + (rb==(frame_parms->N_RB_UL>>1))) { + len=6; + } - AssertFatal(ul_ch, "RX signal buffer (freq) problem"); + AssertFatal(ul_ch, "RX signal buffer (freq) problem"); - measurements->n0_subband_power[aarx][rb] += signal_energy_nodc(ul_ch,len); + measurements->n0_subband_power[aarx][rb] += signal_energy_nodc(ul_ch,len); - } + } // symbol measurements->n0_subband_power[aarx][rb]/=(14-(frame_parms->Ncp<<1)); measurements->n0_subband_power_dB[aarx][rb] = dB_fixed(measurements->n0_subband_power[aarx][rb]); n0_power_tot += measurements->n0_subband_power[aarx][rb]; - } + } //antenna n0_power_tot/=frame_parms->nb_antennas_rx; n0_power_tot2 += n0_power_tot; - measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_power_tot/frame_parms->nb_antennas_rx); + measurements->n0_subband_power_tot_dB[rb] = dB_fixed(n0_power_tot); measurements->n0_subband_power_tot_dBm[rb] = measurements->n0_subband_power_tot_dB[rb] - eNB->rx_total_gain_dB - dB_fixed(frame_parms->N_RB_UL); - } - } + } //rb not used in subframe + } //rb if (nb_rb>0) measurements->n0_subband_power_avg_dB = dB_fixed(n0_power_tot2/nb_rb); } void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, module_id_t eNB_id, - module_id_t UE_id, + module_id_t srs_id, unsigned char init_averaging) { LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; PHY_MEASUREMENTS_eNB *measurements = &eNB->measurements; - LTE_eNB_SRS *srs_vars = &eNB->srs_vars[UE_id]; + LTE_eNB_SRS *srs_vars = &eNB->srs_vars[srs_id]; int32_t aarx,rx_power_correction; int32_t rx_power; @@ -136,7 +159,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, //printf("Running eNB_srs_measurements for eNB_id %d\n",eNB_id); if (init_averaging == 1) - rx_power_avg_eNB[UE_id] = 0; + rx_power_avg_eNB[srs_id] = 0; rx_power = 0; @@ -152,24 +175,24 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, for (aarx=0; aarxnb_antennas_rx; aarx++) { - measurements->rx_spatial_power[UE_id][0][aarx] = + measurements->rx_spatial_power[srs_id][0][aarx] = ((signal_energy_nodc(&srs_vars->srs_ch_estimates[aarx][frame_parms->first_carrier_offset], (frame_parms->N_RB_DL*6)) + signal_energy_nodc(&srs_vars->srs_ch_estimates[aarx][1], (frame_parms->N_RB_DL*6)))*rx_power_correction) - measurements->n0_power[aarx]; - measurements->rx_spatial_power[UE_id][0][aarx]<<=1; // because of noise only in odd samples + measurements->rx_spatial_power[srs_id][0][aarx]<<=1; // because of noise only in odd samples - measurements->rx_spatial_power_dB[UE_id][0][aarx] = (unsigned short) dB_fixed(measurements->rx_spatial_power[UE_id][0][aarx]); + measurements->rx_spatial_power_dB[srs_id][0][aarx] = (unsigned short) dB_fixed(measurements->rx_spatial_power[srs_id][0][aarx]); - measurements->wideband_cqi[UE_id][aarx] = measurements->rx_spatial_power[UE_id][0][aarx]; + measurements->wideband_cqi[srs_id][aarx] = measurements->rx_spatial_power[srs_id][0][aarx]; // measurements->rx_power[UE_id][aarx]/=frame_parms->nb_antennas_tx; - measurements->wideband_cqi_dB[UE_id][aarx] = (unsigned short) dB_fixed(measurements->wideband_cqi[UE_id][aarx]); - rx_power += measurements->wideband_cqi[UE_id][aarx]; + measurements->wideband_cqi_dB[srs_id][aarx] = (unsigned short) dB_fixed(measurements->wideband_cqi[srs_id][aarx]); + rx_power += measurements->wideband_cqi[srs_id][aarx]; // measurements->rx_avg_power_dB[UE_id] += measurements->rx_power_dB[UE_id][aarx]; } @@ -177,14 +200,14 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, // measurements->rx_avg_power_dB[UE_id]/=frame_parms->nb_antennas_rx; if (init_averaging == 0) - rx_power_avg_eNB[UE_id] = ((k1*rx_power_avg_eNB[UE_id]) + (k2*rx_power))>>10; + rx_power_avg_eNB[srs_id] = ((k1*rx_power_avg_eNB[srs_id]) + (k2*rx_power))>>10; else - rx_power_avg_eNB[UE_id] = rx_power; + rx_power_avg_eNB[srs_id] = rx_power; - measurements->wideband_cqi_tot[UE_id] = dB_fixed2(rx_power,2*measurements->n0_power_tot); + measurements->wideband_cqi_tot[srs_id] = dB_fixed2(rx_power,2*measurements->n0_power_tot); // times 2 since we have noise only in the odd carriers of the srs comb - measurements->rx_rssi_dBm[UE_id] = (int32_t)dB_fixed(rx_power_avg_eNB[UE_id])-eNB->rx_total_gain_dB; + measurements->rx_rssi_dBm[srs_id] = (int32_t)dB_fixed(rx_power_avg_eNB[srs_id])-eNB->rx_total_gain_dB; @@ -200,21 +223,21 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, else if (rb>12) ul_ch = &srs_vars->srs_ch_estimates[aarx][6 + (rb-13)*12]; else { - measurements->subband_cqi_dB[UE_id][aarx][rb] = 0; + measurements->subband_cqi_dB[srs_id][aarx][rb] = 0; continue; } // cqi if (aarx==0) - measurements->subband_cqi_tot[UE_id][rb]=0; + measurements->subband_cqi_tot[srs_id][rb]=0; - measurements->subband_cqi[UE_id][aarx][rb] = (signal_energy_nodc(ul_ch,12))*rx_power_correction - measurements->n0_power[aarx]; + measurements->subband_cqi[srs_id][aarx][rb] = (signal_energy_nodc(ul_ch,12))*rx_power_correction - measurements->n0_power[aarx]; - if (measurements->subband_cqi[UE_id][aarx][rb] < 0) - measurements->subband_cqi[UE_id][aarx][rb]=0; + if (measurements->subband_cqi[srs_id][aarx][rb] < 0) + measurements->subband_cqi[srs_id][aarx][rb]=0; - measurements->subband_cqi_tot[UE_id][rb] += measurements->subband_cqi[UE_id][aarx][rb]; - measurements->subband_cqi_dB[UE_id][aarx][rb] = dB_fixed2(measurements->subband_cqi[UE_id][aarx][rb], + measurements->subband_cqi_tot[srs_id][rb] += measurements->subband_cqi[srs_id][aarx][rb]; + measurements->subband_cqi_dB[srs_id][aarx][rb] = dB_fixed2(measurements->subband_cqi[srs_id][aarx][rb], 2*measurements->n0_power[aarx]); // 2*n0_power since we have noise from the odd carriers in the comb of the srs @@ -225,7 +248,7 @@ void lte_eNB_srs_measurements(PHY_VARS_eNB *eNB, for (rb=0; rbN_RB_DL; rb++) { - measurements->subband_cqi_tot_dB[UE_id][rb] = dB_fixed2(measurements->subband_cqi_tot[UE_id][rb], + measurements->subband_cqi_tot_dB[srs_id][rb] = dB_fixed2(measurements->subband_cqi_tot[srs_id][rb], measurements->n0_power_tot); /* if (measurements->subband_cqi_tot_dB[UE_id][rb] == 65) diff --git a/openair1/PHY/LTE_ESTIMATION/lte_estimation.h b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h index fc40280853..6ba901e29f 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_estimation.h +++ b/openair1/PHY/LTE_ESTIMATION/lte_estimation.h @@ -288,6 +288,8 @@ void freq_equalization(LTE_DL_FRAME_PARMS *frame_parms, unsigned short Msc_RS, unsigned char Qm); +void init_fde(void); +void dump_I0_stats(FILE *fd,PHY_VARS_eNB *eNB); /** @} */ #endif diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index 57b4c28661..1fbc8b7ef2 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -27,12 +27,9 @@ //#include #include -#include "LAYER2/MAC/mac.h" #include "PHY/defs_UE.h" #include "PHY/phy_extern_ue.h" -#include "PHY_INTERFACE/phy_interface.h" #include "PHY/LTE_REFSIG/lte_refsig.h" -#include "RRC/LTE/rrc_extern.h" // Note: this is for prototype of generate_drs_pusch (OTA synchronization of RRUs) #include "PHY/LTE_UE_TRANSPORT/transport_proto_ue.h" diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 1d1b16e036..0ce716ef20 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -20,7 +20,7 @@ */ #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" +//#include "PHY/phy_extern.h" #include "PHY/sse_intrin.h" //#define DEBUG_CH #include "common/utils/LOG/log.h" @@ -34,12 +34,18 @@ static int16_t ru_90c[2*128] = {32767, 0,32766, -402,32758, -804,32746, -1206,32 #define SCALE 0x3FFF +static const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +//static const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; + +extern unsigned short dftsizes[34]; +extern int16_t *ul_ref_sigs_rx[30][2][34]; + int32_t lte_ul_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, L1_rxtx_proc_t *proc, - LTE_eNB_ULSCH_t * ulsch, - int32_t **ul_ch_estimates, - int32_t **ul_ch_estimates_time, - int32_t **rxdataF_ext, + LTE_eNB_ULSCH_t * ulsch, + int32_t **ul_ch_estimates, + int32_t **ul_ch_estimates_time, + int32_t **rxdataF_ext, module_id_t UE_id, unsigned char l, unsigned char Ns) { diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 4b06f67bbe..61af617d6e 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -53,22 +53,25 @@ //#undef LOG_D //#define LOG_D(A,B...) printf(B) -int16_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) { - uint16_t i; - int16_t first_free_index=-1; +int find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) { + int first_free_index=-1; AssertFatal(eNB!=NULL,"eNB is null\n"); - for (i=0; idlsch[i]!=NULL,"eNB->dlsch[%d] is null\n",i); - AssertFatal(eNB->dlsch[i]!=NULL,"eNB->dlsch[%d][0] is null\n",i); + for (int i=0; idlsch[i][0] == NULL) continue; LOG_D(PHY,"searching for rnti %x : UE index %d=> harq_mask %x, rnti %x, first_free_index %d\n", rnti,i,eNB->dlsch[i][0]->harq_mask,eNB->dlsch[i][0]->rnti,first_free_index); - if ((eNB->dlsch[i][0]->harq_mask >0) && - (eNB->dlsch[i][0]->rnti==rnti)) return i; - else if ((eNB->dlsch[i][0]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; + if (type == SEARCH_EXIST_RA) { + if (eNB->dlsch[i][0]->rnti==rnti) return i; + } else { + if ((eNB->dlsch[i][0]->harq_mask >0) && + (eNB->dlsch[i][0]->rnti==rnti)) return i; + else if ((eNB->dlsch[i][0]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; + } + } - if (type == SEARCH_EXIST) + if (type == SEARCH_EXIST_RA || type == SEARCH_EXIST) return -1; if (first_free_index != -1) @@ -78,20 +81,23 @@ int16_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) { } -int16_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) { - uint16_t i; - int16_t first_free_index=-1; +int find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type) { + int first_free_index=-1; AssertFatal(eNB!=NULL,"eNB is null\n"); - for (i=0; iulsch[i]!=NULL,"eNB->ulsch[%d] is null\n",i); + for (int i=0; iulsch[i]==NULL) continue; - if ((eNB->ulsch[i]->harq_mask >0) && - (eNB->ulsch[i]->rnti==rnti)) return i; - else if ((eNB->ulsch[i]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; + if (type == SEARCH_EXIST_RA) { + if (eNB->ulsch[i]->rnti == rnti) return i; + } else { + if ((eNB->ulsch[i]->harq_mask >0) && + (eNB->ulsch[i]->rnti==rnti)) return i; + else if ((eNB->ulsch[i]->harq_mask == 0) && (first_free_index==-1)) first_free_index=i; + } } - if (type == SEARCH_EXIST) + if (type == SEARCH_EXIST_RA || type == SEARCH_EXIST) return -1; if (first_free_index != -1) @@ -301,7 +307,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB, UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); - if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ) { + if( (UE_id<0) || (UE_id>=NUMBER_OF_DLSCH_MAX) ) { LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel8->rnti,UE_id); return; } @@ -476,7 +482,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB, ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->harq_pid = rel8->harq_process; ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->dai = rel8->downlink_assignment_index; ((DCI1A_20MHz_TDD_1_6_t *)dci_pdu)->padding = 0; - // printf("TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",mcs,rballoc,rv,NPRB); + //LOG_D(PHY,"TDD 1A: mcs %d, rballoc %x,rv %d, NPRB %d\n",rel8->mcs_1,rel8->resource_block_coding,rel8->redundancy_version_1,NPRB); } else { dci_alloc->dci_length = sizeof_DCI1A_20MHz_FDD_t; ((DCI1A_20MHz_FDD_t *)dci_pdu)->type = 1; @@ -535,7 +541,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB, dlsch0->harq_mask |= (1 << rel8->harq_process); - if (rel8->rnti_type == 1) LOG_D(PHY,"DCI 1A: round %d, mcs %d, TBS %d, rballoc %x, rv %d, rnti %x, harq process %d\n",dlsch0_harq->round,rel8->mcs_1,dlsch0_harq->TBS,rel8->resource_block_coding, + if (rel8->rnti != SI_RNTI) LOG_D(PHY,"DCI 1A: round %d, mcs %d, TBS %d, rballoc %x, rv %d, rnti %x, harq process %d\n",dlsch0_harq->round,rel8->mcs_1,dlsch0_harq->TBS,rel8->resource_block_coding, rel8->redundancy_version_1,rel8->rnti,rel8->harq_process); break; @@ -1550,7 +1556,7 @@ void fill_mdci_and_dlsch(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc,mDCI_ALLOC_t *dc dci_alloc->i0 = rel13->initial_transmission_sf_io; UE_id = find_dlsch (rel13->rnti, eNB, SEARCH_EXIST_OR_FREE); AssertFatal (UE_id != -1, "no free or exiting dlsch_context\n"); - AssertFatal (UE_id < NUMBER_OF_UE_MAX, "returned UE_id %d >= %d(NUMBER_OF_UE_MAX)\n", UE_id, NUMBER_OF_UE_MAX); + AssertFatal (UE_id < NUMBER_OF_DLSCH_MAX, "returned UE_id %d >= %d(NUMBER_OF_DLSCH_MAX)\n", UE_id, NUMBER_OF_DLSCH_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch0_harq = dlsch0->harq_processes[rel13->harq_process]; dci_alloc->ra_flag = 0; @@ -1955,7 +1961,7 @@ void fill_dci0(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_proc_t *proc, if(frame_parms->frame_type == TDD) { UE_id = find_ulsch(pdu->dci_pdu_rel8.rnti, eNB,SEARCH_EXIST_OR_FREE); - if(UE_id != -1) { + if(UE_id >=0 -1 || UE_id < NUMBER_OF_ULSCH_MAX) { eNB->ulsch[UE_id]->harq_processes[pdu->dci_pdu_rel8.harq_pid]->V_UL_DAI = dai +1; } } diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c index 583d12eedb..64e74ebfbf 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools_common.c @@ -32,7 +32,6 @@ #include "PHY/defs_eNB.h" #include "PHY/phy_extern.h" -#include "SCHED/sched_eNB.h" #ifdef DEBUG_DCI_TOOLS #include "PHY/phy_vars.h" #endif @@ -43,7 +42,6 @@ //#define DEBUG_HARQ -#include "LAYER2/MAC/mac.h" //#define DEBUG_DCI @@ -100,7 +98,6 @@ uint16_t RIV2nb_rb_LUT100[6000]; uint16_t RIV2first_rb_LUT100[6000]; uint16_t RIV_max100=0; -extern RAN_CONTEXT_t RC; extern uint32_t current_dlsch_cqi; @@ -273,15 +270,6 @@ uint16_t get_nCCE(uint8_t num_pdcch_symbols,LTE_DL_FRAME_PARMS *frame_parms,uint -uint16_t get_nCCE_mac(uint8_t Mod_id,uint8_t CC_id,int num_pdcch_symbols,int subframe) -{ - - // check for eNB only ! - return(get_nCCE(num_pdcch_symbols, - &RC.eNB[Mod_id][CC_id]->frame_parms, - get_mi(&RC.eNB[Mod_id][CC_id]->frame_parms,subframe))); -} - void conv_eMTC_rballoc (uint16_t resource_block_coding, uint32_t N_RB_DL, uint32_t * rb_alloc) { diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 3eb44d98fa..b5bcb0848d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -96,6 +96,7 @@ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { } + LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, unsigned char Mdlharq, uint32_t Nsoft, @@ -110,7 +111,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, switch (N_RB_DL) { case 6: - bw_scaling =16; + bw_scaling = 4; break; case 25: @@ -160,7 +161,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, for (i=0; iharq_processes[i] = (LTE_DL_eNB_HARQ_t *)malloc16(sizeof(LTE_DL_eNB_HARQ_t)); - LOG_T(PHY, "Required mem size %d (bw scaling %d), dlsch->harq_processes[%d] %p\n", + LOG_I(PHY, "Required DLSCH mem size %d (bw scaling %d), dlsch->harq_processes[%d] %p\n", MAX_DLSCH_PAYLOAD_BYTES/bw_scaling,bw_scaling, i,dlsch->harq_processes[i]); if (dlsch->harq_processes[i]) { @@ -169,9 +170,9 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, dlsch->harq_processes[i]->b = (unsigned char *)malloc16(MAX_DLSCH_PAYLOAD_BYTES/bw_scaling); if (dlsch->harq_processes[i]->b) { - bzero(dlsch->harq_processes[i]->b,MAX_DLSCH_PAYLOAD_BYTES/bw_scaling); + memset(dlsch->harq_processes[i]->b,0,MAX_DLSCH_PAYLOAD_BYTES/bw_scaling); } else { - printf("Can't get b\n"); + AssertFatal(1==0,"Can't get b\n"); exit_flag=1; } @@ -181,15 +182,15 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, dlsch->harq_processes[i]->c[r] = (uint8_t *)malloc16(((r==0)?8:0) + 3+ 768); if (dlsch->harq_processes[i]->c[r]) { - bzero(dlsch->harq_processes[i]->c[r],((r==0)?8:0) + 3+ 768); + memset(dlsch->harq_processes[i]->c[r],0,((r==0)?8:0) + 3+ 768); } else { - printf("Can't get c\n"); + AssertFatal(1==0,"Can't get c\n"); exit_flag=2; } } } } else { - printf("Can't get harq_p %d\n",i); + AssertFatal(1==0,"Can't get harq_p %d\n",i); exit_flag=3; } } @@ -203,7 +204,7 @@ LTE_eNB_DLSCH_t *new_eNB_dlsch(unsigned char Kmimo, } } - LOG_D(PHY,"new_eNB_dlsch exit flag %d, size of %ld\n", + LOG_I(PHY,"new_eNB_dlsch exit flag %d, size of %ld\n", exit_flag, sizeof(LTE_eNB_DLSCH_t)); free_eNB_dlsch(dlsch); return(NULL); @@ -360,6 +361,7 @@ int dlsch_encoding(PHY_VARS_eNB *eNB, proc->nbEncode=0; + // if (hadlsch->Ndi == 1) { // this is a new packet if (hadlsch->round == 0) { // this is a new packet // Add 24-bit crc (polynomial A) to payload diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 347fbb026b..aba4a464f2 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2375,16 +2375,14 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, for (l=num_pdcch_symbols; lmimo_mode, pmi2hex_2Ar2(dlsch0_harq->pmi_alloc), mod_order0, mod_order1, rb_alloc[0] ); -#endif } if (frame_parms->Ncp==0) { // normal prefix @@ -2980,7 +2978,7 @@ int allocate_REs_in_RB_MCH_khz_1dot25(int32_t **txdataF, case 2: //QPSK - LOG_D(PHY,"%d : %d,%d => ",tti_offset,((int16_t*)&txdataF[0][tti_offset])[0],((int16_t*)&txdataF[0][tti_offset])[1]); + LOG_D(PHY,"%d : %d,%d => ",tti_offset,((int16_t*)&txdataF[0][tti_offset])[0],((int16_t*)&txdataF[0][tti_offset])[1]); ((int16_t*)&txdataF[0][tti_offset])[0] = (x0[*jj]==1) ? (-gain_lin_QPSK) : gain_lin_QPSK; //I //b_i *jj = *jj + 1; @@ -3082,7 +3080,7 @@ int mch_modulation_khz_1dot25(int32_t **txdataF, uint8_t skip_dc=0; uint8_t mod_order = dlsch->harq_processes[0]->Qm; int16_t qam16_table_a[4],qam64_table_a[8];//,qam16_table_b[4],qam64_table_b[8]; - int16_t *qam_table_s; + int16_t *qam_table_s=qam16_table_a; nsymb_pmch = 1; nsymb = (frame_parms->Ncp == NORMAL) ? 14 : 12; @@ -3125,12 +3123,8 @@ int mch_modulation_khz_1dot25(int32_t **txdataF, } - if (mod_order == 4) - qam_table_s = qam16_table_a; - else if (mod_order == 6) + if (mod_order == 6) qam_table_s = qam64_table_a; - else - qam_table_s = NULL; //LOG_I(PHY,"Allocated rb %d, subframe_offset %d,amp %d\n",rb,subframe_offset,amp); allocate_REs_in_RB_MCH_khz_1dot25(txdataF, diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c index b03f59fb78..015a95a862 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_scrambling.c @@ -113,9 +113,6 @@ void dlsch_scrambling(LTE_DL_FRAME_PARMS *frame_parms, x2 = ((Ns>>1)<<9) + frame_parms->Nid_cell_mbsfn; //this is c_init in 36.211 Sec 6.3.1 for PMCH } -#ifdef DEBUG_SCRAMBLING - printf("scrambling: i0 %d rnti %x, q %d, Ns %d, Nid_cell %d, G %d x2 %x\n",dlsch->i0,dlsch->rnti,q,Ns,frame_parms->Nid_cell, G, x2); -#endif s = lte_gold_generic(&x1, &x2, 1); for (n=0; n<(1+(G>>5)); n++) { diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 95ad420028..09c0b4ba0f 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -30,10 +30,13 @@ * \warning */ -#include "PHY/defs_eNB.h" +#include +//#include "PHY/defs_eNB.h" +#include "PHY/defs_RU.h" #include "PHY/TOOLS/alaw_lut.h" -#include "PHY/phy_extern.h" -#include "SCHED/sched_eNB.h" +//#include "PHY/phy_extern.h" +//#include "SCHED/sched_eNB.h" +lte_subframe_t subframe_select(LTE_DL_FRAME_PARMS *frame_parms,uint8_t subframe); //#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c index f39f3ef872..e2bec337aa 100644 --- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c @@ -31,11 +31,11 @@ */ #include -#include "PHY/defs_eNB.h" +#include +#include "PHY/defs_RU.h" #include "PHY/TOOLS/alaw_lut.h" //#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" -#include #include "common/utils/LOG/vcd_signal_dumper.h" //#define DEBUG_DL_MOBIPASS //#define DEBUG_UL_MOBIPASS @@ -1469,7 +1469,7 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16 // HYPOTHESIS: first packet per subframe has lowest timestamp of subframe // should detect out of order and act accordingly .... AssertFatal(aid==0 || aid==1,"aid %d != 0 or 1\n",aid); - //LOG_I(PHY,"rxp[%d] %p, dest %p, offset %d (%lld,%lld)\n",aid,rxp[aid],rxp[aid]+(timestamp[packet_id]-timestamp[0]),(timestamp[packet_id]-timestamp[0]),timestamp[packet_id],timestamp[0]); + LOG_D(PHY,"rxp[%d] %p, dest %p, offset %d (%llu,%llu)\n",aid,rxp[aid],rxp[aid]+(timestamp[packet_id]-timestamp[0]),(int)(timestamp[packet_id]-timestamp[0]),(long long unsigned int)timestamp[packet_id],(long long unsigned int)timestamp[0]); memcpy((void*)(rxp[aid]+(timestamp[packet_id]-timestamp[0])), (void*)temp_rx, spp_eth<<2); diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c index dfa990269e..8e9a968827 100644 --- a/openair1/PHY/LTE_TRANSPORT/pbch.c +++ b/openair1/PHY/LTE_TRANSPORT/pbch.c @@ -72,6 +72,7 @@ int allocate_pbch_REs_in_RB(LTE_DL_FRAME_PARMS *frame_parms, first_re=0; last_re=12; + for (re=first_re; re #include +#include "common/utils/lte/prach_utils.h" void rx_prach0(PHY_VARS_eNB *eNB, RU_t *ru, @@ -84,7 +85,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, uint8_t aa; int32_t lev; int16_t levdB; - int fft_size,log2_ifft_size; + int fft_size=0,log2_ifft_size; int16_t prach_ifft_tmp[2048*2] __attribute__((aligned(32))); int32_t *prach_ifft=(int32_t *)NULL; int32_t **prach_ifftp=(int32_t **)NULL; @@ -112,7 +113,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, prach_ConfigIndex = fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[ce_level]; Ncs_config = fp->prach_emtc_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig; restricted_set = fp->prach_emtc_config_common.prach_ConfigInfo.highSpeedFlag; - n_ra_prb = get_prach_prb_offset(fp,prach_ConfigIndex, + n_ra_prb = get_prach_prb_offset(fp->frame_type,fp->tdd_config,fp->N_RB_UL,fp->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[ce_level], fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level], tdd_mapindex,Nf); // update pointers to results for ce_level @@ -124,7 +125,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, prach_ConfigIndex = fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; Ncs_config = fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig; restricted_set = fp->prach_config_common.prach_ConfigInfo.highSpeedFlag; - n_ra_prb = get_prach_prb_offset(fp,prach_ConfigIndex, + n_ra_prb = get_prach_prb_offset(fp->frame_type,fp->tdd_config,fp->N_RB_UL,fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex, fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset, tdd_mapindex,Nf); } @@ -140,7 +141,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, rxsigF = eNB->prach_vars_br.rxsigF[ce_level]; if (LOG_DEBUGFLAG(PRACH)) { - if (((frame_prach)&1023) < 20) LOG_I(PHY, + if (((frame_prach)&1023) < 20) LOG_D(PHY, "PRACH (eNB) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d, rootSequenceIndex %d, repetition number %d,numRepetitionsPrePreambleAttempt %d\n", br_flag,ce_level,frame_prach,subframe, fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level], @@ -153,24 +154,24 @@ void rx_prach0(PHY_VARS_eNB *eNB, prachF = eNB->prach_vars.prachF; rxsigF = eNB->prach_vars.rxsigF[0]; - if (LOG_DEBUGFLAG(PRACH)) { - if (((frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (eNB) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d , rootSequenceIndex %d\n", subframe, + //if (LOG_DEBUGFLAG(PRACH)) { + if (((frame_prach)&1023) < 20) LOG_D(PHY,"PRACH (eNB) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d , rootSequenceIndex %d\n", subframe, fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset,prach_ConfigIndex,rootSequenceIndex); - } + //} } } else { if (br_flag == 1) { rxsigF = ru->prach_rxsigF_br[ce_level]; if (LOG_DEBUGFLAG(PRACH)) { - if (((frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (RU) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", + if (((frame_prach)&1023) < 20) LOG_D(PHY,"PRACH (RU) : running rx_prach (br_flag %d, ce_level %d) for frame %d subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", br_flag,ce_level,frame_prach,subframe,fp->prach_emtc_config_common.prach_ConfigInfo.prach_FreqOffset[ce_level],prach_ConfigIndex); } } else { rxsigF = ru->prach_rxsigF[0]; if (LOG_DEBUGFLAG(PRACH)) { - if (((frame_prach)&1023) < 20) LOG_I(PHY,"PRACH (RU) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", + if (((frame_prach)&1023) < 20) LOG_D(PHY,"PRACH (RU) : running rx_prach for subframe %d, prach_FreqOffset %d, prach_ConfigIndex %d\n", subframe,fp->prach_config_common.prach_ConfigInfo.prach_FreqOffset,prach_ConfigIndex); } } @@ -299,11 +300,13 @@ void rx_prach0(PHY_VARS_eNB *eNB, case 6: if (prach_fmt == 4) { dft(DFT_256,prach2,rxsigF[aa],1); + fft_size=256; } else { dft(DFT_1536,prach2,rxsigF[aa],1); if (prach_fmt>1) dft(DFT_1536,prach2+3072,rxsigF[aa]+3072,1); + fft_size=1536; } break; @@ -311,13 +314,14 @@ void rx_prach0(PHY_VARS_eNB *eNB, case 15: if (prach_fmt == 4) { dft(DFT_256,prach2,rxsigF[aa],1); + fft_size=256; } else { dft(DFT_3072,prach2,rxsigF[aa],1); if (prach_fmt>1) dft(DFT_3072,prach2+6144,rxsigF[aa]+6144,1); } - + fft_size=3072; break; case 25: @@ -339,11 +343,13 @@ void rx_prach0(PHY_VARS_eNB *eNB, case 50: if (prach_fmt == 4) { dft(DFT_2048,prach2,rxsigF[aa],1); + fft_size=2048; } else { dft(DFT_12288,prach2,rxsigF[aa],1); if (prach_fmt>1) dft(DFT_12288,prach2+24576,rxsigF[aa]+24576,1); + fft_size=12288; } break; @@ -351,11 +357,13 @@ void rx_prach0(PHY_VARS_eNB *eNB, case 75: if (prach_fmt == 4) { dft(DFT_3072,prach2,rxsigF[aa],1); + fft_size=3072; } else { dft(DFT_18432,prach2,rxsigF[aa],1); if (prach_fmt>1) dft(DFT_18432,prach2+36864,rxsigF[aa]+36864,1); + fft_size=18432; } break; @@ -364,20 +372,24 @@ void rx_prach0(PHY_VARS_eNB *eNB, if (fp->threequarter_fs==0) { if (prach_fmt == 4) { dft(DFT_4096,prach2,rxsigF[aa],1); + fft_size=2048; } else { dft(DFT_24576,prach2,rxsigF[aa],1); if (prach_fmt>1) dft(DFT_24576,prach2+49152,rxsigF[aa]+49152,1); + fft_size=24576; } } else { if (prach_fmt == 4) { dft(DFT_3072,prach2,rxsigF[aa],1); + fft_size=3072; } else { dft(DFT_18432,prach2,rxsigF[aa],1); if (prach_fmt>1) dft(DFT_18432,prach2+36864,rxsigF[aa]+36864,1); + fft_size=18432; } } @@ -547,7 +559,6 @@ void rx_prach0(PHY_VARS_eNB *eNB, } log2_ifft_size = 10; - fft_size = 6144; if (new_dft == 1) { new_dft = 0; diff --git a/openair1/PHY/LTE_TRANSPORT/prach_common.c b/openair1/PHY/LTE_TRANSPORT/prach_common.c index 393d4ca3f8..e366e8edbc 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach_common.c +++ b/openair1/PHY/LTE_TRANSPORT/prach_common.c @@ -34,7 +34,7 @@ #include "PHY/phy_extern.h" #include "PHY/phy_extern_ue.h" #include "common/utils/LOG/vcd_signal_dumper.h" - +#include "common/utils/lte/prach_utils.h" uint16_t NCS_unrestricted[16] = {0,13,15,18,22,26,32,38,46,59,76,93,119,167,279,419}; uint16_t NCS_restricted[15] = {15,18,22,26,32,38,46,55,68,82,100,128,158,202,237}; // high-speed case @@ -44,6 +44,9 @@ int16_t ru[2*839]; // quantized roots of unity uint32_t ZC_inv[839]; // multiplicative inverse for roots u uint16_t du[838]; +extern PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7]; + +/* // This is table 5.7.1-4 from 36.211 PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7] = { // TDD Configuration Index 0 @@ -254,7 +257,7 @@ PRACH_TDD_PREAMBLE_MAP tdd_preamble_map[64][7] = { } }; - +*/ uint16_t prach_root_sequence_map0_3[838] = { 129, 710, 140, 699, 120, 719, 210, 629, 168, 671, 84, 755, 105, 734, 93, 746, 70, 769, 60, 779, 2, 837, 1, 838, @@ -378,192 +381,13 @@ uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index) { return(tdd_preamble_map[fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex][fp->tdd_config].map[tdd_map_index].f_ra); } -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type) { - if (frame_type == FDD) // FDD - return(prach_ConfigIndex>>4); - else { - if (prach_ConfigIndex < 20) - return (0); - - if (prach_ConfigIndex < 30) - return (1); - - if (prach_ConfigIndex < 40) - return (2); - - if (prach_ConfigIndex < 48) - return (3); - else - return (4); - } -} - -uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t prach_ConfigIndex, - uint8_t n_ra_prboffset, - uint8_t tdd_mapindex, uint16_t Nf) { - lte_frame_type_t frame_type = frame_parms->frame_type; - uint8_t tdd_config = frame_parms->tdd_config; - uint8_t n_ra_prb; - uint8_t f_ra,t1_ra; - uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); - uint8_t Nsp=2; - - if (frame_type == TDD) { // TDD - if (tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach==0) { - LOG_E(PHY, "Illegal prach_ConfigIndex %"PRIu8"", prach_ConfigIndex); - return(-1); - } - - // adjust n_ra_prboffset for frequency multiplexing (p.36 36.211) - f_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[tdd_mapindex].f_ra; - - if (prach_fmt < 4) { - if ((f_ra&1) == 0) { - n_ra_prb = n_ra_prboffset + 6*(f_ra>>1); - } else { - n_ra_prb = frame_parms->N_RB_UL - 6 - n_ra_prboffset + 6*(f_ra>>1); - } - } else { - if ((tdd_config >2) && (tdd_config<6)) - Nsp = 2; - - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - - if ((((Nf&1)*(2-Nsp)+t1_ra)&1) == 0) { - n_ra_prb = 6*f_ra; - } else { - n_ra_prb = frame_parms->N_RB_UL - 6*(f_ra+1); - } - } - } else { //FDD - n_ra_prb = n_ra_prboffset; - } - - return(n_ra_prb); -} - -int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe) { - // uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - uint8_t tdd_config = frame_parms->tdd_config; - uint8_t t0_ra; - uint8_t t1_ra; - uint8_t t2_ra; - int prach_mask = 0; - - if (frame_parms->frame_type == FDD) { //FDD - //implement Table 5.7.1-2 from 36.211 (Rel-10, p.41) - if ((((frame&1) == 1) && (subframe < 9)) || - (((frame&1) == 0) && (subframe == 9))) // This is an odd frame, ignore even-only PRACH frames - if (((prach_ConfigIndex&0xf)<3) || // 0,1,2,16,17,18,32,33,34,48,49,50 - ((prach_ConfigIndex&0x1f)==18) || // 18,50 - ((prach_ConfigIndex&0xf)==15)) // 15,47 - return(0); - - switch (prach_ConfigIndex&0x1f) { - case 0: - case 3: - if (subframe==1) prach_mask = 1; - - break; - - case 1: - case 4: - if (subframe==4) prach_mask = 1; - - break; - - case 2: - case 5: - if (subframe==7) prach_mask = 1; - - break; - - case 6: - if ((subframe==1) || (subframe==6)) prach_mask=1; - - break; - - case 7: - if ((subframe==2) || (subframe==7)) prach_mask=1; - - break; - - case 8: - if ((subframe==3) || (subframe==8)) prach_mask=1; - - break; - - case 9: - if ((subframe==1) || (subframe==4) || (subframe==7)) prach_mask=1; - - break; - - case 10: - if ((subframe==2) || (subframe==5) || (subframe==8)) prach_mask=1; - - break; - - case 11: - if ((subframe==3) || (subframe==6) || (subframe==9)) prach_mask=1; - - break; - - case 12: - if ((subframe&1)==0) prach_mask=1; - - break; - - case 13: - if ((subframe&1)==1) prach_mask=1; - - break; - - case 14: - prach_mask=1; - break; - - case 15: - if (subframe==9) prach_mask=1; - - break; - } - } else { // TDD - AssertFatal(prach_ConfigIndex<64, - "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); - AssertFatal(tdd_preamble_map[prach_ConfigIndex][tdd_config].num_prach>0, - "Illegal prach_ConfigIndex %d for ",prach_ConfigIndex); - t0_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t0_ra; - t1_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t1_ra; - t2_ra = tdd_preamble_map[prach_ConfigIndex][tdd_config].map[0].t2_ra; -#ifdef PRACH_DEBUG - LOG_I(PHY,"[PRACH] Checking for PRACH format (ConfigIndex %d) in TDD subframe %d (%d,%d,%d)\n", - prach_ConfigIndex, - subframe, - t0_ra,t1_ra,t2_ra); -#endif - - if ((((t0_ra == 1) && ((frame &1)==0))|| // frame is even and PRACH is in even frames - ((t0_ra == 2) && ((frame &1)==1))|| // frame is odd and PRACH is in odd frames - (t0_ra == 0)) && // PRACH is in all frames - (((subframe<5)&&(t1_ra==0)) || // PRACH is in 1st half-frame - (((subframe>4)&&(t1_ra==1))))) { // PRACH is in 2nd half-frame - if ((prach_ConfigIndex<48) && // PRACH only in normal UL subframe - (((subframe%5)-2)==t2_ra)) prach_mask=1; - else if ((prach_ConfigIndex>47) && (((subframe%5)-1)==t2_ra)) prach_mask=1; // PRACH can be in UpPTS - } - } - - return(prach_mask); -} - int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms, uint32_t frame, uint8_t subframe) { uint8_t prach_ConfigIndex = frame_parms->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - int prach_mask = is_prach_subframe0(frame_parms, prach_ConfigIndex, frame, subframe); + int prach_mask = is_prach_subframe0(frame_parms->tdd_config,frame_parms->frame_type, prach_ConfigIndex, frame, subframe); for (int i=0; i<4; i++) { if (frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_CElevel_enable[i] == 1) - prach_mask |= (is_prach_subframe0(frame_parms, frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i], + prach_mask |= (is_prach_subframe0(frame_parms->tdd_config,frame_parms->frame_type, frame_parms->prach_emtc_config_common.prach_ConfigInfo.prach_ConfigIndex[i], frame, subframe) << (i+1)); } diff --git a/openair1/PHY/LTE_TRANSPORT/prach_extern.h b/openair1/PHY/LTE_TRANSPORT/prach_extern.h index 47fbd93ad7..3404646923 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach_extern.h +++ b/openair1/PHY/LTE_TRANSPORT/prach_extern.h @@ -35,7 +35,7 @@ #include "PHY/sse_intrin.h" #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" +//#include "PHY/phy_extern.h" //#define PRACH_DEBUG 1 //#define PRACH_WRITE_OUTPUT_DEBUG 1 @@ -74,17 +74,6 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id); uint8_t get_fid_prach_tdd(module_id_t Mod_id,uint8_t tdd_map_index); -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); - - -uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t prach_ConfigIndex, - uint8_t n_ra_prboffset, - uint8_t tdd_mapindex, uint16_t Nf); - - -int is_prach_subframe0(LTE_DL_FRAME_PARMS *frame_parms,uint8_t prach_ConfigIndex,uint32_t frame, uint8_t subframe); - int is_prach_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame, uint8_t subframe); diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index c72fa1b480..3270066448 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -65,10 +65,41 @@ int16_t cfo_pucch_ep[24*6] = {24278,-22005,29621,-14010,32412,-4808,32412,4807,2 +void dump_uci_stats(FILE *fd,PHY_VARS_eNB *eNB,int frame) { + + int strpos=0; + char output[16384]; + + for (int i=0;iuci_stats[i].rnti>0) { + eNB_UCI_STATS_t *uci_stats = &eNB->uci_stats[i]; + strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch1_trials %d, pucch1_n0 %d dB, pucch1_thres %d dB, current pucch1_stat_pos %d dB, current pucch1_stat_neg %d dB, positive SR count %d\n", + i,uci_stats->rnti,uci_stats->pucch1_trials,eNB->measurements.n0_pucch_dB/*max(eNB->measurements.n0_subband_power_tot_dB[0], eNB->measurements.n0_subband_power_tot_dB[eNB->frame_parms.N_RB_UL-1])*/,uci_stats->pucch1_thres,dB_fixed(uci_stats->current_pucch1_stat_pos),dB_fixed(uci_stats->current_pucch1_stat_neg),uci_stats->pucch1_positive_SR); + strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch1_low (%d,%d)dB pucch1_high (%d,%d)dB\n", + i,uci_stats->rnti, + dB_fixed(uci_stats->pucch1_low_stat[0]), + dB_fixed(uci_stats->pucch1_low_stat[1]), + dB_fixed(uci_stats->pucch1_high_stat[0]), + dB_fixed(uci_stats->pucch1_high_stat[1])); + + strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch1a_trials %d, pucch1a_stat (%d,%d), pucch1b_trials %d, pucch1b_stat (%d,%d) pucch1ab_DTX %d\n", + i,uci_stats->rnti, + uci_stats->pucch1a_trials, + uci_stats->current_pucch1a_stat_re, + uci_stats->current_pucch1a_stat_im, + uci_stats->pucch1b_trials, + uci_stats->current_pucch1b_stat_re, + uci_stats->current_pucch1b_stat_im, + uci_stats->pucch1ab_DTX); + } + } + if (fd) fprintf(fd,"%s",output); + else printf("%s",output); +} /* PUCCH format3 >> */ /* SubCarrier Demap */ uint16_t pucchfmt3_subCarrierDeMapping( PHY_VARS_eNB *eNB, - int16_t SubCarrierDeMapData[NB_ANTENNAS_RX][14][12][2], + int16_t SubCarrierDeMapData[4][14][12][2], uint16_t n3_pucch ) { LTE_eNB_COMMON *eNB_common_vars = &eNB->common_vars; LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; @@ -118,8 +149,8 @@ uint16_t pucchfmt3_subCarrierDeMapping( PHY_VARS_eNB *eNB, } /* cyclic shift hopping remove */ -uint16_t pucchfmt3_Baseseq_csh_remove( int16_t SubCarrierDeMapData[NB_ANTENNAS_RX][14][12][2], - int16_t CshData_fmt3[NB_ANTENNAS_RX][14][12][2], +uint16_t pucchfmt3_Baseseq_csh_remove( int16_t SubCarrierDeMapData[4][14][12][2], + int16_t CshData_fmt3[4][14][12][2], LTE_DL_FRAME_PARMS *frame_parms, uint8_t subframe, uint8_t ncs_cell[20][7] ) { @@ -169,9 +200,9 @@ const int16_t TBL_3_SF5_GEN_N_DASH_NS[MAXROW_TBL_SF5_OS_IDX] = {0,3,6,8,10}; const int16_t TBL_3_SF4_GEN_N_DASH_NS[MAXROW_TBL_SF4_OS_IDX] = {0,3,6,9}; /* Channel estimation */ -uint16_t pucchfmt3_ChannelEstimation( int16_t SubCarrierDeMapData[NB_ANTENNAS_RX][14][12][2], - double delta_theta[NB_ANTENNAS_RX][12], - int16_t ChestValue[NB_ANTENNAS_RX][2][12][2], +uint16_t pucchfmt3_ChannelEstimation( int16_t SubCarrierDeMapData[4][14][12][2], + double delta_theta[4][12], + int16_t ChestValue[4][2][12][2], int16_t *Interpw, uint8_t subframe, uint8_t shortened_format, @@ -183,12 +214,12 @@ uint16_t pucchfmt3_ChannelEstimation( int16_t SubCarrierDeMapData[NB_ANTENNAS_RX int16_t np, np_n, ip_ind=-1; //int16_t npucch_sf; int16_t calctmp[2]; - int16_t BsCshData[NB_ANTENNAS_RX][D_NSYM1SF][D_NSC1RB][2]; - //int16_t delta_theta_calctmp[NB_ANTENNAS_RX][4][D_NSC1RB][2], delta_theta_comp[NB_ANTENNAS_RX][D_NSC1RB][2]; - int16_t delta_theta_comp[NB_ANTENNAS_RX][D_NSC1RB][2]; - int16_t CsData_allavg[NB_ANTENNAS_RX][14][2]; - int16_t CsData_temp[NB_ANTENNAS_RX][D_NSYM1SF][D_NSC1RB][2]; - int32_t IP_CsData_allsfavg[NB_ANTENNAS_RX][14][4][2]; + int16_t BsCshData[4][D_NSYM1SF][D_NSC1RB][2]; + //int16_t delta_theta_calctmp[4][4][D_NSC1RB][2], delta_theta_comp[4][D_NSC1RB][2]; + int16_t delta_theta_comp[4][D_NSC1RB][2]; + int16_t CsData_allavg[4][14][2]; + int16_t CsData_temp[4][D_NSYM1SF][D_NSC1RB][2]; + int32_t IP_CsData_allsfavg[4][14][4][2]; int32_t IP_allavg[D_NPUCCH_SF5]; //int16_t temp_ch[2]; int16_t m[NUMBER_OF_UE_MAX], m_self=0, same_m_number; @@ -432,9 +463,9 @@ uint16_t pucchfmt3_ChannelEstimation( int16_t SubCarrierDeMapData[NB_ANTENNAS_RX } /* Channel Equalization */ -uint16_t pucchfmt3_Equalization( int16_t CshData_fmt3[NB_ANTENNAS_RX][14][12][2], - int16_t ChdetAfterValue_fmt3[NB_ANTENNAS_RX][14][12][2], - int16_t ChestValue[NB_ANTENNAS_RX][2][12][2], +uint16_t pucchfmt3_Equalization( int16_t CshData_fmt3[4][14][12][2], + int16_t ChdetAfterValue_fmt3[4][14][12][2], + int16_t ChestValue[4][2][12][2], LTE_DL_FRAME_PARMS *frame_parms) { int16_t aa, sltNo, symNo, k; @@ -457,9 +488,9 @@ uint16_t pucchfmt3_Equalization( int16_t CshData_fmt3[NB_ANTENNAS_RX][14][12][2] } /* Frequency deviation remove AFC */ -uint16_t pucchfmt3_FrqDevRemove( int16_t ChdetAfterValue_fmt3[NB_ANTENNAS_RX][14][12][2], - double delta_theta[NB_ANTENNAS_RX][12], - int16_t RemoveFrqDev_fmt3[NB_ANTENNAS_RX][2][5][12][2], +uint16_t pucchfmt3_FrqDevRemove( int16_t ChdetAfterValue_fmt3[4][14][12][2], + double delta_theta[4][12], + int16_t RemoveFrqDev_fmt3[4][2][5][12][2], LTE_DL_FRAME_PARMS *frame_parms ) { int16_t aa, sltNo, symNo1slt, k, n; double calctmp[2]; @@ -509,8 +540,8 @@ const int16_t TBL_3_SF4[MAXROW_TBL_SF4_fmt3][MAXCLM_TBL_SF4][2] = { }; /* orthogonal sequence remove */ -uint16_t pucchfmt3_OrthSeqRemove( int16_t RemoveFrqDev_fmt3[NB_ANTENNAS_RX][2][5][12][2], - int16_t Fmt3xDataRmvOrth[NB_ANTENNAS_RX][2][5][12][2], +uint16_t pucchfmt3_OrthSeqRemove( int16_t RemoveFrqDev_fmt3[4][2][5][12][2], + int16_t Fmt3xDataRmvOrth[4][2][5][12][2], uint8_t shortened_format, uint16_t n3_pucch, LTE_DL_FRAME_PARMS *frame_parms ) { @@ -556,7 +587,7 @@ uint16_t pucchfmt3_OrthSeqRemove( int16_t RemoveFrqDev_fmt3[NB_ANTENNAS_RX][2][5 } /* averaging antenna */ -uint16_t pucchfmt3_AvgAnt( int16_t Fmt3xDataRmvOrth[NB_ANTENNAS_RX][2][5][12][2], +uint16_t pucchfmt3_AvgAnt( int16_t Fmt3xDataRmvOrth[4][2][5][12][2], int16_t Fmt3xDataAvgAnt[2][5][12][2], uint8_t shortened_format, LTE_DL_FRAME_PARMS *frame_parms ) { @@ -856,7 +887,7 @@ uint32_t calc_pucch_1x_interference(PHY_VARS_eNB *eNB, uint32_t rx_pucch(PHY_VARS_eNB *eNB, PUCCH_FMT_t fmt, - uint8_t UE_id, + uint8_t UCI_id, uint16_t n1_pucch, uint16_t n2_pucch, uint8_t shortened_format, @@ -871,15 +902,15 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, static int first_call = 1; LTE_eNB_COMMON *common_vars = &eNB->common_vars; LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; - int8_t sigma2_dB = eNB->measurements.n0_pucch_dB; + int8_t sigma2_dB = /*max(eNB->measurements.n0_subband_power_tot_dB[0], eNB->measurements.n0_subband_power_tot_dB[eNB->frame_parms.N_RB_UL-1]); */eNB->measurements.n0_pucch_dB; uint32_t u,v,n,aa; uint32_t z[12*14]; int16_t *zptr; - int16_t rxcomp[NB_ANTENNAS_RX][2*12*14]; + int16_t rxcomp[4][2*12*14]; uint8_t ns,N_UL_symb,nsymb,n_oc,n_oc0,n_oc1; uint8_t c = (frame_parms->Ncp==0) ? 3 : 2; - uint16_t nprime,nprime0,nprime1; + int16_t nprime,nprime0,nprime1; uint16_t i,j,re_offset,thres,h,off; uint8_t Nprime_div_deltaPUCCH_Shift,Nprime,d; uint8_t m,l,refs,phase,re,l2,phase_max=0; @@ -887,12 +918,12 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, int16_t tmp_re,tmp_im,W_re=0,W_im=0; int16_t *rxptr; uint32_t symbol_offset; - int16_t stat_ref_re,stat_ref_im,*cfo; - int16_t chest0_re[NB_ANTENNAS_RX][12],chest0_im[NB_ANTENNAS_RX][12]; - int16_t chest1_re[NB_ANTENNAS_RX][12],chest1_im[NB_ANTENNAS_RX][12]; + int16_t stat0_ref_re[4],stat0_ref_im[4],stat1_ref_re[4],stat1_ref_im[4],*cfo; + int16_t chest0_re[4][12],chest0_im[4][12]; + int16_t chest1_re[4][12],chest1_im[4][12]; int32_t chest_mag; - int32_t stat_re=0,stat_im=0; - uint32_t stat,stat_max=0; + int32_t stat0_re[4],stat1_re[4],stat0_im[4],stat1_im[4]; + uint32_t stat0[4],stat1[4],stat_max=0,stat0_max[4],stat1_max[4]; uint8_t log2_maxh; uint8_t deltaPUCCH_Shift = frame_parms->pucch_config_common.deltaPUCCH_Shift; uint8_t NRB2 = frame_parms->pucch_config_common.nRB_CQI; @@ -905,13 +936,13 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, int chL; /* PUCCH format3 >> */ uint16_t Ret = 0; - int16_t SubCarrierDeMapData[NB_ANTENNAS_RX][14][12][2]; //[Antenna][Symbol][Subcarrier][Complex] - int16_t CshData_fmt3[NB_ANTENNAS_RX][14][12][2]; //[Antenna][Symbol][Subcarrier][Complex] - double delta_theta[NB_ANTENNAS_RX][12]; //[Antenna][Subcarrier][Complex] - int16_t ChestValue[NB_ANTENNAS_RX][2][12][2]; //[Antenna][Slot][Subcarrier][Complex] - int16_t ChdetAfterValue_fmt3[NB_ANTENNAS_RX][14][12][2]; //[Antenna][Symbol][Subcarrier][Complex] - int16_t RemoveFrqDev_fmt3[NB_ANTENNAS_RX][2][5][12][2]; //[Antenna][Slot][PUCCH_Symbol][Subcarrier][Complex] - int16_t Fmt3xDataRmvOrth[NB_ANTENNAS_RX][2][5][12][2]; //[Antenna][Slot][PUCCH_Symbol][Subcarrier][Complex] + int16_t SubCarrierDeMapData[4][14][12][2]; //[Antenna][Symbol][Subcarrier][Complex] + int16_t CshData_fmt3[4][14][12][2]; //[Antenna][Symbol][Subcarrier][Complex] + double delta_theta[4][12]; //[Antenna][Subcarrier][Complex] + int16_t ChestValue[4][2][12][2]; //[Antenna][Slot][Subcarrier][Complex] + int16_t ChdetAfterValue_fmt3[4][14][12][2]; //[Antenna][Symbol][Subcarrier][Complex] + int16_t RemoveFrqDev_fmt3[4][2][5][12][2]; //[Antenna][Slot][PUCCH_Symbol][Subcarrier][Complex] + int16_t Fmt3xDataRmvOrth[4][2][5][12][2]; //[Antenna][Slot][PUCCH_Symbol][Subcarrier][Complex] int16_t Fmt3xDataAvgAnt[2][5][12][2]; //[Slot][PUCCH_Symbol][Subcarrier][Complex] int16_t Fmt3xDataAvgSym[2][12][2]; //[Slot][Subcarrier][Complex] int16_t IFFTOutData_Fmt3[2][12][2]; //[Slot][Subcarrier][Complex] @@ -941,9 +972,27 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, first_call=0; } - + eNB_UCI_STATS_t *uci_stats = NULL; if(fmt!=pucch_format3) { /* PUCCH format3 */ + + eNB_UCI_STATS_t *first_uci_stats=NULL; + for (int i=0;iuci_stats[i].rnti == eNB->uci_vars[UCI_id].rnti) { + uci_stats = &eNB->uci_stats[i]; + break; + } else if (first_uci_stats == NULL && eNB->uci_stats[i].rnti == 0) first_uci_stats = &eNB->uci_stats[i]; + if (uci_stats == NULL) { + if (first_uci_stats == NULL) { + LOG_E(PHY,"first_uci_stats is NULL\n"); + return -1; + } + uci_stats=first_uci_stats; + uci_stats->rnti = eNB->uci_vars[UCI_id].rnti; + } + + AssertFatal(uci_stats!=NULL,"No stat index found\n"); + uci_stats->frame = frame; // TODO // "SR+ACK/NACK" length is only 7 bits. // This restriction will be lifted in the future. @@ -1149,57 +1198,63 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, // Do cfo correction and MRC across symbols if (fmt == pucch_format1) { + uci_stats->pucch1_trials++; #ifdef DEBUG_PUCCH_RX printf("Doing PUCCH detection for format 1\n"); #endif stat_max = 0; for (phase=0; phase<7; phase++) { - stat=0; - + int stat=0; for (aa=0; aanb_antennas_rx; aa++) { + stat0[aa]=0;stat1[aa]=0; for (re=0; re<12; re++) { - stat_re=0; - stat_im=0; + stat0_re[aa]=0; + stat0_im[aa]=0; + stat1_re[aa]=0; + stat1_im[aa]=0; off=re<<1; cfo = (frame_parms->Ncp==0) ? &cfo_pucch_np[14*phase] : &cfo_pucch_ep[12*phase]; for (l=0; l<(nsymb>>1); l++) { - stat_re += (((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15))/nsymb; - stat_im += (((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15))/nsymb; + stat0_re[aa] += (((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15))/nsymb; + stat0_im[aa] += (((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15))/nsymb; off+=2; #ifdef DEBUG_PUCCH_RX printf("[eNB] PUCCH subframe %d (%d,%d,%d) => (%d,%d) x (%d,%d) : (%d,%d) , stat %d\n",subframe,phase,l,re, rxcomp[aa][off],rxcomp[aa][1+off], cfo[l<<1],cfo[1+(l<<1)], - stat_re,stat_im,stat); + stat0_re[aa],stat0_im[aa],stat); #endif } for (l2=0,l=(nsymb>>1); l < nsymb; l++,l2++) { - stat_re += (((rxcomp[aa][off]*(int32_t)cfo[l2<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l2<<1)])>>15))/nsymb; - stat_im += (((rxcomp[aa][off]*(int32_t)cfo[1+(l2<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l2<<1)])>>15))/nsymb; + stat1_re[aa] += (((rxcomp[aa][off]*(int32_t)cfo[l2<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l2<<1)])>>15))/nsymb; + stat1_im[aa] += (((rxcomp[aa][off]*(int32_t)cfo[1+(l2<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l2<<1)])>>15))/nsymb; off+=2; #ifdef DEBUG_PUCCH_RX printf("[eNB] PUCCH subframe %d (%d,%d,%d) => (%d,%d) x (%d,%d) : (%d,%d), stat %d\n",subframe,phase,l2,re, rxcomp[aa][off],rxcomp[aa][1+off], cfo[l2<<1],cfo[1+(l2<<1)], - stat_re,stat_im,stat); + stat1_re[aa],stat1_im[aa],stat); #endif } - - stat += ((stat_re*stat_re) + (stat_im*stat_im)); + + stat0[aa] += ((stat0_re[aa]*stat0_re[aa]) + (stat0_im[aa]*stat0_im[aa])); + stat1[aa] += ((stat1_re[aa]*stat1_re[aa]) + (stat1_im[aa]*stat1_im[aa])); } //re + stat+=(stat0[aa]+stat1[aa]); } // aa - if (stat>stat_max) { stat_max = stat; phase_max = phase; + for (aa=0;aanb_antennas_rx;aa++) { + stat0_max[aa] = stat0[aa]; + stat1_max[aa] = stat1[aa]; + } } } //phase - // stat_max *= nsymb; // normalize to energy per symbol - // stat_max /= (frame_parms->N_RB_UL*12); // stat_max /= 12; #ifdef DEBUG_PUCCH_RX printf("[eNB] PUCCH: stat %d, stat_max %d, phase_max %d\n", stat,stat_max,phase_max); @@ -1207,12 +1262,14 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, #ifdef DEBUG_PUCCH_RX LOG_I(PHY,"[eNB] PUCCH fmt1: stat_max : %d, sigma2_dB %d (%d, %d), phase_max : %d\n",dB_fixed(stat_max),sigma2_dB,eNB->measurements.n0_subband_power_tot_dBm[6],pucch1_thres,phase_max); #endif - eNB->pucch1_stats[UE_id][(subframe<<10)+eNB->pucch1_stats_cnt[UE_id][subframe]] = stat_max; - eNB->pucch1_stats_thres[UE_id][(subframe<<10)+eNB->pucch1_stats_cnt[UE_id][subframe]] = sigma2_dB+pucch1_thres; - eNB->pucch1_stats_cnt[UE_id][subframe] = (eNB->pucch1_stats_cnt[UE_id][subframe]+1)&1023; - T(T_ENB_PHY_PUCCH_1_ENERGY, T_INT(eNB->Mod_id), T_INT(eNB->uci_vars[UE_id].rnti), T_INT(frame), T_INT(subframe), + eNB->pucch1_stats[UCI_id][(subframe<<10)+eNB->pucch1_stats_cnt[UCI_id][subframe]] = stat_max; + eNB->pucch1_stats_thres[UCI_id][(subframe<<10)+eNB->pucch1_stats_cnt[UCI_id][subframe]] = sigma2_dB+pucch1_thres; + eNB->pucch1_stats_cnt[UCI_id][subframe] = (eNB->pucch1_stats_cnt[UCI_id][subframe]+1)&1023; + uci_stats->pucch1_thres = sigma2_dB+pucch1_thres; + T(T_ENB_PHY_PUCCH_1_ENERGY, T_INT(eNB->Mod_id), T_INT(eNB->uci_vars[UCI_id].rnti), T_INT(frame), T_INT(subframe), T_INT(stat_max), T_INT(sigma2_dB+pucch1_thres)); + /* if (eNB->pucch1_stats_cnt[UE_id][subframe] == 0) { LOG_M("pucch_debug.m","pucch_energy", @@ -1226,11 +1283,18 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, // This is a moving average of the PUCCH1 statistics conditioned on being above or below the threshold if (sigma2_dB<(dB_fixed(stat_max)-pucch1_thres)) { *payload = 1; + uci_stats->current_pucch1_stat_pos = stat_max; + for (int aa=0;aanb_antennas_rx;aa++) { + uci_stats->pucch1_low_stat[aa]=stat0_max[aa]; + uci_stats->pucch1_high_stat[aa]=stat1_max[aa]; + uci_stats->pucch1_positive_SR++; + } } else { + uci_stats->current_pucch1_stat_neg = stat_max; *payload = 0; } - if (UE_id==0) { + if (UCI_id==0) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SR_ENERGY,dB_fixed(stat_max)); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_SR_THRES,sigma2_dB+pucch1_thres); } @@ -1239,29 +1303,30 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, #ifdef DEBUG_PUCCH_RX LOG_D(PHY,"Doing PUCCH detection for format 1a/1b\n"); #endif - + int stat_re=0,stat_im=0; for (phase=0; phase<7; phase++) { - stat=0; - + int stat=0; for (aa=0; aanb_antennas_rx; aa++) { + stat0[aa]=0; + stat1[aa]=0; for (re=0; re<12; re++) { // compute received energy first slot, seperately for data and reference // by coherent combining across symbols but not resource elements // Note: assumption is that channel is stationary over symbols in slot after CFO - stat_re=0; - stat_im=0; - stat_ref_re=0; - stat_ref_im=0; + stat0_re[aa]=0; + stat0_im[aa]=0; + stat0_ref_re[aa]=0; + stat0_ref_im[aa]=0; off=re<<1; cfo = (frame_parms->Ncp==0) ? &cfo_pucch_np[14*phase] : &cfo_pucch_ep[12*phase]; for (l=0; l<(nsymb>>1); l++) { if ((l<2)||(l>(nsymb>>1) - 3)) { //data symbols - stat_re += ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); - stat_im += ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); + stat0_re[aa] += ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); + stat0_im[aa] += ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); } else { //reference symbols - stat_ref_re += ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); - stat_ref_im += ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); + stat0_ref_re[aa] += ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); + stat0_ref_im[aa] += ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); } off+=2; @@ -1274,26 +1339,21 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, } // this is total energy received, summed over data and reference - if (fmt==pucch_format1a){ - stat += ((((stat_re*stat_re)) + ((stat_ref_re*stat_ref_re)) + ((stat_ref_im*stat_ref_im)))/nsymb); - }else{ - stat += ((((stat_re*stat_re)) + ((stat_im*stat_im)) + - ((stat_ref_re*stat_ref_re)) + ((stat_ref_im*stat_ref_im)))/nsymb); - } - + stat0[aa] += ((((stat0_re[aa]*stat0_re[aa])) + ((stat0_im[aa]*stat0_im[aa])) + + ((stat0_ref_re[aa]*stat0_ref_re[aa])) + ((stat0_ref_im[aa]*stat0_ref_im[aa])))/nsymb); // now second slot - stat_re=0; - stat_im=0; - stat_ref_re=0; - stat_ref_im=0; + stat1_re[aa]=0; + stat1_im[aa]=0; + stat1_ref_re[aa]=0; + stat1_ref_im[aa]=0; for (l2=0,l=(nsymb>>1); l< nsymb; l++,l2++) { if ((l2<2) || ((l2>(nsymb>>1) - 3)) ) { // data symbols - stat_re += ((rxcomp[aa][off]*(int32_t)cfo[l2<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l2<<1)])>>15); - stat_im += ((rxcomp[aa][off]*(int32_t)cfo[1+(l2<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l2<<1)])>>15); + stat1_re[aa] += ((rxcomp[aa][off]*(int32_t)cfo[l2<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l2<<1)])>>15); + stat1_im[aa] += ((rxcomp[aa][off]*(int32_t)cfo[1+(l2<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l2<<1)])>>15); } else { //reference_symbols - stat_ref_re += ((rxcomp[aa][off]*(int32_t)cfo[l2<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l2<<1)])>>15); - stat_ref_im += ((rxcomp[aa][off]*(int32_t)cfo[1+(l2<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l2<<1)])>>15); + stat1_ref_re[aa] += ((rxcomp[aa][off]*(int32_t)cfo[l2<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l2<<1)])>>15); + stat1_ref_im[aa] += ((rxcomp[aa][off]*(int32_t)cfo[1+(l2<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l2<<1)])>>15); } off+=2; @@ -1308,20 +1368,16 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, #ifdef DEBUG_PUCCH_RX printf("aa%d re %d : phase %d : stat %d\n",aa,re,phase,stat); #endif - if (fmt==pucch_format1a){ - stat += ((((stat_re*stat_re)) + ((stat_ref_re*stat_ref_re)) + ((stat_ref_im*stat_ref_im)))/nsymb); - }else{ - stat += ((((stat_re*stat_re)) + ((stat_im*stat_im)) + - ((stat_ref_re*stat_ref_re)) + ((stat_ref_im*stat_ref_im)))/nsymb); - } - + stat1[aa] += ((((stat1_re[aa]*stat1_re[aa])) + ((stat1_im[aa]*stat1_im[aa])) + + ((stat1_ref_re[aa]*stat1_ref_re[aa])) + ((stat1_ref_im[aa]*stat1_ref_im[aa])))/nsymb); } //re + stat+=(stat0[aa]+stat1[aa]); } // aa #ifdef DEBUG_PUCCH_RX LOG_D(PHY,"Format 1A: phase %d : stat %d\n",phase,stat); #endif - + if (stat>stat_max) { stat_max = stat; phase_max = phase; @@ -1332,8 +1388,6 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, #ifdef DEBUG_PUCCH_RX LOG_I(PHY,"[eNB] PUCCH fmt1a/b: stat_max : %d (%d : sigma2 %d), phase_max : %d\n",stat_max,dB_fixed(stat_max),sigma2_dB,phase_max); #endif - stat_re=0; - stat_im=0; // Do detection now @@ -1341,13 +1395,12 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, // For instance i assume to skip pucch1_thres from the test below. // Not 100% sure - if (sigma2_dB<(dB_fixed(stat_max) - (IS_SOFTMODEM_IQPLAYER?0:pucch1_thres)) ) {// + if (sigma2_dB<(dB_fixed(stat_max) - (IS_SOFTMODEM_IQPLAYER?0:pucch1_thres)) ) {// chL = (nsymb>>1)-4; chest_mag=0; cfo = (frame_parms->Ncp==0) ? &cfo_pucch_np[14*phase_max] : &cfo_pucch_ep[12*phase_max]; for (aa=0; aanb_antennas_rx; aa++) { - // channel estimates first for (re=0; re<12; re++) { // channel estimate for first slot chest0_re[aa][re]=0; @@ -1381,6 +1434,11 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, // now do channel matched filter for (aa=0; aanb_antennas_rx; aa++) { + stat0_re[aa]=0; + stat0_im[aa]=0; + stat1_re[aa]=0; + stat1_im[aa]=0; + for (re=0; re<12; re++) { #ifdef DEBUG_PUCCH_RX printf("[eNB] PUCCH subframe %d chest0[%d][%d] => (%d,%d)\n",subframe,aa,re, @@ -1392,8 +1450,8 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, off=(re<<1) + (24*l); tmp_re = ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); tmp_im = ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); - stat_re += (((tmp_re*chest0_re[aa][re])>>log2_maxh) + ((tmp_im*chest0_im[aa][re])>>log2_maxh)); - stat_im += (((tmp_re*chest0_im[aa][re])>>log2_maxh) - ((tmp_im*chest0_re[aa][re])>>log2_maxh)); + stat0_re[aa] += (((tmp_re*chest0_re[aa][re])>>log2_maxh) + ((tmp_im*chest0_im[aa][re])>>log2_maxh)); + stat0_im[aa] += (((tmp_re*chest0_im[aa][re])>>log2_maxh) - ((tmp_im*chest0_re[aa][re])>>log2_maxh)); off+=2; #ifdef DEBUG_PUCCH_RX printf("[eNB] PUCCH subframe %d (%d,%d) => (%d,%d) x (%d,%d) : (%d,%d) => (%d,%d)\n",subframe,l,re, @@ -1409,8 +1467,8 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, off=(re<<1) + (24*l); tmp_re = ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); tmp_im = ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); - stat_re += (((tmp_re*chest0_re[aa][re])>>log2_maxh) + ((tmp_im*chest0_im[aa][re])>>log2_maxh)); - stat_im += (((tmp_re*chest0_im[aa][re])>>log2_maxh) - ((tmp_im*chest0_re[aa][re])>>log2_maxh)); + stat0_re[aa] += (((tmp_re*chest0_re[aa][re])>>log2_maxh) + ((tmp_im*chest0_im[aa][re])>>log2_maxh)); + stat0_im[aa] += (((tmp_re*chest0_im[aa][re])>>log2_maxh) - ((tmp_im*chest0_re[aa][re])>>log2_maxh)); off+=2; #ifdef DEBUG_PUCCH_RX printf("[eNB] PUCCH subframe %d (%d,%d) => (%d,%d) x (%d,%d) : (%d,%d) => (%d,%d)\n",subframe,l,re, @@ -1431,8 +1489,8 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, off=(re<<1) + (24*l) + (nsymb>>1)*24; tmp_re = ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); tmp_im = ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); - stat_re += (((tmp_re*chest1_re[aa][re])>>log2_maxh) + ((tmp_im*chest1_im[aa][re])>>log2_maxh)); - stat_im += (((tmp_re*chest1_im[aa][re])>>log2_maxh) - ((tmp_im*chest1_re[aa][re])>>log2_maxh)); + stat1_re[aa] += (((tmp_re*chest1_re[aa][re])>>log2_maxh) + ((tmp_im*chest1_im[aa][re])>>log2_maxh)); + stat1_im[aa] += (((tmp_re*chest1_im[aa][re])>>log2_maxh) - ((tmp_im*chest1_re[aa][re])>>log2_maxh)); off+=2; #ifdef DEBUG_PUCCH_RX printf("[PHY][eNB] PUCCH subframe %d (%d,%d) => (%d,%d) x (%d,%d) : (%d,%d) => (%d,%d)\n",subframe,l,re, @@ -1448,8 +1506,8 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, off=(re<<1) + (24*l) + (nsymb>>1)*24; tmp_re = ((rxcomp[aa][off]*(int32_t)cfo[l<<1])>>15) - ((rxcomp[aa][1+off]*(int32_t)cfo[1+(l<<1)])>>15); tmp_im = ((rxcomp[aa][off]*(int32_t)cfo[1+(l<<1)])>>15) + ((rxcomp[aa][1+off]*(int32_t)cfo[(l<<1)])>>15); - stat_re += (((tmp_re*chest1_re[aa][re])>>log2_maxh) + ((tmp_im*chest1_im[aa][re])>>log2_maxh)); - stat_im += (((tmp_re*chest1_im[aa][re])>>log2_maxh) - ((tmp_im*chest1_re[aa][re])>>log2_maxh)); + stat1_re[aa] += (((tmp_re*chest1_re[aa][re])>>log2_maxh) + ((tmp_im*chest1_im[aa][re])>>log2_maxh)); + stat1_im[aa] += (((tmp_re*chest1_im[aa][re])>>log2_maxh) - ((tmp_im*chest1_re[aa][re])>>log2_maxh)); off+=2; #ifdef DEBUG_PUCCH_RX printf("[PHY][eNB] PUCCH subframe %d (%d,%d) => (%d,%d) x (%d,%d) : (%d,%d) => (%d,%d)\n",subframe,l,re, @@ -1464,29 +1522,42 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, printf("aa%d re %d : stat %d,%d\n",aa,re,stat_re,stat_im); #endif } //re + stat_re+=stat0_re[aa]+stat1_re[aa]; + stat_im+=stat0_im[aa]+stat1_im[aa]; } // aa LOG_D(PHY,"PUCCH 1a/b: subframe %d : stat %d,%d (pos %d)\n",subframe,stat_re,stat_im, - (subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])); + (subframe<<10) + (eNB->pucch1ab_stats_cnt[UCI_id][subframe])); LOG_D(PHY,"In pucch.c PUCCH 1a/b: ACK subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); - eNB->pucch1ab_stats[UE_id][(subframe<<11) + 2*(eNB->pucch1ab_stats_cnt[UE_id][subframe])] = (stat_re); - eNB->pucch1ab_stats[UE_id][(subframe<<11) + 1+2*(eNB->pucch1ab_stats_cnt[UE_id][subframe])] = (stat_im); - eNB->pucch1ab_stats_cnt[UE_id][subframe] = (eNB->pucch1ab_stats_cnt[UE_id][subframe]+1)&1023; + eNB->pucch1ab_stats[UCI_id][(subframe<<11) + 2*(eNB->pucch1ab_stats_cnt[UCI_id][subframe])] = (stat_re); + eNB->pucch1ab_stats[UCI_id][(subframe<<11) + 1+2*(eNB->pucch1ab_stats_cnt[UCI_id][subframe])] = (stat_im); + eNB->pucch1ab_stats_cnt[UCI_id][subframe] = (eNB->pucch1ab_stats_cnt[UCI_id][subframe]+1)&1023; /* frame not available here - set to -1 for the moment */ - T(T_ENB_PHY_PUCCH_1AB_IQ, T_INT(eNB->Mod_id), T_INT(eNB->uci_vars[UE_id].rnti), T_INT(-1), T_INT(subframe), T_INT(stat_re), T_INT(stat_im)); + T(T_ENB_PHY_PUCCH_1AB_IQ, T_INT(eNB->Mod_id), T_INT(eNB->uci_vars[UCI_id].rnti), T_INT(-1), T_INT(subframe), T_INT(stat_re), T_INT(stat_im)); *payload = (stat_re<0) ? 1 : 2; // 1 == ACK, 2 == NAK - if (fmt==pucch_format1b) + if (fmt==pucch_format1b) { + uci_stats->pucch1b_trials++; *(1+payload) = (stat_im<0) ? 1 : 2; + uci_stats->current_pucch1b_stat_re = stat_re; + uci_stats->current_pucch1b_stat_im = stat_im; + } + else { + uci_stats->pucch1a_trials++; + uci_stats->current_pucch1a_stat_re = stat_re; + uci_stats->current_pucch1a_stat_im = stat_im; + } + } else { // insufficient energy on PUCCH so NAK LOG_D(PHY,"In pucch.c PUCCH 1a/b: NAK subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); *payload = 4; // DTX - ((int16_t *)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[0] = (int16_t)(stat_re); - ((int16_t *)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[1] = (int16_t)(stat_im); - eNB->pucch1ab_stats_cnt[UE_id][subframe] = (eNB->pucch1ab_stats_cnt[UE_id][subframe]+1)&1023; + ((int16_t *)&eNB->pucch1ab_stats[UCI_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UCI_id][subframe])])[0] = (int16_t)(stat_re); + ((int16_t *)&eNB->pucch1ab_stats[UCI_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UCI_id][subframe])])[1] = (int16_t)(stat_im); + eNB->pucch1ab_stats_cnt[UCI_id][subframe] = (eNB->pucch1ab_stats_cnt[UCI_id][subframe]+1)&1023; if (fmt==pucch_format1b) *(1+payload) = 4; + uci_stats->pucch1ab_DTX++; } } else { LOG_E(PHY,"[eNB] PUCCH fmt2/2a/2b not supported\n"); diff --git a/openair1/PHY/LTE_TRANSPORT/pucch_common.c b/openair1/PHY/LTE_TRANSPORT/pucch_common.c index 5b939b08d2..d7a500d5f7 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch_common.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch_common.c @@ -31,7 +31,6 @@ */ #include "PHY/defs_eNB.h" #include "PHY/phy_extern.h" -#include "LAYER2/MAC/mac.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/log.h" diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common.h b/openair1/PHY/LTE_TRANSPORT/transport_common.h index ab2921c2b9..135f3cdf4b 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_common.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_common.h @@ -35,9 +35,9 @@ #include "dci.h" #include "mdci.h" //#include "uci.h" -#ifndef STANDALONE_COMPILE - #include "UTIL/LISTS/list.h" -#endif +//#ifndef STANDALONE_COMPILE +// #include "UTIL/LISTS/list.h" +//#endif #define MOD_TABLE_QPSK_OFFSET 1 #define MOD_TABLE_16QAM_OFFSET 5 @@ -57,7 +57,7 @@ // maximum of 3 segments before each coding block if data length exceeds 6144 bits. -#define MAX_NUM_DLSCH_SEGMENTS 16 +#define MAX_NUM_DLSCH_SEGMENTS 13 #define MAX_NUM_ULSCH_SEGMENTS MAX_NUM_DLSCH_SEGMENTS #define MAX_DLSCH_PAYLOAD_BYTES (MAX_NUM_DLSCH_SEGMENTS*768) #define MAX_ULSCH_PAYLOAD_BYTES (MAX_NUM_ULSCH_SEGMENTS*768) @@ -65,22 +65,6 @@ #define MAX_NUM_CHANNEL_BITS (14*1200*6) // 14 symbols, 1200 REs, 12 bits/RE #define MAX_NUM_RE (14*1200) -#if !defined(SI_RNTI) - #define SI_RNTI (rnti_t)0xffff - #define SI_RNTI_MBMS (rnti_t)0xfff9 -#endif -#if !defined(M_RNTI) - #define M_RNTI (rnti_t)0xfffd -#endif -#if !defined(P_RNTI) - #define P_RNTI (rnti_t)0xfffe -#endif -#if !defined(CBA_RNTI) - #define CBA_RNTI (rnti_t)0xfff4 -#endif -#if !defined(C_RNTI) - #define C_RNTI (rnti_t)0x1234 -#endif // These are the codebook indexes according to Table 6.3.4.2.3-1 of 36.211 //1 layer #define PMI_2A_11 0 @@ -93,7 +77,8 @@ #define PMI_2A_R1_1j 2 typedef enum { SEARCH_EXIST=0, - SEARCH_EXIST_OR_FREE + SEARCH_EXIST_OR_FREE, + SEARCH_EXIST_RA } find_type_t; typedef enum { diff --git a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h index 1944f06fab..622f37b3bc 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_common_proto.h @@ -223,7 +223,9 @@ uint8_t get_num_prach_tdd(module_id_t Mod_id); @param frame_type 0-FDD, 1-TDD @returns 0-1 accordingly */ +/* uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); +*/ /*! \brief Helper for MAC, returns frequency index of PRACH resource in TDD for a particular configuration index @@ -306,12 +308,12 @@ void init_scrambling_lut(void); void init_unscrambling_lut(void); - +/* uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, uint8_t prach_ConfigIndex, uint8_t n_ra_prboffset, uint8_t tdd_mapindex, uint16_t Nf); - +*/ uint8_t subframe2harq_pid(LTE_DL_FRAME_PARMS *frame_parms,frame_t frame,uint8_t subframe); uint8_t ul_subframe2pdcch_alloc_subframe(LTE_DL_FRAME_PARMS *frame_parms,uint8_t n); @@ -319,6 +321,6 @@ uint32_t conv_1C_RIV(int32_t rballoc,uint32_t N_RB_DL); void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t *rb_alloc2); -int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs); +int16_t estimate_ue_tx_power(int norm,uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs); #endif diff --git a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h index 5e446db5fd..b3985e973a 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_eNB.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_eNB.h @@ -36,9 +36,9 @@ #include "dci.h" #include "mdci.h" #include "uci_common.h" -#ifndef STANDALONE_COMPILE - #include "UTIL/LISTS/list.h" -#endif +//#ifndef STANDALONE_COMPILE +// #include "UTIL/LISTS/list.h" +//#endif // structures below implement 36-211 and 36-212 diff --git a/openair1/PHY/LTE_TRANSPORT/transport_proto.h b/openair1/PHY/LTE_TRANSPORT/transport_proto.h index 9e37821b05..19af50056c 100644 --- a/openair1/PHY/LTE_TRANSPORT/transport_proto.h +++ b/openair1/PHY/LTE_TRANSPORT/transport_proto.h @@ -520,6 +520,9 @@ int generate_eNB_ulsch_params_from_dci(PHY_VARS_eNB *PHY_vars_eNB, void dump_ulsch(PHY_VARS_eNB *phy_vars_eNB,int frame, int subframe, uint8_t UE_id,int round); +void dump_ulsch_stats(FILE *fd,PHY_VARS_eNB *eNB,int frame); +void dump_uci_stats(FILE *fd,PHY_VARS_eNB *eNB,int frame); + @@ -691,13 +694,11 @@ void conv_eMTC_rballoc(uint16_t resource_block_coding, uint32_t N_RB_DL, uint32_t *rb_alloc); -int16_t find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); +int find_dlsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); -int16_t find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); +int find_ulsch(uint16_t rnti, PHY_VARS_eNB *eNB,find_type_t type); -int16_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); - -uint8_t get_prach_fmt(uint8_t prach_ConfigIndex,lte_frame_type_t frame_type); +int find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type); uint32_t lte_gold_generic(uint32_t *x1, uint32_t *x2, uint8_t reset); diff --git a/openair1/PHY/LTE_TRANSPORT/uci_tools.c b/openair1/PHY/LTE_TRANSPORT/uci_tools.c index f8ade9afc8..ae039bec2a 100644 --- a/openair1/PHY/LTE_TRANSPORT/uci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/uci_tools.c @@ -37,12 +37,11 @@ //#define DEBUG_UCI 1 -int16_t find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type) { - uint16_t i; - int16_t first_free_index=-1; +int find_uci(uint16_t rnti, int frame, int subframe, PHY_VARS_eNB *eNB,find_type_t type) { + int first_free_index=-1; AssertFatal(eNB!=NULL,"eNB is null\n"); - for (i=0; iuci_vars[i].active >0) && (eNB->uci_vars[i].rnti==rnti) && (eNB->uci_vars[i].frame==frame) && diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 476d7028b1..ae8c666d18 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -468,6 +468,35 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, ulsch_harq->Nsymb_pusch, nb_rb); //#endif + + eNB_SCH_STATS_t *stats=NULL; + int first_free=-1; + for (int i=0;iulsch_stats[i].rnti == 0 && first_free == -1) { + first_free = i; + stats=&eNB->ulsch_stats[i]; + } + if (eNB->ulsch_stats[i].rnti == ulsch->rnti) { + stats=&eNB->ulsch_stats[i]; + break; + } + } + if (stats) { + stats->rnti = ulsch->rnti; + stats->round_trials[ulsch_harq->round]++; + stats->frame=proc->frame_rx; + } + if (ulsch_harq->round == 0) { + if (stats) { + stats->current_Qm = Q_m; + stats->current_RI = 1; + stats->total_bytes_tx += ulsch_harq->TBS; + stats->current_TBS = ulsch_harq->TBS; + stats->current_G = ulsch_harq->G; + } + } + + //if (ulsch_harq->round == 0) { // delete for RB shortage pattern // This is a new packet, so compute quantities regarding segmentation ulsch_harq->B = A+24; @@ -1086,3 +1115,44 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB, ret = ulsch_decoding_data_all(eNB,proc, UE_id,harq_pid,llr8_flag); return(ret); } + +#define STATSTRLEN 16384 +void dump_ulsch_stats(FILE *fd,PHY_VARS_eNB *eNB,int frame) { + + char output[16384]; + int stroff=0; + for (int i=0;iulsch_stats[i].rnti>0 && eNB->ulsch_stats[i].round_trials[0]>100) { + for (int aa=0;aaframe_parms.nb_antennas_rx;aa++) + stroff+=sprintf(output+stroff,"ULSCH RNTI %x: ulsch_power[%d] %d, ulsch_noise_power[%d] %d\n", + eNB->ulsch_stats[i].rnti, aa,eNB->ulsch_stats[i].ulsch_power[aa],aa,eNB->ulsch_stats[i].ulsch_noise_power[aa]); + AssertFatal(stroff<(STATSTRLEN-1000),"Increase STATSTRLEN\n"); + stroff+=sprintf(output+stroff,"ULSCH RNTI %x: round_trials %d(%1.1e):%d(%1.1e):%d(%1.1e):%d\n", + eNB->ulsch_stats[i].rnti, + eNB->ulsch_stats[i].round_trials[0], + (double)eNB->ulsch_stats[i].round_trials[1]/eNB->ulsch_stats[i].round_trials[0], + eNB->ulsch_stats[i].round_trials[1], + (double)eNB->ulsch_stats[i].round_trials[2]/eNB->ulsch_stats[i].round_trials[0], + eNB->ulsch_stats[i].round_trials[2], + (double)eNB->ulsch_stats[i].round_trials[3]/eNB->ulsch_stats[i].round_trials[0], + eNB->ulsch_stats[i].round_trials[3]); + stroff+=sprintf(output+stroff,"ULSCH RNTI %x: current_Qm %d, current_G %d, current_TBS %d, current_rate %f,current_RI %d, timing_offset %d, total_bytes RX/SCHED %d/%d\n", + eNB->ulsch_stats[i].rnti, + eNB->ulsch_stats[i].current_Qm, + eNB->ulsch_stats[i].current_G, + eNB->ulsch_stats[i].current_TBS, + (double)eNB->ulsch_stats[i].current_G/eNB->ulsch_stats[i].current_TBS, + eNB->ulsch_stats[i].current_RI, + eNB->ulsch_stats[i].timing_offset, + eNB->ulsch_stats[i].total_bytes_rx, + eNB->ulsch_stats[i].total_bytes_tx); + } + fprintf(fd,"%s",output); +} + +void clear_ulsch_stats(PHY_VARS_eNB *eNB) { + + for (int i=0;iulsch_stats[i],0,sizeof(eNB->ulsch_stats[i])); +} + diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c index eeab616097..3529df8e44 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c @@ -31,12 +31,12 @@ */ #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" +//#include "PHY/phy_extern.h" #include "transport_eNB.h" #include "PHY/sse_intrin.h" #include "transport_common_proto.h" #include "PHY/LTE_ESTIMATION/lte_estimation.h" -#include "PHY/MODULATION/modulation_eNB.h" +//#include "PHY/MODULATION/modulation_eNB.h" #include "T.h" @@ -45,8 +45,11 @@ //extern int **ulchmag_eren; //eren -static short jitter[8] __attribute__ ((aligned(16))) = {1,0,0,1,0,1,1,0}; -static short jitterc[8] __attribute__ ((aligned(16))) = {0,1,1,0,1,0,0,1}; +static const short jitter[8] __attribute__ ((aligned(16))) = {1,0,0,1,0,1,1,0}; +static const short jitterc[8] __attribute__ ((aligned(16))) = {0,1,1,0,1,0,0,1}; +static const short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; +static const short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; + void lte_idft(LTE_DL_FRAME_PARMS *frame_parms,uint32_t *z, uint16_t Msc_PUSCH) { #if defined(__x86_64__) || defined(__i386__) @@ -511,7 +514,6 @@ void ulsch_16qam_llr(LTE_DL_FRAME_PARMS *frame_parms, for (i=0; i<(nb_rb*3); i++) { #if defined(__x86_64__) || defined(__i386__) mmtmpU0 = _mm_abs_epi16(rxF[i]); - // print_shorts("tmp0",&tmp0); mmtmpU0 = _mm_subs_epi16(ch_mag[i],mmtmpU0); (*llrp128)[0] = _mm_unpacklo_epi32(rxF[i],mmtmpU0); (*llrp128)[1] = _mm_unpackhi_epi32(rxF[i],mmtmpU0); @@ -627,11 +629,15 @@ void ulsch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, uint8_t symbol, uint16_t nb_rb) { #if defined(__x86_64__) || defined(__i386__) - __m128i *rxdataF_comp128_0,*ul_ch_mag128_0,*ul_ch_mag128_0b; - __m128i *rxdataF_comp128_1,*ul_ch_mag128_1,*ul_ch_mag128_1b; + __m128i *rxdataF_comp128_0=NULL,*ul_ch_mag128_0=NULL,*ul_ch_mag128_0b=NULL; + __m128i *rxdataF_comp128_1=NULL,*ul_ch_mag128_1=NULL,*ul_ch_mag128_1b=NULL; + __m128i *rxdataF_comp128_2=NULL,*ul_ch_mag128_2=NULL,*ul_ch_mag128_2b=NULL; + __m128i *rxdataF_comp128_3=NULL,*ul_ch_mag128_3=NULL,*ul_ch_mag128_3b=NULL; #elif defined(__arm__) int16x8_t *rxdataF_comp128_0,*ul_ch_mag128_0,*ul_ch_mag128_0b; int16x8_t *rxdataF_comp128_1,*ul_ch_mag128_1,*ul_ch_mag128_1b; + int16x8_t *rxdataF_comp128_2,*ul_ch_mag128_2,*ul_ch_mag128_2b; + int16x8_t *rxdataF_comp128_3,*ul_ch_mag128_3,*ul_ch_mag128_3b; #endif int32_t i; @@ -643,15 +649,39 @@ void ulsch_detection_mrc(LTE_DL_FRAME_PARMS *frame_parms, ul_ch_mag128_1 = (__m128i *)&ul_ch_mag[1][symbol*frame_parms->N_RB_DL*12]; ul_ch_mag128_0b = (__m128i *)&ul_ch_magb[0][symbol*frame_parms->N_RB_DL*12]; ul_ch_mag128_1b = (__m128i *)&ul_ch_magb[1][symbol*frame_parms->N_RB_DL*12]; - - // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) - for (i=0; inb_antennas_rx>2) { + rxdataF_comp128_2 = (__m128i *)&rxdataF_comp[2][symbol*frame_parms->N_RB_DL*12]; + ul_ch_mag128_2 = (__m128i *)&ul_ch_mag[2][symbol*frame_parms->N_RB_DL*12]; + ul_ch_mag128_2b = (__m128i *)&ul_ch_magb[2][symbol*frame_parms->N_RB_DL*12]; + } + if (frame_parms->nb_antennas_rx>3) { + rxdataF_comp128_3 = (__m128i *)&rxdataF_comp[3][symbol*frame_parms->N_RB_DL*12]; + ul_ch_mag128_3 = (__m128i *)&ul_ch_mag[3][symbol*frame_parms->N_RB_DL*12]; + ul_ch_mag128_3b = (__m128i *)&ul_ch_magb[3][symbol*frame_parms->N_RB_DL*12]; } + // MRC on each re of rb, both on MF output and magnitude (for 16QAM/64QAM llr computation) + if (frame_parms->nb_antennas_rx==2) + for (i=0; inb_antennas_rx==3) + for (i=0; inb_antennas_rx==4) + for (i=0; iN_RB_DL*12]; rxdataF_comp128_1 = (int16x8_t *)&rxdataF_comp[1][symbol*frame_parms->N_RB_DL*12]; @@ -795,7 +825,7 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, mmtmpU0 = _mm_srai_epi32(mmtmpU0,output_shift); mmtmpU1 = _mm_packs_epi32(mmtmpU0,mmtmpU0); ul_ch_mag128[2] = _mm_unpacklo_epi16(mmtmpU1,mmtmpU1); - LOG_D(PHY,"comp: symbol %d rb %d => %d,%d,%d (output_shift %d)\n",symbol,rb,*((int16_t *)&ul_ch_mag128[0]),*((int16_t *)&ul_ch_mag128[1]),*((int16_t *)&ul_ch_mag128[2]),output_shift); + //LOG_I(PHY,"comp: ant %d symbol %d rb %d => %d,%d,%d (output_shift %d)\n",aarx,symbol,rb,*((int16_t *)&ul_ch_mag128[0]),*((int16_t *)&ul_ch_mag128[1]),*((int16_t *)&ul_ch_mag128[2]),output_shift); #elif defined(__arm__) mmtmpU0 = vmull_s16(ul_ch128[0], ul_ch128[0]); mmtmpU0 = vqshlq_s32(vqaddq_s32(mmtmpU0,vrev64q_s32(mmtmpU0)),-output_shift128); @@ -834,6 +864,7 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, // print_ints("c1",&mmtmpU3); rxdataF_comp128[0] = _mm_packs_epi32(mmtmpU2,mmtmpU3); /* + LOG_I(PHY,"Antenna %d:",aarx); print_shorts("rx:",&rxdataF128[0]); print_shorts("ch:",&ul_ch128[0]); print_shorts("pack:",&rxdataF_comp128[0]); @@ -851,9 +882,12 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, mmtmpU2 = _mm_unpacklo_epi32(mmtmpU0,mmtmpU1); mmtmpU3 = _mm_unpackhi_epi32(mmtmpU0,mmtmpU1); rxdataF_comp128[1] = _mm_packs_epi32(mmtmpU2,mmtmpU3); - // print_shorts("rx:",rxdataF128[1]); - // print_shorts("ch:",ul_ch128[1]); - // print_shorts("pack:",rxdataF_comp128[1]); + /* + LOG_I(PHY,"Antenna %d:",aarx); + print_shorts("rx:",&rxdataF128[1]); + print_shorts("ch:",&ul_ch128[1]); + print_shorts("pack:",&rxdataF_comp128[1]); + */ // multiply by conjugated channel mmtmpU0 = _mm_madd_epi16(ul_ch128[2],rxdataF128[2]); // mmtmpU0 contains real part of 4 consecutive outputs (32-bit) @@ -867,9 +901,12 @@ void ulsch_channel_compensation(int32_t **rxdataF_ext, mmtmpU2 = _mm_unpacklo_epi32(mmtmpU0,mmtmpU1); mmtmpU3 = _mm_unpackhi_epi32(mmtmpU0,mmtmpU1); rxdataF_comp128[2] = _mm_packs_epi32(mmtmpU2,mmtmpU3); - // print_shorts("rx:",rxdataF128[2]); - // print_shorts("ch:",ul_ch128[2]); - // print_shorts("pack:",rxdataF_comp128[2]); + /* + LOG_I(PHY,"Antenna %d:",aarx); + print_shorts("rx:",&rxdataF128[2]); + print_shorts("ch:",&ul_ch128[2]); + print_shorts("pack:",&rxdataF_comp128[2]); + */ // Add a jitter to compensate for the saturation in "packs" resulting in a bias on the DC after IDFT rxdataF_comp128[0] = _mm_add_epi16(rxdataF_comp128[0],(*(__m128i *)&jitter[0])); rxdataF_comp128[1] = _mm_add_epi16(rxdataF_comp128[1],(*(__m128i *)&jitter[0])); @@ -1078,6 +1115,15 @@ void rx_ulsch(PHY_VARS_eNB *eNB, } for (i=0; inb_antennas_rx; i++) { + pusch_vars->ulsch_power[i] = signal_energy_nodc(pusch_vars->drs_ch_estimates[i], + ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12)/correction_factor; + LOG_D(PHY,"%4.4d.%d power harq_pid %d rb %2.2d TBS %2.2d (MPR_times_Ks %d correction %d) power %d dBtimes10\n", proc->frame_rx, proc->subframe_rx, harq_pid, + ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->TBS,MPR_times_100Ks,correction_factor,dB_fixed_x10(pusch_vars->ulsch_power[i])); + pusch_vars->ulsch_noise_power[i]=0; + for (int rb=0;rbharq_processes[harq_pid]->nb_rb;rb++) + pusch_vars->ulsch_noise_power[i]+=eNB->measurements.n0_subband_power[i][rb]/ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; + LOG_D(PHY,"noise power[%d] %d\n",i,dB_fixed_x10(pusch_vars->ulsch_noise_power[i])); +/* Check this modification w.r.t to new PUSCH modifications //symbol 3 int symbol_offset = frame_parms->N_RB_UL*12*(3 - frame_parms->Ncp); pusch_vars->ulsch_interference_power[i] = interference_power(&pusch_vars->drs_ch_estimates[i][symbol_offset],ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12); @@ -1100,7 +1146,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, } LOG_D(PHY,"%4.4d.%d power harq_pid %d rb %2.2d TBS %2.2d (MPR_times_Ks %d correction %d) power %d dBtimes10\n", proc->frame_rx, proc->subframe_rx, harq_pid, ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, ulsch[UE_id]->harq_processes[harq_pid]->TBS,MPR_times_100Ks,correction_factor,dB_fixed_x10(pusch_vars->ulsch_power[i])); - + */ } ulsch_channel_level(pusch_vars->drs_ch_estimates, @@ -1113,8 +1159,7 @@ void rx_ulsch(PHY_VARS_eNB *eNB, for (aarx=0; aarxnb_antennas_rx; aarx++) avgs = cmax(avgs,avgU[aarx]); - // log2_maxh = 4+(log2_approx(avgs)/2); - log2_maxh = (log2_approx(avgs)/2)+ log2_approx(frame_parms->nb_antennas_rx-1)+4; + log2_maxh = 4+(log2_approx(avgs)/2); LOG_D(PHY,"[ULSCH] log2_maxh = %d (%d,%d)\n",log2_maxh,avgU[0],avgs); for (l=0; l<(frame_parms->symbols_per_tti-ulsch[UE_id]->harq_processes[harq_pid]->srs_active); l++) { @@ -1221,67 +1266,56 @@ void dump_ulsch(PHY_VARS_eNB *eNB,int frame,int subframe,uint8_t UE_id,int round uint8_t harq_pid; char fname[100],vname[100]; harq_pid = subframe2harq_pid(&eNB->frame_parms,frame,subframe); - LOG_UI(PHY,"Dumping ULSCH in subframe %d with harq_pid %d, round %d for NB_rb %d, TBS %d, Qm %d, N_symb %d\n", + LOG_UI(PHY,"Dumping ULSCH in subframe %d with harq_pid %d, round %d for NB_rb %d, first_rb %d, TBS %d, Qm %d, N_symb %d\n", subframe,harq_pid,round,eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb, + eNB->ulsch[UE_id]->harq_processes[harq_pid]->first_rb, eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS,eNB->ulsch[UE_id]->harq_processes[harq_pid]->Qm, eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch); + for (int aa=0;aaframe_parms.nb_antennas_rx;aa++) + LOG_UI(PHY,"ulsch_power[%d] %d, ulsch_noise_power[%d] %d\n",aa,dB_fixed_x10(eNB->pusch_vars[UE_id]->ulsch_power[aa]),aa,dB_fixed_x10(eNB->pusch_vars[UE_id]->ulsch_noise_power[aa])); sprintf(fname,"/tmp/ulsch_r%d_d",round); sprintf(vname,"/tmp/ulsch_r%d_dseq",round); LOG_UM(fname,vname,&eNB->ulsch[UE_id]->harq_processes[harq_pid]->d[0][96], eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus*3,1,0); if (eNB->common_vars.rxdata) { - sprintf(fname,"/tmp/rxsig0_r%d.m",round); - sprintf(vname,"rxs0_r%d",round); - LOG_UM(fname,vname, &eNB->common_vars.rxdata[0][0],eNB->frame_parms.samples_per_tti*10,1,1); + for (int aarx=0;aarxframe_parms.nb_antennas_rx;aarx++) { + sprintf(fname,"/tmp/rxsig%d_r%d.m",aarx,round); + sprintf(vname,"rxs%d_r%d",aarx,round); + LOG_UM(fname,vname, &eNB->common_vars.rxdata[aarx][0],eNB->frame_parms.samples_per_tti*10,1,1); - if (eNB->frame_parms.nb_antennas_rx>1) - if (eNB->common_vars.rxdata) { - sprintf(fname,"/tmp/rxsig1_r%d.m",round); - sprintf(vname,"rxs1_r%d",round); - LOG_UM(fname,vname, &eNB->common_vars.rxdata[1][0],eNB->frame_parms.samples_per_tti*10,1,1); - } + } } - - sprintf(fname,"/tmp/rxsigF0_r%d.m",round); - sprintf(vname,"rxsF0_r%d",round); - LOG_UM(fname,vname, (void *)&eNB->common_vars.rxdataF[0][0],eNB->frame_parms.ofdm_symbol_size*nsymb,1,1); - - if (eNB->frame_parms.nb_antennas_rx>1) { - sprintf(fname,"/tmp/rxsigF1_r%d.m",round); - sprintf(vname,"rxsF1_r%d",round); - LOG_UM(vname,fname, &eNB->common_vars.rxdataF[1][0],eNB->frame_parms.ofdm_symbol_size*nsymb,1,1); + if (eNB->common_vars.rxdataF) { + for (int aarx=0;aarxframe_parms.nb_antennas_rx;aarx++) { + sprintf(fname,"/tmp/rxsigF%d_r%d.m",aarx,round); + sprintf(vname,"rxsF%d_r%d",aarx,round); + LOG_UM(fname,vname, (void *)&eNB->common_vars.rxdataF[aarx][0],eNB->frame_parms.ofdm_symbol_size*nsymb,1,1); + } } - - sprintf(fname,"/tmp/rxsigF0_ext_r%d.m",round); - sprintf(vname,"rxsF0_ext_r%d",round); - LOG_UM(fname,vname, &eNB->pusch_vars[UE_id]->rxdataF_ext[0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); - - if (eNB->frame_parms.nb_antennas_rx>1) { - sprintf(fname,"/tmp/rxsigF1_ext_r%d.m",round); - sprintf(vname,"rxsF1_ext_r%d",round); - LOG_UM(fname,vname,&eNB->pusch_vars[UE_id]->rxdataF_ext[1][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); + if (eNB->pusch_vars[UE_id]->rxdataF_ext) { + for (int aarx=0;aarxframe_parms.nb_antennas_rx;aarx++) { + sprintf(fname,"/tmp/rxsigF%d_ext_r%d.m",aarx,round); + sprintf(vname,"rxsF%d_ext_r%d",aarx,round); + LOG_UM(fname,vname, &eNB->pusch_vars[UE_id]->rxdataF_ext[aarx][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); + } } - /* if (eNB->srs_vars[UE_id].srs_ch_estimates) LOG_UM("/tmp/srs_est0.m","srsest0",eNB->srs_vars[UE_id].srs_ch_estimates[0],eNB->frame_parms.ofdm_symbol_size,1,1); if (eNB->frame_parms.nb_antennas_rx>1) if (eNB->srs_vars[UE_id].srs_ch_estimates) LOG_UM("/tmp/srs_est1.m","srsest1",eNB->srs_vars[UE_id].srs_ch_estimates[1],eNB->frame_parms.ofdm_symbol_size,1,1); */ - sprintf(fname,"/tmp/drs_est0_r%d.m",round); - sprintf(vname,"drsest0_r%d",round); - LOG_UM(fname,vname,eNB->pusch_vars[UE_id]->drs_ch_estimates[0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); + for (int aarx=0;aarxframe_parms.nb_antennas_rx;aarx++) { + sprintf(fname,"/tmp/drs_est%d_r%d.m",aarx,round); + sprintf(vname,"drsest%d_r%d",aarx,round); + LOG_UM(fname,vname,eNB->pusch_vars[UE_id]->drs_ch_estimates[aarx],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); - if (eNB->frame_parms.nb_antennas_rx>1) { - sprintf(fname,"/tmp/drs_est1_r%d.m",round); - sprintf(vname,"drsest1_r%d",round); - LOG_UM(fname,vname,eNB->pusch_vars[UE_id]->drs_ch_estimates[1],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); + sprintf(fname,"/tmp/ulsch%d_rxF_comp0_r%d.m",aarx,round); + sprintf(vname,"ulsch_rxF%d_comp0_r%d",aarx,round); + LOG_UM(fname,vname,&eNB->pusch_vars[UE_id]->rxdataF_comp[aarx][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); } - sprintf(fname,"/tmp/ulsch0_rxF_comp0_r%d.m",round); - sprintf(vname,"ulsch0_rxF_comp0_r%d",round); - LOG_UM(fname,vname,&eNB->pusch_vars[UE_id]->rxdataF_comp[0][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); // LOG_M("ulsch_rxF_comp1.m","ulsch0_rxF_comp1",&eNB->pusch_vars[UE_id]->rxdataF_comp[0][1][0],eNB->frame_parms.N_RB_UL*12*nsymb,1,1); sprintf(fname,"/tmp/ulsch_rxF_llr_r%d.m",round); sprintf(vname,"ulsch_llr_r%d",round); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c index 7442a0ae7e..39900113b7 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_decoding.c @@ -78,7 +78,7 @@ LTE_UE_DLSCH_t *new_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint8_ switch (N_RB_DL) { case 6: - bw_scaling =16; + bw_scaling =4; break; case 25: @@ -276,7 +276,7 @@ uint32_t dlsch_decoding(PHY_VARS_UE *phy_vars_ue, switch (frame_parms->N_RB_DL) { case 6: - bw_scaling =16; + bw_scaling =4; break; case 25: diff --git a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c index ab7c2b9091..929f63e9fc 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/prach_ue.c @@ -41,6 +41,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "../LTE_TRANSPORT/prach_extern.h" +#include "common/utils/lte/prach_utils.h" //#define PRACH_DEBUG 1 @@ -115,7 +116,9 @@ int32_t generate_prach( PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe, uint1 NCS = NCS_restricted[Ncs_config]; } - n_ra_prb = get_prach_prb_offset(&(ue->frame_parms), + n_ra_prb = get_prach_prb_offset(ue->frame_parms.frame_type, + ue->frame_parms.tdd_config, + ue->frame_parms.N_RB_UL, ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex, ue->frame_parms.prach_config_common.prach_ConfigInfo.prach_FreqOffset, tdd_mapindex, Nf); diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h index 3299401443..7ab795cae9 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_proto_ue.h @@ -1740,10 +1740,5 @@ double computeRhoB_UE(PDSCH_CONFIG_DEDICATED *pdsch_config_dedicated, LTE_UE_DLSCH_t *dlsch_ue); */ -uint8_t get_prach_prb_offset(LTE_DL_FRAME_PARMS *frame_parms, - uint8_t prach_ConfigIndex, - uint8_t n_ra_prboffset, - uint8_t tdd_mapindex, uint16_t Nf); - /**@}*/ #endif diff --git a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h index 4c433a5683..6b84a5f969 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h +++ b/openair1/PHY/LTE_UE_TRANSPORT/transport_ue.h @@ -36,9 +36,11 @@ #include "../LTE_TRANSPORT/mdci.h" #include "../LTE_TRANSPORT/uci_common.h" #include "../LTE_TRANSPORT/transport_common.h" +/* #ifndef STANDALONE_COMPILE #include "UTIL/LISTS/list.h" #endif +*/ #include "../LTE_TRANSPORT/transport_common.h" diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c index 4405c46abf..d592aa466e 100644 --- a/openair1/PHY/MODULATION/beamforming.c +++ b/openair1/PHY/MODULATION/beamforming.c @@ -44,7 +44,6 @@ #include "PHY/defs_common.h" #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" #include "PHY/CODING/coding_defs.h" #include "PHY/CODING/coding_extern.h" #include "PHY/CODING/lte_interleaver_inline.h" diff --git a/openair1/PHY/MODULATION/slot_fep_ul.c b/openair1/PHY/MODULATION/slot_fep_ul.c index 746f8dbc0e..ccb7ee5f3e 100644 --- a/openair1/PHY/MODULATION/slot_fep_ul.c +++ b/openair1/PHY/MODULATION/slot_fep_ul.c @@ -20,8 +20,8 @@ */ #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" -#include "modulation_eNB.h" +//#include "PHY/phy_extern.h" +//#include "modulation_eNB.h" //#define DEBUG_FEP diff --git a/openair1/PHY/MODULATION/ul_7_5_kHz.c b/openair1/PHY/MODULATION/ul_7_5_kHz.c index a5b428a813..384b9d621c 100644 --- a/openair1/PHY/MODULATION/ul_7_5_kHz.c +++ b/openair1/PHY/MODULATION/ul_7_5_kHz.c @@ -20,7 +20,6 @@ */ #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" #include #include "PHY/sse_intrin.h" #include "modulation_extern.h" diff --git a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c index 116a943880..91b6a59248 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c +++ b/openair1/PHY/NR_ESTIMATION/nr_measurements_gNB.c @@ -102,12 +102,8 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int first_symb,int num_symb) { NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; NR_gNB_COMMON *common_vars = &gNB->common_vars; PHY_MEASUREMENTS_gNB *measurements = &gNB->measurements; - NR_DL_FRAME_PARMS *fp = &gNB->frame_parms; - double rx_gain = openair0_cfg[0].rx_gain[0]; - double rx_gain_offset = openair0_cfg[0].rx_gain_offset[0]; uint32_t *rb_mask = gNB->rb_mask_ul; int rb, offset, offset0, nb_rb, len; - uint32_t n0_subband_power_temp = 0; int32_t *ul_ch; int32_t n0_power_tot; int64_t n0_power_tot2; diff --git a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h index 7ecaa97f6a..89bb5b2807 100644 --- a/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h +++ b/openair1/PHY/NR_ESTIMATION/nr_ul_estimation.h @@ -47,6 +47,8 @@ int nr_pusch_channel_estimation(PHY_VARS_gNB *gNB, unsigned short bwp_start_subcarrier, nfapi_nr_pusch_pdu_t *pusch_pdu); +void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB); + void gNB_I0_measurements(PHY_VARS_gNB *gNB,int first_symb,int num_symb); void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq_pid, unsigned char symbol); diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci.c b/openair1/PHY/NR_TRANSPORT/nr_dci.c index aa31cbe17b..d208167855 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci.c @@ -97,7 +97,7 @@ void nr_generate_dci(PHY_VARS_gNB *gNB, cset_start_symb = pdcch_pdu_rel15->StartSymbolIndex; cset_nsymb = pdcch_pdu_rel15->DurationSymbols; dci_idx = 0; - LOG_D(PHY, "Coreset rb_offset %d, nb_rb %d\n",rb_offset,n_rb); + LOG_D(PHY, "Coreset rb_offset %d, nb_rb %d BWP Start %d\n",rb_offset,n_rb,pdcch_pdu_rel15->BWPStart); LOG_D(PHY, "Coreset starting subcarrier %d on symbol %d (%d symbols)\n", cset_start_sc, cset_start_symb, cset_nsymb); // DMRS length is per OFDM symbol uint32_t dmrs_length = n_rb*6; //2(QPSK)*3(per RB)*6(REG per CCE) diff --git a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c index 0d32cf2732..c562dfaa41 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dci_tools.c @@ -239,7 +239,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, //uint64_t *dci_pdu = (uint64_t*)pdcch_pdu_rel15->dci_pdu[i].Payload; int dlsch_id = find_nr_dlsch(pdcch_pdu_rel15->dci_pdu[i].RNTI,gNB,SEARCH_EXIST_OR_FREE); - if( (dlsch_id<0) || (dlsch_id>=NUMBER_OF_NR_DLSCH_MAX) ){ + if( (dlsch_id<0) || (dlsch_id>=gNB->number_of_nr_dlsch_max) ){ LOG_E(PHY,"illegal dlsch_id found!!! rnti %04x dlsch_id %d\n",(unsigned int)pdcch_pdu_rel15->dci_pdu[i].RNTI,dlsch_id); return; } @@ -255,10 +255,7 @@ void nr_fill_dci(PHY_VARS_gNB *gNB, dlsch->harq_mask |= (1<rnti = pdcch_pdu_rel15->dci_pdu[i].RNTI; - // nr_fill_cce_list(gNB,0); - - - + // nr_fill_cce_list(gNB,0); } } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c index d06c4bbb1c..b1dbc7c7d9 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch.c @@ -82,7 +82,6 @@ void nr_pdsch_codeword_scrambling_optim(uint8_t *in, s=lte_gold_generic(&x1, &x2, 1); - #if defined(__AVX2__) for (int i=0; i<((size>>5)+((size&0x1f) > 0 ? 1 : 0)); i++) { in32=_mm256_movemask_epi8(_mm256_slli_epi16(((__m256i*)in)[i],7)); @@ -133,7 +132,7 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, time_stats_t *dlsch_interleaving_stats=&gNB->dlsch_interleaving_stats; time_stats_t *dlsch_segmentation_stats=&gNB->dlsch_segmentation_stats; - for (int dlsch_id=0;dlsch_idnumber_of_nr_dlsch_max;dlsch_id++) { dlsch = gNB->dlsch[dlsch_id][0]; if (dlsch->slot_tx[slot] == 0) continue; @@ -160,8 +159,7 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, uint16_t nb_re = ((12*rel15->NrOfSymbols)-nb_re_dmrs*dmrs_len-xOverhead)*rel15->rbSize*rel15->nrOfLayers; uint8_t Qm = rel15->qamModOrder[0]; uint32_t encoded_length = nb_re*Qm; - int16_t mod_dmrs[14][n_dmrs<<1] __attribute__ ((aligned(16))); - + int16_t mod_dmrs[n_dmrs<<1] __attribute__ ((aligned(16))); /* PTRS */ uint16_t beta_ptrs = 1; @@ -266,24 +264,6 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, printf("\n"); } #endif - - /// DMRS QPSK modulation - // TODO: performance improvement, we can skip the modulation of DMRS symbols outside the bandwidth part - for (int l=rel15->StartSymbolIndex; lStartSymbolIndex+rel15->NrOfSymbols; l++) { - if (rel15->dlDmrsSymbPos & (1 << l)) { - nr_modulation(pdsch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs[l]); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated - -#ifdef DEBUG_DLSCH - printf("DMRS modulation (symbol %d, %d symbols, type %d):\n", l, n_dmrs, dmrs_Type); - for (int i=0; i>4; i++) { - for (int j=0; j<8; j++) { - printf("%d %d\t", mod_dmrs[l][((i<<3)+j)<<1], mod_dmrs[l][(((i<<3)+j)<<1)+1]); - } - printf("\n"); - } -#endif - } - } /// Resource mapping @@ -351,6 +331,21 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, } } + /// DMRS QPSK modulation + if (rel15->dlDmrsSymbPos & (1 << l)) { + nr_modulation(pdsch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated + +#ifdef DEBUG_DLSCH + printf("DMRS modulation (symbol %d, %d symbols, type %d):\n", l, n_dmrs, dmrs_Type); + for (int i=0; i>4; i++) { + for (int j=0; j<8; j++) { + printf("%d %d\t", mod_dmrs[((i<<3)+j)<<1], mod_dmrs[(((i<<3)+j)<<1)+1]); + } + printf("\n"); + } +#endif + } + /* calculate if current symbol is PTRS symbols */ ptrs_idx = 0; @@ -381,8 +376,8 @@ uint8_t nr_generate_pdsch(PHY_VARS_gNB *gNB, /* Map DMRS Symbol */ if ( ( dmrs_symbol_map & (1 << l) ) && (k == ((start_sc+get_dmrs_freq_idx(n, k_prime, delta, dmrs_Type))%(frame_parms->ofdm_symbol_size)))) { - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[l][dmrs_idx<<1]) >> 15; - txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[l][(dmrs_idx<<1) + 1]) >> 15; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[dmrs_idx<<1]) >> 15; + txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1 + (2*txdataF_offset)] = (Wt[l_prime]*Wf[k_prime]*amp*mod_dmrs[(dmrs_idx<<1) + 1]) >> 15; #ifdef DEBUG_DLSCH_MAPPING printf("dmrs_idx %d\t l %d \t k %d \t k_prime %d \t n %d \t txdataF: %d %d\n", dmrs_idx, l, k, k_prime, n, txdataF_precoding[ap][((l*frame_parms->ofdm_symbol_size + k)<<1) + (2*txdataF_offset)], @@ -545,6 +540,6 @@ void dump_pdsch_stats(PHY_VARS_gNB *gNB) { void clear_pdsch_stats(PHY_VARS_gNB *gNB) { - for (int i=0;inumber_of_nr_dlsch_max;i++) memset((void*)&gNB->dlsch_stats[i],0,sizeof(gNB->dlsch_stats[i])); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c index 9c832d58e3..77bc8dd132 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_coding.c @@ -44,6 +44,7 @@ #include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/log.h" #include +#include //#define DEBUG_DLSCH_CODING //#define DEBUG_DLSCH_FREE 1 @@ -266,6 +267,8 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN); A = rel15->TBSize[0]<<3; + if ( dlsch->rnti != SI_RNTI ) + trace_NRpdu(DIRECTION_DOWNLINK, a, rel15->TBSize[0], 0, WS_C_RNTI, dlsch->rnti, frame, slot,0, 0); NR_gNB_SCH_STATS_t *stats=NULL; int first_free=-1; @@ -407,7 +410,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, E = nr_get_E(G, harq->C, mod_order, rel15->nrOfLayers, r); //#ifdef DEBUG_DLSCH_CODING - LOG_D(PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n", + LOG_D(NR_PHY,"Rate Matching, Code segment %d/%d (coded bits (G) %u, E %d, Filler bits %d, Filler offset %d mod_order %d, nb_rb %d)...\n", r, harq->C, G, diff --git a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c index 05d6c4c112..543002827d 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c +++ b/openair1/PHY/NR_TRANSPORT/nr_dlsch_tools.c @@ -260,7 +260,7 @@ int16_t find_nr_dlsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type) { int16_t first_free_index=-1; AssertFatal(gNB!=NULL,"gNB is null\n"); - for (i=0; inumber_of_nr_dlsch_max; i++) { AssertFatal(gNB->dlsch[i]!=NULL,"gNB->dlsch[%d] is null\n",i); AssertFatal(gNB->dlsch[i][0]!=NULL,"gNB->dlsch[%d][0] is null\n",i); LOG_D(PHY,"searching for rnti %x : dlsch_index %d=> harq_mask %x, rnti %x, first_free_index %d\n", rnti,i, @@ -286,7 +286,7 @@ void nr_fill_dlsch(PHY_VARS_gNB *gNB, nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &pdsch_pdu->pdsch_pdu_rel15; int dlsch_id = find_nr_dlsch(rel15->rnti,gNB,SEARCH_EXIST); - AssertFatal( (dlsch_id>=0) && (dlsch_id=0) && (dlsch_idnumber_of_nr_dlsch_max), "illegal or no dlsch_id found!!! rnti %04x dlsch_id %d\n",rel15->rnti,dlsch_id); NR_gNB_DLSCH_t *dlsch = gNB->dlsch[dlsch_id][0]; NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index 5e6011c437..994ff18bc8 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -133,15 +133,13 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, @param ue Pointer to PHY variables @param UE_id id of current UE @param frame Frame number - @param nr_tti_rx TTI number - @param symbol Symbol on which to act (within-in nr_TTI_rx) + @param slot Slot number @param harq_pid HARQ process ID */ int nr_rx_pusch(PHY_VARS_gNB *gNB, uint8_t UE_id, uint32_t frame, - uint8_t nr_tti_rx, - unsigned char symbol, + uint8_t slot, unsigned char harq_pid); /** \brief This function performs RB extraction (signal and channel estimates) (currently signal only until channel estimation and compensation are implemented) diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c index e6b709b2aa..53ff90404b 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.c @@ -41,7 +41,7 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type) { int16_t first_free_index=-1; AssertFatal(gNB!=NULL,"gNB is null\n"); - for (i=0; inumber_of_nr_ulsch_max; i++) { AssertFatal(gNB->ulsch[i]!=NULL,"gNB->ulsch[%d] is null\n",i); AssertFatal(gNB->ulsch[i][0]!=NULL,"gNB->ulsch[%d][0] is null\n",i); LOG_D(PHY,"searching for rnti %x : ulsch_index %d=> harq_mask %x, rnti %x, first_free_index %d\n", rnti,i,gNB->ulsch[i][0]->harq_mask,gNB->ulsch[i][0]->rnti,first_free_index); @@ -62,7 +62,7 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB, int ulsch_id = find_nr_ulsch(ulsch_pdu->rnti,gNB,SEARCH_EXIST_OR_FREE); - AssertFatal( (ulsch_id>=0) && (ulsch_id=0) && (ulsch_idnumber_of_nr_ulsch_max), "illegal or no ulsch_id found!!! rnti %04x ulsch_id %d\n",ulsch_pdu->rnti,ulsch_id); NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ulsch_id][0]; @@ -143,16 +143,16 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { char output[16384]; int stroff=0; - for (int i=0;inumber_of_nr_ulsch_max;i++) { if (gNB->ulsch_stats[i].rnti>0) { - for (int aa=0;aaframe_parms.nb_antennas_rx;aa++) - if (aa==0) stroff+=sprintf(output+stroff,"ULSCH RNTI %4x: ulsch_power[%d] %d,%d ulsch_noise_power[%d] %d.%d\n", - gNB->ulsch_stats[i].rnti, + for (int aa=0;aaframe_parms.nb_antennas_rx;aa++) + if (aa==0) stroff+=sprintf(output+stroff,"ULSCH RNTI %4x: ulsch_power[%d] %d,%d ulsch_noise_power[%d] %d.%d\n", + gNB->ulsch_stats[i].rnti, aa,gNB->ulsch_stats[i].power[aa]/10,gNB->ulsch_stats[i].power[aa]%10, aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10); - else stroff+=sprintf(output+stroff," ulsch_power[%d] %d.%d, ulsch_noise_power[%d] %d.%d\n", + else stroff+=sprintf(output+stroff," ulsch_power[%d] %d.%d, ulsch_noise_power[%d] %d.%d\n", aa,gNB->ulsch_stats[i].power[aa]/10,gNB->ulsch_stats[i].power[aa]%10, - gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10); + aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10); AssertFatal(stroff<(STATSTRLEN-1000),"Increase STATSTRLEN\n"); @@ -170,21 +170,21 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { gNB->ulsch_stats[i].current_RI, gNB->ulsch_stats[i].total_bytes_rx, gNB->ulsch_stats[i].total_bytes_tx); - } + } } fprintf(fd,"%s",output); } void clear_pusch_stats(PHY_VARS_gNB *gNB) { - for (int i=0;inumber_of_nr_ulsch_max;i++) memset((void*)&gNB->ulsch_stats[i],0,sizeof(gNB->ulsch_stats[i])); } NR_gNB_SCH_STATS_t *get_ulsch_stats(PHY_VARS_gNB *gNB,NR_gNB_ULSCH_t *ulsch) { NR_gNB_SCH_STATS_t *stats=NULL; int first_free=-1; - for (int i=0;inumber_of_nr_ulsch_max;i++) { if (gNB->ulsch_stats[i].rnti == 0 && first_free == -1) { first_free = i; stats=&gNB->ulsch_stats[i]; diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h index 2ca8e24af1..80c10d74b1 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch.h +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch.h @@ -91,6 +91,7 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB); +void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB); void clear_pusch_stats(PHY_VARS_gNB *gNB); NR_gNB_SCH_STATS_t *get_ulsch_stats(PHY_VARS_gNB *gNB,NR_gNB_ULSCH_t *ulsch); diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c index 032b277030..7a4555d254 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c +++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c @@ -12,6 +12,8 @@ //#define DEBUG_RB_EXT //#define DEBUG_CH_MAG +#define INVALID_VALUE 255 + void nr_idft(int32_t *z, uint32_t Msc_PUSCH) { @@ -1157,12 +1159,11 @@ void nr_ulsch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, int nr_rx_pusch(PHY_VARS_gNB *gNB, uint8_t ulsch_id, uint32_t frame, - uint8_t nr_tti_rx, - unsigned char symbol, + uint8_t slot, unsigned char harq_pid) { - uint8_t aarx, aatx, dmrs_symbol_flag; // dmrs_symbol_flag, a flag to indicate DMRS REs in current symbol + uint8_t aarx, aatx; uint32_t nb_re_pusch, bwp_start_subcarrier; int avgs; int avg[4]; @@ -1170,210 +1171,202 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms; nfapi_nr_pusch_pdu_t *rel15_ul = &gNB->ulsch[ulsch_id][0]->harq_processes[harq_pid]->ulsch_pdu; - dmrs_symbol_flag = 0; - - if(symbol == rel15_ul->start_symbol_index){ - gNB->pusch_vars[ulsch_id]->dmrs_symbol = 0; - gNB->pusch_vars[ulsch_id]->cl_done = 0; - } - + gNB->pusch_vars[ulsch_id]->dmrs_symbol = INVALID_VALUE; + gNB->pusch_vars[ulsch_id]->cl_done = 0; bwp_start_subcarrier = ((rel15_ul->rb_start + rel15_ul->bwp_start)*NR_NB_SC_PER_RB + frame_parms->first_carrier_offset) % frame_parms->ofdm_symbol_size; - - dmrs_symbol_flag = ((rel15_ul->ul_dmrs_symb_pos)>>symbol)&0x01; - - LOG_D(PHY,"symbol %d bwp_start_subcarrier %d, rb_start %d, first_carrier_offset %d\n",symbol,bwp_start_subcarrier,rel15_ul->rb_start,frame_parms->first_carrier_offset); + LOG_D(PHY,"bwp_start_subcarrier %d, rb_start %d, first_carrier_offset %d\n", bwp_start_subcarrier, rel15_ul->rb_start, frame_parms->first_carrier_offset); LOG_D(PHY,"ul_dmrs_symb_pos %x\n",rel15_ul->ul_dmrs_symb_pos); - if (dmrs_symbol_flag == 1){ - if (((rel15_ul->ul_dmrs_symb_pos)>>((symbol+1)%frame_parms->symbols_per_slot))&0x01) - AssertFatal(1==0,"Double DMRS configuration is not yet supported\n"); - - if (rel15_ul->dmrs_config_type == 0) { - // if no data in dmrs cdm group is 1 only even REs have no data - // if no data in dmrs cdm group is 2 both odd and even REs have no data - nb_re_pusch = rel15_ul->rb_size *(12 - (rel15_ul->num_dmrs_cdm_grps_no_data*6)); - } - else { - nb_re_pusch = rel15_ul->rb_size *(12 - (rel15_ul->num_dmrs_cdm_grps_no_data*4)); - } - LOG_D(PHY,"dmrs_symbol: nb_re_pusch %d\n",nb_re_pusch); - gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol; - - } else { - nb_re_pusch = rel15_ul->rb_size * NR_NB_SC_PER_RB; - } - //---------------------------------------------------------- //--------------------- Channel estimation --------------------- //---------------------------------------------------------- start_meas(&gNB->ulsch_channel_estimation_stats); - if (dmrs_symbol_flag == 1) { - nr_pusch_channel_estimation(gNB, - nr_tti_rx, - 0, // p - symbol, - ulsch_id, - bwp_start_subcarrier, - rel15_ul); + for(uint8_t symbol = rel15_ul->start_symbol_index; symbol < (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols); symbol++) { + uint8_t dmrs_symbol_flag = (rel15_ul->ul_dmrs_symb_pos >> symbol) & 0x01; + LOG_D(PHY, "symbol %d, dmrs_symbol_flag :%d\n", symbol, dmrs_symbol_flag); + if (dmrs_symbol_flag == 1) { + if (gNB->pusch_vars[ulsch_id]->dmrs_symbol == INVALID_VALUE) + gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol; - nr_gnb_measurements(gNB, ulsch_id, harq_pid, symbol); - int num_symb = rel15_ul->nr_of_symbols; - for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { - if (symbol == rel15_ul->start_symbol_index) { - gNB->pusch_vars[ulsch_id]->ulsch_power[aarx]=0; - gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx]=0; + nr_pusch_channel_estimation(gNB, + slot, + 0, // p + symbol, + ulsch_id, + bwp_start_subcarrier, + rel15_ul); + + nr_gnb_measurements(gNB, ulsch_id, harq_pid, symbol); + + for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { + if (symbol == rel15_ul->start_symbol_index) { + gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] = 0; + gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx] = 0; + } + gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] += signal_energy_nodc( + &gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aarx][symbol * frame_parms->ofdm_symbol_size], + rel15_ul->rb_size * 12); + for (int rb = 0; rb < rel15_ul->rb_size; rb++) { + gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx] += + gNB->measurements.n0_subband_power[aarx][rel15_ul->bwp_start + rel15_ul->rb_start + rb] / + rel15_ul->rb_size; + } } - gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] += signal_energy_nodc(&gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aarx][symbol*frame_parms->ofdm_symbol_size], - rel15_ul->rb_size*12); - for (int rb=0;rbrb_size;rb++) { - gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx]+=gNB->measurements.n0_subband_power[aarx][rel15_ul->bwp_start+rel15_ul->rb_start+rb]/rel15_ul->rb_size; - } - - } + } } stop_meas(&gNB->ulsch_channel_estimation_stats); - //---------------------------------------------------------- - //--------------------- RBs extraction --------------------- - //---------------------------------------------------------- - gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol] = nb_re_pusch; +#ifdef __AVX2__ + int off = ((rel15_ul->rb_size&1) == 1)? 4:0; +#else + int off = 0; +#endif + uint32_t rxdataF_ext_offset = 0; - if (nb_re_pusch > 0) { + for(uint8_t symbol = rel15_ul->start_symbol_index; symbol < (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols); symbol++) { + uint8_t dmrs_symbol_flag = (rel15_ul->ul_dmrs_symb_pos >> symbol) & 0x01; + if (dmrs_symbol_flag == 1) { + if ((rel15_ul->ul_dmrs_symb_pos >> ((symbol + 1) % frame_parms->symbols_per_slot)) & 0x01) + AssertFatal(1==0,"Double DMRS configuration is not yet supported\n"); - start_meas(&gNB->ulsch_rbs_extraction_stats); - nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF, - gNB->pusch_vars[ulsch_id], - symbol, - dmrs_symbol_flag, - rel15_ul, - frame_parms); - stop_meas(&gNB->ulsch_rbs_extraction_stats); + gNB->pusch_vars[ulsch_id]->dmrs_symbol = symbol; - //---------------------------------------------------------- - //--------------------- Channel Scaling -------------------- - //---------------------------------------------------------- - - nr_ulsch_scale_channel(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, - frame_parms, - gNB->ulsch[ulsch_id], - symbol, - dmrs_symbol_flag, - rel15_ul->rb_size, - rel15_ul->dmrs_config_type); - - - if (gNB->pusch_vars[ulsch_id]->cl_done==0) { - - nr_ulsch_channel_level(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, - frame_parms, - avg, - symbol, - nb_re_pusch, - rel15_ul->rb_size); - - avgs = 0; - - for (aatx=0;aatxnb_antennas_rx;aarx++) - avgs = cmax(avgs,avg[(aatx<<1)+aarx]); - - gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs)/2)+3; - gNB->pusch_vars[ulsch_id]->cl_done = 1; + if (rel15_ul->dmrs_config_type == 0) { + // if no data in dmrs cdm group is 1 only even REs have no data + // if no data in dmrs cdm group is 2 both odd and even REs have no data + nb_re_pusch = rel15_ul->rb_size *(12 - (rel15_ul->num_dmrs_cdm_grps_no_data*6)); + } + else { + nb_re_pusch = rel15_ul->rb_size *(12 - (rel15_ul->num_dmrs_cdm_grps_no_data*4)); + } + } else { + nb_re_pusch = rel15_ul->rb_size * NR_NB_SC_PER_RB; } - //---------------------------------------------------------- - //--------------------- Channel Compensation --------------- - //---------------------------------------------------------- + gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol] = nb_re_pusch; + LOG_D(PHY,"symbol %d: nb_re_pusch %d, DMRS symbl used for Chest :%d \n", symbol, nb_re_pusch, gNB->pusch_vars[ulsch_id]->dmrs_symbol); - start_meas(&gNB->ulsch_channel_compensation_stats); - nr_ulsch_channel_compensation(gNB->pusch_vars[ulsch_id]->rxdataF_ext, - gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, - gNB->pusch_vars[ulsch_id]->ul_ch_mag0, - gNB->pusch_vars[ulsch_id]->ul_ch_magb0, - gNB->pusch_vars[ulsch_id]->rxdataF_comp, - (nb_antennas_ue_tx>1) ? gNB->pusch_vars[ulsch_id]->rho : NULL, - frame_parms, + //---------------------------------------------------------- + //--------------------- RBs extraction --------------------- + //---------------------------------------------------------- + if (nb_re_pusch > 0) { + + start_meas(&gNB->ulsch_rbs_extraction_stats); + nr_ulsch_extract_rbs_single(gNB->common_vars.rxdataF, + gNB->pusch_vars[ulsch_id], symbol, dmrs_symbol_flag, - rel15_ul->qam_mod_order, - rel15_ul->rb_size, - gNB->pusch_vars[ulsch_id]->log2_maxh); - stop_meas(&gNB->ulsch_channel_compensation_stats); + rel15_ul, + frame_parms); + stop_meas(&gNB->ulsch_rbs_extraction_stats); - start_meas(&gNB->ulsch_mrc_stats); - nr_ulsch_detection_mrc(frame_parms, - gNB->pusch_vars[ulsch_id]->rxdataF_comp, - gNB->pusch_vars[ulsch_id]->ul_ch_mag, - gNB->pusch_vars[ulsch_id]->ul_ch_magb, - symbol, - rel15_ul->rb_size); - stop_meas(&gNB->ulsch_mrc_stats); + //---------------------------------------------------------- + //--------------------- Channel Scaling -------------------- + //---------------------------------------------------------- + nr_ulsch_scale_channel(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, + frame_parms, + gNB->ulsch[ulsch_id], + symbol, + dmrs_symbol_flag, + rel15_ul->rb_size, + rel15_ul->dmrs_config_type); + if (gNB->pusch_vars[ulsch_id]->cl_done==0) { + nr_ulsch_channel_level(gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, + frame_parms, + avg, + symbol, + nb_re_pusch, + rel15_ul->rb_size); + + avgs = 0; + + for (aatx=0;aatxnb_antennas_rx;aarx++) + avgs = cmax(avgs,avg[(aatx<<1)+aarx]); + + gNB->pusch_vars[ulsch_id]->log2_maxh = (log2_approx(avgs)/2)+3; + gNB->pusch_vars[ulsch_id]->cl_done = 1; + } + + //---------------------------------------------------------- + //--------------------- Channel Compensation --------------- + //---------------------------------------------------------- + start_meas(&gNB->ulsch_channel_compensation_stats); + nr_ulsch_channel_compensation(gNB->pusch_vars[ulsch_id]->rxdataF_ext, + gNB->pusch_vars[ulsch_id]->ul_ch_estimates_ext, + gNB->pusch_vars[ulsch_id]->ul_ch_mag0, + gNB->pusch_vars[ulsch_id]->ul_ch_magb0, + gNB->pusch_vars[ulsch_id]->rxdataF_comp, + (nb_antennas_ue_tx>1) ? gNB->pusch_vars[ulsch_id]->rho : NULL, + frame_parms, + symbol, + dmrs_symbol_flag, + rel15_ul->qam_mod_order, + rel15_ul->rb_size, + gNB->pusch_vars[ulsch_id]->log2_maxh); + stop_meas(&gNB->ulsch_channel_compensation_stats); + + start_meas(&gNB->ulsch_mrc_stats); + nr_ulsch_detection_mrc(frame_parms, + gNB->pusch_vars[ulsch_id]->rxdataF_comp, + gNB->pusch_vars[ulsch_id]->ul_ch_mag, + gNB->pusch_vars[ulsch_id]->ul_ch_magb, + symbol, + rel15_ul->rb_size); + stop_meas(&gNB->ulsch_mrc_stats); + + if (rel15_ul->transform_precoding == transform_precoder_enabled) { - if (rel15_ul->transform_precoding == transform_precoder_enabled) { - #ifdef __AVX2__ // For odd number of resource blocks need byte alignment to multiple of 8 int nb_re_pusch2 = nb_re_pusch + (nb_re_pusch&7); #else int nb_re_pusch2 = nb_re_pusch; - #endif - - // perform IDFT operation on the compensated rxdata if transform precoding is enabled - nr_idft(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][symbol * nb_re_pusch2], nb_re_pusch); - LOG_D(PHY,"Transform precoding being done on data- symbol: %d, nb_re_pusch: %d\n", symbol, nb_re_pusch); - } + #endif + // perform IDFT operation on the compensated rxdata if transform precoding is enabled + nr_idft(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][symbol * nb_re_pusch2], nb_re_pusch); + LOG_D(PHY,"Transform precoding being done on data- symbol: %d, nb_re_pusch: %d\n", symbol, nb_re_pusch); + } - //---------------------------------------------------------- - //--------------------- PTRS Processing -------------------- - //---------------------------------------------------------- + //---------------------------------------------------------- + //--------------------- PTRS Processing -------------------- + //---------------------------------------------------------- + /* In case PTRS is enabled then LLR will be calculated after PTRS symbols are processed * + * otherwise LLR are calculated for each symbol based upon DMRS channel estimates only. */ + if (rel15_ul->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) { + start_meas(&gNB->ulsch_ptrs_processing_stats); + nr_pusch_ptrs_processing(gNB, + frame_parms, + rel15_ul, + ulsch_id, + slot, + symbol, + nb_re_pusch); + stop_meas(&gNB->ulsch_ptrs_processing_stats); - /* In case PTRS is enabled then LLR will be calculated after PTRS symbols are processed * - * otherwise LLR are calculated for each symbol based upon DMRS channel estimates only. */ - if (rel15_ul->pdu_bit_map & PUSCH_PDU_BITMAP_PUSCH_PTRS) - { - start_meas(&gNB->ulsch_ptrs_processing_stats); - nr_pusch_ptrs_processing(gNB, - frame_parms, - rel15_ul, - ulsch_id, - nr_tti_rx, - symbol, - nb_re_pusch); - stop_meas(&gNB->ulsch_ptrs_processing_stats); + /* Subtract total PTRS RE's in the symbol from PUSCH RE's */ + gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol] -= gNB->pusch_vars[ulsch_id]->ptrs_re_per_slot; + } - /* Subtract total PTRS RE's in the symbol from PUSCH RE's */ - gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol] -= gNB->pusch_vars[ulsch_id]->ptrs_re_per_slot; - } - } - - /*---------------------------------------------------------------------------------------------------- */ - /*-------------------- LLRs computation -------------------------------------------------------------*/ - /*-----------------------------------------------------------------------------------------------------*/ - if(symbol == (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols -1)) { - -#ifdef __AVX2__ - int off = ((rel15_ul->rb_size&1) == 1)? 4:0; -#else - int off = 0; -#endif - uint32_t rxdataF_ext_offset = 0; - for(uint8_t i =rel15_ul->start_symbol_index; i< (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols);i++) { + /*---------------------------------------------------------------------------------------------------- */ + /*-------------------- LLRs computation -------------------------------------------------------------*/ + /*-----------------------------------------------------------------------------------------------------*/ start_meas(&gNB->ulsch_llr_stats); - nr_ulsch_compute_llr(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][i * (off + rel15_ul->rb_size * NR_NB_SC_PER_RB)], - gNB->pusch_vars[ulsch_id]->ul_ch_mag0, - gNB->pusch_vars[ulsch_id]->ul_ch_magb0, - &gNB->pusch_vars[ulsch_id]->llr[rxdataF_ext_offset * rel15_ul->qam_mod_order], - rel15_ul->rb_size, - gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[i], - i, - rel15_ul->qam_mod_order); + nr_ulsch_compute_llr(&gNB->pusch_vars[ulsch_id]->rxdataF_comp[0][symbol * (off + rel15_ul->rb_size * NR_NB_SC_PER_RB)], + gNB->pusch_vars[ulsch_id]->ul_ch_mag0, + gNB->pusch_vars[ulsch_id]->ul_ch_magb0, + &gNB->pusch_vars[ulsch_id]->llr[rxdataF_ext_offset * rel15_ul->qam_mod_order], + rel15_ul->rb_size, + gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol], + symbol, + rel15_ul->qam_mod_order); stop_meas(&gNB->ulsch_llr_stats); - rxdataF_ext_offset += gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[i]; - }// symbol loop - }// last symbol check - - return (0); + rxdataF_ext_offset += gNB->pusch_vars[ulsch_id]->ul_valid_re_per_slot[symbol]; + } + } // symbol loop + + return 0; } diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 7e2ec05b7f..2b5343aa60 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -174,15 +174,14 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, pucch_GroupHopping_t pucch_GroupHopping = pucch_pdu->group_hop_flag + (pucch_pdu->sequence_hop_flag<<1); - AssertFatal(pucch_pdu->bit_len_harq > 0 || pucch_pdu->sr_flag > 0, "Either bit_len_harq (%d) or sr_flag (%d) must be > 0\n", pucch_pdu->bit_len_harq,pucch_pdu->sr_flag); NR_gNB_UCI_STATS_t *uci_stats=NULL; NR_gNB_UCI_STATS_t *first_uci_stats=NULL; - for (int i=0;iuci_stats[i].rnti == pucch_pdu->rnti) { + for (int i=0;iuci_stats[i].rnti == pucch_pdu->rnti) { uci_stats = &gNB->uci_stats[i]; break; } else if (first_uci_stats == NULL && gNB->uci_stats[i].rnti == 0) first_uci_stats = &gNB->uci_stats[i]; @@ -205,7 +204,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, nr_sequences=8>>(1-pucch_pdu->sr_flag); } - LOG_D(PHY,"pucch0: nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, O_ACK %d, O_SR %d, mcs %d\n",pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,mcs[0]); + LOG_D(PHY,"pucch0: nr_symbols %d, start_symbol %d, prb_start %d, second_hop_prb %d, group_hop_flag %d, sequence_hop_flag %d, O_ACK %d, O_SR %d, mcs %d\n",pucch_pdu->nr_of_symbols,pucch_pdu->start_symbol_index,pucch_pdu->prb_start,pucch_pdu->second_hop_prb,pucch_pdu->group_hop_flag,pucch_pdu->sequence_hop_flag,pucch_pdu->bit_len_harq,pucch_pdu->sr_flag,mcs[0]); int cs_ind = get_pucch0_cs_lut_index(gNB,pucch_pdu); /* @@ -271,7 +270,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, for (l=0; lnr_of_symbols; l++) { l2 = l+pucch_pdu->start_symbol_index; re_offset[l] = (12*prb_offset[l]) + frame_parms->first_carrier_offset; - if (re_offset[l]>= frame_parms->ofdm_symbol_size) + if (re_offset[l]>= frame_parms->ofdm_symbol_size) re_offset[l]-=frame_parms->ofdm_symbol_size; AssertFatal(re_offset[l]+12 < frame_parms->ofdm_symbol_size,"pucch straddles DC carrier, handle this!\n"); @@ -287,12 +286,18 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, #endif } } - int32_t corr_re[2],corr_im[2],no_corr=0; + + int32_t corr_re[2]; + int32_t corr_im[2]; + //int32_t no_corr = 0; int seq_index; - int64_t temp,av_corr=0; + int64_t temp; + int64_t av_corr=0; + for(i=0;inr_of_symbols;l++) { - corr_re[l]=0;corr_im[l]=0; + corr_re[l]=0; + corr_im[l]=0; seq_index = (pucch_pdu->initial_cyclic_shift+ mcs[i]+ gNB->pucch0_lut.lut[cs_ind][slot][l+pucch_pdu->start_symbol_index])%12; @@ -331,8 +336,7 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, if (l==2) uci_stats->current_pucch0_stat1 = dB_fixed64((int64_t)corr_re[1]*corr_re[1] + (int64_t)corr_im[1]*corr_im[1]); } } - if(nr_sequences>1) - no_corr=(av_corr-xrtmag)/(nr_sequences-1)/l; + av_corr/=nr_sequences/l; uint8_t xrtmag_dB = dB_fixed64(xrtmag); @@ -343,7 +347,6 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, index=maxpos; - // estimate CQI for MAC (from antenna port 0 only) int max_n0 = uci_stats->pucch0_n00>uci_stats->pucch0_n01 ? uci_stats->pucch0_n00:uci_stats->pucch0_n01; int SNRtimes10 = dB_fixed_times10(signal_energy_nodc(&rxdataF[0][pucch_pdu->start_symbol_index*frame_parms->ofdm_symbol_size+re_offset[0]],12)) - (10*max_n0); @@ -352,12 +355,13 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, else if (SNRtimes10 > 635) cqi=255; else cqi=(640+SNRtimes10)/5; - uci_stats->pucch0_thres = gNB->pucch0_thres + (10*max_n0); + uci_stats->pucch0_thres = gNB->pucch0_thres + (10*max_n0); bool no_conf=false; if (nr_sequences>1) { - if (10*xrtmag_dB < uci_stats->pucch0_thres) + if (10*xrtmag_dB < uci_stats->pucch0_thres) no_conf=true; } + gNB->bad_pucch += no_conf; // first bit of bitmap for sr presence and second bit for acknack presence uci_pdu->pduBitmap = pucch_pdu->sr_flag | ((pucch_pdu->bit_len_harq>0)<<1); uci_pdu->pucch_format = 0; // format 0 @@ -395,7 +399,6 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, uci_stats->pucch0_positive_SR++; } uci_stats->pucch01_trials++; - } else { uci_pdu->harq = calloc(1,sizeof(*uci_pdu->harq)); @@ -1596,7 +1599,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, if (pucch_pdu->bit_len_harq>0) { int harq_bytes=pucch_pdu->bit_len_harq>>3; if ((pucch_pdu->bit_len_harq&7) > 0) harq_bytes++; - uci_pdu->pduBitmap|=1; + uci_pdu->pduBitmap|=2; uci_pdu->harq.harq_payload = (uint8_t*)malloc(harq_bytes); uci_pdu->harq.harq_crc = decoderState; int i=0; @@ -1610,7 +1613,7 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, } if (pucch_pdu->sr_flag == 1) { - uci_pdu->pduBitmap|=2; + uci_pdu->pduBitmap|=1; uci_pdu->sr.sr_bit_len = 1; uci_pdu->sr.sr_payload = malloc(1); uci_pdu->sr.sr_payload[0] = decodedPayload[0]&1; @@ -1638,9 +1641,8 @@ void nr_decode_pucch2(PHY_VARS_gNB *gNB, uci_pdu->pduBitmap|=8; } } - -void dump_uci_stats(FILE *fd,PHY_VARS_gNB *gNB,int frame) { +void nr_dump_uci_stats(FILE *fd,PHY_VARS_gNB *gNB,int frame) { int strpos=0; char output[16384]; @@ -1654,12 +1656,12 @@ void dump_uci_stats(FILE *fd,PHY_VARS_gNB *gNB,int frame) { if (uci_stats->pucch01_trials > 0) strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch01_trials %d, pucch0_n00 %d dB, pucch0_n01 %d dB, pucch0_thres %d dB, current pucch0_stat0 %d dB, current pucch1_stat1 %d dB, pucch01_DTX %d\n", i,uci_stats->rnti,uci_stats->pucch01_trials,uci_stats->pucch0_n01,uci_stats->pucch0_n01,uci_stats->pucch0_thres,dB_fixed(uci_stats->current_pucch0_stat0),dB_fixed(uci_stats->current_pucch0_stat1),uci_stats->pucch01_DTX); - + if (uci_stats->pucch02_trials > 0) strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch01_trials %d, pucch0_n00 %d dB, pucch0_n01 %d dB, pucch0_thres %d dB, current pucch0_stat0 %d dB, current pucch0_stat1 %d dB, pucch01_DTX %d\n", i,uci_stats->rnti,uci_stats->pucch02_trials,uci_stats->pucch0_n00,uci_stats->pucch0_n01,uci_stats->pucch0_thres,dB_fixed(uci_stats->current_pucch0_stat0),dB_fixed(uci_stats->current_pucch0_stat1),uci_stats->pucch02_DTX); - if (uci_stats->pucch2_trials > 0) + if (uci_stats->pucch2_trials > 0) strpos+=sprintf(output+strpos,"UCI %d RNTI %x: pucch2_trials %d, pucch2_DTX %d\n", i,uci_stats->rnti, uci_stats->pucch2_trials, @@ -1667,5 +1669,5 @@ void dump_uci_stats(FILE *fd,PHY_VARS_gNB *gNB,int frame) { } } if (fd) fprintf(fd,"%s",output); - else printf("%s",output); + else printf("%s",output); } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index 0318ed6478..a2f824e468 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -105,7 +105,7 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, { first_time = 0; ue->time_sync_cell = 1; - if (get_softmodem_params()->do_ra) { + if (get_softmodem_params()->do_ra || get_softmodem_params()->sa) { LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id); //mac_resynch(); //dl_phy_sync_success(ue->Mod_id,frame,0,1);//ue->common_vars.eNb_id); diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c index 3f52b29281..44f1844ae9 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_ue_measurements.c @@ -180,11 +180,11 @@ void nr_ue_measurements(PHY_VARS_NR_UE *ue, ue->measurements.wideband_cqi_avg[gNB_id] = dB_fixed2(ue->measurements.rx_power_avg[gNB_id], ue->measurements.n0_power_avg); ue->measurements.rx_rssi_dBm[gNB_id] = ue->measurements.rx_power_avg_dB[gNB_id] + 30 - 10*log10(pow(2, 30)) - ((int)openair0_cfg[0].rx_gain[0] - (int)openair0_cfg[0].rx_gain_offset[0]) - dB_fixed(ue->frame_parms.ofdm_symbol_size); - LOG_I(PHY, "[gNB %d] Slot %d, RSSI %d dBm/RE, RSSI (digital) %d dB, WBandCQI %d dB, rxPwrAvg %d, n0PwrAvg %d \n", + LOG_D(PHY, "[gNB %d] Slot %d, RSSI %d dB (%d dBm/RE), WBandCQI %d dB, rxPwrAvg %d, n0PwrAvg %d\n", gNB_id, slot, - ue->measurements.rx_rssi_dBm[gNB_id], ue->measurements.rx_power_avg_dB[gNB_id], + ue->measurements.rx_rssi_dBm[gNB_id], ue->measurements.wideband_cqi_avg[gNB_id], ue->measurements.rx_power_avg[gNB_id], ue->measurements.n0_power_tot); diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c index 24be04d665..fc7897b46a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_nr.c @@ -889,6 +889,33 @@ void nr_pdcch_unscrambling(int16_t *z, #ifdef NR_PDCCH_DCI_RUN +/* This function compares the received DCI bits with + * re-encoded DCI bits and returns the number of mismatched bits + */ +uint16_t nr_dci_false_detection(uint64_t *dci, + int16_t *soft_in, + const t_nrPolar_params *polar_param, + int encoded_length, + int rnti) { + + uint32_t encoder_output[NR_MAX_DCI_SIZE_DWORD]; + polar_encoder_fast(dci, (void*)encoder_output, rnti, 1, (t_nrPolar_params *)polar_param); + uint8_t *enout_p = (uint8_t*)encoder_output; + uint16_t x = 0; + + for (int i=0; i> 15 ) & 1); + x += ( ( enout_p[i] >> 1 ) & 1 ) ^ ( ( soft_in[i*8+1] >> 15 ) & 1 ); + x += ( ( enout_p[i] >> 2 ) & 1 ) ^ ( ( soft_in[i*8+2] >> 15 ) & 1 ); + x += ( ( enout_p[i] >> 3 ) & 1 ) ^ ( ( soft_in[i*8+3] >> 15 ) & 1 ); + x += ( ( enout_p[i] >> 4 ) & 1 ) ^ ( ( soft_in[i*8+4] >> 15 ) & 1 ); + x += ( ( enout_p[i] >> 5 ) & 1 ) ^ ( ( soft_in[i*8+5] >> 15 ) & 1 ); + x += ( ( enout_p[i] >> 6 ) & 1 ) ^ ( ( soft_in[i*8+6] >> 15 ) & 1 ); + x += ( ( enout_p[i] >> 7 ) & 1 ) ^ ( ( soft_in[i*8+7] >> 15 ) & 1 ); + } + return x; +} + uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, fapi_nr_dci_indication_t *dci_ind, @@ -931,17 +958,25 @@ uint8_t nr_dci_decoding_procedure(PHY_VARS_NR_UE *ue, n_rnti = rel15->rnti; if (crc == n_rnti) { - LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", + LOG_D(PHY, "(%i.%i) Received dci indication (rnti %x,dci format %s,n_CCE %d,payloadSize %d,payload %llx)\n", proc->frame_rx, proc->nr_slot_rx,n_rnti,nr_dci_format_string[rel15->dci_format_options[k]],CCEind,dci_length,*(unsigned long long*)dci_estimation); - dci_ind->SFN = proc->frame_rx; - dci_ind->slot = proc->nr_slot_rx; - dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; - dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; - dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; - dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; - memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); - dci_ind->number_of_dcis++; - break; // If DCI is found, no need to check for remaining DCI lengths + uint16_t mb = nr_dci_false_detection(dci_estimation,tmp_e,currentPtrDCI,L*108,n_rnti); + ue->dci_thres = (ue->dci_thres + mb) / 2; + if (mb > (ue->dci_thres+20)) { + LOG_W(PHY,"DCI false positive. Dropping DCI index %d. Mismatched bits: %d/%d. Current DCI threshold: %d\n",j,mb,L*108,ue->dci_thres); + continue; + } + else { + dci_ind->SFN = proc->frame_rx; + dci_ind->slot = proc->nr_slot_rx; + dci_ind->dci_list[dci_ind->number_of_dcis].rnti = n_rnti; + dci_ind->dci_list[dci_ind->number_of_dcis].n_CCE = CCEind; + dci_ind->dci_list[dci_ind->number_of_dcis].dci_format = rel15->dci_format_options[k]; + dci_ind->dci_list[dci_ind->number_of_dcis].payloadSize = dci_length; + memcpy((void*)dci_ind->dci_list[dci_ind->number_of_dcis].payloadBits,(void*)dci_estimation,8); + dci_ind->number_of_dcis++; + break; // If DCI is found, no need to check for remaining DCI lengths + } } else { LOG_D(PHY,"(%i.%i) Decoded crc %x does not match rnti %x for DCI format %d\n", proc->frame_rx, proc->nr_slot_rx, crc, n_rnti, rel15->dci_format_options[k]); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c index 58eb071346..6ccf8ee85b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_decoding.c @@ -588,10 +588,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ret = no_iteration_ldpc; } else { - LOG_D(PHY,"CRC NOT OK\n\033[0m"); /* - ret = 1 + dlsch->max_ldpc_iterations; - dump_nrdlsch(phy_vars_ue,0,nr_slot_rx,&E,0,0); - exit(-1);*/ + LOG_D(PHY,"CRC NOT OK\n\033[0m"); } @@ -705,7 +702,6 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_DLSCH_COMBINE_SEG, VCD_FUNCTION_OUT); dlsch->last_iteration_cnt = ret; - // log_dump(PHY, harq_process->b, 60, LOG_DUMP_CHAR,"nrue pdsch rx frame %d %d: ", frame, nr_slot_rx ); return(ret); } diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c index 7c2db4f3c0..0cdc24f98a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_dlsch_demodulation.c @@ -3368,97 +3368,6 @@ static int nr_dlsch_llr(NR_UE_PDSCH **pdsch_vars, //============================================================================================== -void dump_nrdlsch(PHY_VARS_NR_UE *ue,uint8_t gNB_id,uint8_t nr_slot_rx,unsigned int *coded_bits_per_codeword,int round, unsigned char harq_pid) -{ - unsigned int nsymb = (ue->frame_parms.Ncp == 0) ? 14 : 12; - char fname[32],vname[32]; - int N_RB_DL=ue->frame_parms.N_RB_DL; - - snprintf(fname, 32, "dlsch%d_rxF_r%d_ext0.m", gNB_id, round); - snprintf(vname, 32, "dl%d_rxF_r%d_ext0", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->rxdataF_ext[0],12*N_RB_DL*nsymb,1,1); - - if (ue->frame_parms.nb_antennas_rx >1) { - snprintf(fname, 32, "dlsch%d_rxF_r%d_ext1.m", gNB_id, round); - snprintf(vname, 32, "dl%d_rxF_r%d_ext1", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->rxdataF_ext[1],12*N_RB_DL*nsymb,1,1); - } - - snprintf(fname, 32, "dlsch%d_ch_r%d_ext00.m", gNB_id, round); - snprintf(vname, 32, "dl%d_ch_r%d_ext00", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1); - - if (ue->transmission_mode[gNB_id]==7){ - snprintf(fname, 32, "dlsch%d_bf_ch_r%d.m", gNB_id, round); - snprintf(vname, 32, "dl%d_bf_ch_r%d", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_bf_ch_estimates[0],512*nsymb,1,1); - //write_output(fname,vname,phy_vars_ue->lte_ue_pdsch_vars[gNB_id]->dl_bf_ch_estimates[0],512,1,1); - - snprintf(fname, 32, "dlsch%d_bf_ch_r%d_ext00.m", gNB_id, round); - snprintf(vname, 32, "dl%d_bf_ch_r%d_ext00", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_bf_ch_estimates_ext[0],12*N_RB_DL*nsymb,1,1); - } - - if (ue->frame_parms.nb_antennas_rx == 2) { - snprintf(fname, 32, "dlsch%d_ch_r%d_ext01.m", gNB_id, round); - snprintf(vname, 32, "dl%d_ch_r%d_ext01", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb,1,1); - } - - if (ue->frame_parms.nb_antenna_ports_gNB == 2) { - snprintf(fname, 32, "dlsch%d_ch_r%d_ext10.m", gNB_id, round); - snprintf(vname, 32, "dl%d_ch_r%d_ext10", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1); - - if (ue->frame_parms.nb_antennas_rx == 2) { - snprintf(fname, 32, "dlsch%d_ch_r%d_ext11.m",gNB_id,round); - snprintf(vname, 32, "dl%d_ch_r%d_ext11",gNB_id,round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1); - } - } - - snprintf(fname, 32, "dlsch%d_rxF_r%d_uespec0.m", gNB_id, round); - snprintf(vname, 32, "dl%d_rxF_r%d_uespec0", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->rxdataF_uespec_pilots[0],12*N_RB_DL,1,1); - - /* - write_output("dlsch%d_ch_ext01.m","dl01_ch0_ext",pdsch_vars[gNB_id]->dl_ch_estimates_ext[1],12*N_RB_DL*nsymb,1,1); - write_output("dlsch%d_ch_ext10.m","dl10_ch0_ext",pdsch_vars[gNB_id]->dl_ch_estimates_ext[2],12*N_RB_DL*nsymb,1,1); - write_output("dlsch%d_ch_ext11.m","dl11_ch0_ext",pdsch_vars[gNB_id]->dl_ch_estimates_ext[3],12*N_RB_DL*nsymb,1,1); - */ - snprintf(fname, 32, "dlsch%d_r%d_rho.m", gNB_id, round); - snprintf(vname, 32, "dl_rho_r%d_%d", gNB_id, round); - - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_ch_rho_ext[harq_pid][round][0],12*N_RB_DL*nsymb,1,1); - - snprintf(fname, 32, "dlsch%d_r%d_rho2.m", gNB_id, round); - snprintf(vname, 32, "dl_rho2_r%d_%d", gNB_id, round); - - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->dl_ch_rho2_ext[0],12*N_RB_DL*nsymb,1,1); - - snprintf(fname, 32, "dlsch%d_rxF_r%d_comp0.m", gNB_id, round); - snprintf(vname, 32, "dl%d_rxF_r%d_comp0", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->rxdataF_comp0[0],12*N_RB_DL*nsymb,1,1); - if (ue->frame_parms.nb_antenna_ports_gNB == 2) { - snprintf(fname, 32, "dlsch%d_rxF_r%d_comp1.m", gNB_id, round); - snprintf(vname, 32, "dl%d_rxF_r%d_comp1", gNB_id, round); - write_output(fname,vname,ue->pdsch_vars[0][gNB_id]->rxdataF_comp1[harq_pid][round][0],12*N_RB_DL*nsymb,1,1); - } - - snprintf(fname, 32, "dlsch%d_rxF_r%d_llr.m", gNB_id, round); - snprintf(vname, 32, "dl%d_r%d_llr", gNB_id, round); - write_output(fname, vname, ue->pdsch_vars[0][gNB_id]->llr[0], coded_bits_per_codeword[0], 1, 0); - snprintf(fname, 32, "dlsch%d_r%d_mag1.m", gNB_id, round); - snprintf(vname, 32, "dl%d_r%d_mag1", gNB_id, round); - write_output(fname, vname, ue->pdsch_vars[0][gNB_id]->dl_ch_mag0[0], 12*N_RB_DL*nsymb, 1, 1); - snprintf(fname, 32, "dlsch%d_r%d_mag2.m", gNB_id, round); - snprintf(vname, 32, "dl%d_r%d_mag2", gNB_id, round); - write_output(fname, vname, ue->pdsch_vars[0][gNB_id]->dl_ch_magb0[0], 12*N_RB_DL*nsymb, 1, 1); - - // printf("log2_maxh = %d\n",ue->pdsch_vars[gNB_id]->log2_maxh); -} - - #ifdef DEBUG_DLSCH_DEMOD /* void print_bytes(char *s,__m128i *x) diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c index c73d2356a0..f24777b61a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_initial_sync.c @@ -311,12 +311,15 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, // every 7*(1<symbol_offset/(7*(1<ofdm_symbol_size + fp->nb_prefix_samples0)+(ue->symbol_offset-n_symb_prefix0)*(fp->ofdm_symbol_size + fp->nb_prefix_samples); - if (ue->ssb_offset < sync_pos_frame) + // for a correct computation of frame number to sync with the one decoded at MIB we need to take into account in which of the n_frames we got sync + ue->init_sync_frame = n_frames - 1 - is; + // we also need to take into account the shift by samples_per_frame in case the if is true + if (ue->ssb_offset < sync_pos_frame){ ue->rx_offset = fp->samples_per_frame - sync_pos_frame + ue->ssb_offset; + ue->init_sync_frame += 1; + } else ue->rx_offset = ue->ssb_offset - sync_pos_frame; - - ue->init_sync_frame = is; } /* diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index c8ee94f510..f0e6e9984b 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -589,7 +589,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, frame_parms->ssb_index += (((nr_ue_pbch_vars->xtra_byte>>(7-i))&0x01)<<(3+i)); } - ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms,i_ssb); + ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms,frame_parms->ssb_index); if (frame_parms->half_frame_bit) ue->symbol_offset += (frame_parms->slots_per_frame>>1)*frame_parms->symbols_per_slot; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c index 12ac8ced47..e7cf3c15a9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_prach.c @@ -66,7 +66,7 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ uint8_t Mod_id, fd_occasion, preamble_index, restricted_set, not_found; uint16_t rootSequenceIndex, prach_fmt_id, NCS, *prach_root_sequence_map, preamble_offset = 0; - uint16_t preamble_shift = 0, preamble_index0, n_shift_ra, n_shift_ra_bar, d_start, numshift, N_ZC, u, offset, offset2, first_nonzero_root_idx; + uint16_t preamble_shift = 0, preamble_index0, n_shift_ra, n_shift_ra_bar, d_start=INT16_MAX, numshift, N_ZC, u, offset, offset2, first_nonzero_root_idx; int16_t prach_tmp[98304*2*4] __attribute__((aligned(32))); int16_t Ncp = 0, amp, *prach, *prach2, *prachF, *Xu; @@ -74,6 +74,10 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ int prach_start, prach_sequence_length, i, prach_len, dftlen, mu, kbar, K, n_ra_prb, k, prachStartSymbol, sample_offset_slot; //int restricted_Type; + fd_occasion = 0; + prach_len = 0; + dftlen = 0; + first_nonzero_root_idx = 0; prach = prach_tmp; prachF = ue->prach_vars[gNB_id]->prachF; amp = ue->prach_vars[gNB_id]->amp; @@ -87,10 +91,6 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ NCS = prach_pdu->num_cs; prach_fmt_id = prach_pdu->prach_format; preamble_index = prach_resources->ra_PreambleIndex; - fd_occasion = 0; - prach_len = 0; - dftlen = 0; - first_nonzero_root_idx = 0; kbar = 1; K = 24; k = 12*n_ra_prb - 6*fp->N_RB_UL; @@ -218,12 +218,12 @@ int32_t generate_nr_prach(PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint8_t slot){ k *= 2; LOG_I(PHY, "PRACH [UE %d] in slot %d, placing PRACH in position %d, msg1 frequency start %d (k1 %d), preamble_offset %d, first_nonzero_root_idx %d\n", Mod_id, - slot, - k, - n_ra_prb, - nrUE_config->prach_config.num_prach_fd_occasions_list[fd_occasion].k1, - preamble_offset, - first_nonzero_root_idx); + slot, + k, + n_ra_prb, + nrUE_config->prach_config.num_prach_fd_occasions_list[fd_occasion].k1, + preamble_offset, + first_nonzero_root_idx); Xu = (int16_t*)ue->X_u[preamble_offset-first_nonzero_root_idx]; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index aa32ecc8c9..f3cca9e33d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -38,10 +38,10 @@ //#include "PHY/defs_nr_UE.h" #include "../NR_TRANSPORT/nr_transport_common_proto.h" -#ifndef STANDALONE_COMPILE +/*#ifndef STANDALONE_COMPILE #include "UTIL/LISTS/list.h" #endif - +*/ #include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h" diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c index 76fc5f298f..6cf782d9d8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ue_rf_helpers.c @@ -31,13 +31,15 @@ #include "PHY/defs_nr_UE.h" #include "PHY/phy_extern_nr_ue.h" #include "nr_transport_proto_ue.h" +#include "executables/softmodem-common.h" void nr_get_carrier_frequencies(NR_DL_FRAME_PARMS *fp, uint64_t *dl_carrier, uint64_t *ul_carrier){ - if (downlink_frequency[0][0]) - *dl_carrier = downlink_frequency[0][0]; - else + if (get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra==1 || !downlink_frequency[0][0]) { *dl_carrier = fp->dl_CarrierFreq; + } else { + *dl_carrier = downlink_frequency[0][0]; + } if (uplink_frequency_offset[0][0]) *ul_carrier = *dl_carrier + uplink_frequency_offset[0][0]; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c index 1adc81d556..5733ef6eb3 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_coding.c @@ -40,6 +40,7 @@ #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "common/utils/LOG/vcd_signal_dumper.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" +#include //#define DEBUG_ULSCH_CODING @@ -256,7 +257,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, Ilbrm = 0; Tbslbrm = 950984; //max tbs Coderate = 0.0; - + trace_NRpdu(DIRECTION_UPLINK, harq_process->a, harq_process->pusch_pdu.pusch_data.tb_size, 0, WS_C_RNTI, 0, 0, 0,0, 0); /////////// ///////////////////////////////////////////////////////////////////////////////////////// @@ -264,13 +265,15 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, LOG_D(PHY,"ulsch coding nb_rb %d, Nl = %d\n", nb_rb, harq_process->pusch_pdu.nrOfLayers); LOG_D(PHY,"ulsch coding A %d G %d mod_order %d\n", A,G, mod_order); - LOG_D(PHY,"harq_pid %d harq_process->ndi %d, pusch_data.new_data_indicator %d\n",harq_pid,harq_process->ndi,harq_process->pusch_pdu.pusch_data.new_data_indicator); + LOG_D(PHY,"harq_pid %d harq_process->ndi %d, pusch_data.new_data_indicator %d\n", + harq_pid,harq_process->ndi,harq_process->pusch_pdu.pusch_data.new_data_indicator); + if (harq_process->first_tx == 1 || harq_process->ndi != harq_process->pusch_pdu.pusch_data.new_data_indicator) { // this is a new packet #ifdef DEBUG_ULSCH_CODING printf("encoding thinks this is a new packet \n"); #endif - harq_process->first_tx=0; + harq_process->first_tx = 0; ///////////////////////// a---->| add CRC |---->b ///////////////////////// /////////// /* @@ -413,7 +416,7 @@ int nr_ulsch_encoding(NR_UE_ULSCH_t *ulsch, /////////// /////////////////////////////////////////////////////////////////////////////// - LOG_D(PHY,"setting ndi to %d from pusch_data\n",harq_process->pusch_pdu.pusch_data.new_data_indicator); + LOG_D(PHY,"setting ndi to %d from pusch_data\n", harq_process->pusch_pdu.pusch_data.new_data_indicator); harq_process->ndi = harq_process->pusch_pdu.pusch_data.new_data_indicator; } F = harq_process->F; diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 18fe11d40a..fae6b5b2e7 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -147,7 +147,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, get_num_re_dmrs(pusch_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols); LOG_D(PHY,"ulsch %x : start_rb %d bwp_start %d start_sc %d start_symbol %d num_symbols %d cdmgrpsnodata %d num_dmrs %d dmrs_re_per_rb %d\n", - rnti,start_rb,pusch_pdu->bwp_start,start_sc,start_symbol,number_of_symbols,cdm_grps_no_data,number_dmrs_symbols,nb_dmrs_re_per_rb); + rnti,start_rb,pusch_pdu->bwp_start,start_sc,start_symbol,number_of_symbols,cdm_grps_no_data,number_dmrs_symbols,nb_dmrs_re_per_rb); // TbD num_of_mod_symbols is set but never used N_RE_prime = NR_NB_SC_PER_RB*number_of_symbols - nb_dmrs_re_per_rb*number_dmrs_symbols - N_PRB_oh; @@ -164,8 +164,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /////////// //////////////////////////////////////////////////////////////////// - //log_dump(PHY, harq_process_ul_ue->a, 16, LOG_DUMP_CHAR,"nrue pusch tx frame %d %d: ", frame, slot); - + /////////////////////////ULSCH scrambling///////////////////////// /////////// @@ -365,7 +364,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, // TODO: performance improvement, we can skip the modulation of DMRS symbols outside the bandwidth part // Perform this on gold sequence, not required when SC FDMA operation is done, - LOG_D(PHY,"DMRS in symbol %d\n",l); + LOG_D(PHY,"DMRS in symbol %d\n",l); nr_modulation(pusch_dmrs[l][0], n_dmrs*2, DMRS_MOD_ORDER, mod_dmrs); // currently only codeword 0 is modulated. Qm = 2 as DMRS is QPSK modulated } else { diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 9a191ae6f9..c7bf459f6f 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -59,11 +59,11 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, int16_t amp, int nr_slot_tx, uint8_t m0, - uint8_t mcs, + uint8_t mcs, uint8_t nrofSymbols, uint8_t startingSymbolIndex, uint16_t startingPRB, - uint16_t secondHopPRB) { + uint16_t secondHopPRB) { #ifdef DEBUG_NR_PUCCH_TX printf("\t [nr_generate_pucch0] start function at slot(nr_slot_tx)=%d\n",nr_slot_tx); #endif @@ -112,9 +112,9 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, } for (int l=0; l>15) diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h index cb4b59c92f..665dec2443 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h @@ -54,11 +54,12 @@ void nr_generate_pucch0(PHY_VARS_NR_UE *ue, int16_t amp, int nr_slot_tx, uint8_t m0, - uint8_t mcs, + uint8_t mcs, uint8_t nrofSymbols, uint8_t startingSymbolIndex, uint16_t startingPRB, - uint16_t secondHopPRB); + uint16_t secondHopPRB); + void nr_generate_pucch1(PHY_VARS_NR_UE *ue, int32_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, @@ -73,10 +74,11 @@ void nr_generate_pucch1(PHY_VARS_NR_UE *ue, uint16_t startingPRB_intraSlotHopping, uint8_t timeDomainOCC, uint8_t nr_bit); + void nr_generate_pucch2(PHY_VARS_NR_UE *ue, uint16_t crnti, - uint32_t dmrs_scrambling_id, - uint32_t data_scrambling_id, + uint32_t dmrs_scrambling_id, + uint32_t data_scrambling_id, int32_t **txdataF, NR_DL_FRAME_PARMS *frame_parms, PUCCH_CONFIG_DEDICATED *pucch_config_dedicated, @@ -88,6 +90,7 @@ void nr_generate_pucch2(PHY_VARS_NR_UE *ue, uint8_t nrofPRB, uint16_t startingPRB, uint8_t nr_bit); + void nr_generate_pucch3_4(PHY_VARS_NR_UE *ue, uint16_t crnti, int32_t **txdataF, diff --git a/openair1/PHY/TOOLS/lte_phy_scope.h b/openair1/PHY/TOOLS/lte_phy_scope.h index af9858ebad..1873fabea0 100644 --- a/openair1/PHY/TOOLS/lte_phy_scope.h +++ b/openair1/PHY/TOOLS/lte_phy_scope.h @@ -28,6 +28,7 @@ #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" #include "PHY/impl_defs_top.h" +#include /* Forms and Objects */ diff --git a/openair1/PHY/TOOLS/nr_phy_scope.c b/openair1/PHY/TOOLS/nr_phy_scope.c index 90a252dc98..c840149507 100644 --- a/openair1/PHY/TOOLS/nr_phy_scope.c +++ b/openair1/PHY/TOOLS/nr_phy_scope.c @@ -240,7 +240,7 @@ static void genericWaterFall (OAIgraph_t *graph, scopeSample_t *values, const in for (int pix=0; pixw; pix++) { scopeSample_t *end=values+(pix+1)*samplesPerPixel; end-=2; - AssertFatal(end <= values+datasize,"diff : %u", end-values+datasize); + AssertFatal(end <= values+datasize,"diff : %ld", end-values+datasize); double val=0; for (scopeSample_t *s=values+(pix)*samplesPerPixel; diff --git a/openair1/PHY/TOOLS/oai_dfts.c b/openair1/PHY/TOOLS/oai_dfts.c index 6e85bca384..83207426fd 100644 --- a/openair1/PHY/TOOLS/oai_dfts.c +++ b/openair1/PHY/TOOLS/oai_dfts.c @@ -32,17 +32,17 @@ #define M_PI 3.14159265358979323846 #endif #define OAIDFTS_MAIN -#ifndef MR_MAIN -#include "PHY/defs_common.h" -#include "PHY/impl_defs_top.h" -#else +//#ifndef MR_MAIN +//#include "PHY/defs_common.h" +//#include "PHY/impl_defs_top.h" +//#else #include "time_meas.h" #include "LOG/log.h" #define debug_msg #define ONE_OVER_SQRT2_Q15 23170 -int oai_exit=0; -#endif +//int oai_exit=0; +//#endif #define ONE_OVER_SQRT3_Q15 18919 @@ -50,6 +50,8 @@ int oai_exit=0; #include "assertions.h" +#include "tools_defs.h" + #define print_shorts(s,x) printf("%s %d,%d,%d,%d,%d,%d,%d,%d\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7]) #define print_shorts256(s,x) printf("%s %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",s,(x)[0],(x)[1],(x)[2],(x)[3],(x)[4],(x)[5],(x)[6],(x)[7],(x)[8],(x)[9],(x)[10],(x)[11],(x)[12],(x)[13],(x)[14],(x)[15]) diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h index 86c94421f2..66cb51adc6 100644 --- a/openair1/PHY/defs_RU.h +++ b/openair1/PHY/defs_RU.h @@ -436,6 +436,14 @@ typedef enum { typedef struct RU_t_s { /// index of this ru uint32_t idx; + /// pointer to first RU + struct RU_t_s *ru0; + /// pointer to ru_mask + uint64_t *ru_mask; + /// pointer to ru_mutex + pthread_mutex_t *ru_mutex; + /// pointer to ru_cond + pthread_cond_t *ru_cond; /// Pointer to configuration file char *rf_config_file; /// southbound interface @@ -446,6 +454,12 @@ typedef struct RU_t_s { node_function_t function; /// Ethernet parameters for fronthaul interface eth_params_t eth_params; + /// flag to indicate RF emulation mode + int emulate_rf; + /// numerology index + int numerology; + /// flag to indicate basicsim operation + int basicsim; /// flag to indicate the RU is in sync with a master reference int in_synch; /// timing offset diff --git a/openair1/PHY/defs_common.h b/openair1/PHY/defs_common.h index 70ca77fcc6..a371b2334b 100644 --- a/openair1/PHY/defs_common.h +++ b/openair1/PHY/defs_common.h @@ -945,6 +945,23 @@ extern int sync_var; #define DECODE_NUM_FPTR 13 +// Mask for identifying subframe for MBMS +#define MBSFN_TDD_SF3 0x80// for TDD +#define MBSFN_TDD_SF4 0x40 +#define MBSFN_TDD_SF7 0x20 +#define MBSFN_TDD_SF8 0x10 +#define MBSFN_TDD_SF9 0x08 + + + +#define MBSFN_FDD_SF1 0x80// for FDD +#define MBSFN_FDD_SF2 0x40 +#define MBSFN_FDD_SF3 0x20 +#define MBSFN_FDD_SF6 0x10 +#define MBSFN_FDD_SF7 0x08 +#define MBSFN_FDD_SF8 0x04 + + typedef uint8_t(decoder_if_t)(int16_t *y, int16_t *y2, uint8_t *decoded_bytes, diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h index 0f1bf75114..030d50bc04 100644 --- a/openair1/PHY/defs_eNB.h +++ b/openair1/PHY/defs_eNB.h @@ -164,10 +164,10 @@ typedef struct { /// - first index: rx antenna id [0..nb_antennas_rx[ /// - second index: ? [0..12*N_RB_UL*frame_parms->symbols_per_tti[ int32_t **ul_ch_magb; - /// measured RX power based on DRS - int ulsch_power[2]; - /// measured Interference power based on DRS - int ulsch_interference_power[2]; + /// measured RX power based on DMRS + int ulsch_power[4]; + /// measured RX power of noise + int ulsch_noise_power[4]; /// \brief llr values. /// - first index: ? [0..1179743] (hard coded) int16_t *llr; @@ -217,6 +217,58 @@ typedef struct { int ret; } td_params; +/// Context data structure for RX/TX portion of subframe processing +typedef struct { + /// Component Carrier index + uint8_t CC_id; + /// timestamp transmitted to HW + openair0_timestamp timestamp_tx; + openair0_timestamp timestamp_rx; + /// subframe to act upon for transmission + int subframe_tx; + /// subframe to act upon for reception + int subframe_rx; + /// frame to act upon for transmission + int frame_tx; + /// frame to act upon for reception + int frame_rx; + int frame_prach; + int subframe_prach; + int frame_prach_br; + int subframe_prach_br; + /// \brief Instance count for RXn-TXnp4 processing thread. + /// \internal This variable is protected by \ref mutex_rxtx. + int instance_cnt; + /// pthread structure for RXn-TXnp4 processing thread + pthread_t pthread; + /// pthread attributes for RXn-TXnp4 processing thread + pthread_attr_t attr; + /// condition variable for tx processing thread + pthread_cond_t cond; + /// mutex for RXn-TXnp4 processing thread + pthread_mutex_t mutex; + /// scheduling parameters for RXn-TXnp4 thread + struct sched_param sched_param_rxtx; + + /// \internal This variable is protected by \ref mutex_RUs. + int instance_cnt_RUs; + /// condition variable for tx processing thread + pthread_cond_t cond_RUs; + /// mutex for RXn-TXnp4 processing thread + pthread_mutex_t mutex_RUs; + tpool_t *threadPool; + int nbEncode; + int nbDecode; + notifiedFIFO_t *respEncode; + notifiedFIFO_t *respDecode; + pthread_mutex_t mutex_emulateRF; + int instance_cnt_emulateRF; + pthread_t pthread_emulateRF; + pthread_attr_t attr_emulateRF; + pthread_cond_t cond_emulateRF; + int first_rx; +} L1_rxtx_proc_t; + typedef struct { struct PHY_VARS_eNB_s *eNB; LTE_eNB_DLSCH_t *dlsch; @@ -362,8 +414,11 @@ typedef struct L1_proc_t_s { L1_rxtx_proc_t L1_proc,L1_proc_tx; /// stats thread pthread descriptor pthread_t process_stats_thread; + /// L1 stats pthread descriptor + pthread_t L1_stats_thread; /// for waking up tx procedure RU_proc_t *ru_proc; + struct PHY_VARS_eNB_s *eNB; } L1_proc_t; @@ -395,36 +450,73 @@ typedef struct { short n0_subband_power_avg_dB; // eNB measurements (per user) //! estimated received spatial signal power (linear) - unsigned int rx_spatial_power[NUMBER_OF_UE_MAX][2][2]; + unsigned int rx_spatial_power[NUMBER_OF_SRS_MAX][2][2]; //! estimated received spatial signal power (dB) - unsigned short rx_spatial_power_dB[NUMBER_OF_UE_MAX][2][2]; + unsigned short rx_spatial_power_dB[NUMBER_OF_SRS_MAX][2][2]; //! estimated rssi (dBm) - short rx_rssi_dBm[NUMBER_OF_UE_MAX]; + short rx_rssi_dBm[NUMBER_OF_SRS_MAX]; //! estimated correlation (wideband linear) between spatial channels (computed in dlsch_demodulation) - int rx_correlation[NUMBER_OF_UE_MAX][2]; + int rx_correlation[NUMBER_OF_SRS_MAX][2]; //! estimated correlation (wideband dB) between spatial channels (computed in dlsch_demodulation) - int rx_correlation_dB[NUMBER_OF_UE_MAX][2]; + int rx_correlation_dB[NUMBER_OF_SRS_MAX][2]; /// Wideband CQI (= SINR) - int wideband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB]; + int wideband_cqi[NUMBER_OF_SRS_MAX][MAX_NUM_RU_PER_eNB]; /// Wideband CQI in dB (= SINR dB) - int wideband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB]; + int wideband_cqi_dB[NUMBER_OF_SRS_MAX][MAX_NUM_RU_PER_eNB]; /// Wideband CQI (sum of all RX antennas, in dB) - char wideband_cqi_tot[NUMBER_OF_UE_MAX]; + char wideband_cqi_tot[NUMBER_OF_SRS_MAX]; /// Subband CQI per RX antenna and RB (= SINR) - int subband_cqi[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB][100]; + int subband_cqi[NUMBER_OF_SRS_MAX][MAX_NUM_RU_PER_eNB][100]; /// Total Subband CQI and RB (= SINR) int subband_cqi_tot[NUMBER_OF_UE_MAX][100]; /// Subband CQI in dB and RB (= SINR dB) - int subband_cqi_dB[NUMBER_OF_UE_MAX][MAX_NUM_RU_PER_eNB][100]; + int subband_cqi_dB[NUMBER_OF_SRS_MAX][MAX_NUM_RU_PER_eNB][100]; /// Total Subband CQI and RB - int subband_cqi_tot_dB[NUMBER_OF_UE_MAX][100]; + int subband_cqi_tot_dB[NUMBER_OF_SRS_MAX][100]; /// PRACH background noise level int prach_I0; /// PUCCH background noise level int n0_pucch_dB; } PHY_MEASUREMENTS_eNB; +typedef struct { + uint16_t rnti; + int frame; + int round_trials[8]; + int total_bytes_tx; + int total_bytes_rx; + int current_G; + int current_TBS; + int current_Qm; + int current_mcs; + int current_RI; + int timing_offset; + int ulsch_power[4]; + int ulsch_noise_power[4]; +} eNB_SCH_STATS_t; + +typedef struct { + uint16_t rnti; + int frame; + int pucch1_trials; + int pucch1_thres; + int current_pucch1_stat_pos; + int current_pucch1_stat_neg; + int pucch1_positive_SR; + int pucch1_low_stat[4]; + int pucch1_high_stat[4]; + int pucch1_phase; + int pucch1a_trials; + int current_pucch1a_stat_re; + int current_pucch1a_stat_im; + int pucch1ab_DTX; + int pucch1b_trials; + int current_pucch1b_stat_re; + int current_pucch1b_stat_im; + int pucch3_trials; + int current_pucch3_stat; +} eNB_UCI_STATS_t; /// Top-level PHY Data Structure for eNB typedef struct PHY_VARS_eNB_s { @@ -472,13 +564,13 @@ typedef struct PHY_VARS_eNB_s { LTE_eNB_MPDCCH mpdcch_vars[2]; LTE_eNB_PRACH prach_vars_br; LTE_eNB_COMMON common_vars; - LTE_eNB_UCI uci_vars[NUMBER_OF_UCI_VARS_MAX]; - LTE_eNB_SRS srs_vars[NUMBER_OF_UE_MAX]; + LTE_eNB_UCI uci_vars[NUMBER_OF_UCI_MAX]; + LTE_eNB_SRS srs_vars[NUMBER_OF_SRS_MAX]; LTE_eNB_PBCH pbch; - LTE_eNB_PUSCH *pusch_vars[NUMBER_OF_UE_MAX]; + LTE_eNB_PUSCH *pusch_vars[NUMBER_OF_ULSCH_MAX]; LTE_eNB_PRACH prach_vars; - LTE_eNB_DLSCH_t *dlsch[NUMBER_OF_UE_MAX][2]; // Nusers times two spatial streams - LTE_eNB_ULSCH_t *ulsch[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA + LTE_eNB_DLSCH_t *dlsch[NUMBER_OF_DLSCH_MAX][2]; // Num active DLSCH contexts times two spatial streams + LTE_eNB_ULSCH_t *ulsch[NUMBER_OF_ULSCH_MAX]; // Num active ULSCH contexts LTE_eNB_DLSCH_t *dlsch_SI,*dlsch_ra,*dlsch_p; LTE_eNB_DLSCH_t *dlsch_MCH; LTE_eNB_DLSCH_t *dlsch_PCH; @@ -489,7 +581,7 @@ typedef struct PHY_VARS_eNB_s { uint32_t lte_gold_table[20][2][14]; /// UE-specific reference symbols (p=5), TM 7 - uint32_t lte_gold_uespec_port5_table[NUMBER_OF_UE_MAX][20][38]; + uint32_t lte_gold_uespec_port5_table[NUMBER_OF_DLSCH_MAX][20][38]; /// UE-specific reference symbols (p=7...14), TM 8/9/10 uint32_t lte_gold_uespec_table[2][20][2][21]; @@ -521,6 +613,9 @@ typedef struct PHY_VARS_eNB_s { uint8_t pbch_pdu[4]; //PBCH_PDU_SIZE char eNB_generate_rar; + /// indicator that eNB signal generation uses DTX (i.e. signal is cleared in each subframe + int use_DTX; + int32_t **subframe_mask; /// Indicator set to 0 after first SR uint8_t first_sr[NUMBER_OF_UE_MAX]; @@ -592,7 +687,12 @@ typedef struct PHY_VARS_eNB_s { /// Information regarding TM5 MU_MIMO_mode mu_mimo_mode[NUMBER_OF_UE_MAX]; - + /// statistics for DLSCH measurement collection + eNB_SCH_STATS_t dlsch_stats[NUMBER_OF_SCH_STATS_MAX]; + /// statistics for ULSCH measurement collection + eNB_SCH_STATS_t ulsch_stats[NUMBER_OF_SCH_STATS_MAX]; + /// statis for UCI (PUCCH) measurement collection + eNB_UCI_STATS_t uci_stats[NUMBER_OF_SCH_STATS_MAX]; /// target_ue_dl_mcs : only for debug purposes uint32_t target_ue_dl_mcs; /// target_ue_ul_mcs : only for debug purposes diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index 129f7a9a71..364e3a118a 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -751,7 +751,6 @@ typedef struct PHY_VARS_gNB_s { // nfapi_nr_dl_tti_pdcch_pdu *pdcch_pdu; // nfapi_nr_ul_dci_request_pdus_t *ul_dci_pdu; - uint16_t num_pdsch_rnti[80]; NR_gNB_SSB_t ssb[64]; NR_gNB_PBCH pbch; @@ -886,6 +885,8 @@ typedef struct PHY_VARS_gNB_s { tpool_t *threadPool; int nbDecode; uint8_t pusch_proc_threads; + int number_of_nr_dlsch_max; + int number_of_nr_ulsch_max; void * scopeData; } PHY_VARS_gNB; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 47db683d90..198d58bf3e 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -766,6 +766,8 @@ typedef struct { int is_synchronized; /// \brief Indicates on which frame is synchronized in a two frame synchronization int is_synchronized_on_frame; + /// \brief Indicator that UE lost frame synchronization + int lost_sync; /// Data structure for UE process scheduling UE_nr_proc_t proc; /// Flag to indicate the UE shouldn't do timing correction at all @@ -792,6 +794,8 @@ typedef struct { uint8_t ho_initiated; /// \brief indicator that Handover procedure has been triggered uint8_t ho_triggered; + /// threshold for false dci detection + int dci_thres; /// \brief Measurement variables. PHY_NR_MEASUREMENTS measurements; NR_DL_FRAME_PARMS frame_parms; @@ -1083,6 +1087,7 @@ typedef struct { typedef struct nr_rxtx_thread_data_s { UE_nr_rxtx_proc_t proc; PHY_VARS_NR_UE *UE; + notifiedFIFO_t txFifo; } nr_rxtx_thread_data_t; #include "SIMULATION/ETH_TRANSPORT/defs.h" diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 398252c37b..d1d69ecabe 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -109,6 +109,8 @@ #define MAX_NUM_NR_CHANNEL_BITS (14*273*12*8) // 14 symbols, 273 RB #define MAX_NUM_NR_RE (14*273*12) +#define NR_RX_NB_TH 1 +#define NR_NB_TH_SLOT 2 extern const uint8_t nr_rv_round_map[4]; extern const uint8_t nr_rv_round_map_ue[4]; diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h index fad578c8b0..a74c3675a4 100644 --- a/openair1/PHY/impl_defs_nr.h +++ b/openair1/PHY/impl_defs_nr.h @@ -36,7 +36,6 @@ #include #include "types.h" -#include "NR_PDSCH-TimeDomainResourceAllocation.h" #ifdef DEFINE_VARIABLES_PHY_IMPLEMENTATION_DEFS_NR_H #define EXTERN @@ -395,6 +394,13 @@ typedef struct{ typedef struct{ // to be defined FIXME!!! }zp_CSI_RS_Resource_t; + +typedef struct{ + int k0; + int mappingType; + int startSymbolAndLength; + +}PDSCH_TimeDomainResourceAllocation_t; typedef struct { /* * resourceAllocation @@ -447,7 +453,8 @@ typedef struct { */ maxNrofCodeWordsScheduledByDCI_t maxNrofCodeWordsScheduledByDCI; - NR_PDSCH_TimeDomainResourceAllocation_t *pdsch_TimeDomainResourceAllocation[MAX_NR_OF_DL_ALLOCATIONS]; + + PDSCH_TimeDomainResourceAllocation_t *pdsch_TimeDomainResourceAllocation[MAX_NR_OF_DL_ALLOCATIONS]; } PDSCH_Config_t; diff --git a/openair1/PHY/phy_extern.h b/openair1/PHY/phy_extern.h index 4ba5e328e3..d5fea5aec6 100644 --- a/openair1/PHY/phy_extern.h +++ b/openair1/PHY/phy_extern.h @@ -23,7 +23,6 @@ #define __PHY_EXTERN_H__ #include "PHY/defs_common.h" -#include "common/ran_context.h" extern char* namepointer_chMag ; extern char* namepointer_log2; @@ -33,14 +32,13 @@ extern unsigned int RX_DMA_BUFFER[4][NB_ANTENNAS_RX]; extern unsigned int TX_DMA_BUFFER[4][NB_ANTENNAS_TX]; #include "PHY/LTE_TRANSPORT/transport_extern.h" -//#include "SIMULATION/ETH_TRANSPORT/extern.h" +#include "PHY/defs_RU.h" extern unsigned int DAQ_MBOX; extern int number_of_cards; extern const short conjugate[8],conjugate2[8]; -extern RAN_CONTEXT_t RC; extern short primary_synch0[144]; extern short primary_synch1[144]; diff --git a/openair1/PHY/phy_extern_ue.h b/openair1/PHY/phy_extern_ue.h index fdaf6eaa89..9f227806fd 100644 --- a/openair1/PHY/phy_extern_ue.h +++ b/openair1/PHY/phy_extern_ue.h @@ -23,7 +23,6 @@ #define __PHY_EXTERN_UE__H__ #include "PHY/defs_UE.h" -#include "common/ran_context.h" extern char* namepointer_chMag ; extern char* namepointer_log2; diff --git a/openair1/PHY/phy_vars.h b/openair1/PHY/phy_vars.h index dadb1649ec..9edb7031b9 100644 --- a/openair1/PHY/phy_vars.h +++ b/openair1/PHY/phy_vars.h @@ -25,7 +25,6 @@ #include "PHY/types.h" #include "PHY/defs_eNB.h" #include "PHY/defs_UE.h" -#include "common/ran_context.h" char* namepointer_chMag ; char fmageren_name2[512]; @@ -38,9 +37,10 @@ char* namepointer_log2; #include "PHY/LTE_TRANSPORT/transport_vars.h" #include "PHY/MODULATION/modulation_vars.h" +#include "nfapi/oai_integration/vendor_ext.h" + PHY_VARS_UE ***PHY_vars_UE_g; -RAN_CONTEXT_t RC; UL_RCC_IND_t UL_RCC_INFO; unsigned short rev[2048],rev_times4[8192],rev_half[1024]; diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 3f342802b4..ecfec02193 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -32,11 +32,15 @@ #include "PHY/defs_eNB.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" +#include "PHY/LTE_TRANSPORT/transport_extern.h" #include "SCHED/sched_eNB.h" #include "nfapi/oai_integration/vendor_ext.h" #include "nfapi_pnf_interface.h" #include "fapi_l1.h" +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req); int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req); int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req); @@ -209,13 +213,13 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); - if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ) { + if( (UE_id<0) || (UE_id>=NUMBER_OF_DLSCH_MAX) ) { LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rel8->rnti,UE_id); return; } //AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); - //AssertFatal(UE_id= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); + //AssertFatal(UE_id= %d(NUMBER_OF_DLSCHMAX)\n",UE_id,NUMBER_OF_DLSCH_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; @@ -291,7 +295,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro if ((rel13->pdsch_payload_type <2) && (rel13->ue_type>0)) { // this is a BR/CE UE and SIB1-BR/SI-BR UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); - AssertFatal(UE_id= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); + AssertFatal(UE_id= %d(NUMBER_OF_DLSCH_MAX)\n",UE_id,NUMBER_OF_DLSCH_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch0->harq_mask = 1; dlsch0_harq = dlsch0->harq_processes[0]; @@ -366,7 +370,7 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,L1_rxtx_pro } else { UE_id = find_dlsch(rel8->rnti,eNB,SEARCH_EXIST_OR_FREE); AssertFatal(UE_id!=-1,"no free or exiting dlsch_context\n"); - AssertFatal(UE_id= %d(NUMBER_OF_UE_MAX)\n",UE_id,NUMBER_OF_UE_MAX); + AssertFatal(UE_id= %d(NUMBER_OF_DLSCH_MAX)\n",UE_id,NUMBER_OF_DLSCH_MAX); dlsch0 = eNB->dlsch[UE_id][0]; dlsch1 = eNB->dlsch[UE_id][1]; dlsch0->sib1_br_flag=0; @@ -596,7 +600,7 @@ void handle_uci_sr_pdu(PHY_VARS_eNB *eNB, uci->frame = frame; uci->subframe = subframe; uci->rnti = ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti; - uci->ue_id = find_ulsch(ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE); + uci->ue_id = find_ulsch(ul_config_pdu->uci_sr_pdu.ue_information.ue_information_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE); uci->type = SR; uci->pucch_fmt = pucch_format1; uci->num_antenna_ports = 1; @@ -622,7 +626,7 @@ void handle_uci_sr_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_ uci->frame = frame; uci->subframe = subframe; uci->rnti = ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti; - uci->ue_id = find_ulsch(ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE); + uci->ue_id = find_ulsch(ul_config_pdu->uci_sr_harq_pdu.ue_information.ue_information_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE); uci->type = HARQ_SR; uci->num_antenna_ports = 1; uci->num_pucch_resources = 1; @@ -660,7 +664,7 @@ void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_p if (NFAPI_MODE==NFAPI_MODE_VNF) return; - for (i=0; isoundingrs_ul_config_dedicated[i].active==1) continue; eNB->soundingrs_ul_config_dedicated[i].active = 1; @@ -676,7 +680,7 @@ void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_p break; } - AssertFatal(imodule_id; @@ -780,7 +785,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc) { nfapi_dl_config_request_pdu_t *dl_config_pdu; nfapi_hi_dci0_request_pdu_t *hi_dci0_req_pdu; nfapi_ul_config_request_pdu_t *ul_config_pdu; - int i; + eNB->pdcch_vars[subframe&1].num_pdcch_symbols = number_pdcch_ofdm_symbols; eNB->pdcch_vars[subframe&1].num_dci = 0; eNB->phich_vars[subframe&1].num_hi = 0; @@ -811,8 +816,8 @@ void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc) { // clear DCI allocation maps for new subframe if (NFAPI_MODE!=NFAPI_MODE_VNF) - for (i=0; iulsch[i]) { + for (int i=0; iulsch[i]!=NULL) { ulsch_harq = eNB->ulsch[i]->harq_processes[harq_pid]; ulsch_harq->dci_alloc=0; ulsch_harq->rar_alloc=0; @@ -820,7 +825,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc) { } } - for (i=0; idl_config_request_body.dl_config_pdu_list[i]; //LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type); @@ -969,7 +974,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc) { } if (NFAPI_MODE!=NFAPI_MODE_VNF) - for (i=0; ihi_dci0_request_body.hi_dci0_pdu_list[i]; LOG_D(PHY,"NFAPI: hi_dci0_pdu %d : type %d\n",i,hi_dci0_req_pdu->pdu_type); @@ -993,7 +998,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc) { if (NFAPI_MODE!=NFAPI_MONOLITHIC) { if (number_ul_pdu>0) { uint8_t ulsch_pdu_num = 0; - for (i=0; iul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) || (UL_req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE) || (UL_req->ul_config_request_body.ul_config_pdu_list[i].pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE) || @@ -1020,7 +1025,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc) { } } } else { - for (i=0; iul_config_request_body.ul_config_pdu_list[i]; LOG_D(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type); AssertFatal(ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE || diff --git a/openair1/SCHED/fapi_l1.h b/openair1/SCHED/fapi_l1.h index 6b9121e17f..b8f0ae1dd8 100644 --- a/openair1/SCHED/fapi_l1.h +++ b/openair1/SCHED/fapi_l1.h @@ -31,8 +31,6 @@ */ #include "PHY/defs_eNB.h" -#include "PHY/defs_gNB.h" -#include "PHY/phy_extern.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" #include "SCHED/sched_eNB.h" #include "SCHED/sched_common.h" @@ -82,4 +80,4 @@ void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu void handle_srs_pdu(PHY_VARS_eNB *eNB,nfapi_ul_config_request_pdu_t *ul_config_pdu,uint16_t frame,uint8_t subframe); -void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); +void schedule_response(Sched_Rsp_t *Sched_INFO, void *proc); diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index 0b592b9c55..7033c52701 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -1085,73 +1085,3 @@ void compute_srs_pos(lte_frame_type_t frameType,uint16_t isrs,uint16_t *psrsPeri } } - -// uint8_t eNB_id,uint8_t harq_pid, uint8_t UE_id, -int16_t estimate_ue_tx_power(uint32_t tbs, uint32_t nb_rb, uint8_t control_only, lte_prefix_type_t ncp, uint8_t use_srs) -{ - - /// The payload + CRC size in bits, "B" - uint32_t B; - /// Number of code segments - uint32_t C; - /// Number of "small" code segments - uint32_t Cminus; - /// Number of "large" code segments - uint32_t Cplus; - /// Number of bits in "small" code segments (<6144) - uint32_t Kminus; - /// Number of bits in "large" code segments (<6144) - uint32_t Kplus; - /// Total number of bits across all segments - uint32_t sumKr; - /// Number of "Filler" bits - uint32_t F; - // num resource elements - uint32_t num_re=0.0; - // num symbols - uint32_t num_symb=0.0; - /// effective spectral efficiency of the PUSCH - uint32_t MPR_x100=0; - /// beta_offset - uint16_t beta_offset_pusch_x8=8; - /// delta mcs - float delta_mcs=0.0; - /// bandwidth factor - float bw_factor=0.0; - - B= tbs+24; - lte_segmentation(NULL, - NULL, - B, - &C, - &Cplus, - &Cminus, - &Kplus, - &Kminus, - &F); - - - sumKr = Cminus*Kminus + Cplus*Kplus; - num_symb = 12-(ncp<<1)-(use_srs==0?0:1); - num_re = num_symb * nb_rb * 12; - - if (num_re == 0) - return(0); - - MPR_x100 = 100*sumKr/num_re; - - if (control_only == 1 ) - beta_offset_pusch_x8=8; // fixme - - //(beta_offset_pusch_x8=ue->ulsch[eNB_id]->harq_processes[harq_pid]->control_only == 1) ? ue->ulsch[eNB_id]->beta_offset_cqi_times8:8; - - // if deltamcs_enabledm - delta_mcs = ((hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_x10((beta_offset_pusch_x8)>>3))/100.0); - bw_factor = (hundred_times_log10_NPRB[nb_rb-1]/100.0); -#ifdef DEBUG_SEGMENTATION - printf("estimated ue tx power %d (num_re %d, sumKr %d, mpr_x100 %d, delta_mcs %f, bw_factor %f)\n", - (int16_t)ceil(delta_mcs + bw_factor), num_re, sumKr, MPR_x100, delta_mcs, bw_factor); -#endif - return (int16_t)ceil(delta_mcs + bw_factor); - -} diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index d894061acd..973c921d23 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -52,21 +52,24 @@ #define MBMS_NFAPI_SCHEDULER +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; -int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t harq_pid, uint8_t bw_factor) { + +int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t ULSCH_id,uint8_t harq_pid, uint8_t bw_factor) { uint32_t Nre,sumKr,MPR_x100,Kr,r; uint16_t beta_offset_pusch; - DevAssert( UE_id < NUMBER_OF_UE_MAX+1 ); + DevAssert( ULSCH_id < NUMBER_OF_ULSCH_MAX+1 ); DevAssert( harq_pid < 8 ); - Nre = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_initial * - eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb*12; + Nre = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->Nsymb_initial * + eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->nb_rb*12; sumKr = 0; - for (r=0; rulsch[UE_id]->harq_processes[harq_pid]->C; r++) { - if (rulsch[UE_id]->harq_processes[harq_pid]->Cminus) - Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kminus; + for (r=0; rulsch[ULSCH_id]->harq_processes[harq_pid]->C; r++) { + if (rulsch[ULSCH_id]->harq_processes[harq_pid]->Cminus) + Kr = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->Kminus; else - Kr = eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus; + Kr = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->Kplus; sumKr += Kr; } @@ -79,14 +82,14 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t // FK 20140908 sumKr is only set after the ulsch_encoding beta_offset_pusch = 8; //(eNB->ulsch[UE_id]->harq_processes[harq_pid]->control_only == 1) ? eNB->ulsch[UE_id]->beta_offset_cqi_times8:8; - DevAssert( UE_id < NUMBER_OF_UE_MAX ); + DevAssert( ULSCH_id < NUMBER_OF_ULSCH_MAX ); //#warning "This condition happens sometimes. Need more investigation" // navid //DevAssert( MPR_x100/6 < 100 ); if (1==1) { //eNB->ul_power_control_dedicated[UE_id].deltaMCS_Enabled == 1) { // This is the formula from Section 5.1.1.1 in 36.213 10*log10(deltaIF_PUSCH = (2^(MPR*Ks)-1)*beta_offset_pusch) if (bw_factor == 1) { - uint8_t nb_rb = eNB->ulsch[UE_id]->harq_processes[harq_pid]->nb_rb; + uint8_t nb_rb = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->nb_rb; return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_x10((beta_offset_pusch)>>3)) + hundred_times_log10_NPRB[nb_rb-1]; } else return(hundred_times_delta_TF[MPR_x100/6]+10*dB_fixed_x10((beta_offset_pusch)>>3)); @@ -97,21 +100,21 @@ int16_t get_hundred_times_delta_IF_eNB(PHY_VARS_eNB *eNB,uint16_t UE_id,uint8_t int16_t get_hundred_times_delta_IF_mac(module_id_t module_idP, uint8_t CC_id, rnti_t rnti, uint8_t harq_pid) { - int8_t UE_id; + int8_t ULSCH_id; if ((RC.eNB == NULL) || (module_idP > RC.nb_inst) || (CC_id > RC.nb_CC[module_idP])) { LOG_E(PHY,"get_UE_stats: No eNB found (or not allocated) for Mod_id %d,CC_id %d\n",module_idP,CC_id); return -1; } - UE_id = find_ulsch( rnti, RC.eNB[module_idP][CC_id],SEARCH_EXIST); + ULSCH_id = find_ulsch( rnti, RC.eNB[module_idP][CC_id],SEARCH_EXIST); - if (UE_id == -1) { + if (ULSCH_id == -1) { // not found return 0; } - return get_hundred_times_delta_IF_eNB( RC.eNB[module_idP][CC_id], UE_id, harq_pid, 0 ); + return get_hundred_times_delta_IF_eNB( RC.eNB[module_idP][CC_id], ULSCH_id, harq_pid, 0 ); } int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); @@ -499,9 +502,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, int do_meas) { int frame=proc->frame_tx; int subframe=proc->subframe_tx; - uint32_t i,aa; uint8_t harq_pid; - int16_t UE_id=0; uint8_t num_pdcch_symbols=0; uint8_t num_dci=0; uint8_t num_mdci = 0; @@ -516,12 +517,15 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),1); if (do_meas==1) start_meas(&eNB->phy_proc_tx); - if (do_meas==1) start_meas(&eNB->dlsch_common_and_dci); // clear the transmit data array for the current subframe - for (aa = 0; aa < fp->nb_antenna_ports_eNB; aa++) { - memset (&eNB->common_vars.txdataF[aa][subframe * fp->ofdm_symbol_size * (fp->symbols_per_tti)], 0, fp->ofdm_symbol_size * (fp->symbols_per_tti) * sizeof (int32_t)); + for (int aa = 0; aa < fp->nb_antenna_ports_eNB; aa++) { + if (eNB->use_DTX==0) + memcpy(&eNB->common_vars.txdataF[aa][subframe * fp->ofdm_symbol_size * (fp->symbols_per_tti)], + &eNB->subframe_mask[aa][subframe*fp->ofdm_symbol_size*fp->symbols_per_tti], + fp->ofdm_symbol_size * (fp->symbols_per_tti) * sizeof (int32_t)); + else memset(&eNB->common_vars.txdataF[aa][subframe * fp->ofdm_symbol_size * (fp->symbols_per_tti)], 0, fp->ofdm_symbol_size * (fp->symbols_per_tti) * sizeof (int32_t)); } if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) { @@ -556,7 +560,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, ul_frame = pdcch_alloc2ul_frame (fp, frame, subframe); // clear previous allocation information for all UEs - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (volatile int i = 0; i < NUMBER_OF_DLSCH_MAX; i++) { if (eNB->dlsch[i][0]) eNB->dlsch[i][0]->subframe_tx[subframe] = 0; } @@ -565,7 +569,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, //if ((ul_subframe < 10)&& // (subframe_select(fp,ul_subframe)==SF_UL)) { // This means that there is a potential UL subframe that will be scheduled here if (ul_subframe < 10) { // This means that there is a potential UL subframe that will be scheduled here - for (i=0; iulsch[i] && eNB->ulsch[i]->ue_type >0) harq_pid = 0; else @@ -651,9 +655,9 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, // Now scan UE specific DLSCH LTE_eNB_DLSCH_t *dlsch0,*dlsch1; - for (UE_id=0; UE_iddlsch[(uint8_t)UE_id][0]; - dlsch1 = eNB->dlsch[(uint8_t)UE_id][1]; + for (int DLSCH_id=0; DLSCH_iddlsch[(uint8_t)DLSCH_id][0]; + dlsch1 = eNB->dlsch[(uint8_t)DLSCH_id][1]; if ((dlsch0)&&(dlsch0->rnti>0)&& #ifdef PHY_TX_THREAD @@ -663,12 +667,13 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, #endif ) { // get harq_pid - harq_pid = dlsch0->harq_ids[frame%2][subframe]; + harq_pid = dlsch0->harq_ids[frame%2][subframe]; //AssertFatal(harq_pid>=0,"harq_pid is negative\n"); if((harq_pid < 0) || (harq_pid >= dlsch0->Mdlharq)) { + if (dlsch0->ue_type==0) - LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 UE_id:%d frame:%d subframe:%d rnti:%x [ %1d.%1d.%1d.%1d.%1d.%1d.%1d.%1d\n", harq_pid,UE_id,frame,subframe,dlsch0->rnti, + LOG_E(PHY,"harq_pid:%d corrupt must be 0-7 DLSCH_id:%d frame:%d subframe:%d rnti:%x [ %1d.%1d.%1d.%1d.%1d.%1d.%1d.%1d\n", harq_pid,DLSCH_id,frame,subframe,dlsch0->rnti, dlsch0->harq_ids[frame%2][0], dlsch0->harq_ids[frame%2][1], dlsch0->harq_ids[frame%2][2], @@ -682,7 +687,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, proc, harq_pid, dlsch0, - &eNB->UE_stats[(uint32_t)UE_id])) { + &eNB->UE_stats[(uint32_t)DLSCH_id])) { // if we generate dlsch, we must generate pdsch pdsch_procedures(eNB, proc, @@ -717,6 +722,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, if (do_meas==1) stop_meas(&eNB->phy_proc_tx); } +/* This has to be updated with FAPI structures*/ void srs_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; @@ -728,7 +734,7 @@ void srs_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { // Do SRS processing // check if there is SRS and we have to use shortened format // TODO: check for exceptions in transmission of SRS together with ACK/NACK - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < NUMBER_OF_SRS_MAX; i++) { if (eNB->soundingrs_ul_config_dedicated[i].active == 1) { if (lte_srs_channel_estimation (fp, &eNB->common_vars, &eNB->srs_vars[i], &eNB->soundingrs_ul_config_dedicated[i], subframe, 0 /*eNB_id */ )) { LOG_E (PHY, "problem processing SRS\n"); @@ -793,7 +799,7 @@ uci_procedures(PHY_VARS_eNB *eNB, calc_pucch_1x_interference(eNB, frame, subframe, 0); - for (int i = 0; i < NUMBER_OF_UCI_VARS_MAX; i++) { + for (int i = 0; i < NUMBER_OF_UCI_MAX; i++) { uci = &(eNB->uci_vars[i]); if ((uci->active == 1) && (uci->frame == frame) && (uci->subframe == subframe)) { @@ -850,7 +856,7 @@ uci_procedures(PHY_VARS_eNB *eNB, int pucch1_thres = (uci->ue_type == 0) ? eNB->pucch1_DTX_threshold : eNB->pucch1_DTX_threshold_emtc[0]; metric_SR = rx_pucch(eNB, uci->pucch_fmt, - uci->ue_id, + i,//uci->ue_id, uci->n_pucch_1_0_sr[0], 0, // n2_pucch uci->srs_active, // shortened format @@ -1275,7 +1281,7 @@ uci_procedures(PHY_VARS_eNB *eNB, #ifdef DEBUG_PHY_PROC LOG_D (PHY, "[eNB %d][PDSCH %x] Frame %d subframe %d ACK/NAK metric 0 %d, metric 1 %d, (%d,%d)\n", eNB->Mod_id, - eNB->dlsch[UE_id][0]->rnti, frame, subframe, metric0, metric1, pucch_b0b1[0], pucch_b0b1[1]); + eNB->dlsch[DLSCH_id][0]->rnti, frame, subframe, metric0, metric1, pucch_b0b1[0], pucch_b0b1[1]); #endif } @@ -1298,7 +1304,7 @@ uci_procedures(PHY_VARS_eNB *eNB, } } } // end if ((uci->active == 1) && (uci->frame == frame) && (uci->subframe == subframe)) { - } // end loop for (int i = 0; i < NUMBER_OF_UE_MAX; i++) { + } // end loop for (int i = 0; i < NUMBER_OF_UCI_MAX; i++) { } void postDecode(L1_rxtx_proc_t *proc, notifiedFIFO_elt_t *req) { @@ -1325,7 +1331,7 @@ void postDecode(L1_rxtx_proc_t *proc, notifiedFIFO_elt_t *req) { int nb=abortTpool(proc->threadPool, req->key); nb+=abortNotifiedFIFO(proc->respDecode, req->key); proc->nbDecode-=nb; - LOG_I(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); + LOG_D(PHY,"uplink segment error %d/%d, aborted %d segments\n",rdata->segment_r,rdata->nbSegments, nb); AssertFatal(ulsch_harq->processedSegments+nb == rdata->nbSegments,"processed: %d, aborted: %d, total %d\n", ulsch_harq->processedSegments, nb, rdata->nbSegments); ulsch_harq->processedSegments=rdata->nbSegments; @@ -1381,6 +1387,15 @@ void postDecode(L1_rxtx_proc_t *proc, notifiedFIFO_elt_t *req) { fill_rx_indication(eNB,i,rdata->frame,rdata->subframe); // indicate SDU to MAC ulsch_harq->status = SCH_IDLE; ulsch->harq_mask &= ~(1 << rdata->harq_pid); + for (int j=0;julsch_stats[j].rnti == ulsch->rnti) { + eNB->ulsch_stats[j].total_bytes_rx+=ulsch_harq->TBS; + for (int aa=0;aaframe_parms.nb_antennas_rx;aa++) { + eNB->ulsch_stats[j].ulsch_power[aa] = dB_fixed_x10(eNB->pusch_vars[rdata->UEid]->ulsch_power[aa]); + eNB->ulsch_stats[j].ulsch_noise_power[aa] = dB_fixed_x10(eNB->pusch_vars[rdata->UEid]->ulsch_noise_power[aa]); + } + break; + } T (T_ENB_PHY_ULSCH_UE_ACK, T_INT(eNB->Mod_id), T_INT(rdata->frame), T_INT(rdata->subframe), T_INT(ulsch->rnti), T_INT(rdata->harq_pid)); } // ulsch not in error @@ -1401,8 +1416,9 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { const int frame = proc->frame_rx; uint32_t harq_pid0 = subframe2harq_pid(&eNB->frame_parms,frame,subframe); - for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + for (i = 0; i < NUMBER_OF_ULSCH_MAX; i++) { ulsch = eNB->ulsch[i]; + if (!ulsch) continue; if (ulsch->ue_type > 0) harq_pid = 0; else harq_pid=harq_pid0; @@ -1411,10 +1427,9 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { if (ulsch->rnti>0) LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n", i, harq_pid, frame,subframe,i,ulsch->rnti, - ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); + ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); - if ((ulsch) && - (ulsch->rnti>0) && + if ((ulsch->rnti>0) && (ulsch_harq->status == ACTIVE) && ((ulsch_harq->frame == frame) || (ulsch_harq->repetition_number >1) ) && ((ulsch_harq->subframe == subframe) || (ulsch_harq->repetition_number >1) ) && @@ -1459,6 +1474,17 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { ulsch_harq->V_UL_DAI, ulsch_harq->nb_rb>20 ? 1 : 0); stop_meas(&eNB->ulsch_decoding_stats); +/* + int ulsch_id=-1; + for (ulsch_id=0;ulsch_idrnti == eNB->ulsch_stats[ulsch_id].rnti) break; + AssertFatal(ulsch_id>=0,"no ulsch_id found\n"); + + if (eNB->ulsch_stats[ulsch_id].round_trials[0]>100) { + dump_ulsch(eNB,frame,subframe,i,ulsch_harq->round); + AssertFatal(1==0,"exiting\n"); + } +*/ } else if ((ulsch) && (ulsch->rnti>0) && @@ -1472,7 +1498,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { ulsch->harq_mask &= ~(1 << harq_pid); LOG_W (PHY, "Removing stale ULSCH config for UE %x harq_pid %d (harq_mask is now 0x%2.2x)\n", ulsch->rnti, harq_pid, ulsch->harq_mask); } - } // for (i=0; inbDecode > 0) { notifiedFIFO_elt_t *req=pullTpool(proc->respDecode, proc->threadPool); @@ -1537,7 +1563,7 @@ void kill_te_thread(PHY_VARS_eNB *eNB) { } void fill_rx_indication(PHY_VARS_eNB *eNB, - int UE_id, + int ULSCH_id, int frame, int subframe) { nfapi_rx_indication_pdu_t *pdu; @@ -1545,7 +1571,7 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, int sync_pos; uint32_t harq_pid; - if (eNB->ulsch[UE_id]->ue_type > 0) harq_pid = 0; + if (eNB->ulsch[ULSCH_id]->ue_type > 0) harq_pid = 0; else { harq_pid = subframe2harq_pid (&eNB->frame_parms, frame, subframe); @@ -1555,19 +1581,22 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, eNB->UL_INFO.rx_ind.sfn_sf = frame<<4| subframe; eNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; pdu = &eNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus]; - // pdu->rx_ue_information.handle = eNB->ulsch[UE_id]->handle; + // pdu->rx_ue_information.handle = eNB->ulsch[ULSCH_id]->handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; + pdu->rx_ue_information.rnti = eNB->ulsch[ULSCH_id]->rnti; pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; - pdu->rx_indication_rel8.length = eNB->ulsch[UE_id]->harq_processes[harq_pid]->TBS>>3; + pdu->rx_indication_rel8.length = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->TBS>>3; pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation - pdu->data = eNB->ulsch[UE_id]->harq_processes[harq_pid]->decodedBytes; + pdu->data = eNB->ulsch[ULSCH_id]->harq_processes[harq_pid]->decodedBytes; // estimate timing advance for MAC - sync_pos = lte_est_timing_advance_pusch(&eNB->frame_parms, eNB->pusch_vars[UE_id]->drs_ch_estimates_time); - timing_advance_update = sync_pos; // - eNB->frame_parms.nb_prefix_samples/4; //to check + sync_pos = lte_est_timing_advance_pusch(&eNB->frame_parms, eNB->pusch_vars[ULSCH_id]->drs_ch_estimates_time); + timing_advance_update = sync_pos; - // if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} - // if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,UE_id); exit(-1);} + for (int i=0;iulsch_stats[i].rnti == eNB->ulsch[ULSCH_id]->rnti) + eNB->ulsch_stats[i].timing_offset = sync_pos; + // if (timing_advance_update > 10) { dump_ulsch(eNB,frame,subframe,ULSCH_id); exit(-1);} + // if (timing_advance_update < -10) { dump_ulsch(eNB,frame,subframe,ULSCH_id); exit(-1);} switch (eNB->frame_parms.N_RB_DL) { case 6: /* nothing to do */ break; @@ -1607,7 +1636,13 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, pdu->rx_indication_rel8.timing_advance = timing_advance_update; // estimate UL_CQI for MAC - int SNRtimes10 = dB_fixed_x10(eNB->pusch_vars[UE_id]->ulsch_power[0] + ((eNB->frame_parms.nb_antennas_rx>1) ?eNB->pusch_vars[UE_id]->ulsch_power[1] : 0 ) ) - dB_fixed_x10(eNB->pusch_vars[UE_id]->ulsch_interference_power[0]+((eNB->frame_parms.nb_antennas_rx>1) ?eNB->pusch_vars[UE_id]->ulsch_interference_power[1] : 0 ) ); + int total_power=0, avg_noise_power=0; + for (int i=0;iframe_parms.nb_antennas_rx;i++) { + total_power+=(eNB->pusch_vars[ULSCH_id]->ulsch_power[i]); + avg_noise_power+=(eNB->pusch_vars[ULSCH_id]->ulsch_noise_power[i])/eNB->frame_parms.nb_antennas_rx; + } + int SNRtimes10 = dB_fixed_x10(total_power) - + dB_fixed_x10(avg_noise_power); if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi = 0; @@ -1616,9 +1651,11 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, else pdu->rx_indication_rel8.ul_cqi = (640 + SNRtimes10) / 5; - LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d,%d), timing_advance %d (update %d)\n", - harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,eNB->measurements.n0_subband_power_avg_dB,pdu->rx_indication_rel8.timing_advance, - timing_advance_update); + LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d,%d,%d), timing_advance %d (update %d,sync_pos %d)\n", + harq_pid,frame,subframe,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,dB_fixed_x10(total_power),dB_fixed_x10(avg_noise_power),pdu->rx_indication_rel8.timing_advance,timing_advance_update,sync_pos); + for (int i=0;iframe_parms.nb_antennas_rx;i++) + LOG_D(PHY,"antenna %d: ulsch_power %d, noise_power %d\n",i,dB_fixed_x10(eNB->pusch_vars[ULSCH_id]->ulsch_power[i]),dB_fixed_x10(eNB->pusch_vars[ULSCH_id]->ulsch_noise_power[i])); + eNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; eNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | subframe; pthread_mutex_unlock(&eNB->UL_INFO_mutex); @@ -1629,7 +1666,7 @@ void fill_rx_indication(PHY_VARS_eNB *eNB, * Release the harq process if its round is >= 'after_rounds' */ static void do_release_harq(PHY_VARS_eNB *eNB, - int UE_id, + int DLSCH_id, int tb, uint16_t frame, uint8_t subframe, @@ -1644,10 +1681,10 @@ static void do_release_harq(PHY_VARS_eNB *eNB, int harq_pid; int subframe_tx; int frame_tx; - AssertFatal(UE_id != -1, "No existing dlsch context\n"); - AssertFatal(UE_id < NUMBER_OF_UE_MAX, "Returned UE_id %d >= %d (NUMBER_OF_UE_MAX)\n", UE_id, NUMBER_OF_UE_MAX); - dlsch0 = eNB->dlsch[UE_id][0]; - dlsch1 = eNB->dlsch[UE_id][1]; + AssertFatal(DLSCH_id != -1, "No existing dlsch context\n"); + AssertFatal(DLSCH_id < NUMBER_OF_DLSCH_MAX, "Returned DLSCH_id %d >= %d (NUMBER_OF_DLSCH_MAX)\n", DLSCH_id, NUMBER_OF_DLSCH_MAX); + dlsch0 = eNB->dlsch[DLSCH_id][0]; + dlsch1 = eNB->dlsch[DLSCH_id][1]; if (eNB->frame_parms.frame_type == FDD) { subframe_tx = (subframe + 6) % 10; @@ -1746,13 +1783,13 @@ static void do_release_harq(PHY_VARS_eNB *eNB, } // end if TDD } -static void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int is_ack) { +static void release_harq(PHY_VARS_eNB *eNB,int DLSCH_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int is_ack) { /* * Maximum number of DL transmissions = 4. * TODO: get the value from configuration. * If is_ack is true then we release immediately. The value -1 can be used for that. */ - do_release_harq(eNB, UE_id, tb, frame, subframe, mask, is_ack ? -1 : 4); + do_release_harq(eNB, DLSCH_id, tb, frame, subframe, mask, is_ack ? -1 : 4); } int getM(PHY_VARS_eNB *eNB,int frame,int subframe) { @@ -1832,14 +1869,14 @@ void fill_ulsch_cqi_indication (PHY_VARS_eNB *eNB, uint16_t frame, uint8_t subfr } void fill_ulsch_harq_indication (PHY_VARS_eNB *eNB, LTE_UL_eNB_HARQ_t *ulsch_harq, uint16_t rnti, int frame, int subframe, int bundling) { - int UE_id = find_dlsch(rnti,eNB,SEARCH_EXIST); + int DLSCH_id = find_dlsch(rnti,eNB,SEARCH_EXIST); - if( (UE_id<0) || (UE_id>=NUMBER_OF_UE_MAX) ) { - LOG_E(PHY,"illegal UE_id found!!! rnti %04x UE_id %d\n",rnti,UE_id); + if( (DLSCH_id<0) || (DLSCH_id>=NUMBER_OF_DLSCH_MAX) ) { + LOG_E(PHY,"illegal DLSCH_id found!!! rnti %04x DLSCH_id %d\n",rnti,DLSCH_id); return; } - //AssertFatal(UE_id>=0,"UE_id doesn't exist\n"); + //AssertFatal(DLSCH_id>=0,"DLSCH_id doesn't exist\n"); pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_harq_indication_pdu_t *pdu = &eNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list[eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs]; int M; @@ -1861,7 +1898,7 @@ void fill_ulsch_harq_indication (PHY_VARS_eNB *eNB, LTE_UL_eNB_HARQ_t *ulsch_har AssertFatal (ulsch_harq->o_ACK[i] == 0 || ulsch_harq->o_ACK[i] == 1, "harq_ack[%d] is %d, should be 1,2 or 4\n", i, ulsch_harq->o_ACK[i]); pdu->harq_indication_fdd_rel13.harq_tb_n[i] = 2 - ulsch_harq->o_ACK[i]; // release DLSCH if needed - release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + release_harq(eNB,DLSCH_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); } } else { // TDD M = ul_ACK_subframe2_M (&eNB->frame_parms, subframe); @@ -1877,14 +1914,14 @@ void fill_ulsch_harq_indication (PHY_VARS_eNB *eNB, LTE_UL_eNB_HARQ_t *ulsch_har * We have to release the proper HARQ in case of ACK or NACK if max retransmission reached. * Basically, call release_harq with 1 as last argument when ACK and 0 when NACK. */ - release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + release_harq(eNB,DLSCH_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); - if (M==1 && ulsch_harq->O_ACK==1 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); - else if (M==1 && ulsch_harq->O_ACK==2 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + if (M==1 && ulsch_harq->O_ACK==1 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + else if (M==1 && ulsch_harq->O_ACK==2 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,DLSCH_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); else if (M>1 && ulsch_harq->o_ACK[i] == 1) { // spatial bundling - release_harq(eNB,UE_id,0,frame,subframe,1<o_ACK[i] == 1); - release_harq(eNB,UE_id,1,frame,subframe,1<o_ACK[i] == 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,1<o_ACK[i] == 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,1<o_ACK[i] == 1); } } } @@ -1900,10 +1937,10 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in return; } - int UE_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST); + int DLSCH_id=find_dlsch(uci->rnti,eNB,SEARCH_EXIST); - //AssertFatal(UE_id>=0,"UE_id doesn't exist rnti:%x\n", uci->rnti); - if (UE_id < 0) { + //AssertFatal(DLSCH_id>=0,"DLSCH_id doesn't exist rnti:%x\n", uci->rnti); + if (DLSCH_id < 0) { LOG_E(PHY,"SFN/SF:%04d%d Unable to find rnti:%x do not send HARQ\n", frame, subframe, uci->rnti); return; } @@ -1943,7 +1980,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in AssertFatal (harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n", harq_ack[0]); pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; // release DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); } else if (uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_fdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_FDD_REL13_TAG; pdu->harq_indication_fdd_rel13.mode = 0; @@ -1953,8 +1990,8 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; pdu->harq_indication_fdd_rel13.harq_tb_n[1] = harq_ack[1]; // release DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); } else AssertFatal(1==0,"only format 1a/b for now, received %d\n",uci->pucch_fmt); } else { // TDD AssertFatal (tdd_mapping_mode == 0 || tdd_mapping_mode == 1 || tdd_mapping_mode == 2, "Illegal tdd_mapping_mode %d\n", tdd_mapping_mode); @@ -1972,7 +2009,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; // release all bundled DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); } else if (uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[1] == 4, "harq_ack[0] is %d, should be 0,1 or 4\n",harq_ack[0]); @@ -1981,8 +2018,8 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = harq_ack[1]; // release all DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); } break; @@ -1996,7 +2033,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; // release all DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); } else if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; @@ -2005,8 +2042,8 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; // release all DLSCH if needed - release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, harq_ack[1] == 1); } else { // num_pucch_resources (M) > 1 pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; pdu->harq_indication_tdd_rel13.number_of_ack_nack = uci->num_pucch_resources; @@ -2018,8 +2055,8 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in if (uci->num_pucch_resources == 4) pdu->harq_indication_tdd_rel13.harq_data[3].multiplex.value_0 = harq_ack[3]; // spatial-bundling in this case so release both HARQ if necessary - release_harq(eNB,UE_id,0,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); - release_harq(eNB,UE_id,1,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); + release_harq(eNB,DLSCH_id,0,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); + release_harq(eNB,DLSCH_id,1,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); } break; @@ -2043,8 +2080,8 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in if (uci->num_pucch_resources == 1 || uci->num_pucch_resources == 4 || tdd_config5_sf2scheds == 1 || tdd_config5_sf2scheds == 4 || tdd_config5_sf2scheds == 7) { pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, 1); } else { pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; } @@ -2055,8 +2092,8 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in if (uci->num_pucch_resources == 2 || tdd_config5_sf2scheds == 2 || tdd_config5_sf2scheds == 5 || tdd_config5_sf2scheds == 8) { pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, 1); } else { pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; } @@ -2067,8 +2104,8 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in if (uci->num_pucch_resources == 3 || tdd_config5_sf2scheds == 3 || tdd_config5_sf2scheds == 6 || tdd_config5_sf2scheds == 9) { pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 1; - release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); - release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); + release_harq(eNB,DLSCH_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,DLSCH_id,1,frame,subframe,0xffff, 1); } else { pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = 0; } @@ -2085,7 +2122,7 @@ void fill_uci_harq_indication (int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, in pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void fill_crc_indication (PHY_VARS_eNB *eNB, int UE_id, int frame, int subframe, uint8_t crc_flag) { +void fill_crc_indication (PHY_VARS_eNB *eNB, int ULSCH_id, int frame, int subframe, uint8_t crc_flag) { pthread_mutex_lock(&eNB->UL_INFO_mutex); nfapi_crc_indication_pdu_t *pdu = &eNB->UL_INFO.crc_ind.crc_indication_body.crc_pdu_list[eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs]; eNB->UL_INFO.crc_ind.sfn_sf = frame<<4 | subframe; @@ -2094,7 +2131,7 @@ void fill_crc_indication (PHY_VARS_eNB *eNB, int UE_id, int frame, int subframe, pdu->instance_length = 0; // don't know what to do with this // pdu->rx_ue_information.handle = handle; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; - pdu->rx_ue_information.rnti = eNB->ulsch[UE_id]->rnti; + pdu->rx_ue_information.rnti = eNB->ulsch[ULSCH_id]->rnti; pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG; pdu->crc_indication_rel8.crc_flag = crc_flag; eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs++; @@ -2133,20 +2170,24 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc) { } lte_eNB_I0_measurements (eNB, subframe, 0, eNB->first_run_I0_measurements); - int min_I0=1000,max_I0=0; - int amin=0,amax=0; - if ((frame==0) && (subframe==3)) { - for (int i=0; iframe_parms.N_RB_UL; i++) { - if (i==(eNB->frame_parms.N_RB_UL>>1) - 1) i+=2; - if (eNB->measurements.n0_subband_power_tot_dB[i]measurements.n0_subband_power_tot_dB[i]; amin=i;} - - if (eNB->measurements.n0_subband_power_tot_dB[i]>max_I0) {max_I0 = eNB->measurements.n0_subband_power_tot_dB[i]; amax=i;} - } - - LOG_I (PHY, "max_I0 %d (rb %d), min_I0 %d (rb %d), avg I0 %d\n", max_I0, amax, min_I0, amin, eNB->measurements.n0_subband_power_avg_dB); + // clear unused statistics after 2 seconds + for (int i=0;iulsch_stats[i].frame <= frame) { + if ((eNB->ulsch_stats[i].frame + 200) < frame) memset(&eNB->ulsch_stats[i],0,sizeof(eNB->ulsch_stats[i])); + } + else { + if (eNB->ulsch_stats[i].frame + 200 < (frame+1024)) memset(&eNB->ulsch_stats[i],0,sizeof(eNB->ulsch_stats[i])); + } + if (eNB->uci_stats[i].frame <= frame) { + if ((eNB->uci_stats[i].frame + 200) < frame) memset(&eNB->uci_stats[i],0,sizeof(eNB->uci_stats[i])); + } + else { + if (eNB->uci_stats[i].frame + 200 < (frame+1024)) memset(&eNB->uci_stats[i],0,sizeof(eNB->uci_stats[i])); + } } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, 0 ); } @@ -2163,13 +2204,7 @@ void release_rnti_of_phy(module_id_t mod_id) { eNB_PHY = RC.eNB[mod_id][CC_id]; rnti = release_rntis.ue_release_request_TLVs_list[i].rnti; - for (j=0; julsch[j]; - - if((ulsch != NULL) && (ulsch->rnti == rnti)) { - LOG_I(PHY, "clean_eNb_ulsch ulsch[%d] UE %x\n", j, rnti); - clean_eNb_ulsch(ulsch); - } + for (j=0; jdlsch[j][0]; @@ -2179,14 +2214,18 @@ void release_rnti_of_phy(module_id_t mod_id) { } } - ulsch = eNB_PHY->ulsch[j]; + for (j=0;julsch[j]; - if((ulsch != NULL) && (ulsch->rnti == rnti)) { - LOG_I(PHY, "clean_eNb_ulsch ulsch[%d] UE %x\n", j, rnti); - clean_eNb_ulsch(ulsch); + if((ulsch != NULL) && (ulsch->rnti == rnti)) { + LOG_I(PHY, "clean_eNb_ulsch ulsch[%d] UE %x\n", j, rnti); + clean_eNb_ulsch(ulsch); + for (j=0;julsch_stats[j].rnti == rnti) {eNB_PHY->ulsch_stats[j].rnti=0; break;} + } } - for(j=0; juci_vars[j].rnti == rnti) { LOG_I(PHY, "clean eNb uci_vars[%d] UE %x \n",j, rnti); memset(&eNB_PHY->uci_vars[i],0,sizeof(LTE_eNB_UCI)); diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index b99bb2ee7d..4d0fe428e8 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -31,8 +31,6 @@ */ #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" -#include "SCHED/sched_eNB.h" #include "nfapi_interface.h" #include "fapi_l1.h" #include "nfapi_pnf.h" @@ -46,7 +44,6 @@ #include -#include "intertask_interface.h" extern int oai_nfapi_rach_ind(nfapi_rach_indication_t *rach_ind); @@ -188,7 +185,7 @@ void prach_procedures(PHY_VARS_eNB *eNB, else { eNB->measurements.prach_I0 = ((eNB->measurements.prach_I0*900)>>10) + ((avg_preamble_energy[0]*124)>>10); - if (frame==0) LOG_I(PHY,"prach_I0 = %d.%d dB\n",eNB->measurements.prach_I0/10,eNB->measurements.prach_I0%10); + if (frame==0) LOG_D(PHY,"prach_I0 = %d.%d dB\n",eNB->measurements.prach_I0/10,eNB->measurements.prach_I0%10); if (eNB->prach_energy_counter < 100) eNB->prach_energy_counter++; } diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 70399f0a23..15eba7b5bc 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -54,7 +54,6 @@ #include "PHY/defs_eNB.h" -#include "PHY/phy_extern.h" #include "SCHED/sched_eNB.h" #include "PHY/MODULATION/modulation_eNB.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" @@ -140,27 +139,26 @@ void feptx0(RU_t *ru, int num_symb = 7; if (subframe_select(fp,subframe) == SF_S) - num_symb = fp->dl_symbols_in_S_subframe+1; + num_symb = fp->dl_symbols_in_S_subframe+1; - if (ru->generate_dmrs_sync == 1 && slot == 0 && subframe == 1 && aa==0) { + if (ru->generate_dmrs_sync == 1 && slot == 2 && aa==0) { //int32_t dmrs[ru->frame_parms.ofdm_symbol_size*14] __attribute__((aligned(32))); //int32_t *dmrsp[2] ={dmrs,NULL}; //{&dmrs[(3-ru->frame_parms.Ncp)*ru->frame_parms.ofdm_symbol_size],NULL}; - - generate_drs_pusch((PHY_VARS_UE *)NULL, - (UE_rxtx_proc_t*)NULL, - fp, - ru->common.txdataF_BF, - 0, - AMP, - 0, - 0, - fp->N_RB_DL, - aa); + generate_drs_pusch((PHY_VARS_UE *)NULL, + (UE_rxtx_proc_t*)NULL, + fp, + ru->common.txdataF_BF, + 0, + AMP, + 0, + 0, + fp->N_RB_DL, + aa); } - normal_prefix_mod(&ru->common.txdataF_BF[aa][(slot&1)*slot_sizeF], - (int*)&ru->common.txdata[aa][slot_offset], - num_symb, - fp); + normal_prefix_mod(&ru->common.txdataF_BF[aa][(slot&1)*slot_sizeF], + (int*)&ru->common.txdata[aa][slot_offset], + num_symb, + fp); } } @@ -474,15 +472,16 @@ void feptx_prec(RU_t *ru, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+ru->idx , 1); for (aa=0;aanb_tx;aa++) { - memset(ru->common.txdataF_BF[aa],0,sizeof(int32_t)*fp->ofdm_symbol_size*fp->symbols_per_tti); - for (int p=0;pdo_precoding == 0) { - if (p==0) - memcpy((void*)ru->common.txdataF_BF[aa], - (void*)&eNB->common_vars.txdataF[aa][subframe*fp->symbols_per_tti*fp->ofdm_symbol_size], - sizeof(int32_t)*fp->ofdm_symbol_size*fp->symbols_per_tti); - } else { - if (pnb_antenna_ports_eNB) { + if (ru->do_precoding == 0) { + memcpy((void*)ru->common.txdataF_BF[aa], + (void*)&eNB->common_vars.txdataF[aa%fp->nb_antenna_ports_eNB][subframe*fp->symbols_per_tti*fp->ofdm_symbol_size], + sizeof(int32_t)*fp->ofdm_symbol_size*fp->symbols_per_tti); + + } + else { + memset(ru->common.txdataF_BF[aa],0,sizeof(int32_t)*fp->ofdm_symbol_size*fp->symbols_per_tti); + for (int p=0;pnb_antenna_ports_eNB) { // For the moment this does nothing different than below, except ignore antenna ports 5,7,8. for (l=0;lnum_pdcch_symbols;l++) beam_precoding(eNB->common_vars.txdataF, @@ -494,10 +493,10 @@ void feptx_prec(RU_t *ru, aa, p, eNB->Mod_id); - } //if (pnb_antenna_ports_eNB) + } //if (pnb_antenna_ports_eNB) // PDSCH region - if (pnb_antenna_ports_eNB || p==5 || p==7 || p==8) { + if (pnb_antenna_ports_eNB || p==5 || p==7 || p==8) { for (l=pdcch_vars->num_pdcch_symbols;lsymbols_per_tti;l++) { beam_precoding(eNB->common_vars.txdataF, ru->common.txdataF_BF, @@ -510,8 +509,8 @@ void feptx_prec(RU_t *ru, eNB->Mod_id); } // for (l=pdcch_vars ....) } // if (pnb_antenna_ports_eNB) ... - } // ru->do_precoding!=0 - } // for (p=0...) + } // for (p=0...) + } // if do_precoding } // for (aa=0 ...) if(ru->idx<2) @@ -658,7 +657,7 @@ void ru_fep_full_2thread(RU_t *ru, struct timespec wait; - if ((fp->frame_type == TDD) && (subframe_select(fp,subframe) != SF_UL)) return; + if ((fp->frame_type == TDD) && (subframe_select(fp,subframe) == SF_DL)) return; if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); @@ -705,7 +704,7 @@ void ru_fep_full_2thread(RU_t *ru, if (proc->tti_rx/*proc->subframe_rx*/==1 && ru->is_slave==1/* && ru->state == RU_CHECK_SYNC*/) { - //LOG_I(PHY,"Running check synchronization procedure for frame %d\n", proc->frame_rx); + LOG_I(PHY,"Running check synchronization procedure for frame %d\n", proc->frame_rx); ulsch_extract_rbs_single(ru->common.rxdataF, calibration->rxdataF_ext, 0, @@ -731,9 +730,10 @@ void ru_fep_full_2thread(RU_t *ru, check_sync_pos = lte_est_timing_advance_pusch(ru->frame_parms, ru->calibration.drs_ch_estimates_time); if (ru->state == RU_CHECK_SYNC) { if ((check_sync_pos >= 0 && check_sync_pos<8) || (check_sync_pos < 0 && check_sync_pos>-8)) { - LOG_I(PHY,"~~~~~~~~~~~ check_sync_pos %d, frame %d, cnt %d\n",check_sync_pos,proc->frame_rx,ru->wait_check); +// LOG_I(PHY,"~~~~~~~~~~~ check_sync_pos %d, frame %d, cnt %d\n",check_sync_pos,proc->frame_rx,ru->wait_check); ru->wait_check++; } + LOG_I(PHY,"~~~~~~~~~~~ check_sync_pos %d, frame %d, cnt %d\n",check_sync_pos,proc->frame_rx,ru->wait_check); if (ru->wait_check==20) { ru->state = RU_RUN; @@ -743,10 +743,11 @@ void ru_fep_full_2thread(RU_t *ru, rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len LOG_I(PHY,"Sending RRU_sync_ok to RAU\n"); AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU %d\n",ru->idx); +/* //LOG_I(PHY,"~~~~~~~~~ RU_RUN\n"); - /*LOG_M("dmrs_time.m","dmrstime",calibration->drs_ch_estimates_time[0], (fp->ofdm_symbol_size),1,1); + LOG_M("dmrs_time.m","dmrstime",calibration->drs_ch_estimates_time[0], (fp->ofdm_symbol_size),1,1); LOG_M("rxdataF_ext.m","rxdataFext",&calibration->rxdataF_ext[0][36*fp->N_RB_DL], 12*(fp->N_RB_DL),1,1); - LOG_M("drs_seq0.m","drsseq0",ul_ref_sigs_rx[0][0][23],600,1,1); + //LOG_M("drs_seq0.m","drsseq0",ul_ref_sigs_rx[0][0][23],600,1,1); LOG_M("rxdata.m","rxdata",&ru->common.rxdata[0][0], fp->samples_per_tti*2,1,1); exit(-1);*/ } diff --git a/openair1/SCHED/sched_common.h b/openair1/SCHED/sched_common.h index f3e43d516e..c9fc338686 100644 --- a/openair1/SCHED/sched_common.h +++ b/openair1/SCHED/sched_common.h @@ -311,7 +311,7 @@ void get_cqipmiri_params(PHY_VARS_UE *ue,uint8_t eNB_id); int8_t get_PHR(uint8_t Mod_id, uint8_t CC_id, uint8_t eNB_index); -void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); +void schedule_response(Sched_Rsp_t *Sched_INFO, void *proc); LTE_eNB_UE_stats* get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti); diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h index f04bec2e5c..de987b0ac7 100644 --- a/openair1/SCHED/sched_eNB.h +++ b/openair1/SCHED/sched_eNB.h @@ -193,7 +193,7 @@ int8_t find_ue_ulsch(uint16_t rnti, PHY_VARS_eNB *phy_vars_eNB); -void schedule_response(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); +void schedule_response(Sched_Rsp_t *Sched_INFO, void *proc); LTE_eNB_UE_stats *get_UE_stats(uint8_t Mod_id, uint8_t CC_id,uint16_t rnti); diff --git a/openair1/SCHED_NR/fapi_nr_l1.c b/openair1/SCHED_NR/fapi_nr_l1.c index 88f3dca070..012e088dff 100644 --- a/openair1/SCHED_NR/fapi_nr_l1.c +++ b/openair1/SCHED_NR/fapi_nr_l1.c @@ -168,7 +168,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){ int pdcch_received=0; gNB->num_pdsch_rnti[slot]=0; - for (int i=0; inumber_of_nr_dlsch_max; i++) { gNB->dlsch[i][0]->rnti=0; gNB->dlsch[i][0]->harq_mask=0; } diff --git a/openair1/SCHED_NR/nr_prach_procedures.c b/openair1/SCHED_NR/nr_prach_procedures.c index 848b11dcde..dfc5376ee7 100644 --- a/openair1/SCHED_NR/nr_prach_procedures.c +++ b/openair1/SCHED_NR/nr_prach_procedures.c @@ -122,8 +122,7 @@ void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot) { max_preamble_delay[0], gNB->prach_energy_counter); - if ((gNB->prach_energy_counter == 100) && - (max_preamble_energy[0] > gNB->measurements.prach_I0+gNB->prach_thres)) { + if ((gNB->prach_energy_counter == 100) && (max_preamble_energy[0] > gNB->measurements.prach_I0+gNB->prach_thres)) { LOG_I(PHY,"[gNB %d][RAPROC] Frame %d, slot %d Initiating RA procedure with preamble %d, energy %d.%d dB (I0 %d, thres %d), delay %d start symbol %u freq index %u\n", gNB->Mod_id, diff --git a/openair1/SCHED_NR/nr_ru_procedures.c b/openair1/SCHED_NR/nr_ru_procedures.c index 1b2baf03f5..c8e047d849 100644 --- a/openair1/SCHED_NR/nr_ru_procedures.c +++ b/openair1/SCHED_NR/nr_ru_procedures.c @@ -31,15 +31,12 @@ */ #include "PHY/defs_gNB.h" -#include "PHY/phy_extern.h" #include "sched_nr.h" #include "PHY/MODULATION/modulation_common.h" #include "PHY/MODULATION/nr_modulation.h" #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" -#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h" -#include "LAYER2/MAC/mac.h" #include "common/utils/LOG/log.h" #include "common/utils/system.h" #include "common/utils/LOG/vcd_signal_dumper.h" @@ -200,18 +197,17 @@ void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+j , 1); start_meas(&ru->txdataF_copy_stats); - if (ru->num_gNB == 1){ - gNB = ru->gNB_list[0]; - cfg = &gNB->gNB_config; + AssertFatal(ru->num_gNB==1,"num_gNB>1, help\n"); + gNB = ru->gNB_list[0]; + cfg = &gNB->gNB_config; - for(i=0; inb_tx; ++i){ - memcpy((void*)&ru->common.txdataF[i][j*fp->ofdm_symbol_size], - (void*)&gNB->common_vars.txdataF[i][j*fp->ofdm_symbol_size + txdataF_offset], - fp->ofdm_symbol_size*sizeof(int32_t)); + for(i=0; inb_tx; ++i){ + memcpy((void*)&ru->common.txdataF[i][j*fp->ofdm_symbol_size], + (void*)&gNB->common_vars.txdataF[i][j*fp->ofdm_symbol_size + txdataF_offset], + fp->ofdm_symbol_size*sizeof(int32_t)); - } + } - }//num_gNB == 1 stop_meas(&ru->txdataF_copy_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+j , 0); @@ -306,20 +302,27 @@ static void *nr_feptx_thread(void *param) { ////////////precoding//////////// VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+feptx->index+1 , 1); - start_meas(&ru->precoding_stats); + if (aa==0 && l==0) start_meas(&ru->precoding_stats); - for(i=0; inb_log_antennas; ++i) { - memcpy((void*) &ru->common.beam_id[i][slot*fp->symbols_per_slot+l], - (void*) &ru->gNB_list[0]->common_vars.beam_id[i][slot*fp->symbols_per_slot+l], - (fp->symbols_per_slot>>1)*sizeof(uint8_t)); + if (ru->do_precoding == 1) { + for(i=0; inb_log_antennas; ++i) { + memcpy((void*) &ru->common.beam_id[i][slot*fp->symbols_per_slot+l], + (void*) &ru->gNB_list[0]->common_vars.beam_id[i][slot*fp->symbols_per_slot+l], + (fp->symbols_per_slot>>1)*sizeof(uint8_t)); + } } - if (ru->nb_tx == 1 && ru->nb_log_antennas == 1) { memcpy((void*)&ru->common.txdataF_BF[0][l*fp->ofdm_symbol_size], (void*)&ru->gNB_list[0]->common_vars.txdataF[0][txdataF_offset + l*fp->ofdm_symbol_size], (fp->samples_per_slot_wCP>>1)*sizeof(int32_t)); } + else if (ru->do_precoding == 0) { + int gNB_tx = ru->gNB_list[0]->frame_parms.nb_antennas_tx; + memcpy((void*)&ru->common.txdataF_BF[aa][l*fp->ofdm_symbol_size], + (void*)&ru->gNB_list[0]->common_vars.txdataF[aa%gNB_tx][txdataF_offset + l*fp->ofdm_symbol_size], + (fp->samples_per_slot_wCP>>1)*sizeof(int32_t)); + } else { bw = ru->beam_weights[0]; for(i=0; isymbols_per_slot>>1; ++i){ @@ -334,13 +337,13 @@ static void *nr_feptx_thread(void *param) { txdataF_offset);//here } } - stop_meas(&ru->precoding_stats); + if (aa==0 && l==0) stop_meas(&ru->precoding_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_PREC+feptx->index+1 , 0); ////////////FEPTX//////////// - start_meas(&ru->ofdm_mod_stats); + if (aa==0 && l==0) start_meas(&ru->ofdm_mod_stats); nr_feptx0(ru,slot,start,fp->symbols_per_slot>>1,aa); - stop_meas(&ru->ofdm_mod_stats); + if (aa==0 && l==0) stop_meas(&ru->ofdm_mod_stats); if (release_thread(&feptx->mutex_feptx,&feptx->instance_cnt_feptx,"NR feptx thread")<0) break; diff --git a/openair1/SCHED_NR/phy_procedures_nr_gNB.c b/openair1/SCHED_NR/phy_procedures_nr_gNB.c index fad1d79dd3..dfe47d75f1 100644 --- a/openair1/SCHED_NR/phy_procedures_nr_gNB.c +++ b/openair1/SCHED_NR/phy_procedures_nr_gNB.c @@ -259,7 +259,6 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req) { LOG_D(PHY, "ULSCH received ok \n"); nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0); - //log_dump(PHY, ulsch_harq->b, 16, LOG_DUMP_CHAR,"gnb pusch rx frame %d %d: ", ulsch_harq->frame, ulsch_harq->slot); } else { LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d) r %d\n", gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, @@ -382,9 +381,9 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int ULSCH LOG_D(PHY, "Estimated timing advance PUSCH is = %d, timing_advance_update is %d \n", sync_pos,timing_advance_update); - // estimate UL_CQI for MAC + // estimate UL_CQI for MAC - int SNRtimes10 = dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot) - + int SNRtimes10 = dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot) - dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot); LOG_D(PHY, "Estimated SNR for PUSCH is = %f dB (ulsch_power %f, noise %f)\n", SNRtimes10/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot)/10.0,dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot)/10.0); @@ -463,7 +462,7 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { } } } - for (int ULSCH_id=0;ULSCH_idnumber_of_nr_ulsch_max;ULSCH_id++) { NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; int harq_pid; NR_UL_gNB_HARQ_t *ulsch_harq; @@ -526,7 +525,7 @@ void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) } -void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { +int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) { /* those variables to log T_GNB_PHY_PUCCH_PUSCH_IQ only when we try to decode */ int pucch_decode_done = 0; int pusch_decode_done = 0; @@ -575,6 +574,10 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) gNB->uci_pdu_list[num_ucis].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); nfapi_nr_uci_pucch_pdu_format_0_1_t *uci_pdu_format0 = &gNB->uci_pdu_list[num_ucis].pucch_pdu_format_0_1; + offset = pucch_pdu->start_symbol_index*gNB->frame_parms.ofdm_symbol_size + (gNB->frame_parms.first_carrier_offset+pucch_pdu->prb_start*12); + power_rxF = signal_energy_nodc(&gNB->common_vars.rxdataF[0][offset],12); + LOG_D(PHY,"frame %d, slot %d: PUCCH signal energy %d\n",frame_rx,slot_rx,power_rxF); + nr_decode_pucch0(gNB, frame_rx, slot_rx, @@ -608,9 +611,10 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) } } - for (int ULSCH_id=0;ULSCH_idnumber_of_nr_ulsch_max;ULSCH_id++) { NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; int harq_pid; + int no_sig; NR_UL_gNB_HARQ_t *ulsch_harq; if ((ulsch) && @@ -656,13 +660,14 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) pusch_decode_done = 1; - uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index; - uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RX_PUSCH,1); start_meas(&gNB->rx_pusch_stats); - for (uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) { - nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid); - } + no_sig = nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, harq_pid); + if (no_sig) { + LOG_D(PHY, "PUSCH not detected in frame %d, slot %d\n", frame_rx, slot_rx); + nr_fill_indication(gNB, frame_rx, slot_rx, ULSCH_id, harq_pid, 1); + return 1; + } gNB->pusch_vars[ULSCH_id]->ulsch_power_tot=0; gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot=0; for (int aarx=0;aarxframe_parms.nb_antennas_rx;aarx++) { @@ -671,7 +676,7 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) gNB->pusch_vars[ULSCH_id]->ulsch_noise_power[aarx]/=num_dmrs; gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot += gNB->pusch_vars[ULSCH_id]->ulsch_noise_power[aarx]; } - if (dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot) < + if (dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_power_tot) < dB_fixed_x10(gNB->pusch_vars[ULSCH_id]->ulsch_noise_power_tot) + gNB->pusch_thres) { NR_gNB_SCH_STATS_t *stats=get_ulsch_stats(gNB,ulsch); @@ -682,7 +687,7 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1); gNB->pusch_vars[ULSCH_id]->DTX=1; if (stats) stats->DTX++; - return; + return 1; } else gNB->pusch_vars[ULSCH_id]->DTX=0; stop_meas(&gNB->rx_pusch_stats); @@ -699,9 +704,14 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) } stop_meas(&gNB->phy_proc_rx); // figure out a better way to choose slot_rx, 19 is ok for a particular TDD configuration with 30kHz SCS + if ((frame_rx&127) == 0 && slot_rx==19) { + LOG_I(PHY, "Number of bad PUCCH received: %lu\n", gNB->bad_pucch); + } + if (pucch_decode_done || pusch_decode_done) { T(T_GNB_PHY_PUCCH_PUSCH_IQ, T_INT(frame_rx), T_INT(slot_rx), T_BUFFER(&gNB->common_vars.rxdataF[0][0], gNB->frame_parms.symbols_per_slot * gNB->frame_parms.ofdm_symbol_size * 4)); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_gNB_UESPEC_RX,0); + return 0; } diff --git a/openair1/SCHED_NR/sched_nr.h b/openair1/SCHED_NR/sched_nr.h index e0cf20d862..5e31c08d38 100644 --- a/openair1/SCHED_NR/sched_nr.h +++ b/openair1/SCHED_NR/sched_nr.h @@ -38,7 +38,7 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_scf_t *cfg, NR_DL_FRAME_PARMS *fp); void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int frame_tx, int slot_tx, int do_meas); void phy_procedures_gNB_common_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); -void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); +int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx); void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot); void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame,int slot,nfapi_nr_dl_tti_ssb_pdu ssb_pdu); void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx); diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 046b79efdc..914de97110 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -115,14 +115,17 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t @param proc Pointer to proc information @param gNB_id Local id of eNB on which to act @param dlsch_parallel use multithreaded dlsch processing + @param txFifo Result fifo if PDSCH is run in parallel */ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - uint8_t dlsch_parallel); + uint8_t dlsch_parallel, + notifiedFIFO_t *txFifo); int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t eNB_id, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); +void processSlotTX(void *arg); #ifdef UE_SLOT_PARALLELISATION void *UE_thread_slot1_dl_processing(void *arg); diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index ee6e4876fc..e445190162 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -130,6 +130,8 @@ int8_t nr_ue_scheduled_response(nr_scheduled_response_t *scheduled_response){ // dlsch0_harq->status not ACTIVE may be due to false retransmission. Reset the // following flag to skip PDSCH procedures in that case. dlsch0->active = 0; + dlsch0_harq->harq_ack.ack = 1; + dlsch0_harq->harq_ack.send_harq_status = 1; } dlsch0_harq->harq_ack.vDAI_DL = dlsch_config_pdu->dai; /* PTRS */ @@ -274,7 +276,7 @@ int8_t nr_ue_phy_config_request(nr_phy_config_t *phy_config){ if(phy_config != NULL) { memcpy(nrUE_config,&phy_config->config_req,sizeof(fapi_nr_config_request_t)); if (PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->UE_mode[0] == NOT_SYNCHED) - PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->UE_mode[0] = PRACH; + PHY_vars_UE_g[phy_config->Mod_id][phy_config->CC_id]->UE_mode[0] = PRACH; } return 0; } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index fdf3f8891d..b79e0da528 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -141,7 +141,7 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, case FAPI_NR_RX_PDU_TYPE_SSB: rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu = ue->pbch_vars[gNB_id]->decoded_output; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.additional_bits = ue->pbch_vars[gNB_id]->xtra_byte; - rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_index = frame_parms->ssb_index; + rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_index = (frame_parms->ssb_index)&0x7; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_length = frame_parms->Lmax; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.cell_id = frame_parms->Nid_cell; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_start_subcarrier = frame_parms->ssb_start_subcarrier; @@ -275,24 +275,8 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, nr_ue_ulsch_procedures(ue, harq_pid, frame_tx, slot_tx, proc->thread_id, gNB_id); } - if (get_softmodem_params()->usim_test==0) { - pucch_procedures_ue_nr(ue, - gNB_id, - proc, - FALSE); - } - - nr_ue_pusch_common_procedures(ue, - slot_tx, - &ue->frame_parms,1); - } - if (ue->UE_mode[gNB_id] > NOT_SYNCHED && ue->UE_mode[gNB_id] < PUSCH) { - nr_ue_prach_procedures(ue, proc, gNB_id); - } - LOG_D(PHY,"****** end TX-Chain (%s) for AbsSubframe %d.%d ******\n", nr_mode_string[ue->UE_mode[gNB_id]],frame_tx, slot_tx); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); #if UE_TIMING_TRACE stop_meas(&ue->phy_proc_tx); @@ -366,7 +350,7 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_IN); - LOG_D(PHY,"[UE %d] Frame %d, Trying PBCH (NidCell %d, gNB_id %d)\n",ue->Mod_id,frame_rx,ue->frame_parms.Nid_cell,gNB_id); + LOG_D(PHY,"[UE %d] Frame %d Slot %d, Trying PBCH (NidCell %d, gNB_id %d)\n",ue->Mod_id,frame_rx,nr_slot_rx,ue->frame_parms.Nid_cell,gNB_id); ret = nr_rx_pbch(ue, proc, ue->pbch_vars[gNB_id], @@ -433,8 +417,13 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, ue->pbch_vars[gNB_id]->pdu_errors++; if (ue->pbch_vars[gNB_id]->pdu_errors_conseq>=100) { - LOG_E(PHY,"More that 100 consecutive PBCH errors! Exiting!\n"); - exit_fun("More that 100 consecutive PBCH errors! Exiting!\n"); + if (get_softmodem_params()->non_stop) { + LOG_E(PHY,"More that 100 consecutive PBCH errors! Going back to Sync mode!\n"); + ue->lost_sync = 1; + } else { + LOG_E(PHY,"More that 100 consecutive PBCH errors! Exiting!\n"); + exit_fun("More that 100 consecutive PBCH errors! Exiting!\n"); + } } } @@ -1616,7 +1605,8 @@ int is_pbch_in_slot(fapi_nr_config_request_t *config, int frame, int slot, NR_DL int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - uint8_t dlsch_parallel + uint8_t dlsch_parallel, + notifiedFIFO_t *txFifo ) { int frame_rx = proc->frame_rx; @@ -1774,6 +1764,13 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, #endif //NR_PDCCH_SCHED + // Start PUSCH processing here. It runs in parallel with PDSCH processing + notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), proc->nr_slot_tx,txFifo,processSlotTX); + nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(newElt); + curMsg->proc = *proc; + curMsg->UE = ue; + pushTpool(&(get_nrUE_params()->Tpool), newElt); + #if UE_TIMING_TRACE start_meas(&ue->generic_stat); #endif @@ -1905,6 +1902,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDSCH_PROC, VCD_FUNCTION_OUT); } + #if UE_TIMING_TRACE start_meas(&ue->generic_stat); #endif @@ -2066,7 +2064,6 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t } else { - nr_prach = nr_ue_get_rach(prach_resources, &ue->prach_vars[0]->prach_pdu, mod_id, ue->CC_id, frame_tx, gNB_id, nr_slot_tx); LOG_D(PHY, "In %s:[%d.%d] getting PRACH resources : %d\n", __FUNCTION__, frame_tx, nr_slot_tx,nr_prach); } diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index c8929449ff..61042ce5fc 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -119,7 +119,7 @@ static const int sequence_cyclic_shift_1_harq_ack_bit_positive_sr[2] /* Sequence cyclic shift */ = { 3, 9 } ; -static float RSRP_meas_mapping_nr[98] +static float RSRP_meas_mapping_nr[98] = { -140, -139, @@ -418,17 +418,12 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ int dmrs_scrambling_id=0,data_scrambling_id=0; NR_UE_MAC_INST_t *mac = get_mac_inst(0); - NR_PUCCH_Resource_t *pucch_resource; + NR_PUCCH_Resource_t *pucch_resource = NULL; uint16_t crnti = mac->crnti; NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; /* update current context */ - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig) - AssertFatal(1==0,"0 > %d.%d csi_MeasConfig is not null\n",frame_tx,nr_slot_tx); int subframe_number = proc->nr_slot_rx / ue->frame_parms.slots_per_subframe; nb_pucch_format_4_in_subframes[subframe_number] = 0; /* reset pucch format 4 counter at current rx position */ @@ -481,41 +476,42 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig&& mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup) { NR_CSI_MeasConfig_t *csi_MeasConfig = mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; - + uint16_t report_slot_csi =csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320; - - //if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){ + + //if (mac->csirc->reportQuantity.choice.ssb_Index_RSRP){ if (report_slot_csi == proc->nr_slot_tx) csi_status = get_csi_nr(mac, ue, gNB_id, &csi_payload); else csi_status = 0; //} - + O_CSI = cqi_status + ri_status + csi_status; - + /* Part - II */ /* if payload is empty or only negative SR -> no pucch transmission */ - - if(O_ACK == 0) { - N_UCI = O_SR + O_CSI; - if ((N_UCI == 0) || ((O_CSI == 0) && (sr_payload == 0))) { /* TS 38.213 9.2.4 UE procedure for reporting SR */ - NR_TST_PHY_PRINTF("PUCCH No feedback AbsSubframe %d.%d \n", frame_tx%1024, nr_slot_tx); - LOG_D(PHY,"PUCCH No feedback AbsSubframe %d.%d \n", frame_tx%1024, nr_slot_tx); - return (FALSE); + + if(O_ACK == 0) { + N_UCI = O_SR + O_CSI; + if ((N_UCI == 0) || ((O_CSI == 0) && (sr_payload == 0))) { /* TS 38.213 9.2.4 UE procedure for reporting SR */ + NR_TST_PHY_PRINTF("PUCCH No feedback AbsSubframe %d.%d \n", frame_tx%1024, nr_slot_tx); + LOG_D(PHY,"PUCCH No feedback AbsSubframe %d.%d \n", frame_tx%1024, nr_slot_tx); + return (FALSE); + } + else { + /* a resource set and a resource should be find according to payload size */ + pucch_resource_set = find_pucch_resource_set( mac, gNB_id, N_UCI); + if (pucch_resource_set != MAX_NB_OF_PUCCH_RESOURCE_SETS) { + pucch_resource_indicator = 0; + /* get the first resource of the set */ + pucch_resource_id = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set]->resourceList.list.array[pucch_resource_indicator][0]; } else { - /* a resource set and a resource should be find according to payload size */ - pucch_resource_set = find_pucch_resource_set( mac, gNB_id, N_UCI); - if (pucch_resource_set != MAX_NB_OF_PUCCH_RESOURCE_SETS) { - pucch_resource_indicator = 0; - pucch_resource_id = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[pucch_resource_set]->resourceList.list.array[pucch_resource_indicator][0]; /* get the first resource of the set */ - } - else { - LOG_W(PHY,"PUCCH no resource set found for CSI at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); - O_CSI = 0; - csi_payload = 0; - } - + LOG_W(PHY,"PUCCH no resource set found for CSI at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); + O_CSI = 0; + csi_payload = 0; + } + if (O_CSI == 0) { /* only SR has to be send */ /* in this case there is no DCI related to PUCCH parameters so pucch resource should be get from sr configuration */ @@ -533,22 +529,9 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ } } - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig) - AssertFatal(1==0,"6 > %d.%d csi_MeasConfig is not null\n",frame_tx,nr_slot_tx); - - - N_UCI = O_SR + O_ACK + O_CSI; + N_UCI = O_SR + O_ACK + O_CSI; if (N_UCI ==0) return(TRUE); - if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig) - AssertFatal(1==0,"5 > %d.%d csi_MeasConfig is not null\n",frame_tx,nr_slot_tx); - /* Part - III */ /* Choice PUCCH format and its related parameters */ pucch_format_nr_t format = pucch_format0_nr; @@ -565,25 +548,25 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ int time_domain_occ = 0; int occ_length = 0; int occ_Index = 0; + int BWPsize = 0; + int BWPstart = INT_MAX; NR_UE_HARQ_STATUS_t *harq_status = &ue->dlsch[proc->thread_id][gNB_id][0]->harq_processes[dl_harq_pid]->harq_ack; - int BWPsize,BWPstart; + if (select_pucch_resource(ue, mac, gNB_id, N_UCI, pucch_resource_indicator, &initial_pucch_id, &pucch_resource_set, &pucch_resource_id, harq_status) == TRUE) { /* use of initial pucch configuration provided by system information 1 */ /***********************************************************************/ if (initial_pucch_id != NB_INITIAL_PUCCH_RESOURCE) { - LOG_I(MAC,"Selecting INITIAL PUCCH Resource\n"); + LOG_D(MAC,"Selecting INITIAL PUCCH Resource\n"); format = initial_pucch_resource[initial_pucch_id].format; starting_symbol_index = initial_pucch_resource[initial_pucch_id].startingSymbolIndex; nb_symbols_total = initial_pucch_resource[initial_pucch_id].nrofSymbols; int N_CS = initial_pucch_resource[initial_pucch_id].nb_CS_indexes; /* see TS 38213 Table 9.2.1-1: PUCCH resource sets before dedicated PUCCH resource configuration */ - BWPsize = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); - BWPstart = NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); + BWPsize = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + BWPstart = NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); int RB_BWP_offset; if (initial_pucch_id == 15) { RB_BWP_offset =BWPsize/4; @@ -617,9 +600,8 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ else if ((pucch_resource_set != MAX_NB_OF_PUCCH_RESOURCE_SETS) && (pucch_resource_id != MAX_NB_OF_PUCCH_RESOURCES)) { /* check that current configuration is supported */ if (mac->cg && - mac->cg->physicalCellGroupConfig && - (mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL || - mac->cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook != 1)) { + mac->cg->physicalCellGroupConfig && + (mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL || mac->cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook != 1)) { LOG_E(PHY,"PUCCH Unsupported cell group configuration : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); return(FALSE); } @@ -634,17 +616,19 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ } NR_PUCCH_Config_t *pucch_Config; if (bwp_id>0 && - mac->ULbwp[bwp_id-1] && - mac->ULbwp[bwp_id-1]->bwp_Dedicated && + mac->ULbwp[bwp_id-1] && + mac->ULbwp[bwp_id-1]->bwp_Dedicated && mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config && - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup) - pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; - else if (bwp_id==0 && - mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup) { + pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup; + BWPsize = NRRIV2BW(mac->ULbwp[bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + BWPstart = NRRIV2PRBOFFSET(mac->ULbwp[bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE); + } else if (bwp_id==0 && + mac->cg && + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; @@ -699,9 +683,6 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ int O_CRC = 0; nb_symbols = nb_symbols_total; /* by default, it can be reduced due to symbols reserved for dmrs */ - pucch_resource = format>1 ? - mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList->list.array[pucch_resource_id]: - 0; switch(format) { case pucch_format0_nr: @@ -880,26 +861,26 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ case pucch_format0_nr: { int pucch_GroupHopping = mac->ULbwp[bwp_id-1] ? - mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup->pucch_GroupHopping: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup->pucch_GroupHopping; + mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup->pucch_GroupHopping: + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup->pucch_GroupHopping; int hoppingId = mac->ULbwp[bwp_id-1] ? - mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup->hoppingId[0]: - (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup->hoppingId? - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup->hoppingId[0]: - mac->physCellId); + mac->ULbwp[bwp_id-1]->bwp_Common->pucch_ConfigCommon->choice.setup->hoppingId[0]: + (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup->hoppingId? + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pucch_ConfigCommon->choice.setup->hoppingId[0]: + mac->physCellId); nr_generate_pucch0(ue,ue->common_vars.txdataF, - &ue->frame_parms, - pucch_GroupHopping, - hoppingId, - tx_amp, - nr_slot_tx, - (uint8_t)m_0, - (uint8_t)m_CS, - nb_symbols_total, - starting_symbol_index, - startingPRB, - secondHopPRB - ); + &ue->frame_parms, + pucch_GroupHopping, + hoppingId, + tx_amp, + nr_slot_tx, + (uint8_t)m_0, + (uint8_t)m_CS, + nb_symbols_total, + starting_symbol_index, + startingPRB, + secondHopPRB + ); break; } case pucch_format1_nr: @@ -1010,8 +991,6 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t int V_DAI_m_DL = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(0); - - if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Dedicated && mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && @@ -1093,8 +1072,8 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t U_DAI_c = number_harq_feedback/number_of_code_word; N_m_c_rx = number_harq_feedback; int N_SPS_c = 0; /* FFS TODO_NR multicells and SPS are not supported at the moment */ - if (mac->cg != NULL && - mac->cg->physicalCellGroupConfig != NULL && + if (mac->cg != NULL && + mac->cg->physicalCellGroupConfig != NULL && mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL) { int N_TB_max_DL = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI[0]; *n_HARQ_ACK = (((V_DAI_m_DL - U_DAI_c)%4) * N_TB_max_DL) + N_m_c_rx + N_SPS_c; @@ -1200,7 +1179,7 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, NR_UE_MAC_INST_t *mac, uint8 int current_resource_id = MAX_NB_OF_PUCCH_RESOURCES; pucch_format_nr_t format_pucch; int ready_pucch_resource_id = FALSE; /* in the case that it is already given */ - NR_PUCCH_Resource_t *pucch_resource; + NR_PUCCH_Resource_t *pucch_resource = NULL; NR_BWP_Id_t bwp_id = mac->UL_BWP_Id; /* ini values to unset */ @@ -1288,17 +1267,17 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, NR_UE_MAC_INST_t *mac, uint8 } if (resource_set_found == TRUE) { + if (pucch_resource_indicator < MAX_PUCCH_RESOURCE_INDICATOR) { // Verify that the value of pucch_resource_indicator is valid - struct NR_PUCCH_Config__resourceSetToAddModList *resourceSetToAddModList; - struct NR_PUCCH_Config__resourceToAddModList *resourceToAddModList; + struct NR_PUCCH_Config__resourceSetToAddModList *resourceSetToAddModList = NULL; + struct NR_PUCCH_Config__resourceToAddModList *resourceToAddModList = NULL; if (bwp_id > 0 && mac->ULbwp[bwp_id-1]) { AssertFatal(mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList!=NULL,"mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList is null\n"); resourceSetToAddModList = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList; resourceToAddModList = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList; - } - else if (bwp_id == 0 && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList!=NULL) { - resourceSetToAddModList = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList; + } else if (bwp_id == 0 && mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList!=NULL) { + resourceSetToAddModList = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceSetToAddModList; resourceToAddModList = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup->resourceToAddModList; } if (resourceSetToAddModList->list.array[pucch_resource_set_id]->resourceList.list.count <= pucch_resource_indicator) @@ -1335,15 +1314,18 @@ boolean_t select_pucch_resource(PHY_VARS_NR_UE *ue, NR_UE_MAC_INST_t *mac, uint8 current_resource_id = r_PUCCH; } else { - current_resource_id = resourceSetToAddModList->list.array[pucch_resource_set_id]->resourceList.list.array[pucch_resource_indicator][0]; + current_resource_id = resourceSetToAddModList->list.array[pucch_resource_set_id]->resourceList.list.array[pucch_resource_indicator][0]; } } - pucch_resource = resourceToAddModList->list.array[current_resource_id]; + uint8_t pucch_resource_count = resourceToAddModList->list.count; + for (uint8_t i=0; ilist.array[i]->pucch_ResourceId == current_resource_id) + pucch_resource = resourceToAddModList->list.array[i]; + } if (pucch_resource != NULL) { - format_pucch = resourceToAddModList->list.array[current_resource_id]->format.present; + format_pucch = pucch_resource->format.present; nb_symbols_for_tx = get_nb_symbols_pucch(pucch_resource, format_pucch); - if (check_pucch_format(mac, gNB_id, format_pucch, nb_symbols_for_tx, uci_size) == TRUE) { *resource_set_id = pucch_resource_set_id; *resource_id = current_resource_id; diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 8955454282..adfda7a0c8 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -60,7 +60,7 @@ #include "dummy_functions.c" #include "executables/thread-common.h" #include "executables/split_headers.h" - +#include "common/ran_context.h" void feptx_ofdm(RU_t *ru, int frame, int subframe); void feptx_prec(RU_t *ru, int frame, int subframe); @@ -85,6 +85,7 @@ double DS_TDL = .03; static int cmpdouble(const void *p1, const void *p2) { return *(double *)p1 > *(double *)p2; } +RAN_CONTEXT_t RC; int emulate_rf = 0; int split73=0; @@ -936,9 +937,10 @@ int main(int argc, char **argv) { NB_RB = conv_nprb(0,DLSCH_RB_ALLOC,N_RB_DL); } else { - if (rballocset==0) NB_RB = 8; + if (rballocset==0) NB_RB = 2+TPC; else NB_RB = DLSCH_RB_ALLOC; + printf("Common PDSCH: NB_RB = %d\n",NB_RB); AssertFatal(NB_RB <= N_RB_DL,"illegal NB_RB %d\n",NB_RB); } diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index c6049bc31d..0d39e6e533 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -55,6 +55,8 @@ #include "executables/thread-common.h" #include "targets/RT/USER/lte-softmodem.h" #include "executables/split_headers.h" +#include "common/ran_context.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" double cpuf; #define inMicroS(a) (((double)(a))/(get_cpu_freq_GHz()*1000.0)) @@ -87,7 +89,7 @@ static int cmpdouble(const void *p1, const void *p2) { return *(double *)p1 > *(double *)p2; } - +RAN_CONTEXT_t RC; int split73=0; void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { AssertFatal(false, "Must not be called in this context\n"); @@ -345,7 +347,6 @@ int main(int argc, char **argv) { int UE_id = 0; static int nb_rb=25,first_rb=0,mcs=0,round=0; //unsigned char l; - static int awgn_flag = 0 ; SCM_t channel_model=Rice1; unsigned char *input_buffer=0,harq_pid; unsigned short input_buffer_length; @@ -407,7 +408,7 @@ int main(int argc, char **argv) { printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz); AssertFatal(load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) != NULL, "Cannot load configuration module, exiting\n"); logInit(); - set_glog(OAILOG_WARNING); + set_glog(OAILOG_INFO); T_stdout = 1; // enable these lines if you need debug info // however itti will catch all signals, so ctrl-c won't work anymore @@ -1089,14 +1090,12 @@ int main(int argc, char **argv) { } } - if (awgn_flag == 0) { - if (UE2eNB->max_Doppler == 0) { - multipath_channel(UE2eNB,s_re,s_im,r_re,r_im, - eNB->frame_parms.samples_per_tti,hold_channel,0); - } else { - multipath_tv_channel(UE2eNB,s_re,s_im,r_re,r_im, - 2*eNB->frame_parms.samples_per_tti,hold_channel); - } + if (UE2eNB->max_Doppler == 0) { + multipath_channel(UE2eNB,s_re,s_im,r_re,r_im, + eNB->frame_parms.samples_per_tti,hold_channel,0); + } else { + multipath_tv_channel(UE2eNB,s_re,s_im,r_re,r_im, + 2*eNB->frame_parms.samples_per_tti,hold_channel); } if(abstx) { @@ -1139,6 +1138,15 @@ int main(int argc, char **argv) { sqrt(sigma2/2)*gaussdouble(0.0,1.0)); } } + if (n_frames==1) + for (i=0; iframe_parms.samples_per_tti; i++) { + for (aa=0; aaframe_parms.nb_antennas_rx; aa++) { + ((short *) &ru->common.rxdata[aa][eNB->frame_parms.samples_per_tti*(subframe+1)%10])[2*i] = + (short) (sqrt(sigma2/2)*gaussdouble(0.0,1.0)); + ((short *) &ru->common.rxdata[aa][eNB->frame_parms.samples_per_tti*(subframe+1)%10])[2*i+1] = + (short) (sqrt(sigma2/2)*gaussdouble(0.0,1.0)); + } + } if (n_frames<=10) { printf("rx_level Null symbol %f\n",10*log10((double)signal_energy((int *) @@ -1164,9 +1172,10 @@ int main(int argc, char **argv) { start_meas(&eNB->phy_proc_rx); ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full; ru->feprx(ru,subframe); + if (n_frames==1) lte_eNB_I0_measurements(eNB,(subframe+1)%10,0,1); + phy_procedures_eNB_uespec_RX(eNB,proc_rxtx); stop_meas(&eNB->phy_proc_rx); - if (cqi_flag > 0) { cqi_error = 0; @@ -1206,6 +1215,9 @@ int main(int argc, char **argv) { eNB->ulsch[0]->harq_processes[harq_pid]->uci_format,0,eNB->frame_parms.N_RB_DL); dump_ulsch(eNB,eNB->proc.frame_rx,subframe,0,round); + dump_I0_stats(stdout,eNB); + dump_ulsch_stats(stdout,eNB,0); + exit(-1); } @@ -1266,14 +1278,16 @@ int main(int argc, char **argv) { if (t_rx > 2000 ) n_rx_dropped++; - appendVarArray(table_tx, &t_tx); - appendVarArray(table_tx_ifft, &t_tx_ifft); - appendVarArray(table_tx_mod, &t_tx_mod ); - appendVarArray(table_tx_enc, &t_tx_enc ); - appendVarArray(table_rx, &t_rx ); - appendVarArray(table_rx_fft, &t_rx_fft ); - appendVarArray(table_rx_demod, &t_rx_demod ); - appendVarArray(table_rx_dec, &t_rx_dec ); + if (trials < 1000) { + appendVarArray(table_tx, &t_tx); + appendVarArray(table_tx_ifft, &t_tx_ifft); + appendVarArray(table_tx_mod, &t_tx_mod ); + appendVarArray(table_tx_enc, &t_tx_enc ); + appendVarArray(table_rx, &t_rx ); + appendVarArray(table_rx_fft, &t_rx_fft ); + appendVarArray(table_rx_demod, &t_rx_demod ); + appendVarArray(table_rx_dec, &t_rx_dec ); + } } //trials // sort table @@ -1292,6 +1306,7 @@ int main(int argc, char **argv) { LOG_UDUMPMSG(SIM,dataArray(table_rx),table_rx->size,LOG_DUMP_DOUBLE,"The receiver raw data: \n"); } + dump_ulsch_stats(stdout,eNB,0); printf("\n**********rb: %d ***mcs : %d *********SNR = %f dB (%f): TX %u dB (gain %f dB), N0W %f dB, I0 %u dB, delta_IF %d [ (%d,%d) dB / (%u,%u) dB ]**************************\n", nb_rb,mcs,SNR,SNR2, tx_lev_dB, diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 12b0b1d1f0..633a214699 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -357,7 +357,7 @@ int main(int argc, char **argv) frame_parms->Ncp = extended_prefix_flag ? EXTENDED : NORMAL; crcTableInit(); nr_phy_config_request_sim(gNB, N_RB_DL, N_RB_DL, mu, Nid_cell,SSB_positions); - phy_init_nr_gNB(gNB, 0, 0); + phy_init_nr_gNB(gNB, 0, 1); //lowmem //init_eNB_afterRU(); frame_length_complex_samples = frame_parms->samples_per_subframe; //frame_length_complex_samples_no_prefix = frame_parms->samples_per_subframe_wCP; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index fa1d7a4615..d604c302fd 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -69,6 +69,8 @@ #include #include +#include + LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; rlc_info_t Rlc_info_um,Rlc_info_am_config; @@ -86,7 +88,7 @@ uint64_t downlink_frequency[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; msc_interface_t msc_interface; - +uint32_t N_RB_DL = 106; // dummy functions int dummy_nr_ue_ul_indication(nr_uplink_indication_t *ul_info) { return(0); } @@ -129,6 +131,12 @@ rrc_data_ind( { } +int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, + const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, + gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { + return 0; +} + int gtpv1u_create_s1u_tunnel( const instance_t instanceP, @@ -164,6 +172,10 @@ gtpv1u_update_ngu_tunnel( return 0; } +int ocp_gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) { + return 0; +} + int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( const protocol_ctxt_t *const ctxt_pP, @@ -202,6 +214,19 @@ int is_x2ap_enabled(void) return 0; } +int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, + int CC_idP, + int UE_id, + rnti_t rntiP, + const uint8_t *sduP, + sdu_size_t sdu_lenP, + const uint8_t *sdu2P, + sdu_size_t sdu2_lenP) { + return 0; +} + +void processSlotTX(void *arg) {} + //nFAPI P7 dummy functions int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0); } @@ -213,7 +238,7 @@ int oai_nfapi_ul_tti_req(nfapi_nr_ul_tti_request_t *ul_tti_req){ return(0); } openair0_config_t openair0_cfg[MAX_CARDS]; void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSize, uint8_t *mcsIndex,int8_t *ptrs_arg); void update_dmrs_config(NR_CellGroupConfig_t *scg,PHY_VARS_NR_UE *ue, int8_t* dmrs_arg); -extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration +extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration /* specific dlsim DL preprocessor: uses rbStart/rbSize/mcs from command line of dlsim, does not search for CCE/PUCCH occasion but simply sets to 0 */ @@ -224,26 +249,50 @@ void nr_dlsim_preprocessor(module_id_t module_id, NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; AssertFatal(UE_info->num_UEs == 1, "can have only a single UE\n"); NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[0]; + NR_ServingCellConfigCommon_t *scc = RC.nrmac[0]->common_channels[0].ServingCellConfigCommon; /* manually set free CCE to 0 */ const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp, target_ss); + sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); uint8_t nr_of_candidates; find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space); - sched_ctrl->coreset = get_coreset( - sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); + sched_ctrl->coreset = get_coreset(scc, sched_ctrl->active_bwp, sched_ctrl->search_space, target_ss); sched_ctrl->cce_index = 0; - sched_ctrl->rbStart = g_rbStart; - sched_ctrl->rbSize = g_rbSize; - sched_ctrl->mcs = g_mcsIndex; - sched_ctrl->time_domain_allocation = 2; - sched_ctrl->mcsTableIdx = g_mcsTableIdx; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; + + nr_set_pdsch_semi_static(scc, + UE_info->CellGroup[0], + sched_ctrl->active_bwp, + /* tda = */ 2, + /* num_dmrs_cdm_grps_no_data = */ 1, + ps); + + NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; + sched_pdsch->rbStart = g_rbStart; + sched_pdsch->rbSize = g_rbSize; + sched_pdsch->mcs = g_mcsIndex; + /* the following might override the table that is mandated by RRC + * configuration */ + ps->mcsTableIdx = g_mcsTableIdx; + + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, + sched_pdsch->R, + sched_pdsch->rbSize, + ps->nrOfSymbols, + ps->N_PRB_DMRS * ps->N_DMRS_SLOT, + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; + /* the simulator assumes the HARQ PID is equal to the slot number */ - sched_ctrl->dl_harq_pid = slot; + sched_pdsch->dl_harq_pid = slot; + /* The scheduler uses lists to track whether a HARQ process is * free/busy/awaiting retransmission, and updates the HARQ process states. * However, in the simulation, we never get ack or nack for any HARQ process, @@ -256,13 +305,26 @@ void nr_dlsim_preprocessor(module_id_t module_id, else add_front_nr_list(&sched_ctrl->retrans_dl_harq, slot); // ... make PID retransmission sched_ctrl->harq_processes[slot].is_waiting = false; - AssertFatal(sched_ctrl->rbStart >= 0, "invalid rbStart %d\n", sched_ctrl->rbStart); - AssertFatal(sched_ctrl->rbSize > 0, "invalid rbSize %d\n", sched_ctrl->rbSize); - AssertFatal(sched_ctrl->mcs >= 0, "invalid sched_ctrl->mcs %d\n", sched_ctrl->mcs); - AssertFatal(sched_ctrl->mcsTableIdx >= 0 && sched_ctrl->mcsTableIdx <= 2, "invalid sched_ctrl->mcsTableIdx %d\n", sched_ctrl->mcsTableIdx); - sched_ctrl->numDmrsCdmGrpsNoData = 1; + AssertFatal(sched_pdsch->rbStart >= 0, "invalid rbStart %d\n", sched_pdsch->rbStart); + AssertFatal(sched_pdsch->rbSize > 0, "invalid rbSize %d\n", sched_pdsch->rbSize); + AssertFatal(sched_pdsch->mcs >= 0, "invalid mcs %d\n", sched_pdsch->mcs); + AssertFatal(ps->mcsTableIdx >= 0 && ps->mcsTableIdx <= 2, "invalid mcsTableIdx %d\n", ps->mcsTableIdx); } +typedef struct { + uint64_t optmask; //mask to store boolean config options + uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization + tpool_t Tpool; // thread pool +} nrUE_params_t; + +nrUE_params_t nrUE_params; + +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} + +void do_nothing(void *args) { +} int main(int argc, char **argv) { @@ -326,8 +388,6 @@ int main(int argc, char **argv) NR_UE_MAC_INST_t *UE_mac; int cyclic_prefix_type = NFAPI_CP_NORMAL; int run_initial_sync=0; - int pusch_tgt_snrx10 = 200; - int pucch_tgt_snrx10 = 200; int loglvl=OAILOG_INFO; //float target_error_rate = 0.01; @@ -635,7 +695,6 @@ int main(int argc, char **argv) RC.nb_nr_mac_CC[i] = 1; mac_top_init_gNB(); gNB_mac = RC.nrmac[0]; - gNB_mac->pre_processor_dl = nr_dlsim_preprocessor; gNB_RRC_INST rrc; memset((void*)&rrc,0,sizeof(rrc)); @@ -695,13 +754,7 @@ int main(int argc, char **argv) prepare_scd(scd); - fill_default_secondaryCellGroup(scc, - scd, - secondaryCellGroup, - 0, - 1, - n_tx, - 0); + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 0, 0); /* RRC parameter validation for secondaryCellGroup */ fix_scd(scd); @@ -720,10 +773,13 @@ int main(int argc, char **argv) AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface"); gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - rrc_mac_config_req_gNB(0,0,n_tx,1,pusch_tgt_snrx10,pucch_tgt_snrx10,scc,0,0,NULL); + rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0,n_tx,1,pusch_tgt_snrx10,pucch_tgt_snrx10,NULL,1,secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); - phy_init_nr_gNB(gNB,0,0); + rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + // reset preprocessor to the one of DLSIM after it has been set during + // rrc_mac_config_req_gNB + gNB_mac->pre_processor_dl = nr_dlsim_preprocessor; + phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; NR_UE_info_t *UE_info = &RC.nrmac[0]->UE_info; UE_info->num_UEs=1; @@ -860,6 +916,7 @@ int main(int argc, char **argv) unsigned int errors_bit = 0; uint32_t errors_scrambling = 0; + initTpool("N", &(nrUE_params.Tpool), false); test_input_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); estimated_output_bit = (unsigned char *) malloc16(sizeof(unsigned char) * 16 * 68 * 384); @@ -874,7 +931,7 @@ int main(int argc, char **argv) rrc.carrier.MIB = (uint8_t*) malloc(4); rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0); - nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib,NULL,secondaryCellGroup); + nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup); nr_dcireq_t dcireq; @@ -1110,7 +1167,8 @@ int main(int argc, char **argv) phy_procedures_nrUE_RX(UE, &UE_proc, 0, - dlsch_threads); + dlsch_threads, + NULL); //printf("dlsim round %d ends\n",round); round++; @@ -1365,15 +1423,62 @@ void update_dmrs_config(NR_CellGroupConfig_t *scg,PHY_VARS_NR_UE *ue, int8_t* dm } else if (dmrs_arg[0] == 1) { mapping_type = typeB; + } else { + AssertFatal(1==0,"Incorrect Mappingtype, valid options 0-typeA, 1-typeB\n"); } - /* Additional DMRS positions 0 ,1 and 2 */ - if(dmrs_arg[1] >= 0 && dmrs_arg[1] <3 ) { + + /* Additional DMRS positions 0 ,1 ,2 and 3 */ + if(dmrs_arg[1] >= 0 && dmrs_arg[1] <4 ) { add_pos = dmrs_arg[1]; + } else { + AssertFatal(1==0,"Incorrect Additional Position, valid options 0-pos1, 1-pos1, 2-pos2, 3-pos3\n"); } if(scg != NULL) { NR_BWP_Downlink_t *bwp = scg->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[0]; - *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = add_pos; + + AssertFatal((bwp->bwp_Dedicated->pdsch_Config != NULL && bwp->bwp_Dedicated->pdsch_Config->choice.setup != NULL), "Base RRC reconfig structures are not allocated.\n"); + + if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA == NULL) { + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL;//calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NULL; + printf("DLSIM: Allocated Mapping TypeA in RRC reconfig message\n"); + } else if (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB == NULL) { + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_Type=NULL;//calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type)); + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->maxLength=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->scramblingID0=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->scramblingID1=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->phaseTrackingRS=NULL; + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup->dmrs_AdditionalPosition = NULL; + printf("DLSIM: Allocated Mapping TypeB in RRC reconfig message\n"); + } + + struct NR_SetupRelease_DMRS_DownlinkConfig *dmrs_MappingtypeA = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA; + struct NR_SetupRelease_DMRS_DownlinkConfig *dmrs_MappingtypeB = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeB; + + + NR_DMRS_DownlinkConfig_t *dmrs_config = (mapping_type == typeA) ? dmrs_MappingtypeA->choice.setup : dmrs_MappingtypeB->choice.setup; + + if (add_pos != 2) { // pos0,pos1,pos3 + if (dmrs_config->dmrs_AdditionalPosition == NULL) { + dmrs_config->dmrs_AdditionalPosition = calloc(1,sizeof(*dmrs_MappingtypeA->choice.setup->dmrs_AdditionalPosition)); + } + *dmrs_config->dmrs_AdditionalPosition = add_pos; + } else { // if NULL, Value pos2 + free(dmrs_config->dmrs_AdditionalPosition); + dmrs_config->dmrs_AdditionalPosition = NULL; + } + for (int i=0;ibwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) { bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType = mapping_type; } diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index 32b6b10412..24ed8a930c 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -1,3 +1,5 @@ +#include "nfapi/oai_integration/vendor_ext.h" + int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0); } int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); } int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { return(0); } diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 3e1b37ac61..c26b80de5a 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -47,7 +47,7 @@ #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" #include "openair1/PHY/MODULATION/nr_modulation.h" - +#include //#define DEBUG_NR_PBCHSIM PHY_VARS_gNB *gNB; @@ -70,6 +70,31 @@ softmodem_params_t *get_softmodem_params(void) {return 0;} void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) {} +int nr_ue_pdcch_procedures(uint8_t gNB_id, + PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + int n_ss) { + return 0; +} + +int nr_ue_pdsch_procedures(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + int eNB_id, PDSCH_t pdsch, + NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch1) { + return 0; +} + +bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, + UE_nr_rxtx_proc_t *proc, + int gNB_id, + PDSCH_t pdsch, + NR_UE_DLSCH_t *dlsch0, + NR_UE_DLSCH_t *dlsch1, + int *dlsch_errors, + uint8_t dlsch_parallel) { + return false; +} + void nr_phy_config_request_sim_pbchsim(PHY_VARS_gNB *gNB, int N_RB_DL, int N_RB_UL, @@ -415,7 +440,7 @@ int main(int argc, char **argv) frame_parms->ssb_type = nr_ssb_type_C; nr_phy_config_request_sim_pbchsim(gNB,N_RB_DL,N_RB_DL,mu,Nid_cell,SSB_positions); - phy_init_nr_gNB(gNB,0,0); + phy_init_nr_gNB(gNB,0,1); nr_set_ssb_first_subcarrier(&gNB->gNB_config,frame_parms); uint8_t n_hf = 0; diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 26c1518188..7192d4126a 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -48,10 +48,10 @@ #include "OCG_vars.h" #include #include +#include #include //#include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" - #define NR_PRACH_DEBUG 1 #define PRACH_WRITE_OUTPUT_DEBUG 1 @@ -66,8 +66,11 @@ double cpuf; extern uint16_t prach_root_sequence_map0_3[838]; openair0_config_t openair0_cfg[MAX_CARDS]; //uint8_t nfapi_mode=0; +uint64_t downlink_frequency[MAX_NUM_CCs][4]; +int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; uint16_t sl_ahead = 0; msc_interface_t msc_interface; +uint32_t N_RB_DL = 106; //void dump_nr_prach_config(NR_DL_FRAME_PARMS *frame_parms,uint8_t subframe); @@ -90,6 +93,12 @@ rrc_data_ind( { } +int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, + const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, + gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { + return 0; +} + int gtpv1u_create_s1u_tunnel( const instance_t instanceP, @@ -125,6 +134,10 @@ gtpv1u_update_ngu_tunnel( return 0; } +int ocp_gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) { + return 0; +} + int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( const protocol_ctxt_t *const ctxt_pP, @@ -174,6 +187,31 @@ int nr_derive_key(int alg_type, uint8_t alg_id, return 0; } +int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, + int CC_idP, + int UE_id, + rnti_t rntiP, + const uint8_t *sduP, + sdu_size_t sdu_lenP, + const uint8_t *sdu2P, + sdu_size_t sdu2_lenP) { + return 0; +} + +typedef struct { + uint64_t optmask; //mask to store boolean config options + uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization + tpool_t Tpool; // thread pool +} nrUE_params_t; + +nrUE_params_t nrUE_params; + +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} + +void processSlotTX(void *arg) {} + int main(int argc, char **argv){ char c; @@ -508,7 +546,8 @@ int main(int argc, char **argv){ ru->if_south = LOCAL_RF; ru->nb_tx = n_tx; ru->nb_rx = n_rx; - + ru->num_gNB = 1; + ru->gNB_list[0] = gNB; gNB->gNB_config.carrier_config.num_tx_ant.value = 1; gNB->gNB_config.carrier_config.num_rx_ant.value = 1; if (mu==1) @@ -609,7 +648,7 @@ int main(int argc, char **argv){ memcpy((void*)&ru->config,(void*)&RC.gNB[0]->gNB_config,sizeof(ru->config)); RC.nb_nr_L1_inst=1; - phy_init_nr_gNB(gNB,0,0); + phy_init_nr_gNB(gNB,0,1); //lowmem nr_phy_init_RU(ru); gNB->common_vars.rxdata = ru->common.rxdata; set_tdd_config_nr(&gNB->gNB_config, mu, 7, 6, 2, 4); diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 4cef1213c9..9c5fa5b8c9 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -46,6 +46,7 @@ #include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" #include "openair1/SIMULATION/NR_PHY/nr_dummy_functions.c" + PHY_VARS_gNB *gNB; PHY_VARS_NR_UE *UE; RAN_CONTEXT_t RC; @@ -91,6 +92,7 @@ int main(int argc, char **argv) //uint8_t nacktoack_flag=0; int16_t amp=0x7FFF; int nr_slot_tx=0; + int nr_frame_tx=0; uint64_t actual_payload=0,payload_received; int nr_bit=1; // maximum value possible is 2 uint8_t m0=0;// higher layer paramater initial cyclic shift @@ -501,13 +503,13 @@ int main(int argc, char **argv) for (trial=0; trialofdm_symbol_size*sizeof(int)); if(format==0){ - nr_generate_pucch0(UE,txdataF,frame_parms,PUCCH_GroupHopping,hopping_id,amp,nr_slot_tx,m0,mcs,nrofSymbols,startingSymbolIndex,startingPRB); + nr_generate_pucch0(UE,txdataF,frame_parms,PUCCH_GroupHopping,hopping_id,amp,nr_slot_tx,m0,mcs,nrofSymbols,startingSymbolIndex,startingPRB, 0); } else if (format == 1){ nr_generate_pucch1(UE,txdataF,frame_parms,UE->pucch_config_dedicated,actual_payload,amp,nr_slot_tx,m0,nrofSymbols,startingSymbolIndex,startingPRB,startingPRB_intraSlotHopping,0,nr_bit); } else { - nr_generate_pucch2(UE,0x1234,dmrs_scrambling_id,data_scrambling_id,txdataF,frame_parms,UE->pucch_config_dedicated,actual_payload,amp,nr_slot_tx,nrofSymbols,startingSymbolIndex,nrofPRB,startingPRB,nr_bit); + nr_generate_pucch2(UE,0x1234,dmrs_scrambling_id,data_scrambling_id,txdataF,frame_parms,UE->pucch_config_dedicated,actual_payload,amp,nr_slot_tx,nrofSymbols,startingSymbolIndex,nrofPRB,startingPRB,nr_bit); } int txlev = signal_energy(&txdataF[aa][startingSymbolIndex*frame_parms->ofdm_symbol_size], @@ -532,7 +534,7 @@ int main(int argc, char **argv) int rb2 = rb+startingPRB; gNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); } - gNB_I0_measurements(gNB); + gNB_I0_measurements(gNB, startingSymbolIndex, nrofSymbols); if (n_trials==1) printf("rxlev %d (%d dB), sigma2 %f dB, SNR %f, TX %f\n",rxlev,dB_fixed(rxlev),sigma2_dB,SNR,10*log10((double)txlev*UE->frame_parms.ofdm_symbol_size/12)); if(format==0){ @@ -550,7 +552,9 @@ int main(int argc, char **argv) pucch_pdu.initial_cyclic_shift = 0; pucch_pdu.start_symbol_index = startingSymbolIndex; pucch_pdu.prb_start = startingPRB; - nr_decode_pucch0(gNB,nr_slot_tx,&uci_pdu,&pucch_pdu); + pucch_pdu.bwp_start = 0; + pucch_pdu.freq_hop_flag = 0; + nr_decode_pucch0(gNB, nr_frame_tx, nr_slot_tx,&uci_pdu,&pucch_pdu); if(sr_flag==1){ if (uci_pdu.sr->sr_indication == 0 || uci_pdu.sr->sr_confidence_level == 1) sr_errors+=1; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index f84e553683..c889e6dcb9 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -394,7 +394,7 @@ int main(int argc, char **argv) nr_phy_config_request_sim(gNB, N_RB_UL, N_RB_UL, mu, Nid_cell, SSB_positions); - phy_init_nr_gNB(gNB, 0, 0); + phy_init_nr_gNB(gNB, 0, 1); //lowmem //configure UE UE = malloc(sizeof(PHY_VARS_NR_UE)); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 7a6df7d519..9df74d12a8 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -63,8 +63,8 @@ #include #include +#include #include "PHY/NR_REFSIG/ul_ref_seq_nr.h" - //#define DEBUG_ULSIM LCHAN_DESC DCCH_LCHAN_DESC,DTCH_DL_LCHAN_DESC,DTCH_UL_LCHAN_DESC; @@ -84,6 +84,7 @@ uint64_t downlink_frequency[MAX_NUM_CCs][4]; THREAD_STRUCT thread_struct; nfapi_ue_release_request_body_t release_rntis; msc_interface_t msc_interface; +uint32_t N_RB_DL = 106; extern void fix_scd(NR_ServingCellConfig_t *scd);// forward declaration @@ -120,6 +121,12 @@ rrc_data_ind( { } +int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, + const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, + gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { + return 0; +} + int gtpv1u_create_s1u_tunnel( const instance_t instanceP, @@ -129,6 +136,10 @@ gtpv1u_create_s1u_tunnel( return 0; } +int ocp_gtpv1u_delete_s1u_tunnel(const instance_t instance, const gtpv1u_enb_delete_tunnel_req_t *const req_pP) { + return 0; +} + int rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP( const protocol_ctxt_t *const ctxt_pP, @@ -185,6 +196,17 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, return 0; } +int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, + int CC_idP, + int UE_id, + rnti_t rntiP, + const uint8_t *sduP, + sdu_size_t sdu_lenP, + const uint8_t *sdu2P, + sdu_size_t sdu2_lenP) { + return 0; +} + //nFAPI P7 dummy functions int oai_nfapi_dl_tti_req(nfapi_nr_dl_tti_request_t *dl_config_req) { return(0); } @@ -198,6 +220,19 @@ int nr_derive_key(int alg_type, uint8_t alg_id, return 0; } +typedef struct { + uint64_t optmask; //mask to store boolean config options + uint8_t nr_dlsch_parallel; // number of threads for dlsch decoding, 0 means no parallelization + tpool_t Tpool; // thread pool +} nrUE_params_t; + +void processSlotTX(void *arg) {} + +nrUE_params_t nrUE_params; + +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} // needed for some functions uint16_t n_rnti = 0x1234; openair0_config_t openair0_cfg[MAX_CARDS]; @@ -209,6 +244,7 @@ double s_re1[122880],s_im1[122880],r_re1[122880],r_im1[122880]; double r_re2[122880],r_im2[122880]; double r_re3[122880],r_im3[122880]; + int main(int argc, char **argv) { char c; @@ -282,15 +318,13 @@ int main(int argc, char **argv) int file_offset = 0; double DS_TDL = .03; - int pusch_tgt_snrx10 = 200; - int pucch_tgt_snrx10 = 200; int ibwps=24; int ibwp_rboffset=41; int params_from_file = 0; if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == 0 ) { exit_fun("[NR_ULSIM] Error, configuration module init failed\n"); } - + int ul_proc_error = 0; // uplink processing checking status flag //logInit(); randominit(0); @@ -663,13 +697,7 @@ int main(int argc, char **argv) prepare_scd(scd); - fill_default_secondaryCellGroup(scc, - scd, - secondaryCellGroup, - 0, - 1, - n_tx, - 0); + fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, 0, 1, n_tx, 0, 0); // xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); @@ -680,10 +708,10 @@ int main(int argc, char **argv) gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; // common configuration - rrc_mac_config_req_gNB(0,0,n_tx,n_rx,pusch_tgt_snrx10,pucch_tgt_snrx10,scc,0,0,NULL); + rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 0, 0, NULL); // UE dedicated configuration - rrc_mac_config_req_gNB(0,0,1,1,pusch_tgt_snrx10,pucch_tgt_snrx10,NULL,1,secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); - phy_init_nr_gNB(gNB,0,0); + rrc_mac_config_req_gNB(0,0, n_tx, n_tx, 0, scc, 1, secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity,secondaryCellGroup); + phy_init_nr_gNB(gNB,0,1); N_RB_DL = gNB->frame_parms.N_RB_DL; @@ -740,7 +768,7 @@ int main(int argc, char **argv) rrc.carrier.MIB = (uint8_t*) malloc(4); rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0); - nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib,NULL,secondaryCellGroup); + nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup); nr_ue_phy_config_request(&UE_mac->phy_config); @@ -808,7 +836,7 @@ int main(int argc, char **argv) } uint8_t length_dmrs = pusch_len1; - uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs); + uint16_t l_prime_mask = get_l_prime(nb_symb_sch, mapping_type, add_pos, length_dmrs, start_symbol, NR_MIB__dmrs_TypeA_Position_pos2); uint16_t number_dmrs_symbols = get_dmrs_symbols_in_slot(l_prime_mask, nb_symb_sch); uint8_t nb_re_dmrs = (dmrs_config_type == pusch_dmrs_type1) ? 6 : 4; @@ -994,7 +1022,7 @@ int main(int argc, char **argv) pusch_pdu->transform_precoding = transform_precoding; pusch_pdu->data_scrambling_id = *scc->physCellId; pusch_pdu->nrOfLayers = 1; - pusch_pdu->ul_dmrs_symb_pos = l_prime_mask << start_symbol; + pusch_pdu->ul_dmrs_symb_pos = l_prime_mask; pusch_pdu->dmrs_config_type = dmrs_config_type; pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId; pusch_pdu->scid = 0; @@ -1057,7 +1085,7 @@ int main(int argc, char **argv) ul_config.ul_config_list[0].pusch_config_pdu.rb_start = start_rb; ul_config.ul_config_list[0].pusch_config_pdu.nr_of_symbols = nb_symb_sch; ul_config.ul_config_list[0].pusch_config_pdu.start_symbol_index = start_symbol; - ul_config.ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = l_prime_mask << start_symbol; + ul_config.ul_config_list[0].pusch_config_pdu.ul_dmrs_symb_pos = l_prime_mask; ul_config.ul_config_list[0].pusch_config_pdu.dmrs_config_type = dmrs_config_type; ul_config.ul_config_list[0].pusch_config_pdu.mcs_index = Imcs; ul_config.ul_config_list[0].pusch_config_pdu.mcs_table = mcs_table; @@ -1101,6 +1129,11 @@ int main(int argc, char **argv) phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id); + /* We need to call common sending function to send signal */ + LOG_D(PHY, "Sending Uplink data \n"); + nr_ue_pusch_common_procedures(UE, + slot, + &UE->frame_parms,1); if (n_trials==1) { LOG_M("txsig0.m","txs0", UE->common_vars.txdata[0],frame_parms->samples_per_subframe*10,1,1); @@ -1172,7 +1205,7 @@ int main(int argc, char **argv) phy_procedures_gNB_common_RX(gNB, frame, slot); - phy_procedures_gNB_uespec_RX(gNB, frame, slot); + ul_proc_error = phy_procedures_gNB_uespec_RX(gNB, frame, slot); if (n_trials==1 && round==0) { LOG_M("rxsig0.m","rx0",&gNB->common_vars.rxdata[0][slot_offset],slot_length,1,1); @@ -1202,9 +1235,9 @@ int main(int argc, char **argv) &gNB->pusch_vars[0]->llr[0],(nb_symb_sch-1)*NR_NB_SC_PER_RB * pusch_pdu->rb_size * mod_order,1,0); } //////////////////////////////////////////////////////////// - - if (gNB->ulsch[0][0]->last_iteration_cnt >= - gNB->ulsch[0][0]->max_ldpc_iterations+1) { + + if ((gNB->ulsch[0][0]->last_iteration_cnt >= + gNB->ulsch[0][0]->max_ldpc_iterations+1) || ul_proc_error == 1) { error_flag = 1; n_errors[round]++; crc_status = 1; @@ -1293,7 +1326,8 @@ int main(int argc, char **argv) (double)errors_scrambling[3]/available_bits/round_trials[0], roundStats[snrRun],effRate,effRate/TBS*100,TBS); - dump_pusch_stats(gNB); + FILE *fd=fopen("nr_ulsim.log","w"); + dump_pusch_stats(fd,gNB); printf("*****************************************\n"); printf("\n"); diff --git a/openair1/SIMULATION/TOOLS/multipath_channel.c b/openair1/SIMULATION/TOOLS/multipath_channel.c index 683526a8f0..3608eb7da2 100644 --- a/openair1/SIMULATION/TOOLS/multipath_channel.c +++ b/openair1/SIMULATION/TOOLS/multipath_channel.c @@ -39,13 +39,13 @@ uint8_t multipath_channel_nosigconv(channel_desc_t *desc) //#define CHANNEL_SSE #ifdef CHANNEL_SSE void multipath_channel(channel_desc_t *desc, - double tx_sig_re[2][30720*2], - double tx_sig_im[2][30720*2], - double rx_sig_re[2][30720*2], - double rx_sig_im[2][30720*2], + double tx_sig_re[NB_ANTENNAS_TX][30720*2], + double tx_sig_im[NB_ANTENANS_TX][30720*2], + double rx_sig_re[NB_ANTENNAS_RX][30720*2], + double rx_sig_im[NB_ANTENNAS_RX][30720*2], uint32_t length, uint8_t keep_channel, - int log_channel) + int log_channel) { int i,ii,j,l; @@ -146,13 +146,13 @@ void multipath_channel(channel_desc_t *desc, #else void multipath_channel(channel_desc_t *desc, - double *tx_sig_re[2], - double *tx_sig_im[2], - double *rx_sig_re[2], - double *rx_sig_im[2], + double *tx_sig_re[NB_ANTENNAS_TX], + double *tx_sig_im[NB_ANTENNAS_TX], + double *rx_sig_re[NB_ANTENNAS_RX], + double *rx_sig_im[NB_ANTENNAS_RX], uint32_t length, uint8_t keep_channel, - int log_channel) + int log_channel) { int i,ii,j,l; @@ -198,21 +198,22 @@ void multipath_channel(channel_desc_t *desc, rx_tmp.x += (tx.x * desc->ch[ii+(j*desc->nb_rx)][l].x) - (tx.y * desc->ch[ii+(j*desc->nb_rx)][l].y); rx_tmp.y += (tx.y * desc->ch[ii+(j*desc->nb_rx)][l].x) + (tx.x * desc->ch[ii+(j*desc->nb_rx)][l].y); - if (i==0 && log_channel == 1) { - printf("channel[%d][%d][%d] = %f dB (%e,%e)\n",ii,j,l,10*log10(pow(desc->ch[ii+(j*desc->nb_rx)][l].x,2.0)+pow(desc->ch[ii+(j*desc->nb_rx)][l].y,2.0)), - desc->ch[ii+(j*desc->nb_rx)][l].x, - desc->ch[ii+(j*desc->nb_rx)][l].y); - } + + if (i==0 && log_channel == 1) { + printf("channel[%d][%d][%d] = %f dB (%e,%e)\n",ii,j,l,10*log10(pow(desc->ch[ii+(j*desc->nb_rx)][l].x,2.0)+pow(desc->ch[ii+(j*desc->nb_rx)][l].y,2.0)), + desc->ch[ii+(j*desc->nb_rx)][l].x, + desc->ch[ii+(j*desc->nb_rx)][l].y); + } } //l } // j rx_sig_re[ii][i+dd] = rx_tmp.x*path_loss; rx_sig_im[ii][i+dd] = rx_tmp.y*path_loss; - - /* if ((ii==0)&&((i%32)==0)) { - printf("%p %p %f,%f => %e,%e\n",rx_sig_re[ii],rx_sig_im[ii],rx_tmp.x,rx_tmp.y,rx_sig_re[ii][i-dd],rx_sig_im[ii][i-dd]); - }*/ - +#ifdef DEBUG_CHANNEL + if ((i%32)==0) { + printf("rx aa %d: %p %p %f,%f => %e,%e\n",ii,rx_sig_re[ii],rx_sig_im[ii],rx_tmp.x,rx_tmp.y,rx_sig_re[ii][i-dd],rx_sig_im[ii][i-dd]); + } +#endif //rx_sig_re[ii][i] = sqrt(.5)*(tx_sig_re[0][i] + tx_sig_re[1][i]); //rx_sig_im[ii][i] = sqrt(.5)*(tx_sig_im[0][i] + tx_sig_im[1][i]); diff --git a/openair1/SIMULATION/TOOLS/random_channel.c b/openair1/SIMULATION/TOOLS/random_channel.c index 4e26d9a954..d2339954bd 100644 --- a/openair1/SIMULATION/TOOLS/random_channel.c +++ b/openair1/SIMULATION/TOOLS/random_channel.c @@ -2034,7 +2034,6 @@ static int channelmod_modify_cmd(char *buff, int debug, telnet_printfunc_t prnt) prnt("ERROR: %s, unknown channel parameter\n",param); return CMDSTATUS_FOUND; } - display_channelmodel(defined_channels[cd_id],debug,prnt); free(param); free(value); diff --git a/openair1/SIMULATION/TOOLS/sim.h b/openair1/SIMULATION/TOOLS/sim.h index 7696f9202f..78e260b73f 100644 --- a/openair1/SIMULATION/TOOLS/sim.h +++ b/openair1/SIMULATION/TOOLS/sim.h @@ -339,10 +339,10 @@ void set_channeldesc_name(channel_desc_t *cdesc,char *modelname); int random_channel(channel_desc_t *desc, uint8_t abstraction_flag); /**\fn void multipath_channel(channel_desc_t *desc, - double tx_sig_re[2], - double tx_sig_im[2], - double rx_sig_re[2], - double rx_sig_im[2], + double tx_sig_re[NB_ANTENNAS_TX], + double tx_sig_im[NB_ANTENANS_TX], + double rx_sig_re[NB_ANTENNAS_RX], + double rx_sig_im[NB_ANTENNAS_RX], uint32_t length, uint8_t keep_channel, int log_channel) @@ -359,10 +359,10 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag); */ void multipath_channel(channel_desc_t *desc, - double *tx_sig_re[2], - double *tx_sig_im[2], - double *rx_sig_re[2], - double *rx_sig_im[2], + double *tx_sig_re[NB_ANTENNAS_TX], + double *tx_sig_im[NB_ANTENNAS_TX], + double *rx_sig_re[NB_ANTENNAS_RX], + double *rx_sig_im[NB_ANTENNAS_RX], uint32_t length, uint8_t keep_channel, int log_channel); @@ -510,7 +510,6 @@ double N_RB2channel_bandwidth(uint16_t N_RB); void InitSinLUT( void ); void phase_noise(double ts, int16_t * InRe, int16_t * InIm); -#include "targets/RT/USER/rfsim.h" void do_DL_sig(sim_t *sim, uint16_t subframe, diff --git a/openair2/COMMON/f1ap_messages_types.h b/openair2/COMMON/f1ap_messages_types.h index ecfde8d38b..c2fb4a9cf7 100644 --- a/openair2/COMMON/f1ap_messages_types.h +++ b/openair2/COMMON/f1ap_messages_types.h @@ -299,7 +299,7 @@ typedef struct f1ap_initial_ul_rrc_message_s { uint16_t crnti; uint8_t *rrc_container; int rrc_container_length; - uint8_t *du2cu_rrc_container; + int8_t *du2cu_rrc_container; int du2cu_rrc_container_length; } f1ap_initial_ul_rrc_message_t; diff --git a/openair2/COMMON/gtpv1_u_messages_types.h b/openair2/COMMON/gtpv1_u_messages_types.h index 63911d46cb..75df3253f6 100644 --- a/openair2/COMMON/gtpv1_u_messages_types.h +++ b/openair2/COMMON/gtpv1_u_messages_types.h @@ -168,23 +168,23 @@ typedef struct gtpv1u_enb_end_marker_ind_s { uint32_t sdu_size; uint8_t *sdu_p; uint8_t mode; - uint16_t rnti; - uint8_t module_id; + uint16_t rnti; + uint8_t module_id; uint8_t eNB_index; } gtpv1u_enb_end_marker_ind_t; typedef struct { in_addr_t enb_ip_address_for_S1u_S12_S4_up; tcp_udp_port_t enb_port_for_S1u_S12_S4_up; - char addrStr[256]; - char portStr[256]; + char addrStr[256]; + char portStr[256]; } Gtpv1uS1Req; typedef struct { in_addr_t gnb_ip_address_for_NGu_up; tcp_udp_port_t gnb_port_for_NGu_up; - char addrStr[256]; - char portStr[256]; + char addrStr[256]; + char portStr[256]; } Gtpv1uNGReq; typedef struct gtpv1u_gnb_create_tunnel_req_s { rnti_t rnti; diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h index 4a0a6027bc..5a45f2f196 100644 --- a/openair2/COMMON/mac_rrc_primitives.h +++ b/openair2/COMMON/mac_rrc_primitives.h @@ -189,7 +189,7 @@ typedef struct MEAS_REQ_TABLE_ENTRY { MAC_MEAS_REQ Mac_meas_req; unsigned int Last_report_frame; unsigned int Next_check_frame; - uint8_t Status; + uint8_t StatusMeas; uint8_t Meas_req_status; uint8_t Rx_activity; //uint8_t Meas_Direction;//??? @@ -269,7 +269,7 @@ typedef struct { char Wideband_sinr; uint8_t Forg_fact; unsigned short Rep_interval; - uint8_t Status; + uint8_t StatusMeas; unsigned int Last_report_frame; unsigned int Next_check_frame; uint8_t Active; @@ -299,7 +299,7 @@ typedef struct { unsigned short Rep_interval; unsigned int Last_report_frame; unsigned int Next_check_frame; - uint8_t Status; //IDLE,NEED_rADIO_CONFIG, RADIO_CONFIG_TX, RADIO_CONFIG_ok + uint8_t StatusMeas; //IDLE,NEED_rADIO_CONFIG, RADIO_CONFIG_TX, RADIO_CONFIG_ok uint8_t Active; } __attribute__ ((__packed__)) DEFAULT_CH_MEAS; #define DEFAULT_eNB_MEAS_SIZE sizeof(DEFAULT_eNB_MEAS) diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index be6927ec37..c56a31711a 100644 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -28,12 +28,14 @@ ***************************************************************************/ -#include "LTE_asn_constant.h" -#include "NR_asn_constant.h" #ifndef __PLATFORM_CONSTANTS_H__ # define __PLATFORM_CONSTANTS_H__ +#include "LTE_asn_constant.h" +#include "NR_asn_constant.h" +#define NR_MAXDRB 14 + #ifdef JUMBO_FRAME #define NL_MAX_PAYLOAD 18000 /* this should cover the max mtu size*/ #else @@ -87,14 +89,7 @@ #define MAX_gNB 2 #endif -#define NUMBER_OF_NR_DLSCH_MAX 2//16 -#define NUMBER_OF_NR_ULSCH_MAX 2//16 -#define NUMBER_OF_NR_SCH_STATS_MAX 16 #define NUMBER_OF_NR_UCI_STATS_MAX 16 -#define NUMBER_OF_NR_PUCCH_MAX 16 -#define NUMBER_OF_NR_SR_MAX 16 -#define NUMBER_OF_NR_PDCCH_MAX 16 - #define MAX_MANAGED_ENB_PER_MOBILE 2 #define MAX_MANAGED_GNB_PER_MOBILE 2 diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index d425b9e7d7..23b33dd8b1 100644 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -195,21 +195,13 @@ typedef uint8_t mme_code_t; 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 -#endif -#if ! defined(NOT_A_RNTI) #define NOT_A_RNTI (rnti_t)0 -#endif -#if ! defined(M_RNTI) #define M_RNTI (rnti_t)0xFFFD -#endif -#if ! defined(P_RNTI) #define P_RNTI (rnti_t)0xFFFE -#endif -#if ! defined(SI_RNTI) #define SI_RNTI (rnti_t)0xFFFF -#endif +#define CBA_RNTI (rnti_t)0xfff4 +#define OAI_C_RNTI (rnti_t)0x1234 typedef enum config_action_e { CONFIG_ACTION_NULL = 0, CONFIG_ACTION_ADD = 1, diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index 5086cd1b25..3ef69b19e0 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -405,6 +405,7 @@ typedef struct NRRrcConfigurationReq_s { uint16_t mcc[PLMN_LIST_MAX_SIZE]; uint16_t mnc[PLMN_LIST_MAX_SIZE]; uint8_t mnc_digit_length[PLMN_LIST_MAX_SIZE]; + uint8_t num_plmn; NR_ServingCellConfigCommon_t *scc; NR_ServingCellConfig_t *scd; int ssb_SubcarrierOffset; diff --git a/openair2/COMMON/tasks_def.h b/openair2/COMMON/tasks_def.h deleted file mode 100644 index 33b6d5f9d4..0000000000 --- a/openair2/COMMON/tasks_def.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The OpenAirInterface Software Alliance licenses this file to You under - * the OAI Public License, Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.openairinterface.org/?page_id=698 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *------------------------------------------------------------------------------- - * For more information about the OpenAirInterface (OAI) Software Alliance: - * contact@openairinterface.org - */ - -// This task is mandatory and must always be placed in first position -TASK_DEF(TASK_TIMER, TASK_PRIORITY_MAX, 10) - -// Other possible tasks in the process - -// Common tasks: - -/// Bearers Manager task -TASK_DEF(TASK_BM, TASK_PRIORITY_MED, 200) - -// eNodeB tasks and sub-tasks: - -/// Radio Resource Control task -TASK_DEF(TASK_RRC_ENB, TASK_PRIORITY_MED, 200) - -// Define here for now -TASK_DEF(TASK_RRC_ENB_NB_IoT, TASK_PRIORITY_MED, 200) - -TASK_DEF(TASK_RRC_GNB, TASK_PRIORITY_MED, 200) - -/// S1ap task -/// RAL task for ENB -TASK_DEF(TASK_RAL_ENB, TASK_PRIORITY_MED, 200) - -// UDP TASK -TASK_DEF(TASK_UDP, TASK_PRIORITY_MED, 1000) -// GTP_V1U task -TASK_DEF(TASK_GTPV1_U, TASK_PRIORITY_MED, 1000) -TASK_DEF(TASK_S1AP, TASK_PRIORITY_MED, 200) -TASK_DEF(TASK_CU_F1, TASK_PRIORITY_MED, 200) -TASK_DEF(TASK_DU_F1, TASK_PRIORITY_MED, 200) -/// M3ap task, acts as both source and target -TASK_DEF(TASK_M3AP, TASK_PRIORITY_MED, 200) -/// M3ap task, acts as both source and target -TASK_DEF(TASK_M3AP_MME, TASK_PRIORITY_MED, 200) -/// M3ap task, acts as both source and target -TASK_DEF(TASK_M3AP_MCE, TASK_PRIORITY_MED, 200) -/// M2ap task, acts as both source and target -TASK_DEF(TASK_M2AP_MCE, TASK_PRIORITY_MED, 200) -TASK_DEF(TASK_M2AP_ENB, TASK_PRIORITY_MED, 200) -/// X2ap task, acts as both source and target -TASK_DEF(TASK_X2AP, TASK_PRIORITY_MED, 200) -/// Sctp task (Used by both S1AP and X2AP) -TASK_DEF(TASK_SCTP, TASK_PRIORITY_MED, 200) -/// eNB APP task -TASK_DEF(TASK_ENB_APP, TASK_PRIORITY_MED, 200) -/// gNB APP task -TASK_DEF(TASK_GNB_APP, TASK_PRIORITY_MED, 200) -/// eNB Agent task -TASK_DEF(TASK_FLEXRAN_AGENT, TASK_PRIORITY_MED, 200) -TASK_DEF(TASK_PROTO_AGENT, TASK_PRIORITY_MED, 200) -// UE tasks and sub-tasks: - -/// Radio Resource Control task -TASK_DEF(TASK_RRC_UE, TASK_PRIORITY_MED, 200) -TASK_DEF(TASK_RRC_NRUE, TASK_PRIORITY_MED, 200) -/// Non Access Stratum task -TASK_DEF(TASK_NAS_UE, TASK_PRIORITY_MED, 200) -TASK_DEF(TASK_RAL_UE, TASK_PRIORITY_MED, 200) - -//MESSAGE GENERATOR TASK -TASK_DEF(TASK_MSC, TASK_PRIORITY_MED, 200) - -#ifdef ITTI_SIM -TASK_DEF(TASK_RRC_GNB_SIM, TASK_PRIORITY_MED, 200) -TASK_DEF(TASK_RRC_UE_SIM, TASK_PRIORITY_MED, 200) -#endif - diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c index 7ca466e8ff..51e495b027 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac.c @@ -42,6 +42,9 @@ #include +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + /*Array containing the Agent-MAC interfaces*/ AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]; diff --git a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c index 42246c3ebf..e05fa98854 100644 --- a/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c +++ b/openair2/ENB_APP/CONTROL_MODULES/MAC/flexran_agent_mac_internal.c @@ -33,6 +33,9 @@ #include "flexran_agent_mac_internal.h" #include "flexran_agent_mac_slice_verification.h" +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + extern SLIST_HEAD(flexran_so_handle, flexran_agent_so_handle_s) flexran_handles[NUM_MAX_ENB]; diff --git a/openair2/ENB_APP/MACRLC_paramdef.h b/openair2/ENB_APP/MACRLC_paramdef.h index fcee6142f0..11cbe445b8 100644 --- a/openair2/ENB_APP/MACRLC_paramdef.h +++ b/openair2/ENB_APP/MACRLC_paramdef.h @@ -56,10 +56,14 @@ #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD "local_s_portd" #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD "remote_s_portd" #define CONFIG_STRING_MACRLC_SCHED_MODE "scheduler_mode" -#define CONFIG_MACRLC_PUSCH10xSNR "puSch10xSnr" -#define CONFIG_MACRLC_PUCCH10xSNR "puCch10xSnr" +#define CONFIG_STRING_MACRLC_PUSCH10xSNR "puSch10xSnr" +#define CONFIG_STRING_MACRLC_PUCCH10xSNR "puCch10xSnr" #define CONFIG_STRING_MACRLC_DEFAULT_SCHED_DL_ALGO "default_sched_dl_algo" - +#define CONFIG_STRING_MACRLC_UE_MULTIPLE_MAX "ue_multiple_max" +#define CONFIG_STRING_MACRLC_USE_MCS_OFFSET "use_mcs_offset" +#define CONFIG_STRING_MACRLC_BLER_TARGET_LOWER "bler_target_lower" +#define CONFIG_STRING_MACRLC_BLER_TARGET_UPPER "bler_target_upper" +#define CONFIG_STRING_MACRLC_MAX_UL_RB_INDEX "max_ul_rb_index" /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* MacRLC configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -83,10 +87,15 @@ {CONFIG_STRING_MACRLC_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_SCHED_MODE, NULL, 0, strptr:NULL, defstrval:"default", TYPE_STRING, 0}, \ -{CONFIG_MACRLC_PUSCH10xSNR, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ -{CONFIG_MACRLC_PUCCH10xSNR, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ -{CONFIG_STRING_MACRLC_DEFAULT_SCHED_DL_ALGO, NULL, 0, strptr:NULL, defstrval:"round_robin_dl", TYPE_STRING, 0}, \ -} +{CONFIG_STRING_MACRLC_PUSCH10xSNR, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_PUCCH10xSNR, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_DEFAULT_SCHED_DL_ALGO, NULL, 0, strptr:NULL, defstrval:"round_robin_dl", TYPE_STRING, 0}, \ +{CONFIG_STRING_MACRLC_UE_MULTIPLE_MAX, NULL, 0, iptr:NULL, defintval:4, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_USE_MCS_OFFSET, NULL, 0, iptr:NULL, defintval:1, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_BLER_TARGET_LOWER, NULL, 0, dblptr:NULL, defdblval:.5, TYPE_DOUBLE, 0}, \ +{CONFIG_STRING_MACRLC_BLER_TARGET_UPPER, NULL, 0, dblptr:NULL, defdblval:2, TYPE_DOUBLE, 0}, \ +{CONFIG_STRING_MACRLC_MAX_UL_RB_INDEX, NULL, 0, iptr:NULL, defintval:22, TYPE_INT, 0}} + #define MACRLC_CC_IDX 0 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 #define MACRLC_LOCAL_N_IF_NAME_IDX 2 @@ -108,6 +117,11 @@ #define MACRLC_PUSCH10xSNR_IDX 18 #define MACRLC_PUCCH10xSNR_IDX 19 #define MACRLC_DEFAULT_SCHED_DL_ALGO_IDX 20 +#define MACRLC_UE_MULTIPLE_MAX_IDX 21 +#define MACRLC_USE_MCS_OFFSET_IDX 22 +#define MACRLC_BLER_TARGET_LOWER_IDX 23 +#define MACRLC_BLER_TARGET_UPPER_IDX 24 +#define MACRLC_MAX_UL_RB_INDEX_IDX 25 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ #endif diff --git a/openair2/ENB_APP/NB_IoT_interface.c b/openair2/ENB_APP/NB_IoT_interface.c index 7355233d71..8fc6de78af 100644 --- a/openair2/ENB_APP/NB_IoT_interface.c +++ b/openair2/ENB_APP/NB_IoT_interface.c @@ -35,6 +35,9 @@ #define NBIOT_INTERFACE_SOURCE #include "NB_IoT_interface.h" +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + diff --git a/openair2/ENB_APP/NB_IoT_interface.h b/openair2/ENB_APP/NB_IoT_interface.h index b3454b077b..c13f6dd1cb 100644 --- a/openair2/ENB_APP/NB_IoT_interface.h +++ b/openair2/ENB_APP/NB_IoT_interface.h @@ -31,6 +31,7 @@ #define NBIOT_MODULENAME "NB_IoT" +#include "common/ran_context.h" typedef void(*RCConfig_NbIoT_f_t)(RAN_CONTEXT_t *RC); #define NBIOT_RCCONFIG_FNAME "RCConfig_NbIoT" diff --git a/openair2/ENB_APP/enb_app.c b/openair2/ENB_APP/enb_app.c index 5080157c3f..9f134f826e 100644 --- a/openair2/ENB_APP/enb_app.c +++ b/openair2/ENB_APP/enb_app.c @@ -244,6 +244,8 @@ void *eNB_app_task(void *args_p) { } + LOG_I(ENB_APP,"TASK_ENB_APP is ready\n"); + do { // Wait for a message itti_receive_msg (TASK_ENB_APP, &msg_p); diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index ee7b26ff1a..4751596931 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -64,6 +64,8 @@ extern uint32_t to_earfcn_UL(int eutra_bandP, uint32_t ul_CarrierFreq, uint32_t extern char *parallel_config; extern char *worker_config; +RAN_CONTEXT_t RC; + void RCconfig_flexran() { /* get number of eNBs */ paramdef_t ENBSParams[] = ENBSPARAMS_DESC; @@ -218,13 +220,26 @@ void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]) { for (j = 0; j < RC.nb_macrlc_inst; j++) { RC.mac[j]->puSch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUSCH10xSNR_IDX ].iptr); RC.mac[j]->puCch10xSnr = *(MacRLC_ParamList.paramarray[j][MACRLC_PUCCH10xSNR_IDX ].iptr); + RC.mac[j]->ue_multiple_max = *(MacRLC_ParamList.paramarray[j][MACRLC_UE_MULTIPLE_MAX_IDX ].iptr); + RC.mac[j]->use_mcs_offset = *(MacRLC_ParamList.paramarray[j][MACRLC_USE_MCS_OFFSET_IDX ].iptr); + RC.mac[j]->bler_lower = *(MacRLC_ParamList.paramarray[j][MACRLC_BLER_TARGET_LOWER_IDX ].dblptr); + RC.mac[j]->bler_upper = *(MacRLC_ParamList.paramarray[j][MACRLC_BLER_TARGET_UPPER_IDX ].dblptr); + RC.mac[j]->max_ul_rb_index = *(MacRLC_ParamList.paramarray[j][MACRLC_MAX_UL_RB_INDEX_IDX ].iptr); RC.nb_mac_CC[j] = *(MacRLC_ParamList.paramarray[j][MACRLC_CC_IDX].iptr); - + LOG_I(ENB_APP,"MAC instance %d parameters : pusch_snr %lf, pucch_snr %lf, ue_multiple_max %d, use_mcs_offset %d, bler_lower %lf, bler_upper %lf,max_ul_rb_index %d\n", + j, + RC.mac[j]->puSch10xSnr/10.0, + RC.mac[j]->puCch10xSnr/10.0, + RC.mac[j]->ue_multiple_max, + RC.mac[j]->use_mcs_offset, + RC.mac[j]->bler_lower, + RC.mac[j]->bler_upper, + RC.mac[j]->max_ul_rb_index); if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { // check number of instances is same as RRC/PDCP - printf("Configuring local RRC for MACRLC\n"); + LOG_I(ENB_APP,"Configuring local RRC for MACRLC\n"); } else if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "f1") == 0) { - printf("Configuring F1 interfaces for MACRLC\n"); + LOG_I(ENB_APP,"Configuring F1 interfaces for MACRLC\n"); RC.mac[j]->eth_params_n.local_if_name = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_IF_NAME_IDX].strptr)); RC.mac[j]->eth_params_n.my_addr = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr)); RC.mac[j]->eth_params_n.remote_addr = strdup(*(MacRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr)); @@ -1993,7 +2008,7 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) { F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nrb = rrc->carrier[0].mib.message.dl_Bandwidth; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.num_frequency_bands = 1; F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.nr_band[0] = rrc->carrier[0].sib1->freqBandIndicator; - F1AP_SETUP_REQ (msg_p).nr_mode_info[k].fdd.sul_active = 0; + F1AP_SETUP_REQ (msg_p).nr_mode_info[k].tdd.sul_active = 0; } else { LOG_I(ENB_APP,"ngran_DU: Configuring Cell %d for FDD\n",k); F1AP_SETUP_REQ (msg_p).fdd_flag = 1; @@ -2779,12 +2794,13 @@ int RCconfig_X2(MessageDef *msg_p, uint32_t i) { "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; - + LOG_I(X2AP,"X2ParamList.numelt %d\n",X2ParamList.numelt); for (l = 0; l < X2ParamList.numelt; l++) { X2AP_REGISTER_ENB_REQ (msg_p).nb_x2 += 1; strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4_address,*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr)); strcpy(X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6_address,*(X2ParamList.paramarray[l][ENB_X2_IPV6_ADDRESS_IDX].strptr)); + LOG_I(X2AP,"registering with ip : %s\n",*(X2ParamList.paramarray[l][ENB_X2_IPV4_ADDRESS_IDX].strptr)); if (strcmp(*(X2ParamList.paramarray[l][ENB_X2_IP_ADDRESS_PREFERENCE_IDX].strptr), "ipv4") == 0) { X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv4 = 1; X2AP_REGISTER_ENB_REQ (msg_p).target_enb_x2_ip_address[l].ipv6 = 0; @@ -2964,7 +2980,7 @@ void extract_and_decode_SI(int inst,int si_ind,uint8_t *si_container,int si_cont eNB_RRC_INST *rrc = RC.rrc[inst]; rrc_eNB_carrier_data_t *carrier = &rrc->carrier[0]; LTE_BCCH_DL_SCH_Message_t *bcch_message ; - AssertFatal(si_ind==0,"Can only handle a single SI block for now\n"); + AssertFatal(si_ind==2,"Can only handle a single SI block for now\n"); LOG_I(ENB_APP, "rrc inst %d: Trying to decode SI block %d @ %p, length %d\n",inst,si_ind,si_container,si_container_length); // point to first SI block bcch_message = &carrier->systemInformation; @@ -3151,15 +3167,19 @@ void handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { (check_plmn_identity(carrier, resp->cells_to_activate[j].mcc, resp->cells_to_activate[j].mnc, resp->cells_to_activate[j].mnc_digit_length)>0 && resp->cells_to_activate[j].nrpci == carrier->physCellId)) { // copy system information and decode it - for (si_ind=0; si_indcells_to_activate[j].num_SI; si_ind++) { - //printf("SI %d size %d: ", si_ind, resp->SI_container_length[j][si_ind]); - //for (int n=0;nSI_container_length[j][si_ind];n++) - // printf("%02x ",resp->SI_container[j][si_ind][n]); + for (si_ind=2; si_indcells_to_activate[j].num_SI + 2; si_ind++) { + //printf("SI %d size %d: ", si_ind, resp->cells_to_activate[j].SI_container_length[si_ind]); + //for (int n=0;ncells_to_activate[j].SI_container_length[si_ind];n++) + // printf("%02x ",resp->cells_to_activate[j].SI_container[si_ind][n]); //printf("\n"); - extract_and_decode_SI(i, - si_ind, - resp->cells_to_activate[j].SI_container[si_ind], - resp->cells_to_activate[j].SI_container_length[si_ind]); + if (si_ind==6) si_ind=9; + if (resp->cells_to_activate[j].SI_container[si_ind] != NULL) { + extract_and_decode_SI(i, + si_ind, + resp->cells_to_activate[j].SI_container[si_ind], + resp->cells_to_activate[j].SI_container_length[si_ind]); + } + } // perform MAC/L1 common configuration diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h index 4bc4f5bf22..b95bf90f70 100644 --- a/openair2/ENB_APP/enb_config.h +++ b/openair2/ENB_APP/enb_config.h @@ -100,7 +100,6 @@ typedef struct ru_config_s { uint8_t if_compress; } ru_config_t; -extern void RCconfig_RU(void); extern void RCconfig_flexran(void); extern void RCconfig_L1(void); extern void RCconfig_macrlc(int macrlc_has_f1[MAX_MAC_INST]); diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index f26863414c..79e66881b5 100644 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -98,6 +98,7 @@ typedef enum { #define CONFIG_STRING_RU_BF_WEIGHTS_LIST "bf_weights" #define CONFIG_STRING_RU_IF_FREQUENCY "if_freq" #define CONFIG_STRING_RU_IF_FREQ_OFFSET "if_offset" +#define CONFIG_STRING_RU_DO_PRECODING "do_precoding" #define RU_LOCAL_IF_NAME_IDX 0 #define RU_LOCAL_ADDRESS_IDX 1 @@ -127,7 +128,7 @@ typedef enum { #define RU_BF_WEIGHTS_LIST_IDX 25 #define RU_IF_FREQUENCY 26 #define RU_IF_FREQ_OFFSET 27 - +#define RU_DO_PRECODING 28 /*-----------------------------------------------------------------------------------------------------------------------------------------*/ /* RU configuration parameters */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ @@ -160,7 +161,8 @@ typedef enum { {CONFIG_STRING_RU_OTA_SYNC_ENABLE, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \ {CONFIG_STRING_RU_BF_WEIGHTS_LIST, NULL, 0, iptr:NULL, defintarrayval:DEFBFW, TYPE_INTARRAY, 0}, \ {CONFIG_STRING_RU_IF_FREQUENCY, NULL, 0, u64ptr:NULL, defuintval:0, TYPE_UINT64, 0}, \ - {CONFIG_STRING_RU_IF_FREQ_OFFSET, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ + {CONFIG_STRING_RU_IF_FREQ_OFFSET, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ + {CONFIG_STRING_RU_DO_PRECODING, NULL, 0, iptr:NULL, defintval:0, TYPE_INT, 0}, \ } /*---------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index 33182f3593..af7ff6ff6f 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -33,6 +33,9 @@ #include #include +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + int agent_task_created = 0; /* * enb agent task mainly wakes up the tx thread for periodic and oneshot messages to the controller diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 1af59eab87..55a1c61b25 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -53,6 +53,9 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rrc_eNB_UE_context.h" +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + /* * message primitives */ diff --git a/openair2/ENB_APP/flexran_agent_ran_api.c b/openair2/ENB_APP/flexran_agent_ran_api.c index ff21971810..68d1f3311f 100644 --- a/openair2/ENB_APP/flexran_agent_ran_api.c +++ b/openair2/ENB_APP/flexran_agent_ran_api.c @@ -32,6 +32,9 @@ #include "s1ap_eNB_management_procedures.h" #include "openair2/LAYER2/MAC/slicing/slicing.h" +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + static inline int phy_is_present(mid_t mod_id, uint8_t cc_id) { return RC.eNB && RC.eNB[mod_id] && RC.eNB[mod_id][cc_id]; } @@ -885,7 +888,7 @@ uint8_t flexran_get_rrc_status(mid_t mod_id, rnti_t rnti) { if (!ue_context_p) return RRC_INACTIVE; - return ue_context_p->ue_context.Status; + return ue_context_p->ue_context.StatusRrc; } uint64_t flexran_get_ue_aggregated_max_bitrate_dl(mid_t mod_id, mid_t ue_id) { diff --git a/targets/RT/USER/rfsim.h b/openair2/F1AP/dummy_enb.c similarity index 71% rename from targets/RT/USER/rfsim.h rename to openair2/F1AP/dummy_enb.c index 801ab5eb56..fe6dfb6a06 100644 --- a/targets/RT/USER/rfsim.h +++ b/openair2/F1AP/dummy_enb.c @@ -18,23 +18,17 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ -#ifndef __RFSIM__H__ -#define __RFSIM__H__ -#include "lte-softmodem.h" -#include "openair1/SIMULATION/TOOLS/sim.h" -#include "platform_constants.h" + +#include "COMMON/platform_types.h" #include "common/ran_context.h" -#include "PHY/defs_UE.h" -#include "PHY/defs_eNB.h" +#include "common/utils/LOG/log.h" +#include "NR_BCCH-BCH-Message.h" +#include "NR_ServingCellConfigCommon.h" +#include "NR_MIB.h" -void init_ocm(void); +void apply_macrlc_config(gNB_RRC_INST *rrc, + rrc_gNB_ue_context_t *const ue_context_pP, + const protocol_ctxt_t *const ctxt_pP ) { +abort(); +} -void update_ocm(double snr_dB,double sinr_dB); - -//extern pthread_mutex_t async_server_lock; -//extern pthread_cond_t async_server_notify; -//extern int async_server_shutdown; - -void init_channel_vars(void); - -#endif diff --git a/openair2/F1AP/f1ap_cu_interface_management.c b/openair2/F1AP/f1ap_cu_interface_management.c index 88d0a8ec59..057d0d97a0 100644 --- a/openair2/F1AP/f1ap_cu_interface_management.c +++ b/openair2/F1AP/f1ap_cu_interface_management.c @@ -103,7 +103,11 @@ int CU_handle_F1_SETUP_REQUEST(instance_t instance, assoc_id, stream); } - message_p = itti_alloc_new_message(TASK_CU_F1, 0, F1AP_SETUP_REQ); + if(RC.nrrrc) { + message_p = itti_alloc_new_message(TASK_CU_F1, 0, F1AP_SETUP_REQ); + } else { + message_p = itti_alloc_new_message(TASK_RRC_ENB, 0, F1AP_SETUP_REQ); + } /* assoc_id */ F1AP_SETUP_REQ(message_p).assoc_id = assoc_id; @@ -142,8 +146,7 @@ int CU_handle_F1_SETUP_REQUEST(instance_t instance, /* tac */ if (served_cells_item_p->served_Cell_Information.fiveGS_TAC) { OCTET_STRING_TO_INT16(served_cells_item_p->served_Cell_Information.fiveGS_TAC, F1AP_SETUP_REQ(message_p).tac[i]); - LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).tac[%d] %d \n", - i, F1AP_SETUP_REQ(message_p).tac[i]); + LOG_D(F1AP, "F1AP_SETUP_REQ(message_p).tac[%d] %d \n", i, F1AP_SETUP_REQ(message_p).tac[i]); } /* - nRCGI */ TBCD_TO_MCC_MNC(&(served_cells_item_p->served_Cell_Information.nRCGI.pLMN_Identity), F1AP_SETUP_REQ(message_p).mcc[i], @@ -247,14 +250,14 @@ int CU_handle_F1_SETUP_REQUEST(instance_t instance, ); if (num_cells_available > 0) { - if (RC.nrrrc[0]->node_type == ngran_gNB_CU) { + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_CU) { itti_send_msg_to_task(TASK_RRC_GNB, GNB_MODULE_ID_TO_INSTANCE(instance), message_p); } else { itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(instance), message_p); } } else { CU_send_F1_SETUP_FAILURE(instance); - if (RC.nrrrc[0]->node_type == ngran_gNB_CU) { + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_CU) { itti_free(TASK_RRC_GNB,message_p); } else { itti_free(TASK_RRC_ENB,message_p); @@ -322,22 +325,26 @@ int CU_send_F1_SETUP_RESPONSE(instance_t instance, ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List; ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_F1SetupResponseIEs__value_PR_Cells_to_be_Activated_List; - - - for (i=0; - icells_to_activate[i].mcc, + f1ap_setup_resp->cells_to_activate[i].mnc, + f1ap_setup_resp->cells_to_activate[i].mnc_digit_length, + f1ap_setup_resp->cells_to_activate[i].nr_cellid); + F1AP_Cells_to_be_Activated_List_ItemIEs_t *cells_to_be_activated_list_item_ies; cells_to_be_activated_list_item_ies = (F1AP_Cells_to_be_Activated_List_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemIEs_t)); cells_to_be_activated_list_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; cells_to_be_activated_list_item_ies->criticality = F1AP_Criticality_reject; cells_to_be_activated_list_item_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; - + /* 3.1 cells to be Activated list item */ F1AP_Cells_to_be_Activated_List_Item_t cells_to_be_activated_list_item; memset((void *)&cells_to_be_activated_list_item, 0, sizeof(F1AP_Cells_to_be_Activated_List_Item_t)); - + /* - nRCGI */ F1AP_NRCGI_t nRCGI; memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); @@ -345,62 +352,59 @@ int CU_send_F1_SETUP_RESPONSE(instance_t instance, &nRCGI.pLMN_Identity); NR_CELL_ID_TO_BIT_STRING(f1ap_setup_resp->cells_to_activate[i].nr_cellid, &nRCGI.nRCellIdentity); cells_to_be_activated_list_item.nRCGI = nRCGI; - + /* optional */ /* - nRPCI */ if (1) { - cells_to_be_activated_list_item.nRPCI = (F1AP_NRPCI_t *)calloc(1, sizeof(F1AP_NRPCI_t)); - *cells_to_be_activated_list_item.nRPCI = f1ap_setup_resp->cells_to_activate[i].nrpci; // int 0..1007 + cells_to_be_activated_list_item.nRPCI = (F1AP_NRPCI_t *)calloc(1, sizeof(F1AP_NRPCI_t)); + *cells_to_be_activated_list_item.nRPCI = f1ap_setup_resp->cells_to_activate[i].nrpci; // int 0..1007 } - + /* optional */ /* - gNB-CU System Information */ if (1) { - /* 3.1.2 gNB-CUSystem Information */ - F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs; - cells_to_be_activated_list_itemExtIEs = (F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t)); - cells_to_be_activated_list_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; - cells_to_be_activated_list_itemExtIEs->criticality = F1AP_Criticality_reject; - cells_to_be_activated_list_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; - - F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)calloc(1, sizeof(F1AP_GNB_CUSystemInformation_t)); - //LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]); - //for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++) - // printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]); - //printf("\n"); - - // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? - for (int sIBtype=2;sIBtype<21;sIBtype++) { - if (f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype]!=NULL) { - AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); - F1AP_SibtypetobeupdatedListItem_t *sib_item = calloc(1,sizeof(*sib_item)); - memset((void*)sib_item,0,sizeof(*sib_item)); - sib_item->sIBtype = sIBtype; - OCTET_STRING_fromBuf(&sib_item->sIBmessage, - (const char*)f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype], - f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); - - LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype,f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); - ASN_SEQUENCE_ADD(&gNB_CUSystemInformation->sibtypetobeupdatedlist.list,sib_item); - } - } - cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation = *gNB_CUSystemInformation; - - - F1AP_ProtocolExtensionContainer_154P112_t p_154P112_t; - memset((void *)&p_154P112_t, 0, sizeof(F1AP_ProtocolExtensionContainer_154P112_t)); - - ASN_SEQUENCE_ADD(&p_154P112_t.list, - cells_to_be_activated_list_itemExtIEs); - cells_to_be_activated_list_item.iE_Extensions = (struct F1AP_ProtocolExtensionContainer*)&p_154P112_t; - - free(gNB_CUSystemInformation); - gNB_CUSystemInformation = NULL; + /* 3.1.2 gNB-CUSystem Information */ + F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs; + cells_to_be_activated_list_itemExtIEs = (F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t)); + cells_to_be_activated_list_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; + cells_to_be_activated_list_itemExtIEs->criticality = F1AP_Criticality_reject; + cells_to_be_activated_list_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; + + F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)calloc(1, sizeof(F1AP_GNB_CUSystemInformation_t)); + //LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]); + //for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++) + // printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]); + //printf("\n"); + + // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? + for (int sIBtype=2;sIBtype<21;sIBtype++) { + if (f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype]!=NULL) { + AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); + F1AP_SibtypetobeupdatedListItem_t *sib_item = calloc(1,sizeof(*sib_item)); + memset((void*)sib_item,0,sizeof(*sib_item)); + sib_item->sIBtype = sIBtype; + OCTET_STRING_fromBuf(&sib_item->sIBmessage, + (const char*)f1ap_setup_resp->cells_to_activate[i].SI_container[sIBtype], + f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); + + LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype,f1ap_setup_resp->cells_to_activate[i].SI_container_length[sIBtype]); + ASN_SEQUENCE_ADD(&gNB_CUSystemInformation->sibtypetobeupdatedlist.list,sib_item); + } + } + cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation = *gNB_CUSystemInformation; + + F1AP_ProtocolExtensionContainer_154P112_t p_154P112_t; + memset((void *)&p_154P112_t, 0, sizeof(F1AP_ProtocolExtensionContainer_154P112_t)); + + ASN_SEQUENCE_ADD(&p_154P112_t.list, cells_to_be_activated_list_itemExtIEs); + cells_to_be_activated_list_item.iE_Extensions = (struct F1AP_ProtocolExtensionContainer*)&p_154P112_t; + + free(gNB_CUSystemInformation); + gNB_CUSystemInformation = NULL; } /* ADD */ cells_to_be_activated_list_item_ies->value.choice.Cells_to_be_Activated_List_Item = cells_to_be_activated_list_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Activated_List.list, - cells_to_be_activated_list_item_ies); + ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Activated_List.list, cells_to_be_activated_list_item_ies); } ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } @@ -548,7 +552,7 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage; pdu.choice.initiatingMessage = (F1AP_InitiatingMessage_t *)calloc(1, sizeof(F1AP_InitiatingMessage_t)); pdu.choice.initiatingMessage->procedureCode = F1AP_ProcedureCode_id_gNBCUConfigurationUpdate; - pdu.choice.initiatingMessage->criticality = F1AP_Criticality_reject; + pdu.choice.initiatingMessage->criticality = F1AP_Criticality_ignore; pdu.choice.initiatingMessage->value.present = F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate; out = &pdu.choice.initiatingMessage->value.choice.GNBCUConfigurationUpdate; @@ -562,345 +566,351 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + // mandatory - // c2. Cells_to_be_Activated_List + // c2. Cells_to_be_Activated_List if (f1ap_gnb_cu_configuration_update->num_cells_to_activate > 0) { ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List; ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List; - - for (i=0; - inum_cells_to_activate; - i++) { - + + for (i=0; inum_cells_to_activate; i++) { + + LOG_D(F1AP, "[c2] (cell %d) mcc = %d, mnc = %d, mnc_digit_length = %d, nr_cellid = %lu\n", + i, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid); + F1AP_Cells_to_be_Activated_List_ItemIEs_t *cells_to_be_activated_list_item_ies; cells_to_be_activated_list_item_ies = (F1AP_Cells_to_be_Activated_List_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemIEs_t)); cells_to_be_activated_list_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; cells_to_be_activated_list_item_ies->criticality = F1AP_Criticality_reject; cells_to_be_activated_list_item_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item; - + // 2.1 cells to be Activated list item F1AP_Cells_to_be_Activated_List_Item_t cells_to_be_activated_list_item; memset((void *)&cells_to_be_activated_list_item, 0, sizeof(F1AP_Cells_to_be_Activated_List_Item_t)); - - // - nRCGI + + // - nRCGI F1AP_NRCGI_t nRCGI; memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, - f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, + MCC_MNC_TO_PLMNID(f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid, + NR_CELL_ID_TO_BIT_STRING(f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid, &nRCGI.nRCellIdentity); cells_to_be_activated_list_item.nRCGI = nRCGI; - - // optional - // -nRPCI - cells_to_be_activated_list_item.nRPCI = (F1AP_NRPCI_t *)calloc(1, sizeof(F1AP_NRPCI_t)); - *cells_to_be_activated_list_item.nRPCI = f1ap_gnb_cu_configuration_update->cells_to_activate[i].nrpci; // int 0..1007 - - // optional - // 3.1.2 gNB-CUSystem Information - F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs; - cells_to_be_activated_list_itemExtIEs = (F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t)); - cells_to_be_activated_list_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; - cells_to_be_activated_list_itemExtIEs->criticality = F1AP_Criticality_reject; - cells_to_be_activated_list_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; - if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].num_SI > 0) { - F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)calloc(1, sizeof(F1AP_GNB_CUSystemInformation_t)); - //LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]); - //for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++) - // printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]); - //printf("\n"); - - // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? - for (int sIBtype=2;sIBtype<21;sIBtype++) { - if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype]!=NULL) { - AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); - F1AP_SibtypetobeupdatedListItem_t *sib_item = calloc(1,sizeof(*sib_item)); - memset((void*)sib_item,0,sizeof(*sib_item)); - sib_item->sIBtype = sIBtype; - OCTET_STRING_fromBuf(&sib_item->sIBmessage, - (const char*)f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype], - f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); - - LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype,f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); - ASN_SEQUENCE_ADD(&gNB_CUSystemInformation->sibtypetobeupdatedlist.list,sib_item); - } - } - cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation = *gNB_CUSystemInformation; - - - F1AP_ProtocolExtensionContainer_154P112_t p_154P112_t; - memset((void *)&p_154P112_t, 0, sizeof(F1AP_ProtocolExtensionContainer_154P112_t)); - - ASN_SEQUENCE_ADD(&p_154P112_t.list, - cells_to_be_activated_list_itemExtIEs); - cells_to_be_activated_list_item.iE_Extensions = (struct F1AP_ProtocolExtensionContainer*)&p_154P112_t; - - free(gNB_CUSystemInformation); - gNB_CUSystemInformation = NULL; - } + if(RC.nrrrc) { + + // optional + // -nRPCI + cells_to_be_activated_list_item.nRPCI = (F1AP_NRPCI_t *)calloc(1, sizeof(F1AP_NRPCI_t)); + *cells_to_be_activated_list_item.nRPCI = f1ap_gnb_cu_configuration_update->cells_to_activate[i].nrpci; // int 0..1007 + + // optional + // 3.1.2 gNB-CUSystem Information + F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs; + cells_to_be_activated_list_itemExtIEs = (F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t)); + cells_to_be_activated_list_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation; + cells_to_be_activated_list_itemExtIEs->criticality = F1AP_Criticality_reject; + cells_to_be_activated_list_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation; + + if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].num_SI > 0) { + F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)calloc(1, sizeof(F1AP_GNB_CUSystemInformation_t)); + //LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]); + //for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++) + // printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]); + //printf("\n"); + + // for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ? + for (int sIBtype=2;sIBtype<21;sIBtype++) { + if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype]!=NULL) { + AssertFatal(sIBtype < 6 || sIBtype == 9, "Illegal SI type %d\n",sIBtype); + F1AP_SibtypetobeupdatedListItem_t *sib_item = calloc(1,sizeof(*sib_item)); + memset((void*)sib_item,0,sizeof(*sib_item)); + sib_item->sIBtype = sIBtype; + OCTET_STRING_fromBuf(&sib_item->sIBmessage, + (const char*)f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container[sIBtype], + f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); + + LOG_D(F1AP, "f1ap_setup_resp->SI_container_length[%d][%d] = %d \n", i,sIBtype,f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_container_length[sIBtype]); + ASN_SEQUENCE_ADD(&gNB_CUSystemInformation->sibtypetobeupdatedlist.list,sib_item); + } + } + cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation = *gNB_CUSystemInformation; + + + F1AP_ProtocolExtensionContainer_154P112_t p_154P112_t; + memset((void *)&p_154P112_t, 0, sizeof(F1AP_ProtocolExtensionContainer_154P112_t)); + + ASN_SEQUENCE_ADD(&p_154P112_t.list, + cells_to_be_activated_list_itemExtIEs); + cells_to_be_activated_list_item.iE_Extensions = (struct F1AP_ProtocolExtensionContainer*)&p_154P112_t; + + free(gNB_CUSystemInformation); + gNB_CUSystemInformation = NULL; + } + } // ADD cells_to_be_activated_list_item_ies->value.choice.Cells_to_be_Activated_List_Item = cells_to_be_activated_list_item; ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Activated_List.list, cells_to_be_activated_list_item_ies); - } + } ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - + } - - /* - - // c3. Cells_to_be_Deactivated_List - // - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Deactivated_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Deactivated_List; - - for (i=0; - i<1; - i++) { - - F1AP_Cells_to_be_Deactivated_List_ItemIEs_t *cells_to_be_deactivated_list_item_ies; - cells_to_be_deactivated_list_item_ies = (F1AP_Cells_to_be_Deactivated_List_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Deactivated_List_ItemIEs_t)); - cells_to_be_deactivated_list_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; - cells_to_be_deactivated_list_item_ies->criticality = F1AP_Criticality_reject; - cells_to_be_deactivated_list_item_ies->value.present = F1AP_Cells_to_be_Deactivated_List_ItemIEs__value_PR_Cells_to_be_Deactivated_List_Item; - - // 3.1 cells to be Deactivated list item - F1AP_Cells_to_be_Deactivated_List_Item_t cells_to_be_deactivated_list_item; - memset((void *)&cells_to_be_deactivated_list_item, 0, sizeof(F1AP_Cells_to_be_Deactivated_List_Item_t)); - F1AP_NRCGI_t nRCGI; - memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); - cells_to_be_deactivated_list_item.nRCGI = nRCGI; + if(!RC.nrrrc) { - cells_to_be_deactivated_list_item_ies->value.choice.Cells_to_be_Deactivated_List_Item = cells_to_be_deactivated_list_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Deactivated_List.list, - cells_to_be_deactivated_list_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); -*/ + /* mandatory */ + /* c3. Cells_to_be_Deactivated_List */ + ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Deactivated_List; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Deactivated_List; + + for (i=0; + i<1; + i++) { + + F1AP_Cells_to_be_Deactivated_List_ItemIEs_t *cells_to_be_deactivated_list_item_ies; + cells_to_be_deactivated_list_item_ies = (F1AP_Cells_to_be_Deactivated_List_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Deactivated_List_ItemIEs_t)); + cells_to_be_deactivated_list_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; + cells_to_be_deactivated_list_item_ies->criticality = F1AP_Criticality_reject; + cells_to_be_deactivated_list_item_ies->value.present = F1AP_Cells_to_be_Deactivated_List_ItemIEs__value_PR_Cells_to_be_Deactivated_List_Item; + + // 3.1 cells to be Deactivated list item + F1AP_Cells_to_be_Deactivated_List_Item_t cells_to_be_deactivated_list_item; + memset((void *)&cells_to_be_deactivated_list_item, 0, sizeof(F1AP_Cells_to_be_Deactivated_List_Item_t)); - /* - // c4. GNB_CU_TNL_Association_To_Add_List - - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Add_List; + F1AP_NRCGI_t nRCGI; + memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); + MCC_MNC_TO_PLMNID(f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, + &nRCGI.pLMN_Identity); + NR_CELL_ID_TO_BIT_STRING(f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid, &nRCGI.nRCellIdentity); + cells_to_be_deactivated_list_item.nRCGI = nRCGI; - for (i=0; - i<1; - i++) { - - F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t *gnb_cu_tnl_association_to_add_item_ies; - gnb_cu_tnl_association_to_add_item_ies = (F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t)); - gnb_cu_tnl_association_to_add_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_Item; - gnb_cu_tnl_association_to_add_item_ies->criticality = F1AP_Criticality_reject; - gnb_cu_tnl_association_to_add_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Add_Item; - - // 4.1 GNB_CU_TNL_Association_To_Add_Item - F1AP_GNB_CU_TNL_Association_To_Add_Item_t gnb_cu_tnl_association_to_add_item; - memset((void *)&gnb_cu_tnl_association_to_add_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Add_Item_t)); + cells_to_be_deactivated_list_item_ies->value.choice.Cells_to_be_Deactivated_List_Item = cells_to_be_deactivated_list_item; + ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Deactivated_List.list, + cells_to_be_deactivated_list_item_ies); + } + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - // 4.1.1 tNLAssociationTransportLayerAddress - F1AP_CP_TransportLayerAddress_t transportLayerAddress; - memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - - // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; - // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); - // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); + /* mandatory */ + /* c4. GNB_CU_TNL_Association_To_Add_List */ + ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_List; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Add_List; - gnb_cu_tnl_association_to_add_item.tNLAssociationTransportLayerAddress = transportLayerAddress; + for (i=0; + i<1; + i++) { - // 4.1.2 tNLAssociationUsage - gnb_cu_tnl_association_to_add_item.tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; - + F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t *gnb_cu_tnl_association_to_add_item_ies; + gnb_cu_tnl_association_to_add_item_ies = (F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs_t)); + gnb_cu_tnl_association_to_add_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Add_Item; + gnb_cu_tnl_association_to_add_item_ies->criticality = F1AP_Criticality_reject; + gnb_cu_tnl_association_to_add_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Add_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Add_Item; - - gnb_cu_tnl_association_to_add_item_ies->value.choice.GNB_CU_TNL_Association_To_Add_Item = gnb_cu_tnl_association_to_add_item; - ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Add_List.list, - gnb_cu_tnl_association_to_add_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - */ - - /* - - // c5. GNB_CU_TNL_Association_To_Remove_List - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Remove_List; - for (i=0; - i<1; - i++) { - - F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t *gnb_cu_tnl_association_to_remove_item_ies; - gnb_cu_tnl_association_to_remove_item_ies = (F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t)); - gnb_cu_tnl_association_to_remove_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_Item; - gnb_cu_tnl_association_to_remove_item_ies->criticality = F1AP_Criticality_reject; - gnb_cu_tnl_association_to_remove_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Remove_Item; - - // 4.1 GNB_CU_TNL_Association_To_Remove_Item - F1AP_GNB_CU_TNL_Association_To_Remove_Item_t gnb_cu_tnl_association_to_remove_item; - memset((void *)&gnb_cu_tnl_association_to_remove_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Remove_Item_t)); + // 4.1 GNB_CU_TNL_Association_To_Add_Item + F1AP_GNB_CU_TNL_Association_To_Add_Item_t gnb_cu_tnl_association_to_add_item; + memset((void *)&gnb_cu_tnl_association_to_add_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Add_Item_t)); - // 4.1.1 tNLAssociationTransportLayerAddress - F1AP_CP_TransportLayerAddress_t transportLayerAddress; - memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - - // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; - // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); - // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); + // 4.1.1 tNLAssociationTransportLayerAddress + F1AP_CP_TransportLayerAddress_t transportLayerAddress; + memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - gnb_cu_tnl_association_to_remove_item.tNLAssociationTransportLayerAddress = transportLayerAddress; - + // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; + // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); + // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); + + gnb_cu_tnl_association_to_add_item.tNLAssociationTransportLayerAddress = transportLayerAddress; + + // 4.1.2 tNLAssociationUsage + gnb_cu_tnl_association_to_add_item.tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; - gnb_cu_tnl_association_to_remove_item_ies->value.choice.GNB_CU_TNL_Association_To_Remove_Item = gnb_cu_tnl_association_to_remove_item; - ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Remove_List.list, - gnb_cu_tnl_association_to_remove_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - */ - /* - //c6. GNB_CU_TNL_Association_To_Update_List - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Update_List; - for (i=0; - i<1; - i++) { - - F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t *gnb_cu_tnl_association_to_update_item_ies; - gnb_cu_tnl_association_to_update_item_ies = (F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t)); - gnb_cu_tnl_association_to_update_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_Item; - gnb_cu_tnl_association_to_update_item_ies->criticality = F1AP_Criticality_reject; - gnb_cu_tnl_association_to_update_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Update_Item; - - // 4.1 GNB_CU_TNL_Association_To_Update_Item - F1AP_GNB_CU_TNL_Association_To_Update_Item_t gnb_cu_tnl_association_to_update_item; - memset((void *)&gnb_cu_tnl_association_to_update_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Update_Item_t)); + gnb_cu_tnl_association_to_add_item_ies->value.choice.GNB_CU_TNL_Association_To_Add_Item = gnb_cu_tnl_association_to_add_item; + ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Add_List.list, + gnb_cu_tnl_association_to_add_item_ies); + } + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - // 4.1.1 tNLAssociationTransportLayerAddress - F1AP_CP_TransportLayerAddress_t transportLayerAddress; - memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; - TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - - // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); - // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; - // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); - // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); + /* mandatory */ + /* c5. GNB_CU_TNL_Association_To_Remove_List */ + ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_List; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Remove_List; + for (i=0; + i<1; + i++) { - gnb_cu_tnl_association_to_update_item.tNLAssociationTransportLayerAddress = transportLayerAddress; - + F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t *gnb_cu_tnl_association_to_remove_item_ies; + gnb_cu_tnl_association_to_remove_item_ies = (F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs_t)); + gnb_cu_tnl_association_to_remove_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Remove_Item; + gnb_cu_tnl_association_to_remove_item_ies->criticality = F1AP_Criticality_reject; + gnb_cu_tnl_association_to_remove_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Remove_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Remove_Item; - // 4.1.2 tNLAssociationUsage - if (1) { - gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = (F1AP_TNLAssociationUsage_t *)calloc(1, sizeof(F1AP_TNLAssociationUsage_t)); - *gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; - } - - - gnb_cu_tnl_association_to_update_item_ies->value.choice.GNB_CU_TNL_Association_To_Update_Item = gnb_cu_tnl_association_to_update_item; - ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Update_List.list, - gnb_cu_tnl_association_to_update_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + // 4.1 GNB_CU_TNL_Association_To_Remove_Item + F1AP_GNB_CU_TNL_Association_To_Remove_Item_t gnb_cu_tnl_association_to_remove_item; + memset((void *)&gnb_cu_tnl_association_to_remove_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Remove_Item_t)); - */ + // 4.1.1 tNLAssociationTransportLayerAddress + F1AP_CP_TransportLayerAddress_t transportLayerAddress; + memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); - /* - // c7. Cells_to_be_Barred_List - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Barred_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Barred_List; - for (i=0; - i<1; - i++) { + // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; + // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); + // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); - F1AP_Cells_to_be_Barred_ItemIEs_t *cells_to_be_barred_item_ies; - cells_to_be_barred_item_ies = (F1AP_Cells_to_be_Barred_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Barred_ItemIEs_t)); - cells_to_be_barred_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; - cells_to_be_barred_item_ies->criticality = F1AP_Criticality_reject; - cells_to_be_barred_item_ies->value.present = F1AP_Cells_to_be_Barred_ItemIEs__value_PR_Cells_to_be_Barred_Item; - - // 7.1 cells to be Deactivated list item - F1AP_Cells_to_be_Barred_Item_t cells_to_be_barred_item; - memset((void *)&cells_to_be_barred_item, 0, sizeof(F1AP_Cells_to_be_Barred_Item_t)); - - // - nRCGI - F1AP_NRCGI_t nRCGI; - memset(&nRCGI,0,sizeof(F1AP_NRCGI_t)); - MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, - &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); - cells_to_be_barred_item.nRCGI = nRCGI; - - // 7.2 cellBarred - cells_to_be_barred_item.cellBarred = F1AP_CellBarred_not_barred; - - cells_to_be_barred_item_ies->value.choice.Cells_to_be_Barred_Item = cells_to_be_barred_item; - ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Barred_List.list, - cells_to_be_barred_item_ies); - } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - - */ - - /* - // c8. Protected_EUTRA_Resources_List - ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Protected_EUTRA_Resources_List; - - for (i=0; - i<1; - i++) { + gnb_cu_tnl_association_to_remove_item.tNLAssociationTransportLayerAddress = transportLayerAddress; - F1AP_Protected_EUTRA_Resources_ItemIEs_t *protected_eutra_resources_item_ies; - // 8.1 SpectrumSharingGroupID - protected_eutra_resources_item_ies = (F1AP_Protected_EUTRA_Resources_ItemIEs_t *)calloc(1, sizeof(F1AP_Protected_EUTRA_Resources_ItemIEs_t)); - protected_eutra_resources_item_ies->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; - protected_eutra_resources_item_ies->criticality = F1AP_Criticality_reject; - protected_eutra_resources_item_ies->value.present = F1AP_Protected_EUTRA_Resources_ItemIEs__value_PR_Protected_EUTRA_Resources_Item; - ((F1AP_Protected_EUTRA_Resources_Item_t*)&protected_eutra_resources_item_ies->value.choice.Protected_EUTRA_Resources_Item)->spectrumSharingGroupID = 123L; - memset(&protected_eutra_resources_item_ies->value.choice.Protected_EUTRA_Resources_Item,0, - sizeof(F1AP_Protected_EUTRA_Resources_Item_t)); - ASN_SEQUENCE_ADD(&ie->value.choice.Protected_EUTRA_Resources_List.list, protected_eutra_resources_item_ies); + gnb_cu_tnl_association_to_remove_item_ies->value.choice.GNB_CU_TNL_Association_To_Remove_Item = gnb_cu_tnl_association_to_remove_item; + ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Remove_List.list, + gnb_cu_tnl_association_to_remove_item_ies); + } + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + /* mandatory */ + /* c6. GNB_CU_TNL_Association_To_Update_List */ + ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_List; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_GNB_CU_TNL_Association_To_Update_List; + for (i=0; + i<1; + i++) { + + F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t *gnb_cu_tnl_association_to_update_item_ies; + gnb_cu_tnl_association_to_update_item_ies = (F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t *)calloc(1, sizeof(F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs_t)); + gnb_cu_tnl_association_to_update_item_ies->id = F1AP_ProtocolIE_ID_id_GNB_CU_TNL_Association_To_Update_Item; + gnb_cu_tnl_association_to_update_item_ies->criticality = F1AP_Criticality_reject; + gnb_cu_tnl_association_to_update_item_ies->value.present = F1AP_GNB_CU_TNL_Association_To_Update_ItemIEs__value_PR_GNB_CU_TNL_Association_To_Update_Item; + + // 4.1 GNB_CU_TNL_Association_To_Update_Item + F1AP_GNB_CU_TNL_Association_To_Update_Item_t gnb_cu_tnl_association_to_update_item; + memset((void *)&gnb_cu_tnl_association_to_update_item, 0, sizeof(F1AP_GNB_CU_TNL_Association_To_Update_Item_t)); + + + // 4.1.1 tNLAssociationTransportLayerAddress + F1AP_CP_TransportLayerAddress_t transportLayerAddress; + memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address; + TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address); + + // memset((void *)&transportLayerAddress, 0, sizeof(F1AP_CP_TransportLayerAddress_t)); + // transportLayerAddress.present = F1AP_CP_TransportLayerAddress_PR_endpoint_IP_address_and_port; + // transportLayerAddress.choice.endpoint_IP_address_and_port = (F1AP_Endpoint_IP_address_and_port_t *)calloc(1, sizeof(F1AP_Endpoint_IP_address_and_port_t)); + // TRANSPORT_LAYER_ADDRESS_IPv4_TO_BIT_STRING(1234, &transportLayerAddress.choice.endpoint_IP_address_and_port.endpoint_IP_address); + + gnb_cu_tnl_association_to_update_item.tNLAssociationTransportLayerAddress = transportLayerAddress; + + + // 4.1.2 tNLAssociationUsage + if (1) { + gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = (F1AP_TNLAssociationUsage_t *)calloc(1, sizeof(F1AP_TNLAssociationUsage_t)); + *gnb_cu_tnl_association_to_update_item.tNLAssociationUsage = F1AP_TNLAssociationUsage_non_ue; + } + + + gnb_cu_tnl_association_to_update_item_ies->value.choice.GNB_CU_TNL_Association_To_Update_Item = gnb_cu_tnl_association_to_update_item; + ASN_SEQUENCE_ADD(&ie->value.choice.GNB_CU_TNL_Association_To_Update_List.list, + gnb_cu_tnl_association_to_update_item_ies); + } + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + + + /* mandatory */ + /* c7. Cells_to_be_Barred_List */ + ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Barred_List; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Barred_List; + for (i=0; + i<1; + i++) { + + F1AP_Cells_to_be_Barred_ItemIEs_t *cells_to_be_barred_item_ies; + cells_to_be_barred_item_ies = (F1AP_Cells_to_be_Barred_ItemIEs_t *)calloc(1, sizeof(F1AP_Cells_to_be_Barred_ItemIEs_t)); + cells_to_be_barred_item_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item; + cells_to_be_barred_item_ies->criticality = F1AP_Criticality_reject; + cells_to_be_barred_item_ies->value.present = F1AP_Cells_to_be_Barred_ItemIEs__value_PR_Cells_to_be_Barred_Item; + + // 7.1 cells to be Deactivated list item + F1AP_Cells_to_be_Barred_Item_t cells_to_be_barred_item; + memset((void *)&cells_to_be_barred_item, 0, sizeof(F1AP_Cells_to_be_Barred_Item_t)); + + // - nRCGI + F1AP_NRCGI_t nRCGI; + memset(&nRCGI,0,sizeof(F1AP_NRCGI_t)); + MCC_MNC_TO_PLMNID(f1ap_gnb_cu_configuration_update->cells_to_activate[i].mcc, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc, + f1ap_gnb_cu_configuration_update->cells_to_activate[i].mnc_digit_length, + &nRCGI.pLMN_Identity); + NR_CELL_ID_TO_BIT_STRING(f1ap_gnb_cu_configuration_update->cells_to_activate[i].nr_cellid, &nRCGI.nRCellIdentity); + cells_to_be_barred_item.nRCGI = nRCGI; + + // 7.2 cellBarred + cells_to_be_barred_item.cellBarred = F1AP_CellBarred_not_barred; + + cells_to_be_barred_item_ies->value.choice.Cells_to_be_Barred_Item = cells_to_be_barred_item; + ASN_SEQUENCE_ADD(&ie->value.choice.Cells_to_be_Barred_List.list, + cells_to_be_barred_item_ies); + } + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + + + /* mandatory */ + /* c8. Protected_EUTRA_Resources_List */ + ie = (F1AP_GNBCUConfigurationUpdateIEs_t *)calloc(1, sizeof(F1AP_GNBCUConfigurationUpdateIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Protected_EUTRA_Resources_List; + + for (i=0; + i<1; + i++) { + + + F1AP_Protected_EUTRA_Resources_ItemIEs_t *protected_eutra_resources_item_ies; + + // 8.1 SpectrumSharingGroupID + protected_eutra_resources_item_ies = (F1AP_Protected_EUTRA_Resources_ItemIEs_t *)calloc(1, sizeof(F1AP_Protected_EUTRA_Resources_ItemIEs_t)); + protected_eutra_resources_item_ies->id = F1AP_ProtocolIE_ID_id_Protected_EUTRA_Resources_List; + protected_eutra_resources_item_ies->criticality = F1AP_Criticality_reject; + protected_eutra_resources_item_ies->value.present = F1AP_Protected_EUTRA_Resources_ItemIEs__value_PR_Protected_EUTRA_Resources_Item; + ((F1AP_Protected_EUTRA_Resources_Item_t*)&protected_eutra_resources_item_ies->value.choice.Protected_EUTRA_Resources_Item)->spectrumSharingGroupID = 123L; + memset(&protected_eutra_resources_item_ies->value.choice.Protected_EUTRA_Resources_Item,0, + sizeof(F1AP_Protected_EUTRA_Resources_Item_t)); + ASN_SEQUENCE_ADD(&ie->value.choice.Protected_EUTRA_Resources_List.list, protected_eutra_resources_item_ies); + + /* F1AP_Served_EUTRA_Cells_Information_t served_eutra_cells_information; memset((void *)&served_eutra_cells_information, 0, sizeof(F1AP_Served_EUTRA_Cells_Information_t)); @@ -931,10 +941,10 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu ASN_SEQUENCE_ADD(&protected_eutra_resources_item_ies->value.choice.ListofEUTRACellsinGNBDUCoordination.list, &served_eutra_cells_information); ASN_SEQUENCE_ADD(&ie->value.choice.Protected_EUTRA_Resources_List.list, protected_eutra_resources_item_ies); - + */ + } + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - */ /* encode */ @@ -942,10 +952,11 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu LOG_E(F1AP, "Failed to encode F1 gNB-CU CONFIGURATION UPDATE\n"); return -1; } - - printf("F1AP gNB-CU CONFIGURATION UPDATE : "); - for (int i=0;iassoc_id, buffer, len, 0); return 0; } @@ -961,7 +972,7 @@ int CU_handle_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, uint32_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { - LOG_I(F1AP,"Cell Configuration ok (assoc_id %d)\n",assoc_id); + LOG_D(F1AP,"Cell Configuration ok (assoc_id %d)\n",assoc_id); return(0); } diff --git a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c index 2a029a3ac5..8a5b9785b5 100644 --- a/openair2/F1AP/f1ap_cu_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_cu_rrc_message_transfer.c @@ -38,13 +38,6 @@ #include "common/ran_context.h" #include "openair3/UTILS/conversions.h" -// undefine C_RNTI from -// openair1/PHY/LTE_TRANSPORT/transport_common.h which -// replaces in ie->value.choice.C_RNTI, causing -// a compile error -#undef C_RNTI - - // Bing Kai: create CU and DU context, and put all the information there. uint64_t du_ue_f1ap_id = 0; uint32_t f1ap_assoc_id = 0; @@ -116,7 +109,7 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, F1AP_ProtocolIE_ID_id_RRCContainer, true); AssertFatal(ie!=NULL,"RRCContainer is missing\n"); // create an ITTI message and copy SDU - if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { + if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { message_p = itti_alloc_new_message (TASK_CU_F1, 0, NR_RRC_MAC_CCCH_DATA_IND); memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE); ccch_sdu_len = ie->value.choice.RRCContainer.size; @@ -130,32 +123,35 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, ccch_sdu_len); } - LOG_I(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__, - ie->value.choice.RRCContainer.size); - for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) - printf("%02x ", RRC_MAC_CCCH_DATA_IND (message_p).sdu[i]); - printf("\n"); + if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { - /* DUtoCURRCContainer */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DUtoCURRCContainer, true); - if (ie) { - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t)); - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = ie->value.choice.DUtoCURRCContainer.size; - NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf = malloc(ie->value.choice.DUtoCURRCContainer.size); - memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf, - ie->value.choice.DUtoCURRCContainer.buf, - ie->value.choice.DUtoCURRCContainer.size); + LOG_D(F1AP, "%s() RRCContainer (CCCH) size %ld: ", __func__, ie->value.choice.RRCContainer.size); + //for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) + // printf("%02x ", RRC_MAC_CCCH_DATA_IND (message_p).sdu[i]); + //printf("\n"); + /* DUtoCURRCContainer */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_DUtoCURRCContainer, true); + if (ie) { + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container = malloc(sizeof(OCTET_STRING_t)); + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->size = ie->value.choice.DUtoCURRCContainer.size; + NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf = malloc( + ie->value.choice.DUtoCURRCContainer.size); + memcpy(NR_RRC_MAC_CCCH_DATA_IND (message_p).du_to_cu_rrc_container->buf, + ie->value.choice.DUtoCURRCContainer.buf, + ie->value.choice.DUtoCURRCContainer.size); + } } + // Find instance from nr_cellid int rrc_inst = -1; - if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { + if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { for (int i=0;inr_cellid == nr_cellid) { - rrc_inst = i; + rrc_inst = i; break; } } @@ -164,12 +160,11 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, // first get RRC instance (note, no the ITTI instance) eNB_RRC_INST *rrc = RC.rrc[i]; if (rrc->nr_cellid == nr_cellid) { - rrc_inst = i; + rrc_inst = i; break; } } } - AssertFatal(rrc_inst>=0,"couldn't find an RRC instance for nr_cell %llu\n",(unsigned long long int)nr_cellid); int f1ap_uid = f1ap_add_ue(&f1ap_cu_inst[rrc_inst], rrc_inst, CC_id, 0, rnti); @@ -180,21 +175,21 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance, } f1ap_cu_inst[rrc_inst].f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id; - if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { - NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; + if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { + NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; - NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance + NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; - NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; + NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p); } else { - RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; + RRC_MAC_CCCH_DATA_IND (message_p).frame = 0; RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0; RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len; - RRC_MAC_CCCH_DATA_IND (message_p).enb_index = rrc_inst; // CU instance + RRC_MAC_CCCH_DATA_IND (message_p).enb_index = rrc_inst; // CU instance RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti; - RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; + RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id; itti_send_msg_to_task (TASK_RRC_ENB, instance, message_p); } @@ -212,7 +207,7 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance, { LOG_D(F1AP, "CU send DL_RRC_MESSAGE_TRANSFER \n"); - F1AP_F1AP_PDU_t pdu; + F1AP_F1AP_PDU_t pdu; F1AP_DLRRCMessageTransfer_t *out; F1AP_DLRRCMessageTransferIEs_t *ie; @@ -293,33 +288,33 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance, OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char*)f1ap_dl_rrc->rrc_container, f1ap_dl_rrc->rrc_container_length); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); - LOG_I(F1AP, "%s() RRCContainer size %d: ", __func__, f1ap_dl_rrc->rrc_container_length); - for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) - printf("%02x ", f1ap_dl_rrc->rrc_container[i]); - printf("\n"); + if (RC.nrrrc && RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) { + LOG_I(F1AP, "%s() RRCContainer size %d: ", __func__, f1ap_dl_rrc->rrc_container_length); + for (int i = 0; i < ie->value.choice.RRCContainer.size; i++) + printf("%02x ", f1ap_dl_rrc->rrc_container[i]); + printf("\n"); + } /* optional */ /* c7. RAT_FrequencyPriorityInformation */ /* TODO */ - if (0) { - int endc=1; - ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_RAT_FrequencyPriorityInformation; - if (endc==1) { - ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC; - ie->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 123L; - } - else { - ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN; - ie->value.choice.RAT_FrequencyPriorityInformation.choice.nGRAN = 11L; - } - //ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_rAT_FrequencySelectionPriority; - //ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority = 123L; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + int endc=1; + ie = (F1AP_DLRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_DLRRCMessageTransferIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_RAT_FrequencyPriorityInformation; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_RAT_FrequencyPriorityInformation; + if (endc==1) { + ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC; + ie->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 123L; } - + else { + ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_nGRAN; + ie->value.choice.RAT_FrequencyPriorityInformation.choice.nGRAN = 11L; + } + //ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_rAT_FrequencySelectionPriority; + //ie->value.choice.RAT_FrequencyPriorityInformation.choice.rAT_FrequencySelectionPriority = 123L; + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 DL RRC MESSAGE TRANSFER \n"); @@ -344,7 +339,7 @@ int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance, F1AP_ULRRCMessageTransfer_t *container; F1AP_ULRRCMessageTransferIEs_t *ie; - + uint64_t cu_ue_f1ap_id; uint64_t du_ue_f1ap_id; uint64_t srb_id; diff --git a/openair2/F1AP/f1ap_cu_task.c b/openair2/F1AP/f1ap_cu_task.c index 24aec70b57..b261d8e85b 100644 --- a/openair2/F1AP/f1ap_cu_task.c +++ b/openair2/F1AP/f1ap_cu_task.c @@ -72,11 +72,16 @@ void cu_task_handle_sctp_association_resp(instance_t instance, sctp_new_associat f1ap_du_data_from_du->sctp_out_streams = sctp_new_association_resp->out_streams; /* setup parameters for F1U and start the server */ - const cudu_params_t params = { + const cudu_params_t params = (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_CU) ? (cudu_params_t){ .local_ipv4_address = RC.nrrrc[instance]->eth_params_s.my_addr, .local_port = RC.nrrrc[instance]->eth_params_s.my_portd, .remote_ipv4_address = RC.nrrrc[instance]->eth_params_s.remote_addr, .remote_port = RC.nrrrc[instance]->eth_params_s.remote_portd + } : (cudu_params_t){ + .local_ipv4_address = RC.rrc[instance]->eth_params_s.my_addr, + .local_port = RC.rrc[instance]->eth_params_s.my_portd, + .remote_ipv4_address = RC.rrc[instance]->eth_params_s.remote_addr, + .remote_port = RC.rrc[instance]->eth_params_s.remote_portd }; AssertFatal(proto_agent_start(instance, ¶ms) == 0, "could not start PROTO_AGENT for F1U on instance %ld!\n", instance); @@ -109,7 +114,7 @@ void cu_task_send_sctp_init_req(instance_t enb_id) { message_p->ittiMsg.sctp_init.ipv4 = 1; message_p->ittiMsg.sctp_init.ipv6 = 0; message_p->ittiMsg.sctp_init.nb_ipv4_addr = 1; - if (RC.nrrrc[0]->node_type == ngran_gNB_CU) { + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_CU) { message_p->ittiMsg.sctp_init.ipv4_address[0] = inet_addr(RC.nrrrc[enb_id]->eth_params_s.my_addr); } else{ message_p->ittiMsg.sctp_init.ipv4_address[0] = inet_addr(RC.rrc[enb_id]->eth_params_s.my_addr); diff --git a/openair2/F1AP/f1ap_cu_ue_context_management.c b/openair2/F1AP/f1ap_cu_ue_context_management.c index 85c992f757..da723ba5a3 100644 --- a/openair2/F1AP/f1ap_cu_ue_context_management.c +++ b/openair2/F1AP/f1ap_cu_ue_context_management.c @@ -39,8 +39,10 @@ #include "rrc_extern.h" #include "rrc_eNB_UE_context.h" +#include "openair2/RRC/NR/rrc_gNB_UE_context.h" #include "rrc_eNB_S1AP.h" #include "rrc_eNB_GTPV1U.h" +#include "openair2/RRC/NR/rrc_gNB_NGAP.h" extern f1ap_setup_req_t *f1ap_du_data_from_du; extern f1ap_cudu_inst_t f1ap_cu_inst[MAX_eNB]; @@ -151,7 +153,7 @@ int CU_send_UE_CONTEXT_SETUP_REQUEST(instance_t instance, ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); -if (0) { + /* mandatory */ /* c7. Candidate_SpCell_List */ ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); @@ -264,7 +266,7 @@ if (0) { f1ap_ue_context_setup_req->mnc, f1ap_ue_context_setup_req->mnc_digit_length, &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); scell_toBeSetup_item.sCell_ID = nRCGI; /* 10.1.2 sCellIndex */ @@ -476,7 +478,7 @@ if (0) { /* OPTIONAL */ /* gBR_QoS_Flow_Information */ if (0) { - DRB_Information->dRB_QoS.gBR_QoS_Flow_Information = (F1AP_GBR_QoSFlowInformation_t *)calloc(1, sizeof(F1AP_GBR_QoSFlowInformation_t)); + DRB_Information->dRB_QoS.gBR_QoS_Flow_Information = (F1AP_GBR_QoSFlowInformation_t *)calloc(1, sizeof(F1AP_GBR_QoSFlowInformation_t)); asn_long2INTEGER(&DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxFlowBitRateDownlink, 1L); asn_long2INTEGER(&DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxFlowBitRateUplink, 1L); asn_long2INTEGER(&DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink, 1L); @@ -485,14 +487,14 @@ if (0) { /* OPTIONAL */ /* maxPacketLossRateDownlink */ if (0) { - DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); + DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); *DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateDownlink = 1L; } /* OPTIONAL */ /* maxPacketLossRateUplink */ if (0) { - DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); + DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink = (F1AP_MaxPacketLossRate_t *)calloc(1, sizeof(F1AP_MaxPacketLossRate_t)); *DRB_Information->dRB_QoS.gBR_QoS_Flow_Information->maxPacketLossRateUplink = 1L; } @@ -501,7 +503,7 @@ if (0) { /* OPTIONAL */ /* reflective_QoS_Attribute */ if (0) { - DRB_Information->dRB_QoS.reflective_QoS_Attribute = (long *)calloc(1, sizeof(long)); + DRB_Information->dRB_QoS.reflective_QoS_Attribute = (long *)calloc(1, sizeof(long)); *DRB_Information->dRB_QoS.reflective_QoS_Attribute = 1L; } @@ -582,8 +584,9 @@ if (0) { /* packetErrorRate */ flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->packetErrorRate.pER_Scalar = 1L; - flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->packetErrorRate.pER_Exponent = 6L; - /* OPTIONAL */ + flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->packetErrorRate.pER_Exponent = 6L; + + /* OPTIONAL */ /* delayCritical */ if (0) { flows_mapped_to_drb_item.qoSFlowLevelQoSParameters.qoS_Characteristics.choice.dynamic_5QI->delayCritical = (long *)calloc(1, sizeof(long)); @@ -708,7 +711,7 @@ if (0) { } ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); -} + /* OPTIONAL */ /* InactivityMonitoringRequest */ if (0) { @@ -728,7 +731,7 @@ if (0) { ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_RAT_FrequencyPriorityInformation; - int endc = 1; // RK: Get this from somewhere ... + int endc = 1; // RK: Get this from somewhere ... if (endc) { ie->value.choice.RAT_FrequencyPriorityInformation.present = F1AP_RAT_FrequencyPriorityInformation_PR_eNDC; ie->value.choice.RAT_FrequencyPriorityInformation.choice.eNDC = 11L; @@ -741,13 +744,15 @@ if (0) { /* OPTIONAL */ /* RRCContainer */ - ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_RRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char*)f1ap_ue_context_setup_req->rrc_container, - f1ap_ue_context_setup_req->rrc_container_length); - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + if(RC.nrrrc) { + ie = (F1AP_UEContextSetupRequestIEs_t *)calloc(1, sizeof(F1AP_UEContextSetupRequestIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_RRCContainer; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_UEContextSetupRequestIEs__value_PR_RRCContainer; + OCTET_STRING_fromBuf(&ie->value.choice.RRCContainer, (const char*)f1ap_ue_context_setup_req->rrc_container, + f1ap_ue_context_setup_req->rrc_container_length); + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + } /* OPTIONAL */ /* MaskedIMEISV */ @@ -780,7 +785,9 @@ if (0) { LOG_D(F1AP,"F1AP UEContextSetupRequest Encoded %u bits\n", len); - cu_f1ap_itti_send_sctp_data_req(instance, f1ap_assoc_id /* BK: fix me*/ , buffer, len, 0 /* BK: fix me*/); + if(RC.nrrrc) { + cu_f1ap_itti_send_sctp_data_req(instance, f1ap_assoc_id /* BK: fix me*/ , buffer, len, 0 /* BK: fix me*/); + } return 0; } @@ -1024,35 +1031,55 @@ int CU_handle_UE_CONTEXT_RELEASE_COMPLETE(instance_t instance, // F1AP_CriticalityDiagnostics_IE_List } - struct rrc_eNB_ue_context_s *ue_context_p = - rrc_eNB_get_ue_context(RC.rrc[instance], rnti); protocol_ctxt_t ctxt; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, instance, ENB_FLAG_YES, rnti, 0, 0, instance); - if (ue_context_p) { - /* The following is normally done in the function rrc_rx_tx() */ - rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_CPLT(instance, - ue_context_p->ue_context.eNB_ue_s1ap_id); + if (RC.nrrrc[instance]->node_type == ngran_gNB_CU) { + struct rrc_gNB_ue_context_s *ue_context_p = + rrc_gNB_get_ue_context(RC.nrrrc[instance], rnti); - rrc_eNB_send_GTPV1U_ENB_DELETE_TUNNEL_REQ(instance, ue_context_p); - // erase data of GTP tunnels in UE context - for (int e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { - 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; + if (ue_context_p) { + MessageDef *msg = itti_alloc_new_message(TASK_CU_F1, 0, NGAP_UE_CONTEXT_RELEASE_COMPLETE); + NGAP_UE_CONTEXT_RELEASE_COMPLETE(msg).gNB_ue_ngap_id = ue_context_p->ue_context.gNB_ue_ngap_id; + itti_send_msg_to_task(TASK_NGAP, instance, msg); + + rrc_gNB_remove_ue_context(&ctxt, RC.nrrrc[instance], ue_context_p); + } else { + LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti); } +#ifdef ITTI_SIM + return 0; +#endif - struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = - rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], 0, - ue_context_p->ue_context.eNB_ue_s1ap_id); - if (rrc_ue_s1ap_ids) - rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); - - /* trigger UE release in RRC */ - rrc_eNB_remove_ue_context(&ctxt, RC.rrc[instance], ue_context_p); } else { - LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti); + struct rrc_eNB_ue_context_s *ue_context_p = + rrc_eNB_get_ue_context(RC.rrc[instance], rnti); + + if (ue_context_p) { + /* The following is normally done in the function rrc_rx_tx() */ + rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_CPLT(instance, + ue_context_p->ue_context.eNB_ue_s1ap_id); + + rrc_eNB_send_GTPV1U_ENB_DELETE_TUNNEL_REQ(instance, ue_context_p); + // erase data of GTP tunnels in UE context + for (int e_rab = 0; e_rab < ue_context_p->ue_context.nb_of_e_rabs; e_rab++) { + 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; + } + + struct rrc_ue_s1ap_ids_s *rrc_ue_s1ap_ids = + rrc_eNB_S1AP_get_ue_ids(RC.rrc[instance], 0, + ue_context_p->ue_context.eNB_ue_s1ap_id); + if (rrc_ue_s1ap_ids) + rrc_eNB_S1AP_remove_ue_ids(RC.rrc[instance], rrc_ue_s1ap_ids); + + /* trigger UE release in RRC */ + rrc_eNB_remove_ue_context(&ctxt, RC.rrc[instance], ue_context_p); + } else { + LOG_E(F1AP, "could not find ue_context of UE RNTI %x\n", rnti); + } } pdcp_remove_UE(&ctxt); @@ -1080,8 +1107,8 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { // for test int mcc = 208; - int mnc = 93; - int mnc_digit_length = 8; + int mnc = 92; + int mnc_digit_length = 2; /* Create */ /* 0. Message Type */ @@ -1122,7 +1149,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { F1AP_NRCGI_t nRCGI; MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); ie->value.choice.NRCGI = nRCGI; ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); @@ -1247,7 +1274,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); scell_toBeSetupMod_item.sCell_ID = nRCGI; /* sCellIndex */ @@ -1287,7 +1314,7 @@ int CU_send_UE_CONTEXT_MODIFICATION_REQUEST(instance_t instance) { memset(&nRCGI, 0, sizeof(F1AP_NRCGI_t)); MCC_MNC_TO_PLMNID(mcc, mnc, mnc_digit_length, &nRCGI.pLMN_Identity); - NR_CELL_ID_TO_BIT_STRING(123456, &nRCGI.nRCellIdentity); + NR_CELL_ID_TO_BIT_STRING(12345678, &nRCGI.nRCellIdentity); scell_toBeRemoved_item.sCell_ID = nRCGI; /* ADD */ diff --git a/openair2/F1AP/f1ap_decoder.c b/openair2/F1AP/f1ap_decoder.c index 1b35ca6ccf..ac55db7fda 100644 --- a/openair2/F1AP/f1ap_decoder.c +++ b/openair2/F1AP/f1ap_decoder.c @@ -161,7 +161,7 @@ int f1ap_decode_pdu(F1AP_F1AP_PDU_t *pdu, const uint8_t *const buffer, uint32_t 0, 0); - if (1 /*asn1_decoder_xer_print*/) { + if (asn1_decoder_xer_print) { LOG_E(F1AP, "----------------- ASN1 DECODER PRINT START----------------- \n"); xer_fprint(stdout, &asn_DEF_F1AP_F1AP_PDU, pdu); LOG_E(F1AP, "----------------- ASN1 DECODER PRINT END ----------------- \n"); diff --git a/openair2/F1AP/f1ap_du_interface_management.c b/openair2/F1AP/f1ap_du_interface_management.c index 6f43240e66..b6ece9b13f 100644 --- a/openair2/F1AP/f1ap_du_interface_management.c +++ b/openair2/F1AP/f1ap_du_interface_management.c @@ -43,8 +43,12 @@ extern RAN_CONTEXT_t RC; int nrb_lut[29] = {11, 18, 24, 25, 31, 32, 38, 51, 52, 65, 66, 78, 79, 93, 106, 107, 121, 132, 133, 135, 160, 162, 189, 216, 217, 245, 264, 270, 273}; int to_NRNRB(int nrb) { - for (int i=0;i<29;i++) if (nrb_lut[i] == nrb) return i; - AssertFatal(1==0,"nrb %d is not in the list of possible NRNRB\n",nrb); + if (RC.nrrrc) { + for (int i=0;i<29;i++) if (nrb_lut[i] == nrb) return i; + AssertFatal(1==0,"nrb %d is not in the list of possible NRNRB\n",nrb); + } else { + return nrb; + } } int DU_handle_RESET(instance_t instance, @@ -195,14 +199,19 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { served_cell_information.nRPCI = f1ap_du_data->nr_pci[i]; // int 0..1007 /* - fiveGS_TAC */ - uint8_t fiveGS_TAC[3]; - served_cell_information.fiveGS_TAC=calloc(1,sizeof(*served_cell_information.fiveGS_TAC)); - fiveGS_TAC[0] = ((uint8_t*)&f1ap_du_data->tac[i])[2]; - fiveGS_TAC[1] = ((uint8_t*)&f1ap_du_data->tac[i])[1]; - fiveGS_TAC[2] = ((uint8_t*)&f1ap_du_data->tac[i])[0]; - OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, - (const char *)fiveGS_TAC, - 3); + if (RC.nrrrc) { + uint8_t fiveGS_TAC[3]; + fiveGS_TAC[0] = ((uint8_t*)&f1ap_du_data->tac[i])[2]; + fiveGS_TAC[1] = ((uint8_t*)&f1ap_du_data->tac[i])[1]; + fiveGS_TAC[2] = ((uint8_t*)&f1ap_du_data->tac[i])[0]; + OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, + (const char *)fiveGS_TAC, + 3); + } else { + OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, + (const char*)&f1ap_du_data->tac[i], + 3); + } /* - Configured_EPS_TAC */ if(0){ @@ -240,7 +249,7 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { /* FDD.1.3 freqBandListNr */ int fdd_ul_num_available_freq_Bands = f1ap_du_data->nr_mode_info[i].fdd.ul_num_frequency_bands; - LOG_D(F1AP, "fdd_ul_num_available_freq_Bands = %d \n", fdd_ul_num_available_freq_Bands); + LOG_I(F1AP, "fdd_ul_num_available_freq_Bands = %d \n", fdd_ul_num_available_freq_Bands); int fdd_ul_j; for (fdd_ul_j=0; fdd_ul_jnr_mode_info[i].fdd.dl_num_frequency_bands; - LOG_D(F1AP, "fdd_dl_num_available_freq_Bands = %d \n", fdd_dl_num_available_freq_Bands); + LOG_I(F1AP, "fdd_dl_num_available_freq_Bands = %d \n", fdd_dl_num_available_freq_Bands); int fdd_dl_j; for (fdd_dl_j=0; fdd_dl_jnr_mode_info[i].tdd.num_frequency_bands; - LOG_D(F1AP, "tdd_num_available_freq_Bands = %d \n", tdd_num_available_freq_Bands); + LOG_I(F1AP, "tdd_num_available_freq_Bands = %d \n", tdd_num_available_freq_Bands); + AssertFatal(tdd_num_available_freq_Bands > 0, "should have at least one TDD band available\n"); int j; for (j=0; jmib[i],//f1ap_du_data->mib, f1ap_du_data->mib_length[i]); + LOG_D(F1AP,"Filling SIB1_message for cell %d, length %d\n",i,f1ap_du_data->sib1_length[i]); OCTET_STRING_fromBuf(&gNB_DU_System_Information->sIB1_message, // sept. 2018 (const char*)f1ap_du_data->sib1[i], f1ap_du_data->sib1_length[i]); @@ -404,15 +415,17 @@ int DU_send_F1_SETUP_REQUEST(instance_t instance) { /* mandatory */ /* c5. RRC VERSION */ - ie = (F1AP_F1SetupRequestIEs_t *)calloc(1, sizeof(F1AP_F1SetupRequestIEs_t)); - ie->id = F1AP_ProtocolIE_ID_id_GNB_DU_RRC_Version; - ie->criticality = F1AP_Criticality_reject; - ie->value.present = F1AP_F1SetupRequestIEs__value_PR_RRC_Version; - ie->value.choice.RRC_Version.latest_RRC_Version.buf=calloc(1,sizeof(char)); - ie->value.choice.RRC_Version.latest_RRC_Version.buf[0] = 0xe0; - ie->value.choice.RRC_Version.latest_RRC_Version.size = 1; - ie->value.choice.RRC_Version.latest_RRC_Version.bits_unused = 5; - ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + if(RC.nrrrc) { + ie = (F1AP_F1SetupRequestIEs_t *) calloc(1, sizeof(F1AP_F1SetupRequestIEs_t)); + ie->id = F1AP_ProtocolIE_ID_id_GNB_DU_RRC_Version; + ie->criticality = F1AP_Criticality_reject; + ie->value.present = F1AP_F1SetupRequestIEs__value_PR_RRC_Version; + ie->value.choice.RRC_Version.latest_RRC_Version.buf = calloc(1, sizeof(char)); + ie->value.choice.RRC_Version.latest_RRC_Version.buf[0] = 0xe0; + ie->value.choice.RRC_Version.latest_RRC_Version.size = 1; + ie->value.choice.RRC_Version.latest_RRC_Version.bits_unused = 5; + ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); + } /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { @@ -518,10 +531,12 @@ int DU_handle_F1_SETUP_RESPONSE(instance_t instance, cell->nRCGI.nRCellIdentity.buf[2], cell->nRCGI.nRCellIdentity.buf[3], cell->nRCGI.nRCellIdentity.buf[4]); + BIT_STRING_TO_NR_CELL_IDENTITY(&cell->nRCGI.nRCellIdentity, F1AP_SETUP_RESP (msg_p).cells_to_activate[i].nr_cellid); - F1AP_ProtocolExtensionContainer_154P112_t *ext = (F1AP_ProtocolExtensionContainer_154P112_t *)cell->iE_Extensions; - if (ext==NULL) continue; + F1AP_ProtocolExtensionContainer_154P112_t *ext = (F1AP_ProtocolExtensionContainer_154P112_t *)cell->iE_Extensions; + + if (ext==NULL) continue; for (int cnt=0;cntlist.count;cnt++) { F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs=(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)ext->list.array[cnt]; @@ -546,10 +561,10 @@ int DU_handle_F1_SETUP_RESPONSE(instance_t instance, for (int si = 0;si < gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count;si++) { F1AP_SibtypetobeupdatedListItem_t *sib_item = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.array[si]; size_t size = sib_item->sIBmessage.size; - F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container_length[si] = size; - LOG_D(F1AP, "F1AP: SI_container_length[%d][%d] %ld bytes\n", i, (int)sib_item->sIBtype, size); - F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[si] = malloc(F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container_length[si]); - memcpy((void*)F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[si], + F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container_length[sib_item->sIBtype] = size; + LOG_I(F1AP, "F1AP: SI_container_length[%d][%d] %ld bytes\n", i, (int)sib_item->sIBtype, size); + F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype] = malloc(size); + memcpy((void*)F1AP_SETUP_RESP (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype], (void*)sib_item->sIBmessage.buf, size); } @@ -582,10 +597,8 @@ int DU_handle_F1_SETUP_RESPONSE(instance_t instance, } // switch ie } // for IE AssertFatal(TransactionId!=-1,"TransactionId was not sent\n"); - LOG_D(F1AP,"F1AP: num_cells_to_activate %d\n",num_cells_to_activate); F1AP_SETUP_RESP (msg_p).num_cells_to_activate = num_cells_to_activate; - // tmp - // F1AP_SETUP_RESP (msg_p).num_SI[0] = 1; + for (int i=0;i 0, "System Information %d is missing",i); @@ -598,14 +611,14 @@ int DU_handle_F1_SETUP_RESPONSE(instance_t instance, 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), assoc_id); - if (RC.nrrrc[0]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) { LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message to GNB_APP with assoc_id (%d->%d)\n", assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); itti_send_msg_to_task(TASK_GNB_APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); } else { LOG_D(F1AP, "Sending F1AP_SETUP_RESP ITTI message to ENB_APP with assoc_id (%d->%d)\n", assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); - itti_send_msg_to_task(TASK_ENB_APP, ENB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); + itti_send_msg_to_task(TASK_ENB_APP, instance, msg_p); } return 0; @@ -719,13 +732,19 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, served_cell_information.nRPCI = f1ap_setup_req->nr_pci[i]; // int 0..1007 /* - fiveGS_TAC */ - uint8_t fiveGS_TAC[3]; - fiveGS_TAC[0] = ((uint8_t*)&f1ap_setup_req->tac[i])[2]; - fiveGS_TAC[1] = ((uint8_t*)&f1ap_setup_req->tac[i])[1]; - fiveGS_TAC[2] = ((uint8_t*)&f1ap_setup_req->tac[i])[0]; - OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, - (const char *)fiveGS_TAC, - 3); + if (RC.nrrrc) { + uint8_t fiveGS_TAC[3]; + fiveGS_TAC[0] = ((uint8_t*)&f1ap_setup_req->tac[i])[2]; + fiveGS_TAC[1] = ((uint8_t*)&f1ap_setup_req->tac[i])[1]; + fiveGS_TAC[2] = ((uint8_t*)&f1ap_setup_req->tac[i])[0]; + OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, + (const char *)fiveGS_TAC, + 3); + } else { + OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, + (const char *) &f1ap_setup_req->tac[i], + 3); + } /* - Configured_EPS_TAC */ if(1){ @@ -740,7 +759,6 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &servedPLMN_item->pLMN_Identity); ASN_SEQUENCE_ADD(&served_cell_information.servedPLMNs.list, servedPLMN_item); - // // /* - CHOICE NR-MODE-Info */ F1AP_NR_Mode_Info_t nR_Mode_Info; @@ -885,7 +903,6 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, served_cell_information.nRPCI = f1ap_setup_req->nr_pci[i]; // int 0..1007 /* - fiveGS_TAC */ - served_cell_information.fiveGS_TAC=calloc(1,sizeof(*served_cell_information.fiveGS_TAC)); OCTET_STRING_fromBuf(served_cell_information.fiveGS_TAC, (const char *) &f1ap_setup_req->tac[i], 3); @@ -903,8 +920,6 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, MCC_MNC_TO_PLMNID(f1ap_du_data->mcc[i], f1ap_du_data->mnc[i], f1ap_du_data->mnc_digit_length[i], &servedPLMN_item->pLMN_Identity); ASN_SEQUENCE_ADD(&served_cell_information.servedPLMNs.list, servedPLMN_item); - - // // /* - CHOICE NR-MODE-Info */ F1AP_NR_Mode_Info_t nR_Mode_Info; @@ -1072,6 +1087,10 @@ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { + if(!RC.nrrrc) { + return 0; + } + LOG_D(F1AP, "DU_handle_gNB_CU_CONFIGURATION_UPDATE\n"); AssertFatal(pdu->present == F1AP_F1AP_PDU_PR_initiatingMessage, @@ -1141,7 +1160,7 @@ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, F1AP_ProtocolExtensionContainer_154P112_t *ext = (F1AP_ProtocolExtensionContainer_154P112_t *)cell->iE_Extensions; if (ext==NULL) continue; - + for (int cnt=0;cntlist.count;cnt++) { F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs=(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)ext->list.array[cnt]; switch (cells_to_be_activated_list_itemExtIEs->id) { @@ -1165,10 +1184,10 @@ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, for (int si = 0;si < gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count;si++) { F1AP_SibtypetobeupdatedListItem_t *sib_item = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.array[si]; size_t size = sib_item->sIBmessage.size; - F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container_length[si] = size; - LOG_D(F1AP, "F1AP: SI_container_length[%d][%d] %ld bytes\n", i, (int)sib_item->sIBtype, size); - F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[si] = malloc(F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container_length[si]); - memcpy((void*)F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[si], + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container_length[sib_item->sIBtype] = size; + LOG_I(F1AP, "F1AP: SI_container_length[%d][%d] %ld bytes\n", i, (int)sib_item->sIBtype, size); + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype] = malloc(size); + memcpy((void*)F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].SI_container[sib_item->sIBtype], (void*)sib_item->sIBmessage.buf, size); } @@ -1213,7 +1232,7 @@ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, 0,0,//MSC_AS_TIME_ARGS(ctxt_pP), assoc_id); - if (RC.nrrrc[0]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) { LOG_D(F1AP, "Sending F1AP_GNB_CU_CONFIGURATION_UPDATE ITTI message to GNB_APP with assoc_id (%d->%d)\n", assoc_id,ENB_MODULE_ID_TO_INSTANCE(assoc_id)); itti_send_msg_to_task(TASK_GNB_APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p); @@ -1235,6 +1254,10 @@ int DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(instance_t instance, int DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, f1ap_gnb_cu_configuration_update_acknowledge_t *GNBCUConfigurationUpdateAcknowledge) { + if(!RC.nrrrc) { + return 0; + } + AssertFatal(GNBCUConfigurationUpdateAcknowledge->num_cells_failed_to_be_activated == 0, "%d cells failed to activate\n", GNBCUConfigurationUpdateAcknowledge->num_cells_failed_to_be_activated); @@ -1247,7 +1270,7 @@ int DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, AssertFatal(GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_failed == 0, "%d TNLAssociations failed\n", GNBCUConfigurationUpdateAcknowledge->noofTNLAssociations_failed); - + AssertFatal(GNBCUConfigurationUpdateAcknowledge->noofDedicatedSIDeliveryNeededUEs == 0, "%d DedicatedSIDeliveryNeededUEs\n", GNBCUConfigurationUpdateAcknowledge->noofDedicatedSIDeliveryNeededUEs); diff --git a/openair2/F1AP/f1ap_du_interface_management.h b/openair2/F1AP/f1ap_du_interface_management.h index f15decb6f5..619b725f38 100644 --- a/openair2/F1AP/f1ap_du_interface_management.h +++ b/openair2/F1AP/f1ap_du_interface_management.h @@ -98,17 +98,17 @@ int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, F1AP_F1AP_PDU_t *pdu); int DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(instance_t instance, - f1ap_gnb_cu_configuration_update_failure_t *GNBCUConfigurationUpdateFailure); + f1ap_gnb_cu_configuration_update_failure_t *GNBCUConfigurationUpdateFailure); int DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(instance_t instance, - f1ap_gnb_cu_configuration_update_acknowledge_t *GNBCUConfigurationUpdateAcknowledge); + f1ap_gnb_cu_configuration_update_acknowledge_t *GNBCUConfigurationUpdateAcknowledge); /* * gNB-DU Resource Coordination */ int DU_send_gNB_DU_RESOURCE_COORDINATION_REQUEST(instance_t instance, - F1AP_GNBDUResourceCoordinationRequest_t *GNBDUResourceCoordinationRequest); + F1AP_GNBDUResourceCoordinationRequest_t *GNBDUResourceCoordinationRequest); int DU_handle_gNB_DU_RESOURCE_COORDINATION_RESPONSE(instance_t instance, uint32_t assoc_id, diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.c b/openair2/F1AP/f1ap_du_rrc_message_transfer.c index 92ce430bca..0c8f566fd6 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.c +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.c @@ -56,17 +56,18 @@ #include "intertask_interface.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" -// undefine C_RNTI from -// openair1/PHY/LTE_TRANSPORT/transport_common.h which -// replaces in ie->value.choice.C_RNTI, causing -// a compile error - -#undef C_RNTI - extern f1ap_setup_req_t *f1ap_du_data; extern RAN_CONTEXT_t RC; extern f1ap_cudu_inst_t f1ap_du_inst[MAX_eNB]; +extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt_pP, + const NR_SRB_ToAddModList_t * const srb2add_listP, + const NR_DRB_ToAddModList_t * const drb2add_listP, + const NR_DRB_ToReleaseList_t * const drb2release_listP, + const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_srb_bearer2add_list, + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_drb_bearer2add_list); + uint8_t du_ccch_flag = 1; int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, @@ -80,10 +81,9 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, uint32_t stream, F1AP_F1AP_PDU_t *pdu) { - if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) { LOG_I(F1AP, "node is gNB DU, call DU_handle_DL_NR_RRC_MESSAGE_TRANSFER \n"); - DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance, assoc_id, stream, pdu); - return 0; + return DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance, assoc_id, stream, pdu); } LOG_D(F1AP, "DU_handle_DL_RRC_MESSAGE_TRANSFER \n"); @@ -472,36 +472,36 @@ int DU_handle_DL_RRC_MESSAGE_TRANSFER(instance_t instance, DRB2LCHAN[i] = (uint8_t) * DRB_configList->list.array[i]->logicalChannelIdentity; } - rrc_mac_config_req_eNB( - ctxt.module_id, - 0,0,0,0,0,0, - 0, - ue_context_p->ue_context.rnti, - (LTE_BCCH_BCH_Message_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, - (LTE_RadioResourceConfigCommonSIB_t *) NULL, - physicalConfigDedicated, - (LTE_SCellToAddMod_r10_t *)NULL, - //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, - (LTE_MeasObjectToAddMod_t **) NULL, - mac_MainConfig, - DRB2LCHAN[i], - DRB_configList->list.array[i]->logicalChannelConfig, - measGapConfig, - (LTE_TDD_Config_t *) NULL, - NULL, - (LTE_SchedulingInfoList_t *) NULL, - 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL - , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL, - (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL, - 0, - (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL, - (LTE_SchedulingInfo_MBMS_r14_t *) NULL, - (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL, - (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL, - (LTE_MBSFN_AreaInfoList_r9_t *) NULL, - (LTE_MBSFNAreaConfiguration_r9_t*) NULL - ); + rrc_mac_config_req_eNB( + ctxt.module_id, + 0,0,0,0,0,0, + 0, + ue_context_p->ue_context.rnti, + (LTE_BCCH_BCH_Message_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, + (LTE_RadioResourceConfigCommonSIB_t *) NULL, + physicalConfigDedicated, + (LTE_SCellToAddMod_r10_t *)NULL, + //(struct PhysicalConfigDedicatedSCell_r10 *)NULL, + (LTE_MeasObjectToAddMod_t **) NULL, + mac_MainConfig, + DRB2LCHAN[i], + DRB_configList->list.array[i]->logicalChannelConfig, + measGapConfig, + (LTE_TDD_Config_t *) NULL, + NULL, + (LTE_SchedulingInfoList_t *) NULL, + 0, NULL, NULL, (LTE_MBSFN_SubframeConfigList_t *) NULL + , 0, (LTE_MBSFN_AreaInfoList_r9_t *) NULL, (LTE_PMCH_InfoList_r9_t *) NULL, + (LTE_SystemInformationBlockType1_v1310_IEs_t *)NULL, + 0, + (LTE_BCCH_DL_SCH_Message_MBMS_t *) NULL, + (LTE_SchedulingInfo_MBMS_r14_t *) NULL, + (struct LTE_NonMBSFN_SubframeConfig_r14 *) NULL, + (LTE_SystemInformationBlockType1_MBMS_r14_t *) NULL, + (LTE_MBSFN_AreaInfoList_r9_t *) NULL, + (LTE_MBSFNAreaConfiguration_r9_t*) NULL + ); } } else { // remove LCHAN from MAC/PHY @@ -739,7 +739,7 @@ int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance, } else { LOG_I(F1AP, "Processing RRCConnectionSetupComplete UE %x\n", rnti); - ue_context_p->ue_context.Status = RRC_CONNECTED; + ue_context_p->ue_context.StatusRrc = RRC_CONNECTED; } break; @@ -799,8 +799,9 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, rnti_t rntiP, const uint8_t *sduP, sdu_size_t sdu_lenP, - const uint8_t *sdu2P, - sdu_size_t sdu2_lenP) { + const int8_t *sdu2P, + sdu_size_t sdu2_lenP) { + F1AP_F1AP_PDU_t pdu; F1AP_InitialULRRCMessageTransfer_t *out; F1AP_InitialULRRCMessageTransferIEs_t *ie; @@ -870,25 +871,22 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, /* optional */ /* c5. DUtoCURRCContainer */ - if (sdu2P) { + if (sdu2P && RC.nrrrc) { ie = (F1AP_InitialULRRCMessageTransferIEs_t *)calloc(1, sizeof(F1AP_InitialULRRCMessageTransferIEs_t)); ie->id = F1AP_ProtocolIE_ID_id_DUtoCURRCContainer; ie->criticality = F1AP_Criticality_reject; ie->value.present = F1AP_InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer; - OCTET_STRING_fromBuf(&ie->value.choice.DUtoCURRCContainer, - sdu2P, - sdu2_lenP); + OCTET_STRING_fromBuf(&ie->value.choice.DUtoCURRCContainer, (char *)sdu2P, sdu2_lenP); ASN_SEQUENCE_ADD(&out->protocolIEs.list, ie); } - /* encode */ if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) { LOG_E(F1AP, "Failed to encode F1 INITIAL UL RRC MESSAGE TRANSFER\n"); return -1; } - if (RC.nrrrc[module_idP]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[module_idP]->node_type == ngran_gNB_DU) { struct rrc_gNB_ue_context_s* ue_context_p = rrc_gNB_allocate_new_UE_context(RC.nrrrc[module_idP]); ue_context_p->ue_id_rnti = rntiP; ue_context_p->ue_context.rnti = rntiP; @@ -1164,7 +1162,7 @@ int DU_handle_DL_NR_RRC_MESSAGE_TRANSFER(instance_t instance, apply_macrlc_config(rrc,ue_context_p,&ctxt); - gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; + gNB_RRC_UE_t *ue_p = &ue_context_p->ue_context; AssertFatal(ue_p->Srb0.Active == 1,"SRB0 is not active\n"); memcpy((void*)ue_p->Srb0.Tx_buffer.Payload, diff --git a/openair2/F1AP/f1ap_du_rrc_message_transfer.h b/openair2/F1AP/f1ap_du_rrc_message_transfer.h index 0bb6371fe8..3036c66d70 100644 --- a/openair2/F1AP/f1ap_du_rrc_message_transfer.h +++ b/openair2/F1AP/f1ap_du_rrc_message_transfer.h @@ -50,7 +50,7 @@ int DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(module_id_t module_idP, rnti_t rntiP, const uint8_t *sduP, sdu_size_t sdu_lenP, - const uint8_t *sdu2P, - sdu_size_t sdu2_lenP); + const int8_t *sdu2P, + sdu_size_t sdu2_lenP); #endif /* F1AP_DU_RRC_MESSAGE_TRANSFER_H_ */ diff --git a/openair2/F1AP/f1ap_du_task.c b/openair2/F1AP/f1ap_du_task.c index 726d5629f8..50f7cdff80 100644 --- a/openair2/F1AP/f1ap_du_task.c +++ b/openair2/F1AP/f1ap_du_task.c @@ -86,9 +86,9 @@ void du_task_handle_sctp_association_resp(instance_t instance, sctp_new_associat DevAssert(sctp_new_association_resp != NULL); if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) { - LOG_W(F1AP, "Received unsuccessful result for SCTP association (%u), instance %ld, cnx_id %u\n", + LOG_E(F1AP, "Received unsuccessful result for SCTP association (%u), instance %d, cnx_id %u\n", sctp_new_association_resp->sctp_state, - instance, + (int)instance, sctp_new_association_resp->ulp_cnx_id); //f1ap_handle_setup_message(instance, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN); @@ -102,11 +102,16 @@ void du_task_handle_sctp_association_resp(instance_t instance, sctp_new_associat f1ap_du_data->default_sctp_stream_id = 0; /* setup parameters for F1U and start the server */ - const cudu_params_t params = { + const cudu_params_t params = (RC.nrrrc && RC.nrrrc[instance]->node_type == ngran_gNB_DU) ? (cudu_params_t){ .local_ipv4_address = RC.nrmac[instance]->eth_params_n.my_addr, .local_port = RC.nrmac[instance]->eth_params_n.my_portd, .remote_ipv4_address = RC.nrmac[instance]->eth_params_n.remote_addr, .remote_port = RC.nrmac[instance]->eth_params_n.remote_portd + } : (cudu_params_t){ + .local_ipv4_address = RC.mac[instance]->eth_params_n.my_addr, + .local_port = RC.mac[instance]->eth_params_n.my_portd, + .remote_ipv4_address = RC.mac[instance]->eth_params_n.remote_addr, + .remote_port = RC.mac[instance]->eth_params_n.remote_portd }; AssertFatal(proto_agent_start(instance, ¶ms) == 0, "could not start PROTO_AGENT for F1U on instance %ld!\n", instance); @@ -160,13 +165,13 @@ void *F1AP_DU_task(void *arg) { &F1AP_SETUP_REQ(received_msg)); break; case F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE: - DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), + DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), &F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(received_msg)); - break; + break; case F1AP_GNB_CU_CONFIGURATION_UPDATE_FAILURE: - DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), + DU_send_gNB_CU_CONFIGURATION_UPDATE_FAILURE(ITTI_MSG_DESTINATION_INSTANCE(received_msg), &F1AP_GNB_CU_CONFIGURATION_UPDATE_FAILURE(received_msg)); - break; + break; case SCTP_NEW_ASSOCIATION_RESP: // 1. store the respon @@ -190,14 +195,13 @@ void *F1AP_DU_task(void *arg) { DU_send_INITIAL_UL_RRC_MESSAGE_TRANSFER(0,0,0,msg->crnti, msg->rrc_container, msg->rrc_container_length, - msg->du2cu_rrc_container, - msg->du2cu_rrc_container_length - ); + (const int8_t*)msg->du2cu_rrc_container, + msg->du2cu_rrc_container_length); break; case F1AP_UL_RRC_MESSAGE: // to rrc LOG_I(F1AP, "DU Task Received F1AP_UL_RRC_MESSAGE\n"); - if (RC.nrrrc[0]->node_type == ngran_gNB_DU) { + if (RC.nrrrc && RC.nrrrc[0]->node_type == ngran_gNB_DU) { DU_send_UL_NR_RRC_MESSAGE_TRANSFER(ITTI_MSG_DESTINATION_INSTANCE(received_msg), &F1AP_UL_RRC_MESSAGE(received_msg)); } else { diff --git a/openair2/F1AP/f1ap_du_ue_context_management.c b/openair2/F1AP/f1ap_du_ue_context_management.c index 51bf7da32d..131dbce8ef 100644 --- a/openair2/F1AP/f1ap_du_ue_context_management.c +++ b/openair2/F1AP/f1ap_du_ue_context_management.c @@ -38,13 +38,8 @@ #include "rrc_extern.h" #include "rrc_eNB_UE_context.h" - -// undefine C_RNTI from -// openair1/PHY/LTE_TRANSPORT/transport_common.h which -// replaces in ie->value.choice.C_RNTI, causing -// a compile error - -#undef C_RNTI +#include "openair2/RRC/NR/rrc_gNB_UE_context.h" +#include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h" extern f1ap_setup_req_t *f1ap_du_data; extern f1ap_cudu_inst_t f1ap_du_inst[MAX_eNB]; @@ -108,22 +103,52 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, f1ap_ue_context_setup_req->cellULConfigured = NULL; } - /* CUtoDURRCInformation */ - /* Candidate_SpCell_List */ - /* optional */ - /* DRXCycle */ - /* optional */ - /* ResourceCoordinationTransferContainer */ - /* SCell_ToBeSetup_List */ - /* SRBs_ToBeSetup_List */ - /* DRBs_ToBeSetup_List */ - /* Decode DRBs_ToBeSetup_List */ - if(0) { + if (RC.nrrrc) { + /* RRCContainer */ F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true); + F1AP_ProtocolIE_ID_id_RRCContainer, false); + if (ie) { + /* correct here */ + f1ap_ue_context_setup_req->rrc_container = malloc(ie->value.choice.RRCContainer.size); + memcpy(f1ap_ue_context_setup_req->rrc_container, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); + } else { + LOG_E(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); + } + + // AssertFatal(0, "check configuration, send to appropriate handler\n"); + + protocol_ctxt_t ctxt; + // ctxt.rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], ie->value.choice.GNB_DU_UE_F1AP_ID); + ctxt.rnti = 0x1234; + ctxt.module_id = instance; + ctxt.instance = instance; + ctxt.enb_flag = 1; + + mem_block_t *pdcp_pdu_p = NULL; + pdcp_pdu_p = get_free_mem_block(ie->value.choice.RRCContainer.size, __func__); + if (pdcp_pdu_p != NULL) { + memset(pdcp_pdu_p->data, 0, ie->value.choice.RRCContainer.size); + memcpy(&pdcp_pdu_p->data[0], ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); + + /* for rfsim */ + du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ie->value.choice.RRCContainer.size, pdcp_pdu_p); + } + } else { + /* CUtoDURRCInformation */ + /* Candidate_SpCell_List */ + /* optional */ + /* DRXCycle */ + /* optional */ + /* ResourceCoordinationTransferContainer */ + /* SCell_ToBeSetup_List */ + /* SRBs_ToBeSetup_List */ + /* DRBs_ToBeSetup_List */ + /* Decode DRBs_ToBeSetup_List */ + F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, + F1AP_ProtocolIE_ID_id_DRBs_ToBeSetup_List, true); f1ap_ue_context_setup_req->drbs_to_be_setup_length = ie->value.choice.DRBs_ToBeSetup_List.list.count; f1ap_ue_context_setup_req->drbs_to_be_setup = calloc(f1ap_ue_context_setup_req->drbs_to_be_setup_length, - sizeof(f1ap_drb_to_be_setup_t)); + sizeof(f1ap_drb_to_be_setup_t)); AssertFatal(f1ap_ue_context_setup_req->drbs_to_be_setup, "could not allocate memory for f1ap_ue_context_setup_req->drbs_to_be_setup\n"); @@ -153,35 +178,7 @@ int DU_handle_UE_CONTEXT_SETUP_REQUEST(instance_t instance, } } } - /* RRCContainer */ - F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_UEContextSetupRequestIEs_t, ie, container, - F1AP_ProtocolIE_ID_id_RRCContainer, false); - if (ie) { - /* correct here */ - f1ap_ue_context_setup_req->rrc_container = malloc(ie->value.choice.RRCContainer.size); - memcpy(f1ap_ue_context_setup_req->rrc_container, ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); - } else { - LOG_E(F1AP, "can't find RRCContainer in UEContextSetupRequestIEs by id %ld \n", F1AP_ProtocolIE_ID_id_RRCContainer); - } - // AssertFatal(0, "check configuration, send to appropriate handler\n"); - - protocol_ctxt_t ctxt; - // ctxt.rnti = f1ap_get_rnti_by_du_id(&f1ap_du_inst[instance], ie->value.choice.GNB_DU_UE_F1AP_ID); - ctxt.rnti = 0x1234; - ctxt.module_id = instance; - ctxt.instance = instance; - ctxt.enb_flag = 1; - - mem_block_t *pdcp_pdu_p = NULL; - pdcp_pdu_p = get_free_mem_block(ie->value.choice.RRCContainer.size, __func__); - if (pdcp_pdu_p != NULL) { - memset(pdcp_pdu_p->data, 0, ie->value.choice.RRCContainer.size); - memcpy(&pdcp_pdu_p->data[0], ie->value.choice.RRCContainer.buf, ie->value.choice.RRCContainer.size); - - /* for rfsim */ - du_rlc_data_req(&ctxt, 1, 0x00, 1, 1, 0, ie->value.choice.RRCContainer.size, pdcp_pdu_p); - } return 0; } @@ -662,11 +659,21 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, rnti, ctxt.rnti); int UE_out_of_sync = 0; - for (int n = 0; n < MAX_MOBILES_PER_ENB; ++n) { - if (RC.mac[instance]->UE_info.active[n] == TRUE - && rnti == UE_RNTI(instance, n)) { - UE_out_of_sync = RC.mac[instance]->UE_info.UE_sched_ctrl[n].ul_out_of_sync; - break; + if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + for (int n = 0; n < MAX_MOBILES_PER_GNB; ++n) { + if (RC.nrmac[instance]->UE_info.active[n] == TRUE + && rnti == RC.nrmac[instance]->UE_info.rnti[n]) { + UE_out_of_sync = 0; + break; + } + } + } else { + for (int n = 0; n < MAX_MOBILES_PER_ENB; ++n) { + if (RC.mac[instance]->UE_info.active[n] == TRUE + && rnti == UE_RNTI(instance, n)) { + UE_out_of_sync = RC.mac[instance]->UE_info.UE_sched_ctrl[n].ul_out_of_sync; + break; + } } } @@ -716,6 +723,15 @@ int DU_handle_UE_CONTEXT_RELEASE_COMMAND(instance_t instance, } } + if (RC.nrrrc[instance]->node_type == ngran_gNB_DU) { + // struct rrc_gNB_ue_context_s *ue_context_p; + + f1ap_ue_context_release_cplt_t cplt; + cplt.rnti = ctxt.rnti; + DU_send_UE_CONTEXT_RELEASE_COMPLETE(instance, &cplt); + return 0; + } + struct rrc_eNB_ue_context_s *ue_context_p; ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.module_id], ctxt.rnti); diff --git a/openair2/F1AP/f1ap_encoder.c b/openair2/F1AP/f1ap_encoder.c index 1dbfd707c0..6e5f0f4e49 100644 --- a/openair2/F1AP/f1ap_encoder.c +++ b/openair2/F1AP/f1ap_encoder.c @@ -33,7 +33,7 @@ #include "f1ap_common.h" #include "f1ap_encoder.h" -int asn1_encoder_xer_print = 1; +int asn1_encoder_xer_print = 0; /* static inline int f1ap_encode_initiating(f1ap_message *message, @@ -84,12 +84,8 @@ int f1ap_encode_pdu(F1AP_F1AP_PDU_t *pdu, uint8_t **buffer, uint32_t *length) LOG_E(F1AP, "----------------- ASN1 ENCODER PRINT END----------------- \n"); } - encoded = aper_encode_to_new_buffer(&asn_DEF_F1AP_F1AP_PDU, 0, pdu, (void **)buffer); - - if (encoded < 0) { - LOG_E(F1AP, "Failed to encode F1AP message\n"); - return -1; - } + AssertFatal((encoded = aper_encode_to_new_buffer(&asn_DEF_F1AP_F1AP_PDU, 0, pdu, (void **)buffer))>0, + "Failed to encode F1AP message\n"); *length = encoded; diff --git a/openair2/GNB_APP/L1_nr_paramdef.h b/openair2/GNB_APP/L1_nr_paramdef.h index fd22e92730..8a41ac8a88 100644 --- a/openair2/GNB_APP/L1_nr_paramdef.h +++ b/openair2/GNB_APP/L1_nr_paramdef.h @@ -66,7 +66,7 @@ {CONFIG_STRING_L1_REMOTE_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:1, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:100, TYPE_UINT, 0}, \ -{CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:200, TYPE_UINT, 0}, \ +{CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:250, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:50, TYPE_UINT, 0} \ } #define L1_CC_IDX 0 diff --git a/openair2/GNB_APP/MACRLC_nr_paramdef.h b/openair2/GNB_APP/MACRLC_nr_paramdef.h index dd971801e9..bf8b32f591 100644 --- a/openair2/GNB_APP/MACRLC_nr_paramdef.h +++ b/openair2/GNB_APP/MACRLC_nr_paramdef.h @@ -55,6 +55,7 @@ #define CONFIG_STRING_MACRLC_REMOTE_S_PORTC "remote_s_portc" #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD "local_s_portd" #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD "remote_s_portd" +#define CONFIG_STRING_MACRLC_ULSCH_MAX_SLOTS_INACTIVITY "ulsch_max_slots_inactivity" #define CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10 "pusch_TargetSNRx10" #define CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10 "pucch_TargetSNRx10" #define CONFIG_STRING_MACRLC_PUCCHFAILURETHRES "pucch_FailureThres" @@ -82,10 +83,11 @@ {CONFIG_STRING_MACRLC_REMOTE_S_PORTC, NULL, 0, uptr:NULL, defintval:50020, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ -{CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ -{CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:150, TYPE_INT, 0}, \ -{CONFIG_STRING_MACRLC_PUCCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ -{CONFIG_STRING_MACRLC_PUSCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_ULSCH_MAX_SLOTS_INACTIVITY, "Maximum number of slots before a UE is scheduled ULSCH due to inactivity", 0, uptr:NULL, defintval:200, TYPE_UINT, 0}, \ +{CONFIG_STRING_MACRLC_PUSCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:200, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_PUCCHTARGETSNRX10, NULL, 0, iptr:NULL, defintval:150, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_PUCCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ +{CONFIG_STRING_MACRLC_PUSCHFAILURETHRES, NULL, 0, iptr:NULL, defintval:10, TYPE_INT, 0}, \ } #define MACRLC_CC_IDX 0 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 @@ -104,6 +106,7 @@ #define MACRLC_REMOTE_S_PORTC_IDX 14 #define MACRLC_LOCAL_S_PORTD_IDX 15 #define MACRLC_REMOTE_S_PORTD_IDX 16 +#define MACRLC_ULSCH_MAX_SLOTS_INACTIVITY 17 #define MACRLC_PUSCHTARGETSNRX10_IDX 17 #define MACRLC_PUCCHTARGETSNRX10_IDX 18 #define MACRLC_PUCCHFAILURETHRES_IDX 19 diff --git a/openair2/GNB_APP/gnb_app.c b/openair2/GNB_APP/gnb_app.c index d79d09d409..b1dc59f2e2 100644 --- a/openair2/GNB_APP/gnb_app.c +++ b/openair2/GNB_APP/gnb_app.c @@ -29,6 +29,10 @@ #include #include +#include +#include +#include +#include #include "gnb_app.h" #include "gnb_config.h" @@ -46,6 +50,7 @@ #include "f1ap_cu_task.h" #include "f1ap_du_task.h" #include "nfapi/oai_integration/vendor_ext.h" +#include extern unsigned char NB_gNB_INST; extern RAN_CONTEXT_t RC; @@ -128,6 +133,35 @@ static uint32_t gNB_app_register_x2(uint32_t gnb_id_start, uint32_t gnb_id_end) } /*------------------------------------------------------------------------------*/ + +static void init_pdcp(void) { + if (!NODE_IS_DU(RC.nrrrc[0]->node_type)) { + pdcp_layer_init(); + uint32_t pdcp_initmask = (IS_SOFTMODEM_NOS1) ? + (PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT; + if (IS_SOFTMODEM_NOS1) { + LOG_I(PDCP, "IS_SOFTMODEM_NOS1 option enabled\n"); + pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT; + } + + pdcp_module_init(pdcp_initmask); + + if (NODE_IS_CU(RC.nrrrc[0]->node_type)) { + LOG_I(PDCP, "node is CU, pdcp send rlc_data_req by proto_agent \n"); + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t)proto_agent_send_rlc_data_req); + } else { + LOG_I(PDCP, "node is gNB \n"); + pdcp_set_rlc_data_req_func((send_rlc_data_req_func_t) rlc_data_req); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) pdcp_data_ind); + } + } else { + LOG_I(PDCP, "node is DU, rlc send pdcp_data_ind by proto_agent \n"); + pdcp_set_pdcp_data_ind_func((pdcp_data_ind_func_t) proto_agent_send_pdcp_data_ind); + } +} + +/*------------------------------------------------------------------------------*/ + void *gNB_app_task(void *args_p) { @@ -142,12 +176,11 @@ void *gNB_app_task(void *args_p) /* for no gcc warnings */ (void)instance; - int cell_to_activate = 0; + int cell_to_activate = 0; itti_mark_task_ready (TASK_GNB_APP); LOG_I(PHY, "%s() Task ready initialize structures\n", __FUNCTION__); - if (RC.nb_nr_macrlc_inst>0) RCconfig_nr_macrlc(); LOG_I(PHY, "%s() RC.nb_nr_L1_inst:%d\n", __FUNCTION__, RC.nb_nr_L1_inst); @@ -170,25 +203,18 @@ void *gNB_app_task(void *args_p) configure_nr_rrc(gnb_id); } - for (int gnb_id = 0; gnb_id < RC.nb_nr_inst; gnb_id++) { - MessageDef *msg_p = itti_alloc_new_message (TASK_GNB_APP, 0, NRRRC_CONFIGURATION_REQ); - NRRRC_CONFIGURATION_REQ(msg_p) = RC.nrrrc[gnb_id]->configuration; - LOG_I(GNB_APP, "Sending configuration message to NR_RRC task\n"); - itti_send_msg_to_task (TASK_RRC_GNB, GNB_MODULE_ID_TO_INSTANCE(gnb_id), msg_p); - } - if (RC.nb_nr_inst > 0) { init_pdcp(); - } + if (is_x2ap_enabled() ) { //&& !NODE_IS_DU(RC.rrc[0]->node_type) LOG_I(X2AP, "X2AP enabled \n"); __attribute__((unused)) uint32_t x2_register_gnb_pending = gNB_app_register_x2 (gnb_id_start, gnb_id_end); } /* For the CU case the gNB registration with the AMF might have to take place after the F1 setup, as the PLMN info - * can originate from the DU. */ - if (AMF_MODE_ENABLED && !NODE_IS_DU(RC.nrrrc[0]->node_type)) { + * can originate from the DU. Add check on whether x2ap is enabled to account for ENDC NSA scenario.*/ + if ((AMF_MODE_ENABLED || is_x2ap_enabled()) && !NODE_IS_DU(RC.nrrrc[0]->node_type) && !NODE_IS_CU(RC.nrrrc[0]->node_type)) { /* Try to register each gNB */ //registered_gnb = 0; __attribute__((unused)) uint32_t register_gnb_pending = gNB_app_register (gnb_id_start, gnb_id_end); @@ -200,7 +226,6 @@ void *gNB_app_task(void *args_p) LOG_E(F1AP, "Create task for F1AP CU failed\n"); AssertFatal(1==0,"exiting"); } - pdcp_layer_init_for_CU(); } if (NODE_IS_DU(RC.nrrrc[0]->node_type)) { diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index b669451813..d8fb1045ff 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -35,6 +35,7 @@ #include "assertions.h" #include "gnb_config.h" #include "gnb_paramdef.h" +#include "enb_paramdef.h" #include "UTIL/OTG/otg.h" #include "UTIL/OTG/otg_externs.h" #include "intertask_interface.h" @@ -723,9 +724,10 @@ void RCconfig_nr_macrlc() { }else { // other midhaul AssertFatal(1==0,"MACRLC %d: %s unknown southbound midhaul\n",j,*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_S_PREFERENCE_IDX].strptr)); } + RC.nrmac[j]->ulsch_max_slots_inactivity = *(MacRLC_ParamList.paramarray[j][MACRLC_ULSCH_MAX_SLOTS_INACTIVITY].uptr); }// for (j=0;j 0 - printf("No %s configuration found \n", CONFIG_STRING_MACRLC_LIST); + LOG_E(PHY,"No %s configuration found\n", CONFIG_STRING_MACRLC_LIST); // AssertFatal (0,"No " CONFIG_STRING_MACRLC_LIST " configuration found"); } @@ -1026,7 +1028,7 @@ void RCconfig_NRRRC(MessageDef *msg_p, uint32_t i, gNB_RRC_INST *rrc) { AssertFatal(0, "The number of PLMN IDs must be in [1,6], but is %d\n", PLMNParamList.numelt); - RRC_CONFIGURATION_REQ(msg_p).num_plmn = PLMNParamList.numelt; + NRRRC_CONFIGURATION_REQ(msg_p).num_plmn = PLMNParamList.numelt; for (int l = 0; l < PLMNParamList.numelt; ++l) { @@ -1300,13 +1302,14 @@ int RCconfig_NR_NG(MessageDef *msg_p, uint32_t i) { NGAP_REGISTER_GNB_REQ (msg_p).amf_ip_address[j].ipv4 = 1; NGAP_REGISTER_GNB_REQ (msg_p).amf_ip_address[j].ipv6 = 1; } -/* not in configuration yet ... + /* not in configuration yet ... if (NGParamList.paramarray[l][GNB_AMF_BROADCAST_PLMN_INDEX].iptr) NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_num[l] = NGParamList.paramarray[l][GNB_AMF_BROADCAST_PLMN_INDEX].numelt; else NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_num[l] = 0; -*/ + */ + AssertFatal(NGAP_REGISTER_GNB_REQ(msg_p).broadcast_plmn_num[l] <= NGAP_REGISTER_GNB_REQ(msg_p).num_plmn, "List of broadcast PLMN to be sent to AMF can not be longer than actual " "PLMN list (max %d, but is %d)\n", @@ -1951,8 +1954,8 @@ int gNB_app_handle_f1ap_setup_resp(f1ap_setup_resp_t *resp) { du_extract_and_decode_SI(i, si_ind, - resp->cells_to_activate[j].SI_container[si_ind], - resp->cells_to_activate[j].SI_container_length[si_ind]); + resp->cells_to_activate[j].SI_container[2+si_ind], + resp->cells_to_activate[j].SI_container_length[2+si_ind]); } // perform MAC/L1 common configuration @@ -1986,8 +1989,8 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up du_extract_and_decode_SI(i, si_ind, - gnb_cu_cfg_update->cells_to_activate[j].SI_container[si_ind], - gnb_cu_cfg_update->cells_to_activate[j].SI_container_length[si_ind]); + gnb_cu_cfg_update->cells_to_activate[j].SI_container[2+si_ind], + gnb_cu_cfg_update->cells_to_activate[j].SI_container_length[2+si_ind]); } // perform MAC/L1 common configuration @@ -2085,7 +2088,7 @@ void nr_read_config_and_init(void) { } if (NODE_IS_CU(RC.nrrrc[0]->node_type)) { - pdcp_layer_init_for_CU(); + pdcp_layer_init(); // nr_DRB_preconfiguration(0x1234); rrc_init_nr_global_param(); } diff --git a/openair2/GNB_APP/gnb_config.h b/openair2/GNB_APP/gnb_config.h index 035a3ce76c..46102e4488 100644 --- a/openair2/GNB_APP/gnb_config.h +++ b/openair2/GNB_APP/gnb_config.h @@ -93,7 +93,7 @@ typedef struct ru_config_s { uint8_t if_compress; } ru_config_t; */ -extern void RCconfig_RU(void); +extern void NRRCconfig_RU(void); extern void RCconfig_nr_flexran(void); extern void RCconfig_NR_L1(void); extern void RCconfig_nr_macrlc(void); diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index ccbff6a5eb..4e063d2207 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -595,6 +595,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, CC_id = UE_PCCID(module_idP, UE_id); UE_scheduling_control = &(UE_info->UE_sched_ctrl[UE_id]); +/* to be merged with MAC_stats.log generation. probably redundant if (((frameP & 127) == 0) && (subframeP == 0)) { double total_bler; if(UE_scheduling_control->pusch_rx_num[CC_id] == 0 && UE_scheduling_control->pusch_rx_error_num[CC_id] == 0) { @@ -632,7 +633,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, UE_scheduling_control->aperiodic_ri_received[CC_id] ); } - +*/ RC.eNB[module_idP][CC_id]->pusch_stats_bsr[UE_id][(frameP * 10) + subframeP] = -63; if (UE_id == UE_info->list.head) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 3dea211dbc..8a400af1f3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -476,8 +476,8 @@ void generate_Msg2(module_id_t module_idP, first_rb = 0; vrb_map[first_rb] = 1; vrb_map[first_rb + 1] = 1; - vrb_map[first_rb + 2] = 1; - vrb_map[first_rb + 3] = 1; + //vrb_map[first_rb + 2] = 1; + //vrb_map[first_rb + 3] = 1; 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)); @@ -488,12 +488,12 @@ void generate_Msg2(module_id_t module_idP, dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // RA-RNTI : 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 = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 0; // no TPC dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; - dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 2); // This checks if the above DCI allocation is feasible in current subframe if (!CCE_allocation_infeasible(module_idP, CC_idP, 0, subframeP, @@ -512,7 +512,7 @@ void generate_Msg2(module_id_t module_idP, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized - 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.resource_block_coding = getRIV(N_RB_DL, first_rb, 2); dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0; dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block @@ -901,7 +901,7 @@ generate_Msg4(module_id_t module_idP, } // rach_resource_type > 0 else { // This is normal LTE case - LOG_I(MAC, "generate_Msg4 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP); + LOG_D(MAC, "generate_Msg4 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP); if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) { // Get RRCConnectionSetup for Piggyback @@ -918,7 +918,7 @@ generate_Msg4(module_id_t module_idP, module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length); // AssertFatal(rrc_sdu_length > 0, // "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length); - LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", + LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n", module_idP, CC_idP, frameP, subframeP, ra->rnti); /// Choose first 4 RBs for Msg4, should really check that these are free! first_rb = 0; @@ -1086,7 +1086,7 @@ generate_Msg4(module_id_t module_idP, } } // CCE Allocation feasible } else { - LOG_I(MAC, + LOG_D(MAC, "eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Delaying Msg4 for RRC Piggyback (RNTI %x)\n", module_idP, CC_idP, frameP, subframeP, ra->rnti); ra->Msg4_subframe ++; @@ -1289,8 +1289,8 @@ initiate_ra_proc(module_id_t module_idP, } LOG_D(MAC, - "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n", - module_idP, CC_id, frameP, subframeP, preamble_index); + "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d, timing offset %d\n", + module_idP, CC_id, frameP, subframeP, preamble_index, timing_offset); LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n", module_idP, CC_id, frameP, subframeP, rach_resource_type); @@ -1332,6 +1332,9 @@ initiate_ra_proc(module_id_t module_idP, abort(); case 1 : + case 3 : + case 4 : + case 5 : offset = 6; break; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index b516b04e03..596d978a98 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -651,7 +651,7 @@ schedule_ue_spec(module_id_t module_idP, eNB_UE_stats->rrc_status = mac_eNB_get_rrc_status(module_idP, rnti); eNB_UE_stats->harq_pid = harq_pid; eNB_UE_stats->harq_round = round_DL; - + eNB_UE_stats->dlsch_rounds[round_DL&7]++; if (eNB_UE_stats->rrc_status < RRC_RECONFIGURED) { ue_sched_ctrl->uplane_inactivity_timer = 0; } @@ -792,7 +792,6 @@ schedule_ue_spec(module_id_t module_idP, // No TX request for retransmission (check if null request for FAPI) } - //eNB_UE_stats->dlsch_trials[round]++; eNB_UE_stats->num_retransmission += 1; eNB_UE_stats->rbs_used_retx = nb_rb; eNB_UE_stats->total_rbs_used_retx += nb_rb; @@ -1065,20 +1064,23 @@ schedule_ue_spec(module_id_t module_idP, ue_template->pucch_tpc_tx_frame = frameP; ue_template->pucch_tpc_tx_subframe = subframeP; - if (snr > target_snr + 4) { + if (snr > target_snr + PUCCH_PCHYST) { tpc = 0; //-1 - } else if (snr < target_snr - 4) { + ue_sched_ctrl->pucch_tpc_accumulated[CC_id]--; + } else if (snr < target_snr - PUCCH_PCHYST) { tpc = 2; //+1 + ue_sched_ctrl->pucch_tpc_accumulated[CC_id]--; } else { tpc = 1; //0 } - LOG_D(MAC, "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, snr/target snr %d/%d (normal case)\n", + LOG_D(MAC, "[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d (accumulated %d), snr/target snr %d/%d (normal case)\n", module_idP, frameP, subframeP, harq_pid, tpc, + ue_sched_ctrl->pucch_tpc_accumulated[CC_id], snr, target_snr); } // Po_PUCCH has been updated @@ -1700,9 +1702,9 @@ schedule_ue_spec_br(module_id_t module_idP, UE_info->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP; UE_info->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP; - if (snr > target_snr + 4) { + if (snr > target_snr + PUCCH_PCHYST) { tpc = 0; //-1 - } else if (snr < target_snr - 4) { + } else if (snr < target_snr - PUCCH_PCHYST) { tpc = 2; //+1 } else { tpc = 1; //0 diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c index 23137b7887..e9f0b807c4 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c @@ -47,7 +47,7 @@ #include "OCG_extern.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "rlc.h" - +#include "common/utils/lte/prach_utils.h" #include "T.h" @@ -195,7 +195,7 @@ 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.radioresourceconfig[CC_id].ue_multiple_max; + dlsch_ue_max_num[CC_id] = eNB->ue_multiple_max; // 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; @@ -1044,48 +1044,6 @@ 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; - } - -#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) { @@ -1154,7 +1112,6 @@ schedule_ue_spec_fairRR(module_id_t module_idP, // int continue_flag = 0; int32_t snr, target_snr; int32_t tpc = 1; - static int32_t tpc_accumulated = 0; UE_sched_ctrl_t *ue_sched_ctl; int mcs; int i; @@ -1540,7 +1497,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP, subframeP, S_DL_SCHEDULED, rnti); - //eNB_UE_stats->dlsch_trials[round]++; + UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_rounds[round]++; UE_info->eNB_UE_stats[CC_id][UE_id].num_retransmission += 1; UE_info->eNB_UE_stats[CC_id][UE_id].rbs_used_retx = nb_rb; UE_info->eNB_UE_stats[CC_id][UE_id].total_rbs_used_retx += nb_rb; @@ -1982,6 +1939,7 @@ 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_info->eNB_UE_stats[CC_id][UE_id].dlsch_rounds[0]++; UE_info->eNB_UE_stats[CC_id][UE_id].rbs_used = nb_rb; UE_info->eNB_UE_stats[CC_id][UE_id].total_rbs_used += nb_rb; UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; @@ -2015,19 +1973,19 @@ schedule_ue_spec_fairRR(module_id_t module_idP, UE_info->UE_template[CC_id][UE_id].pucch_tpc_tx_frame=frameP; UE_info->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe=subframeP; - if (snr > target_snr + 4) { + if (snr > target_snr + PUCCH_PCHYST) { tpc = 0; //-1 - tpc_accumulated--; - } else if (snr < target_snr - 4) { + ue_sched_ctl->pucch_tpc_accumulated[CC_id]--; + } else if (snr < target_snr - PUCCH_PCHYST) { tpc = 2; //+1 - tpc_accumulated++; + ue_sched_ctl->pucch_tpc_accumulated[CC_id]++; } else { tpc = 1; //0 } LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, snr/target snr %d/%d\n", module_idP,frameP, subframeP,harq_pid,tpc, - tpc_accumulated,snr,target_snr); + ue_sched_ctl->pucch_tpc_accumulated[CC_id],snr,target_snr); } // Po_PUCCH has been updated else { tpc = 1; //0 @@ -2245,7 +2203,6 @@ 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]={{0}}; - // 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; @@ -2263,7 +2220,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( //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.radioresourceconfig[CC_id].ue_multiple_max; + ulsch_ue_max_num[CC_id] =eNB->ue_multiple_max; cc_id_flag[CC_id] = 0; ue_first_num[CC_id] = 0; ul_inactivity_num[CC_id] = 0; @@ -2290,6 +2247,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( // 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]; @@ -2322,6 +2280,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( //round round = UE_info->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; @@ -2352,6 +2311,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( UE_info->UE_template[CC_id][UE_id].scheduled_ul_bytes = 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; @@ -2369,9 +2329,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( UE_sched_ctl = &UE_info->UE_sched_ctrl[UE_id]; rrc_status = mac_eNB_get_rrc_status(module_idP, rnti); - - if ( ((UE_sched_ctl->ul_inactivity_timer>64)&&(UE_sched_ctl->ul_scheduled==0)) || - ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(rrc_status < RRC_CONNECTED)) || + if ( ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(rrc_status < RRC_CONNECTED)) || ((UE_sched_ctl->cqi_req_timer>64)&&((rrc_status >= 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; @@ -2482,6 +2440,7 @@ void ulsch_scheduler_pre_ue_select_fairRR( } rrc_status = mac_eNB_get_rrc_status(module_idP, rnti); + if ( (bytes_to_schedule > 0) || (UE_info->UE_template[CC_id][UE_id].ul_SR > 0) || ((UE_sched_ctl->ul_inactivity_timer>64)&&(UE_sched_ctl->ul_scheduled==0)) || ((UE_sched_ctl->ul_inactivity_timer>10)&&(UE_sched_ctl->ul_scheduled==0)&&(rrc_status < RRC_CONNECTED)) || @@ -2595,7 +2554,6 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, eNB_MAC_INST *eNB = RC.mac[module_idP]; UE_info_t *UE_info= &eNB->UE_info; UE_TEMPLATE *UE_template = NULL; - LTE_DL_FRAME_PARMS *frame_parms = NULL; uint8_t ue_num_temp; uint8_t total_rbs=0; uint8_t average_rbs; @@ -2617,18 +2575,17 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, // MCS and RB assgin 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); - + int N_RB_UL = to_prb(cc->ul_Bandwidth); if (cc->tdd_Config) { //TDD - if (frame_parms->N_RB_UL == 25) { + if (N_RB_UL == 25) { num_pucch_rb = 1; - } else if (frame_parms->N_RB_UL == 50) { + } else if (N_RB_UL == 50) { num_pucch_rb = 2; } else { num_pucch_rb = 3; } } else {//FDD - if (frame_parms->N_RB_UL == 25) { + if (N_RB_UL == 25) { num_pucch_rb = 1; } else { num_pucch_rb = 2; @@ -2653,13 +2610,13 @@ 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 ) { + if (first_rb[CC_id] >= 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; } - total_rbs = frame_parms->N_RB_UL-num_pucch_rb-first_rb[CC_id]; + total_rbs = 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 ) { @@ -2727,19 +2684,20 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, UE_info->UE_sched_ctrl[UE_id].pusch_rx_num_old[CC_id] = UE_info->UE_sched_ctrl[UE_id].pusch_rx_num[CC_id]; UE_info->UE_sched_ctrl[UE_id].pusch_rx_error_num_old[CC_id] = UE_info->UE_sched_ctrl[UE_id].pusch_rx_error_num[CC_id]; - if(bler < 0.5) { - if(UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id] !=0) { - UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id]--; + if (eNB->use_mcs_offset == 1) { + if(bler < eNB->bler_lower) { + if(UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id] !=0) { + UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id]--; + } } - } - if(bler >= 2) { - UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id]++; - if(UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id] >= 20) { - UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id]=20; + if(bler >= eNB->bler_upper) { + UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id]++; + if(UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id] >= 20) { + UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id]=20; + } } } } - snr = UE_info->UE_sched_ctrl[UE_id].pusch_snr_avg[CC_id]; mcs = 20 - UE_info->UE_sched_ctrl[UE_id].mcs_offset[CC_id]; @@ -2758,15 +2716,20 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, if ( ulsch_ue_select[CC_id].list[ulsch_ue_num].ul_total_buffer > 0 ) { rb_table_index = 2; tbs = get_TBS_UL(mcs,rb_table[rb_table_index]); - tx_power = (int8_t)(hundred_times_log10_NPRB[rb_table[rb_table_index] - 1] / 100); + tx_power= estimate_ue_tx_power(0,tbs*8,rb_table[rb_table_index],0,cc->Ncp,0); - 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 )) { - rb_table_index++; + while ( (((UE_template->phr_info - tx_power) < 0 ) || (tbs > bytes_to_schedule)) && (mcs > 3) ) { + mcs--; tbs = get_TBS_UL(mcs,rb_table[rb_table_index]); - tx_power = (int8_t)(hundred_times_log10_NPRB[rb_table[rb_table_index] - 1] / 100); + tx_power= estimate_ue_tx_power(0,tbs*8,rb_table[rb_table_index],0,cc->Ncp,0); } + while ( (tbs < bytes_to_schedule) && (rb_table[rb_table_index]<(N_RB_UL-num_pucch_rb-first_rb[CC_id])) && + ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < eNB->max_ul_rb_index )) { + rb_table_index++; + tbs = get_TBS_UL(mcs,rb_table[rb_table_index]); + tx_power= estimate_ue_tx_power(0,tbs*8,rb_table[rb_table_index],0,cc->Ncp,0); + } if ( rb_table[rb_table_index]<3 ) { rb_table_index=2; } @@ -2807,11 +2770,12 @@ void ulsch_scheduler_pre_processor_fairRR(module_id_t module_idP, UE_info->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; } else { // assigne RBS( 3 RBs) +/* first_rb[CC_id] = first_rb[CC_id] + 3; UE_info->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul = 3; UE_info->UE_template[CC_id][UE_id].pre_allocated_rb_table_index_ul = 2; - UE_info->UE_template[CC_id][UE_id].pre_assigned_mcs_ul = 10; - } + UE_info->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 ) { // assigne RBS( 3 RBs) @@ -2913,12 +2877,10 @@ schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, 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_idcommon_channels[CC_id]; - frame_parms= &RC.eNB[module_idP][CC_id]->frame_parms; - + int N_RB_UL=to_prb(cc->ul_Bandwidth); // 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 @@ -2928,13 +2890,13 @@ schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, 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) { + if(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(N_RB_UL) { case 25: default: ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = 1; @@ -2958,14 +2920,18 @@ schedule_ulsch_fairRR(module_id_t module_idP, frame_t frameP, } //PRACH - if (is_prach_subframe(frame_parms,sched_frame,sched_subframe)==1) { + if (is_prach_subframe0(cc->tdd_Config!=NULL ? cc->tdd_Config->subframeAssignment : 0,cc->tdd_Config!=NULL ? 1 : 0, + cc->radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex, + 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 --> shouldn't it be sched_frame ??? + ulsch_ue_select[CC_id].list[ulsch_ue_select[CC_id].ue_num].start_rb = + get_prach_prb_offset(cc->tdd_Config!=NULL ? 1 : 0, + cc->tdd_Config!=NULL ? cc->tdd_Config->subframeAssignment : 0, + to_prb(cc->ul_Bandwidth), + cc->radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex, + cc->radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset, + 0, + sched_frame); 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++; @@ -2993,7 +2959,6 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, uint32_t cqi_req,cshift,ndi,tpc; int32_t snr; int32_t target_snr=0; - static int32_t tpc_accumulated=0; int CC_id,ulsch_ue_num; int N_RB_UL; eNB_MAC_INST *eNB = RC.mac[module_idP]; @@ -3012,7 +2977,7 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, 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"); + LOG_D(MAC,"entering ulsch preprocesor for %d.%d\n",sched_frame,sched_subframeP); ulsch_scheduler_pre_processor_fairRR(module_idP, frameP, subframeP, @@ -3185,12 +3150,12 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, UE_template->pusch_tpc_tx_frame=frameP; UE_template->pusch_tpc_tx_subframe=subframeP; - if (snr > target_snr + 4) { + if (snr > target_snr + PUSCH_PCHYST) { tpc = 0; //-1 - tpc_accumulated--; - } else if (snr < target_snr - 4) { + UE_sched_ctrl->pusch_tpc_accumulated[CC_id]--; + } else if (snr < target_snr - PUSCH_PCHYST) { tpc = 2; //+1 - tpc_accumulated++; + UE_sched_ctrl->pusch_tpc_accumulated[CC_id]++; } else { tpc = 1; //0 } @@ -3201,7 +3166,7 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, if (tpc!=1) { LOG_D(MAC,"[eNB %d] ULSCH schedulerRR: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, snr/target snr %d/%d\n", module_idP,frameP,subframeP,harq_pid,tpc, - tpc_accumulated,snr,target_snr); + UE_sched_ctrl->pusch_tpc_accumulated[CC_id],snr,target_snr); } // new transmission @@ -3214,6 +3179,7 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, UE_sched_ctrl->cqi_req_timer); ndi = 1-UE_template->oldNDI_UL[harq_pid]; UE_template->oldNDI_UL[harq_pid]=ndi; + UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_rounds[0]++; UE_info->eNB_UE_stats[CC_id][UE_id].snr = snr; UE_info->eNB_UE_stats[CC_id][UE_id].target_snr = target_snr; UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1=UE_template->pre_assigned_mcs_ul; @@ -3402,6 +3368,7 @@ void schedule_ulsch_rnti_fairRR(module_id_t module_idP, T_INT(round)); UE_info->eNB_UE_stats[CC_id][UE_id].snr = snr; UE_info->eNB_UE_stats[CC_id][UE_id].target_snr = target_snr; + uint8_t mcs_rv = 0; if(rvidx_tab[round&3]==1) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index 47c27798bf..d4f486f761 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -57,7 +57,7 @@ #include "flexran_agent_mac.h" #include #include - +#include "common/utils/lte/prach_utils.h" #include "T.h" @@ -144,16 +144,18 @@ rx_sdu(const module_id_t enb_mod_idP, if (UE_id != -1) { UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id]; UE_template_ptr = &UE_info->UE_template[CC_idP][UE_id]; - 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", + LOG_D(MAC, "[eNB %d][PUSCH %d] CC_id %d %d.%d Received ULSCH (%s) sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d, timing_advance %d\n", enb_mod_idP, harq_pid, CC_idP, frameP, subframeP, + sduP==NULL ? "in error" : "OK", UE_scheduling_control->round_UL[CC_idP][harq_pid], current_rnti, UE_id, - ul_cqi); + ul_cqi, + timing_advance); AssertFatal(UE_scheduling_control->round_UL[CC_idP][harq_pid] < 8, "round >= 8\n"); if (sduP != NULL) { @@ -219,7 +221,7 @@ rx_sdu(const module_id_t enb_mod_idP, if (UE_scheduling_control->round_UL[CC_idP][harq_pid] == 3) { UE_scheduling_control->ul_scheduled &= (~(1 << harq_pid)); UE_scheduling_control->round_UL[CC_idP][harq_pid] = 0; - + UE_info->eNB_UE_stats[CC_idP][UE_id].ulsch_errors++; if (UE_scheduling_control->ul_consecutive_errors++ == 10) { UE_scheduling_control->ul_failure_timer = 1; } @@ -236,6 +238,7 @@ rx_sdu(const module_id_t enb_mod_idP, } } else { UE_scheduling_control->round_UL[CC_idP][harq_pid]++; + UE_info->eNB_UE_stats[CC_idP][UE_id].ulsch_rounds[UE_scheduling_control->round_UL[CC_idP][harq_pid]]++; } /* CDRX UL HARQ timers */ @@ -287,17 +290,35 @@ rx_sdu(const module_id_t enb_mod_idP, 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); - 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", + LOG_D(MAC, "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu (%s) round %d from PHY (rnti %x, RA_id %d) ul_cqi %d, timing advance %d\n", enb_mod_idP, harq_pid, CC_idP, + sduP!=NULL ? "OK" : "in error", ra->msg3_round, current_rnti, RA_id, - ul_cqi); + ul_cqi, + timing_advance); + first_rb = ra->msg3_first_rb; - if (sduP == NULL) { // we've got an error on Msg3 + bool no_sig = true; + if (sduP) { + for (int k = 0; k < sdu_lenP; k++) { + if(sduP[k]!=0) { + no_sig = false; + break; + } + } + } + + if (no_sig || sduP == NULL) { // we've got an error on Msg3 + + if(no_sig) { + LOG_D(MAC,"No signal in Msg3\n"); + } + LOG_D(MAC, "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n", enb_mod_idP, CC_idP, @@ -306,6 +327,20 @@ rx_sdu(const module_id_t enb_mod_idP, (int) mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx); if (ra->msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) { + + // Release RNTI of LTE PHY when RA does not succeed + UE_free_list_t *free_list = NULL; + pthread_mutex_lock(&lock_ue_freelist); + free_list = &mac->UE_free_list; + free_list->UE_free_ctrl[free_list->tail_freelist].rnti = current_rnti; + free_list->UE_free_ctrl[free_list->tail_freelist].removeContextFlg = 1; + free_list->UE_free_ctrl[free_list->tail_freelist].raFlag = 1; + free_list->num_UEs++; + mac->UE_release_req.ue_release_request_body.ue_release_request_TLVs_list[mac->UE_release_req.ue_release_request_body.number_of_TLVs].rnti = current_rnti; + mac->UE_release_req.ue_release_request_body.number_of_TLVs++; + free_list->tail_freelist = (free_list->tail_freelist + 1) % (NUMBER_OF_UE_MAX+1); + pthread_mutex_unlock(&lock_ue_freelist); + cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); nfapi_hi_dci0_request_t *hi_dci0_req = NULL; uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP); @@ -403,7 +438,8 @@ rx_sdu(const module_id_t enb_mod_idP, switch (rx_ces[i]) { // implement and process PHR + CRNTI + BSR case POWER_HEADROOM: if (UE_id != -1) { - UE_template_ptr->phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET + (int8_t)(hundred_times_log10_NPRB[UE_template_ptr->nb_rb_ul[harq_pid] - 1] / 100); + /*UE_template_ptr->phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET + (int8_t)(hundred_times_log10_NPRB[UE_template_ptr->nb_rb_ul[harq_pid] - 1] / 100);i*/ + UE_template_ptr->phr_info = (payload_ptr[0] & 0x3f) - PHR_MAPPING_OFFSET + estimate_ue_tx_power(0,sdu_lenP*8,UE_template_ptr->nb_rb_ul[harq_pid],0,mac->common_channels[CC_idP].Ncp,0); if (UE_template_ptr->phr_info > 40) { UE_template_ptr->phr_info = 40; @@ -424,7 +460,7 @@ rx_sdu(const module_id_t enb_mod_idP, case CRNTI: old_rnti = (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1]; 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", + LOG_I(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, @@ -438,7 +474,7 @@ rx_sdu(const module_id_t enb_mod_idP, /* Receiving CRNTI means that the current rnti has to go away */ if (old_UE_id != -1) { if (mac_eNB_get_rrc_status(enb_mod_idP,old_rnti) == RRC_HO_EXECUTION) { - LOG_I(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d : (rnti %x UE_id %d) Handover case\n", + LOG_D(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d : (rnti %x UE_id %d) Handover case\n", enb_mod_idP, frameP, subframeP, @@ -683,6 +719,19 @@ rx_sdu(const module_id_t enb_mod_idP, break; } + bool no_sig = true; + for (int k = 0; k < sdu_lenP; k++) { + if(sduP[k]!=0) { + no_sig = false; + break; + } + } + + if(no_sig) { + LOG_D(MAC, "No signal\n"); + 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, @@ -1293,16 +1342,19 @@ schedule_ulsch(module_id_t module_idP, /* Note: RC.nb_mac_CC[module_idP] should be lower than or equal to NFAPI_CC_MAX */ for (int CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++, cc++) { - LTE_DL_FRAME_PARMS *frame_parms = &RC.eNB[module_idP][CC_id]->frame_parms; - if (is_prach_subframe(frame_parms, sched_frame, sched_subframe)) { - int 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 - sched_frame); // Nf + + if (is_prach_subframe0(cc->tdd_Config!=NULL ? cc->tdd_Config->subframeAssignment : 0,cc->tdd_Config!=NULL ? 1 : 0, + cc->radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex, + sched_frame, sched_subframe)) { + int start_rb = get_prach_prb_offset(cc->tdd_Config!=NULL ? 1 : 0, + cc->tdd_Config!=NULL ? cc->tdd_Config->subframeAssignment : 0, + to_prb(cc->ul_Bandwidth), + cc->radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex, + cc->radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_FreqOffset, + 0, // tdd_mapindex + sched_frame); // Nf for (int i = 0; i < 6; i++) - cc[CC_id].vrb_map_UL[start_rb + i] = 1; + cc->vrb_map_UL[start_rb + i] = 1; } /* HACK: let's remove the PUCCH from available RBs @@ -1314,24 +1366,24 @@ schedule_ulsch(module_id_t module_idP, */ switch (to_prb(cc[CC_id].ul_Bandwidth)) { case 25: - cc[CC_id].vrb_map_UL[0] = 1; - cc[CC_id].vrb_map_UL[24] = 1; + cc->vrb_map_UL[0] = 1; + cc->vrb_map_UL[24] = 1; break; case 50: - cc[CC_id].vrb_map_UL[0] = 1; - cc[CC_id].vrb_map_UL[1] = 1; - cc[CC_id].vrb_map_UL[48] = 1; - cc[CC_id].vrb_map_UL[49] = 1; + cc->vrb_map_UL[0] = 1; + cc->vrb_map_UL[1] = 1; + cc->vrb_map_UL[48] = 1; + cc->vrb_map_UL[49] = 1; break; case 100: - cc[CC_id].vrb_map_UL[0] = 1; - cc[CC_id].vrb_map_UL[1] = 1; - cc[CC_id].vrb_map_UL[2] = 1; - cc[CC_id].vrb_map_UL[97] = 1; - cc[CC_id].vrb_map_UL[98] = 1; - cc[CC_id].vrb_map_UL[99] = 1; + cc->vrb_map_UL[0] = 1; + cc->vrb_map_UL[1] = 1; + cc->vrb_map_UL[2] = 1; + cc->vrb_map_UL[97] = 1; + cc->vrb_map_UL[98] = 1; + cc->vrb_map_UL[99] = 1; break; default: @@ -1349,6 +1401,8 @@ schedule_ulsch(module_id_t module_idP, /* * Schedule the DCI0 for ULSCH */ + + void schedule_ulsch_rnti(module_id_t module_idP, int CC_id, @@ -1356,7 +1410,6 @@ schedule_ulsch_rnti(module_id_t module_idP, sub_frame_t subframeP, unsigned char sched_subframeP) { /* TODO: does this need to be static? */ - static int32_t tpc_accumulated = 0; /* values from 0 to 7 can be used for mapping the cyclic shift * (36.211 , Table 5.5.2.1.1-1) */ const uint32_t cshift = 0; @@ -1481,8 +1534,7 @@ schedule_ulsch_rnti(module_id_t module_idP, /* Power control */ /* * Compute the expected ULSCH RX snr (for the stats) - * This is the normalized RX snr and this should be constant (regardless - * of mcs) Is not in dBm, unit from nfapi, converting to dBm + * */ const int32_t snr = UE_sched_ctrl_ptr->pusch_snr[CC_id]; const int32_t target_snr = mac->puSch10xSnr / 10; @@ -1501,12 +1553,12 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_template_ptr->pusch_tpc_tx_frame = frameP; UE_template_ptr->pusch_tpc_tx_subframe = subframeP; - if (snr > target_snr + 4) { + if (snr > target_snr + PUSCH_PCHYST) { tpc = 0; // -1 - tpc_accumulated--; - } else if (snr < target_snr - 4) { + UE_sched_ctrl_ptr->pusch_tpc_accumulated[CC_id]--; + } else if (snr < target_snr - PUSCH_PCHYST) { tpc = 2; // +1 - tpc_accumulated++; + UE_sched_ctrl_ptr->pusch_tpc_accumulated[CC_id]++; } } if (tpc != 1) { @@ -1518,7 +1570,7 @@ schedule_ulsch_rnti(module_id_t module_idP, subframeP, harq_pid, tpc, - tpc_accumulated, + UE_sched_ctrl_ptr->pusch_tpc_accumulated[CC_id], snr, target_snr); } @@ -1572,6 +1624,7 @@ schedule_ulsch_rnti(module_id_t module_idP, const uint8_t ndi = 1 - UE_template_ptr->oldNDI_UL[harq_pid]; // NDI: new data indicator const uint8_t mcs = UE_template_ptr->pre_assigned_mcs_ul; UE_template_ptr->oldNDI_UL[harq_pid] = ndi; + UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_rounds[0]++; UE_info->eNB_UE_stats[CC_id][UE_id].snr = snr; UE_info->eNB_UE_stats[CC_id][UE_id].target_snr = target_snr; UE_template_ptr->mcs_UL[harq_pid] = mcs; @@ -1593,8 +1646,6 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = mcs; - while (rb_table[rb_table_index] > 45 && rb_table_index > 0) - rb_table_index--; UE_template_ptr->TBS_UL[harq_pid] = get_TBS_UL(mcs, rb_table[rb_table_index]); UE_info->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += rb_table[rb_table_index]; @@ -2080,10 +2131,10 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, if (snr > target_snr + 4) { tpc = 0; //-1 - UE_sched_ctrl->tpc_accumulated[CC_id]--; + UE_sched_ctrl->pusch_tpc_accumulated[CC_id]--; } else if (snr < target_snr - 4) { tpc = 2; //+1 - UE_sched_ctrl->tpc_accumulated[CC_id]++; + UE_sched_ctrl->pusch_tpc_accumulated[CC_id]++; } else { tpc = 1; //0 } @@ -2098,7 +2149,7 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP, subframeP, harq_pid, tpc, - UE_sched_ctrl->tpc_accumulated[CC_id], + UE_sched_ctrl->pusch_tpc_accumulated[CC_id], snr, target_snr); } diff --git a/openair2/LAYER2/MAC/mac.h b/openair2/LAYER2/MAC/mac.h index ae8522bc83..cb93c2feb8 100644 --- a/openair2/LAYER2/MAC/mac.h +++ b/openair2/LAYER2/MAC/mac.h @@ -83,7 +83,7 @@ #define MAX_MAC_INST 16 #define BCCH_PAYLOAD_SIZE_MAX 128 -#define CCCH_PAYLOAD_SIZE_MAX 128 +#define CCCH_PAYLOAD_SIZE_MAX 512 #define PCCH_PAYLOAD_SIZE_MAX 128 #define RAR_PAYLOAD_SIZE_MAX 128 @@ -143,7 +143,10 @@ #define MAX_SUPPORTED_BW 4 /*!\brief CQI values range from 1 to 15 (4 bits) */ #define CQI_VALUE_RANGE 16 - +/*!\brief Hysteresis of PUSCH power control loop */ +#define PUSCH_PCHYST 1 +/*!\brief Hysteresis of PUCCH power control loop */ +#define PUCCH_PCHYST 1 /*!\brief value for indicating BSR Timer is not running */ #define MAC_UE_BSR_TIMER_NOT_RUNNING (0xFFFF) @@ -615,6 +618,8 @@ typedef struct { // here for RX // + + uint32_t ulsch_rounds[4]; uint32_t ulsch_bitrate; // uint32_t ulsch_bytes_rx; @@ -684,6 +689,17 @@ typedef struct { // Length of SDU Got from LC DL uint32_t sdu_length_tx[NB_RB_MAX]; + int lc_bytes_tx[64]; + int dlsch_rounds[8]; + int dlsch_errors; + int dlsch_total_bytes; + + int lc_bytes_rx[64]; + int ulsch_rounds[8]; + int ulsch_errors; + int ulsch_total_bytes_scheduled; + int ulsch_total_bytes_rx; + /// overall // @@ -776,7 +792,6 @@ typedef struct { uint32_t num_mac_sdu_rx; // Length of SDU Got from LC UL - Size array can be refined uint32_t sdu_length_rx[NB_RB_MAX]; - } eNB_UE_STATS; /*! \brief eNB template for UE context information */ @@ -982,7 +997,8 @@ typedef struct { uint16_t feedback_cnt[NFAPI_CC_MAX]; uint16_t timing_advance; uint16_t timing_advance_r9; - uint8_t tpc_accumulated[NFAPI_CC_MAX]; + int8_t pusch_tpc_accumulated[NFAPI_CC_MAX]; + int8_t pucch_tpc_accumulated[NFAPI_CC_MAX]; uint8_t periodic_wideband_cqi[NFAPI_CC_MAX]; uint8_t periodic_wideband_spatial_diffcqi[NFAPI_CC_MAX]; uint8_t periodic_wideband_pmi[NFAPI_CC_MAX]; @@ -1176,6 +1192,8 @@ typedef struct { rnti_t rnti; ///remove UE context flag boolean_t removeContextFlg; + ///remove RA flag + boolean_t raFlag; } UE_free_ctrl_t; /*! \brief REMOVE UE list used by eNB to order UEs/CC for deleting*/ typedef struct { @@ -1342,6 +1360,7 @@ typedef struct { uint8_t FeMBMS_flag; } COMMON_channels_t; /*! \brief top level eNB MAC structure */ + typedef struct eNB_MAC_INST_s { /// Ethernet parameters for northbound midhaul interface eth_params_t eth_params_n; @@ -1435,6 +1454,17 @@ typedef struct eNB_MAC_INST_s { int32_t puSch10xSnr; int32_t puCch10xSnr; + + int max_ul_rb_index; + + int ue_multiple_max; + + int use_mcs_offset; + + double bler_lower; + + double bler_upper; + pthread_t mac_stats_thread; } eNB_MAC_INST; /* diff --git a/openair2/LAYER2/MAC/mac_extern.h b/openair2/LAYER2/MAC/mac_extern.h index cda64ec0e9..cbca693b2a 100644 --- a/openair2/LAYER2/MAC/mac_extern.h +++ b/openair2/LAYER2/MAC/mac_extern.h @@ -78,5 +78,8 @@ extern eNB_UE_STATS pre_scd_eNB_UE_stats[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; extern mac_rlc_am_muilist_t rlc_am_mui; extern SCHEDULER_MODES global_scheduler_mode; + +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; extern rb_id_t mbms_rab_id; #endif //DEF_H diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index 59554425cc..a4e924c68b 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -40,8 +40,84 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "common/ran_context.h" #include "intertask_interface.h" +#include extern RAN_CONTEXT_t RC; +extern int oai_exit; + +void *mac_stats_thread(void *param) { + eNB_MAC_INST *mac = (eNB_MAC_INST *)param; + FILE *fd; + UE_info_t *UE_info = &(mac->UE_info); + + while (!oai_exit) { + sleep(1); + fd=fopen("MAC_stats.log","w+"); + AssertFatal(fd!=NULL,"Cannot open MAC_stats.log\n"); + + for (int UE_id = 0; UE_id < MAX_MOBILES_PER_ENB; UE_id++) { + if (UE_info->active[UE_id]) { + int rnti = UE_RNTI(mac->Mod_id, UE_id); + int CC_id = UE_PCCID(mac->Mod_id, UE_id); + UE_sched_ctrl_t *UE_scheduling_control = &(UE_info->UE_sched_ctrl[UE_id]); + + double total_bler; + if(UE_scheduling_control->pusch_rx_num[CC_id] == 0 && UE_scheduling_control->pusch_rx_error_num[CC_id] == 0) { + total_bler = 0; + } + else { + total_bler = (double)UE_scheduling_control->pusch_rx_error_num[CC_id] / (double)(UE_scheduling_control->pusch_rx_error_num[CC_id] + UE_scheduling_control->pusch_rx_num[CC_id]) * 100; + } + fprintf(fd,"MAC UE rnti %x : %s, PHR %d DLCQI %d PUSCH %d PUCCH %d RLC disc %d UL-stat rcv %lu err %lu bler %lf (%lf/%lf) total_bler %lf mcsoff %d pre_allocated nb_rb %d, mcs %d, bsr %u sched %u tbs %lu cnt %u , DL-stat tbs %lu cnt %u rb %u buf %u 1st %u ret %u ri %d\n", + rnti, + UE_scheduling_control->ul_out_of_sync == 0 ? "in synch" : "out of sync", + UE_info->UE_template[CC_id][UE_id].phr_info, + UE_scheduling_control->dl_cqi[CC_id], + UE_scheduling_control->pusch_snr/*_avg*/[CC_id], + UE_scheduling_control->pucch1_snr[CC_id], + UE_scheduling_control->rlc_out_of_resources_cnt, + UE_scheduling_control->pusch_rx_num[CC_id], + UE_scheduling_control->pusch_rx_error_num[CC_id], + UE_scheduling_control->pusch_bler[CC_id], + mac->bler_lower,mac->bler_upper,total_bler, + UE_scheduling_control->mcs_offset[CC_id], + UE_info->UE_template[CC_id][UE_id].pre_allocated_nb_rb_ul, + UE_info->UE_template[CC_id][UE_id].pre_assigned_mcs_ul, + UE_info->UE_template[CC_id][UE_id].estimated_ul_buffer, + UE_info->UE_template[CC_id][UE_id].scheduled_ul_bytes, + UE_info->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes_rx, + UE_info->eNB_UE_stats[CC_id][UE_id].total_num_pdus_rx, + UE_info->eNB_UE_stats[CC_id][UE_id].total_pdu_bytes, + UE_info->eNB_UE_stats[CC_id][UE_id].total_num_pdus, + UE_info->eNB_UE_stats[CC_id][UE_id].total_rbs_used, +#if defined(PRE_SCD_THREAD) + UE_info->UE_template[CC_id][UE_id].dl_buffer_total, +#else + 0, +#endif + UE_scheduling_control->first_cnt[CC_id], + UE_scheduling_control->ret_cnt[CC_id], + UE_scheduling_control->aperiodic_ri_received[CC_id] + ); + fprintf(fd," ULSCH rounds %d/%d/%d/%d, DLSCH rounds %d/%d/%d/%d, ULSCH errors %d, DLSCH errors %d\n", + UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_rounds[0], + UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_rounds[1], + UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_rounds[2], + UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_rounds[3], + UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_rounds[0], + UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_rounds[1], + UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_rounds[2], + UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_rounds[3], + UE_info->eNB_UE_stats[CC_id][UE_id].ulsch_errors, + UE_info->eNB_UE_stats[CC_id][UE_id].dlsch_errors); + + + } + } + fclose(fd); + } + return(NULL); +} void init_UE_info(UE_info_t *UE_info) { @@ -128,6 +204,9 @@ void mac_top_init_eNB(void) pdcp_layer_init(); rrc_init_global_param(); + + for (i=0;imac_stats_thread,NULL,mac_stats_thread,(void*)mac[i]); + } void mac_init_cell_params(int Mod_idP, int CC_idP) diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index bf8202f622..bb892c7efe 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -730,13 +730,13 @@ void calculate_max_mcs_min_rb(module_id_t mod_id, int tbs = get_TBS_UL(*mcs, rb_table[*rb_index]); // fixme: set use_srs flag - *tx_power = estimate_ue_tx_power(tbs * 8, rb_table[*rb_index], 0, Ncp, 0); + *tx_power = estimate_ue_tx_power(0,tbs * 8, rb_table[*rb_index], 0, Ncp, 0); /* find maximum MCS */ while ((phr - *tx_power < 0 || tbs > bytes) && *mcs > 3) { (*mcs)--; tbs = get_TBS_UL(*mcs, rb_table[*rb_index]); - *tx_power = estimate_ue_tx_power(tbs * 8, rb_table[*rb_index], 0, Ncp, 0); + *tx_power = estimate_ue_tx_power(0,tbs * 8, rb_table[*rb_index], 0, Ncp, 0); } /* find minimum necessary RBs */ @@ -746,7 +746,7 @@ void calculate_max_mcs_min_rb(module_id_t mod_id, && phr - *tx_power > 0) { (*rb_index)++; tbs = get_TBS_UL(*mcs, rb_table[*rb_index]); - *tx_power = estimate_ue_tx_power(tbs * 8, rb_table[*rb_index], 0, Ncp, 0); + *tx_power = estimate_ue_tx_power(0,tbs * 8, rb_table[*rb_index], 0, Ncp, 0); } /* Decrease if we went to far in last iteration */ @@ -801,7 +801,7 @@ int rr_ul_run(module_id_t Mod_id, AssertFatal(num_contig_rb <= 2, "cannot handle more than two contiguous RB regions\n"); UE_info_t *UE_info = &RC.mac[Mod_id]->UE_info; const int max_rb = num_contig_rb > 1 ? MAX(rbs[0].length, rbs[1].length) : rbs[0].length; - + eNB_MAC_INST *mac = RC.mac[Mod_id]; /* for every UE: check whether we have to handle a retransmission (and * allocate, if so). If not, compute how much RBs this UE would need */ int rb_idx_required[MAX_MOBILES_PER_ENB]; @@ -809,7 +809,7 @@ int rr_ul_run(module_id_t Mod_id, int num_ue_req = 0; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { UE_TEMPLATE *UE_template = &UE_info->UE_template[CC_id][UE_id]; - uint8_t harq_pid = subframe2harqpid(&RC.mac[Mod_id]->common_channels[CC_id], + uint8_t harq_pid = subframe2harqpid(&mac->common_channels[CC_id], sched_frame, sched_subframe); if (UE_info->UE_sched_ctrl[UE_id].round_UL[CC_id][harq_pid] > 0) { /* this UE has a retransmission, allocate it right away */ @@ -845,11 +845,11 @@ int rr_ul_run(module_id_t Mod_id, } } else { LOG_W(MAC, - "cannot allocate UL retransmission for UE %d (nb_rb %d)\n", - UE_id, - nb_rb); + "%d.%d cannot allocate UL retransmission for UE %d (nb_rb %d, rbs0.length %d, rbs1.length %d,rbs0.start %d,rbs1.start %d)\n", + sched_frame,sched_subframe,UE_id, + nb_rb, rbs[0].length,rbs[1].length,rbs[0].start,rbs[1].start); UE_template->pre_dci_ul_pdu_idx = -1; // do not need CCE - RC.mac[Mod_id]->HI_DCI0_req[CC_id][subframe].hi_dci0_request_body.number_of_dci--; + mac->HI_DCI0_req[CC_id][subframe].hi_dci0_request_body.number_of_dci--; continue; } LOG_D(MAC, "%4d.%d UE %d retx %d RBs at start %d\n", @@ -895,10 +895,9 @@ int rr_ul_run(module_id_t Mod_id, &tx_power); UE_template->pre_assigned_mcs_ul = mcs; - /* rb_idx_given >= 22: apparently the PHY cannot support more than 48 - * RBs in the uplink. Hence, we limit every UE to 48 RBs, which is at - * index 22 */ - rb_idx_required[UE_id] = min(22, rb_table_index); + /* rb_idx_given >= MAX index: limit RBs to value in configuration file + * RBs in the uplink. */ + rb_idx_required[UE_id] = min(mac->max_ul_rb_index, rb_table_index); //UE_template->pre_allocated_nb_rb_ul = rb_table[rb_table_index]; /* only print log when PHR changed */ static int phr = 0; diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index 23ac209389..d48952318a 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -67,8 +67,10 @@ fill_rar(const module_id_t module_idP, rar[5] = (uint8_t) (ra->rnti & 0xff); //ra->timing_offset = 0; ra->timing_offset /= 16; //T_A = N_TA/16, where N_TA should be on a 30.72Msps - rar[0] = (uint8_t) (ra->timing_offset >> (2 + 4)); // 7 MSBs of timing advance + divide by 4 - rar[1] = (uint8_t) (ra->timing_offset << (4 - 2)) & 0xf0; // 4 LSBs of timing advance + divide by 4 + //rar[0] = (uint8_t) (ra->timing_offset >> (2 + 4)); // 7 MSBs of timing advance + divide by 4 + //rar[1] = (uint8_t) (ra->timing_offset << (4 - 2)) & 0xf0; // 4 LSBs of timing advance + divide by 4 + rar[0] = (uint8_t) (ra->timing_offset >> (4)); // 7 MSBs of timing advance + divide by 4 + rar[1] = (uint8_t) (ra->timing_offset << (4)) & 0xf0; // 4 LSBs of timing advance + divide by 4 COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id]; if(N_RB_UL == 25) { diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 4d15d8d9e0..09fb08d7c4 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -56,7 +56,7 @@ // Definitions for MAC control and data #define NR_BCCH_DL_SCH 3 // SI #define NR_BCCH_BCH 5 // MIB -#define CCCH_PAYLOAD_SIZE_MAX 128 +#define CCCH_PAYLOAD_SIZE_MAX 512 #define RAR_PAYLOAD_SIZE_MAX 128 #define MAX_BWP_SIZE 275 @@ -151,10 +151,10 @@ typedef struct { // single Entry PHR MAC CE // TS 38.321 ch. 6.1.3.8 typedef struct { - uint8_t PH: 6; - uint8_t R1: 2; - uint8_t PCMAX: 6; - uint8_t R2: 6; + uint8_t PH: 6; // octet 1 [5:0] + uint8_t R1: 2; // octet 1 [7:6] + uint8_t PCMAX: 6; // octet 2 [5:0] + uint8_t R2: 2; // octet 2 [7:6] } __attribute__ ((__packed__)) NR_SINGLE_ENTRY_PHR_MAC_CE; diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c index 63d46d207e..8e666c376d 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.c @@ -1876,6 +1876,47 @@ uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config, } } +// TS 38.211 Table 7.4.1.1.2-3: PDSCH DMRS positions l' within a slot for single-symbol DMRS and intra-slot frequency hopping disabled. +// The first 4 colomns are PDSCH mapping type A and the last 4 colomns are PDSCH mapping type B. +// When l' = l0, it is represented by 1 +// E.g. when symbol duration is 12 in colomn 7, value 1057 ('10000100001') which means l' = l0, 5, 10. + +int32_t table_7_4_1_1_2_3_pdsch_dmrs_positions_l [13][8] = { // Duration in symbols +{-1, -1, -1, -1, 1, 1, 1, 1}, //2 // (DMRS l' position) +{0, 0, 0, 0, 1, 1, 1, 1}, //3 // (DMRS l' position) +{0, 0, 0, 0, 1, 1, 1, 1}, //4 // (DMRS l' position) +{0, 0, 0, 0, 1, 17, 17, 17}, //5 // (DMRS l' position) +{0, 0, 0, 0, 1, 17, 17, 17}, //6 // (DMRS l' position) +{0, 0, 0, 0, 1, 17, 17, 17}, //7 // (DMRS l' position) +{0, 128, 128, 128, 1, 65, 73, 73}, //8 // (DMRS l' position) +{0, 128, 128, 128, 1, 129, 145, 145}, //9 // (DMRS l' position) +{0, 512, 576, 576, 1, 129, 145, 145}, //10 // (DMRS l' position) +{0, 512, 576, 576, 1, 257, 273, 585}, //11 // (DMRS l' position) +{0, 512, 576, 2336, 1, 513, 545, 585}, //12 // (DMRS l' position) +{0, 2048, 2176, 2336, 1, 513, 545, 585}, //13 // (DMRS l' position) +{0, 2048, 2176, 2336, -1, -1, -1, -1}, //14 // (DMRS l' position) +}; + + +// TS 38.211 Table 7.4.1.1.2-4: PDSCH DMRS positions l' within a slot for double-symbol DMRS and intra-slot frequency hopping disabled. +// The first 4 colomns are PDSCH mapping type A and the last 4 colomns are PDSCH mapping type B. +// When l' = l0, it is represented by 1 + +int32_t table_7_4_1_1_2_4_pdsch_dmrs_positions_l [12][8] = { // Duration in symbols +{-1, -1, -1, -1, -1, -1, -1, -1}, //<4 // (DMRS l' position) +{0, 0, -1, -1, -1, -1, -1, -1}, //4 // (DMRS l' position) +{0, 0, -1, -1, 3, 3, -1, -1}, //5 // (DMRS l' position) +{0, 0, -1, -1, 3, 3, -1, -1}, //6 // (DMRS l' position) +{0, 0, -1, -1, 3, 3, -1, -1}, //7 // (DMRS l' position) +{0, 0, -1, -1, 3, 99, -1, -1}, //8 // (DMRS l' position) +{0, 0, -1, -1, 3, 99, -1, -1}, //9 // (DMRS l' position) +{0, 768, -1, -1, 3, 387, -1, -1}, //10 // (DMRS l' position) +{0, 768, -1, -1, 3, 387, -1, -1}, //11 // (DMRS l' position) +{0, 768, -1, -1, 3, 771, -1, -1}, //12 // (DMRS l' position) +{0, 3072, -1, -1, 3, 771, -1, -1}, //13 // (DMRS l' position) +{0, 3072, -1, -1, -1, -1, -1, -1}, //14 // (DMRS l' position) +}; + // TS 38.211 Table 6.4.1.1.3-3: PUSCH DMRS positions l' within a slot for single-symbol DMRS and intra-slot frequency hopping disabled. // The first 4 colomns are PUSCH mapping type A and the last 4 colomns are PUSCH mapping type B. // When l' = l0, it is represented by 1 @@ -1883,17 +1924,17 @@ uint8_t compute_nr_root_seq(NR_RACH_ConfigCommon_t *rach_config, int32_t table_6_4_1_1_3_3_pusch_dmrs_positions_l [12][8] = { // Duration in symbols {-1, -1, -1, -1, 1, 1, 1, 1}, //<4 // (DMRS l' position) -{1, 1, 1, 1, 1, 1, 1, 1}, //4 // (DMRS l' position) -{1, 1, 1, 1, 1, 5, 5, 5}, //5 // (DMRS l' position) -{1, 1, 1, 1, 1, 5, 5, 5}, //6 // (DMRS l' position) -{1, 1, 1, 1, 1, 5, 5, 5}, //7 // (DMRS l' position) -{1, 129, 129, 129, 1, 65, 73, 73}, //8 // (DMRS l' position) -{1, 129, 129, 129, 1, 65, 73, 73}, //9 // (DMRS l' position) -{1, 513, 577, 577, 1, 257, 273, 585}, //10 // (DMRS l' position) -{1, 513, 577, 577, 1, 257, 273, 585}, //11 // (DMRS l' position) -{1, 513, 577, 2337, 1, 1025, 1057, 585}, //12 // (DMRS l' position) -{1, 2049, 2177, 2337, 1, 1025, 1057, 585}, //13 // (DMRS l' position) -{1, 2049, 2177, 2337, 1, 1025, 1057, 585}, //14 // (DMRS l' position) +{0, 0, 0, 0, 1, 1, 1, 1}, //4 // (DMRS l' position) +{0, 0, 0, 0, 1, 17, 17, 17}, //5 // (DMRS l' position) +{0, 0, 0, 0, 1, 17, 17, 17}, //6 // (DMRS l' position) +{0, 0, 0, 0, 1, 17, 17, 17}, //7 // (DMRS l' position) +{0, 128, 128, 128, 1, 65, 73, 73}, //8 // (DMRS l' position) +{0, 128, 128, 128, 1, 65, 73, 73}, //9 // (DMRS l' position) +{0, 512, 576, 576, 1, 257, 273, 585}, //10 // (DMRS l' position) +{0, 512, 576, 576, 1, 257, 273, 585}, //11 // (DMRS l' position) +{0, 512, 576, 2336, 1, 1025, 1057, 585}, //12 // (DMRS l' position) +{0, 2048, 2176, 2336, 1, 1025, 1057, 585}, //13 // (DMRS l' position) +{0, 2048, 2176, 2336, 1, 1025, 1057, 585}, //14 // (DMRS l' position) }; @@ -1903,17 +1944,17 @@ int32_t table_6_4_1_1_3_3_pusch_dmrs_positions_l [12][8] = { int32_t table_6_4_1_1_3_4_pusch_dmrs_positions_l [12][8] = { // Duration in symbols {-1, -1, -1, -1, -1, -1, -1, -1}, //<4 // (DMRS l' position) -{1, 1, -1, -1, -1, -1, -1, -1}, //4 // (DMRS l' position) -{1, 1, -1, -1, 1, 1, -1, -1}, //5 // (DMRS l' position) -{1, 1, -1, -1, 1, 1, -1, -1}, //6 // (DMRS l' position) -{1, 1, -1, -1, 1, 1, -1, -1}, //7 // (DMRS l' position) -{1, 1, -1, -1, 1, 33, -1, -1}, //8 // (DMRS l' position) -{1, 1, -1, -1, 1, 33, -1, -1}, //9 // (DMRS l' position) -{1, 257, -1, -1, 1, 129, -1, -1}, //10 // (DMRS l' position) -{1, 257, -1, -1, 1, 129, -1, -1}, //11 // (DMRS l' position) -{1, 257, -1, -1, 1, 513, -1, -1}, //12 // (DMRS l' position) -{1, 1025, -1, -1, 1, 513, -1, -1}, //13 // (DMRS l' position) -{1, 1025, -1, -1, 1, 513, -1, -1}, //14 // (DMRS l' position) +{0, 0, -1, -1, -1, -1, -1, -1}, //4 // (DMRS l' position) +{0, 0, -1, -1, 3, 3, -1, -1}, //5 // (DMRS l' position) +{0, 0, -1, -1, 3, 3, -1, -1}, //6 // (DMRS l' position) +{0, 0, -1, -1, 3, 3, -1, -1}, //7 // (DMRS l' position) +{0, 0, -1, -1, 3, 99, -1, -1}, //8 // (DMRS l' position) +{0, 0, -1, -1, 3, 99, -1, -1}, //9 // (DMRS l' position) +{0, 768, -1, -1, 3, 387, -1, -1}, //10 // (DMRS l' position) +{0, 768, -1, -1, 3, 387, -1, -1}, //11 // (DMRS l' position) +{0, 768, -1, -1, 3, 1539, -1, -1}, //12 // (DMRS l' position) +{0, 3072, -1, -1, 3, 1539, -1, -1}, //13 // (DMRS l' position) +{0, 3072, -1, -1, 3, 1539, -1, -1}, //14 // (DMRS l' position) }; // Returns the corresponding row index of the NR table @@ -2459,8 +2500,8 @@ int get_num_dmrs(uint16_t dmrs_mask ) { return(num_dmrs); } /* returns the total DMRS symbols in a slot*/ -uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol){ - return get_num_dmrs(fill_dmrs_mask(pdsch_Config,dmrs_TypeA_Position,NrOfSymbols,startSymbol)); +uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols, int startSymbol, int mappingtype){ + return get_num_dmrs(fill_dmrs_mask(pdsch_Config,dmrs_TypeA_Position,NrOfSymbols, startSymbol, mappingtype)); } // Table 5.1.2.2.1-1 38.214 @@ -2524,29 +2565,46 @@ uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position) { } -int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength) { +int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength, uint8_t start_symbol, uint8_t dmrs_typeA_position) { uint8_t row, colomn; int32_t l_prime; + LOG_D(MAC, "PUSCH: NrofSymbols:%d, startSymbol:%d, mappingtype:%d, dmrs_TypeA_Position:%d\n", duration_in_symbols, start_symbol, mapping_type, dmrs_typeA_position); + + // Section 6.4.1.1.3 in Spec 38.211 + // For PDSCH Mapping TypeA, ld is duration between first OFDM of the slot and last OFDM symbol of the scheduled PUSCH resources + // For TypeB, ld is the duration of the scheduled PUSCH resources + uint8_t ld = (mapping_type == typeA) ? (duration_in_symbols + start_symbol) : duration_in_symbols; + uint8_t l0 = (dmrs_typeA_position == NR_MIB__dmrs_TypeA_Position_pos2) ? 2 : 3 ; + colomn = additional_pos; if (mapping_type == typeB) colomn += 4; - if (duration_in_symbols < 4) + if (ld < 4) row = 0; else - row = duration_in_symbols - 3; + row = ld - 3; - if (pusch_maxLength == pusch_len1) + if (pusch_maxLength == pusch_len1) { l_prime = table_6_4_1_1_3_3_pusch_dmrs_positions_l[row][colomn]; - else + l0 = 1 << l0; + } + else { l_prime = table_6_4_1_1_3_4_pusch_dmrs_positions_l[row][colomn]; + l0 = 1<0,"invalid l_prime < 0\n"); + LOG_D(MAC, "PUSCH - l0:%d, ld:%d,row:%d, column:%d, addpos:%d, maxlen:%d\n", l0, ld, row, colomn, additional_pos, pusch_maxLength); + AssertFatal(l_prime>=0,"invalid l_prime < 0\n"); + + l_prime = (mapping_type == typeA) ? (l_prime | l0) : (l_prime << start_symbol); + LOG_D(MAC, " PUSCH DMRS MASK in HEX:%x\n", l_prime); return l_prime; + } /******************************************************************* @@ -3053,7 +3111,7 @@ int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slo if (tdd_UL_DL_ConfigurationCommon->pattern2) { if (tdd_UL_DL_ConfigurationCommon->pattern2->ext1 && - tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530) + tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530) period2 = 3000+*tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530; else period2 = tdd_period_to_num[tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity]; @@ -3085,7 +3143,7 @@ int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, sl if (tdd_UL_DL_ConfigurationCommon->pattern2) { if (tdd_UL_DL_ConfigurationCommon->pattern2->ext1 && - tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530) + tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530) period2 = 3000+*tdd_UL_DL_ConfigurationCommon->pattern2->ext1->dl_UL_TransmissionPeriodicity_v1530; else period2 = tdd_period_to_num[tdd_UL_DL_ConfigurationCommon->pattern2->dl_UL_TransmissionPeriodicity]; @@ -3099,92 +3157,90 @@ int is_nr_UL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon, sl else return(slot_in_period >= slots1+tdd_UL_DL_ConfigurationCommon->pattern2->nrofDownlinkSlots ? 1 : 0); } -int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol) { +int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols, int startSymbol, int mappingtype_fromDCI) { + + int l0;int dmrs_AdditionalPosition = 0;int maxLength = 0; + NR_DMRS_DownlinkConfig_t *dmrs_config = NULL; + + LOG_D(MAC, "NrofSymbols:%d, startSymbol:%d, mappingtype:%d, dmrs_TypeA_Position:%d\n", NrOfSymbols, startSymbol, mappingtype_fromDCI, dmrs_TypeA_Position); - int l0; - int ld = NrOfSymbols+startSymbol; if (dmrs_TypeA_Position == NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2) l0=2; else if (dmrs_TypeA_Position == NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos3) l0=3; else AssertFatal(1==0,"Illegal dmrs_TypeA_Position %d\n",(int)dmrs_TypeA_Position); - if (pdsch_Config == NULL) { // Initial BWP - if (ld <= 7) return(1<dmrs_DownlinkForPDSCH_MappingTypeA && pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->present == NR_SetupRelease_DMRS_DownlinkConfig_PR_setup) + dmrs_config = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; + } else if (mappingtype_fromDCI == typeB) { + if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB && pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->present == NR_SetupRelease_DMRS_DownlinkConfig_PR_setup) + dmrs_config = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeB->choice.setup; + } else { + AssertFatal(1==0,"Incorrect Mappingtype\n"); + } + + AssertFatal(dmrs_config != NULL," DMRS configs not present in PDSCH DMRS Downlink config\n"); + + // default values of maxlength = len2, additionalposition is pos2 + if (dmrs_config->maxLength != NULL) maxLength = 2; + if (dmrs_config->dmrs_AdditionalPosition != NULL) dmrs_AdditionalPosition = *dmrs_config->dmrs_AdditionalPosition; + } + + uint8_t ld, row, column; + int32_t l_prime = -1; + + // columns 0-3 for TypeA, 4-7 for TypeB + column = (mappingtype_fromDCI == typeA) ? dmrs_AdditionalPosition : (dmrs_AdditionalPosition + 4); + + // Section 7.4.1.1.2 in Spec 38.211 + // For PDSCH Mapping TypeA, ld is duration between first OFDM of the slot and last OFDM symbol of the scheduled PDSCH resources + // For TypeB, ld is the duration of the scheduled PDSCH resources + ld = (mappingtype_fromDCI == typeA) ? (NrOfSymbols + startSymbol) : NrOfSymbols; + + // Section 7.4.1.1.2 in Spec 38.211 + //For PDSCH Mapping typeB, if PDSCH duration ld <=4, only single symbol DMRS is supported + if (mappingtype_fromDCI == typeB && ld <= 4) + maxLength = 1; + + AssertFatal(ld > 2 && ld < 15,"Illegal NrOfSymbols according to Table 5.1.2.1-1 Spec 38.214 %d\n",ld); + AssertFatal((NrOfSymbols + startSymbol) < 15,"Illegal S+L according to Table 5.1.2.1-1 Spec 38.214 S:%d L:%d\n",startSymbol, NrOfSymbols); + + if (mappingtype_fromDCI == typeA) { + + // Section 7.4.1.1.2 in Spec 38.211 + AssertFatal((l0 == 2) || (l0 == 3 && dmrs_AdditionalPosition != 3),"Wrong config, If dmrs_TypeA_Position POS3, ADD POS cannot be POS3 \n"); + + // Table 5.1.2.1-1 in Spec 38.214 + AssertFatal(startSymbol <= l0, "Wrong config, Start symbol %d cannot be later than dmrs_TypeA_Position %d \n", startSymbol, l0); + + // Section 7.4.1.1.2 in Spec 38.211 + AssertFatal(l0 == 2 || (l0 == 3 && (ld != 3 || ld != 4)), "ld 3 or 4 symbols only possible with dmrs_TypeA_Position POS2 \n"); + + } + + if (maxLength == 1) { + row = ld - 2; + l_prime = table_7_4_1_1_2_3_pdsch_dmrs_positions_l[row][column]; + l0 = 1 << l0; } else { - if (pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA && - pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->present == NR_SetupRelease_DMRS_DownlinkConfig_PR_setup) { - // Relative to start of slot - NR_DMRS_DownlinkConfig_t *dmrs_config = (NR_DMRS_DownlinkConfig_t *)pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup; - AssertFatal(ld>1 && ld < 15,"Illegal l_d %d\n",ld); - int pos2=0; - if (dmrs_config->maxLength == NULL) { - // this is Table 7.4.1.1.2-3: PDSCH DM-RS positions l for single-symbol DM-RS - if (dmrs_config->dmrs_AdditionalPosition == NULL) pos2=1; - else if (dmrs_config->dmrs_AdditionalPosition && *dmrs_config->dmrs_AdditionalPosition == NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0 ) - return(1<dmrs_AdditionalPosition && *dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1) - return(1<dmrs_AdditionalPosition && *dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1) - return(1<dmrs_AdditionalPosition && *dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos3) - return(1<dmrs_AdditionalPosition && *dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1) - return(1<dmrs_AdditionalPosition && *dmrs_config->dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos3) - return(1<3,"Illegal l_d %d for len2 DMRS\n",ld); - if (ld < 10) return(1<dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition!=NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1) return(1<dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0) return(1<dmrs_AdditionalPosition==NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos1) return(1<dmrs_DownlinkForPDSCH_MappingTypeB && - pdsch_Config->dmrs_DownlinkForPDSCH_MappingTypeA->present == NR_SetupRelease_DMRS_DownlinkConfig_PR_setup) { - // Relative to start of PDSCH resource - AssertFatal(1==0,"TypeB DMRS not supported yet\n"); - } + row = (ld < 4) ? 0 : (ld - 3); + l_prime = table_7_4_1_1_2_4_pdsch_dmrs_positions_l[row][column]; + l0 = 1<=0,"ERROR in configuration.Check Time Domain allocation of this Grant. l_prime < 1. row:%d, column:%d\n", row, column); + + l_prime = (mappingtype_fromDCI == typeA) ? (l_prime | l0) : (l_prime << startSymbol); + LOG_D(MAC, " PDSCH DMRS MASK in HEX:%x\n", l_prime); + + return l_prime; } uint8_t get_pusch_mcs_table(long *mcs_Table, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h index b83dd70260..1585c99193 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h @@ -47,7 +47,7 @@ uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw); -int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol); +int16_t fill_dmrs_mask(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol,int mappingtype_fromDCI); int is_nr_DL_slot(NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,slot_t slotP); @@ -57,8 +57,8 @@ uint16_t nr_dci_size(const NR_BWP_UplinkCommon_t *initialULBWP, const NR_CellGroupConfig_t *cg, dci_pdu_rel15_t *dci_pdu, nr_dci_format_t format, - nr_rnti_type_t rnti_type, - uint16_t N_RB, + nr_rnti_type_t rnti_type, + uint16_t N_RB, int bwp_id); void find_aggregation_candidates(uint8_t *aggregation_level, @@ -121,7 +121,7 @@ uint16_t get_NCS(uint8_t index, uint16_t format, uint8_t restricted_set_config); int get_num_dmrs(uint16_t dmrs_mask ); uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position); -int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength); +int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength, uint8_t start_symbolt, uint8_t dmrs_typeA_position); uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint8_t mcs_table); uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB); @@ -164,7 +164,7 @@ bool set_ul_ptrs_values(NR_PTRS_UplinkConfig_t *ul_ptrs_config, uint8_t *reOffset, uint8_t *maxNumPorts, uint8_t *ulPower, uint8_t NrOfSymbols); -uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol); +uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols,int startSymbol,int mappingtype); /* \brief Set the transform precoding according to 6.1.3 of 3GPP TS 38.214 version 16.3.0 Release 16 @param *pusch_config, pointer to pusch config @@ -180,4 +180,9 @@ uint8_t get_transformPrecoding(const NR_BWP_UplinkCommon_t *initialUplinkBWP, int rnti_type, uint8_t configuredGrant); +void nr_mac_gNB_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) ; #endif diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 93bde4a443..a2befdbe1a 100755 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -329,12 +329,12 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, for (i=0; i<5; i++) { if (i==scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing) { - cfg->carrier_config.dl_grid_size[i] = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; - cfg->carrier_config.dl_k0[i] = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier; + cfg->carrier_config.dl_grid_size[i] = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; + cfg->carrier_config.dl_k0[i] = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->offsetToCarrier; } else { - cfg->carrier_config.dl_grid_size[i] = 0; - cfg->carrier_config.dl_k0[i] = 0; + cfg->carrier_config.dl_grid_size[i] = 0; + cfg->carrier_config.dl_k0[i] = 0; } } @@ -365,10 +365,10 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, } uint32_t band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; - frequency_range_t frequency_range = band<100?FR1:FR2; + mac->frequency_range = band<100?FR1:FR2; lte_frame_type_t frame_type = get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing); - + // cell config cfg->cell_config.phy_cell_id = *scc->physCellId; @@ -470,13 +470,14 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, for (i=0; iprach_config.num_prach_fd_occasions; i++) { cfg->prach_config.num_prach_fd_occasions_list[i].num_prach_fd_occasions = i; if (cfg->prach_config.prach_sequence_length) - cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139; + cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l139; else - cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l839; + cfg->prach_config.num_prach_fd_occasions_list[i].prach_root_sequence_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.choice.l839; cfg->prach_config.num_prach_fd_occasions_list[i].k1 = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.msg1_FrequencyStart; cfg->prach_config.num_prach_fd_occasions_list[i].prach_zero_corr_conf = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.zeroCorrelationZoneConfig; - cfg->prach_config.num_prach_fd_occasions_list[i].num_root_sequences = compute_nr_root_seq(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup, nb_preambles, frame_type,frequency_range); + cfg->prach_config.num_prach_fd_occasions_list[i].num_root_sequences = compute_nr_root_seq(scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup, + nb_preambles, frame_type,mac->frequency_range); //cfg->prach_config.num_prach_fd_occasions_list[i].num_unused_root_sequences = ??? } @@ -649,7 +650,7 @@ int nr_rrc_mac_config_req_ue( mac->common_configuration_complete = 1; } if(scell_group_config != NULL ){ - mac->cg = cell_group_config; + mac->cg = scell_group_config; mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex; config_control_ue(mac); if (scell_group_config->spCellConfig->reconfigurationWithSync) { @@ -657,7 +658,7 @@ int nr_rrc_mac_config_req_ue( ra->rach_ConfigDedicated = scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; } mac->scc = scell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; - mac->physCellId = *mac->scc->physCellId; + mac->physCellId = *mac->scc->physCellId; config_common_ue(mac,module_id,cc_idP); mac->crnti = scell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); @@ -666,12 +667,26 @@ int nr_rrc_mac_config_req_ue( // Setup the SSB to Rach Occasions mapping according to the config build_ssb_to_ro_map(mac); } - else if (cell_group_config != NULL ){ + else if (cell_group_config != NULL){ LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); mac->cg = cell_group_config; mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0; - // config_control_ue(mac); - // config_common_ue(mac,module_id,cc_idP); + if(get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra==1) { + config_control_ue(mac); + if (cell_group_config->spCellConfig->reconfigurationWithSync) { + if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) { + ra->rach_ConfigDedicated = cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink; + } + mac->scc = cell_group_config->spCellConfig->reconfigurationWithSync->spCellConfigCommon; + config_common_ue(mac,module_id,cc_idP); + mac->crnti = cell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity; + LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti); + } + + // Setup the SSB to Rach Occasions mapping according to the config + build_ssb_to_ro_map(mac); + } + /* if(mac_cell_group_configP != NULL){ if(mac_cell_group_configP->drx_Config != NULL ){ diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 9bfd3bbc22..9f25281e8a 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -391,6 +391,8 @@ typedef struct { uint16_t nr_band; uint8_t ssb_subcarrier_offset; + dci_pdu_rel15_t def_dci_pdu_rel15[8]; + } NR_UE_MAC_INST_t; typedef enum seach_space_mask_e { diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 0e0bc66cce..b2607e5382 100755 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -169,6 +169,10 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, unsigned short post_padding, uint16_t buflen); +void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15); + +void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id); + void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot); uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index eecdbadc85..91579d750f 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -53,17 +53,26 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(sizeof(NR_UE_MAC_INST_t),NB_NR_UE_MAC_INST); for (int j=0;jscell_group_config) { - nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,rrc_inst->scell_group_config); - - // if (IS_SOFTMODEM_NOS1){ - //if (1) { - // AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); - // nr_pdcp_layer_init(); - //nr_DRB_preconfiguration(nr_ue_mac_inst->crnti); - //} + if (rrc_inst && (rrc_inst->scell_group_config || rrc_inst->cell_group_config)) { + + if(rrc_inst->scell_group_config) { + nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,rrc_inst->scell_group_config); + //if (IS_SOFTMODEM_NOS1){ + // AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); + // nr_pdcp_layer_init(); + // nr_DRB_preconfiguration(nr_ue_mac_inst->crnti); + //} + } else if (rrc_inst->cell_group_config) { + nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,rrc_inst->cell_group_config,NULL); + AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); + if (IS_SOFTMODEM_NOS1){ + pdcp_layer_init(); + nr_DRB_preconfiguration(nr_ue_mac_inst->crnti); + } + } // Allocate memory for ul_config_request in the mac instance. This is now a pointer and will // point to a list of structures (one for each UL slot) to store PUSCH scheduling parameters @@ -75,12 +84,14 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) { LOG_D(MAC, "Initializing ul_config_request. num_slots_ul = %d\n", num_slots_ul); nr_ue_mac_inst->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t)); } - } - else { + + } else { LOG_I(MAC,"Running without CellGroupConfig\n"); nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,NULL); - AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); - } + if(get_softmodem_params()->sa == 1) { + AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); + } + } return (nr_ue_mac_inst); } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 9c52942763..314951a63b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -48,6 +48,8 @@ #include "NR_MAC_COMMON/nr_mac.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" +#include + void nr_get_RA_window(NR_UE_MAC_INST_t *mac); // Random Access procedure initialization as per 5.1.1 and initialization of variables specific @@ -532,7 +534,6 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, else setup = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; AssertFatal(&setup->rach_ConfigGeneric != NULL, "In %s: FATAL! rach_ConfigGeneric is NULL...\n", __FUNCTION__); NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; - //NR_FrequencyInfoDL_t *frequencyInfoDL = scc->downlinkConfigCommon->frequencyInfoDL; NR_RACH_ConfigDedicated_t *rach_ConfigDedicated = ra->rach_ConfigDedicated; uint8_t sdu_lcids[NB_RB_MAX] = {0}; @@ -542,16 +543,15 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, // Delay init RA procedure to allow the convergence of the IIR filter on PRACH noise measurements at gNB side if (!prach_resources->init_msg1) { - if (/*(((MAX_FRAME_NUMBER + frame - prach_resources->sync_frame) % MAX_FRAME_NUMBER) > 150) &&*/ - mac->common_configuration_complete > 0){ + if ( (mac->common_configuration_complete>0 || get_softmodem_params()->do_ra==1) && ((MAX_FRAME_NUMBER+frame-prach_resources->sync_frame)%MAX_FRAME_NUMBER)>150 ){ prach_resources->init_msg1 = 1; } else { - LOG_I(PHY,"PRACH Condition not met: frame %d, prach_resources->sync_frame %d\n",frame,prach_resources->sync_frame); + LOG_D(NR_MAC,"PRACH Condition not met: frame %d, prach_resources->sync_frame %d\n",frame,prach_resources->sync_frame); return 0; } } - LOG_I(PHY,"frame %d prach_resources->init_msg1 %d, ra->ra_state %d, ra->RA_active %d\n", + LOG_D(NR_MAC,"frame %d prach_resources->init_msg1 %d, ra->ra_state %d, ra->RA_active %d\n", frame,prach_resources->init_msg1,ra->ra_state,ra->RA_active); if (prach_resources->init_msg1 && ra->ra_state != RA_SUCCEEDED) { @@ -559,7 +559,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, if (ra->RA_active == 0) { /* RA not active - checking if RRC is ready to initiate the RA procedure */ - LOG_I(MAC, "RA not active. Checking for data to transmit from upper layers...\n"); + LOG_D(NR_MAC, "RA not active. Checking for data to transmit from upper layers...\n"); uint8_t TBS_max = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); payload = (uint8_t*) mac->CCCH_pdu.payload; @@ -580,7 +580,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, sdu_lengths[0] = size_sdu; - LOG_I(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", mod_id, frame, size_sdu); + LOG_D(NR_MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n", mod_id, frame, size_sdu); if (size_sdu > 0) { @@ -589,7 +589,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, // Random Access Procedure has been successful after reception of Msg4 memcpy(ra->cont_res_id, mac_sdus, sizeof(uint8_t) * 6); - LOG_I(MAC, "[UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", mod_id, frame, nr_slot_tx); + LOG_D(NR_MAC, "[UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", mod_id, frame, nr_slot_tx); ra->Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); @@ -653,6 +653,7 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, } else { ra->generate_nr_prach = GENERATE_IDLE; } + } else if (ra->RA_window_cnt == 0 && !ra->RA_RAPID_found) { LOG_I(MAC, "[UE %d][%d:%d] RAR reception failed \n", mod_id, frame, nr_slot_tx); @@ -665,9 +666,9 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, // Fill in preamble and PRACH resources ra->RA_window_cnt--; - if (ra->generate_nr_prach == GENERATE_PREAMBLE) { + if (ra->generate_nr_prach == GENERATE_PREAMBLE) { nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated); - } + } } else if (ra->RA_backoff_cnt > 0) { LOG_D(MAC, "[UE %d][%d.%d]: RAR not received yet (RA backoff count %d) \n", mod_id, frame, nr_slot_tx, ra->RA_backoff_cnt); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c index 215b19d727..f1431dcbd9 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_dci_configuration.c @@ -49,8 +49,6 @@ //#define DEBUG_DCI -dci_pdu_rel15_t *def_dci_pdu_rel15; - void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) { LOG_D(MAC,"Filling search candidates for DCI\n"); @@ -71,10 +69,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t uint16_t monitoringSymbolsWithinSlot = 0; uint8_t coreset_id = 1; int sps = 0; - def_dci_pdu_rel15 = calloc(1,2*sizeof(dci_pdu_rel15_t)); AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n"); - + NR_BWP_Id_t bwp_id = mac->DL_BWP_Id; NR_ServingCellConfigCommon_t *scc = mac->scc; NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB; @@ -140,9 +137,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t switch(rnti_type) { case NR_RNTI_C: // we use DL BWP dedicated - sps = bwp_Common ? - (bwp_Common->genericParameters.cyclicPrefix ? 12 : 14) : - initialDownlinkBWP->genericParameters.cyclicPrefix ? 12 : 14; + sps = bwp_Common ? + (bwp_Common->genericParameters.cyclicPrefix ? 12 : 14) : + initialDownlinkBWP->genericParameters.cyclicPrefix ? 12 : 14; // for SPS=14 8 MSBs in positions 13 down to 6 monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps)); rel15->rnti = mac->crnti; @@ -156,7 +153,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing; } for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(initialUplinkBWP, mac->cg, def_dci_pdu_rel15+i, rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id); + rel15->dci_length_options[i] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id); } break; case NR_RNTI_RA: @@ -171,7 +168,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; - rel15->dci_length_options[0] = nr_dci_size(initialUplinkBWP, mac->cg, def_dci_pdu_rel15, rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id); + rel15->dci_length_options[0] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id); break; case NR_RNTI_P: break; @@ -185,7 +182,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); rel15->BWPStart = NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing; - rel15->dci_length_options[0] = nr_dci_size(initialUplinkBWP, mac->cg, def_dci_pdu_rel15, rel15->dci_format_options[0], NR_RNTI_TC, rel15->BWPSize, bwp_id); + rel15->dci_length_options[0] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_TC, rel15->BWPSize, bwp_id); break; case NR_RNTI_SP_CSI: break; @@ -207,7 +204,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2; for (int i = 0; i < rel15->num_dci_options; i++) { - rel15->dci_length_options[i] = nr_dci_size(NULL, NULL, def_dci_pdu_rel15, rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0); + rel15->dci_length_options[i] = nr_dci_size(initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0); } break; case NR_RNTI_SFI: @@ -269,7 +266,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl switch (ss->searchSpaceType->present){ case NR_SearchSpace__searchSpaceType_PR_common: // this is for CSSs, we use BWP common and pdcch_ConfigCommon - + // Fetch configuration for searchSpaceZero // note: The search space with the SearchSpaceId = 0 identifies the search space configured via PBCH (MIB) and in ServingCellConfigCommon (searchSpaceZero). if (pdcch_ConfigCommon->choice.setup->searchSpaceZero){ @@ -358,7 +355,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_3 with CRC scrambled by TPC-SRS-RNTI \n"); LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet..."); } - + break; case NR_SearchSpace__searchSpaceType_PR_ue_Specific: // this is an USS @@ -366,13 +363,13 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl if(ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1){ // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI if ((ra->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) && mac->crnti > 0) { - LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); - rel15->num_dci_options = 2; - rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; - rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; - config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); - fill_dci_search_candidates(ss, rel15); - + LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n"); + rel15->num_dci_options = 2; + rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1; + rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1; + config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id); + fill_dci_search_candidates(ss, rel15); + #ifdef DEBUG_DCI LOG_D(MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n", ss_id, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index c292f97746..d38645ab22 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -62,8 +62,9 @@ #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" +//#define DEBUG_MIB //#define ENABLE_MAC_PAYLOAD_DEBUG 1 -#define DEBUG_EXTRACT_DCI +//#define DEBUG_EXTRACT_DCI //#define DEBUG_RAR extern uint32_t N_RB_DL; @@ -115,9 +116,10 @@ int8_t nr_ue_decode_mib(module_id_t module_id, //if(mac->mib != NULL){ uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused); uint16_t frame_number_4lsb = 0; + for (int i=0; i<4; i++) frame_number_4lsb |= ((extra_bits>>i)&1)<<(3-i); - uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1; // extra bits[4] + uint8_t ssb_subcarrier_offset_msb = ( extra_bits >> 5 ) & 0x1; // extra bits[5] uint8_t ssb_subcarrier_offset = (uint8_t)mac->mib->ssb_SubcarrierOffset; @@ -134,15 +136,20 @@ int8_t nr_ue_decode_mib(module_id_t module_id, } } - LOG_D(MAC,"system frame number(6 MSB bits): %d\n", mac->mib->systemFrameNumber.buf[0]); - LOG_D(MAC,"system frame number(with LSB): %d\n", (int)frame); - LOG_D(MAC,"subcarrier spacing (0=15or60, 1=30or120): %d\n", (int)mac->mib->subCarrierSpacingCommon); - LOG_D(MAC,"ssb carrier offset(with MSB): %d\n", (int)ssb_subcarrier_offset); - LOG_D(MAC,"dmrs type A position (0=pos2,1=pos3): %d\n", (int)mac->mib->dmrs_TypeA_Position); - LOG_D(MAC,"cell barred (0=barred,1=notBarred): %d\n", (int)mac->mib->cellBarred); - LOG_D(MAC,"intra frequency reselection (0=allowed,1=notAllowed): %d\n", (int)mac->mib->intraFreqReselection); - LOG_D(MAC,"half frame bit(extra bits): %d\n", (int)half_frame_bit); - LOG_D(MAC,"ssb index(extra bits): %d\n", (int)ssb_index); +#ifdef DEBUG_MIB + uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1; // extra bits[4] + LOG_I(MAC,"system frame number(6 MSB bits): %d\n", mac->mib->systemFrameNumber.buf[0]); + LOG_I(MAC,"system frame number(with LSB): %d\n", (int)frame); + LOG_I(MAC,"subcarrier spacing (0=15or60, 1=30or120): %d\n", (int)mac->mib->subCarrierSpacingCommon); + LOG_I(MAC,"ssb carrier offset(with MSB): %d\n", (int)ssb_subcarrier_offset); + LOG_I(MAC,"dmrs type A position (0=pos2,1=pos3): %d\n", (int)mac->mib->dmrs_TypeA_Position); + LOG_I(MAC,"controlResourceSetZero: %d\n", (int)mac->mib->pdcch_ConfigSIB1.controlResourceSetZero); + LOG_I(MAC,"searchSpaceZero: %d\n", (int)mac->mib->pdcch_ConfigSIB1.searchSpaceZero); + LOG_I(MAC,"cell barred (0=barred,1=notBarred): %d\n", (int)mac->mib->cellBarred); + LOG_I(MAC,"intra frequency reselection (0=allowed,1=notAllowed): %d\n", (int)mac->mib->intraFreqReselection); + LOG_I(MAC,"half frame bit(extra bits): %d\n", (int)half_frame_bit); + LOG_I(MAC,"ssb index(extra bits): %d\n", (int)ssb_index); +#endif //storing ssb index in the mac structure mac->mib_ssb = ssb_index; @@ -322,12 +329,16 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, */ if(dlsch_config_pdu != NULL){ NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; - if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) + if (mac->DLbwp[0] && + mac->DLbwp[0]->bwp_Dedicated && + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; else if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + if (pdsch_TimeDomainAllocationList && use_default==false) { if (time_domain_ind >= pdsch_TimeDomainAllocationList->list.count) { @@ -367,21 +378,21 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, if(pusch_config_pdu != NULL){ NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Dedicated && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { + mac->ULbwp[0]->bwp_Dedicated && + mac->ULbwp[0]->bwp_Dedicated->pusch_Config && + mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup && + mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList) { pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->pusch_TimeDomainAllocationList->choice.setup; } else if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Common && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup && - mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + mac->ULbwp[0]->bwp_Common && + mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon && + mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup && + mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; } else pusch_TimeDomainAllocationList = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - + if (pusch_TimeDomainAllocationList && use_default==false) { if (time_domain_ind >= pusch_TimeDomainAllocationList->list.count) { LOG_E(MAC, "time_domain_ind %d >= pusch->TimeDomainAllocationList->list.count %d\n", @@ -411,7 +422,6 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, } LOG_D(NR_MAC,"start_symbol = %i\n", pusch_config_pdu->start_symbol_index); LOG_D(NR_MAC,"number_symbols = %i\n", pusch_config_pdu->nr_of_symbols); - } return 0; } @@ -419,10 +429,11 @@ int8_t nr_ue_process_dci_time_dom_resource_assignment(NR_UE_MAC_INST_t *mac, int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_index, frame_t frame, int slot, fapi_nr_dci_indication_pdu_t *dci) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); + dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci->dci_format]; LOG_D(MAC,"Received dci indication (rnti %x,dci format %d,n_CCE %d,payloadSize %d,payload %llx)\n", dci->rnti,dci->dci_format,dci->n_CCE,dci->payloadSize,*(unsigned long long*)dci->payloadBits); - int8_t ret = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15); + int8_t ret = nr_extract_dci_info(mac, dci->dci_format, dci->payloadSize, dci->rnti, (uint64_t *)dci->payloadBits, def_dci_pdu_rel15); if ((ret&1) == 1) return -1; else if (ret == 2) dci->dci_format = NR_UL_DCI_FORMAT_0_0; return (nr_ue_process_dci(module_id, cc_id, gNB_index, frame, slot, def_dci_pdu_rel15, dci->rnti, dci->dci_format)); @@ -471,7 +482,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // - SUL_IND_0_0 // Schedule PUSCH - ret = nr_ue_pusch_scheduler(mac, is_Msg3, frame, slot, &frame_tx, &slot_tx, dci->time_domain_assignment.val); if (ret != -1){ @@ -611,8 +621,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_0 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; NR_PDSCH_Config_t *pdsch_config= (mac->DLbwp[0]) ? mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup : NULL; - - uint16_t BWPSize = 0; + uint16_t BWPSize = n_RB_DLBWP; if(rnti == SI_RNTI) { NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config = mac->type0_PDCCH_CSS_config; @@ -630,19 +639,18 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; } if( (ra->RA_window_cnt >= 0 && rnti == ra->ra_rnti) || (rnti == ra->t_crnti) ) { - if (mac->scc == NULL) { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + if (mac->scc == NULL) { + dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } - else { - dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } + else { + dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - } - if (get_softmodem_params()->sa) { - - } else { // NSA mode is not using the Initial BWP + } + if (!get_softmodem_params()->sa) { // NSA mode is not using the Initial BWP dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); pdsch_config = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup; + BWPSize = dlsch_config_pdu_1_0->BWPSize; } } else if (mac->DLbwp[0]) { dlsch_config_pdu_1_0->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -654,9 +662,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dlsch_config_pdu_1_0->BWPStart = NRRIV2PRBOFFSET(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); dlsch_config_pdu_1_0->SubcarrierSpacing = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.subcarrierSpacing; pdsch_config = NULL; - } - BWPSize = n_RB_DLBWP; } /* IDENTIFIER_DCI_FORMATS */ @@ -670,14 +676,28 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } + + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; + if (mac->DLbwp[0] && + mac->DLbwp[0]->bwp_Dedicated && + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; + else if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) + pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + + int mappingtype = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType : ((dlsch_config_pdu_1_0->start_symbol <= 3)? typeA: typeB); + /* dmrs symbol positions*/ dlsch_config_pdu_1_0->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, mac->mib->dmrs_TypeA_Position, dlsch_config_pdu_1_0->number_symbols, - dlsch_config_pdu_1_0->start_symbol); + dlsch_config_pdu_1_0->start_symbol, + mappingtype); dlsch_config_pdu_1_0->dmrsConfigType = (mac->DLbwp[0] != NULL) ? (mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; - /* number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214 version 15.9.0 Release 15 */ if (dlsch_config_pdu_1_0->number_symbols == 2) dlsch_config_pdu_1_0->n_dmrs_cdm_groups = 1; @@ -727,10 +747,10 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr // Sanity check for pucch_resource_indicator value received to check for false DCI. valid = 0; if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Dedicated && - mac->ULbwp[0]->bwp_Dedicated->pucch_Config && - mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup&& - mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList) { + mac->ULbwp[0]->bwp_Dedicated && + mac->ULbwp[0]->bwp_Dedicated->pucch_Config && + mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup&& + mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList) { pucch_res_set_cnt = mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.count; for (int id = 0; id < pucch_res_set_cnt; id++) { if (dlsch_config_pdu_1_0->pucch_resource_id < mac->ULbwp[0]->bwp_Dedicated->pucch_Config->choice.setup->resourceSetToAddModList->list.array[id]->resourceList.list.count) { @@ -762,7 +782,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr /* PDSCH_TO_HARQ_FEEDBACK_TIME_IND (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI)*/ dlsch_config_pdu_1_0->pdsch_to_harq_feedback_time_ind = 1+dci->pdsch_to_harq_feedback_timing_indicator.val; - + LOG_D(MAC,"(nr_ue_procedures.c) rnti = %x dl_config->number_pdus = %d\n", dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti, dl_config->number_pdus); @@ -837,10 +857,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DLSCH; dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.rnti = rnti; - // FIXME: fix number of additional dmrs - if(pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition == NULL) - pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition=calloc(1,sizeof(*pdsch_config->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition)); - fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15; dlsch_config_pdu_1_1->BWPSize = NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -861,11 +877,26 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr LOG_W(MAC, "[%d.%d] Invalid time_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot); return -1; } + + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList = NULL; + if (mac->DLbwp[0] && + mac->DLbwp[0]->bwp_Dedicated && + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config && + mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList->choice.setup; + else if (mac->DLbwp[0] && mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) + pdsch_TimeDomainAllocationList = mac->DLbwp[0]->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + else if (mac->scc_SIB && mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup) + pdsch_TimeDomainAllocationList = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + + int mappingtype = pdsch_TimeDomainAllocationList ? pdsch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType : ((dlsch_config_pdu_1_1->start_symbol <= 3)? typeA: typeB); + /* dmrs symbol positions*/ dlsch_config_pdu_1_1->dlDmrsSymbPos = fill_dmrs_mask(pdsch_config, - mac->scc->dmrs_TypeA_Position, - dlsch_config_pdu_1_1->number_symbols, - dlsch_config_pdu_1_1->start_symbol); + mac->scc->dmrs_TypeA_Position, + dlsch_config_pdu_1_1->number_symbols, + dlsch_config_pdu_1_1->start_symbol, + mappingtype); dlsch_config_pdu_1_1->dmrsConfigType = mac->DLbwp[dl_bwp_id-1]->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; /* TODO: fix number of DM-RS CDM groups without data according to subclause 5.1.6.2 of 3GPP TS 38.214, using tables 7.3.1.2.2-1, 7.3.1.2.2-2, 7.3.1.2.2-3, 7.3.1.2.2-4 of 3GPP TS 38.212 */ @@ -1167,21 +1198,32 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, uint64_t *dci_pdu, dci_pdu_rel15_t *dci_pdu_rel15) { + int N_RB = 0; + int pos = 0; + int fsize = 0; + int rnti_type = get_rnti_type(mac, rnti); - int N_RB=0,N_RB_UL=0; + + int N_RB_UL = 0; + if(mac->scc_SIB) { + N_RB_UL = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } else if(mac->ULbwp[0]) { + N_RB_UL = NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } else if(mac->scc) { + N_RB_UL = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } - int pos=0; - int fsize=0; LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d\n",*dci_pdu,dci_size); switch(dci_format) { case NR_DL_DCI_FORMAT_1_0: switch(rnti_type) { case NR_RNTI_RA: - // check BWP id - if (mac->DLbwp[0]) N_RB=NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - else N_RB=NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); - + if(mac->scc_SIB) { + N_RB = NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); + } else { + N_RB = get_n_rb(mac, rnti_type); + } // Freq domain assignment fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) ); pos=fsize; @@ -1221,14 +1263,16 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, //Identifier for DCI formats pos++; dci_pdu_rel15->format_indicator = (*dci_pdu>>(dci_size-pos))&1; + + //switch to DCI_0_0 if (dci_pdu_rel15->format_indicator == 0) - //switch to DCI_0_0 - return 2+nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, dci_pdu, dci_pdu_rel15); + return 2+nr_extract_dci_info(mac, NR_UL_DCI_FORMAT_0_0, dci_size, rnti, dci_pdu, dci_pdu_rel15); + #ifdef DEBUG_EXTRACT_DCI LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu); #endif - // check BWP id + // check BWP id if (mac->DLbwp[0]) N_RB=NRRIV2BW(mac->DLbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); else N_RB=NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -1530,7 +1574,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, dci_pdu_rel15->ndi= (*dci_pdu>>(dci_size-pos))&1; #ifdef DEBUG_EXTRACT_DCI LOG_D(MAC,"NDI %d (%d bits)=> %d (0x%lx)\n",dci_pdu_rel15->ndi,1,dci_size-pos,*dci_pdu); -#endif +#endif // Redundancy version 2bit pos+=2; dci_pdu_rel15->rv= (*dci_pdu>>(dci_size-pos))&3; @@ -1709,10 +1753,7 @@ uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac, // Freq domain assignment max 16 bit fsize = (int)ceil( log2( (N_RB_UL*(N_RB_UL+1))>>1 ) ); - //pos+=dci_pdu_rel15->frequency_domain_assignment.nbits; pos+=fsize; - - //pos+=dci_pdu_rel15->frequency_domain_assignment.nbits; dci_pdu_rel15->frequency_domain_assignment.val = (*dci_pdu>>(dci_size-pos))&((1<F = 0; ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->LCID = sdu_lcids[i]; ((NR_MAC_SUBHEADER_SHORT *) mac_pdu_ptr)->L = (unsigned char) sdu_lengths[i]; - last_size = 2; + mac_pdu_ptr += sizeof(NR_MAC_SUBHEADER_SHORT); } else { ((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->R = 0; ((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->F = 1; ((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->LCID = sdu_lcids[i]; ((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->L1 = ((unsigned short) sdu_lengths[i] >> 8) & 0x7f; ((NR_MAC_SUBHEADER_LONG *) mac_pdu_ptr)->L2 = (unsigned short) sdu_lengths[i] & 0xff; - last_size = 3; + mac_pdu_ptr += sizeof(NR_MAC_SUBHEADER_LONG); } } else { // UL CCCH SDU - ((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->R = 0; - ((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->LCID = sdu_lcids[i]; - last_size = 1; + mac_pdu_ptr->R = 0; + mac_pdu_ptr->LCID = sdu_lcids[i]; + mac_pdu_ptr ++; } - mac_pdu_ptr += last_size; - // cycle through SDUs, compute each relevant and place ulsch_buffer in memcpy((void *) mac_pdu_ptr, (void *) sdus_payload, sdu_lengths[i]); sdus_payload += sdu_lengths[i]; @@ -2173,8 +2209,6 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, // Generating UL MAC subPDUs including MAC CEs (MAC CE and subheader) - ce_ptr = &mac_header_control_elements[0]; - if (power_headroom) { // MAC CE fixed subheader mac_pdu_ptr->R = 0; @@ -2182,17 +2216,11 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, mac_pdu_ptr++; // PHR MAC CE (1 octet) - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->PH = power_headroom; - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->R1 = 0; - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->PCMAX = 0; // todo - ((NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr)->R2 = 0; - - mac_ce_size = sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE); - - // Copying bytes for PHR MAC CEs to the mac pdu pointer - memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size); - ce_ptr += mac_ce_size; - mac_pdu_ptr += (unsigned char) mac_ce_size; + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->PH = power_headroom; + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->R1 = 0; + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->PCMAX = 0; // todo + ((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_pdu_ptr)->R2 = 0; + mac_pdu_ptr += sizeof(NR_SINGLE_ENTRY_PHR_MAC_CE); } if (crnti) { @@ -2202,13 +2230,8 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, mac_pdu_ptr++; // C-RNTI MAC CE (2 octets) - * (uint16_t *) ce_ptr = crnti; - mac_ce_size = sizeof(uint16_t); - - // Copying bytes for CRNTI MAC CE to the mac pdu pointer - memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size); - ce_ptr += mac_ce_size; - mac_pdu_ptr += (unsigned char) mac_ce_size; + * (uint16_t *) mac_pdu_ptr = crnti; + mac_pdu_ptr += sizeof(uint16_t); } if (truncated_bsr) { @@ -2218,11 +2241,9 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, mac_pdu_ptr++; // Short truncated BSR MAC CE (1 octet) - ((NR_BSR_SHORT_TRUNCATED *) ce_ptr)-> Buffer_size = truncated_bsr; - ((NR_BSR_SHORT_TRUNCATED *) ce_ptr)-> LcgID = 0; // todo - mac_ce_size = sizeof(NR_BSR_SHORT_TRUNCATED); - - bsr = 1 ; + ((NR_BSR_SHORT_TRUNCATED *) mac_pdu_ptr)-> Buffer_size = truncated_bsr; + ((NR_BSR_SHORT_TRUNCATED *) mac_pdu_ptr)-> LcgID = 0; // todo + mac_pdu_ptr+= sizeof(NR_BSR_SHORT_TRUNCATED); } else if (short_bsr) { // MAC CE fixed subheader mac_pdu_ptr->R = 0; @@ -2230,11 +2251,9 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, mac_pdu_ptr++; // Short truncated BSR MAC CE (1 octet) - ((NR_BSR_SHORT *) ce_ptr)->Buffer_size = short_bsr; - ((NR_BSR_SHORT *) ce_ptr)->LcgID = 0; // todo - mac_ce_size = sizeof(NR_BSR_SHORT); - - bsr = 1 ; + ((NR_BSR_SHORT *) mac_pdu_ptr)->Buffer_size = short_bsr; + ((NR_BSR_SHORT *) mac_pdu_ptr)->LcgID = 0; // todo + mac_pdu_ptr+= sizeof(NR_BSR_SHORT); } else if (long_bsr) { // MAC CE variable subheader // todo ch 6.1.3.1. TS 38.321 @@ -2250,36 +2269,19 @@ uint16_t nr_generate_ulsch_pdu(uint8_t *sdus_payload, // ((NR_BSR_LONG *) ce_ptr)->LCGID0 = 0; // mac_ce_size = sizeof(NR_BSR_LONG); // size is variable } - - if (bsr){ - // Copying bytes for BSR MAC CE to the mac pdu pointer - memcpy((void *) mac_pdu_ptr, (void *) ce_ptr, mac_ce_size); - ce_ptr += mac_ce_size; - mac_pdu_ptr += (unsigned char) mac_ce_size; - } - - // compute offset before adding padding (if necessary) - offset = ((unsigned char *) mac_pdu_ptr - pdu); - uint16_t padding_bytes = 0; +// compute offset before adding padding (if necessary) + int padding_bytes = 0; if(buflen > 0) // If the buflen is provided - padding_bytes = buflen - offset; - + padding_bytes = buflen + pdu - (unsigned char *) mac_pdu_ptr; + AssertFatal(padding_bytes>=0,""); // Compute final offset for padding - if (post_padding > 0 || padding_bytes>0) { + if (post_padding || padding_bytes>0) { ((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->R = 0; ((NR_MAC_SUBHEADER_FIXED *) mac_pdu_ptr)->LCID = UL_SCH_LCID_PADDING; mac_pdu_ptr++; - } else { - // no MAC subPDU with padding - } - - // compute final offset - offset = ((unsigned char *) mac_pdu_ptr - pdu); - - //printf("Offset %d \n", ((unsigned char *) mac_pdu_ptr - pdu)); - - return offset; + } + return (uint8_t *)mac_pdu_ptr-pdu; } ///////////////////////////////////// diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index e5985e5192..20cafa8389 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -51,6 +51,8 @@ #include "asn1_conversions.h" #include "SIMULATION/TOOLS/sim.h" // for taus +#include + static prach_association_pattern_t prach_assoc_pattern; static ssb_list_info_t ssb_list; @@ -143,13 +145,13 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl // Calculate the index of the UL slot in mac->ul_config_request list. This is // based on the TDD pattern (slot configuration period) and number of UL+mixed // slots in the period. TS 38.213 Sec 11.1 - int mu = mac->ULbwp[0] ? - mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing : + int mu = mac->ULbwp[0] ? + mac->ULbwp[0]->bwp_Common->genericParameters.subcarrierSpacing : mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; NR_TDD_UL_DL_Pattern_t *tdd_pattern = &tdd_config->pattern1; const int num_slots_per_tdd = nr_slots_per_frame[mu] >> (7 - tdd_pattern->dl_UL_TransmissionPeriodicity); const int num_slots_ul = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); - int index = slot % num_slots_ul; + int index = slot % num_slots_ul; LOG_D(NR_MAC, "In %s slots per tdd %d, num_slots_ul %d, index %d\n", __FUNCTION__, num_slots_per_tdd, @@ -502,7 +504,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int NrOfSymbols; uint8_t nb_dmrs_re_per_rb; - uint16_t l_prime_mask = 1; + uint16_t l_prime_mask = 0; uint16_t number_dmrs_symbols = 0; int N_PRB_oh = 0; @@ -517,31 +519,36 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP; else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP; + pusch_dmrs_AdditionalPosition_t add_pos = pusch_dmrs_pos2; + pusch_maxLength_t dmrslength = pusch_len1; + if (rar_grant) { // Note: for Msg3 or MsgA PUSCH transmission the N_PRB_oh is always set to 0 NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; NR_BWP_UplinkDedicated_t *ibwp; - int scs,abwp_start,abwp_size,startSymbolAndLength; + int scs,abwp_start,abwp_size,startSymbolAndLength,mappingtype; NR_PUSCH_Config_t *pusch_Config=NULL; if (mac->cg && ubwp && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP - ) { + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) { + ibwp = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP; pusch_Config = ibwp->pusch_Config->choice.setup; startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->startSymbolAndLength; - + mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->mappingType; + // active BWP start abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; - } + } else { startSymbolAndLength = initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->startSymbolAndLength; - + mappingtype = initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[rar_grant->Msg3_t_alloc]->mappingType; + // active BWP start abwp_start = NRRIV2PRBOFFSET(initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); abwp_size = NRRIV2BW(initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); @@ -578,6 +585,9 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->start_symbol_index = StartSymbolIndex; pusch_config_pdu->nr_of_symbols = NrOfSymbols; + l_prime_mask = get_l_prime(NrOfSymbols, mappingtype, add_pos, dmrslength, StartSymbolIndex, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); + LOG_D(MAC, "MSG3 start_sym:%d NR Symb:%d mappingtype:%d , DMRS_MASK:%x\n", pusch_config_pdu->start_symbol_index, pusch_config_pdu->nr_of_symbols, mappingtype, l_prime_mask); + #ifdef DEBUG_MSG3 LOG_D(NR_MAC, "In %s BWP assignment (BWP (start %d, size %d) \n", __FUNCTION__, pusch_config_pdu->bwp_start, pusch_config_pdu->bwp_size); #endif @@ -606,7 +616,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->cyclic_prefix = 0; pusch_config_pdu->data_scrambling_id = mac->physCellId; pusch_config_pdu->ul_dmrs_scrambling_id = mac->physCellId; - pusch_config_pdu->subcarrier_spacing = scs; + pusch_config_pdu->subcarrier_spacing = scs; pusch_config_pdu->vrb_to_prb_mapping = 0; pusch_config_pdu->uplink_frequency_shift_7p5khz = 0; //Optional Data only included if indicated in pduBitmap @@ -620,8 +630,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, int target_ss; bool valid_ptrs_setup = 0; uint16_t n_RB_ULBWP; - if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Common) { + if (mac->ULbwp[0] && mac->ULbwp[0]->bwp_Common) { n_RB_ULBWP = NRRIV2BW(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); pusch_config_pdu->bwp_start = NRRIV2PRBOFFSET(mac->ULbwp[0]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); } @@ -669,18 +678,35 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL; + if (pusch_Config && pusch_Config->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = pusch_Config->pusch_TimeDomainAllocationList->choice.setup; + } + else if (mac->ULbwp[0] && + mac->ULbwp[0]->bwp_Common&& + mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon&& + mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup && + mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) { + pusch_TimeDomainAllocationList = mac->ULbwp[0]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + } + else if (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList) + pusch_TimeDomainAllocationList=mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + else AssertFatal(1==0,"need to fall back to default PUSCH time-domain allocations\n"); + + int mappingtype = pusch_TimeDomainAllocationList->list.array[dci->time_domain_assignment.val]->mappingType; + + NR_DMRS_UplinkConfig_t *NR_DMRS_ulconfig = NULL; + if(pusch_Config) { + NR_DMRS_ulconfig = (mappingtype == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA) + ? pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; + } + /* TRANSFORM PRECODING ------------------------------------------------------------------------------------------*/ if (pusch_config_pdu->transform_precoding == transform_precoder_enabled) { pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; - NR_DMRS_UplinkConfig_t *NR_DMRS_ulconfig = NULL; - if(pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) - NR_DMRS_ulconfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup; - else - NR_DMRS_ulconfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup; - uint32_t n_RS_Id = 0; if (NR_DMRS_ulconfig->transformPrecodingEnabled->nPUSCH_Identity != NULL) n_RS_Id = *NR_DMRS_ulconfig->transformPrecodingEnabled->nPUSCH_Identity; @@ -714,7 +740,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, } /* FREQ_HOPPING_FLAG */ - if ((pusch_Config->frequencyHopping!=NULL) && (pusch_Config->resourceAllocation != NR_PUSCH_Config__resourceAllocation_resourceAllocationType0)){ + if ((pusch_Config!=NULL) && (pusch_Config->frequencyHopping!=NULL) && (pusch_Config->resourceAllocation != NR_PUSCH_Config__resourceAllocation_resourceAllocationType0)){ pusch_config_pdu->frequency_hopping = dci->frequency_hopping_flag.val; } @@ -749,32 +775,36 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->absolute_delta_PUSCH = 4; } + if (NR_DMRS_ulconfig != NULL) { + add_pos = (NR_DMRS_ulconfig->dmrs_AdditionalPosition == NULL) ? 2 : *NR_DMRS_ulconfig->dmrs_AdditionalPosition; + dmrslength = NR_DMRS_ulconfig->maxLength == NULL ? pusch_len1 : pusch_len2; + } + /* DMRS */ - l_prime_mask = get_l_prime(pusch_config_pdu->nr_of_symbols, typeB, - (*dci_format == NR_UL_DCI_FORMAT_0_1) ? pusch_dmrs_pos0 : pusch_dmrs_pos2, pusch_len1); + l_prime_mask = get_l_prime(pusch_config_pdu->nr_of_symbols, mappingtype, add_pos, dmrslength, pusch_config_pdu->start_symbol_index, mac->scc ? mac->scc->dmrs_TypeA_Position : mac->mib->dmrs_TypeA_Position); if ((mac->ULbwp[0] && pusch_config_pdu->transform_precoding == transform_precoder_disabled)) pusch_config_pdu->num_dmrs_cdm_grps_no_data = 1; - else if ((*dci_format == NR_UL_DCI_FORMAT_0_0) || (mac->ULbwp[0] && pusch_config_pdu->transform_precoding == transform_precoder_enabled)) + else if (*dci_format == NR_UL_DCI_FORMAT_0_0 || (mac->ULbwp[0] && pusch_config_pdu->transform_precoding == transform_precoder_enabled)) pusch_config_pdu->num_dmrs_cdm_grps_no_data = 2; - + // Num PRB Overhead from PUSCH-ServingCellConfig if (mac->cg && - mac->cg->spCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig && - mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead) + mac->cg->spCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig && + mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead) N_PRB_oh = *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->xOverhead; else N_PRB_oh = 0; /* PTRS */ if (mac->ULbwp[0] && - mac->ULbwp[0]->bwp_Dedicated && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB && - mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { + mac->ULbwp[0]->bwp_Dedicated && + mac->ULbwp[0]->bwp_Dedicated->pusch_Config && + mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup && + mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB && + mac->ULbwp[0]->bwp_Dedicated->pusch_Config->choice.setup->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->phaseTrackingRS) { if (pusch_config_pdu->transform_precoding == transform_precoder_disabled) { nfapi_nr_ue_ptrs_ports_t ptrs_ports_list; pusch_config_pdu->pusch_ptrs.ptrs_ports_list = &ptrs_ports_list; @@ -800,7 +830,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, pusch_config_pdu->nr_of_symbols, rnti_types[rnti_type]); - pusch_config_pdu->ul_dmrs_symb_pos = l_prime_mask << pusch_config_pdu->start_symbol_index;; + pusch_config_pdu->ul_dmrs_symb_pos = l_prime_mask; pusch_config_pdu->target_code_rate = nr_get_code_rate_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); pusch_config_pdu->qam_mod_order = nr_get_Qm_ul(pusch_config_pdu->mcs_index, pusch_config_pdu->mcs_table); @@ -920,10 +950,12 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in } LOG_D(NR_MAC,"Flipping NDI for harq_id %d (Msg3)\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator); mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator; - mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0; + mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0; } else { - if (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator|| - mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id]==1){ + + if ( (mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator || + mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id]==1)){ + // Getting IP traffic to be transmitted data_existing = nr_ue_get_sdu(mod_id, cc_id, @@ -948,7 +980,7 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2) //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should //have a valid LCID (nr_process_mac_pdu function) - ulsch_input_buffer[0] = 0x31; + ulsch_input_buffer[0] = UL_SCH_LCID_PADDING; for (int i = 1; i < TBS_bytes; i++) { ulsch_input_buffer[i] = (unsigned char) rand(); @@ -973,8 +1005,8 @@ NR_UE_L2_STATE_t nr_ue_scheduler(nr_downlink_indication_t *dl_info, nr_uplink_in tx_req.tx_request_body[0].pdu_index = j; tx_req.tx_request_body[0].pdu = ulsch_input_buffer; - if (ra->ra_state != RA_SUCCEEDED && !ra->cfra){ - LOG_D(NR_MAC,"[RAPROC] RA-Msg3 transmitted\n"); + if (ra->ra_state == WAIT_RAR && !ra->cfra){ + LOG_I(NR_MAC,"[RAPROC] RA-Msg3 transmitted\n"); nr_Msg3_transmitted(ul_info->module_id, ul_info->cc_id, ul_info->frame_tx, ul_info->gNB_index); } @@ -1009,12 +1041,13 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac, int delta = 0; NR_BWP_Uplink_t *ubwp = mac->ULbwp[0]; + // Get the numerology to calculate the Tx frame and slot - int mu = ubwp ? + int mu = ubwp ? ubwp->bwp_Common->genericParameters.subcarrierSpacing : mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing; - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ubwp ? + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ubwp ? ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; // k2 as per 3GPP TS 38.214 version 15.9.0 Release 15 ch 6.1.2.1.1 @@ -1096,20 +1129,20 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { uint8_t prach_conf_period_frame_idx; int64_t *prach_config_info_p; - NR_RACH_ConfigCommon_t *setup = (mac->scc) ? + NR_RACH_ConfigCommon_t *setup = (mac->scc) ? mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; - + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = &setup->rach_ConfigGeneric; config_index = rach_ConfigGeneric->prach_ConfigurationIndex; - if (setup->msg1_SubcarrierSpacing) - //L139 + if (setup->msg1_SubcarrierSpacing) { mu = *setup->msg1_SubcarrierSpacing; - else - //L839 I don't think this is supported by UE looking at the code below - AssertFatal(1==0,"Long PRACH not supported\n"); + } else if(mac->scc) { + mu = mac->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + } else { + mu = get_softmodem_params()->numerology; + } msg1_FDM = rach_ConfigGeneric->msg1_FDM; @@ -1166,7 +1199,7 @@ static void build_ro_list(NR_UE_MAC_INST_t *mac) { prach_conf_start_symbol = prach_config_info_p[5]; N_t_slot = prach_config_info_p[7]; N_dur = prach_config_info_p[8]; - LOG_D(NR_MAC,"N_t_slot %d, N_dur %d\n",N_t_slot,N_dur); + LOG_D(NR_MAC,"N_t_slot %d, N_dur %d\n",N_t_slot,N_dur); if (prach_config_info_p[1] != -1) format2 = (uint8_t) prach_config_info_p[1]; format = ((uint8_t) prach_config_info_p[0]) | (format2<<8); @@ -1311,7 +1344,6 @@ static void build_ssb_list(NR_UE_MAC_INST_t *mac) { LOG_D(NR_MAC,"SSB idx %d transmitted\n", ssb_idx); } ssb_idx++; - } break; default: @@ -1330,9 +1362,9 @@ static void build_ssb_list(NR_UE_MAC_INST_t *mac) { for (uint8_t bit_nb=7; bit_nb<=7; bit_nb--) { // If SSB is transmitted if ((ssb_positionsInBurst>>bit_nb) & 0x01) { - ssb_list.nb_tx_ssb++; - ssb_list.tx_ssb[ssb_idx].transmitted = true; - LOG_D(NR_MAC,"SSB idx %d transmitted\n", ssb_idx); + ssb_list.nb_tx_ssb++; + ssb_list.tx_ssb[ssb_idx].transmitted = true; + LOG_D(NR_MAC,"SSB idx %d transmitted\n", ssb_idx); } ssb_idx++; } @@ -1345,10 +1377,9 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) { // Map SSBs to PRACH occasions // =========================== // WIP: Assumption: No PRACH occasion is rejected because of a conflict with SSBs or TDD_UL_DL_ConfigurationCommon schedule - NR_RACH_ConfigCommon_t *setup = (mac->scc) ? + NR_RACH_ConfigCommon_t *setup = (mac->scc) ? mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: - mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; - + mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; NR_RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR ssb_perRACH_config = setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present; boolean_t multiple_ssb_per_ro; // true if more than one or exactly one SSB per RACH occasion, false if more than one RO per SSB @@ -1549,7 +1580,7 @@ static void map_ssb_to_ro(NR_UE_MAC_INST_t *mac) { for (ssb_idx=0; ssb_idx %d\n", + LOG_D(NR_MAC,"Checking ssb_idx %d => %d\n", ssb_idx,ssb_list.tx_ssb[ssb_idx].transmitted); // Map only the transmitted ssb_idx @@ -1759,7 +1790,6 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s ra->generate_nr_prach = GENERATE_IDLE; // Reset flag for PRACH generation NR_TDD_UL_DL_ConfigCommon_t *tdd_config = scc==NULL ? scc_SIB->tdd_UL_DL_ConfigurationCommon : scc->tdd_UL_DL_ConfigurationCommon; - if (is_nr_UL_slot(tdd_config, slotP, mac->frame_type)) { // WIP Need to get the proper selected ssb_idx @@ -1870,7 +1900,6 @@ void nr_ue_prach_scheduler(module_id_t module_idP, frame_t frameP, sub_frame_t s } // if is_nr_UL_slot } - // This function schedules the reception of SIB1 after initial sync and before going to real time state void nr_ue_sib1_scheduler(module_id_t module_idP, int cc_id, @@ -1941,22 +1970,23 @@ void nr_ue_sib1_scheduler(module_id_t module_idP, } +#define MAX_LCID 8 //Fixme: also defined in LCID table uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t subframe, uint8_t eNB_index, uint8_t *ulsch_buffer, uint16_t buflen, uint8_t *access_mode) { + uint8_t total_rlc_pdu_header_len = 0; int16_t buflen_remain = 0; uint8_t lcid = 0; - uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + uint16_t sdu_lengths[MAX_LCID] = { 0 }; + uint8_t sdu_lcids[MAX_LCID] = { 0 }; uint16_t payload_offset = 0, num_sdus = 0; uint8_t ulsch_sdus[MAX_ULSCH_PAYLOAD_BYTES]; uint16_t sdu_length_total = 0; //unsigned short post_padding = 0; NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); - rlc_buffer_occupancy_t lcid_buffer_occupancy_old = - 0, lcid_buffer_occupancy_new = 0; + rlc_buffer_occupancy_t lcid_buffer_occupancy_new = 0; LOG_D(NR_MAC, "[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n", module_idP, frameP, subframe, buflen); @@ -1965,13 +1995,11 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, // Check for DCCH first // TO DO: Multiplex in the order defined by the logical channel prioritization - for (lcid = UL_SCH_LCID_SRB1; lcid < NR_MAX_NUM_LCID; lcid++) { - lcid_buffer_occupancy_old = mac_rlc_get_buffer_occupancy_ind(module_idP, mac->crnti, eNB_index, frameP, subframe, ENB_FLAG_NO, lcid); - lcid_buffer_occupancy_new = lcid_buffer_occupancy_old; - - if(lcid_buffer_occupancy_new){ + for (lcid = UL_SCH_LCID_SRB1; lcid < MAX_LCID; lcid++) { + lcid_buffer_occupancy_new = mac_rlc_get_buffer_occupancy_ind(module_idP, mac->crnti, eNB_index, frameP, subframe, ENB_FLAG_NO, lcid); + if(lcid_buffer_occupancy_new) { buflen_remain = buflen - (total_rlc_pdu_header_len + sdu_length_total + MAX_RLC_SDU_SUBHEADER_SIZE); LOG_D(NR_MAC, @@ -1990,7 +2018,9 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, ENB_FLAG_NO, MBMS_FLAG_NO, lcid, - buflen_remain, + buflen_remain-MAX_RLC_SDU_SUBHEADER_SIZE, + //Fixme: Laurent I removed MAX_RLC_SDU_SUBHEADER_SIZE because else we get out the buffer silently + // the interface with nr_generate_ulsch_pdu() looks over complex and not CPU optimized (char *)&ulsch_sdus[sdu_length_total],0, 0); @@ -2009,15 +2039,8 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, } /* Get updated BO after multiplexing this PDU */ - lcid_buffer_occupancy_new = mac_rlc_get_buffer_occupancy_ind(module_idP, - mac->crnti, - eNB_index, - frameP, - subframe, - ENB_FLAG_NO, - lcid); - buflen_remain = - buflen - (total_rlc_pdu_header_len + sdu_length_total + MAX_RLC_SDU_SUBHEADER_SIZE); + lcid_buffer_occupancy_new = mac_rlc_get_buffer_occupancy_ind(module_idP,mac->crnti,eNB_index,frameP, subframe, ENB_FLAG_NO, lcid); + buflen_remain = buflen - (total_rlc_pdu_header_len + sdu_length_total + MAX_RLC_SDU_SUBHEADER_SIZE); } } } @@ -2036,9 +2059,9 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, 0, // long_bsr 0, // post_padding buflen); // TBS in bytes + } else { + return 0; } - else - return 0; // Padding: fill remainder of ULSCH with 0 if (buflen - payload_offset > 0){ @@ -2046,7 +2069,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, ulsch_buffer[j] = 0; } - //#if defined(ENABLE_MAC_PAYLOAD_DEBUG) +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) LOG_I(NR_MAC, "Printing UL MAC payload UE side, payload_offset: %d \n", payload_offset); for (int i = 0; i < buflen ; i++) { //harq_process_ul_ue->a[i] = (unsigned char) rand(); @@ -2054,7 +2077,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP, printf("%02x ",(unsigned char)ulsch_buffer[i]); } printf("\n"); - //#endif +#endif return 1; } diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 803c906798..e300b21ddf 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -54,11 +54,11 @@ extern RAN_CONTEXT_t RC; extern void mac_top_init_gNB(void); extern uint8_t nfapi_mode; -void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list, +void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list, struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_bearer2release_list, NR_UE_sched_ctrl_t *sched_ctrl) { - if (rlc_bearer2add_list) + if (rlc_bearer2add_list) // keep lcids for (int i=0;ilist.count;i++) { sched_ctrl->lcid_mask |= (1<list.array[i]->logicalChannelIdentity); @@ -67,10 +67,10 @@ void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList * rlc_bearer2add_list->list.array[i]->logicalChannelIdentity<4 ? "SRB" : "DRB", (int)rlc_bearer2add_list->list.array[i]->logicalChannelIdentity); } - if (rlc_bearer2release_list) + if (rlc_bearer2release_list) for (int i=0;ilist.count;i++) sched_ctrl->lcid_mask |= (1<<*rlc_bearer2release_list->list.array[i]); - + } @@ -118,7 +118,7 @@ void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sche AssertFatal(CellGroup, "CellGroup is null\n"); NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = CellGroup->mac_CellGroupConfig; - + if (mac_CellGroupConfig) { process_drx_Config(sched_ctrl,mac_CellGroupConfig->drx_Config); @@ -134,7 +134,7 @@ void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sche process_rlcBearerConfig(CellGroup->rlc_BearerToAddModList,CellGroup->rlc_BearerToReleaseList,sched_ctrl); -} +} void config_common(int Mod_idP, int ssb_SubcarrierOffset, int pdsch_AntennaPorts, int pusch_AntennaPorts, NR_ServingCellConfigCommon_t *scc) { nfapi_nr_config_request_scf_t *cfg = &RC.nrmac[Mod_idP]->config[0]; @@ -452,14 +452,6 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, AssertFatal(RC.nrmac[Mod_idP]->common_channels[0].vrb_map_UL, "could not allocate memory for RC.nrmac[]->common_channels[0].vrb_map_UL\n"); - for (int i = 0; i < MAX_NUM_BWP; ++i) { - RC.nrmac[Mod_idP]->pucch_index_used[i] = - calloc(n, sizeof(*RC.nrmac[Mod_idP]->pucch_index_used)); - AssertFatal(RC.nrmac[Mod_idP]->pucch_index_used[i], - "could not allocate memory for RC.nrmac[]->pucch_index_used[%d]\n", - i); - } - LOG_I(NR_MAC,"Configuring common parameters from NR ServingCellConfig\n"); config_common(Mod_idP, @@ -467,7 +459,7 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, pdsch_AntennaPorts, pusch_AntennaPorts, scc); - LOG_E(NR_MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); + LOG_D(NR_MAC, "%s() %s:%d RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req:%p\n", __FUNCTION__, __FILE__, __LINE__, RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req); // if in nFAPI mode if ( (NFAPI_MODE == NFAPI_MODE_PNF || NFAPI_MODE == NFAPI_MODE_VNF) && (RC.nrmac[Mod_idP]->if_inst->NR_PHY_config_req == NULL) ){ @@ -488,6 +480,32 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, find_SSB_and_RO_available(Mod_idP); + const NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; + const int nr_dlmix_slots = tdd->nrofDownlinkSlots + (tdd->nrofDownlinkSymbols != 0); + const int nr_ulstart_slot = tdd->nrofDownlinkSlots + (tdd->nrofUplinkSymbols == 0); + + for (int slot = 0; slot < n; ++slot) { + /* FIXME: it seems there is a problem with slot 0/10/slots right after UL: + * we just get retransmissions. Thus, do not schedule such slots in DL */ + if (slot % nr_slots_period != 0) + RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) < nr_dlmix_slots) << (slot % 64); + RC.nrmac[Mod_idP]->ulsch_slot_bitmap[slot / 64] |= (uint64_t)((slot % nr_slots_period) >= nr_ulstart_slot) << (slot % 64); + LOG_D(NR_MAC, "slot %d DL %d UL %d\n", + slot, + (RC.nrmac[Mod_idP]->dlsch_slot_bitmap[slot / 64] & ((uint64_t)1 << (slot % 64))) != 0, + (RC.nrmac[Mod_idP]->ulsch_slot_bitmap[slot / 64] & ((uint64_t)1 << (slot % 64))) != 0); + } + + if (get_softmodem_params()->phy_test) { + RC.nrmac[Mod_idP]->pre_processor_dl = nr_preprocessor_phytest; + RC.nrmac[Mod_idP]->pre_processor_ul = nr_ul_preprocessor_phytest; + } else { + RC.nrmac[Mod_idP]->pre_processor_dl = nr_init_fr1_dlsch_preprocessor(Mod_idP, 0); + RC.nrmac[Mod_idP]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(Mod_idP, 0); + } + if (get_softmodem_params()->sa > 0) { NR_COMMON_channels_t *cc = &RC.nrmac[Mod_idP]->common_channels[0]; RC.nrmac[Mod_idP]->sib1_tda = sib1_tda; @@ -504,10 +522,30 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, if (CellGroup) { + const NR_ServingCellConfig_t *servingCellConfig = CellGroup->spCellConfig->spCellConfigDedicated; + + const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = servingCellConfig->downlinkBWP_ToAddModList; + if(bwpList) { + AssertFatal(bwpList->list.count > 0, "downlinkBWP_ToAddModList has no BWPs!\n"); + for (int i = 0; i < bwpList->list.count; ++i) { + const NR_BWP_Downlink_t *bwp = bwpList->list.array[i]; + calculate_preferred_dl_tda(Mod_idP, bwp); + } + } + + const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList; + if(ubwpList) { + AssertFatal(ubwpList->list.count > 0, "downlinkBWP_ToAddModList no BWPs!\n"); + for (int i = 0; i < ubwpList->list.count; ++i) { + const NR_BWP_Uplink_t *ubwp = ubwpList->list.array[i]; + calculate_preferred_ul_tda(Mod_idP, ubwp); + } + } + NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; if (add_ue == 1 && get_softmodem_params()->phy_test) { const int UE_id = add_new_nr_ue(Mod_idP, rnti, CellGroup); - LOG_I(PHY,"Added new UE_id %d/%x with initial CellGroup\n",UE_id,rnti); + LOG_I(NR_MAC,"Added new UE_id %d/%x with initial CellGroup\n",UE_id,rnti); process_CellGroup(CellGroup,&UE_info->UE_sched_ctrl[UE_id]); } else if (add_ue == 1 && !get_softmodem_params()->phy_test) { const int CC_id = 0; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c index 20f0bea3b2..3a704c2093 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler.c @@ -55,46 +55,81 @@ #include "nfapi/oai_integration/vendor_ext.h" #include "executables/nr-softmodem.h" +#include +#include + uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 }; void clear_mac_stats(gNB_MAC_INST *gNB) { memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t)); } - +#define MACSTATSSTRLEN 16384 void dump_mac_stats(gNB_MAC_INST *gNB) { NR_UE_info_t *UE_info = &gNB->UE_info; int num = 1; + FILE *fd=fopen("nrMAC_stats.log","w"); + AssertFatal(fd!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno)); + char output[MACSTATSSTRLEN]; + memset(output,0,MACSTATSSTRLEN); + int stroff=0; for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { - LOG_I(MAC, "UE ID %d RNTI %04x (%d/%d)\n", UE_id, UE_info->rnti[UE_id], num++, UE_info->num_UEs); + stroff = sprintf(output,"UE ID %d RNTI %04x (%d/%d)\n", UE_id, UE_info->rnti[UE_id], num++, UE_info->num_UEs); + LOG_I(NR_MAC, "UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm\n", + UE_id, + UE_info->rnti[UE_id], + num++, + UE_info->num_UEs, + UE_info->UE_sched_ctrl[UE_id].ph, + UE_info->UE_sched_ctrl[UE_id].pcmax); NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id]; const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0; - LOG_I(MAC, "UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, average RSRP %d (%d meas)\n", + stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, average RSRP %d (%d meas)\n", UE_id, stats->dlsch_rounds[0], stats->dlsch_rounds[1], stats->dlsch_rounds[2], stats->dlsch_rounds[3], stats->dlsch_errors, avg_rsrp, stats->num_rsrp_meas); + LOG_I(NR_MAC, "UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, average RSRP %d (%d meas)\n", + UE_id, + stats->dlsch_rounds[0], stats->dlsch_rounds[1], + stats->dlsch_rounds[2], stats->dlsch_rounds[3], stats->dlsch_errors, + avg_rsrp, stats->num_rsrp_meas); stats->num_rsrp_meas = 0; stats->cumul_rsrp = 0 ; - LOG_I(MAC, "UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes); - LOG_I(MAC, "UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n", + stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes); + stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n", + UE_id, + stats->ulsch_rounds[0], stats->ulsch_rounds[1], + stats->ulsch_rounds[2], stats->ulsch_rounds[3], + stats->ulsch_DTX, + stats->ulsch_errors); + stroff+=sprintf(output+stroff, + "UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n", + UE_id, + stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx); + LOG_I(NR_MAC, "UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes); + LOG_I(NR_MAC, "UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n", UE_id, stats->ulsch_rounds[0], stats->ulsch_rounds[1], - stats->ulsch_rounds[2], stats->ulsch_rounds[3], + stats->ulsch_rounds[2], stats->ulsch_rounds[3], stats->ulsch_DTX, stats->ulsch_errors); - LOG_I(MAC, + LOG_I(NR_MAC, "UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n", UE_id, stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx); for (int lc_id = 0; lc_id < 63; lc_id++) { if (stats->lc_bytes_tx[lc_id] > 0) - LOG_I(MAC, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); + stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); + LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]); if (stats->lc_bytes_rx[lc_id] > 0) - LOG_I(MAC, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); + stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); + LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]); } } print_meas(&gNB->eNB_scheduler, "DL & UL scheduling timing stats", NULL, NULL); + if (stroff>0) fprintf(fd,"%s",output); + fclose(fd); } void clear_nr_nfapi_information(gNB_MAC_INST * gNB, @@ -305,7 +340,7 @@ void schedule_nr_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subfram bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot) { - if (slot>64) return false; //quickfix for FR2 where there are more than 64 slots (bitmap to be removed) + if (slot>=64) return false; //quickfix for FR2 where there are more than 64 slots (bitmap to be removed) return (bitmap >> slot) & 0x01; } @@ -315,63 +350,24 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, protocol_ctxt_t ctxt={0}; PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP); - - int nb_periods_per_frame; const int bwp_id = 1; gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = gNB->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; - NR_TDD_UL_DL_Pattern_t *tdd_pattern = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; - - switch(scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity) { - case 0: - nb_periods_per_frame = 20; // 10ms/0p5ms - break; - - case 1: - nb_periods_per_frame = 16; // 10ms/0p625ms - break; - - case 2: - nb_periods_per_frame = 10; // 10ms/1ms - break; - - case 3: - nb_periods_per_frame = 8; // 10ms/1p25ms - break; - - case 4: - nb_periods_per_frame = 5; // 10ms/2ms - break; - - case 5: - nb_periods_per_frame = 4; // 10ms/2p5ms - break; - - case 6: - nb_periods_per_frame = 2; // 10ms/5ms - break; - - case 7: - nb_periods_per_frame = 1; // 10ms/10ms - break; - - default: - AssertFatal(1==0,"Undefined tdd period %ld\n", scc->tdd_UL_DL_ConfigurationCommon->pattern1.dl_UL_TransmissionPeriodicity); - } if (slot==0 && (*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]>=257)) { + const NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int n = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; + const int nb_periods_per_frame = n / nr_slots_period; // re-initialization of tdd_beam_association at beginning of frame (only for FR2) for (int i=0; itdd_beam_association[i] = -1; } - int num_slots_per_tdd = (nr_slots_per_frame[*scc->ssbSubcarrierSpacing])/nb_periods_per_frame; - - const int nr_ulmix_slots = tdd_pattern->nrofUplinkSlots + (tdd_pattern->nrofUplinkSymbols!=0); - start_meas(&RC.nrmac[module_idP]->eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); @@ -385,17 +381,6 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, nr_rrc_trigger(&ctxt, 0 /*CC_id*/, frame, slot >> *scc->ssbSubcarrierSpacing); } -#define BIT(x) (1 << (x)) - const uint64_t dlsch_in_slot_bitmap = BIT( 1) | BIT( 2) | BIT( 3) | BIT( 4) | BIT( 5) | BIT( 6) - | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15) | BIT(16); - - uint8_t prach_config_index = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric.prach_ConfigurationIndex; - uint64_t ulsch_in_slot_bitmap; - if (prach_config_index==4) //this is the PRACH config used in the Benetel RRU. TODO: make this generic for any PRACH config. - ulsch_in_slot_bitmap = BIT( 8) | BIT( 9); - else - ulsch_in_slot_bitmap = BIT( 8) | BIT(18); - memset(RC.nrmac[module_idP]->cce_list[0][0],0,MAX_NUM_CCE*sizeof(int)); // coreset0 memset(RC.nrmac[module_idP]->cce_list[bwp_id][1],0,MAX_NUM_CCE*sizeof(int)); // coresetid 1 NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; @@ -421,7 +406,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, // This schedules MIB - schedule_nr_mib(module_idP, frame, slot, nr_slots_per_frame[*scc->ssbSubcarrierSpacing],nb_periods_per_frame); + schedule_nr_mib(module_idP, frame, slot); // This schedules SIB1 if ( get_softmodem_params()->sa == 1 ) @@ -443,7 +428,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } // This schedule SR - // TODO + nr_sr_reporting(module_idP, frame, slot); // Schedule CSI measurement reporting: check in slot 0 for the whole frame if (slot == 0) @@ -456,14 +441,10 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, } // This schedules the DCI for Uplink and subsequently PUSCH - { - nr_schedule_ulsch(module_idP, frame, slot, num_slots_per_tdd, nr_ulmix_slots, ulsch_in_slot_bitmap); - } + nr_schedule_ulsch(module_idP, frame, slot); // This schedules the DCI for Downlink and PDSCH - if (is_xlsch_in_slot(dlsch_in_slot_bitmap, slot)) - nr_schedule_ue_spec(module_idP, frame, slot); - + nr_schedule_ue_spec(module_idP, frame, slot); nr_schedule_pucch(module_idP, frame, slot); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 6cd89c7424..d4475cc53d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -41,6 +41,7 @@ #include "UTIL/OPT/opt.h" #include "SIMULATION/TOOLS/sim.h" // for taus +#include extern RAN_CONTEXT_t RC; extern const uint8_t nr_slots_per_frame[5]; extern uint16_t sl_ahead; @@ -214,7 +215,7 @@ void find_SSB_and_RO_available(module_id_t module_idP) { } cc->total_prach_occasions_per_config_period = total_RA_occasions; - for(int i=1; (1 << (i-1)) < max_association_period; i++) { + for(int i=1; (1 << (i-1)) <= max_association_period; i++) { cc->max_association_period = (1 <<(i-1)); total_RA_occasions = total_RA_occasions * cc->max_association_period; if(total_RA_occasions >= (int) (num_active_ssb/num_ssb_per_RO)) { @@ -377,6 +378,16 @@ void schedule_nr_prach(module_id_t module_idP, frame_t frameP, sub_frame_t slotP } } } + + // block resources in vrb_map_UL + const NR_RACH_ConfigGeneric_t *rach_ConfigGeneric = + &scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric; + const uint8_t mu_pusch = + scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + const int16_t N_RA_RB = get_N_RA_RB(cfg->prach_config.prach_sub_c_spacing.value, mu_pusch); + uint16_t *vrb_map_UL = &cc->vrb_map_UL[slotP * MAX_BWP_SIZE]; + for (int i = 0; i < N_RA_RB * fdm; ++i) + vrb_map_UL[rach_ConfigGeneric->msg1_FrequencyStart + i] = 0xff; // all symbols } } } @@ -502,7 +513,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, num_ssb_per_RO -= 3; total_RApreambles = total_RApreambles/num_ssb_per_RO ; } - + for (int i = 0; i < NR_NB_RA_PROC_MAX; i++) { NR_RA_t *ra = &cc->ra[i]; pr_found = 0; @@ -515,11 +526,11 @@ void nr_initiate_ra_proc(module_id_t module_idP, } } if (pr_found == 0) { - continue; + continue; } - + uint16_t ra_rnti; - + // ra_rnti from 5.1.3 in 38.321 // FK: in case of long PRACH the phone seems to expect the subframe number instead of the slot number here. if (scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present @@ -527,26 +538,28 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra_rnti = 1 + symbol + (9 /*slotP*/ * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); else ra_rnti = 1 + symbol + (slotP * 14) + (freq_index * 14 * 80) + (ul_carrier_id * 14 * 80 * 8); + // This should be handled differently when we use the initialBWP for RA ra->bwp_id = 0; NR_BWP_Downlink_t *bwp=NULL; if (ra->CellGroup && ra->CellGroup->spCellConfig && ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { - bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; - ra->bwp_id = 1; + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) { + ra->bwp_id = 1; + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1); - + LOG_D(NR_MAC, - "[gNB %d][RAPROC] CC_id %d Frame %d, Slot %d Initiating RA procedure for preamble index %d\n", - module_idP, - CC_id, - frameP, - slotP, - preamble_index); - + "[gNB %d][RAPROC] CC_id %d Frame %d, Slot %d Initiating RA procedure for preamble index %d\n", + module_idP, + CC_id, + frameP, + slotP, + preamble_index); + uint8_t beam_index = ssb_index_from_prach(module_idP, frameP, slotP, preamble_index, freq_index, symbol); - + // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries if (ra->cfra) { // if the preamble received correspond to one of the listed @@ -564,20 +577,26 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->timing_offset = timing_offset; ra->preamble_slot = slotP; - struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = bwp ? - bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList: - scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + NR_SearchSpaceId_t ra_SearchSpace = 0; + struct NR_PDCCH_ConfigCommon__commonSearchSpaceList *commonSearchSpaceList = NULL; + if(bwp) { + commonSearchSpaceList = bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + } else { + commonSearchSpaceList = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList; + ra_SearchSpace = *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace; + } AssertFatal(commonSearchSpaceList->list.count > 0, "common SearchSpace list has 0 elements\n"); - // Common searchspace list + // Common SearchSpace list for (int i = 0; i < commonSearchSpaceList->list.count; i++) { ss = commonSearchSpaceList->list.array[i]; - if (ss->searchSpaceId == (bwp ? - *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace : - *scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace)) + if (ss->searchSpaceId == ra_SearchSpace) ra->ra_ss = ss; } + AssertFatal(ra->ra_ss!=NULL,"SearchSpace cannot be null for RA\n"); + // retrieving ra pdcch monitoring period and offset find_monitoring_periodicity_offset_common(ra->ra_ss, &monitoring_slot_period, &monitoring_offset); @@ -598,8 +617,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, LOG_D(NR_MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP); int loop = 0; - // This condition allows for the usage of a preconfigured rnti for the first UE - if (!ra->cfra || ra->rnti == 0) { + if (ra->rnti == 0) { // This condition allows for the usage of a preconfigured rnti for the CFRA do { ra->rnti = (taus() % 65518) + 1; loop++; @@ -635,7 +653,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0); } -void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) + void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { gNB_MAC_INST *mac = RC.nrmac[module_idP]; @@ -676,31 +694,37 @@ void nr_get_Msg3alloc(module_id_t module_id, uint16_t msg3_nb_rb = 8 + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); // sdu has 6 or 8 bytes - int mu = ubwp ? + int mu = ubwp ? ubwp->bwp_Common->genericParameters.subcarrierSpacing : scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; - int StartSymbolIndex, NrOfSymbols, startSymbolAndLength, temp_slot; + int StartSymbolIndex = 0; + int NrOfSymbols = 0; + int startSymbolAndLength = 0; + int temp_slot = 0; ra->Msg3_tda_id = 16; // initialization to a value above limit - NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList= ubwp ? + NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList= ubwp ? ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + uint8_t k2 = 0; for (int i=0; ilist.count; i++) { startSymbolAndLength = pusch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &StartSymbolIndex, &NrOfSymbols); // we want to transmit in the uplink symbols of mixed slot if (NrOfSymbols == scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols) { - ra->Msg3_tda_id = i; - break; + k2 = *pusch_TimeDomainAllocationList->list.array[i]->k2; + temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213 + ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu]; + if (is_xlsch_in_slot(RC.nrmac[module_id]->ulsch_slot_bitmap[ra->Msg3_slot / 64], ra->Msg3_slot)) { + ra->Msg3_tda_id = i; + break; + } } } + AssertFatal(ra->Msg3_tda_id<16,"Unable to find Msg3 time domain allocation in list\n"); - uint8_t k2 = *pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->k2; - - temp_slot = current_slot + k2 + DELTA[mu]; // msg3 slot according to 8.3 in 38.213 - ra->Msg3_slot = temp_slot%nr_slots_per_frame[mu]; if (nr_slots_per_frame[mu]>temp_slot) ra->Msg3_frame = current_frame; else @@ -721,9 +745,9 @@ void nr_get_Msg3alloc(module_id_t module_id, LOG_D(NR_MAC, "[RAPROC] Msg3 slot %d: current slot %u Msg3 frame %u k2 %u Msg3_tda_id %u start symbol index %u\n", ra->Msg3_slot, current_slot, ra->Msg3_frame, k2,ra->Msg3_tda_id, StartSymbolIndex); uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[ra->Msg3_slot * MAX_BWP_SIZE]; - const uint16_t bwpSize = NRRIV2BW(ubwp ? + const uint16_t bwpSize = NRRIV2BW(ubwp ? ubwp->bwp_Common->genericParameters.locationAndBandwidth : - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); /* search msg3_nb_rb free RBs */ @@ -788,31 +812,31 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t int scs = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; int fh = 0; int startSymbolAndLength = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + int mappingtype = scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; if (ra->CellGroup) { AssertFatal(ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count == 1, "downlinkBWP_ToAddModList has %d BWP!\n", ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); NR_BWP_Uplink_t *ubwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id - 1]; - startSymbolAndLength = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->startSymbolAndLength; + mappingtype = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList->list.array[ra->Msg3_tda_id]->mappingType; abwp_size = NRRIV2BW(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); abwp_start = NRRIV2PRBOFFSET(ubwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing; fh = ubwp->bwp_Dedicated->pusch_Config->choice.setup->frequencyHopping ? 1 : 0; - } LOG_D(NR_MAC, "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n", - frameP, - slotP, - ra->Msg3_frame, - ra->Msg3_slot, - ra->msg3_nb_rb, - ra->msg3_first_rb, - ra->msg3_round, - ra->rnti); - + frameP, + slotP, + ra->Msg3_frame, + ra->Msg3_slot, + ra->msg3_nb_rb, + ra->msg3_first_rb, + ra->msg3_round, + ra->rnti); + int start_symbol_index,nr_of_symbols; SLIV2SL(startSymbolAndLength, &start_symbol_index, &nr_of_symbols); @@ -825,7 +849,7 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t else pusch_pdu->bwp_start = ibwp_start; pusch_pdu->bwp_size = ibwp_size; - pusch_pdu->subcarrier_spacing = scs; + pusch_pdu->subcarrier_spacing = scs; pusch_pdu->cyclic_prefix = 0; pusch_pdu->mcs_index = 0; pusch_pdu->mcs_table = 0; @@ -837,7 +861,10 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t pusch_pdu->transform_precoding = 0; pusch_pdu->data_scrambling_id = *scc->physCellId; pusch_pdu->nrOfLayers = 1; - pusch_pdu->ul_dmrs_symb_pos = 1<ul_dmrs_symb_pos = get_l_prime(nr_of_symbols,mappingtype,pusch_dmrs_pos2,pusch_len1,start_symbol_index, scc->dmrs_TypeA_Position); + LOG_D(MAC, "MSG3 start_sym:%d NR Symb:%d mappingtype:%d , ul_dmrs_symb_pos:%x\n", start_symbol_index, nr_of_symbols, mappingtype, pusch_pdu->ul_dmrs_symb_pos); + pusch_pdu->dmrs_config_type = 0; pusch_pdu->ul_dmrs_scrambling_id = *scc->physCellId; //If provided and the PUSCH is not a msg3 PUSCH, otherwise, L2 should set this to physical cell id. pusch_pdu->scid = 0; //DMRS sequence initialization [TS38.211, sec 6.4.1.1.1]. Should match what is sent in DCI 0_1, otherwise set to 0. @@ -884,12 +911,11 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { - uint8_t time_domain_assignment = 3; + uint8_t time_domain_assignment = 1; uint8_t mcsIndex = 0; int rbStart = 0; int rbSize = 8; - NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; @@ -902,10 +928,10 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra long BWPStart = 0; if (ra->CellGroup && - ra->CellGroup->spCellConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) { + ra->CellGroup->spCellConfig && + ra->CellGroup->spCellConfig->spCellConfigDedicated && + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) { bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; genericParameters = &bwp->bwp_Common->genericParameters; pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; @@ -917,7 +943,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); coreset = get_coreset(scc,bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); - if (coreset == NULL) coreset = nr_mac->sched_ctrlCommon->coreset; + + AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg2\n"); uint16_t *vrb_map = cc[CC_id].vrb_map; for (int i = 0; (i < rbSize) && (rbStart <= (BWPSize - rbSize)); i++) { @@ -956,11 +983,13 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_D(MAC,"Msg2 startSymbolIndex.nrOfSymbols %d.%d\n",startSymbolIndex,nrOfSymbols); + int mappingtype = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->mappingType; + // look up the PDCCH PDU for this CC, BWP, and CORESET. If it does not exist, create it. This is especially // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][ra->bwp_id][coresetid]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; if (!pdcch_pdu_rel15) { nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t)); @@ -969,7 +998,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; nr_configure_pdcch(pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); - nr_mac->pdcch_pdu_idx[CC_id][ra->bwp_id][coresetid] = pdcch_pdu_rel15; + nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15; } nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -988,10 +1017,10 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra uint8_t mcsTableIdx = 0; if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { + bwp->bwp_Dedicated && + bwp->bwp_Dedicated->pdsch_Config && + bwp->bwp_Dedicated->pdsch_Config->choice.setup && + bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) mcsTableIdx = 1; else @@ -1001,12 +1030,12 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int dmrsConfigType=0; if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) + bwp->bwp_Dedicated && + bwp->bwp_Dedicated->pdsch_Config && + bwp->bwp_Dedicated->pdsch_Config->choice.setup && + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA && + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup && + bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type) dmrsConfigType = 1; pdsch_pdu_rel15->pduBitmap = 0; @@ -1029,7 +1058,7 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->dmrsConfigType = dmrsConfigType; pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu_rel15->SCID = 0; - pdsch_pdu_rel15->numDmrsCdmGrpsNoData = nrOfSymbols <=2 ? 1 : 2; + pdsch_pdu_rel15->numDmrsCdmGrpsNoData = nrOfSymbols <= 2 ? 1 : 2; pdsch_pdu_rel15->dmrsPorts = 1; pdsch_pdu_rel15->resourceAlloc = 1; pdsch_pdu_rel15->rbStart = rbStart; @@ -1040,7 +1069,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL, nr_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, - startSymbolIndex); + startSymbolIndex, + mappingtype); int x_Overhead = 0; uint8_t tb_scaling = 0; @@ -1061,9 +1091,6 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0(pdsch_pdu_rel15->rbSize, pdsch_pdu_rel15->rbStart, pdsch_pdu_rel15->BWPSize); - LOG_D(MAC,"Msg2 rbSize.rbStart.BWPsize %d.%d.%d\n",pdsch_pdu_rel15->rbSize, - pdsch_pdu_rel15->rbStart, - pdsch_pdu_rel15->BWPSize); dci_payload.time_domain_assignment.val = time_domain_assignment; dci_payload.vrb_to_prb_mapping.val = 0; @@ -1103,8 +1130,8 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; // Program UL processing for Msg3 - NR_BWP_Uplink_t *ubwp = ra->CellGroup ? - ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1] : + NR_BWP_Uplink_t *ubwp = ra->CellGroup ? + ra->CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[ra->bwp_id-1] : NULL; nr_get_Msg3alloc(module_idP, CC_id, scc, ubwp, slotP, frameP, ra, nr_mac->tdd_beam_association); nr_add_msg3(module_idP, CC_id, frameP, slotP, ra, (uint8_t *) &tx_req->TLVs[0].value.direct[0]); @@ -1138,7 +1165,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra gNB_MAC_INST *nr_mac = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc = &nr_mac->common_channels[CC_id]; - NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; if (ra->Msg4_frame == frameP && ra->Msg4_slot == slotP ) { @@ -1148,32 +1174,40 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_SearchSpace_t *ss = ra->ra_ss; - NR_BWP_Downlink_t *bwp = ra->CellGroup ? ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1] : NULL; - NR_ControlResourceSet_t *coreset = get_coreset(scc,ra->CellGroup ? ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id - 1] : NULL, - ss, NR_SearchSpace__searchSpaceType_PR_common); + NR_BWP_Downlink_t *bwp = NULL; + NR_ControlResourceSet_t *coreset = NULL; + NR_BWP_t *genericParameters = NULL; + NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList=NULL; - if (coreset == NULL) coreset = nr_mac->sched_ctrlCommon->coreset; + if (ra->CellGroup && + ra->CellGroup->spCellConfig && + ra->CellGroup->spCellConfig->spCellConfigDedicated && + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList && + ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]) { + bwp = ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[ra->bwp_id-1]; + genericParameters = &bwp->bwp_Common->genericParameters; + pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } + else { + genericParameters= &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; + pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + } + coreset = get_coreset(scc,bwp, ss, NR_SearchSpace__searchSpaceType_PR_common); + + AssertFatal(coreset!=NULL,"Coreset cannot be null for RA-Msg4\n"); int UE_id = find_nr_UE_id(module_idP, ra->rnti); NR_UE_info_t *UE_info = &nr_mac->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - NR_BWP_t *genericParameters = bwp ? & bwp->bwp_Common->genericParameters : &scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters; long BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); long BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); // HARQ management - int8_t current_harq_pid = sched_ctrl->dl_harq_pid; - if (current_harq_pid < 0) { - current_harq_pid = sched_ctrl->available_dl_harq.head; - remove_front_nr_list(&sched_ctrl->available_dl_harq); - sched_ctrl->dl_harq_pid = current_harq_pid; - } else { - if (sched_ctrl->harq_processes[current_harq_pid].round == 0) - remove_nr_list(&sched_ctrl->available_dl_harq, current_harq_pid); - else - remove_nr_list(&sched_ctrl->retrans_dl_harq, current_harq_pid); - } + AssertFatal(sched_ctrl->available_dl_harq.head >= 0, + "UE context not initialized: no HARQ processes found\n"); + int current_harq_pid = sched_ctrl->available_dl_harq.head; + remove_front_nr_list(&sched_ctrl->available_dl_harq); NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; DevAssert(!harq->is_waiting); add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); @@ -1193,15 +1227,18 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra int n_rb=0; for (int i=0;i<6;i++) for (int j=0;j<8;j++) { - n_rb+=((coreset->frequencyDomainResources.buf[i]>>j)&1); + n_rb+=((coreset->frequencyDomainResources.buf[i]>>j)&1); } n_rb*=6; const uint16_t N_cce = n_rb * coreset->duration / NR_NB_REG_PER_CCE; const int delta_PRI=0; int r_pucch = ((CCEIndex<<1)/N_cce)+(delta_PRI<<1); - nr_acknack_scheduling(module_idP, UE_id, frameP, slotP,r_pucch); - harq->feedback_slot = sched_ctrl->sched_pucch->ul_slot; + int alloc = nr_acknack_scheduling(module_idP, UE_id, frameP, slotP, r_pucch); + AssertFatal(alloc>=0,"Couldn't find a pucch allocation for ack nack (msg4)\n"); + NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[alloc]; + harq->feedback_slot = pucch->ul_slot; + harq->feedback_frame = pucch->frame; // Bytes to be transmitted uint8_t *buf = (uint8_t *) harq->tb; @@ -1214,53 +1251,50 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ((NR_MAC_SUBHEADER_SHORT *) &buf[mac_pdu_length])->L = mac_sdu_length; mac_pdu_length = mac_pdu_length + mac_sdu_length + sizeof(NR_MAC_SUBHEADER_SHORT); - LOG_D(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", - mac_sdu_length, - (int)sizeof(NR_MAC_SUBHEADER_SHORT), - mac_pdu_length); + LOG_D(NR_MAC,"Encoded RRCSetup Piggyback (%d + %d bytes), mac_pdu_length %d\n", mac_sdu_length, (int)sizeof(NR_MAC_SUBHEADER_SHORT), mac_pdu_length); + // Calculate number of symbols int startSymbolIndex, nrOfSymbols; - - NR_PDSCH_TimeDomainResourceAllocationList_t *pdsch_TimeDomainAllocationList; - if (bwp && - bwp->bwp_Common && - bwp->bwp_Common->pdsch_ConfigCommon && - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup && - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList) - pdsch_TimeDomainAllocationList = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - else - pdsch_TimeDomainAllocationList = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - const int startSymbolAndLength = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength; SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); AssertFatal(startSymbolIndex >= 0, "StartSymbolIndex is negative\n"); + int mappingtype = pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->mappingType; + uint16_t dlDmrsSymbPos = fill_dmrs_mask(NULL, scc->dmrs_TypeA_Position, nrOfSymbols, - startSymbolIndex); + startSymbolIndex, + mappingtype); uint16_t N_DMRS_SLOT = get_num_dmrs(dlDmrsSymbPos); - long dmrsConfigType = bwp ? (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1):0; + long dmrsConfigType = bwp!=NULL ? (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; + + nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData = 2; + if (nrOfSymbols == 2) { + nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData = 1; + } + + AssertFatal(nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData == 1 + || nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData == 2, + "nr_mac->schedCtrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData %d is not possible", + nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData); + uint8_t N_PRB_DMRS = 0; - AssertFatal(nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData == 1 || - nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData == 2, - "nr_mac->schedCtrlCommon->numDmrsCdmGrpsNoData %d is not possible", - nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData); if (dmrsConfigType==NFAPI_NR_DMRS_TYPE1) { - N_PRB_DMRS = nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData * 6; + N_PRB_DMRS = nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 6; } else { - N_PRB_DMRS = nr_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData * 4; + N_PRB_DMRS = nr_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 4; } uint8_t mcsTableIdx = 0; if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup && - bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { + bwp->bwp_Dedicated && + bwp->bwp_Dedicated->pdsch_Config && + bwp->bwp_Dedicated->pdsch_Config->choice.setup && + bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) mcsTableIdx = 1; else @@ -1304,7 +1338,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra // important if we have multiple RAs, and the DLSCH has to reuse them, so we need to mark them const int bwpid = bwp ? bwp->bwp_Id : 0; const int coresetid = coreset->controlResourceSetId; - nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][ra->bwp_id][coresetid]; + nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu_rel15 = nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid]; if (!pdcch_pdu_rel15) { nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdcch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; memset(dl_tti_pdcch_pdu, 0, sizeof(nfapi_nr_dl_tti_request_pdu_t)); @@ -1313,7 +1347,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dl_req->nPDUs += 1; pdcch_pdu_rel15 = &dl_tti_pdcch_pdu->pdcch_pdu.pdcch_pdu_rel15; nr_configure_pdcch(pdcch_pdu_rel15, ss, coreset, scc, genericParameters, NULL); - nr_mac->pdcch_pdu_idx[CC_id][ra->bwp_id][coresetid] = pdcch_pdu_rel15; + nr_mac->pdcch_pdu_idx[CC_id][bwpid][coresetid] = pdcch_pdu_rel15; } nfapi_nr_dl_tti_request_pdu_t *dl_tti_pdsch_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; @@ -1325,18 +1359,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra LOG_I(NR_MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg4 DCI, state %d\n", module_idP, CC_id, frameP, slotP, ra->state); - int bwp_Id=0; - if (ra->CellGroup && - ra->CellGroup->spCellConfig && - ra->CellGroup->spCellConfig->spCellConfigDedicated && - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList){ - bwp_Id = *ra->CellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id; - AssertFatal(ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count <= 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - ra->CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count); - } - LOG_I(NR_MAC,"[gNB %d] [RAPROC] CC_id %d Frame %d, slotP %d: Generating RA-Msg4 DCI for BWP %d, state %d\n", module_idP, CC_id, frameP, slotP, bwp_Id,ra->state); - // SCF222: PDU index incremented for each PDSCH PDU sent in TX control message. This is used to associate control // information to data and is reset every slot. const int pduindex = nr_mac->pdu_index[CC_id]++; @@ -1361,7 +1383,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->dmrsConfigType = dmrsConfigType; pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu_rel15->SCID = 0; - pdsch_pdu_rel15->numDmrsCdmGrpsNoData = nrOfSymbols <=2 ? 1 : 2; + pdsch_pdu_rel15->numDmrsCdmGrpsNoData = nrOfSymbols <= 2 ? 1 : 2; pdsch_pdu_rel15->dmrsPorts = 1; pdsch_pdu_rel15->resourceAlloc = 1; pdsch_pdu_rel15->rbStart = rbStart; @@ -1371,7 +1393,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra pdsch_pdu_rel15->NrOfSymbols = nrOfSymbols; pdsch_pdu_rel15->dlDmrsSymbPos = dlDmrsSymbPos; - int x_Overhead = 0; nr_get_tbs_dl(&dl_tti_pdsch_pdu->pdsch_pdu, x_Overhead, pdsch_pdu_rel15->numDmrsCdmGrpsNoData, tb_scaling); @@ -1405,10 +1426,10 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_payload.rv = pdsch_pdu_rel15->rvIndex[0]; dci_payload.harq_pid = current_harq_pid; dci_payload.ndi = harq->ndi; - dci_payload.dai[0].val = (sched_ctrl->sched_pucch->dai_c-1)&3; + dci_payload.dai[0].val = (pucch->dai_c-1)&3; dci_payload.tpc = sched_ctrl->tpc1; // TPC for PUCCH: table 7.2.1-1 in 38.213 dci_payload.pucch_resource_indicator = delta_PRI; // This is delta_PRI from 9.2.1 in 38.213 - dci_payload.pdsch_to_harq_feedback_timing_indicator.val = sched_ctrl->sched_pucch->timing_indicator; + dci_payload.pdsch_to_harq_feedback_timing_indicator.val = pucch->timing_indicator; LOG_D(NR_MAC, "[RAPROC] DCI type 1 payload: freq_alloc %d (%d,%d,%d), time_alloc %d, vrb to prb %d, mcs %d tb_scaling %d pucchres %d harqtiming %d\n", @@ -1420,8 +1441,8 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra dci_payload.vrb_to_prb_mapping.val, dci_payload.mcs, dci_payload.tb_scaling, - dci_payload.pucch_resource_indicator, - dci_payload.pdsch_to_harq_feedback_timing_indicator.val); + dci_payload.pucch_resource_indicator, + dci_payload.pdsch_to_harq_feedback_timing_indicator.val); LOG_D(NR_MAC, "[RAPROC] DCI params: rnti 0x%x, rnti_type %d, dci_format %d coreset params: FreqDomainResource %llx, start_symbol %d n_symb %d\n", @@ -1439,7 +1460,7 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra NR_DL_DCI_FORMAT_1_0, NR_RNTI_TC, pdsch_pdu_rel15->BWPSize, - bwp_Id); + bwpid); // Add padding header and zero rest out if there is space left if (mac_pdu_length < harq->tb_size) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c index fd094bc8db..b74432b2ae 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_bch.c @@ -139,8 +139,7 @@ void schedule_ssb(frame_t frame, sub_frame_t slot, } -void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, uint8_t slots_per_frame, int nb_periods_per_frame){ - +void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) { gNB_MAC_INST *gNB = RC.nrmac[module_idP]; NR_COMMON_channels_t *cc; nfapi_nr_dl_tti_request_t *dl_tti_request; @@ -153,14 +152,19 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { cc = &gNB->common_channels[CC_id]; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; + const int slots_per_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; dl_tti_request = &gNB->DL_req[CC_id]; dl_req = &dl_tti_request->dl_tti_request_body; // get MIB every 8 frames - if((slotP == 0) && (frameP & 7) == 0) { + if(((slotP == 0) && (frameP & 7) == 0) || + gNB->first_MIB) { mib_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, MIBCH, 0, 1, &cc->MIB_pdu.payload[0]); + // flag to avoid sending an empty MIB in the first frames of execution since gNB doesn't get at the beginning in frame 0 slot 0 + gNB->first_MIB = false; + LOG_D(MAC, "[gNB %d] Frame %d : MIB->BCH CC_id %d, Received %d bytes\n", module_idP, @@ -254,14 +258,17 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, case 3: // long bitmap FR2 max 64 SSBs num_ssb = 0; - for (int i_ssb=0; i_ssb<63; i_ssb++) { - if ((longBitmap->buf[i_ssb/8]>>(7-i_ssb))&0x01) { + for (int i_ssb=0; i_ssb<64; i_ssb++) { + if ((longBitmap->buf[i_ssb/8]>>(7-(i_ssb%8)))&0x01) { ssb_start_symbol = get_ssb_start_symbol(band,scs,i_ssb); // if start symbol is in current slot, schedule current SSB, fill VRB map and call get_type0_PDCCH_CSS_config_parameters if ((ssb_start_symbol/14) == rel_slot){ schedule_ssb(frameP, slotP, scc, dl_req, i_ssb, ssbSubcarrierOffset, offset_pointa, (*(uint32_t*)cc->MIB_pdu.payload) & ((1<<24)-1)); fill_ssb_vrb_map(cc, offset_pointa, ssb_start_symbol, CC_id); - num_tdd_period = rel_slot/(slots_per_frame/nb_periods_per_frame); + const NR_TDD_UL_DL_Pattern_t *tdd = &scc->tdd_UL_DL_ConfigurationCommon->pattern1; + const int nr_mix_slots = tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0; + const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; + num_tdd_period = rel_slot/nr_slots_period; gNB->tdd_beam_association[num_tdd_period]=i_ssb; num_ssb++; AssertFatal(num_ssb<2,"beamforming currently not supported for more than one SSB per slot\n"); @@ -315,6 +322,7 @@ uint32_t schedule_control_sib1(module_id_t module_id, int time_domain_allocation, int startSymbolIndex, int nrOfSymbols, + uint16_t dlDmrsSymbPos, uint8_t candidate_idx, int num_total_bytes) { @@ -335,9 +343,9 @@ uint32_t schedule_control_sib1(module_id_t module_id, fill_coresetZero(gNB_mac->sched_ctrlCommon->coreset,type0_PDCCH_CSS_config); } - gNB_mac->sched_ctrlCommon->time_domain_allocation = time_domain_allocation; - gNB_mac->sched_ctrlCommon->mcsTableIdx = 0; - gNB_mac->sched_ctrlCommon->mcs = 0; // starting from mcs 0 + gNB_mac->sched_ctrlCommon->pdsch_semi_static.time_domain_allocation = time_domain_allocation; + gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx = 0; + gNB_mac->sched_ctrlCommon->sched_pdsch.mcs = 0; // starting from mcs 0 gNB_mac->sched_ctrlCommon->num_total_bytes = num_total_bytes; uint8_t nr_of_candidates; @@ -356,17 +364,17 @@ uint32_t schedule_control_sib1(module_id_t module_id, const uint16_t bwpSize = type0_PDCCH_CSS_config->num_rbs; int rbStart = type0_PDCCH_CSS_config->cset_start_rb; + // TODO: There are exceptions to this in table 5.1.2.1.1-4,5 (Default time domain allocation tables B, C) + int mappingtype = (startSymbolIndex <= 3)? typeA: typeB; + if (nrOfSymbols == 2) { - gNB_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData = 1; + gNB_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData = 1; } else { - gNB_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData = 2; + gNB_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData = 2; } // Calculate number of PRB_DMRS - uint8_t N_PRB_DMRS = gNB_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData * 6; - uint16_t dlDmrsSymbPos = fill_dmrs_mask(NULL, - gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, - nrOfSymbols, startSymbolIndex); + uint8_t N_PRB_DMRS = gNB_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData * 6; uint16_t dmrs_length = get_num_dmrs(dlDmrsSymbPos); LOG_D(MAC,"dlDmrsSymbPos %x\n",dlDmrsSymbPos); @@ -376,31 +384,33 @@ uint32_t schedule_control_sib1(module_id_t module_id, if(rbSize < bwpSize && !vrb_map[rbStart + rbSize]) rbSize++; else{ - if (gNB_mac->sched_ctrlCommon->mcs<10) - gNB_mac->sched_ctrlCommon->mcs++; + if (gNB_mac->sched_ctrlCommon->sched_pdsch.mcs<10) + gNB_mac->sched_ctrlCommon->sched_pdsch.mcs++; else break; } - TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->mcs, gNB_mac->sched_ctrlCommon->mcsTableIdx), - nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->mcs, gNB_mac->sched_ctrlCommon->mcsTableIdx), + TBS = nr_compute_tbs(nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx), + nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx), rbSize, nrOfSymbols, N_PRB_DMRS * dmrs_length,0, 0,1) >> 3; } while (TBS < gNB_mac->sched_ctrlCommon->num_total_bytes); AssertFatal(TBS>=gNB_mac->sched_ctrlCommon->num_total_bytes,"Couldn't allocate enough resources for %d bytes in SIB1 PDSCH\n", gNB_mac->sched_ctrlCommon->num_total_bytes); - gNB_mac->sched_ctrlCommon->rbSize = rbSize; - gNB_mac->sched_ctrlCommon->rbStart = 0; + gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize = rbSize; + gNB_mac->sched_ctrlCommon->sched_pdsch.rbStart = 0; - LOG_D(MAC,"mcs = %i\n", gNB_mac->sched_ctrlCommon->mcs); + LOG_D(MAC,"mcs = %i\n", gNB_mac->sched_ctrlCommon->sched_pdsch.mcs); LOG_D(MAC,"startSymbolIndex = %i\n", startSymbolIndex); LOG_D(MAC,"nrOfSymbols = %i\n", nrOfSymbols); - LOG_D(MAC,"rbSize = %i\n", gNB_mac->sched_ctrlCommon->rbSize); + LOG_D(MAC, "rbSize = %i\n", gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize); LOG_D(MAC,"TBS = %i\n", TBS); LOG_D(MAC,"dmrs_length %d\n",dmrs_length); LOG_D(MAC,"N_PRB_DMRS = %d\n",N_PRB_DMRS); + LOG_D(MAC,"mappingtype = %d\n", mappingtype); + // Mark the corresponding RBs as used - for (int rb = 0; rb < gNB_mac->sched_ctrlCommon->rbSize; rb++) { + for (int rb = 0; rb < gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize; rb++) { vrb_map[rb + rbStart] = 1; } return TBS; @@ -411,7 +421,8 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, NR_Type0_PDCCH_CSS_config_t *type0_PDCCH_CSS_config, uint32_t TBS, int StartSymbolIndex, - int NrOfSymbols) { + int NrOfSymbols, + uint16_t dlDmrsSymbPos) { gNB_MAC_INST *gNB_mac = RC.nrmac[Mod_idP]; NR_COMMON_channels_t *cc = gNB_mac->common_channels; @@ -450,9 +461,9 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->CyclicPrefix = 0; pdsch_pdu_rel15->NrOfCodewords = 1; - pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->mcs,0); + pdsch_pdu_rel15->targetCodeRate[0] = nr_get_code_rate_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, 0); pdsch_pdu_rel15->qamModOrder[0] = 2; - pdsch_pdu_rel15->mcsIndex[0] = gNB_mac->sched_ctrlCommon->mcs; + pdsch_pdu_rel15->mcsIndex[0] = gNB_mac->sched_ctrlCommon->sched_pdsch.mcs; pdsch_pdu_rel15->mcsTable[0] = 0; pdsch_pdu_rel15->rvIndex[0] = nr_rv_round_map[0]; pdsch_pdu_rel15->dataScramblingId = *scc->physCellId; @@ -462,20 +473,19 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, pdsch_pdu_rel15->dmrsConfigType = 0; pdsch_pdu_rel15->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu_rel15->SCID = 0; - pdsch_pdu_rel15->numDmrsCdmGrpsNoData = gNB_mac->sched_ctrlCommon->numDmrsCdmGrpsNoData; + pdsch_pdu_rel15->numDmrsCdmGrpsNoData = gNB_mac->sched_ctrlCommon->pdsch_semi_static.numDmrsCdmGrpsNoData; pdsch_pdu_rel15->dmrsPorts = 1; pdsch_pdu_rel15->resourceAlloc = 1; - pdsch_pdu_rel15->rbStart = gNB_mac->sched_ctrlCommon->rbStart; - pdsch_pdu_rel15->rbSize = gNB_mac->sched_ctrlCommon->rbSize; + pdsch_pdu_rel15->rbStart = gNB_mac->sched_ctrlCommon->sched_pdsch.rbStart; + pdsch_pdu_rel15->rbSize = gNB_mac->sched_ctrlCommon->sched_pdsch.rbSize; pdsch_pdu_rel15->VRBtoPRBMapping = 0; - pdsch_pdu_rel15->qamModOrder[0] = nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->mcs, gNB_mac->sched_ctrlCommon->mcsTableIdx); + pdsch_pdu_rel15->qamModOrder[0] = nr_get_Qm_dl(gNB_mac->sched_ctrlCommon->sched_pdsch.mcs, + gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx); pdsch_pdu_rel15->TBSize[0] = TBS; - pdsch_pdu_rel15->mcsTable[0] = gNB_mac->sched_ctrlCommon->mcsTableIdx; + pdsch_pdu_rel15->mcsTable[0] = gNB_mac->sched_ctrlCommon->pdsch_semi_static.mcsTableIdx; pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; - - pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL, scc->dmrs_TypeA_Position, pdsch_pdu_rel15->NrOfSymbols, pdsch_pdu_rel15->StartSymbolIndex); - + pdsch_pdu_rel15->dlDmrsSymbPos = dlDmrsSymbPos; LOG_D(MAC,"dlDmrsSymbPos = 0x%x\n", pdsch_pdu_rel15->dlDmrsSymbPos); /* Fill PDCCH DL DCI PDU */ @@ -499,8 +509,8 @@ void nr_fill_nfapi_dl_sib1_pdu(int Mod_idP, dci_payload.frequency_domain_assignment.val = PRBalloc_to_locationandbandwidth0( pdsch_pdu_rel15->rbSize, pdsch_pdu_rel15->rbStart, type0_PDCCH_CSS_config->num_rbs); - dci_payload.time_domain_assignment.val = gNB_mac->sched_ctrlCommon->time_domain_allocation; - dci_payload.mcs = gNB_mac->sched_ctrlCommon->mcs; + dci_payload.time_domain_assignment.val = gNB_mac->sched_ctrlCommon->pdsch_semi_static.time_domain_allocation; + dci_payload.mcs = gNB_mac->sched_ctrlCommon->sched_pdsch.mcs; dci_payload.rv = pdsch_pdu_rel15->rvIndex[0]; dci_payload.harq_pid = 0; dci_payload.ndi = 0; @@ -583,7 +593,8 @@ void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t slotP) uint8_t sib1_sdu_length = mac_rrc_nr_data_req(module_idP, CC_id, frameP, BCCH, SI_RNTI, 1, sib1_payload); LOG_D(NR_MAC,"sib1_sdu_length = %i\n", sib1_sdu_length); LOG_D(NR_MAC,"SIB1: \n"); - for (int k=0;kcommon_channels->ServingCellConfigCommon->dmrs_TypeA_Position, 1, &startSymbolIndex, &nrOfSymbols); + // TODO: There are exceptions to this in table 5.1.2.1.1-4,5 (Default time domain allocation tables B, C) + int mappingtype = (startSymbolIndex <= 3)? typeA: typeB; + + uint16_t dlDmrsSymbPos = fill_dmrs_mask(NULL, gNB_mac->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position, nrOfSymbols, startSymbolIndex, mappingtype); + // Configure sched_ctrlCommon for SIB1 uint32_t TBS = schedule_control_sib1(module_idP, CC_id, type0_PDCCH_CSS_config, time_domain_allocation, startSymbolIndex, nrOfSymbols, + dlDmrsSymbPos, candidate_idx, sib1_sdu_length); nfapi_nr_dl_tti_request_body_t *dl_req = &gNB_mac->DL_req[CC_id].dl_tti_request_body; - nr_fill_nfapi_dl_sib1_pdu(module_idP, dl_req, type0_PDCCH_CSS_config, TBS, startSymbolIndex, nrOfSymbols); - + nr_fill_nfapi_dl_sib1_pdu(module_idP, dl_req, type0_PDCCH_CSS_config, TBS, startSymbolIndex, nrOfSymbols, dlDmrsSymbPos); + const int ntx_req = gNB_mac->TX_req[CC_id].Number_of_PDUs; nfapi_nr_pdu_t *tx_req = &gNB_mac->TX_req[CC_id].pdu_list[ntx_req]; - + // Data to be transmitted bzero(tx_req->TLVs[0].value.direct,MAX_NR_DLSCH_PAYLOAD_BYTES); memcpy(tx_req->TLVs[0].value.direct, sib1_payload, sib1_sdu_length); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index 882a80396f..fd8da150e1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -56,6 +56,84 @@ #define WORD 32 //#define SIZE_OF_POINTER sizeof (void *) static int loop_dcch_dtch = DL_SCH_LCID_DTCH; + +void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp) +{ + gNB_MAC_INST *nrmac = RC.nrmac[module_id]; + const int bwp_id = bwp ? bwp->bwp_Id : 0; + if (nrmac->preferred_dl_tda[bwp_id]) + return; + + /* there is a mixed slot only when in TDD */ + NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; + const NR_TDD_UL_DL_Pattern_t *tdd = + scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + const int symb_dlMixed = tdd ? (1 << tdd->nrofDownlinkSymbols) - 1 : 0; + + const int target_ss = bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; + NR_SearchSpace_t *search_space = get_searchspace(scc, bwp ? bwp->bwp_Dedicated : NULL, target_ss); + const NR_ControlResourceSet_t *coreset = get_coreset(scc, (NR_BWP_Downlink_t*)bwp, search_space, target_ss); + + // get coreset symbol "map" + const uint16_t symb_coreset = (1 << coreset->duration) - 1; + + /* check that TDA index 0 fits into DL and does not overlap CORESET */ + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + AssertFatal(tdaList->list.count >= 1, "need to have at least one TDA for DL slots\n"); + const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_DL = tdaList->list.array[0]; + AssertFatal(!tdaP_DL->k0 || *tdaP_DL->k0 == 0, + "TimeDomainAllocation at index 1: non-null k0 (%ld) is not supported by the scheduler\n", + *tdaP_DL->k0); + int start, len; + SLIV2SL(tdaP_DL->startSymbolAndLength, &start, &len); + const uint16_t symb_tda = ((1 << len) - 1) << start; + // check whether coreset and TDA overlap: then we cannot use it. Note that + // here we assume that the coreset is scheduled every slot (which it + // currently is) and starting at symbol 0 + AssertFatal((symb_coreset & symb_tda) == 0, "TDA index 0 for DL overlaps with CORESET\n"); + + /* check that TDA index 1 fits into DL part of mixed slot, if it exists */ + int tdaMi = -1; + if (tdaList->list.count > 1) { + const NR_PDSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; + AssertFatal(!tdaP_Mi->k0 || *tdaP_Mi->k0 == 0, + "TimeDomainAllocation at index 1: non-null k0 (%ld) is not supported by the scheduler\n", + *tdaP_Mi->k0); + int start, len; + SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); + const uint16_t symb_tda = ((1 << len) - 1) << start; + // check whether coreset and TDA overlap: then, we cannot use it. Also, + // check whether TDA is entirely within mixed slot DL. Note that + // here we assume that the coreset is scheduled every slot (which it + // currently is) + if ((symb_coreset & symb_tda) == 0 && (symb_dlMixed & symb_tda) == symb_tda) { + tdaMi = 1; + } else { + LOG_E(MAC, + "TDA index 1 DL overlaps with CORESET or is not entirely in mixed slot (symb_coreset %x symb_dlMixed %x symb_tda %x), won't schedule DL mixed slot\n", + symb_coreset, + symb_dlMixed, + symb_tda); + } + } + + const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160}; + const int n = slots_per_frame[*scc->ssbSubcarrierSpacing]; + nrmac->preferred_dl_tda[bwp_id] = malloc(n * sizeof(*nrmac->preferred_dl_tda[bwp_id])); + + const int nr_mix_slots = tdd ? tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0 : 0; + const int nr_slots_period = tdd ? tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots : n; + for (int i = 0; i < n; ++i) { + nrmac->preferred_dl_tda[bwp_id][i] = -1; + if (!tdd || i % nr_slots_period < tdd->nrofDownlinkSlots) + nrmac->preferred_dl_tda[bwp_id][i] = 0; + else if (tdd && nr_mix_slots && i % nr_slots_period == tdd->nrofDownlinkSlots) + nrmac->preferred_dl_tda[bwp_id][i] = tdaMi; + LOG_I(MAC, "slot %d preferred_dl_tda %d\n", i, nrmac->preferred_dl_tda[bwp_id][i]); + } +} + // Compute and write all MAC CEs and subheaders, and return number of written // bytes int nr_write_ce_dlsch_pdu(module_id_t module_idP, @@ -302,37 +380,6 @@ int nr_write_ce_dlsch_pdu(module_id_t module_idP, return offset; } -void getStartNrOfSymbols(NR_BWP_Downlink_t *bwp, NR_ServingCellConfigCommon_t *scc,int tda, int *startSymbol, int *nrOfSymbols) { - struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = - bwp? - bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList: - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - AssertFatal(tda < tdaList->list.count, - "time_domain_allocation %d>=%d\n", - tda, - tdaList->list.count); - - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; - SLIV2SL(startSymbolAndLength, startSymbol, nrOfSymbols); -} - -nfapi_nr_dmrs_type_e getDmrsConfigType(NR_BWP_Downlink_t *bwp) { - return bwp? - bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1: - 0; -} - -uint8_t getN_PRB_DMRS(NR_BWP_Downlink_t *bwp, int numDmrsCdmGrpsNoData) { - const nfapi_nr_dmrs_type_e dmrsConfigType = getDmrsConfigType(bwp); - if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) { - // if no data in dmrs cdm group is 1 only even REs have no data - // if no data in dmrs cdm group is 2 both odd and even REs have no data - return numDmrsCdmGrpsNoData * 6; - } else { - return numDmrsCdmGrpsNoData * 4; - } -} - void nr_store_dlsch_buffer(module_id_t module_id, frame_t frame, sub_frame_t slot) { @@ -343,7 +390,7 @@ void nr_store_dlsch_buffer(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; sched_ctrl->num_total_bytes = 0; - if ((sched_ctrl->lcid_mask&(1<<4)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH1) + if ((sched_ctrl->lcid_mask&(1<<4)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DCCH1) loop_dcch_dtch = DL_SCH_LCID_DTCH; else if ((sched_ctrl->lcid_mask&(1<<1)) > 0 && loop_dcch_dtch == DL_SCH_LCID_DTCH) loop_dcch_dtch = DL_SCH_LCID_DCCH; @@ -369,7 +416,8 @@ void nr_store_dlsch_buffer(module_id_t module_id, frame, slot, lcid, - sched_ctrl->num_total_bytes); + sched_ctrl->num_total_bytes); + if (sched_ctrl->num_total_bytes == 0 && !sched_ctrl->ta_apply) /* If TA should be applied, give at least one RB */ return; @@ -386,64 +434,132 @@ void nr_store_dlsch_buffer(module_id_t module_id, } } -bool allocate_retransmission(module_id_t module_id, - uint8_t *rballoc_mask, - int *n_rb_sched, - int UE_id, - int current_harq_pid){ - NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id]; - NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid]; - NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? - &sched_ctrl->active_bwp->bwp_Common->genericParameters : - &RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; +bool allocate_dl_retransmission(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + uint8_t *rballoc_mask, + int *n_rb_sched, + int UE_id, + int current_harq_pid) { + + const NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels->ServingCellConfigCommon; + NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_sched_pdsch_t *retInfo = &sched_ctrl->harq_processes[current_harq_pid].sched_pdsch; + NR_BWP_t *genericParameters = sched_ctrl->active_bwp ? + &sched_ctrl->active_bwp->bwp_Common->genericParameters : + &RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters; const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); int rbStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); - sched_ctrl->time_domain_allocation = retInfo->time_domain_allocation; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_bwp ? (f ? 1 : (ps->nrOfSymbols == 2 ? 1 : 2)) : (ps->nrOfSymbols == 2 ? 1 : 2); - /* ensure that there is a free place for RB allocation */ int rbSize = 0; - while (rbSize < retInfo->rbSize) { - rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ - rbSize = 0; - while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; - if (rbStart >= bwpSize) { - LOG_D(NR_MAC, - "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n", - UE_id, - RC.nrmac[module_id]->UE_info.rnti[UE_id]); - return false; + const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + if (tda == retInfo->time_domain_allocation) { + /* Check that there are enough resources for retransmission */ + while (rbSize < retInfo->rbSize) { + rbStart += rbSize; /* last iteration rbSize was not enough, skip it */ + rbSize = 0; + while (rbStart < bwpSize && !rballoc_mask[rbStart]) + rbStart++; + if (rbStart >= bwpSize) { + LOG_D(NR_MAC, "cannot allocate retransmission for UE %d/RNTI %04x: no resources\n", UE_id, UE_info->rnti[UE_id]); + return false; + } + while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize] && rbSize < retInfo->rbSize) + rbSize++; } - while (rbStart + rbSize < bwpSize - && rballoc_mask[rbStart + rbSize] - && rbSize < retInfo->rbSize) + /* check whether we need to switch the TDA allocation since the last + * (re-)transmission */ + if (ps->time_domain_allocation != tda || ps->numDmrsCdmGrpsNoData != num_dmrs_cdm_grps_no_data) + nr_set_pdsch_semi_static( + scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, num_dmrs_cdm_grps_no_data, ps); + } else { + /* the retransmission will use a different time domain allocation, check + * that we have enough resources */ + while (rbStart < bwpSize && !rballoc_mask[rbStart]) + rbStart++; + while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize]) rbSize++; + NR_pdsch_semi_static_t temp_ps; + nr_set_pdsch_semi_static( + scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, num_dmrs_cdm_grps_no_data, &temp_ps); + uint32_t new_tbs; + uint16_t new_rbSize; + bool success = nr_find_nb_rb(retInfo->Qm, + retInfo->R, + temp_ps.nrOfSymbols, + temp_ps.N_PRB_DMRS * temp_ps.N_DMRS_SLOT, + retInfo->tb_size, + rbSize, + &new_tbs, + &new_rbSize); + if (!success || new_tbs != retInfo->tb_size) { + LOG_D(MAC, "%s(): new TBsize %d of new TDA does not match old TBS %d\n", __func__, new_tbs, retInfo->tb_size); + return false; /* the maximum TBsize we might have is smaller than what we need */ + } + /* we can allocate it. Overwrite the time_domain_allocation, the number + * of RBs, and the new TB size. The rest is done below */ + retInfo->tb_size = new_tbs; + retInfo->rbSize = new_rbSize; + retInfo->time_domain_allocation = tda; + sched_ctrl->pdsch_semi_static = temp_ps; } - sched_ctrl->rbSize = retInfo->rbSize; - sched_ctrl->rbStart = rbStart; - /* MCS etc: just reuse from previous scheduling opportunity */ - sched_ctrl->mcsTableIdx = retInfo->mcsTableIdx; - sched_ctrl->mcs = retInfo->mcs; - sched_ctrl->numDmrsCdmGrpsNoData = retInfo->numDmrsCdmGrpsNoData; + /* Find a free CCE */ + bool freeCCE = find_free_CCE(module_id, slot, UE_id); + if (!freeCCE) { + LOG_D(MAC, "%4d.%2d could not find CCE for DL DCI retransmission UE %d/RNTI %04x\n", + frame, slot, UE_id, UE_info->rnti[UE_id]); + return false; + } + + /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH + * allocation after CCE alloc fail would be more complex) */ + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1); + if (alloc<0) { + LOG_D(MAC, + "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", + __func__, + UE_id, + UE_info->rnti[UE_id], + frame, + slot); + int cid = sched_ctrl->coreset->controlResourceSetId; + UE_info->num_pdcch_cand[UE_id][cid]--; + int *cce_list = RC.nrmac[module_id]->cce_list[sched_ctrl->active_bwp->bwp_Id][cid]; + for (int i = 0; i < sched_ctrl->aggregation_level; i++) + cce_list[sched_ctrl->cce_index + i] = 0; + return false; + } + + sched_ctrl->sched_pdsch.pucch_allocation = alloc; + + /* just reuse from previous scheduling opportunity, set new start RB */ + sched_ctrl->sched_pdsch = *retInfo; + sched_ctrl->sched_pdsch.rbStart = rbStart; /* retransmissions: directly allocate */ - *n_rb_sched -= sched_ctrl->rbSize; - for (int rb = 0; rb < sched_ctrl->rbSize; rb++) - rballoc_mask[rb+sched_ctrl->rbStart] = 0; + *n_rb_sched -= sched_ctrl->sched_pdsch.rbSize; + for (int rb = 0; rb < sched_ctrl->sched_pdsch.rbSize; rb++) + rballoc_mask[rb + sched_ctrl->sched_pdsch.rbStart] = 0; return true; } float thr_ue[MAX_MOBILES_PER_GNB]; +uint32_t pf_tbs[3][29]; // pre-computed, approximate TBS values for PF coefficient void pf_dl(module_id_t module_id, frame_t frame, sub_frame_t slot, NR_list_t *UE_list, + int max_num_ue, int n_rb_sched, - uint8_t *rballoc_mask, - int max_num_ue) { + uint8_t *rballoc_mask) { gNB_MAC_INST *mac = RC.nrmac[module_id]; NR_UE_info_t *UE_info = &mac->UE_info; @@ -457,24 +573,11 @@ void pf_dl(module_id_t module_id, for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { if (UE_info->Msg4_ACKed[UE_id] != true) continue; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - int bwp_Id = sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Id : 0; - NR_BWP_DownlinkDedicated_t *bwp_Dedicated=NULL; - if (sched_ctrl->active_bwp) bwp_Dedicated = sched_ctrl->active_bwp->bwp_Dedicated; - else if (UE_info->CellGroup[UE_id] && - UE_info->CellGroup[UE_id]->spCellConfig && - UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated) - bwp_Dedicated = UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - - sched_ctrl->search_space = get_searchspace(scc,bwp_Dedicated, - bwp_Dedicated ? - NR_SearchSpace__searchSpaceType_PR_ue_Specific: - NR_SearchSpace__searchSpaceType_PR_common); - - sched_ctrl->coreset = get_coreset(scc,sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); - if (sched_ctrl->coreset == NULL) sched_ctrl->coreset = mac->sched_ctrlCommon->coreset; + if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; + NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; /* get the PID of a HARQ process awaiting retrnasmission, or -1 otherwise */ - sched_ctrl->dl_harq_pid = sched_ctrl->retrans_dl_harq.head; - const rnti_t rnti = UE_info->rnti[UE_id]; + sched_pdsch->dl_harq_pid = sched_ctrl->retrans_dl_harq.head; /* Calculate Throughput */ const float a = 0.0005f; // corresponds to 200ms window @@ -482,33 +585,10 @@ void pf_dl(module_id_t module_id, thr_ue[UE_id] = (1 - a) * thr_ue[UE_id] + a * b; /* retransmission */ - if (sched_ctrl->dl_harq_pid >= 0) { - /* Find a free CCE */ - bool freeCCE = find_free_CCE(module_id, slot, UE_id); - if (!freeCCE){ - LOG_D(NR_MAC, "%4d.%2d could not find CCE for DL DCI retransmission UE %d/RNTI %04x\n", frame, slot, UE_id, rnti); - continue; - } - /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH - * allocation after CCE alloc fail would be more complex) */ - const bool alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot,-1); - if (!alloc) { - LOG_W(NR_MAC, - "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", - __func__, - UE_id, - rnti, - frame, - slot); - int cid = sched_ctrl->coreset->controlResourceSetId; - UE_info->num_pdcch_cand[UE_id][cid]--; - int *cce_list = mac->cce_list[bwp_Id][cid]; - for (int i = 0; i < sched_ctrl->aggregation_level; i++) - cce_list[sched_ctrl->cce_index + i] = 0; - return; - } + if (sched_pdsch->dl_harq_pid >= 0) { /* Allocate retransmission */ - bool r = allocate_retransmission(module_id, rballoc_mask, &n_rb_sched, UE_id, sched_ctrl->dl_harq_pid); + bool r = allocate_dl_retransmission( + module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pdsch->dl_harq_pid); if (!r) { LOG_D(NR_MAC, "%4d.%2d retransmission can NOT be allocated\n", frame, slot); continue; @@ -522,27 +602,8 @@ void pf_dl(module_id_t module_id, continue; /* Calculate coeff */ - sched_ctrl->time_domain_allocation = 2; - sched_ctrl->mcsTableIdx = 0; - sched_ctrl->mcs = 9; - sched_ctrl->numDmrsCdmGrpsNoData = sched_ctrl->active_bwp ? 2 : 1; - uint8_t N_PRB_DMRS = - getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); - int startSymbol; - int nrOfSymbols; - getStartNrOfSymbols(sched_ctrl->active_bwp,scc, - sched_ctrl->time_domain_allocation, - &startSymbol, - &nrOfSymbols); - uint32_t tbs = nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - 1, // rbSize - nrOfSymbols, - N_PRB_DMRS, // FIXME // This should be multiplied by the - // number of dmrs symbols - 0 /* N_PRB_oh, 0 for initialBWP */, 0 /* tb_scaling */, - 1 /* nrOfLayers */) - >> 3; + sched_pdsch->mcs = 9; + uint32_t tbs = pf_tbs[ps->mcsTableIdx][sched_pdsch->mcs]; coeff_ue[UE_id] = (float) tbs / thr_ue[UE_id]; LOG_D(NR_MAC,"b %d, thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", b, UE_id, thr_ue[UE_id], tbs, UE_id, coeff_ue[UE_id]); @@ -593,9 +654,9 @@ void pf_dl(module_id_t module_id, /* Find PUCCH occasion: if it fails, undo CCE allocation (undoing PUCCH * allocation after CCE alloc fail would be more complex) */ - const bool alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot,-1); - if (!alloc) { - LOG_W(NR_MAC, + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1); + if (alloc<0) { + LOG_D(NR_MAC, "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", __func__, UE_id, @@ -610,62 +671,49 @@ void pf_dl(module_id_t module_id, return; } - /* Allocate transmission */ - // Time-domain allocation - sched_ctrl->time_domain_allocation = 2; - - // modulation scheme - sched_ctrl->mcsTableIdx = 0; - sched_ctrl->mcs = 9; - sched_ctrl->numDmrsCdmGrpsNoData = sched_ctrl->active_bwp ? 1 : 2; - // Freq-demain allocation while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; - const uint8_t N_PRB_DMRS = - getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); - int startSymbol; - int nrOfSymbols; - getStartNrOfSymbols(sched_ctrl->active_bwp,scc, - sched_ctrl->time_domain_allocation, - &startSymbol, - &nrOfSymbols); - const NR_ServingCellConfigCommon_t *scc = mac->common_channels->ServingCellConfigCommon; - const uint8_t N_DMRS_SLOT = get_num_dmrs_symbols( - sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup : NULL, - scc->dmrs_TypeA_Position, - nrOfSymbols, - startSymbol); + uint16_t max_rbSize = 1; + while (rbStart + max_rbSize < bwpSize && rballoc_mask[rbStart + max_rbSize]) + max_rbSize++; - int rbSize = 0; + /* MCS has been set above */ + const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_bwp ? (f ? 1 : (ps->nrOfSymbols == 2 ? 1 : 2)) : (ps->nrOfSymbols == 2 ? 1 : 2); + if (ps->time_domain_allocation != tda || ps->numDmrsCdmGrpsNoData != num_dmrs_cdm_grps_no_data) + nr_set_pdsch_semi_static( + scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, num_dmrs_cdm_grps_no_data, ps); + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->pucch_allocation = alloc; uint32_t TBS = 0; - const int oh = 2 + (sched_ctrl->num_total_bytes >= 256) - + 2 * (frame == (sched_ctrl->ta_frame + 10) % 1024); - do { - rbSize++; - TBS = nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - rbSize, - nrOfSymbols, - N_PRB_DMRS * N_DMRS_SLOT, - 0 /* N_PRB_oh, 0 for initialBWP */, - 0 /* tb_scaling */, - 1 /* nrOfLayers */) - >> 3; - } while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize] && TBS < sched_ctrl->num_total_bytes + oh); - sched_ctrl->rbSize = rbSize; - sched_ctrl->rbStart = rbStart; + uint16_t rbSize; + const int oh = 3 + 2 * (frame == (sched_ctrl->ta_frame + 10) % 1024); + nr_find_nb_rb(sched_pdsch->Qm, + sched_pdsch->R, + ps->nrOfSymbols, + ps->N_PRB_DMRS * ps->N_DMRS_SLOT, + sched_ctrl->num_total_bytes + oh, + max_rbSize, + &TBS, + &rbSize); + sched_pdsch->rbSize = rbSize; + sched_pdsch->rbStart = rbStart; + sched_pdsch->tb_size = TBS; /* transmissions: directly allocate */ - n_rb_sched -= sched_ctrl->rbSize; - for (int rb = 0; rb < sched_ctrl->rbSize; rb++) - rballoc_mask[rb+sched_ctrl->rbStart] = 0; + n_rb_sched -= sched_pdsch->rbSize; + for (int rb = 0; rb < sched_pdsch->rbSize; rb++) + rballoc_mask[rb + sched_pdsch->rbStart] = 0; } } -void nr_simple_dlsch_preprocessor(module_id_t module_id, - frame_t frame, - sub_frame_t slot) { +void nr_fr1_dlsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) +{ NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; @@ -678,9 +726,10 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, /* Get bwpSize from the first UE */ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, + scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); uint16_t *vrb_map = RC.nrmac[module_id]->common_channels[CC_id].vrb_map; @@ -701,15 +750,45 @@ void nr_simple_dlsch_preprocessor(module_id_t module_id, frame, slot, &UE_info->list, + 2, n_rb_sched, - rballoc_mask, - 2); + rballoc_mask); +} + +nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id) +{ + /* in the PF algorithm, we have to use the TBsize to compute the coefficient. + * This would include the number of DMRS symbols, which in turn depends on + * the time domain allocation. In case we are in a mixed slot, we do not want + * to recalculate all these values just, and therefore we provide a look-up + * table which should approximately give us the TBsize */ + for (int mcsTableIdx = 0; mcsTableIdx < 3; ++mcsTableIdx) { + for (int mcs = 0; mcs < 29; ++mcs) { + if (mcs > 27 && mcsTableIdx == 1) + continue; + const uint8_t Qm = nr_get_Qm_dl(mcs, mcsTableIdx); + const uint16_t R = nr_get_code_rate_dl(mcs, mcsTableIdx); + pf_tbs[mcsTableIdx][mcs] = nr_compute_tbs(Qm, + R, + 1, /* rbSize */ + 10, /* hypothetical number of slots */ + 0, /* N_PRB_DMRS * N_DMRS_SLOT */ + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; + } + } + + return nr_fr1_dlsch_preprocessor; } void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot) { gNB_MAC_INST *gNB_mac = RC.nrmac[module_id]; + if (!is_xlsch_in_slot(gNB_mac->dlsch_slot_bitmap[slot / 64], slot)) + return; /* PREPROCESSOR */ gNB_mac->pre_processor_dl(module_id, frame, slot); @@ -723,7 +802,8 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_list_t *UE_list = &UE_info->list; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->ul_failure==1) continue; + if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; + NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; UE_info->mac_stats[UE_id].dlsch_current_bytes = 0; /* update TA and set ta_apply every 10 frames. @@ -735,48 +815,23 @@ void nr_schedule_ue_spec(module_id_t module_id, LOG_D(NR_MAC, "[UE %d][%d.%d] UL timing alignment procedures: setting flag for Timing Advance command\n", UE_id, frame, slot); } - if (sched_ctrl->rbSize <= 0) + if (sched_pdsch->rbSize <= 0) continue; const rnti_t rnti = UE_info->rnti[UE_id]; /* POST processing */ - struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = - sched_ctrl->active_bwp ? - sched_ctrl->active_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList: - scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; - AssertFatal(sched_ctrl->time_domain_allocation < tdaList->list.count, - "time_domain_allocation %d>=%d\n", - sched_ctrl->time_domain_allocation, - tdaList->list.count); - - const int startSymbolAndLength = - tdaList->list.array[sched_ctrl->time_domain_allocation]->startSymbolAndLength; - int startSymbolIndex, nrOfSymbols; - SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - - uint8_t N_PRB_DMRS = - getN_PRB_DMRS(sched_ctrl->active_bwp, sched_ctrl->numDmrsCdmGrpsNoData); - uint8_t N_DMRS_SLOT = get_num_dmrs_symbols(sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated->pdsch_Config->choice.setup:NULL, - RC.nrmac[module_id]->common_channels->ServingCellConfigCommon->dmrs_TypeA_Position , - nrOfSymbols, - startSymbolIndex); - const nfapi_nr_dmrs_type_e dmrsConfigType = getDmrsConfigType(sched_ctrl->active_bwp); const int nrOfLayers = 1; - const uint16_t R = nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx); - const uint8_t Qm = nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx); - const uint32_t TBS = - nr_compute_tbs(nr_get_Qm_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - nr_get_code_rate_dl(sched_ctrl->mcs, sched_ctrl->mcsTableIdx), - sched_ctrl->rbSize, - nrOfSymbols, - N_PRB_DMRS * N_DMRS_SLOT, - 0 /* N_PRB_oh, 0 for initialBWP */, - 0 /* tb_scaling */, - nrOfLayers) - >> 3; + const uint16_t R = sched_pdsch->R; + const uint8_t Qm = sched_pdsch->Qm; + const uint32_t TBS = sched_pdsch->tb_size; - int8_t current_harq_pid = sched_ctrl->dl_harq_pid; + /* pre-computed PDSCH values that only change if time domain + * allocation/DMRS parameters change. Updated in the preprocessor through + * nr_set_pdsch_semi_static() */ + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; + + int8_t current_harq_pid = sched_pdsch->dl_harq_pid; if (current_harq_pid < 0) { /* PP has not selected a specific HARQ Process, get a new one */ current_harq_pid = sched_ctrl->available_dl_harq.head; @@ -784,7 +839,7 @@ void nr_schedule_ue_spec(module_id_t module_id, "no free HARQ process available for UE %d\n", UE_id); remove_front_nr_list(&sched_ctrl->available_dl_harq); - sched_ctrl->dl_harq_pid = current_harq_pid; + sched_pdsch->dl_harq_pid = current_harq_pid; } else { /* PP selected a specific HARQ process. Check whether it will be a new * transmission or a retransmission, and remove from the corresponding @@ -797,41 +852,26 @@ void nr_schedule_ue_spec(module_id_t module_id, NR_UE_harq_t *harq = &sched_ctrl->harq_processes[current_harq_pid]; DevAssert(!harq->is_waiting); add_tail_nr_list(&sched_ctrl->feedback_dl_harq, current_harq_pid); - NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; + NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[sched_pdsch->pucch_allocation]; + harq->feedback_frame = pucch->frame; harq->feedback_slot = pucch->ul_slot; harq->is_waiting = true; UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++; LOG_D(NR_MAC, - "%4d.%2d RNTI %04x start %d RBs %d startSymbol %d nb_symbsol %d MCS %d TBS %d HARQ PID %d round %d NDI %d\n", + "%4d.%2d RNTI %04x start %3d RBs %3d startSymbol %2d nb_symbol %2d MCS %2d TBS %4d HARQ PID %2d round %d NDI %d\n", frame, slot, rnti, - sched_ctrl->rbStart, - sched_ctrl->rbSize, - startSymbolIndex, - nrOfSymbols, - sched_ctrl->mcs, + sched_pdsch->rbStart, + sched_pdsch->rbSize, + ps->startSymbolIndex, + ps->nrOfSymbols, + sched_pdsch->mcs, TBS, current_harq_pid, harq->round, harq->ndi); - if ((get_softmodem_params()->phy_test == 1) && (frame&127) == 0) - LOG_D(MAC, - "%4d.%2d RNTI %04x start %d RBs %d startSymbol %d nb_symbsol %d MCS %d TBS %d (%f Mbps) HARQ PID %d round %d NDI %d\n", - frame, - slot, - rnti, - sched_ctrl->rbStart, - sched_ctrl->rbSize, - startSymbolIndex, - nrOfSymbols, - sched_ctrl->mcs, - TBS, - ((double)TBS)*(1<uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing)/1000, - current_harq_pid, - harq->round, - harq->ndi); NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp; @@ -876,18 +916,18 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->BWPSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pdsch_pdu->BWPStart = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); pdsch_pdu->SubcarrierSpacing = genericParameters->subcarrierSpacing; - + pdsch_pdu->CyclicPrefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0; // Codeword information pdsch_pdu->NrOfCodewords = 1; pdsch_pdu->targetCodeRate[0] = R; pdsch_pdu->qamModOrder[0] = Qm; - pdsch_pdu->mcsIndex[0] = sched_ctrl->mcs; - pdsch_pdu->mcsTable[0] = sched_ctrl->mcsTableIdx; + pdsch_pdu->mcsIndex[0] = sched_pdsch->mcs; + pdsch_pdu->mcsTable[0] = ps->mcsTableIdx; AssertFatal(harq!=NULL,"harq is null\n"); - AssertFatal(harq->round < 16,"harq->round %d > 15\n",harq->round); - pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round&3]; + AssertFatal(harq->round<4,"%d",harq->round); + pdsch_pdu->rvIndex[0] = nr_rv_round_map[harq->round]; pdsch_pdu->TBSize[0] = TBS; pdsch_pdu->dataScramblingId = *scc->physCellId; @@ -896,32 +936,29 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->refPoint = 0; // Point A // DMRS - NR_PDSCH_Config_t *pdsch_Config=NULL; - if (bwp && - bwp->bwp_Dedicated && - bwp->bwp_Dedicated->pdsch_Config && - bwp->bwp_Dedicated->pdsch_Config->choice.setup) - pdsch_Config = bwp->bwp_Dedicated->pdsch_Config->choice.setup; - - pdsch_pdu->dlDmrsSymbPos = fill_dmrs_mask(pdsch_Config, - scc->dmrs_TypeA_Position, - nrOfSymbols, - startSymbolIndex); - pdsch_pdu->dmrsConfigType = dmrsConfigType; + pdsch_pdu->dlDmrsSymbPos = ps->dl_dmrs_symb_pos; + pdsch_pdu->dmrsConfigType = ps->dmrsConfigType; pdsch_pdu->dlDmrsScramblingId = *scc->physCellId; pdsch_pdu->SCID = 0; - pdsch_pdu->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; + pdsch_pdu->numDmrsCdmGrpsNoData = ps->numDmrsCdmGrpsNoData; pdsch_pdu->dmrsPorts = 1; // Pdsch Allocation in frequency domain pdsch_pdu->resourceAlloc = 1; - pdsch_pdu->rbStart = sched_ctrl->rbStart; - pdsch_pdu->rbSize = sched_ctrl->rbSize; + pdsch_pdu->rbStart = sched_pdsch->rbStart; + pdsch_pdu->rbSize = sched_pdsch->rbSize; pdsch_pdu->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP // Resource Allocation in time domain - pdsch_pdu->StartSymbolIndex = startSymbolIndex; - pdsch_pdu->NrOfSymbols = nrOfSymbols; + pdsch_pdu->StartSymbolIndex = ps->startSymbolIndex; + pdsch_pdu->NrOfSymbols = ps->nrOfSymbols; + + NR_PDSCH_Config_t *pdsch_Config=NULL; + if (bwp && + bwp->bwp_Dedicated && + bwp->bwp_Dedicated->pdsch_Config && + bwp->bwp_Dedicated->pdsch_Config->choice.setup) + pdsch_Config = bwp->bwp_Dedicated->pdsch_Config->choice.setup; /* Check and validate PTRS values */ struct NR_SetupRelease_PTRS_DownlinkConfig *phaseTrackingRS = @@ -945,9 +982,9 @@ void nr_schedule_ue_spec(module_id_t module_id, nfapi_nr_dl_dci_pdu_t *dci_pdu = &pdcch_pdu->dci_pdu[pdcch_pdu->numDlDci]; pdcch_pdu->numDlDci++; dci_pdu->RNTI = rnti; - if (sched_ctrl->coreset && - sched_ctrl->search_space && - sched_ctrl->coreset->pdcch_DMRS_ScramblingID && + if (sched_ctrl->coreset && + sched_ctrl->search_space && + sched_ctrl->coreset->pdcch_DMRS_ScramblingID && sched_ctrl->search_space->searchSpaceType->present == NR_SearchSpace__searchSpaceType_PR_ue_Specific) { dci_pdu->ScramblingId = *sched_ctrl->coreset->pdcch_DMRS_ScramblingID; dci_pdu->ScramblingRNTI = rnti; @@ -965,9 +1002,8 @@ void nr_schedule_ue_spec(module_id_t module_id, memset(&dci_payload, 0, sizeof(dci_pdu_rel15_t)); // bwp indicator const int n_dl_bwp = bwp ? UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.count : 0; - AssertFatal(n_dl_bwp <= 1, - "downlinkBWP_ToAddModList has %d BWP!\n", - n_dl_bwp); + AssertFatal(n_dl_bwp <= 1, "downlinkBWP_ToAddModList has %d BWP!\n", n_dl_bwp); + // as per table 7.3.1.1.2-1 in 38.212 dci_payload.bwp_indicator.val = bwp ? (n_dl_bwp < 4 ? bwp->bwp_Id : bwp->bwp_Id - 1) : 0; if (bwp) AssertFatal(bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation == NR_PDSCH_Config__resourceAllocation_resourceAllocationType1, @@ -978,8 +1014,8 @@ void nr_schedule_ue_spec(module_id_t module_id, pdsch_pdu->rbStart, pdsch_pdu->BWPSize); dci_payload.format_indicator = 1; - dci_payload.time_domain_assignment.val = sched_ctrl->time_domain_allocation; - dci_payload.mcs = sched_ctrl->mcs; + dci_payload.time_domain_assignment.val = ps->time_domain_allocation; + dci_payload.mcs = sched_pdsch->mcs; dci_payload.rv = pdsch_pdu->rvIndex[0]; dci_payload.harq_pid = current_harq_pid; dci_payload.ndi = harq->ndi; @@ -1025,29 +1061,7 @@ void nr_schedule_ue_spec(module_id_t module_id, pdcch_pdu->StartSymbolIndex, pdcch_pdu->DurationSymbols); - NR_UE_ret_info_t *retInfo = &sched_ctrl->retInfo[current_harq_pid]; if (harq->round != 0) { /* retransmission */ - if (sched_ctrl->rbSize != retInfo->rbSize) - LOG_W(NR_MAC, - "retransmission uses different rbSize (%d vs. orig %d)\n", - sched_ctrl->rbSize, - retInfo->rbSize); - if (sched_ctrl->time_domain_allocation != retInfo->time_domain_allocation) - LOG_W(NR_MAC, - "retransmission uses different time_domain_allocation (%d vs. orig %d)\n", - sched_ctrl->time_domain_allocation, - retInfo->time_domain_allocation); - if (sched_ctrl->mcs != retInfo->mcs - || sched_ctrl->mcsTableIdx != retInfo->mcsTableIdx - || sched_ctrl->numDmrsCdmGrpsNoData != retInfo->numDmrsCdmGrpsNoData) - LOG_W(NR_MAC, - "retransmission uses different table/MCS/numDmrsCdmGrpsNoData (%d/%d/%d vs. orig %d/%d/%d)\n", - sched_ctrl->mcsTableIdx, - sched_ctrl->mcs, - sched_ctrl->numDmrsCdmGrpsNoData, - retInfo->mcsTableIdx, - retInfo->mcs, - retInfo->numDmrsCdmGrpsNoData); /* we do not have to do anything, since we do not require to get data * from RLC or encode MAC CEs. The TX_req structure is filled below * or copy data to FAPI structures */ @@ -1060,14 +1074,15 @@ void nr_schedule_ue_spec(module_id_t module_id, current_harq_pid, harq->round, harq->ndi); - AssertFatal(harq->tb_size == TBS, + + AssertFatal(harq->sched_pdsch.tb_size == TBS, "UE %d mismatch between scheduled TBS and buffered TB for HARQ PID %d\n", UE_id, current_harq_pid); } else { /* initial transmission */ LOG_D(NR_MAC, "[%s] Initial HARQ transmission in %d.%d\n", __FUNCTION__, frame, slot); - harq->tb_size = TBS; + uint8_t *buf = (uint8_t *) harq->tb; /* first, write all CEs that might be there */ @@ -1110,7 +1125,7 @@ void nr_schedule_ue_spec(module_id_t module_id, 0, 0); - LOG_I(NR_MAC, + LOG_D(NR_MAC, "%4d.%2d RNTI %04x: %d bytes from %s %d (ndata %d, remaining size %d)\n", frame, slot, @@ -1177,11 +1192,11 @@ void nr_schedule_ue_spec(module_id_t module_id, UE_info->mac_stats[UE_id].dlsch_current_bytes = TBS; UE_info->mac_stats[UE_id].lc_bytes_tx[lcid] += dlsch_total_bytes; - retInfo->rbSize = sched_ctrl->rbSize; - retInfo->time_domain_allocation = sched_ctrl->time_domain_allocation; - retInfo->mcsTableIdx = sched_ctrl->mcsTableIdx; - retInfo->mcs = sched_ctrl->mcs; - retInfo->numDmrsCdmGrpsNoData = sched_ctrl->numDmrsCdmGrpsNoData; + /* save retransmission information */ + harq->sched_pdsch = *sched_pdsch; + /* save which time allocation has been used, to be used on + * retransmissions */ + harq->sched_pdsch.time_domain_allocation = ps->time_domain_allocation; // ta command is sent, values are reset if (sched_ctrl->ta_apply) { @@ -1210,6 +1225,6 @@ void nr_schedule_ue_spec(module_id_t module_id, gNB_mac->TX_req[CC_id].Slot = slot; /* mark UE as scheduled */ - sched_ctrl->rbSize = 0; + sched_pdsch->rbSize = 0; } } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c index dbbc40e426..14bce77fae 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_phytest.c @@ -146,15 +146,18 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, int startSymbolAndLength=0; int StartSymbolIndex=-1,NrOfSymbols=14; int StartSymbolIndex_tmp,NrOfSymbols_tmp; + int mappingtype_tmp, mappingtype=0; for (int i=0; idownlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count; i++) { startSymbolAndLength = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength; SLIV2SL(startSymbolAndLength,&StartSymbolIndex_tmp,&NrOfSymbols_tmp); + mappingtype_tmp = scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType; if (NrOfSymbols_tmp < NrOfSymbols) { NrOfSymbols = NrOfSymbols_tmp; StartSymbolIndex = StartSymbolIndex_tmp; + mappingtype = mappingtype_tmp; // k0 = *scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0; // time_domain_assignment = i; } @@ -165,7 +168,8 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, pdsch_pdu_rel15->dlDmrsSymbPos = fill_dmrs_mask(NULL, scc->dmrs_TypeA_Position, NrOfSymbols, - StartSymbolIndex); + StartSymbolIndex, + mappingtype); /* AssertFatal(k0==0,"k0 is not zero for Initial DL BWP TimeDomain Alloc\n"); @@ -316,14 +320,10 @@ void nr_preprocessor_phytest(module_id_t module_id, 0); sched_ctrl->num_total_bytes += sched_ctrl->rlc_status[lcid].bytes_in_buffer; - const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - sched_ctrl->search_space = get_searchspace(scc,sched_ctrl->active_bwp, target_ss); uint8_t nr_of_candidates; find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space); - sched_ctrl->coreset = get_coreset(scc, - sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); const int cid = sched_ctrl->coreset->controlResourceSetId; const uint16_t Y = UE_info->Y[UE_id][cid][slot]; const int m = UE_info->num_pdcch_cand[UE_id][cid]; @@ -339,8 +339,8 @@ void nr_preprocessor_phytest(module_id_t module_id, __func__, UE_id); - const bool alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot,-1); - if (!alloc) { + const int alloc = nr_acknack_scheduling(module_id, UE_id, frame, slot, -1); + if (alloc < 0) { LOG_D(MAC, "%s(): could not find PUCCH for UE %d/%04x@%d.%d\n", __func__, @@ -355,41 +355,49 @@ void nr_preprocessor_phytest(module_id_t module_id, return; } - AssertFatal(alloc, - "could not find uplink slot for PUCCH (RNTI %04x@%d.%d)!\n", - rnti, frame, slot); + //AssertFatal(alloc, + // "could not find uplink slot for PUCCH (RNTI %04x@%d.%d)!\n", + // rnti, frame, slot); + + NR_sched_pdsch_t *sched_pdsch = &sched_ctrl->sched_pdsch; + NR_pdsch_semi_static_t *ps = &sched_ctrl->pdsch_semi_static; + sched_pdsch->pucch_allocation = alloc; + sched_pdsch->rbStart = rbStart; + sched_pdsch->rbSize = rbSize; + const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1; + const uint8_t num_dmrs_cdm_grps_no_data = 1; + if (ps->time_domain_allocation != tda || ps->numDmrsCdmGrpsNoData != num_dmrs_cdm_grps_no_data) + nr_set_pdsch_semi_static( + scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, tda, num_dmrs_cdm_grps_no_data, ps); + + sched_pdsch->mcs = target_dl_mcs; + sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx); + sched_pdsch->tb_size = nr_compute_tbs(sched_pdsch->Qm, + sched_pdsch->R, + sched_pdsch->rbSize, + ps->nrOfSymbols, + ps->N_PRB_DMRS * ps->N_DMRS_SLOT, + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; - sched_ctrl->rbStart = rbStart; - sched_ctrl->rbSize = rbSize; - sched_ctrl->time_domain_allocation = 2; - if (!UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table) - sched_ctrl->mcsTableIdx = 0; - else { - if (*UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table == 0) - sched_ctrl->mcsTableIdx = 1; - else - sched_ctrl->mcsTableIdx = 2; - } - sched_ctrl->mcs = target_dl_mcs; - sched_ctrl->numDmrsCdmGrpsNoData = 1; /* get the PID of a HARQ process awaiting retransmission, or -1 otherwise */ - sched_ctrl->dl_harq_pid = sched_ctrl->retrans_dl_harq.head; + sched_pdsch->dl_harq_pid = sched_ctrl->retrans_dl_harq.head; /* mark the corresponding RBs as used */ - for (int rb = 0; rb < sched_ctrl->rbSize; rb++) - vrb_map[rb + sched_ctrl->rbStart] = 1; + for (int rb = 0; rb < sched_pdsch->rbSize; rb++) + vrb_map[rb + sched_pdsch->rbStart] = 1; - if ((frame&127) == 0) LOG_I(MAC,"phytest: %d.%d DL mcs %d, DL rbStart %d, DL rbSize %d\n", frame, slot, sched_ctrl->mcs, rbStart,rbSize); + if ((frame&127) == 0) LOG_D(MAC,"phytest: %d.%d DL mcs %d, DL rbStart %d, DL rbSize %d\n", frame, slot, sched_pdsch->mcs, rbStart,rbSize); } uint32_t target_ul_mcs = 9; uint32_t target_ul_bw = 50; -uint64_t ulsch_slot_bitmap = (1<<8); -bool nr_ul_preprocessor_phytest(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - int num_slots_per_tdd, - uint64_t ulsch_in_slot_bitmap) { +uint64_t ulsch_slot_bitmap = (1 << 8); +bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_t slot) +{ gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -408,7 +416,9 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = 1; + const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 1; + if (tda < 0) + return false; const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; AssertFatal(tda < tdaList->list.count, @@ -424,15 +434,24 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, if (!is_xlsch_in_slot(ulsch_slot_bitmap, sched_slot)) return false; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const int dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; + const uint8_t num_dmrs_cdm_grps_no_data = 1; + /* we want to avoid a lengthy deduction of DMRS and other parameters in + * every TTI if we can save it, so check whether dci_format, TDA, or + * num_dmrs_cdm_grps_no_data has changed and only then recompute */ + NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; + if (ps->time_domain_allocation != tda + || ps->dci_format != dci_format + || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + uint16_t rbStart = 0; uint16_t rbSize = target_ul_bw; uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; - int startSymbolIndex, nrOfSymbols; - SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); - const uint16_t symb = ((1 << nrOfSymbols) - 1) << startSymbolIndex; + const uint16_t symb = ((1 << ps->nrOfSymbols) - 1) << ps->startSymbolIndex; for (int i = rbStart; i < rbStart + rbSize; ++i) { if ((vrb_map_UL[i] & symb) != 0) { LOG_E(MAC, @@ -448,14 +467,10 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; - const int target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific; - sched_ctrl->search_space = get_searchspace(scc,sched_ctrl->active_bwp, target_ss); uint8_t nr_of_candidates; find_aggregation_candidates(&sched_ctrl->aggregation_level, &nr_of_candidates, sched_ctrl->search_space); - sched_ctrl->coreset = get_coreset(scc, - sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); const int cid = sched_ctrl->coreset->controlResourceSetId; const uint16_t Y = UE_info->Y[UE_id][cid][slot]; const int m = UE_info->num_pdcch_cand[UE_id][cid]; @@ -472,24 +487,6 @@ bool nr_ul_preprocessor_phytest(module_id_t module_id, } UE_info->num_pdcch_cand[UE_id][cid]++; - sched_ctrl->sched_pusch.time_domain_allocation = tda; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - const int dci_format = f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0; - const uint8_t num_dmrs_cdm_grps_no_data = 1; - /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or - * num_dmrs_cdm_grps_no_data has changed and only then recompute */ - NR_sched_pusch_save_t *ps = &sched_ctrl->pusch_save; - if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_save_pusch_fields(scc, - sched_ctrl->active_ubwp, - dci_format, - tda, - num_dmrs_cdm_grps_no_data, - ps); - const int mcs = target_ul_mcs; NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; sched_pusch->mcs = mcs; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 23b19c51ff..1ec72ed371 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -120,10 +120,10 @@ static inline uint8_t get_max_candidates(uint8_t scs) { static inline uint8_t get_max_cces(uint8_t scs) { AssertFatal(scs<4, "Invalid PDCCH subcarrier spacing %d\n", scs); return (nr_max_number_of_cces_per_slot[scs]); -} +} NR_ControlResourceSet_t *get_coreset(NR_ServingCellConfigCommon_t *scc, - NR_BWP_Downlink_t *bwp, + NR_BWP_Downlink_t *bwp, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type) { NR_ControlResourceSetId_t coreset_id = *ss->controlResourceSetId; @@ -139,9 +139,7 @@ NR_ControlResourceSet_t *get_coreset(NR_ServingCellConfigCommon_t *scc, "search space\n"); return coreset; } else { - // AssertFatal(bwp!=NULL,"bwp is null here, we have to check for a dedicated configuration for initialBWP in CellGroup, todo\n"); const int n = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.count; - for (int i = 0; i < n; i++) { NR_ControlResourceSet_t *coreset = bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list.array[i]; @@ -218,12 +216,98 @@ int allocate_nr_CCEs(gNB_MAC_INST *nr_mac, } -void nr_save_pusch_fields(const NR_ServingCellConfigCommon_t *scc, - const NR_BWP_Uplink_t *ubwp, - long dci_format, - int tda, - uint8_t num_dmrs_cdm_grps_no_data, - NR_sched_pusch_save_t *ps) +bool nr_find_nb_rb(uint16_t Qm, + uint16_t R, + uint16_t nb_symb_sch, + uint16_t nb_dmrs_prb, + uint32_t bytes, + uint16_t nb_rb_max, + uint32_t *tbs, + uint16_t *nb_rb) +{ + /* is the maximum (not even) enough? */ + *nb_rb = nb_rb_max; + *tbs = nr_compute_tbs(Qm, R, *nb_rb, nb_symb_sch, nb_dmrs_prb, 0, 0, 1) >> 3; + /* check whether it does not fit, or whether it exactly fits. Some algorithms + * might depend on the return value! */ + if (bytes > *tbs) + return false; + if (bytes == *tbs) + return true; + + /* is the minimum enough? */ + *nb_rb = 1; + *tbs = nr_compute_tbs(Qm, R, *nb_rb, nb_symb_sch, nb_dmrs_prb, 0, 0, 1) >> 3; + if (bytes <= *tbs) + return true; + + /* perform binary search to allocate all bytes within a TBS up to nb_rb_max + * RBs */ + int hi = nb_rb_max; + int lo = 1; + for (int p = (hi + lo) / 2; lo + 1 < hi; p = (hi + lo) / 2) { + const uint32_t TBS = nr_compute_tbs(Qm, R, p, nb_symb_sch, nb_dmrs_prb, 0, 0, 1) >> 3; + if (bytes == TBS) { + hi = p; + break; + } else if (bytes < TBS) { + hi = p; + } else { + lo = p; + } + } + *nb_rb = hi; + *tbs = nr_compute_tbs(Qm, R, *nb_rb, nb_symb_sch, nb_dmrs_prb, 0, 0, 1) >> 3; + /* return whether we could allocate all bytes and stay below nb_rb_max */ + return *tbs >= bytes && *nb_rb <= nb_rb_max; +} + +void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, + const NR_CellGroupConfig_t *secondaryCellGroup, + const NR_BWP_Downlink_t *bwp, + int tda, + uint8_t num_dmrs_cdm_grps_no_data, + NR_pdsch_semi_static_t *ps) +{ + ps->time_domain_allocation = tda; + + const struct NR_PDSCH_TimeDomainResourceAllocationList *tdaList = bwp ? + bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList : + scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; + AssertFatal(tda < tdaList->list.count, "time_domain_allocation %d>=%d\n", tda, tdaList->list.count); + const int mapping_type = tdaList->list.array[tda]->mappingType; + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + SLIV2SL(startSymbolAndLength, &ps->startSymbolIndex, &ps->nrOfSymbols); + + ps->mcsTableIdx = 0; + if (bwp && + bwp->bwp_Dedicated && + bwp->bwp_Dedicated->pdsch_Config && + bwp->bwp_Dedicated->pdsch_Config->choice.setup && + bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table) { + if (*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table == 0) + ps->mcsTableIdx = 1; + else + ps->mcsTableIdx = 2; + } + else ps->mcsTableIdx = 0; + + ps->numDmrsCdmGrpsNoData = num_dmrs_cdm_grps_no_data; + ps->dmrsConfigType = bwp!=NULL ? (bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1) : 0; + + // if no data in dmrs cdm group is 1 only even REs have no data + // if no data in dmrs cdm group is 2 both odd and even REs have no data + ps->N_PRB_DMRS = num_dmrs_cdm_grps_no_data * (ps->dmrsConfigType == NFAPI_NR_DMRS_TYPE1 ? 6 : 4); + ps->dl_dmrs_symb_pos = fill_dmrs_mask(bwp ? bwp->bwp_Dedicated->pdsch_Config->choice.setup : NULL, scc->dmrs_TypeA_Position, ps->nrOfSymbols, ps->startSymbolIndex, mapping_type); + ps->N_DMRS_SLOT = get_num_dmrs(ps->dl_dmrs_symb_pos); +} + +void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, + const NR_BWP_Uplink_t *ubwp, + long dci_format, + int tda, + uint8_t num_dmrs_cdm_grps_no_data, + NR_pusch_semi_static_t *ps) { ps->dci_format = dci_format; ps->time_domain_allocation = tda; @@ -264,9 +348,9 @@ void nr_save_pusch_fields(const NR_ServingCellConfigCommon_t *scc, /* DMRS calculations */ ps->mapping_type = tdaList->list.array[tda]->mappingType; - ps->NR_DMRS_UplinkConfig = ps->pusch_Config ? - (ps->mapping_type == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA ? - ps->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : + ps->NR_DMRS_UplinkConfig = ps->pusch_Config ? + (ps->mapping_type == NR_PUSCH_TimeDomainResourceAllocation__mappingType_typeA ? + ps->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup : ps->pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup) : NULL; ps->dmrs_config_type = ps->NR_DMRS_UplinkConfig ? ((ps->NR_DMRS_UplinkConfig->dmrs_Type == NULL ? 0 : 1)) : 0; const pusch_dmrs_AdditionalPosition_t additional_pos = @@ -278,11 +362,12 @@ void nr_save_pusch_fields(const NR_ServingCellConfigCommon_t *scc, : *ps->NR_DMRS_UplinkConfig->dmrs_AdditionalPosition)):2; const pusch_maxLength_t pusch_maxLength = ps->NR_DMRS_UplinkConfig ? (ps->NR_DMRS_UplinkConfig->maxLength == NULL ? 1 : 2) : 1; - const uint16_t l_prime_mask = get_l_prime(ps->nrOfSymbols, + ps->ul_dmrs_symb_pos = get_l_prime(ps->nrOfSymbols, ps->mapping_type, additional_pos, - pusch_maxLength); - ps->ul_dmrs_symb_pos = l_prime_mask << ps->startSymbolIndex; + pusch_maxLength, + ps->startSymbolIndex, + scc->dmrs_TypeA_Position); uint8_t num_dmrs_symb = 0; for(int i = ps->startSymbolIndex; i < ps->startSymbolIndex + ps->nrOfSymbols; i++) num_dmrs_symb += (ps->ul_dmrs_symb_pos >> i) & 1; @@ -511,7 +596,7 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, } void config_uldci(const NR_BWP_Uplink_t *ubwp, - const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, @@ -519,7 +604,7 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, uint8_t tpc, int n_ubwp, int bwp_id) { - const int bw = NRRIV2BW(ubwp ? + const int bw = NRRIV2BW(ubwp ? ubwp->bwp_Common->genericParameters.locationAndBandwidth : scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE); dci_pdu_rel15->frequency_domain_assignment.val = @@ -542,11 +627,11 @@ void config_uldci(const NR_BWP_Uplink_t *ubwp, // bwp indicator as per table 7.3.1.1.2-1 in 38.212 dci_pdu_rel15->bwp_indicator.val = n_ubwp < 4 ? bwp_id : bwp_id - 1; // SRS resource indicator - if (ubwp && - ubwp->bwp_Dedicated && - ubwp->bwp_Dedicated->pusch_Config && - ubwp->bwp_Dedicated->pusch_Config->choice.setup && - ubwp->bwp_Dedicated->pusch_Config->choice.setup->txConfig != NULL) { + if (ubwp && + ubwp->bwp_Dedicated && + ubwp->bwp_Dedicated->pusch_Config && + ubwp->bwp_Dedicated->pusch_Config->choice.setup && + ubwp->bwp_Dedicated->pusch_Config->choice.setup->txConfig != NULL) { AssertFatal(*ubwp->bwp_Dedicated->pusch_Config->choice.setup->txConfig == NR_PUSCH_Config__txConfig_codebook, "Non Codebook configuration non supported\n"); dci_pdu_rel15->srs_resource_indicator.val = 0; // taking resource 0 for SRS @@ -623,20 +708,22 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, break; } } - + pdcch_pdu->DurationSymbols = coreset->duration; - + for (int i=0;i<6;i++) pdcch_pdu->FreqDomainResource[i] = coreset->frequencyDomainResources.buf[i]; - - + + //cce-REG-MappingType pdcch_pdu->CceRegMappingType = coreset->cce_REG_MappingType.present == NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved? NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED : NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED; - + if (pdcch_pdu->CceRegMappingType == NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED) { - pdcch_pdu->RegBundleSize = (coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize); - pdcch_pdu->InterleaverSize = (coreset->cce_REG_MappingType.choice.interleaved->interleaverSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->interleaverSize); + pdcch_pdu->RegBundleSize = (coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize == + NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->reg_BundleSize); + pdcch_pdu->InterleaverSize = (coreset->cce_REG_MappingType.choice.interleaved->interleaverSize == + NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2+coreset->cce_REG_MappingType.choice.interleaved->interleaverSize); AssertFatal(scc->physCellId != NULL,"scc->physCellId is null\n"); pdcch_pdu->ShiftIndex = coreset->cce_REG_MappingType.choice.interleaved->shiftIndex != NULL ? *coreset->cce_REG_MappingType.choice.interleaved->shiftIndex : *scc->physCellId; } @@ -645,7 +732,7 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, pdcch_pdu->InterleaverSize = 0; pdcch_pdu->ShiftIndex = 0; } - + if(coreset->controlResourceSetId == 0) { if(bwp == NULL) pdcch_pdu->CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1; @@ -662,15 +749,15 @@ void nr_configure_pdcch(nfapi_nr_dl_tti_pdcch_pdu_rel15_t *pdcch_pdu, // This function configures pucch pdu fapi structure void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, - NR_ServingCellConfigCommon_t *scc, - NR_CellGroupConfig_t *CellGroup, - NR_BWP_Uplink_t *bwp, + NR_ServingCellConfigCommon_t *scc, + NR_CellGroupConfig_t *CellGroup, + NR_BWP_Uplink_t *bwp, uint16_t rnti, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, uint8_t O_sr, - int r_pucch) { + int r_pucch) { NR_PUCCH_Config_t *pucch_Config; NR_PUCCH_Resource_t *pucchres; @@ -690,14 +777,14 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, NR_PUSCH_Config_t *pusch_Config = bwp ? bwp->bwp_Dedicated->pusch_Config->choice.setup : NULL; long *pusch_id = bwp ? pusch_Config->dataScramblingIdentityPUSCH : NULL; - + if (bwp && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA != NULL) id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup->transformPrecodingDisabled->scramblingID0; else if (bwp && pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB != NULL) id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0; else id0 = scc->physCellId; - - NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = bwp ? + + NR_PUCCH_ConfigCommon_t *pucch_ConfigCommon = bwp ? bwp->bwp_Common->pucch_ConfigCommon->choice.setup : scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup; // hop flags and hopping id are valid for any BWP @@ -720,34 +807,34 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, default: AssertFatal(1==0,"Group hopping flag %ld undefined (0,1,2) \n", bwp->bwp_Common->pucch_ConfigCommon->choice.setup->pucch_GroupHopping); } - + if (pucch_ConfigCommon->hoppingId != NULL) pucch_pdu->hopping_id = *pucch_ConfigCommon->hoppingId; else pucch_pdu->hopping_id = *scc->physCellId; - NR_BWP_t *genericParameters = bwp ? + NR_BWP_t *genericParameters = bwp ? &bwp->bwp_Common->genericParameters: &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; pucch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pucch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth,MAX_BWP_SIZE); pucch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; pucch_pdu->cyclic_prefix = (genericParameters->cyclicPrefix==NULL) ? 0 : *genericParameters->cyclicPrefix; - if (r_pucch<0){ + if (r_pucch<0 || bwp){ // we have either a dedicated BWP or Dedicated PUCCH configuration on InitialBWP - pucch_Config = bwp ? + pucch_Config = bwp ? bwp->bwp_Dedicated->pucch_Config->choice.setup: CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - + AssertFatal(pucch_Config->resourceSetToAddModList!=NULL, "PUCCH resourceSetToAddModList is null\n"); - - n_set = pucch_Config->resourceSetToAddModList->list.count; + + n_set = pucch_Config->resourceSetToAddModList->list.count; AssertFatal(n_set>0,"PUCCH resourceSetToAddModList is empty\n"); - + LOG_D(NR_MAC, "UCI n_set= %d\n", n_set); - + N2 = 2; - // procedure to select pucch resource id from resource sets according to + // procedure to select pucch resource id from resource sets according to // number of uci bits and pucch resource indicator pucch_resource // ( see table 9.2.3.2 in 38.213) for (int i=0; ipucch_ResourceSetId == 0 && O_uci<3) { if (pucch_resource < n_list) resource_id = pucchresset->resourceList.list.array[pucch_resource]; - else + else AssertFatal(1==0,"Couldn't fine pucch resource indicator %d in PUCCH resource set %d for %d UCI bits",pucch_resource,i,O_uci); } if (pucchresset->pucch_ResourceSetId == 1 && O_uci>2) { @@ -768,21 +855,21 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, if (N2O_uci) { if (pucch_resource < n_list) resource_id = pucchresset->resourceList.list.array[pucch_resource]; - else + else AssertFatal(1==0,"Couldn't fine pucch resource indicator %d in PUCCH resource set %d for %d UCI bits",pucch_resource,i,O_uci); } else N2 = N3; } } - + AssertFatal(resource_id!=NULL,"Couldn-t find any matching PUCCH resource in the PUCCH resource sets"); - + AssertFatal(pucch_Config->resourceToAddModList!=NULL, "PUCCH resourceToAddModList is null\n"); - - n_list = pucch_Config->resourceToAddModList->list.count; + + n_list = pucch_Config->resourceToAddModList->list.count; AssertFatal(n_list>0,"PUCCH resourceToAddModList is empty\n"); - + // going through the list of PUCCH resources to find the one indexed by resource_id for (int i=0; iresourceToAddModList->list.array[i]; @@ -872,13 +959,13 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, } } } - AssertFatal(res_found==1,"No PUCCH resource found corresponding to id %ld\n",*resource_id); + AssertFatal(res_found==1,"No PUCCH resource found corresponding to id %ld\n",*resource_id); } else { // this is the default PUCCH configuration, PUCCH format 0 or 1 int rsetindex = *scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon; int prboffset = r_pucch/default_pucch_csset[rsetindex]; int prboffsetm8 = (r_pucch-8)/default_pucch_csset[rsetindex]; - pucch_pdu->prb_start = (r_pucch>>3)==0 ? + pucch_pdu->prb_start = (r_pucch>>3)==0 ? default_pucch_prboffset[rsetindex] + prboffset: pucch_pdu->bwp_size-1-default_pucch_prboffset[rsetindex]-prboffsetm8; pucch_pdu->rnti = rnti; @@ -894,7 +981,7 @@ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, pucch_pdu->nr_of_symbols = default_pucch_numbsymb[rsetindex]; pucch_pdu->start_symbol_index = default_pucch_firstsymb[rsetindex]; if (pucch_pdu->format_type == 1) pucch_pdu->time_domain_occ_idx = 0; // check this!! - pucch_pdu->sr_flag = O_sr; + pucch_pdu->sr_flag = O_sr; } } @@ -1200,7 +1287,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, case NR_RNTI_TC: pos = 1; // indicating a DL DCI format 1bit - *dci_pdu |= ((uint64_t)1) << (dci_size - pos++); + *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos++); // Freq domain assignment 0-16 bit fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); for (int i = 0; i < fsize; i++) @@ -1257,7 +1344,7 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, case NR_RNTI_C: // indicating a UL DCI format 1bit pos=1; - //*dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); + *dci_pdu |= ((uint64_t)dci_pdu_rel15->format_indicator & 1) << (dci_size - pos); // Freq domain assignment max 16 bit fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1)); pos+=fsize; @@ -1292,6 +1379,19 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc, *dci_pdu |= ((uint64_t)dci_pdu_rel15->ul_sul_indicator.val&1)<<(dci_size-pos++); */ + + LOG_D(NR_MAC,"N_RB = %i\n", N_RB); + LOG_D(NR_MAC,"dci_size = %i\n", dci_size); + LOG_D(NR_MAC,"fsize = %i\n", fsize); + LOG_D(NR_MAC,"dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val); + LOG_D(NR_MAC,"dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val); + LOG_D(NR_MAC,"dci_pdu_rel15->frequency_hopping_flag.val = %i\n", dci_pdu_rel15->frequency_hopping_flag.val); + LOG_D(NR_MAC,"dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs); + LOG_D(NR_MAC,"dci_pdu_rel15->ndi = %i\n", dci_pdu_rel15->ndi); + LOG_D(NR_MAC,"dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv); + LOG_D(NR_MAC,"dci_pdu_rel15->harq_pid = %i\n", dci_pdu_rel15->harq_pid); + LOG_D(NR_MAC,"dci_pdu_rel15->tpc = %i\n", dci_pdu_rel15->tpc); + LOG_D(NR_MAC,"dci_pdu_rel15->padding = %i\n", dci_pdu_rel15->padding); break; case NFAPI_NR_RNTI_TC: @@ -1702,9 +1802,28 @@ int get_nrofHARQ_ProcessesForPDSCH(e_NR_PDSCH_ServingCellConfig__nrofHARQ_Proces } } +int get_dl_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) +{ + if (servingCellConfig->firstActiveDownlinkBWP_Id) + return *servingCellConfig->firstActiveDownlinkBWP_Id; + else if (servingCellConfig->defaultDownlinkBWP_Id) + return *servingCellConfig->defaultDownlinkBWP_Id; + else + return 1; +} + +int get_ul_bwp_id(const NR_ServingCellConfig_t *servingCellConfig) +{ + if (servingCellConfig->uplinkConfig && servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id) + return *servingCellConfig->uplinkConfig->firstActiveUplinkBWP_Id; + else + return 1; +} + //------------------------------------------------------------------------------ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellGroup) { + NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_idP]->common_channels[0].ServingCellConfigCommon; NR_UE_info_t *UE_info = &RC.nrmac[mod_idP]->UE_info; LOG_I(NR_MAC, "[gNB %d] Adding UE with rnti %x (num_UEs %d)\n", mod_idP, @@ -1714,14 +1833,14 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) { if (UE_info->active[i]) { - LOG_I(NR_MAC,"UE %x is active, skipping\n",rntiP); + LOG_D(NR_MAC,"UE %x is active, skipping\n",rntiP); continue; } int UE_id = i; UE_info->num_UEs++; UE_info->active[UE_id] = true; if (CellGroup) UE_info->Msg4_ACKed[UE_id] = true; - else UE_info->Msg4_ACKed[UE_id] = false; + else UE_info->Msg4_ACKed[UE_id] = false; UE_info->rnti[UE_id] = rntiP; UE_info->CellGroup[UE_id] = CellGroup; add_nr_list(&UE_info->list, UE_id); @@ -1740,7 +1859,8 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG sched_ctrl->pusch_consecutive_dtx_cnt = 0; sched_ctrl->ul_failure = 0; /* set illegal time domain allocation to force recomputation of all fields */ - sched_ctrl->pusch_save.time_domain_allocation = -1; + sched_ctrl->pdsch_semi_static.time_domain_allocation = -1; + sched_ctrl->pusch_semi_static.time_domain_allocation = -1; const NR_ServingCellConfig_t *servingCellConfig = CellGroup ? CellGroup->spCellConfig->spCellConfigDedicated : NULL; /* Set default BWPs */ @@ -1750,6 +1870,9 @@ int add_new_nr_ue(module_id_t mod_idP, rnti_t rntiP, NR_CellGroupConfig_t *CellG bwpList->list.count); const int bwp_id = 1; sched_ctrl->active_bwp = bwpList ? bwpList->list.array[bwp_id - 1] : NULL; + const int target_ss = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific : NR_SearchSpace__searchSpaceType_PR_common; + sched_ctrl->search_space = get_searchspace(scc, sched_ctrl->active_bwp ? sched_ctrl->active_bwp->bwp_Dedicated : NULL, target_ss); + sched_ctrl->coreset = get_coreset(scc, sched_ctrl->active_bwp, sched_ctrl->search_space, target_ss); const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = servingCellConfig ? servingCellConfig->uplinkConfig->uplinkBWP_ToAddModList : NULL; if (ubwpList) AssertFatal(ubwpList->list.count == 1, "uplinkBWP_ToAddModList has %d BWP!\n", @@ -1864,12 +1987,11 @@ void nr_mac_remove_ra_rnti(module_id_t mod_id, rnti_t rnti) { uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) { // al values passed to this function are x10 - int snrx10 = (cqi*5) - 640; - LOG_D(NR_MAC,"tpc : target %d, snrx10 %d\n",target,snrx10); if (snrx10 > target + incr) return 0; // decrease 1dB if (snrx10 < target - incr) return 2; // increase 1dB if (snrx10 < target - (3*incr)) return 3; // increase 3dB + LOG_D(NR_MAC,"tpc : target %d, snrx10 %d\n",target,snrx10); return 1; // no change } @@ -1885,12 +2007,12 @@ void get_pdsch_to_harq_feedback(int Mod_idP, NR_BWP_Downlink_t *bwp=NULL; NR_BWP_Uplink_t *ubwp=NULL; - if (CellGroup && CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) + if (CellGroup && CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList) bwp = CellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_id-1]; if (CellGroup && CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) ubwp = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[bwp_id-1]; - NR_SearchSpace_t *ss; + NR_SearchSpace_t *ss=NULL; // common search type uses DCI format 1_0 if (ss_type == NR_SearchSpace__searchSpaceType_PR_common) { diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c index 1aef076db0..556b337d2b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_uci.c @@ -26,6 +26,7 @@ * \company Eurecom */ +#include #include "LAYER2/MAC/mac.h" #include "NR_MAC_gNB/nr_mac_gNB.h" #include "NR_MAC_COMMON/nr_mac_extern.h" @@ -72,14 +73,14 @@ void nr_fill_nfapi_pucch(module_id_t mod_id, NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; nr_configure_pucch(pucch_pdu, scc, - UE_info->CellGroup[UE_id], + UE_info->CellGroup[UE_id], UE_info->UE_sched_ctrl[UE_id].active_ubwp, UE_info->rnti[UE_id], pucch->resource_indicator, pucch->csi_bits, pucch->dai_c, pucch->sr_flag, - pucch->r_pucch); + pucch->r_pucch); } #define MIN_RSRP_VALUE -141 @@ -120,13 +121,18 @@ int diff_rsrp_ssb_csi_meas_10_1_6_1_2[16] = { void nr_schedule_pucch(int Mod_idP, frame_t frameP, - sub_frame_t slotP) { - NR_UE_info_t *UE_info = &RC.nrmac[Mod_idP]->UE_info; + sub_frame_t slotP) +{ + gNB_MAC_INST *nrmac = RC.nrmac[Mod_idP]; + if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slotP / 64], slotP)) + return; + + NR_UE_info_t *UE_info = &nrmac->UE_info; const NR_list_t *UE_list = &UE_info->list; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->ul_failure==1) continue; + if (sched_ctrl->ul_failure==1 && get_softmodem_params()->phy_test==0) continue; const int n = sizeof(sched_ctrl->sched_pucch) / sizeof(*sched_ctrl->sched_pucch); for (int i = 0; i < n; i++) { NR_sched_pucch_t *curr_pucch = &UE_info->UE_sched_ctrl[UE_id].sched_pucch[i]; @@ -476,8 +482,8 @@ void nr_csi_meas_reporting(int Mod_idP, for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { const NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || - !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; + if (!CellGroup || !CellGroup->spCellConfig || !CellGroup->spCellConfig->spCellConfigDedicated || + !CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig) continue; const NR_CSI_MeasConfig_t *csi_measconfig = CellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup; AssertFatal(csi_measconfig->csi_ReportConfigToAddModList->list.count > 0, "NO CSI report configuration available"); @@ -509,11 +515,11 @@ void nr_csi_meas_reporting(int Mod_idP, // find free PUCCH that is in order with possibly existing PUCCH // schedulings (other CSI, SR) - NR_sched_pucch_t *curr_pucch = &sched_ctrl->sched_pucch[2]; + NR_sched_pucch_t *curr_pucch = &sched_ctrl->sched_pucch[1]; AssertFatal(curr_pucch->csi_bits == 0 && !curr_pucch->sr_flag && curr_pucch->dai_c == 0, - "PUCCH not free at index 2 for UE %04x\n", + "PUCCH not free at index 1 for UE %04x\n", UE_info->rnti[UE_id]); curr_pucch->r_pucch = -1; curr_pucch->frame = frame; @@ -554,9 +560,6 @@ void nr_csi_meas_reporting(int Mod_idP, for (int i = start; i < start + len; ++i) { vrb_map_UL[i] |= mask; } - AssertFatal(!curr_pucch->simultaneous_harqcsi, - "UE %04x has simultaneous HARQ/CSI configured, but we don't support that\n", - UE_info->rnti[UE_id]); } } } @@ -575,9 +578,7 @@ static void handle_dl_harq(module_id_t mod_id, add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; - } else { - harq->round++; - if (harq->round == MAX_HARQ_ROUNDS) { + } else if (harq->round >= MAX_HARQ_ROUNDS - 1) { add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].available_dl_harq, harq_pid); harq->round = 0; harq->ndi ^= 1; @@ -586,7 +587,7 @@ static void handle_dl_harq(module_id_t mod_id, LOG_D(MAC, "retransmission error for UE %d (total %d)\n", UE_id, stats->dlsch_errors); } else { add_tail_nr_list(&UE_info->UE_sched_ctrl[UE_id].retrans_dl_harq, harq_pid); - } + harq->round++; } } @@ -956,7 +957,50 @@ void extract_pucch_csi_report (NR_CSI_MeasConfig_t *csi_MeasConfig, if ( !(reportQuantity_type)) AssertFatal(reportQuantity_type, "reportQuantity is not configured"); +} +static NR_UE_harq_t *find_harq(module_id_t mod_id, frame_t frame, sub_frame_t slot, int UE_id) +{ + /* In case of realtime problems: we can only identify a HARQ process by + * timing. If the HARQ process's feedback_frame/feedback_slot is not the one we + * expected, we assume that processing has been aborted and we need to + * skip this HARQ process, which is what happens in the loop below. + * Similarly, we might be "in advance", in which case we need to skip + * this result. */ + NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; + int8_t pid = sched_ctrl->feedback_dl_harq.head; + if (pid < 0) + return NULL; + NR_UE_harq_t *harq = &sched_ctrl->harq_processes[pid]; + /* old feedbacks we missed: mark for retransmission */ + while (harq->feedback_frame != frame + || (harq->feedback_frame == frame && harq->feedback_slot < slot)) { + LOG_W(MAC, + "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the past)\n", + pid, + harq->feedback_frame, + harq->feedback_slot, + frame, + slot); + remove_front_nr_list(&sched_ctrl->feedback_dl_harq); + handle_dl_harq(mod_id, UE_id, pid, 0); + pid = sched_ctrl->feedback_dl_harq.head; + if (pid < 0) + return NULL; + harq = &sched_ctrl->harq_processes[pid]; + } + /* feedbacks that we wait for in the future: don't do anything */ + if (harq->feedback_slot > slot) { + LOG_W(MAC, + "expected HARQ pid %d feedback at %d.%d, but is at %d.%d instead (HARQ feedback is in the future)\n", + pid, + harq->feedback_frame, + harq->feedback_slot, + frame, + slot); + return NULL; + } + return harq; } void handle_nr_uci_pucch_0_1(module_id_t mod_id, @@ -972,44 +1016,34 @@ void handle_nr_uci_pucch_0_1(module_id_t mod_id, NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - // tpc (power control) - if (uci_01->harq->harq_confidence_level == 0) - sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, - uci_01->ul_cqi, - 30); - LOG_D(NR_MAC,"pucch tpc %d\n",sched_ctrl->tpc1); - NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; - const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; if (((uci_01->pduBitmap >> 1) & 0x01)) { // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_01->harq->num_harq; harq_bit++) { const uint8_t harq_value = uci_01->harq->harq_list[harq_bit].harq_value; const uint8_t harq_confidence = uci_01->harq->harq_confidence_level; - const int feedback_slot = (slot + num_slots) % num_slots; - /* In case of realtime problems: we can only identify a HARQ process by - * timing. If the HARQ process's feedback_slot is not the one we - * expected, we assume that processing has been aborted and we need to - * skip this HARQ process, which is what happens in the loop below. If - * you don't experience real-time problems, you might simply revert the - * commit that introduced these changes. */ - int8_t pid = sched_ctrl->feedback_dl_harq.head; - DevAssert(pid >= 0); - while (sched_ctrl->harq_processes[pid].feedback_slot != feedback_slot) { - LOG_W(MAC, - "expected feedback slot %d, but found %d instead\n", - sched_ctrl->harq_processes[pid].feedback_slot, - feedback_slot); - remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - handle_dl_harq(mod_id, UE_id, pid, 0); - pid = sched_ctrl->feedback_dl_harq.head; - DevAssert(pid >= 0); - } - remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - NR_UE_harq_t *harq = &sched_ctrl->harq_processes[pid]; + NR_UE_harq_t *harq = find_harq(mod_id, frame, slot, UE_id); + if (!harq) + break; DevAssert(harq->is_waiting); + const int8_t pid = sched_ctrl->feedback_dl_harq.head; + remove_front_nr_list(&sched_ctrl->feedback_dl_harq); handle_dl_harq(mod_id, UE_id, pid, harq_value == 1 && harq_confidence == 0); } } + + // check scheduling request result, confidence_level == 0 is good + if (uci_01->pduBitmap & 0x1 && uci_01->sr->sr_indication && uci_01->sr->sr_confidence_level == 0 && uci_01->ul_cqi >= 148) { + // SR detected with SNR >= 10dB + sched_ctrl->SR |= true; + LOG_D(MAC, "SR UE %04x ul_cqi %d\n", uci_01->rnti, uci_01->ul_cqi); + } + + // tpc (power control) only if we received AckNack or positive SR. For a + // negative SR, the UE won't have sent anything, and the SNR is not valid + if (((uci_01->pduBitmap >> 1) & 0x1) || sched_ctrl->SR) { + sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, uci_01->ul_cqi, 30); + sched_ctrl->pucch_snrx10 = uci_01->ul_cqi * 5 - 640; + } } void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, @@ -1035,35 +1069,18 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, sched_ctrl->tpc1 = nr_get_tpc(RC.nrmac[mod_id]->pucch_target_snrx10, uci_234->ul_cqi, 30); + sched_ctrl->pucch_snrx10 = uci_234->ul_cqi * 5 - 640; - NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; - const int num_slots = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; if ((uci_234->pduBitmap >> 1) & 0x01) { // iterate over received harq bits for (int harq_bit = 0; harq_bit < uci_234->harq.harq_bit_len; harq_bit++) { const int acknack = ((uci_234->harq.harq_payload[harq_bit >> 3]) >> harq_bit) & 0x01; - const int feedback_slot = (slot + num_slots) % num_slots; - /* In case of realtime problems: we can only identify a HARQ process by - * timing. If the HARQ process's feedback_slot is not the one we - * expected, we assume that processing has been aborted and we need to - * skip this HARQ process, which is what happens in the loop below. If - * you don't experience real-time problems, you might simply revert the - * commit that introduced these changes. */ - int8_t pid = sched_ctrl->feedback_dl_harq.head; - DevAssert(pid >= 0); - while (sched_ctrl->harq_processes[pid].feedback_slot != feedback_slot) { - LOG_W(MAC, - "expected feedback slot %d, but found %d instead\n", - sched_ctrl->harq_processes[pid].feedback_slot, - feedback_slot); - remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - handle_dl_harq(mod_id, UE_id, pid, 0); - pid = sched_ctrl->feedback_dl_harq.head; - DevAssert(pid >= 0); - } - remove_front_nr_list(&sched_ctrl->feedback_dl_harq); - NR_UE_harq_t *harq = &sched_ctrl->harq_processes[pid]; + NR_UE_harq_t *harq = find_harq(mod_id, frame, slot, UE_id); + if (!harq) + break; DevAssert(harq->is_waiting); + const int8_t pid = sched_ctrl->feedback_dl_harq.head; + remove_front_nr_list(&sched_ctrl->feedback_dl_harq); handle_dl_harq(mod_id, UE_id, pid, uci_234->harq.harq_crc != 1 && acknack); } } @@ -1080,11 +1097,15 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, // function to update pucch scheduling parameters in UE list when a USS DL is scheduled -bool nr_acknack_scheduling(int mod_id, - int UE_id, - frame_t frame, - sub_frame_t slot, - int r_pucch) +// this function returns an index to NR_sched_pucch structure +// currently this structure contains PUCCH0 at index 0 and PUCCH2 at index 1 +// if the function returns -1 it was not possible to schedule acknack +// when current pucch is ready to be scheduled nr_fill_nfapi_pucch is called +int nr_acknack_scheduling(int mod_id, + int UE_id, + frame_t frame, + sub_frame_t slot, + int r_pucch) { const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; @@ -1094,6 +1115,7 @@ bool nr_acknack_scheduling(int mod_id, const int nr_slots_period = tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots; const int first_ul_slot_tdd = tdd->nrofDownlinkSlots + nr_slots_period * (slot / nr_slots_period); const int CC_id = 0; + NR_sched_pucch_t *csi_pucch; AssertFatal(slot < first_ul_slot_tdd + (tdd->nrofUplinkSymbols != 0), "cannot handle multiple TDD periods (yet): slot %d first_ul_slot_tdd %d nrofUplinkSlots %ld\n", @@ -1106,10 +1128,7 @@ bool nr_acknack_scheduling(int mod_id, * * we do not multiplex with CSI, which is always in pucch_sched[2] * * SR uses format 0 and is allocated in the first UL (mixed) slot (and not * later) - * * that the PUCCH resource set 0 (for up to 2 bits) points to the first N - * PUCCH resources, where N is the number of resources in the PUCCH - * resource set. This is used in pucch_index_used, which counts the used - * resources by index, and not by their ID! */ + * * each UE has dedicated PUCCH Format 0 resources, and we use index 0! */ NR_UE_sched_ctrl_t *sched_ctrl = &RC.nrmac[mod_id]->UE_info.UE_sched_ctrl[UE_id]; NR_sched_pucch_t *pucch = &sched_ctrl->sched_pucch[0]; pucch->r_pucch=r_pucch; @@ -1117,13 +1136,8 @@ bool nr_acknack_scheduling(int mod_id, "%s(): csi_bits %d in sched_pucch[0]\n", __func__, pucch->csi_bits); - - const int max_acknacks = 2; - AssertFatal(pucch->dai_c + pucch->sr_flag <= max_acknacks, - "illegal number of bits in PUCCH of UE %d\n", - UE_id); /* if the currently allocated PUCCH of this UE is full, allocate it */ - if (pucch->sr_flag + pucch->dai_c == max_acknacks) { + if (pucch->dai_c == 2) { /* advance the UL slot information in PUCCH by one so we won't schedule in * the same slot again */ const int f = pucch->frame; @@ -1133,19 +1147,16 @@ bool nr_acknack_scheduling(int mod_id, pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; pucch->ul_slot = (s + 1) % n_slots_frame; // we assume that only two indices over the array sched_pucch exist - NR_sched_pucch_t *csi_pucch = &sched_ctrl->sched_pucch[2]; + csi_pucch = &sched_ctrl->sched_pucch[1]; // skip the CSI PUCCH if it is present and if in the next frame/slot + // and if we don't multiplex csi_pucch->r_pucch=-1; if (csi_pucch->csi_bits > 0 && csi_pucch->frame == pucch->frame - && csi_pucch->ul_slot == pucch->ul_slot) { - AssertFatal(!csi_pucch->simultaneous_harqcsi, - "%s(): %d.%d cannot handle simultaneous_harqcsi, but found for UE %d\n", - __func__, - pucch->frame, - pucch->ul_slot, - UE_id); + && csi_pucch->ul_slot == pucch->ul_slot + && !csi_pucch->simultaneous_harqcsi) { nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); + memset(csi_pucch, 0, sizeof(*csi_pucch)); pucch->frame = s >= n_slots_frame - 2 ? (f + 1) % 1024 : f; pucch->ul_slot = (s + 2) % n_slots_frame; } @@ -1158,17 +1169,15 @@ bool nr_acknack_scheduling(int mod_id, if ((pucch->frame == frame && (pucch->ul_slot >= first_ul_slot_tdd + nr_ulmix_slots)) || (pucch->frame == frame + 1)) - return false; + return -1; - // this is hardcoded for now as ue specific only if we are not on the initialBWP (to be fixed to allow ue_Specific also on initialBWP + // this is hardcoded for now as ue specific only if we are not on the initialBWP (to be fixed to allow ue_Specific also on initialBWP NR_SearchSpace__searchSpaceType_PR ss_type = sched_ctrl->active_bwp ? NR_SearchSpace__searchSpaceType_PR_ue_Specific: NR_SearchSpace__searchSpaceType_PR_common; - ; uint8_t pdsch_to_harq_feedback[8]; get_pdsch_to_harq_feedback(mod_id, UE_id, ss_type, pdsch_to_harq_feedback); - /* there is a scheduled SR or HARQ. Check whether we can use it for this - * ACKNACK */ - if (pucch->sr_flag + pucch->dai_c > 0) { + /* there is a HARQ. Check whether we can use it for this ACKNACK */ + if (pucch->dai_c > 0) { /* this UE already has a PUCCH occasion */ DevAssert(pucch->frame == frame); @@ -1188,45 +1197,25 @@ bool nr_acknack_scheduling(int mod_id, memset(pucch, 0, sizeof(*pucch)); pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; pucch->ul_slot = (s + 1) % n_slots_frame; - return nr_acknack_scheduling(mod_id, UE_id, frame, slot,pucch->r_pucch); + return nr_acknack_scheduling(mod_id, UE_id, frame, slot, pucch->r_pucch); } pucch->timing_indicator = i; pucch->dai_c++; // retain old resource indicator, and we are good - return true; + return 0; } /* we need to find a new PUCCH occasion */ - NR_PUCCH_Config_t *pucch_Config=NULL; - int bwp_Id=0; - if (sched_ctrl->active_ubwp) { - pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; - bwp_Id= sched_ctrl->active_ubwp->bwp_Id; - } - else if (RC.nrmac[mod_id]->UE_info.CellGroup[UE_id] && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && - RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) - pucch_Config = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; - if (pucch_Config) { - DevAssert(pucch_Config->resourceToAddModList->list.count > 0); - DevAssert(pucch_Config->resourceSetToAddModList->list.count > 0); - } - int n_res = (pucch_Config) ? - pucch_Config->resourceSetToAddModList->list.array[0]->resourceList.list.count : - nr_get_default_pucch_res(*scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon->choice.setup->pucch_ResourceCommon); - int *pucch_index_used = RC.nrmac[mod_id]->pucch_index_used[bwp_Id]; - /* if time information is outdated (e.g., last PUCCH occasion in last frame), * set to first possible UL occasion in this frame. Note that if such UE is * scheduled a lot and used all AckNacks, pucch->frame might have been * wrapped around to next frame */ if (frame != pucch->frame || pucch->ul_slot < first_ul_slot_tdd) { - DevAssert(pucch->sr_flag + pucch->dai_c == 0); + AssertFatal(pucch->sr_flag + pucch->dai_c == 0, + "expected no SR/AckNack for UE %d in %4d.%2d, but has %d/%d for %4d.%2d\n", + UE_id, frame, slot, pucch->sr_flag, pucch->dai_c, pucch->frame, pucch->ul_slot); AssertFatal(frame + 1 != pucch->frame, "frame wrap around not handled in %s() yet\n", __func__); @@ -1234,22 +1223,6 @@ bool nr_acknack_scheduling(int mod_id, pucch->ul_slot = first_ul_slot_tdd; } - // increase to first slot in which PUCCH resources are available - while (pucch_index_used[pucch->ul_slot] >= n_res) { - pucch->ul_slot++; - /* if there is no free resource anymore, abort search */ - if ((pucch->frame == frame - && pucch->ul_slot >= first_ul_slot_tdd + nr_ulmix_slots) - || (pucch->frame == frame + 1)) { - LOG_E(MAC, - "%4d.%2d no free PUCCH resources anymore while searching for UE %d\n", - frame, - slot, - UE_id); - return false; - } - } - // advance ul_slot if it is not reachable by UE pucch->ul_slot = max(pucch->ul_slot, slot + pdsch_to_harq_feedback[0]); @@ -1270,41 +1243,70 @@ bool nr_acknack_scheduling(int mod_id, slot, UE_id, pucch->ul_slot); - return false; + return -1; } + + // is there already CSI in this slot? + csi_pucch = &sched_ctrl->sched_pucch[1]; + if (csi_pucch->csi_bits > 0 + && csi_pucch->frame == pucch->frame + && csi_pucch->ul_slot == pucch->ul_slot) { + // skip the CSI PUCCH if it is present and if in the next frame/slot + // and if we don't multiplex + // FIXME currently we support at most 11 bits in pucch2 so skip also in that case + if(!csi_pucch->simultaneous_harqcsi + || ((csi_pucch->csi_bits + csi_pucch->dai_c) >= 11)) { + nr_fill_nfapi_pucch(mod_id, frame, slot, csi_pucch, UE_id); + memset(csi_pucch, 0, sizeof(*csi_pucch)); + /* advance the UL slot information in PUCCH by one so we won't schedule in + * the same slot again */ + const int f = pucch->frame; + const int s = pucch->ul_slot; + memset(pucch, 0, sizeof(*pucch)); + pucch->frame = s == n_slots_frame - 1 ? (f + 1) % 1024 : f; + pucch->ul_slot = (s + 1) % n_slots_frame; + return nr_acknack_scheduling(mod_id, UE_id, frame, slot, -1); + } + // multiplexing harq and csi in a pucch + else { + csi_pucch->timing_indicator = i; + csi_pucch->dai_c++; + return 1; + } + } + pucch->timing_indicator = i; // index in the list of timing indicators LOG_D(MAC,"2. DL slot %d, UL_ACK %d (index %d)\n",slot,pucch->ul_slot,i); pucch->dai_c++; - const int pucch_res = r_pucch<0 ? pucch_index_used[pucch->ul_slot] : r_pucch; - pucch->resource_indicator = pucch_res; - pucch_index_used[pucch->ul_slot] += 1; - AssertFatal(pucch_index_used[pucch->ul_slot] <= n_res, - "UE %d in %4d.%2d: pucch_index_used is %d (%d available)\n", - UE_id, - pucch->frame, - pucch->ul_slot, - pucch_index_used[pucch->ul_slot], - n_res); + pucch->resource_indicator = 0; // each UE has dedicated PUCCH resources + + NR_PUCCH_Config_t *pucch_Config = NULL; + if (sched_ctrl->active_ubwp) { + pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; + } else if (RC.nrmac[mod_id]->UE_info.CellGroup[UE_id] && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + pucch_Config = RC.nrmac[mod_id]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + } /* verify that at that slot and symbol, resources are free. We only do this * for initialCyclicShift 0 (we assume it always has that one), so other * initialCyclicShifts can overlap with ICS 0!*/ - if (pucch_Config) { - const NR_PUCCH_Resource_t *resource = - pucch_Config->resourceToAddModList->list.array[pucch_res]; - DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); - if (resource->format.choice.format0->initialCyclicShift == 0) { - uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; - const uint16_t symb = 1 << resource->format.choice.format0->startingSymbolIndex; - AssertFatal((vrb_map_UL[resource->startingPRB] & symb) == 0, - "symbol %x is not free for PUCCH alloc in vrb_map_UL at RB %ld and slot %d\n", - symb, resource->startingPRB, pucch->ul_slot); - vrb_map_UL[resource->startingPRB] |= symb; - } + const NR_PUCCH_Resource_t *resource = pucch_Config->resourceToAddModList->list.array[pucch->resource_indicator]; + DevAssert(resource->format.present == NR_PUCCH_Resource__format_PR_format0); + if (resource->format.choice.format0->initialCyclicShift == 0) { + uint16_t *vrb_map_UL = &RC.nrmac[mod_id]->common_channels[CC_id].vrb_map_UL[pucch->ul_slot * MAX_BWP_SIZE]; + const uint16_t symb = 1 << resource->format.choice.format0->startingSymbolIndex; + if ((vrb_map_UL[resource->startingPRB] & symb) != 0) + LOG_W(MAC, "symbol 0x%x is not free for PUCCH alloc in vrb_map_UL at RB %ld and slot %d.%d\n", symb, resource->startingPRB, pucch->frame, pucch->ul_slot); + vrb_map_UL[resource->startingPRB] |= symb; } - return true; + return 0; } @@ -1434,3 +1436,166 @@ uint16_t compute_pucch_prb_size(uint8_t format, AssertFatal(1==0,"Not yet implemented"); } } + +void nr_sr_reporting(int Mod_idP, frame_t SFN, sub_frame_t slot) +{ + gNB_MAC_INST *nrmac = RC.nrmac[Mod_idP]; + if (!is_xlsch_in_slot(nrmac->ulsch_slot_bitmap[slot / 64], slot)) + return; + NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; + const int n_slots_frame = nr_slots_per_frame[*scc->ssbSubcarrierSpacing]; + NR_UE_info_t *UE_info = &nrmac->UE_info; + NR_list_t *UE_list = &UE_info->list; + for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + NR_PUCCH_Config_t *pucch_Config = NULL; + if (sched_ctrl->active_ubwp) { + pucch_Config = sched_ctrl->active_ubwp->bwp_Dedicated->pucch_Config->choice.setup; + } else if (RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id] && + RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig && + RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated && + RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig && + RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP && + RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) { + pucch_Config = RC.nrmac[Mod_idP]->UE_info.CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup; + } + + AssertFatal(pucch_Config->schedulingRequestResourceToAddModList->list.count>0,"NO SR configuration available"); + + for (int SR_resource_id =0; SR_resource_id < pucch_Config->schedulingRequestResourceToAddModList->list.count;SR_resource_id++) { + NR_SchedulingRequestResourceConfig_t *SchedulingRequestResourceConfig = pucch_Config->schedulingRequestResourceToAddModList->list.array[SR_resource_id]; + + int SR_period; int SR_offset; + + periodicity__SRR(SchedulingRequestResourceConfig,&SR_period,&SR_offset); + // convert to int to avoid underflow of uint + int sfn_sf = SFN * n_slots_frame + slot; + if ((sfn_sf - SR_offset) % SR_period != 0) + continue; + LOG_D(MAC, "%4d.%2d Scheduling Request identified\n", SFN, slot); + NR_PUCCH_ResourceId_t *PucchResourceId = SchedulingRequestResourceConfig->resource; + + int found = -1; + NR_PUCCH_ResourceSet_t *pucchresset = pucch_Config->resourceSetToAddModList->list.array[0]; // set with formats 0,1 + int n_list = pucchresset->resourceList.list.count; + for (int i=0; iresourceList.list.array[i] == *PucchResourceId ) + found = i; + } + AssertFatal(found>-1,"SR resource not found among PUCCH resources"); + + /* loop through nFAPI PUCCH messages: if the UEs is in there in this slot + * with the resource_indicator, it means we already allocated that PUCCH + * resource for AckNack (e.g., the UE has been scheduled often), and we + * just need to add the SR_flag. Otherwise, just allocate in the internal + * PUCCH resource, and nr_schedule_pucch() will handle the rest */ + NR_PUCCH_Resource_t *pucch_res = pucch_Config->resourceToAddModList->list.array[found]; + /* for the moment, can only handle SR on PUCCH Format 0 */ + DevAssert(pucch_res->format.present == NR_PUCCH_Resource__format_PR_format0); + nfapi_nr_ul_tti_request_t *ul_tti_req = &nrmac->UL_tti_req_ahead[0][slot]; + bool nfapi_allocated = false; + for (int i = 0; i < ul_tti_req->n_pdus; ++i) { + if (ul_tti_req->pdus_list[i].pdu_type != NFAPI_NR_UL_CONFIG_PUCCH_PDU_TYPE) + continue; + nfapi_nr_pucch_pdu_t *pdu = &ul_tti_req->pdus_list[i].pucch_pdu; + /* check that it is our PUCCH F0. Assuming there can be only one */ + if (pdu->rnti == UE_info->rnti[UE_id] + && pdu->format_type == 0 // does not use NR_PUCCH_Resource__format_PR_format0 + && pdu->initial_cyclic_shift == pucch_res->format.choice.format0->initialCyclicShift + && pdu->nr_of_symbols == pucch_res->format.choice.format0->nrofSymbols + && pdu->start_symbol_index == pucch_res->format.choice.format0->startingSymbolIndex) { + LOG_D(MAC,"%4d.%2d adding SR_flag 1 to PUCCH nFAPI SR for RNTI %04x\n", SFN, slot, pdu->rnti); + pdu->sr_flag = 1; + nfapi_allocated = true; + break; + } + } + + if (nfapi_allocated) // break scheduling resource loop, continue next UE + break; + + /* we did not find it: check if current PUCCH is for the current slot, in + * which case we add the SR to it; otherwise, allocate SR separately */ + NR_sched_pucch_t *curr_pucch = &sched_ctrl->sched_pucch[0]; + if (curr_pucch->frame == SFN && curr_pucch->ul_slot == slot) { + if (curr_pucch->resource_indicator != found) { + LOG_W(MAC, "%4d.%2d expected PUCCH in this slot to have resource indicator of SR (%d), skipping SR\n", SFN, slot, found); + continue; + } + curr_pucch->sr_flag = true; + } else { + NR_sched_pucch_t sched_sr; + memset(&sched_sr, 0, sizeof(sched_sr)); + sched_sr.frame = SFN; + sched_sr.ul_slot = slot; + sched_sr.resource_indicator = found; + sched_sr.sr_flag = true; + nr_fill_nfapi_pucch(Mod_idP, SFN, slot, &sched_sr, UE_id); + } + } + } +} + + +void periodicity__SRR (NR_SchedulingRequestResourceConfig_t *SchedulingReqRec, int *period, int *offset) +{ + NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR P_O = SchedulingReqRec->periodicityAndOffset->present; + switch (P_O){ + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1: + *period = 1; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl1; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2: + *period = 2; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl2; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4: + *period = 4; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl4; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5: + *period = 5; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl5; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8: + *period = 8; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl8; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10: + *period = 10; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl10; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16: + *period = 16; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl16; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20: + *period = 20; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl20; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40: + *period = 40; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl40; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80: + *period = 80; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl80; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160: + *period = 160; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl160; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320: + *period = 320; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl320; + break; + case NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640: + *period = 640; + *offset = SchedulingReqRec->periodicityAndOffset->choice.sl640; + break; + default: + AssertFatal(1==0,"No periodicityAndOffset resources found in schedulingrequestresourceconfig"); + } +} + diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index aa1ed57a8d..11707268d6 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -32,6 +32,8 @@ #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "executables/softmodem-common.h" #include "common/utils/nr/nr_common.h" +#include + //38.321 Table 6.1.3.1-1 const uint32_t NR_SHORT_BSR_TABLE[32] = { @@ -61,13 +63,124 @@ const uint32_t NR_LONG_BSR_TABLE[256] ={ 35910462, 38241455, 40723756, 43367187, 46182206, 49179951, 52372284, 55771835, 59392055, 63247269, 67352729, 71724679, 76380419, 81338368, 162676736, 4294967295 }; -void nr_process_mac_pdu( - module_id_t module_idP, - rnti_t rnti, - uint8_t CC_id, - frame_t frameP, - uint8_t *pduP, - uint16_t mac_pdu_len) +void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp) +{ + gNB_MAC_INST *nrmac = RC.nrmac[module_id]; + const int bwp_id = ubwp->bwp_Id; + if (nrmac->preferred_ul_tda[bwp_id]) + return; + + /* there is a mixed slot only when in TDD */ + NR_ServingCellConfigCommon_t *scc = nrmac->common_channels->ServingCellConfigCommon; + const int mu = scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing; + const NR_TDD_UL_DL_Pattern_t *tdd = + scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL; + /* Uplink symbols are at the end of the slot */ + const int symb_ulMixed = tdd ? ((1 << tdd->nrofUplinkSymbols) - 1) << (14 - tdd->nrofUplinkSymbols) : 0; + + const struct NR_PUCCH_Config__resourceToAddModList *resList = ubwp->bwp_Dedicated->pucch_Config->choice.setup->resourceToAddModList; + // for the moment, just block any symbol that might hold a PUCCH, regardless + // of the RB. This is a big simplification, as most RBs will NOT have a PUCCH + // in the respective symbols, but it simplifies scheduling + uint16_t symb_pucch = 0; + for (int i = 0; i < resList->list.count; ++i) { + const NR_PUCCH_Resource_t *resource = resList->list.array[i]; + int nrofSymbols = 0; + int startingSymbolIndex = 0; + switch (resource->format.present) { + case NR_PUCCH_Resource__format_PR_format0: + nrofSymbols = resource->format.choice.format0->nrofSymbols; + startingSymbolIndex = resource->format.choice.format0->startingSymbolIndex; + break; + case NR_PUCCH_Resource__format_PR_format1: + nrofSymbols = resource->format.choice.format1->nrofSymbols; + startingSymbolIndex = resource->format.choice.format1->startingSymbolIndex; + break; + case NR_PUCCH_Resource__format_PR_format2: + nrofSymbols = resource->format.choice.format2->nrofSymbols; + startingSymbolIndex = resource->format.choice.format2->startingSymbolIndex; + break; + case NR_PUCCH_Resource__format_PR_format3: + nrofSymbols = resource->format.choice.format3->nrofSymbols; + startingSymbolIndex = resource->format.choice.format3->startingSymbolIndex; + break; + case NR_PUCCH_Resource__format_PR_format4: + nrofSymbols = resource->format.choice.format4->nrofSymbols; + startingSymbolIndex = resource->format.choice.format4->startingSymbolIndex; + break; + default: + AssertFatal(0, "found NR_PUCCH format index %d\n", resource->format.present); + break; + } + symb_pucch |= ((1 << nrofSymbols) - 1) << startingSymbolIndex; + } + + /* check that TDA index 1 fits into UL slot and does not overlap with PUCCH */ + const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + AssertFatal(tdaList->list.count >= 3, "need to have at least three TDAs for UL slots\n"); + const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_UL = tdaList->list.array[0]; + const int k2 = get_K2(scc, (NR_BWP_Uplink_t*)ubwp,0, mu); + int start, len; + SLIV2SL(tdaP_UL->startSymbolAndLength, &start, &len); + const uint16_t symb_tda = ((1 << len) - 1) << start; + // check whether PUCCH and TDA overlap: then, we cannot use it. Note that + // here we assume that the PUCCH is scheduled in every slot, and on all RBs + // (which is mostly not true, this is a simplification) + AssertFatal((symb_pucch & symb_tda) == 0, "TDA index 0 for UL overlaps with PUCCH\n"); + + // get largest time domain allocation (TDA) for UL slot and UL in mixed slot + int tdaMi = -1; + const NR_PUSCH_TimeDomainResourceAllocation_t *tdaP_Mi = tdaList->list.array[1]; + AssertFatal(k2 == get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu), + "scheduler cannot handle different k2 for UL slot (%d) and UL Mixed slot (%ld)\n", + k2, + get_K2(scc, (NR_BWP_Uplink_t*)ubwp, 1, mu)); + SLIV2SL(tdaP_Mi->startSymbolAndLength, &start, &len); + const uint16_t symb_tda_mi = ((1 << len) - 1) << start; + // check whether PUCCH and TDA overlap: then, we cannot use it. Also, check + // whether TDA is entirely within mixed slot, UL. Note that here we assume + // that the PUCCH is scheduled in every slot, and on all RBs (which is + // mostly not true, this is a simplification) + if ((symb_pucch & symb_tda_mi) == 0 && (symb_ulMixed & symb_tda_mi) == symb_tda_mi) { + tdaMi = 1; + } else { + LOG_E(MAC, + "TDA index 1 UL overlaps with PUCCH or is not entirely in mixed slot (symb_pucch %x symb_ulMixed %x symb_tda_mi %x), won't schedule UL mixed slot\n", + symb_pucch, + symb_ulMixed, + symb_tda_mi); + } + + const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160}; + const int n = slots_per_frame[*scc->ssbSubcarrierSpacing]; + nrmac->preferred_ul_tda[bwp_id] = malloc(n * sizeof(*nrmac->preferred_ul_tda[bwp_id])); + + const int nr_mix_slots = tdd ? tdd->nrofDownlinkSymbols != 0 || tdd->nrofUplinkSymbols != 0 : 0; + const int nr_slots_period = tdd ? tdd->nrofDownlinkSlots + tdd->nrofUplinkSlots + nr_mix_slots : n; + for (int slot = 0; slot < n; ++slot) { + const int sched_slot = (slot + k2) % n; + nrmac->preferred_ul_tda[bwp_id][slot] = -1; + if (!tdd || sched_slot % nr_slots_period >= tdd->nrofDownlinkSlots + nr_mix_slots) + nrmac->preferred_ul_tda[bwp_id][slot] = 0; + else if (tdd && nr_mix_slots && sched_slot % nr_slots_period == tdd->nrofDownlinkSlots) + nrmac->preferred_ul_tda[bwp_id][slot] = tdaMi; + LOG_I(MAC, "DL slot %d UL slot %d preferred_ul_tda %d\n", slot, sched_slot, nrmac->preferred_ul_tda[bwp_id][slot]); + } + + if (k2 < tdd->nrofUplinkSlots) + LOG_W(MAC, + "k2 %d < tdd->nrofUplinkSlots %ld: not all UL slots can be scheduled\n", + k2, + tdd->nrofUplinkSlots); +} + +void nr_process_mac_pdu(module_id_t module_idP, + int UE_id, + uint8_t CC_id, + frame_t frameP, + sub_frame_t slot, + uint8_t *pduP, + uint16_t mac_pdu_len) { // This function is adapting code from the old @@ -78,12 +191,11 @@ void nr_process_mac_pdu( uint16_t mac_ce_len, mac_subheader_len, mac_sdu_len; NR_UE_info_t *UE_info = &RC.nrmac[module_idP]->UE_info; - int UE_id = find_nr_UE_id(module_idP, rnti); - if (UE_id == -1) { - LOG_E(NR_MAC, "%s() UE_id == -1\n",__func__); - return; - } NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + + if ( pduP[0] != UL_SCH_LCID_PADDING ) + trace_NRpdu(DIRECTION_UPLINK, pduP, mac_pdu_len ,UE_id, WS_C_RNTI, UE_info->rnti[UE_id], frameP, 0, 0, 0); + // For both DL/UL-SCH // Except: // - UL/DL-SCH: fixed-size MAC CE(known by LCID) @@ -144,12 +256,15 @@ void nr_process_mac_pdu( NR_BSR_SHORT *bsr_s = (NR_BSR_SHORT *) ce_ptr; sched_ctrl->estimated_ul_buffer = 0; sched_ctrl->estimated_ul_buffer = NR_SHORT_BSR_TABLE[bsr_s->Buffer_size]; - LOG_D(NR_MAC, "SHORT BSR, LCG ID %d, BS Index %d, BS value < %d, est buf %d\n", + LOG_D(NR_MAC, + "SHORT BSR at %4d.%2d, LCG ID %d, BS Index %d, BS value < %d, est buf %d\n", + frameP, + slot, bsr_s->LcgID, bsr_s->Buffer_size, NR_SHORT_BSR_TABLE[bsr_s->Buffer_size], sched_ctrl->estimated_ul_buffer); - break; + break; case UL_SCH_LCID_L_BSR: case UL_SCH_LCID_L_TRUNCATED_BSR: @@ -179,6 +294,15 @@ void nr_process_mac_pdu( NR_LONG_BSR_TABLE[pdu_ptr[mac_subheader_len + 1 + n]]); sched_ctrl->estimated_ul_buffer += NR_LONG_BSR_TABLE[pdu_ptr[mac_subheader_len + 1 + n]]; + LOG_D(NR_MAC, + "LONG BSR at %4d.%2d, %d/%d (n/n_Lcg), BS Index %d, BS value < %d, total %d\n", + frameP, + slot, + n, + n_Lcg, + pdu_ptr[mac_subheader_len + 1 + n], + NR_LONG_BSR_TABLE[pdu_ptr[mac_subheader_len + 1 + n]], + sched_ctrl->estimated_ul_buffer); } break; @@ -195,6 +319,20 @@ void nr_process_mac_pdu( //fixed length mac_ce_len = 2; /* Extract SINGLE ENTRY PHR elements for PHR calculation */ + ce_ptr = &pdu_ptr[mac_subheader_len]; + NR_SINGLE_ENTRY_PHR_MAC_CE *phr = (NR_SINGLE_ENTRY_PHR_MAC_CE *) ce_ptr; + /* Save the phr info */ + const int PH = phr->PH; + const int PCMAX = phr->PCMAX; + /* 38.133 Table10.1.17.1-1 */ + if (PH < 55) + sched_ctrl->ph = PH - 32; + else + sched_ctrl->ph = PH - 32 + (PH - 54); + /* 38.133 Table10.1.18.1-1 */ + sched_ctrl->pcmax = PCMAX - 29; + LOG_D(MAC, "SINGLE ENTRY PHR R1 %d PH %d (%d dB) R2 %d PCMAX %d (%d dBm)\n", + phr->R1, PH, sched_ctrl->ph, phr->R2, PCMAX, sched_ctrl->pcmax); break; case UL_SCH_LCID_MULTI_ENTRY_PHR_1_OCT: @@ -237,18 +375,18 @@ void nr_process_mac_pdu( mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L; mac_subheader_len = 2; } - LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, rnti); + LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, UE_info->rnti[UE_id]); mac_rlc_data_ind(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcid, - (char *) (pdu_ptr + mac_subheader_len), - mac_sdu_len, - 1, - NULL); + UE_info->rnti[UE_id], + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + rx_lcid, + (char *) (pdu_ptr + mac_subheader_len), + mac_sdu_len, + 1, + NULL); break; case UL_SCH_LCID_SRB3: // todo @@ -285,7 +423,7 @@ void nr_process_mac_pdu( frameP, 0, 0, - rnti, + UE_info->rnti[UE_id], CCCH, pdu_ptr+mac_subheader_len, mac_sdu_len, @@ -293,48 +431,51 @@ void nr_process_mac_pdu( break; case UL_SCH_LCID_DTCH: - // check if LCID is valid at current time. - if(((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F){ - //mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8; - mac_subheader_len = 3; - mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *) pdu_ptr)->L1 & 0x7f) << 8) - | ((uint16_t)((NR_MAC_SUBHEADER_LONG *) pdu_ptr)->L2 & 0xff); + // check if LCID is valid at current time. + if (((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->F) { + // mac_sdu_len |= (uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2)<<8; + mac_subheader_len = 3; + mac_sdu_len = ((uint16_t)(((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L1 & 0x7f) << 8) + | ((uint16_t)((NR_MAC_SUBHEADER_LONG *)pdu_ptr)->L2 & 0xff); - } else { - mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L; - mac_subheader_len = 2; - } + } else { + mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L; + mac_subheader_len = 2; + } - LOG_I(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-%s %d (gNB %d, %d bytes)\n", module_idP, frameP, rx_lcid<4?"DCCH":"DTCH",rx_lcid, module_idP, mac_sdu_len); - int UE_id = find_nr_UE_id(module_idP, rnti); - RC.nrmac[module_idP]->UE_info.mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len; - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - log_dump(NR_MAC, pdu_ptr + mac_subheader_len, 32, LOG_DUMP_CHAR, "\n"); + LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-%s %d (gNB %d, %d bytes)\n", + module_idP, + frameP, + rx_lcid<4?"DCCH":"DTCH", + rx_lcid, + module_idP, + mac_sdu_len); + UE_info->mac_stats[UE_id].lc_bytes_rx[rx_lcid] += mac_sdu_len; +#if defined(ENABLE_MAC_PAYLOAD_DEBUG) + log_dump(NR_MAC, pdu_ptr + mac_subheader_len, 32, LOG_DUMP_CHAR, "\n"); +#endif - #endif + mac_rlc_data_ind(module_idP, + UE_info->rnti[UE_id], + module_idP, + frameP, + ENB_FLAG_YES, + MBMS_FLAG_NO, + rx_lcid, + (char *)(pdu_ptr + mac_subheader_len), + mac_sdu_len, + 1, + NULL); - mac_rlc_data_ind(module_idP, - rnti, - module_idP, - frameP, - ENB_FLAG_YES, - MBMS_FLAG_NO, - rx_lcid, - (char *) (pdu_ptr + mac_subheader_len), - mac_sdu_len, - 1, - NULL); - - /* Updated estimated buffer when receiving data */ - if (sched_ctrl->estimated_ul_buffer >= mac_sdu_len) - sched_ctrl->estimated_ul_buffer -= mac_sdu_len; - else - sched_ctrl->estimated_ul_buffer = 0; - - break; + /* Updated estimated buffer when receiving data */ + if (sched_ctrl->estimated_ul_buffer >= mac_sdu_len) + sched_ctrl->estimated_ul_buffer -= mac_sdu_len; + else + sched_ctrl->estimated_ul_buffer = 0; + break; default: - LOG_D(NR_MAC, "Received unknown MAC header (LCID = 0x%02x)\n", rx_lcid); + LOG_E(NR_MAC, "Received unknown MAC header (LCID = 0x%02x)\n", rx_lcid); return; break; } @@ -352,6 +493,24 @@ void nr_process_mac_pdu( } } +void abort_nr_ul_harq(module_id_t mod_id, int UE_id, int8_t harq_pid) +{ + NR_UE_info_t *UE_info = &RC.nrmac[mod_id]->UE_info; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_UE_ul_harq_t *harq = &sched_ctrl->ul_harq_processes[harq_pid]; + + harq->ndi ^= 1; + harq->round = 0; + UE_info->mac_stats[UE_id].ulsch_errors++; + add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); + + /* the transmission failed: the UE won't send the data we expected initially, + * so retrieve to correctly schedule after next BSR */ + sched_ctrl->sched_ul_bytes -= harq->sched_pusch.tb_size; + if (sched_ctrl->sched_ul_bytes < 0) + sched_ctrl->sched_ul_bytes = 0; +} + void handle_nr_ul_harq(module_id_t mod_id, frame_t frame, sub_frame_t slot, @@ -377,11 +536,8 @@ void handle_nr_ul_harq(module_id_t mod_id, remove_front_nr_list(&sched_ctrl->feedback_ul_harq); sched_ctrl->ul_harq_processes[harq_pid].is_waiting = false; - if(sched_ctrl->ul_harq_processes[harq_pid].round == MAX_HARQ_ROUNDS) { - sched_ctrl->ul_harq_processes[harq_pid].ndi ^= 1; - sched_ctrl->ul_harq_processes[harq_pid].round = 0; - UE_info->mac_stats[UE_id].ulsch_errors++; - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); + if(sched_ctrl->ul_harq_processes[harq_pid].round >= MAX_HARQ_ROUNDS - 1) { + abort_nr_ul_harq(mod_id, UE_id, harq_pid); } else { sched_ctrl->ul_harq_processes[harq_pid].round++; add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid); @@ -401,26 +557,22 @@ void handle_nr_ul_harq(module_id_t mod_id, harq_pid, crc_pdu->rnti); add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); + } else if (harq->round >= MAX_HARQ_ROUNDS - 1) { + abort_nr_ul_harq(mod_id, UE_id, harq_pid); + LOG_D(NR_MAC, + "RNTI %04x: Ulharq id %d crc failed in all rounds\n", + crc_pdu->rnti, + harq_pid); } else { harq->round++; - if (harq->round == MAX_HARQ_ROUNDS) { - harq->ndi ^= 1; - harq->round = 0; - LOG_D(NR_MAC, - "RNTI %04x: Ulharq id %d crc failed in all rounds\n", - crc_pdu->rnti, - harq_pid); - UE_info->mac_stats[UE_id].ulsch_errors++; - add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); - } else { - LOG_D(NR_MAC, - "Ulharq id %d crc failed for RNTI %04x\n", - harq_pid, - crc_pdu->rnti); - add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid); - } + LOG_D(NR_MAC, + "Ulharq id %d crc failed for RNTI %04x\n", + harq_pid, + crc_pdu->rnti); + add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid); } } + /* * When data are received on PHY and transmitted to MAC */ @@ -441,6 +593,7 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, const int UE_id = find_nr_UE_id(gnb_mod_idP, current_rnti); const int target_snrx10 = gNB_mac->pusch_target_snrx10; const int pusch_failure_thres = gNB_mac->pusch_failure_thres; + if (UE_id != -1) { NR_UE_sched_ctrl_t *UE_scheduling_control = &UE_info->UE_sched_ctrl[UE_id]; const int8_t harq_pid = UE_scheduling_control->feedback_ul_harq.head; @@ -464,11 +617,12 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, sduP); // if not missed detection (10dB threshold for now) - if (UE_scheduling_control->ul_rssi < (100+rssi)) { + if (UE_scheduling_control->raw_rssi < 100 + rssi) { UE_scheduling_control->tpc0 = nr_get_tpc(target_snrx10,ul_cqi,30); if (timing_advance != 0xffff) UE_scheduling_control->ta_update = timing_advance; - UE_scheduling_control->ul_rssi = rssi; + UE_scheduling_control->raw_rssi = rssi; + UE_scheduling_control->pusch_snrx10 = ul_cqi * 5 - 640; LOG_D(NR_MAC, "[UE %d] PUSCH TPC %d and TA %d\n",UE_id,UE_scheduling_control->tpc0,UE_scheduling_control->ta_update); } else{ @@ -490,13 +644,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, if (sduP != NULL){ LOG_D(NR_MAC, "Received PDU at MAC gNB \n"); - UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt = 0; + UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt = 0; const uint32_t tb_size = UE_scheduling_control->ul_harq_processes[harq_pid].sched_pusch.tb_size; UE_scheduling_control->sched_ul_bytes -= tb_size; if (UE_scheduling_control->sched_ul_bytes < 0) UE_scheduling_control->sched_ul_bytes = 0; - nr_process_mac_pdu(gnb_mod_idP, current_rnti, CC_idP, frameP, sduP, sdu_lenP); + nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP); } else { NR_UE_ul_harq_t *cur_harq = &UE_scheduling_control->ul_harq_processes[harq_pid]; @@ -512,13 +666,13 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, UE_info->mac_stats[UE_id].ulsch_DTX++; } if (UE_info->UE_sched_ctrl[UE_id].pusch_consecutive_dtx_cnt >= pusch_failure_thres) { - LOG_I(NR_MAC,"Detected UL Failure on PUSCH, stopping scheduling\n"); + LOG_D(NR_MAC,"Detected UL Failure on PUSCH, stopping scheduling\n"); UE_info->UE_sched_ctrl[UE_id].ul_failure = 1; + nr_mac_gNB_rrc_ul_failure(gnb_mod_idP,CC_idP,frameP,slotP,rntiP); } } } else if(sduP) { - bool no_sig = true; for (int k = 0; k < sdu_lenP; k++) { if(sduP[k]!=0) { @@ -564,48 +718,49 @@ void nr_rx_sdu(const module_id_t gnb_mod_idP, continue; } - int UE_id=-1; - - UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->CellGroup); - UE_info->UE_beam_index[UE_id] = ra->beam_id; - - // re-initialize ta update variables after RA procedure completion - UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; - - LOG_I(NR_MAC, - "reset RA state information for RA-RNTI %04x/index %d\n", - ra->rnti, - i); - - LOG_I(NR_MAC, - "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, " - "adding UE MAC Context UE_id %d/RNTI %04x\n", - gnb_mod_idP, - current_rnti, - UE_id, - ra->rnti); - - if (ra->cfra) { - - LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); - nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); - nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); - UE_info->active[UE_id] = true; - - } else { - - LOG_I(NR_MAC,"[RAPROC] RA-Msg3 received (sdu_lenP %d)\n",sdu_lenP); - LOG_D(NR_MAC,"[RAPROC] Received Msg3:\n"); - for (int k = 0; k < sdu_lenP; k++) { - LOG_D(NR_MAC,"(%i): 0x%x\n",k,sduP[k]); - } - + + int UE_id=-1; + + UE_id = add_new_nr_ue(gnb_mod_idP, ra->rnti, ra->CellGroup); + UE_info->UE_beam_index[UE_id] = ra->beam_id; + + // re-initialize ta update variables after RA procedure completion + UE_info->UE_sched_ctrl[UE_id].ta_frame = frameP; + + LOG_I(NR_MAC, + "reset RA state information for RA-RNTI %04x/index %d\n", + ra->rnti, + i); + + LOG_I(NR_MAC, + "[gNB %d][RAPROC] PUSCH with TC_RNTI %x received correctly, " + "adding UE MAC Context UE_id %d/RNTI %04x\n", + gnb_mod_idP, + current_rnti, + UE_id, + ra->rnti); + + if(ra->cfra) { + + LOG_I(NR_MAC, "(ue %i, rnti 0x%04x) CFRA procedure succeeded!\n", UE_id, ra->rnti); + nr_mac_remove_ra_rnti(gnb_mod_idP, ra->rnti); + nr_clear_ra_proc(gnb_mod_idP, CC_idP, frameP, ra); + UE_info->active[UE_id] = true; + + } else { + + LOG_I(NR_MAC,"[RAPROC] RA-Msg3 received (sdu_lenP %d)\n",sdu_lenP); + LOG_D(NR_MAC,"[RAPROC] Received Msg3:\n"); + for (int k = 0; k < sdu_lenP; k++) { + LOG_D(NR_MAC,"(%i): 0x%x\n",k,sduP[k]); + } + // UE Contention Resolution Identity // Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to fill in Msg4 // First byte corresponds to R/LCID MAC sub-header memcpy(ra->cont_res_id, &sduP[1], sizeof(uint8_t) * 6); - nr_process_mac_pdu(gnb_mod_idP, current_rnti, CC_idP, frameP, sduP, sdu_lenP); + nr_process_mac_pdu(gnb_mod_idP, UE_id, CC_idP, frameP, slotP, sduP, sdu_lenP); ra->state = Msg4; ra->Msg4_frame = ( frameP +2 ) % 1024; @@ -644,6 +799,34 @@ long get_K2(NR_ServingCellConfigCommon_t *scc,NR_BWP_Uplink_t *ubwp, int time_do return 3; } +bool nr_UE_is_to_be_scheduled(module_id_t mod_id, int CC_id, int UE_id, frame_t frame, sub_frame_t slot) +{ + const NR_ServingCellConfigCommon_t *scc = RC.nrmac[mod_id]->common_channels->ServingCellConfigCommon; + const uint8_t slots_per_frame[5] = {10, 20, 40, 80, 160}; + const int n = slots_per_frame[*scc->ssbSubcarrierSpacing]; + const int now = frame * n + slot; + + const struct gNB_MAC_INST_s *nrmac = RC.nrmac[mod_id]; + const NR_UE_sched_ctrl_t *sched_ctrl = &nrmac->UE_info.UE_sched_ctrl[UE_id]; + const int last_ul_sched = sched_ctrl->last_ul_frame * n + sched_ctrl->last_ul_slot; + + const int diff = (now - last_ul_sched + 1024 * n) % (1024 * n); + /* UE is to be scheduled if + * (1) we think the UE has more bytes awaiting than what we scheduled + * (2) there is a scheduling request + * (3) or we did not schedule it in more than 10 frames */ + const bool has_data = sched_ctrl->estimated_ul_buffer > sched_ctrl->sched_ul_bytes; + const bool high_inactivity = diff >= nrmac->ulsch_max_slots_inactivity; + LOG_D(MAC, + "%4d.%2d UL inactivity %d slots has_data %d SR %d\n", + frame, + slot, + diff, + has_data, + sched_ctrl->SR); + return has_data || sched_ctrl->SR || high_inactivity; +} + int next_list_entry_looped(NR_list_t *list, int UE_id) { if (UE_id < 0) @@ -651,145 +834,195 @@ int next_list_entry_looped(NR_list_t *list, int UE_id) return list->next[UE_id] < 0 ? list->head : list->next[UE_id]; } +bool allocate_ul_retransmission(module_id_t module_id, + frame_t frame, + sub_frame_t slot, + uint8_t *rballoc_mask, + int *n_rb_sched, + int UE_id, + int harq_pid) +{ + const int CC_id = 0; + const NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; + NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; + NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; + NR_sched_pusch_t *retInfo = &sched_ctrl->ul_harq_processes[harq_pid].sched_pusch; + + NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; + const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + + const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_bwp ? 1 : 2; + const int tda = sched_ctrl->active_ubwp ? RC.nrmac[module_id]->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 1; + if (tda == retInfo->time_domain_allocation) { + /* Check the resource is enough for retransmission */ + while (rbStart < bwpSize && !rballoc_mask[rbStart]) + rbStart++; + if (rbStart + retInfo->rbSize >= bwpSize) { + LOG_D(MAC, "cannot allocate retransmission of UE %d/RNTI %04x: no resources\n", UE_id, UE_info->rnti[UE_id]); + return false; + } + /* check whether we need to switch the TDA allocation since tha last + * (re-)transmission */ + NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + if (ps->time_domain_allocation != tda + || ps->dci_format != dci_format + || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + LOG_D(MAC, "%s(): retransmission keeping TDA %d and TBS %d\n", __func__, tda, retInfo->tb_size); + } else { + /* the retransmission will use a different time domain allocation, check + * that we have enough resources */ + while (rbStart < bwpSize && !rballoc_mask[rbStart]) + rbStart++; + int rbSize = 0; + while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart + rbSize]) + rbSize++; + NR_pusch_semi_static_t temp_ps; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, &temp_ps); + uint32_t new_tbs; + uint16_t new_rbSize; + bool success = nr_find_nb_rb(retInfo->Qm, + retInfo->R, + temp_ps.nrOfSymbols, + temp_ps.N_PRB_DMRS * temp_ps.num_dmrs_symb, + retInfo->tb_size, + rbSize, + &new_tbs, + &new_rbSize); + if (!success || new_tbs != retInfo->tb_size) { + LOG_D(MAC, "%s(): new TBsize %d of new TDA does not match old TBS %d\n", __func__, new_tbs, retInfo->tb_size); + return false; /* the maximum TBsize we might have is smaller than what we need */ + } + LOG_D(MAC, "%s(): retransmission with TDA %d->%d and TBS %d -> %d\n", __func__, retInfo->time_domain_allocation, tda, retInfo->tb_size, new_tbs); + /* we can allocate it. Overwrite the time_domain_allocation, the number + * of RBs, and the new TB size. The rest is done below */ + retInfo->tb_size = new_tbs; + retInfo->rbSize = new_rbSize; + retInfo->time_domain_allocation = tda; + sched_ctrl->pusch_semi_static = temp_ps; + } + + /* Find free CCE */ + bool freeCCE = find_free_CCE(module_id, slot, UE_id); + if (!freeCCE) { + LOG_D(MAC, "%4d.%2d no free CCE for retransmission UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); + return false; + } + + /* frame/slot in sched_pusch has been set previously. In the following, we + * overwrite the information in the retransmission information before storing + * as the new scheduling instruction */ + retInfo->frame = sched_ctrl->sched_pusch.frame; + retInfo->slot = sched_ctrl->sched_pusch.slot; + /* Get previous PSUCH field info */ + sched_ctrl->sched_pusch = *retInfo; + NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; + + LOG_D(MAC, + "%4d.%2d Allocate UL retransmission UE %d/RNTI %04x sched %4d.%2d (%d RBs)\n", + frame, + slot, + UE_id, + UE_info->rnti[UE_id], + sched_pusch->frame, + sched_pusch->slot, + sched_pusch->rbSize); + + sched_pusch->rbStart = rbStart; + /* no need to recompute the TBS, it will be the same */ + + /* Mark the corresponding RBs as used */ + n_rb_sched -= sched_pusch->rbSize; + for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) + rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; + return true; +} + +void update_ul_ue_R_Qm(NR_sched_pusch_t *sched_pusch, const NR_pusch_semi_static_t *ps) +{ + const int mcs = sched_pusch->mcs; + sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table); + sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table); + + if (ps->pusch_Config && ps->pusch_Config->tp_pi2BPSK && ((ps->mcs_table == 3 && mcs < 2) || (ps->mcs_table == 4 && mcs < 6))) { + sched_pusch->R >>= 1; + sched_pusch->Qm <<= 1; + } +} + float ul_thr_ue[MAX_MOBILES_PER_GNB]; -int bsr0ue = -1; +uint32_t ul_pf_tbs[3][29]; // pre-computed, approximate TBS values for PF coefficient void pf_ul(module_id_t module_id, frame_t frame, sub_frame_t slot, - int num_slots_per_tdd, NR_list_t *UE_list, + int max_num_ue, int n_rb_sched, - uint8_t *rballoc_mask, - int max_num_ue) { + uint8_t *rballoc_mask) { const int CC_id = 0; - const int tda = 1; - NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[CC_id].ServingCellConfigCommon; - NR_UE_info_t *UE_info = &RC.nrmac[module_id]->UE_info; - const int min_rb = 5; + gNB_MAC_INST *nrmac = RC.nrmac[module_id]; + NR_ServingCellConfigCommon_t *scc = nrmac->common_channels[CC_id].ServingCellConfigCommon; + NR_UE_info_t *UE_info = &nrmac->UE_info; + const int min_rb = 20; float coeff_ue[MAX_MOBILES_PER_GNB]; // UEs that could be scheduled int ue_array[MAX_MOBILES_PER_GNB]; NR_list_t UE_sched = { .head = -1, .next = ue_array, .tail = -1, .len = MAX_MOBILES_PER_GNB }; - /* Hack: currently, we do not have SR, and need to schedule UEs continuously. - * To keep the wasted resources low, we switch UEs to be scheduled in a - * round-robin fashion below, and only schedule a UE with BSR=0 if it is the - * selected one */ - bsr0ue = next_list_entry_looped(UE_list, bsr0ue); - /* Loop UE_list to calculate throughput and coeff */ for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { if (UE_info->Msg4_ACKed[UE_id] != true) continue; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - int rbStart = 0; /*NRRIV2PRBOFFSET(sched_ctrl->active_bwp ? - sched_ctrl->active_bwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE);*/ - const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_ubwp? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); + NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; + const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); + NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; + NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; /* Calculate throughput */ const float a = 0.0005f; // corresponds to 200ms window const uint32_t b = UE_info->mac_stats[UE_id].ulsch_current_bytes; ul_thr_ue[UE_id] = (1 - a) * ul_thr_ue[UE_id] + a * b; - /* Save PUSCH field */ - /* we want to avoid a lengthy deduction of DMRS and other parameters in - * every TTI if we can save it, so check whether dci_format, TDA, or - * num_dmrs_cdm_grps_no_data has changed and only then recompute */ - sched_ctrl->sched_pusch.time_domain_allocation = tda; - NR_BWP_DownlinkDedicated_t *bwp_Dedicated=NULL; - if (sched_ctrl->active_bwp) bwp_Dedicated = sched_ctrl->active_bwp->bwp_Dedicated; - else if (UE_info->CellGroup[UE_id] && - UE_info->CellGroup[UE_id]->spCellConfig && - UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated) - bwp_Dedicated = UE_info->CellGroup[UE_id]->spCellConfig->spCellConfigDedicated->initialDownlinkBWP; - sched_ctrl->search_space = get_searchspace(scc,bwp_Dedicated, - bwp_Dedicated ? - NR_SearchSpace__searchSpaceType_PR_ue_Specific: - NR_SearchSpace__searchSpaceType_PR_common); - sched_ctrl->coreset = get_coreset(scc,sched_ctrl->active_bwp, sched_ctrl->search_space, 1 /* dedicated */); - if (sched_ctrl->coreset == NULL) sched_ctrl->coreset = RC.nrmac[module_id]->sched_ctrlCommon->coreset; - const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; - const int dci_format = sched_ctrl->active_bwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; - const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_bwp ? 1 : 2; - NR_sched_pusch_save_t *ps = &sched_ctrl->pusch_save; - if (ps->time_domain_allocation != tda - || ps->dci_format != dci_format - || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) - nr_save_pusch_fields(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); - /* Check if retransmission is necessary */ - sched_ctrl->sched_pusch.ul_harq_pid = sched_ctrl->retrans_ul_harq.head; - if (sched_ctrl->sched_pusch.ul_harq_pid >= 0) { - /* RETRANSMISSION: Allocate retransmission*/ - /* Find free CCE */ - bool freeCCE = find_free_CCE(module_id, slot, UE_id); - if (!freeCCE) { - LOG_D(NR_MAC, "%4d.%2d no free CCE for retransmission UL DCI UE %04x\n", frame, slot, UE_info->rnti[UE_id]); + sched_pusch->ul_harq_pid = sched_ctrl->retrans_ul_harq.head; + if (sched_pusch->ul_harq_pid >= 0) { + /* Allocate retransmission*/ + bool r = allocate_ul_retransmission( + module_id, frame, slot, rballoc_mask, &n_rb_sched, UE_id, sched_pusch->ul_harq_pid); + if (!r) { + LOG_D(MAC, "%4d.%2d UL retransmission UE RNTI %04x can NOT be allocated\n", frame, slot, UE_info->rnti[UE_id]); continue; } /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ max_num_ue--; if (max_num_ue < 0) return; - - /* Save shced_frame and sched_slot before overwrite by previous PUSCH filed */ - NR_UE_ul_harq_t *cur_harq = &sched_ctrl->ul_harq_processes[sched_ctrl->sched_pusch.ul_harq_pid]; - cur_harq->sched_pusch.frame = sched_ctrl->sched_pusch.frame; - cur_harq->sched_pusch.slot = sched_ctrl->sched_pusch.slot; - /* Get previous PSUCH filed info */ - sched_ctrl->sched_pusch = cur_harq->sched_pusch; - NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; - LOG_D(NR_MAC, "%4d.%2d Allocate UL retransmission UE %d/RNTI %04x sched %4d.%2d (%d RBs)\n", - frame, slot, UE_id, UE_info->rnti[UE_id], - sched_pusch->frame, sched_pusch->slot, - sched_pusch->rbSize); - - while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; - if (rbStart + sched_pusch->rbSize >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate UL data for UE %d/RNTI %04x: no resources (rbStart %d, sched_pusch->rbSize %d, bwpSize %d)\n", - UE_id, UE_info->rnti[UE_id],rbStart,sched_pusch->rbSize,bwpSize); - return; - } - sched_pusch->rbStart = rbStart; - /* no need to recompute the TBS, it will be the same */ - - /* Mark the corresponding RBs as used */ - n_rb_sched -= sched_pusch->rbSize; - for (int rb = 0; rb < sched_ctrl->sched_pusch.rbSize; rb++) - rballoc_mask[rb + sched_ctrl->sched_pusch.rbStart] = 0; - continue; } - /* Calculate TBS from MCS */ - NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; - const int mcs = 9; - sched_pusch->mcs = mcs; - sched_pusch->R = nr_get_code_rate_ul(mcs, ps->mcs_table); - sched_pusch->Qm = nr_get_Qm_ul(mcs, ps->mcs_table); - LOG_D(NR_MAC, "Fixme: work around a NULL pointer (set in function nr_save_pusch_fields that is actually called)\n"); - if (ps->pusch_Config && (ps->pusch_Config->tp_pi2BPSK - && ((ps->mcs_table == 3 && mcs < 2) || (ps->mcs_table == 4 && mcs < 6)))) { - sched_pusch->R >>= 1; - sched_pusch->Qm <<= 1; - } + const int B = max(0, sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes); + /* preprocessor computed sched_frame/sched_slot */ + const bool do_sched = nr_UE_is_to_be_scheduled(module_id, 0, UE_id, sched_pusch->frame, sched_pusch->slot); - /* Check BSR and schedule UE if it is zero to avoid starvation, since we do - * not have SR (yet) */ - if (sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes <= 0) { - if (UE_id != bsr0ue) - continue; + if (B == 0 && !do_sched) + continue; + + /* Schedule UE on SR or UL inactivity and no data (otherwise, will be scheduled + * based on data to transmit) */ + if (B == 0 && do_sched) { /* if no data, pre-allocate 5RB */ bool freeCCE = find_free_CCE(module_id, slot, UE_id); if (!freeCCE) { - LOG_I(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x (BSR 0)\n", frame, slot, UE_info->rnti[UE_id]); + LOG_D(NR_MAC, "%4d.%2d no free CCE for UL DCI UE %04x (BSR 0)\n", frame, slot, UE_info->rnti[UE_id]); continue; } /* reduce max_num_ue once we are sure UE can be allocated, i.e., has CCE */ @@ -800,10 +1033,26 @@ void pf_ul(module_id_t module_id, LOG_D(NR_MAC,"Looking for min_rb %d RBs, starting at %d\n", min_rb,rbStart); while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; if (rbStart + min_rb >= bwpSize) { - LOG_W(NR_MAC, "cannot allocate UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", + LOG_W(NR_MAC, "cannot allocate continuous UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); return; } + + /* Save PUSCH field */ + /* we want to avoid a lengthy deduction of DMRS and other parameters in + * every TTI if we can save it, so check whether dci_format, TDA, or + * num_dmrs_cdm_grps_no_data has changed and only then recompute */ + const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_ubwp ? 1 : 2; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 1; + if (ps->time_domain_allocation != tda + || ps->dci_format != dci_format + || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; + sched_pusch->mcs = 9; + update_ul_ue_R_Qm(sched_pusch, ps); sched_pusch->rbStart = rbStart; sched_pusch->rbSize = min_rb; sched_pusch->tb_size = nr_compute_tbs(sched_pusch->Qm, @@ -828,15 +1077,8 @@ void pf_ul(module_id_t module_id, add_tail_nr_list(&UE_sched, UE_id); /* Calculate coefficient*/ - const uint32_t tbs = nr_compute_tbs(sched_pusch->Qm, - sched_pusch->R, - 1, // rbSize - ps->nrOfSymbols, - ps->N_PRB_DMRS * ps->num_dmrs_symb, - 0, // nb_rb_oh - 0, - 1 /* NrOfLayers */) - >> 3; + sched_pusch->mcs = 9; + const uint32_t tbs = ul_pf_tbs[ps->mcs_table][sched_pusch->mcs]; coeff_ue[UE_id] = (float) tbs / ul_thr_ue[UE_id]; LOG_D(NR_MAC,"b %d, ul_thr_ue[%d] %f, tbs %d, coeff_ue[%d] %f\n", b, UE_id, ul_thr_ue[UE_id], tbs, UE_id, coeff_ue[UE_id]); @@ -874,38 +1116,53 @@ void pf_ul(module_id_t module_id, return; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters:&scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; - int rbStart = 0; /*NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);*/ + NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters : &scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + int rbStart = sched_ctrl->active_ubwp ? NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE) : 0; const uint16_t bwpSize = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; - + NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; while (rbStart < bwpSize && !rballoc_mask[rbStart]) rbStart++; sched_pusch->rbStart = rbStart; + uint16_t max_rbSize = 1; + while (rbStart + max_rbSize < bwpSize && rballoc_mask[rbStart + max_rbSize]) + max_rbSize++; + if (rbStart + min_rb >= bwpSize) { LOG_W(NR_MAC, "cannot allocate UL data for UE %d/RNTI %04x: no resources (rbStart %d, min_rb %d, bwpSize %d\n", UE_id, UE_info->rnti[UE_id],rbStart,min_rb,bwpSize); return; } - /* Calculate the current scheduling bytes */ + /* Save PUSCH field */ + /* we want to avoid a lengthy deduction of DMRS and other parameters in + * every TTI if we can save it, so check whether dci_format, TDA, or + * num_dmrs_cdm_grps_no_data has changed and only then recompute */ + const uint8_t num_dmrs_cdm_grps_no_data = sched_ctrl->active_ubwp ? 1 : 2; + const long f = sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats; + const int dci_format = sched_ctrl->active_ubwp ? (f ? NR_UL_DCI_FORMAT_0_1 : NR_UL_DCI_FORMAT_0_0) : NR_UL_DCI_FORMAT_0_0; + const int tda = sched_ctrl->active_ubwp ? nrmac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 1; + if (ps->time_domain_allocation != tda + || ps->dci_format != dci_format + || ps->num_dmrs_cdm_grps_no_data != num_dmrs_cdm_grps_no_data) + nr_set_pusch_semi_static(scc, sched_ctrl->active_ubwp, dci_format, tda, num_dmrs_cdm_grps_no_data, ps); + update_ul_ue_R_Qm(sched_pusch, ps); + + /* Calculate the current scheduling bytes and the necessary RBs */ const int B = cmax(sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes, 0); - uint16_t rbSize = min_rb - 1; - do { - rbSize++; - sched_pusch->rbSize = rbSize; - sched_pusch->tb_size = nr_compute_tbs(sched_pusch->Qm, - sched_pusch->R, - sched_pusch->rbSize, - sched_ctrl->pusch_save.nrOfSymbols, - sched_ctrl->pusch_save.N_PRB_DMRS * sched_ctrl->pusch_save.num_dmrs_symb, - 0, // nb_rb_oh - 0, - 1 /* NrOfLayers */) - >> 3; - } while (rbStart + rbSize < bwpSize && rballoc_mask[rbStart+rbSize] && - sched_pusch->tb_size < B); - LOG_D(NR_MAC,"rbSize %d, TBS %d, est buf %d, sched_ul %d, B %d\n", + uint16_t rbSize = 0; + uint32_t TBS = 0; + nr_find_nb_rb(sched_pusch->Qm, + sched_pusch->R, + ps->nrOfSymbols, + ps->N_PRB_DMRS * ps->num_dmrs_symb, + B, + max_rbSize, + &TBS, + &rbSize); + sched_pusch->rbSize = rbSize; + sched_pusch->tb_size = TBS; + LOG_D(MAC,"rbSize %d, TBS %d, est buf %d, sched_ul %d, B %d\n", rbSize, sched_pusch->tb_size, sched_ctrl->estimated_ul_buffer, sched_ctrl->sched_ul_bytes, B); /* Mark the corresponding RBs as used */ @@ -915,11 +1172,8 @@ void pf_ul(module_id_t module_id, } } -bool nr_simple_ulsch_preprocessor(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - int num_slots_per_tdd, - uint64_t ulsch_in_slot_bitmap) { +bool nr_fr1_ulsch_preprocessor(module_id_t module_id, frame_t frame, sub_frame_t slot) +{ gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; @@ -931,30 +1185,23 @@ bool nr_simple_ulsch_preprocessor(module_id_t module_id, const int CC_id = 0; - /* NOT support different K2 in here, Get the K2 for first UE */ + /* Get the K2 for first UE to compute offset. The other UEs are guaranteed to + * have the same K2 (we don't support multiple/different K2s via different + * TDAs yet). If the TDA is negative, it means that there is no UL slot to + * schedule now (slot + k2 is not UL slot) */ int UE_id = UE_info->list.head; NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - const int tda = 1; - const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = - sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: - scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; - - AssertFatal(tda < tdaList->list.count, - "time domain assignment %d >= %d\n", - tda, - tdaList->list.count); - - int K2 = get_K2(scc,sched_ctrl->active_ubwp, tda, mu); + const int tda = sched_ctrl->active_ubwp ? nr_mac->preferred_ul_tda[sched_ctrl->active_ubwp->bwp_Id][slot] : 1; + if (tda < 0) + return false; + int K2 = get_K2(scc, sched_ctrl->active_ubwp, tda, mu); const int sched_frame = frame + (slot + K2 >= nr_slots_per_frame[mu]); const int sched_slot = (slot + K2) % nr_slots_per_frame[mu]; - if (!is_xlsch_in_slot(ulsch_in_slot_bitmap, sched_slot)) + if (!is_xlsch_in_slot(nr_mac->ulsch_slot_bitmap[sched_slot / 64], sched_slot)) return false; sched_ctrl->sched_pusch.slot = sched_slot; sched_ctrl->sched_pusch.frame = sched_frame; - - /* Confirm all the UE have same K2 as the first UE */ for (UE_id = UE_info->list.next[UE_id]; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; AssertFatal(K2 == get_K2(scc,sched_ctrl->active_ubwp, tda, mu), @@ -963,20 +1210,29 @@ bool nr_simple_ulsch_preprocessor(module_id_t module_id, sched_ctrl->sched_pusch.frame = sched_frame; } - /* Change vrb_map_UL to rballoc_mask */ + /* Change vrb_map_UL to rballoc_mask: check which symbols per RB (in + * vrb_map_UL) overlap with the "default" tda and exclude those RBs. + * Calculate largest contiguous RBs */ uint16_t *vrb_map_UL = &RC.nrmac[module_id]->common_channels[CC_id].vrb_map_UL[sched_slot * MAX_BWP_SIZE]; - const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_ubwp ? - sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth: - scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, - MAX_BWP_SIZE); + const uint16_t bwpSize = NRRIV2BW(sched_ctrl->active_ubwp ? + sched_ctrl->active_ubwp->bwp_Common->genericParameters.locationAndBandwidth: + scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, + MAX_BWP_SIZE); + const struct NR_PUSCH_TimeDomainResourceAllocationList *tdaList = sched_ctrl->active_ubwp ? + sched_ctrl->active_ubwp->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList: + scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList; + const int startSymbolAndLength = tdaList->list.array[tda]->startSymbolAndLength; + int startSymbolIndex, nrOfSymbols; + SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols); + const uint16_t symb = ((1 << nrOfSymbols) - 1) << startSymbolIndex; int st = 0, e = 0, len = 0; for (int i = 0; i < bwpSize; i++) { - while (vrb_map_UL[i] == 1 && i len) { len = i - st; @@ -995,28 +1251,53 @@ bool nr_simple_ulsch_preprocessor(module_id_t module_id, pf_ul(module_id, frame, slot, - num_slots_per_tdd, &UE_info->list, + 2, len, - rballoc_mask, - 2); + rballoc_mask); return true; } -void nr_schedule_ulsch(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - int num_slots_per_tdd, - int ul_slots, - uint64_t ulsch_in_slot_bitmap) { +nr_pp_impl_ul nr_init_fr1_ulsch_preprocessor(module_id_t module_id, int CC_id) +{ + /* in the PF algorithm, we have to use the TBsize to compute the coefficient. + * This would include the number of DMRS symbols, which in turn depends on + * the time domain allocation. In case we are in a mixed slot, we do not want + * to recalculate all these values, and therefore we provide a look-up table + * which should approximately(!) give us the TBsize. In particular, the + * number of symbols, the number of DMRS symbols, and the exact Qm and R, are + * not correct*/ + for (int mcsTableIdx = 0; mcsTableIdx < 3; ++mcsTableIdx) { + for (int mcs = 0; mcs < 29; ++mcs) { + if (mcs > 27 && mcsTableIdx == 1) + continue; + const uint8_t Qm = nr_get_Qm_dl(mcs, mcsTableIdx); + const uint16_t R = nr_get_code_rate_dl(mcs, mcsTableIdx); + /* note: we do not update R/Qm based on low MCS or pi2BPSK */ + ul_pf_tbs[mcsTableIdx][mcs] = nr_compute_tbs(Qm, + R, + 1, /* rbSize */ + 10, /* hypothetical number of slots */ + 0, /* N_PRB_DMRS * N_DMRS_SLOT */ + 0 /* N_PRB_oh, 0 for initialBWP */, + 0 /* tb_scaling */, + 1 /* nrOfLayers */) + >> 3; + } + } + return nr_fr1_ulsch_preprocessor; +} + +void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot) +{ + gNB_MAC_INST *nr_mac = RC.nrmac[module_id]; /* Uplink data ONLY can be scheduled when the current slot is downlink slot, * because we have to schedule the DCI0 first before schedule uplink data */ - if (is_xlsch_in_slot(ulsch_in_slot_bitmap, slot)) { + if (!is_xlsch_in_slot(nr_mac->dlsch_slot_bitmap[slot / 64], slot)) { LOG_D(NR_MAC, "Current slot %d is NOT DL slot, cannot schedule DCI0 for UL data\n", slot); return; } - bool do_sched = RC.nrmac[module_id]->pre_processor_ul( - module_id, frame, slot, num_slots_per_tdd, ulsch_in_slot_bitmap); + bool do_sched = RC.nrmac[module_id]->pre_processor_ul(module_id, frame, slot); if (!do_sched) return; @@ -1034,8 +1315,9 @@ void nr_schedule_ulsch(module_id_t module_id, const NR_list_t *UE_list = &UE_info->list; for (int UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) { NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id]; - if (sched_ctrl->ul_failure == 1) continue; + if (sched_ctrl->ul_failure == 1 && get_softmodem_params()->phy_test==0) continue; UE_info->mac_stats[UE_id].ulsch_current_bytes = 0; + /* dynamic PUSCH values (RB alloc, MCS, hence R, Qm, TBS) that change in * every TTI are pre-populated by the preprocessor and used below */ NR_sched_pusch_t *sched_pusch = &sched_ctrl->sched_pusch; @@ -1044,6 +1326,7 @@ void nr_schedule_ulsch(module_id_t module_id, continue; uint16_t rnti = UE_info->rnti[UE_id]; + sched_ctrl->SR = false; int8_t harq_id = sched_pusch->ul_harq_pid; if (harq_id < 0) { @@ -1073,8 +1356,8 @@ void nr_schedule_ulsch(module_id_t module_id, /* pre-computed PUSCH values that only change if time domain allocation, * DCI format, or DMRS parameters change. Updated in the preprocessor - * through nr_save_pusch_fields() */ - NR_sched_pusch_save_t *ps = &sched_ctrl->pusch_save; + * through nr_set_pusch_semi_static() */ + NR_pusch_semi_static_t *ps = &sched_ctrl->pusch_semi_static; /* Statistics */ UE_info->mac_stats[UE_id].ulsch_rounds[cur_harq->round]++; @@ -1083,6 +1366,9 @@ void nr_schedule_ulsch(module_id_t module_id, /* Save information on MCS, TBS etc for the current initial transmission * so we have access to it when retransmitting */ cur_harq->sched_pusch = *sched_pusch; + /* save which time allocation has been used, to be used on + * retransmissions */ + cur_harq->sched_pusch.time_domain_allocation = ps->time_domain_allocation; sched_ctrl->sched_ul_bytes += sched_pusch->tb_size; } else { LOG_D(NR_MAC, @@ -1097,9 +1383,11 @@ void nr_schedule_ulsch(module_id_t module_id, cur_harq->ndi); } UE_info->mac_stats[UE_id].ulsch_current_bytes = sched_pusch->tb_size; + sched_ctrl->last_ul_frame = sched_pusch->frame; + sched_ctrl->last_ul_slot = sched_pusch->slot; LOG_D(NR_MAC, - "%4d.%2d RNTI %04x UL sched %4d.%2d start %d RBS %d MCS %d TBS %d HARQ PID %d round %d NDI %d\n", + "%4d.%2d RNTI %04x UL sched %4d.%2d start %2d RBS %3d startSymbol %2d nb_symbol %2d MCS %2d TBS %4d HARQ PID %2d round %d NDI %d est %6d sched %6d est BSR %6d\n", frame, slot, rnti, @@ -1107,11 +1395,17 @@ void nr_schedule_ulsch(module_id_t module_id, sched_pusch->slot, sched_pusch->rbStart, sched_pusch->rbSize, + ps->startSymbolIndex, + ps->nrOfSymbols, sched_pusch->mcs, sched_pusch->tb_size, harq_id, cur_harq->round, - cur_harq->ndi); + cur_harq->ndi, + sched_ctrl->estimated_ul_buffer, + sched_ctrl->sched_ul_bytes, + sched_ctrl->estimated_ul_buffer - sched_ctrl->sched_ul_bytes); + /* PUSCH in a later slot, but corresponding DCI now! */ nfapi_nr_ul_tti_request_t *future_ul_tti_req = &RC.nrmac[module_id]->UL_tti_req_ahead[0][sched_pusch->slot]; @@ -1137,7 +1431,7 @@ void nr_schedule_ulsch(module_id_t module_id, pusch_pdu->handle = 0; //not yet used /* FAPI: BWP */ - NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters:&scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; + NR_BWP_t *genericParameters = sched_ctrl->active_ubwp ? &sched_ctrl->active_ubwp->bwp_Common->genericParameters:&scc->uplinkConfigCommon->initialUplinkBWP->genericParameters; pusch_pdu->bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pusch_pdu->bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE); pusch_pdu->subcarrier_spacing = genericParameters->subcarrierSpacing; @@ -1150,7 +1444,7 @@ void nr_schedule_ulsch(module_id_t module_id, pusch_pdu->mcs_table = ps->mcs_table; pusch_pdu->transform_precoding = ps->transform_precoding; if (ps->pusch_Config && - ps->pusch_Config->dataScramblingIdentityPUSCH) + ps->pusch_Config->dataScramblingIdentityPUSCH) pusch_pdu->data_scrambling_id = *ps->pusch_Config->dataScramblingIdentityPUSCH; else pusch_pdu->data_scrambling_id = *scc->physCellId; @@ -1279,13 +1573,13 @@ void nr_schedule_ulsch(module_id_t module_id, memset(&uldci_payload, 0, sizeof(uldci_payload)); NR_CellGroupConfig_t *CellGroup = UE_info->CellGroup[UE_id]; int n_ubwp=1; - if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && - CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) + if (CellGroup && CellGroup->spCellConfig && CellGroup->spCellConfig->spCellConfigDedicated && + CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig && + CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList) n_ubwp = CellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count; config_uldci(sched_ctrl->active_ubwp, - scc, + scc, pusch_pdu, &uldci_payload, ps->dci_format, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index a5821aaa3c..ab11f3eb87 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -66,6 +66,9 @@ void clear_nr_nfapi_information(gNB_MAC_INST * gNB, void gNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frame_rxP, sub_frame_t slot_rxP); +/* \brief main DL scheduler function. Calls a preprocessor to decide on + * resource allocation, then "post-processes" resource allocation (nFAPI + * messages, statistics, HARQ handling, CEs, ... */ void nr_schedule_ue_spec(module_id_t module_id, frame_t frame, sub_frame_t slot); @@ -76,35 +79,24 @@ uint32_t schedule_control_sib1(module_id_t module_id, int time_domain_allocation, int startSymbolIndex, int nrOfSymbols, + uint16_t dlDmrsSymbPos, uint8_t candidate_idx, int num_total_bytes); +/* \brief default FR1 DL preprocessor init routine, returns preprocessor to call */ +nr_pp_impl_dl nr_init_fr1_dlsch_preprocessor(module_id_t module_id, int CC_id); + void schedule_nr_sib1(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP); -/* \brief default preprocessor */ -void nr_simple_dlsch_preprocessor(module_id_t module_id, - frame_t frame, - sub_frame_t slot); +void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP); -void schedule_nr_mib(module_id_t module_idP, - frame_t frameP, - sub_frame_t subframeP, - uint8_t slots_per_frame, - int nb_periods_per_frame); +/* \brief main UL scheduler function. Calls a preprocessor to decide on + * resource allocation, then "post-processes" resource allocation (nFAPI + * messages, statistics, HARQ handling, ... */ +void nr_schedule_ulsch(module_id_t module_id, frame_t frame, sub_frame_t slot); -/// uplink scheduler -void nr_schedule_ulsch(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - int num_slots_per_tdd, - int ul_slots, - uint64_t ulsch_in_slot_bitmap); - -bool nr_simple_ulsch_preprocessor(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - int num_slots_per_tdd, - uint64_t ulsch_in_slot_bitmap); +/* \brief default FR1 UL preprocessor init routine, returns preprocessor to call */ +nr_pp_impl_ul nr_init_fr1_ulsch_preprocessor(module_id_t module_id, int CC_id); /////// Random Access MAC-PHY interface functions and primitives /////// @@ -158,11 +150,7 @@ void nr_preprocessor_phytest(module_id_t module_id, sub_frame_t slot); /* \brief UL preprocessor for phytest: schedules UE_id 0 with fixed MCS on a * fixed set of resources */ -bool nr_ul_preprocessor_phytest(module_id_t module_id, - frame_t frame, - sub_frame_t slot, - int num_slots_per_tdd, - uint64_t ulsch_in_slot_bitmap); +bool nr_ul_preprocessor_phytest(module_id_t module_id, frame_t frame, sub_frame_t slot); void nr_schedule_css_dlsch_phytest(module_id_t module_idP, frame_t frameP, @@ -179,7 +167,7 @@ void handle_nr_uci_pucch_2_3_4(module_id_t mod_id, void config_uldci(const NR_BWP_Uplink_t *ubwp, - const NR_ServingCellConfigCommon_t *scc, + const NR_ServingCellConfigCommon_t *scc, const nfapi_nr_pusch_pdu_t *pusch_pdu, dci_pdu_rel15_t *dci_pdu_rel15, int dci_format, @@ -199,11 +187,11 @@ void nr_csi_meas_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); -bool nr_acknack_scheduling(int Mod_idP, +int nr_acknack_scheduling(int Mod_idP, int UE_id, frame_t frameP, sub_frame_t slotP, - int r_pucch); + int r_pucch); void get_pdsch_to_harq_feedback(int Mod_idP, int UE_id, @@ -230,15 +218,15 @@ int nr_is_dci_opportunity(nfapi_nr_search_space_t search_space, */ void nr_configure_pucch(nfapi_nr_pucch_pdu_t* pucch_pdu, - NR_ServingCellConfigCommon_t *scc, - NR_CellGroupConfig_t *CellGroup, - NR_BWP_Uplink_t *bwp, + NR_ServingCellConfigCommon_t *scc, + NR_CellGroupConfig_t *CellGroup, + NR_BWP_Uplink_t *bwp, uint16_t rnti, uint8_t pucch_resource, uint16_t O_csi, uint16_t O_ack, uint8_t O_sr, - int r_pucch); + int r_pucch); void find_search_space(int ss_type, NR_BWP_Downlink_t *bwp, @@ -267,7 +255,7 @@ void prepare_dci(const NR_CellGroupConfig_t *CellGroup, /* find coreset within the search space */ NR_ControlResourceSet_t *get_coreset(NR_ServingCellConfigCommon_t *scc, - NR_BWP_Downlink_t *bwp, + NR_BWP_Downlink_t *bwp, NR_SearchSpace_t *ss, NR_SearchSpace__searchSpaceType_PR ss_type); @@ -278,12 +266,19 @@ NR_SearchSpace_t *get_searchspace(NR_ServingCellConfigCommon_t *scc, long get_K2(NR_ServingCellConfigCommon_t *scc, NR_BWP_Uplink_t *ubwp, int time_domain_assignment, int mu); -void nr_save_pusch_fields(const NR_ServingCellConfigCommon_t *scc, - const NR_BWP_Uplink_t *ubwp, - long dci_format, - int tda, - uint8_t num_dmrs_cdm_grps_no_data, - NR_sched_pusch_save_t *ps); +void nr_set_pdsch_semi_static(const NR_ServingCellConfigCommon_t *scc, + const NR_CellGroupConfig_t *secondaryCellGroup, + const NR_BWP_Downlink_t *bwp, + int tda, + uint8_t num_dmrs_cdm_grps_no_data, + NR_pdsch_semi_static_t *ps); + +void nr_set_pusch_semi_static(const NR_ServingCellConfigCommon_t *scc, + const NR_BWP_Uplink_t *ubwp, + long dci_format, + int tda, + uint8_t num_dmrs_cdm_grps_no_data, + NR_pusch_semi_static_t *ps); uint8_t nr_get_tpc(int target, uint8_t cqi, int incr); @@ -376,14 +371,6 @@ void nr_generate_Msg4(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, sub_frame_t slot, NR_RA_t *ra); -void nr_process_mac_pdu( - module_id_t module_idP, - rnti_t rnti, - uint8_t CC_id, - frame_t frameP, - uint8_t *pduP, - uint16_t mac_pdu_len); - int binomial(int n, int k); bool is_xlsch_in_slot(uint64_t bitmap, sub_frame_t slot); @@ -425,5 +412,24 @@ int16_t ssb_index_from_prach(module_id_t module_idP, void find_SSB_and_RO_available(module_id_t module_idP); +void calculate_preferred_dl_tda(module_id_t module_id, const NR_BWP_Downlink_t *bwp); +void calculate_preferred_ul_tda(module_id_t module_id, const NR_BWP_Uplink_t *ubwp); + bool find_free_CCE(module_id_t module_id, sub_frame_t slot, int UE_id); + +bool nr_find_nb_rb(uint16_t Qm, + uint16_t R, + uint16_t nb_symb_sch, + uint16_t nb_dmrs_prb, + uint32_t bytes, + uint16_t nb_rb_max, + uint32_t *tbs, + uint16_t *nb_rb); + +void nr_sr_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP); + +void periodicity__SRR (NR_SchedulingRequestResourceConfig_t *SchedulingReqRecconf, + int *period, + int *offset); + #endif /*__LAYER2_NR_MAC_PROTO_H__*/ diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index 33e575d2b9..117c18ae8d 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -81,12 +81,14 @@ void mac_top_init_gNB(void) RC.nrmac[i]->ul_handle = 0; + RC.nrmac[i]->first_MIB = true; + if (get_softmodem_params()->phy_test) { RC.nrmac[i]->pre_processor_dl = nr_preprocessor_phytest; RC.nrmac[i]->pre_processor_ul = nr_ul_preprocessor_phytest; } else { - RC.nrmac[i]->pre_processor_dl = nr_simple_dlsch_preprocessor; - RC.nrmac[i]->pre_processor_ul = nr_simple_ulsch_preprocessor; + RC.nrmac[i]->pre_processor_dl = nr_init_fr1_dlsch_preprocessor(i, 0); + RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0); } }//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++) @@ -96,12 +98,12 @@ void mac_top_init_gNB(void) // These should be out of here later pdcp_layer_init(); - if(IS_SOFTMODEM_NOS1 && !(get_softmodem_params()->do_ra || get_softmodem_params()->sa) ) + if(IS_SOFTMODEM_NOS1 && get_softmodem_params()->phy_test) nr_DRB_preconfiguration(0x1234); rrc_init_nr_global_param(); - }else { + } else { RC.nrmac = NULL; } diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index ce8883edbb..34a9a97fd0 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -80,7 +80,6 @@ #define NR_NB_RA_PROC_MAX 4 #define MAX_NUM_OF_SSB 64 - /*! \brief NR_list_t is a "list" (of users, HARQ processes, slices, ...). * Especially useful in the scheduler and to keep "classes" of users. */ typedef struct { @@ -307,11 +306,11 @@ typedef struct NR_sched_pucch { int r_pucch; } NR_sched_pucch_t; -/* this struct is a helper: as long as the TDA and DCI format remain the same - * over the same uBWP and search space, there is no need to recalculate all - * S/L, MCS table, or DMRS-related parameters over and over again. Hence, we - * store them in this struct for easy reference. */ -typedef struct NR_sched_pusch_save { +/* PUSCH semi-static configuration: as long as the TDA and DCI format remain + * the same over the same uBWP and search space, there is no need to + * recalculate all S/L, MCS table, or DMRS-related parameters over and over + * again. Hence, we store them in this struct for easy reference. */ +typedef struct NR_pusch_semi_static_t { int dci_format; int time_domain_allocation; uint8_t num_dmrs_cdm_grps_no_data; @@ -329,7 +328,7 @@ typedef struct NR_sched_pusch_save { uint16_t ul_dmrs_symb_pos; uint8_t num_dmrs_symb; uint8_t N_PRB_DMRS; -} NR_sched_pusch_save_t; +} NR_pusch_semi_static_t; typedef struct NR_sched_pusch { int frame; @@ -339,9 +338,6 @@ typedef struct NR_sched_pusch { uint16_t rbSize; uint16_t rbStart; - // time-domain allocation for scheduled RBs - int time_domain_allocation; - /// MCS uint8_t mcs; @@ -352,17 +348,71 @@ typedef struct NR_sched_pusch { /// UL HARQ PID to use for this UE, or -1 for "any new" int8_t ul_harq_pid; + + /// the Time Domain Allocation used for this transmission. Note that this is + /// only important for retransmissions; otherwise, the TDA in + /// NR_pusch_semi_static_t has precedence + int time_domain_allocation; } NR_sched_pusch_t; +/* PDSCH semi-static configuratio: as long as the TDA/DMRS/mcsTable remains the + * same, there is no need to recalculate all S/L or DMRS-related parameters + * over and over again. Hence, we store them in this struct for easy + * reference. */ +typedef struct NR_pdsch_semi_static { + int time_domain_allocation; + uint8_t numDmrsCdmGrpsNoData; + + int startSymbolIndex; + int nrOfSymbols; + + uint8_t mcsTableIdx; + + uint8_t N_PRB_DMRS; + uint8_t N_DMRS_SLOT; + uint16_t dl_dmrs_symb_pos; + nfapi_nr_dmrs_type_e dmrsConfigType; +} NR_pdsch_semi_static_t; + +typedef struct NR_sched_pdsch { + /// RB allocation within active BWP + uint16_t rbSize; + uint16_t rbStart; + + /// MCS-related infos + uint8_t mcs; + + /// TBS-related info + uint16_t R; + uint8_t Qm; + uint32_t tb_size; + + /// DL HARQ PID to use for this UE, or -1 for "any new" + int8_t dl_harq_pid; + + // pucch format allocation + uint8_t pucch_allocation; + + /// the Time Domain Allocation used for this transmission. Note that this is + /// only important for retransmissions; otherwise, the TDA in + /// NR_pdsch_semi_static_t has precedence + int time_domain_allocation; +} NR_sched_pdsch_t; + typedef struct NR_UE_harq { bool is_waiting; uint8_t ndi; uint8_t round; + uint16_t feedback_frame; uint16_t feedback_slot; - /* Transport block to be sent using this HARQ process */ + /* Transport block to be sent using this HARQ process, its size is in + * sched_pdsch */ uint32_t tb[16384]; uint32_t tb_size; + + /// sched_pdsch keeps information on MCS etc used for the initial transmission + NR_sched_pdsch_t sched_pdsch; } NR_UE_harq_t; //! fixme : need to enhace for the multiple TB CQI report @@ -443,13 +493,6 @@ typedef struct nr_csi_report { From spec 38.214 section 5.2.1.2 For periodic and semi-persistent CSI Resource Settings, the number of CSI-RS Resource Sets configured is limited to S=1 */ #define MAX_CSI_RESOURCE_SET_IN_CSI_RESOURCE_CONFIG 16 -typedef struct NR_UE_old_sched { - uint16_t rbSize; - int time_domain_allocation; - uint8_t mcsTableIdx; - uint8_t mcs; - uint8_t numDmrsCdmGrpsNoData; -} NR_UE_ret_info_t; typedef enum { INACTIVE = 0, @@ -470,52 +513,50 @@ typedef struct NR_UE_ul_harq { /*! \brief scheduling control information set through an API */ #define MAX_CSI_REPORTS 48 typedef struct { - /// total amount of data awaiting for this UE - uint32_t num_total_bytes; - /// per-LC status data - mac_rlc_status_resp_t rlc_status[MAX_NUM_LCID]; - /// the currently active BWP in DL NR_BWP_Downlink_t *active_bwp; /// the currently active BWP in UL NR_BWP_Uplink_t *active_ubwp; - - /// PUCCH scheduling information. Array of three, we assume for the moment: - /// HARQ in the first field, SR in second, CSI in third (as fixed by RRC - /// conf., i.e. if actually present). The order is important for - /// nr_acknack_scheduling()! - NR_sched_pucch_t sched_pucch[3]; - - NR_sched_pusch_save_t pusch_save; - NR_sched_pusch_t sched_pusch; - /// CCE index and aggregation, should be coherent with cce_list NR_SearchSpace_t *search_space; NR_ControlResourceSet_t *coreset; + + /// CCE index and Aggr. Level are shared for PUSCH/PDSCH allocation decisions + /// corresponding to the sched_pusch/sched_pdsch structures below int cce_index; uint8_t aggregation_level; - /// RB allocation within active BWP - uint16_t rbSize; - uint16_t rbStart; + /// PUCCH scheduling information. Array of two: HARQ+SR in the first field, + /// CSI in second. This order is important for nr_acknack_scheduling()! + NR_sched_pucch_t sched_pucch[2]; + + /// PUSCH semi-static configuration: is not cleared across TTIs + NR_pusch_semi_static_t pusch_semi_static; + /// Sched PDSCH: scheduling decisions, copied into HARQ and cleared every TTI + NR_sched_pusch_t sched_pusch; /// uplink bytes that are currently scheduled int sched_ul_bytes; /// estimation of the UL buffer size int estimated_ul_buffer; - // time-domain allocation for scheduled RBs - int time_domain_allocation; + /// PHR info: power headroom level (dB) + int ph; + /// PHR info: nominal UE transmit power levels (dBm) + int pcmax; - /// MCS-related infos - uint8_t mcsTableIdx; - uint8_t mcs; - uint8_t numDmrsCdmGrpsNoData; + /// PDSCH semi-static configuration: is not cleared across TTIs + NR_pdsch_semi_static_t pdsch_semi_static; + /// Sched PDSCH: scheduling decisions, copied into HARQ and cleared every TTI + NR_sched_pdsch_t sched_pdsch; + /// For UL synchronization: store last UL scheduling grant + frame_t last_ul_frame; + sub_frame_t last_ul_slot; - /// Retransmission-related information - NR_UE_ret_info_t retInfo[NR_MAX_NB_HARQ_PROCESSES]; - /// DL HARQ PID to use for this UE, or -1 for "any new" - int8_t dl_harq_pid; + /// total amount of data awaiting for this UE + uint32_t num_total_bytes; + /// per-LC status data + mac_rlc_status_resp_t rlc_status[MAX_NUM_LCID]; int lcid_mask; uint16_t ta_frame; @@ -523,12 +564,17 @@ typedef struct { bool ta_apply; uint8_t tpc0; uint8_t tpc1; + int raw_rssi; + int pusch_snrx10; + int pucch_snrx10; uint16_t ul_rssi; uint8_t current_harq_pid; int pusch_consecutive_dtx_cnt; int pucch_consecutive_dtx_cnt; int ul_failure; struct CSI_Report CSI_report[MAX_CSI_REPORTS]; + bool SR; + /// information about every HARQ process NR_UE_harq_t harq_processes[NR_MAX_NB_HARQ_PROCESSES]; /// HARQ processes that are free @@ -545,7 +591,6 @@ typedef struct { NR_list_t feedback_ul_harq; /// UL HARQ processes that await retransmission NR_list_t retrans_ul_harq; - int dummy; NR_UE_mac_ce_ctrl_t UE_mac_ce_ctrl;// MAC CE related information } NR_UE_sched_ctrl_t; @@ -599,9 +644,7 @@ typedef void (*nr_pp_impl_dl)(module_id_t mod_id, sub_frame_t slot); typedef bool (*nr_pp_impl_ul)(module_id_t mod_id, frame_t frame, - sub_frame_t slot, - int num_slots_per_tdd, - uint64_t ulsch_in_slot_bitmap); + sub_frame_t slot); /*! \brief top level eNB MAC structure */ typedef struct gNB_MAC_INST_s { @@ -682,10 +725,22 @@ typedef struct gNB_MAC_INST_s { int cce_list[MAX_NUM_BWP][MAX_NUM_CORESET][MAX_NUM_CCE]; /// list of allocated beams per period int16_t *tdd_beam_association; - /// PUCCH: keep track of the resources has already been used by saving the - /// highest index not yet been used in a given slot. Dynamically allocated - /// so we can have it for every slot as a function of the numerology - int *pucch_index_used[MAX_NUM_BWP]; + + /// bitmap of DLSCH slots, can hold up to 160 slots + uint64_t dlsch_slot_bitmap[3]; + /// Lookup for preferred time domain allocation for BWP, in DL, slots + /// dynamically allocated + int *preferred_dl_tda[MAX_NUM_BWP]; + /// bitmap of ULSCH slots, can hold up to 160 slots + uint64_t ulsch_slot_bitmap[3]; + /// Lookup for preferred time domain allocation for UL BWP, dynamically + /// allocated. The index refers to the DL slot, and the indicated TDA's k2 + /// points to the right UL slot + int *preferred_ul_tda[MAX_NUM_BWP]; + + /// maximum number of slots before a UE will be scheduled ULSCH automatically + uint32_t ulsch_max_slots_inactivity; + /// DL preprocessor for differentiated scheduling nr_pp_impl_dl pre_processor_dl; /// UL preprocessor for differentiated scheduling @@ -694,6 +749,7 @@ typedef struct gNB_MAC_INST_s { NR_UE_sched_ctrl_t *sched_ctrlCommon; NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config[64]; + bool first_MIB; } gNB_MAC_INST; #endif /*__LAYER2_NR_MAC_GNB_H__ */ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index e516217ff1..cddb666bfd 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -57,7 +57,7 @@ #include "openair2/RRC/NAS/nas_config.h" #include "intertask_interface.h" #include "openair3/S1AP/s1ap_eNB.h" - +#include # include "gtpv1u_eNB_task.h" # include "gtpv1u.h" @@ -136,6 +136,43 @@ notifiedFIFO_t pdcp_sdu_list; pdcp_enb_t pdcp_enb[MAX_NUM_CCs]; +extern volatile int oai_exit; + +pthread_t pdcp_stats_thread_desc; + +void *pdcp_stats_thread(void *param) { + + FILE *fd; + int old_byte_cnt[MAX_MOBILES_PER_ENB][NB_RB_MAX],old_byte_cnt_rx[MAX_MOBILES_PER_ENB][NB_RB_MAX]; + for (int i=0;i0) { + fprintf(fd,"PDCP: CRNTI %x, DRB %d: tx_bytes %d, DL Throughput %e\n", + pdcp_enb[0].rnti[UE_id],drb_id, + Pdcp_stats_tx_bytes[0][UE_id][drb_id], + (double)((Pdcp_stats_tx_bytes[0][UE_id][drb_id]-old_byte_cnt[UE_id][drb_id])<<3)); + fprintf(fd," rx_bytes %d, UL Throughput %e\n", + Pdcp_stats_rx_bytes[0][UE_id][drb_id], + (double)((Pdcp_stats_rx_bytes[0][UE_id][drb_id]-old_byte_cnt_rx[UE_id][drb_id])<<3)); + old_byte_cnt[UE_id][drb_id]=Pdcp_stats_tx_bytes[0][UE_id][drb_id]; + old_byte_cnt_rx[UE_id][drb_id]=Pdcp_stats_rx_bytes[0][UE_id][drb_id]; + } + } + fclose(fd); + } + return(NULL); +} + uint64_t get_pdcp_optmask(void) { return pdcp_params.optmask; } @@ -516,7 +553,7 @@ boolean_t pdcp_data_req( break; } - //LOG_I(PDCP,"ueid %d lcid %d tx seq num %d\n", pdcp_uid, rb_idP+rb_offset, current_sn); + LOG_D(PDCP,"ueid %d lcid %d tx seq num %d\n", pdcp_uid, (int)(rb_idP+rb_offset), current_sn); Pdcp_stats_tx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++; Pdcp_stats_tx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=sdu_buffer_sizeP; @@ -1044,7 +1081,13 @@ pdcp_data_ind( pdcpHead->inst = 1; } } // nfapi_mode - } + } else { + if (UE_NAS_USE_TUN) { + pdcpHead->inst = ctxt_pP->module_id; + } else if (ENB_NAS_USE_TUN) { + pdcpHead->inst = 0; + } + } } else { pdcpHead->rb_id = rb_id + (ctxt_pP->module_id * LTE_maxDRB); pdcpHead->inst = ctxt_pP->module_id; @@ -2345,6 +2388,8 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) { LOG_E(PDCP, "ENB pdcp will not use tun interface\n"); } + pthread_create(&pdcp_stats_thread_desc,NULL,pdcp_stats_thread,NULL); + return pdcp_params.optmask ; } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 8ff3c06cd4..cc44572abd 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -43,6 +43,7 @@ extern int otg_enabled; #include #include #include +#include #define rtf_put write #define rtf_get read @@ -222,7 +223,11 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) { key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p); } else { // => ENB_NAS_USE_TUN - ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[0]; + /* Get the IP from a packet */ + struct ip *ip_pack = (struct ip *) nl_rx_buf; + /* Use last octet of destination IP to get index of UE */ + int ue_indx = ((ip_pack->ip_dst.s_addr >> 24) - 2) % MAX_MOBILES_PER_ENB; + ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[ue_indx]; ctxt.enb_flag=ENB_FLAG_YES; ctxt.module_id=0; key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO); diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c b/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c index 36500c3d16..f19d7526fe 100644 --- a/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c +++ b/openair2/LAYER2/PROTO_AGENT/proto_agent_common.c @@ -33,10 +33,9 @@ #include "PHY/phy_extern.h" #include "proto_agent_common.h" #include "common/utils/LOG/log.h" +#include "common/ran_context.h" -#include "RRC/LTE/rrc_extern.h" -#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" -#include "rrc_eNB_UE_context.h" +extern RAN_CONTEXT_t RC; /* * message primitives @@ -364,34 +363,23 @@ int proto_agent_pdcp_data_req_process(mod_id_t mod_id, const void *params, Proto pdcp_pdu_size = rlc_data->fsp_pdu->fsp_pdu_data.len; pdcp_pdu_p = get_free_mem_block(pdcp_pdu_size, __func__); - if (!pdcp_pdu_p) goto error; + if (!pdcp_pdu_p) { + LOG_E(PROTO_AGENT, "%s: an error occured\n", __FUNCTION__); + return -1; + } memcpy(pdcp_pdu_p->data, rlc_data->fsp_pdu->fsp_pdu_data.data, pdcp_pdu_size); - // result = rlc_data_req(&ctxt_pP - // ,srb_flagP - // ,flag_MBMS - // ,rb_idP - // ,muiP - // ,confirmP - // ,pdcp_pdu_size - // ,pdcp_pdu_p - // ,NULL - // ,NULL - // ); - LOG_D(PROTO_AGENT, "proto_agent received pdcp_data_req \n"); - // for (int i = 0; i < pdcp_pdu_size; i++) - // printf(" %2.2x", (unsigned char)pdcp_pdu_p->data[i]); - // printf("\n"); - du_rlc_data_req(&ctxt_pP, srb_flagP, flag_MBMS, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p); - result = 1; + if (RC.nrrrc) { + LOG_D(PROTO_AGENT, "proto_agent received pdcp_data_req \n"); + // for (int i = 0; i < pdcp_pdu_size; i++) + // printf(" %2.2x", (unsigned char)pdcp_pdu_p->data[i]); + // printf("\n"); + du_rlc_data_req(&ctxt_pP, srb_flagP, flag_MBMS, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p); + result = 1; + } else { + result = rlc_data_req(&ctxt_pP, srb_flagP, flag_MBMS, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p, NULL, NULL); + } return result; -error: - - if (pdcp_pdu_p) - free_mem_block(pdcp_pdu_p, __func__); - - LOG_E(PROTO_AGENT, "%s: an error occured\n", __FUNCTION__); - return -1; } int proto_agent_destroy_pdcp_data_ind(Protocol__FlexsplitMessage *msg) { @@ -508,6 +496,13 @@ error: return -1; } +boolean_t pdcp_data_ind( + const protocol_ctxt_t *const ctxt_pP, + const srb_flag_t srb_flagP, + const MBMS_flag_t MBMS_flagP, + const rb_id_t rb_id, + const sdu_size_t sdu_buffer_size, + mem_block_t *const sdu_buffer); int proto_agent_pdcp_data_ind_process(mod_id_t mod_id, const void *params, Protocol__FlexsplitMessage **msg) { boolean_t result = 0; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp.h b/openair2/LAYER2/nr_pdcp/nr_pdcp.h index a5f182c822..94939a0421 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp.h @@ -24,7 +24,6 @@ #ifndef _NR_PDCP_H_ #define _NR_PDCP_H_ -void pdcp_layer_init_for_CU(void); void nr_pdcp_layer_init_ue(void); void nr_DRB_preconfiguration(uint16_t crnti); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c index 6898d4ff71..b1be1f65da 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.c @@ -49,8 +49,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, return; } - if (entity->type != NR_PDCP_SRB && - !(buffer[0] & 0x80)) { + if (entity->type != NR_PDCP_SRB && !(buffer[0] & 0x80)) { LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); } @@ -65,9 +64,9 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, buffer[2]; header_size = 3; } + /* SRBs always have MAC-I, even if integrity is not active */ - if (entity->has_integrity - || entity->type == NR_PDCP_SRB) { + if ( entity->has_integrity || entity->type == NR_PDCP_SRB) { integrity_size = 4; } else { integrity_size = 0; @@ -79,7 +78,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, } rx_deliv_sn = entity->rx_deliv & entity->sn_max; - rx_deliv_hfn = (entity->rx_deliv >> entity->sn_size) & ~entity->sn_max; + rx_deliv_hfn = entity->rx_deliv >> entity->sn_size; if (rcvd_sn < rx_deliv_sn - entity->window_size) { rcvd_hfn = rx_deliv_hfn + 1; @@ -139,7 +138,7 @@ static void nr_pdcp_entity_recv_pdu(nr_pdcp_entity_t *entity, entity->rx_deliv = count; } - if (entity->t_reordering_start != 0 && entity->rx_deliv > entity->rx_reord) { + if (entity->t_reordering_start != 0 && entity->rx_deliv >= entity->rx_reord) { /* stop and reset t-Reordering */ entity->t_reordering_start = 0; } @@ -182,8 +181,7 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity, } /* SRBs always have MAC-I, even if integrity is not active */ - if (entity->has_integrity - || entity->type == NR_PDCP_SRB) { + if (entity->has_integrity || entity->type == NR_PDCP_SRB) { integrity_size = 4; } else { integrity_size = 0; @@ -196,8 +194,9 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity, (unsigned char *)buf + header_size + size, (unsigned char *)buf, header_size + size, entity->rb_id, count, entity->is_gnb ? 1 : 0); + + // set MAC-I to 0 for SRBs with integrity not active else if (integrity_size == 4) - /* set MAC-I to 0 for SRBs with integrity not active */ memset(buf + header_size + size, 0, 4); if (entity->has_ciphering) @@ -272,6 +271,10 @@ static void check_t_reordering(nr_pdcp_entity_t *entity) { uint32_t count; + /* if t_reordering is set to "infinity" (seen as -1) then do nothing */ + if (entity->t_reordering == -1) + return; + if (entity->t_reordering_start == 0 || entity->t_current <= entity->t_reordering_start + entity->t_reordering) return; diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h index 5bdc6f7892..fbcc2b96cd 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h @@ -40,6 +40,7 @@ typedef struct nr_pdcp_entity_t { void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size, int sdu_id); void (*delete)(struct nr_pdcp_entity_t *entity); + /* set_security: pass -1 to integrity_algorithm / ciphering_algorithm * to keep the current algorithm * pass NULL to integrity_key / ciphering_key @@ -50,6 +51,7 @@ typedef struct nr_pdcp_entity_t { char *integrity_key, int ciphering_algorithm, char *ciphering_key); + void (*set_time)(struct nr_pdcp_entity_t *entity, uint64_t now); /* callbacks provided to the PDCP module */ @@ -67,8 +69,8 @@ typedef struct nr_pdcp_entity_t { int has_sdapULheader; int has_sdapDLheader; int sn_size; /* SN size, in bits */ - int t_reordering; /* unit: ms */ - int discard_timer; /* unit: ms */ + int t_reordering; /* unit: ms, -1 for infinity */ + int discard_timer; /* unit: ms, -1 for infinity */ int sn_max; /* (2^SN_size) - 1 */ int window_size; /* 2^(SN_size - 1) */ diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c index 121652062a..6078882601 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.c @@ -54,7 +54,6 @@ hash_table_t *pdcp_coll_p; static uint64_t pdcp_optmask; ngran_node_t node_type = ngran_gNB; -uint8_t first_dcch = 0; uint8_t proto_agent_flag = 0; /****************************************************************************/ @@ -370,27 +369,14 @@ void pdcp_layer_init(void) if (pthread_mutex_unlock(&m) != 0) abort(); nr_pdcp_ue_manager = new_nr_pdcp_ue_manager(1); - init_nr_rlc_data_req_queue(); + + if ((RC.nrrrc == NULL) || (!NODE_IS_CU(RC.nrrrc[0]->node_type))) { + init_nr_rlc_data_req_queue(); + } nr_pdcp_init_timer_thread(nr_pdcp_ue_manager); } -void pdcp_layer_init_for_CU(void) -{ - /* hack: be sure to initialize only once */ - static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; - static int initialized = 0; - if (pthread_mutex_lock(&m) != 0) abort(); - if (initialized) { - if (pthread_mutex_unlock(&m) != 0) abort(); - return; - } - initialized = 1; - if (pthread_mutex_unlock(&m) != 0) abort(); - - nr_pdcp_ue_manager = new_nr_pdcp_ue_manager(1); -} - #include "nfapi/oai_integration/vendor_ext.h" #include "targets/RT/USER/lte-softmodem.h" #include "openair2/RRC/NAS/nas_config.h" @@ -459,7 +445,8 @@ static void deliver_sdu_drb(void *_ue, nr_pdcp_entity_t *entity, int rb_id; int i; - if(IS_SOFTMODEM_NOS1){ + if(IS_SOFTMODEM_NOS1 || UE_NAS_USE_TUN){ + LOG_D(PDCP, "IP packet received, to be sent to TUN interface"); len = write(nas_sock_fd[0], buf, size); if (len != size) { LOG_E(PDCP, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); @@ -535,7 +522,7 @@ rb_found: memblock = get_free_mem_block(size, __FUNCTION__); memcpy(memblock->data, buf, size); - LOG_I(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, rb_id, size); + LOG_D(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, rb_id, size); //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]); //printf("\n"); enqueue_rlc_data_req(&ctxt, 0, MBMS_FLAG_NO, rb_id, sdu_id, 0, size, memblock, NULL, NULL); @@ -548,7 +535,7 @@ static void deliver_sdu_srb(void *_ue, nr_pdcp_entity_t *entity, int srb_id; int i; - for (i = 0; i < 3; i++) { + for (i = 0; i < sizeofArray(ue->srb) ; i++) { if (entity == ue->srb[i]) { srb_id = i+1; goto srb_found; @@ -558,17 +545,17 @@ static void deliver_sdu_srb(void *_ue, nr_pdcp_entity_t *entity, LOG_E(PDCP, "%s:%d:%s: fatal, no SRB found for ue %d\n", __FILE__, __LINE__, __FUNCTION__, ue->rnti); exit(1); - + srb_found: { - uint8_t *rrc_buffer_p = entity->is_gnb ? + uint8_t *rrc_buffer_p = entity->is_gnb ? itti_malloc(TASK_PDCP_ENB, TASK_RRC_GNB, size): itti_malloc(TASK_PDCP_UE, TASK_RRC_NRUE, size); MessageDef *message_p; AssertFatal(rrc_buffer_p != NULL, "OUT OF MEMORY"); memcpy(rrc_buffer_p, buf, size); - message_p = entity->is_gnb ? + message_p = entity->is_gnb ? itti_alloc_new_message(TASK_PDCP_ENB, 0, NR_RRC_DCCH_DATA_IND): itti_alloc_new_message(TASK_PDCP_UE, 0, NR_RRC_DCCH_DATA_IND); @@ -577,7 +564,7 @@ static void deliver_sdu_srb(void *_ue, nr_pdcp_entity_t *entity, NR_RRC_DCCH_DATA_IND(message_p).sdu_p = rrc_buffer_p; NR_RRC_DCCH_DATA_IND(message_p).sdu_size = size; NR_RRC_DCCH_DATA_IND(message_p).rnti = ue->rnti; - + itti_send_msg_to_task(entity->is_gnb ? TASK_RRC_GNB : TASK_RRC_NRUE, 0, message_p); } } @@ -591,7 +578,7 @@ static void deliver_pdu_srb(void *_ue, nr_pdcp_entity_t *entity, int i; mem_block_t *memblock; - for (i = 0; i < 3; i++) { + for (i = 0; i < sizeofArray(ue->srb) ; i++) { if (entity == ue->srb[i]) { srb_id = i+1; goto srb_found; @@ -608,7 +595,7 @@ srb_found: LOG_D(PDCP, "%s(): (srb %d) calling rlc_data_req size %d\n", __func__, srb_id, size); //for (i = 0; i < size; i++) printf(" %2.2x", (unsigned char)memblock->data[i]); //printf("\n"); - if (!NODE_IS_CU(RC.nrrrc[0]->node_type)) { + if ((RC.nrrrc == NULL) || (!NODE_IS_CU(RC.nrrrc[0]->node_type))) { ctxt.module_id = 0; ctxt.enb_flag = 1; ctxt.instance = 0; @@ -617,9 +604,9 @@ srb_found: ctxt.eNB_index = 0; ctxt.configured = 1; ctxt.brOption = 0; - + ctxt.rnti = ue->rnti; - + memblock = get_free_mem_block(size, __FUNCTION__); memcpy(memblock->data, buf, size); enqueue_rlc_data_req(&ctxt, 1, MBMS_FLAG_NO, srb_id, sdu_id, 0, size, memblock, NULL, NULL); @@ -719,7 +706,7 @@ void pdcp_run(const protocol_ctxt_t *const ctxt_pP) } switch (ITTI_MSG_ID(msg_p)) { case RRC_DCCH_DATA_REQ: - LOG_I(PDCP, "Received RRC_DCCH_DATA_REQ type at PDCP task \n"); + LOG_D(PDCP, "Received RRC_DCCH_DATA_REQ type at PDCP task \n"); PROTOCOL_CTXT_SET_BY_MODULE_ID( &ctxt, RRC_DCCH_DATA_REQ(msg_p).module_id, @@ -757,7 +744,7 @@ static void add_srb(int is_gnb, int rnti, struct NR_SRB_ToAddMod *s) int t_Reordering=3000; int srb_id = s->srb_Identity; - if (s->pdcp_Config == NULL || + if (s->pdcp_Config == NULL || s->pdcp_Config->t_Reordering == NULL) t_Reordering = 3000; else t_Reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering); @@ -767,7 +754,7 @@ static void add_srb(int is_gnb, int rnti, struct NR_SRB_ToAddMod *s) LOG_D(PDCP, "%s:%d:%s: warning SRB %d already exist for ue %d, do nothing\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); } else { - pdcp_srb = new_nr_pdcp_entity(NR_PDCP_SRB, is_gnb, srb_id, + pdcp_srb = new_nr_pdcp_entity(NR_PDCP_SRB, is_gnb, srb_id, 0, 0, 0, 0, // sdap parameters deliver_sdu_srb, ue, deliver_pdu_srb, ue, 12, t_Reordering, -1, @@ -790,16 +777,22 @@ static void add_drb_am(int is_gnb, int rnti, struct NR_DRB_ToAddMod *s, nr_pdcp_ue_t *ue; int drb_id = s->drb_Identity; - int t_reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering); int sn_size_ul = decode_sn_size_ul(*s->pdcp_Config->drb->pdcp_SN_SizeUL); int sn_size_dl = decode_sn_size_dl(*s->pdcp_Config->drb->pdcp_SN_SizeDL); int discard_timer = decode_discard_timer(*s->pdcp_Config->drb->discardTimer); - if ((!s->cnAssociation) || s->cnAssociation->present == NR_DRB_ToAddMod__cnAssociation_PR_NOTHING) { + + /* if pdcp_Config->t_Reordering is not present, it means infinity (-1) */ + int t_reordering = -1; + if (s->pdcp_Config->t_Reordering != NULL) { + t_reordering = decode_t_reordering(*s->pdcp_Config->t_Reordering); + } + + if ((!s->cnAssociation) || s->cnAssociation->present == NR_DRB_ToAddMod__cnAssociation_PR_NOTHING) { LOG_E(PDCP,"%s:%d:%s: fatal, cnAssociation is missing or present is NR_DRB_ToAddMod__cnAssociation_PR_NOTHING\n",__FILE__,__LINE__,__FUNCTION__); exit(-1); } - - int pdusession_id; + + int pdusession_id; int has_sdap = 0; int has_sdapULheader=0; int has_sdapDLheader=0; @@ -904,13 +897,14 @@ boolean_t nr_rrc_pdcp_config_asn1_req( //ctxt_pP->configured != 2 || //srb2add_list == NULL || //drb2add_list != NULL || - drb2release_list != NULL || + //drb2release_list != NULL || //security_modeP != 255 || //kRRCenc != NULL || //kRRCint != NULL || //kUPenc != NULL || pmch_InfoList_r9 != NULL /*|| defaultDRB != NULL */) { + LOG_I(PDCP,"Releasing DRBs, oops\n"); TODO; } @@ -934,6 +928,10 @@ boolean_t nr_rrc_pdcp_config_asn1_req( /* todo */ } + if (drb2release_list != NULL) { + // TODO + } + free(kRRCenc); free(kRRCint); free(kUPenc); @@ -960,7 +958,6 @@ boolean_t rrc_pdcp_config_asn1_req( return 0; } - void nr_DRB_preconfiguration(uint16_t crnti) { @@ -1035,7 +1032,7 @@ void nr_DRB_preconfiguration(uint16_t crnti) (NR_SRB_ToAddModList_t *) NULL, rbconfig->drb_ToAddModList , rbconfig->drb_ToReleaseList, - 0xff, + 0, NULL, NULL, NULL, @@ -1055,7 +1052,6 @@ void nr_DRB_preconfiguration(uint16_t crnti) } - uint64_t get_pdcp_optmask(void) { return pdcp_optmask; @@ -1095,7 +1091,7 @@ void pdcp_config_set_security( /* TODO: proper handling of DRBs, for the moment only SRBs are handled */ - if (rb_id >= 1 && rb_id <= 3) { + if (rb_id >= 1 && rb_id <= 2) { rb = ue->srb[rb_id - 1]; if (rb == NULL) { @@ -1117,7 +1113,6 @@ void pdcp_config_set_security( nr_pdcp_manager_unlock(nr_pdcp_ue_manager); } - static boolean_t pdcp_data_req_srb( protocol_ctxt_t *ctxt_pP, const rb_id_t rb_id, @@ -1145,7 +1140,7 @@ static boolean_t pdcp_data_req_srb( ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti); - if (rb_id < 1 || rb_id > 3) + if (rb_id < 1 || rb_id > 2) rb = NULL; else rb = ue->srb[rb_id - 1]; @@ -1200,6 +1195,7 @@ static boolean_t pdcp_data_req_drb( if (rb == NULL) { LOG_E(PDCP, "%s:%d:%s: no DRB found (rnti %d, rb_id %ld)\n", __FILE__, __LINE__, __FUNCTION__, rnti, rb_id); + nr_pdcp_manager_unlock(nr_pdcp_ue_manager); return 0; } @@ -1226,12 +1222,10 @@ boolean_t pdcp_data_req( ) { if (srb_flagP) { - return pdcp_data_req_srb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, - sdu_buffer); + return pdcp_data_req_srb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer); } else{ - return pdcp_data_req_drb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, - sdu_buffer); + return pdcp_data_req_drb(ctxt_pP, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer); } } diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_security_nea2.c b/openair2/LAYER2/nr_pdcp/nr_pdcp_security_nea2.c index fc07f661dd..52afe95673 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_security_nea2.c +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_security_nea2.c @@ -27,12 +27,21 @@ #include #include +#ifndef NETTLE_VERSION_MAJOR +/* hack: include bignum.h, not version.h because version.h does not exist + * in old versions and bignum.h includes version.h (as of today). + * May completely fail to work... maybe we should skip support of old + * versions of nettle. + */ +#include +#endif + void *nr_pdcp_security_nea2_init(unsigned char *ciphering_key) { void *ctx = calloc(1, nettle_aes128.context_size); if (ctx == NULL) exit(1); -#if NETTLE_VERSION_MAJOR < 3 +#if !defined(NETTLE_VERSION_MAJOR) || NETTLE_VERSION_MAJOR < 3 nettle_aes128.set_encrypt_key(ctx, 16, ciphering_key); #else nettle_aes128.set_encrypt_key(ctx, ciphering_key); diff --git a/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h b/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h index 3329f856b7..742e0e84be 100644 --- a/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h +++ b/openair2/LAYER2/nr_pdcp/nr_pdcp_ue_manager.h @@ -28,7 +28,7 @@ typedef void nr_pdcp_ue_manager_t; typedef struct nr_pdcp_ue_t { int rnti; - nr_pdcp_entity_t *srb[2]; + nr_pdcp_entity_t *srb[3]; nr_pdcp_entity_t *drb[5]; } nr_pdcp_ue_t; diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c index 000c764e8f..08f5b11c23 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_am.c @@ -1529,7 +1529,7 @@ static int tx_list_size(nr_rlc_entity_am_t *entity, { int ret = 0; - while (l != NULL) { + while (l != NULL && ret < maxsize) { ret += compute_pdu_header_size(entity, l) + l->size; l = l->next; } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c index 4ef952667d..f967c3c543 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_entity_um.c @@ -497,7 +497,7 @@ static int tx_list_size(nr_rlc_entity_um_t *entity, { int ret = 0; - while (l != NULL) { + while (l != NULL && ret < maxsize) { ret += compute_pdu_header_size(entity, l) + l->size; l = l->next; } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 9373b03668..97ae065904 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -38,7 +38,6 @@ #include "common/ran_context.h" #include "NR_UL-CCCH-Message.h" -#undef C_RNTI // C_RNTI is used in F1AP generated code, prevent preprocessor replace #include "openair2/F1AP/f1ap_du_rrc_message_transfer.h" #include "openair2/LAYER2/PROTO_AGENT/proto_agent.h" @@ -90,7 +89,8 @@ void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChann mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = calloc(1,sizeof(*mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup)); *mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = 1; - mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID = NULL; + mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID = calloc(1,sizeof(*mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); + *mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = false; mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false; mac_LogicalChannelConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULL; @@ -324,7 +324,8 @@ rlc_buffer_occupancy_t mac_rlc_get_buffer_occupancy_ind( * reports '> 81338368' (table 6.1.3.1-2). Passing 100000000 is thus * more than enough. */ - buf_stat = rb->buffer_status(rb, 100000000); + // Fixme : Laurent reduced size for CPU saving + buf_stat = rb->buffer_status(rb, 10000000); ret = buf_stat.status_size + buf_stat.retx_size + buf_stat.tx_size; @@ -426,7 +427,7 @@ static void deliver_sdu(void *_ue, nr_rlc_entity_t *entity, char *buf, int size) int is_enb; /* is it SRB? */ - for (i = 0; i < 2; i++) { + for (i = 0; i < sizeofArray(ue->srb); i++) { if (entity == ue->srb[i]) { is_srb = 1; rb_id = i+1; @@ -435,7 +436,7 @@ static void deliver_sdu(void *_ue, nr_rlc_entity_t *entity, char *buf, int size) } /* maybe DRB? */ - for (i = 0; i < 5; i++) { + for (i = 0; i < sizeofArray(ue->drb) ; i++) { if (entity == ue->drb[i]) { is_srb = 0; rb_id = i+1; @@ -448,7 +449,7 @@ static void deliver_sdu(void *_ue, nr_rlc_entity_t *entity, char *buf, int size) exit(1); rb_found: - LOG_I(RLC, "%s:%d:%s: delivering SDU (rnti %d is_srb %d rb_id %d) size %d\n", + LOG_D(RLC, "%s:%d:%s: delivering SDU (rnti %d is_srb %d rb_id %d) size %d", __FILE__, __LINE__, __FUNCTION__, ue->rnti, is_srb, rb_id, size); memblock = get_free_mem_block(size, __func__); @@ -598,7 +599,7 @@ static void max_retx_reached(void *_ue, nr_rlc_entity_t *entity) exit(1); rb_found: - LOG_D(RLC, "max RETX reached on %s %d\n", + LOG_E(RLC, "max RETX reached on %s %d\n", is_srb ? "SRB" : "DRB", rb_id); @@ -640,7 +641,7 @@ static void add_rlc_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig int t_reassembly; int sn_field_length; - LOG_I(RLC,"Trying to add SRB %d\n",srb_id); + LOG_D(RLC,"Trying to add SRB %d\n",srb_id); if (srb_id != 1 && srb_id != 2) { LOG_E(RLC, "%s:%d:%s: fatal, bad srb id %d\n", __FILE__, __LINE__, __FUNCTION__, srb_id); @@ -707,7 +708,7 @@ static void add_rlc_srb(int rnti, struct NR_SRB_ToAddMod *s, NR_RLC_BearerConfig sn_field_length); nr_rlc_ue_add_srb_rlc_entity(ue, srb_id, nr_rlc_am); - LOG_I(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); + LOG_D(RLC, "%s:%d:%s: added srb %d to UE with RNTI 0x%x\n", __FILE__, __LINE__, __FUNCTION__, srb_id, rnti); } nr_rlc_manager_unlock(nr_rlc_ue_manager); } @@ -918,22 +919,22 @@ rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * const ctxt if (drb2release_listP != NULL) { LOG_E(RLC, "%s:%d:%s: TODO\n", __FILE__, __LINE__, __FUNCTION__); - exit(1); + //exit(1); } if (srb2add_listP != NULL) { for (i = 0; i < srb2add_listP->list.count; i++) { if (rlc_bearer2add_list != NULL) { - for(j = 0; j < rlc_bearer2add_list->list.count; j++){ - if(rlc_bearer2add_list->list.array[j]->servedRadioBearer != NULL){ - if(rlc_bearer2add_list->list.array[j]->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity){ - if(srb2add_listP->list.array[i]->srb_Identity == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.srb_Identity){ - add_rlc_srb(rnti, srb2add_listP->list.array[i], rlc_bearer2add_list->list.array[j]); + for(j = 0; j < rlc_bearer2add_list->list.count; j++){ + if(rlc_bearer2add_list->list.array[j]->servedRadioBearer != NULL){ + if(rlc_bearer2add_list->list.array[j]->servedRadioBearer->present == NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity){ + if(srb2add_listP->list.array[i]->srb_Identity == rlc_bearer2add_list->list.array[j]->servedRadioBearer->choice.srb_Identity){ + add_rlc_srb(rnti, srb2add_listP->list.array[i], rlc_bearer2add_list->list.array[j]); + } } - } + } } } - } } } diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h index 1a4c7789f8..6b3c228163 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h @@ -46,4 +46,4 @@ void nr_rlc_bearer_init(NR_RLC_BearerConfig_t *RLC_BearerConfig, NR_RLC_BearerCo void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config_pr); -void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig); +void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig); \ No newline at end of file diff --git a/openair2/LAYER2/rlc_v2/rlc_oai_api.c b/openair2/LAYER2/rlc_v2/rlc_oai_api.c index 9f04cdce50..0cf4b85fa2 100644 --- a/openair2/LAYER2/rlc_v2/rlc_oai_api.c +++ b/openair2/LAYER2/rlc_v2/rlc_oai_api.c @@ -1041,5 +1041,4 @@ void du_rlc_data_req(const protocol_ctxt_t *const ctxt_pP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP){ -} - +} \ No newline at end of file diff --git a/openair2/NETWORK_DRIVER/MESH/mesh.c b/openair2/NETWORK_DRIVER/MESH/mesh.c index ed87bc05f8..7e147feb68 100644 --- a/openair2/NETWORK_DRIVER/MESH/mesh.c +++ b/openair2/NETWORK_DRIVER/MESH/mesh.c @@ -886,6 +886,7 @@ int nas_mesh_DC_receive(struct cx_entity *cx,struct nas_priv *gpriv) switch (cx->state) { case NAS_CX_RELEASING_FAILURE: cx->retry=0; + /* fallthrough */ case NAS_CX_DCH: nas_mesh_DC_decode_cx_loss_ind(cx,p); // process message diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index 321e1d638f..fa76fd00bc 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -105,14 +105,8 @@ void handle_nr_uci(NR_UL_IND_t *UL_info) } UL_info->uci_ind.num_ucis = 0; - - // mark corresponding PUCCH resources as free - // NOTE: we just assume it is BWP ID 0 and 1, to be revised for multiple BWPs - RC.nrmac[mod_id]->pucch_index_used[0][slot] = 0; - RC.nrmac[mod_id]->pucch_index_used[1][slot] = 0; } - void handle_nr_ulsch(NR_UL_IND_t *UL_info) { if (UL_info->rx_ind.number_of_pdus > 0 && UL_info->crc_ind.number_crcs > 0) { diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 5b020b5988..4576dbcc9b 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -60,7 +60,7 @@ int handle_bcch_bch(module_id_t module_id, int cc_id, ssb_length, // Lssb = 64 is not support ssb_index, pduP, - ssb_start_subcarrier, + ssb_start_subcarrier, cell_id); } @@ -97,8 +97,7 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon = mac->scc != NULL ? mac->scc->tdd_UL_DL_ConfigurationCommon : mac->scc_SIB->tdd_UL_DL_ConfigurationCommon; - - if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type) /*&& get_softmodem_params()->do_ra*/) + if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type) && !get_softmodem_params()->phy_test) nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->thread_id); switch(ret){ diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c index 38a742bf74..ed3c9a5b7d 100644 --- a/openair2/PHY_INTERFACE/IF_Module.c +++ b/openair2/PHY_INTERFACE/IF_Module.c @@ -19,6 +19,8 @@ extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind); extern uint16_t sf_ahead; extern UL_RCC_IND_t UL_RCC_INFO; +extern RAN_CONTEXT_t RC; + uint16_t frame_cnt=0; void handle_rach(UL_IND_t *UL_info) { int i; @@ -685,7 +687,7 @@ static void dump_dl(Sched_Rsp_t *d) { /* debug utility functions end */ /****************************************************************************/ -void UL_indication(UL_IND_t *UL_info, L1_rxtx_proc_t *proc) { +void UL_indication(UL_IND_t *UL_info, void *proc) { AssertFatal(UL_info!=NULL,"UL_INFO is null\n"); #ifdef DUMP_FAPI dump_ul(UL_info); diff --git a/openair2/PHY_INTERFACE/IF_Module.h b/openair2/PHY_INTERFACE/IF_Module.h index 1470cbc006..096979c4fd 100644 --- a/openair2/PHY_INTERFACE/IF_Module.h +++ b/openair2/PHY_INTERFACE/IF_Module.h @@ -37,7 +37,6 @@ #include //#include "openair1/PHY/LTE_TRANSPORT/transport_eNB.h" #include "nfapi_interface.h" -#include "platform_constants.h" #include "platform_types.h" #include @@ -135,64 +134,13 @@ typedef struct { uint8_t Mod_id; int CC_id; nfapi_config_request_t *cfg; -}PHY_Config_t; +} PHY_Config_t; #include -/// Context data structure for RX/TX portion of subframe processing -typedef struct { - /// Component Carrier index - uint8_t CC_id; - /// timestamp transmitted to HW - openair0_timestamp timestamp_tx; - openair0_timestamp timestamp_rx; - /// subframe to act upon for transmission - int subframe_tx; - /// subframe to act upon for reception - int subframe_rx; - /// frame to act upon for transmission - int frame_tx; - /// frame to act upon for reception - int frame_rx; - int frame_prach; - int subframe_prach; - int frame_prach_br; - int subframe_prach_br; - /// \brief Instance count for RXn-TXnp4 processing thread. - /// \internal This variable is protected by \ref mutex_rxtx. - int instance_cnt; - /// pthread structure for RXn-TXnp4 processing thread - pthread_t pthread; - /// pthread attributes for RXn-TXnp4 processing thread - pthread_attr_t attr; - /// condition variable for tx processing thread - pthread_cond_t cond; - /// mutex for RXn-TXnp4 processing thread - pthread_mutex_t mutex; - /// scheduling parameters for RXn-TXnp4 thread - struct sched_param sched_param_rxtx; - - /// \internal This variable is protected by \ref mutex_RUs. - int instance_cnt_RUs; - /// condition variable for tx processing thread - pthread_cond_t cond_RUs; - /// mutex for RXn-TXnp4 processing thread - pthread_mutex_t mutex_RUs; - tpool_t *threadPool; - int nbEncode; - int nbDecode; - notifiedFIFO_t *respEncode; - notifiedFIFO_t *respDecode; - pthread_mutex_t mutex_emulateRF; - int instance_cnt_emulateRF; - pthread_t pthread_emulateRF; - pthread_attr_t attr_emulateRF; - pthread_cond_t cond_emulateRF; - int first_rx; -} L1_rxtx_proc_t; typedef struct IF_Module_s{ //define the function pointer - void (*UL_indication)(UL_IND_t *UL_INFO, L1_rxtx_proc_t *proc); - void (*schedule_response)(Sched_Rsp_t *Sched_INFO, L1_rxtx_proc_t *proc); + void (*UL_indication)(UL_IND_t *UL_INFO, void *proc); + void (*schedule_response)(Sched_Rsp_t *Sched_INFO, void *proc); void (*PHY_config_req)(PHY_Config_t* config_INFO); void (*PHY_config_update_sib2_req)(PHY_Config_t* config_INFO); @@ -209,7 +157,7 @@ void IF_Module_kill(int Mod_id); /*Interface for uplink, transmitting the Preamble(list), ULSCH SDU, NAK, Tick (trigger scheduler) */ -void UL_indication(UL_IND_t *UL_INFO, L1_rxtx_proc_t *proc); +void UL_indication(UL_IND_t *UL_INFO, void *proc); /*Interface for Downlink, transmitting the DLSCH SDU, DCI SDU*/ void Schedule_Response(Sched_Rsp_t *Sched_INFO); diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index 027a629992..f0279f0ef2 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -392,7 +392,7 @@ rrc_rx_tx( current_timestamp_ms, ctxt_pP->frame, estimated_distance); - LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.Status); + LOG_D(LOCALIZE, " RRC status %d\n", ue_context_p->ue_context.StatusRrc); push_front(&RC.rrc[ctxt_pP->module_id]->loc_list, estimated_distance); RC.rrc[ctxt_pP->module_id]->reference_timestamp_ms = current_timestamp_ms; diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c index cd99ddfedc..0b767b8ad6 100644 --- a/openair2/RRC/LTE/L2_interface.c +++ b/openair2/RRC/LTE/L2_interface.c @@ -49,8 +49,6 @@ #include "intertask_interface.h" #include "flexran_agent_extern.h" -#undef C_RNTI // C_RNTI is used in F1AP generated code, prevent preprocessor replace -//#include "f1ap_du_rrc_message_transfer.h" #include "openair2/F1AP/f1ap_du_rrc_message_transfer.h" extern RAN_CONTEXT_t RC; @@ -318,8 +316,7 @@ mac_rrc_data_ind( sduP, sdu_lenP, NULL, - 0 - ); + 0); return(0); } @@ -351,12 +348,12 @@ mac_rrc_data_ind( ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt.module_id],rntiP); if(ue_context_p) { - if (ue_context_p->ue_context.Status != RRC_RECONFIGURED) { - LOG_E(RRC,"[eNB %d] Received C-RNTI ,but UE %x status(%d) not RRC_RECONFIGURED\n",module_idP,rntiP,ue_context_p->ue_context.Status); + if (ue_context_p->ue_context.StatusRrc != RRC_RECONFIGURED) { + LOG_E(RRC,"[eNB %d] Received C-RNTI ,but UE %x status(%d) not RRC_RECONFIGURED\n",module_idP,rntiP,ue_context_p->ue_context.StatusRrc); return (-1); } rrc_eNB_generate_defaultRRCConnectionReconfiguration(&ctxt,ue_context_p,0); - ue_context_p->ue_context.Status = RRC_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = RRC_RECONFIGURED; } } @@ -378,7 +375,7 @@ mac_eNB_get_rrc_status( 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); + return(ue_context_p->ue_context.StatusRrc); } else { return RRC_INACTIVE; } diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index 61bce26b2c..ce26aeef87 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -2728,7 +2728,7 @@ do_RRCConnectionSetup( // assign_enum(&physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax, //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; + physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = LTE_SchedulingRequestConfig__setup__dsr_TransMax_n64; 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 ; @@ -3220,56 +3220,58 @@ uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count=0; ASN_SEQUENCE_ADD(&dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list, &rat); - - /* request NR configuration */ LTE_UECapabilityEnquiry_r8_IEs_t *r8 = &dl_dcch_msg.message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8; LTE_UECapabilityEnquiry_v8a0_IEs_t r8_a0; LTE_UECapabilityEnquiry_v1180_IEs_t r11_80; LTE_UECapabilityEnquiry_v1310_IEs_t r13_10; LTE_UECapabilityEnquiry_v1430_IEs_t r14_30; LTE_UECapabilityEnquiry_v1510_IEs_t r15_10; - - memset(&r8_a0, 0, sizeof(r8_a0)); - memset(&r11_80, 0, sizeof(r11_80)); - memset(&r13_10, 0, sizeof(r13_10)); - memset(&r14_30, 0, sizeof(r14_30)); - memset(&r15_10, 0, sizeof(r15_10)); - - r8->nonCriticalExtension = &r8_a0; - r8_a0.nonCriticalExtension = &r11_80; - r11_80.nonCriticalExtension = &r13_10; - r13_10.nonCriticalExtension = &r14_30; - r14_30.nonCriticalExtension = &r15_10; - - /* TODO: no hardcoded values here */ - - nsa_band_list = (NR_FreqBandList_t *)calloc(1, sizeof(NR_FreqBandList_t)); - - nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); - nsa_band->present = NR_FreqBandInformation_PR_bandInformationEUTRA; - nsa_band->choice.bandInformationEUTRA = (NR_FreqBandInformationEUTRA_t *) calloc(1, sizeof(NR_FreqBandInformationEUTRA_t)); - nsa_band->choice.bandInformationEUTRA->bandEUTRA = eutra_band; - ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); - - nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); - nsa_band->present = NR_FreqBandInformation_PR_bandInformationNR; - nsa_band->choice.bandInformationNR = (NR_FreqBandInformationNR_t *) calloc(1, sizeof(NR_FreqBandInformationNR_t)); - if(nr_band > 0) - nsa_band->choice.bandInformationNR->bandNR = nr_band; - else - nsa_band->choice.bandInformationNR->bandNR = 78; - ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); - OCTET_STRING_t req_freq; - //unsigned char req_freq_buf[5] = { 0x00, 0x20, 0x1a, 0x02, 0x68 }; // bands 7 & nr78 - unsigned char req_freq_buf[1024]; - enc_rval = uper_encode_to_buffer(&asn_DEF_NR_FreqBandList, - NULL, - (void *)nsa_band_list, - req_freq_buf, - 1024); - xer_fprint(stdout, &asn_DEF_NR_FreqBandList, (void *)nsa_band_list); + if (nr_band>0) { + + /* request NR configuration */ + + memset(&r8_a0, 0, sizeof(r8_a0)); + memset(&r11_80, 0, sizeof(r11_80)); + memset(&r13_10, 0, sizeof(r13_10)); + memset(&r14_30, 0, sizeof(r14_30)); + memset(&r15_10, 0, sizeof(r15_10)); + + r8->nonCriticalExtension = &r8_a0; + r8_a0.nonCriticalExtension = &r11_80; + r11_80.nonCriticalExtension = &r13_10; + r13_10.nonCriticalExtension = &r14_30; + r14_30.nonCriticalExtension = &r15_10; + + /* TODO: no hardcoded values here */ + + nsa_band_list = (NR_FreqBandList_t *)calloc(1, sizeof(NR_FreqBandList_t)); + + nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); + nsa_band->present = NR_FreqBandInformation_PR_bandInformationEUTRA; + nsa_band->choice.bandInformationEUTRA = (NR_FreqBandInformationEUTRA_t *) calloc(1, sizeof(NR_FreqBandInformationEUTRA_t)); + nsa_band->choice.bandInformationEUTRA->bandEUTRA = eutra_band; + ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); + + nsa_band = (NR_FreqBandInformation_t *) calloc(1,sizeof(NR_FreqBandInformation_t)); + nsa_band->present = NR_FreqBandInformation_PR_bandInformationNR; + nsa_band->choice.bandInformationNR = (NR_FreqBandInformationNR_t *) calloc(1, sizeof(NR_FreqBandInformationNR_t)); + //if(nr_band > 0) + nsa_band->choice.bandInformationNR->bandNR = nr_band; + //else + // nsa_band->choice.bandInformationNR->bandNR = 78; + ASN_SEQUENCE_ADD(&nsa_band_list->list, nsa_band); + + //unsigned char req_freq_buf[5] = { 0x00, 0x20, 0x1a, 0x02, 0x68 }; // bands 7 & nr78 + unsigned char req_freq_buf[1024]; + enc_rval = uper_encode_to_buffer(&asn_DEF_NR_FreqBandList, + NULL, + (void *)nsa_band_list, + req_freq_buf, + 1024); + + xer_fprint(stdout, &asn_DEF_NR_FreqBandList, (void *)nsa_band_list); @@ -3280,14 +3282,16 @@ uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, //0x01, 0x60, 0x18, 0x05, 0x80, 0xc0, 0x04, 0x04, 0xc1, 0x2c, 0x10, 0x08, 0x20, 0x30, 0x40, 0xe0, 0x82, 0x40, 0x28, 0x80, 0x9a // }; - req_freq.buf = req_freq_buf; - req_freq.size = (enc_rval.encoded+7)/8; + req_freq.buf = req_freq_buf; + req_freq.size = (enc_rval.encoded+7)/8; // req_freq.size = 21; - r15_10.requestedFreqBandsNR_MRDC_r15 = &req_freq; - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_DL_DCCH_Message, (void *)&dl_dcch_msg); + r15_10.requestedFreqBandsNR_MRDC_r15 = &req_freq; + // Add request for eutra-nr } +// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + 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, diff --git a/openair2/RRC/LTE/defs_NB_IoT.h b/openair2/RRC/LTE/defs_NB_IoT.h index 2a34971c23..3907d2321d 100644 --- a/openair2/RRC/LTE/defs_NB_IoT.h +++ b/openair2/RRC/LTE/defs_NB_IoT.h @@ -211,13 +211,13 @@ typedef struct RB_INFO_TABLE_ENTRY_NB_IoT_s { RB_INFO_NB_IoT Rb_info; uint8_t Active; uint32_t Next_check_frame; - uint8_t Status; + uint8_t status; } RB_INFO_TABLE_ENTRY_NB_IoT; typedef struct SRB_INFO_TABLE_ENTRY_NB_IoT_s { SRB_INFO_NB_IoT Srb_info; uint8_t Active; - uint8_t Status; + uint8_t status; uint32_t Next_check_frame; } SRB_INFO_TABLE_ENTRY_NB_IoT; @@ -269,7 +269,7 @@ typedef struct eNB_RRC_UE_NB_IoT_s { e_LTE_CipheringAlgorithm_r12 ciphering_algorithm; //Specs. TS 36.331 V14.1.0 pag 432 Change position of chipering enumerative w.r.t previous version e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; - uint8_t Status; + uint8_t status; rnti_t rnti; uint64_t random_ue_identity; diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index e3d28d8a0f..b2230df623 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -492,7 +492,7 @@ rrc_t310_expiration( UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Srb_info.Srb_id, Rlc_info_um); UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Active = 0; - UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Status = IDLE; + UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].StatusSrb = IDLE; UE_rrc_inst[ctxt_pP->module_id].Srb2[eNB_index].Next_check_frame = 0; } } else { // Restablishment procedure @@ -671,7 +671,7 @@ rrc_ue_establish_srb1( { // add descriptor from RRC PDU UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Active = 1; - UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG + UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].StatusSrb = RADIO_CONFIG_OK;//RADIO CFG UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Srb_id = 1; // copy default configuration for now // memcpy(&UE_rrc_inst[ue_mod_idP].Srb1[eNB_index].Srb_info.Lchan_desc[0],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); @@ -695,7 +695,7 @@ rrc_ue_establish_srb2( { // add descriptor from RRC PDU UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Active = 1; - UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG + UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].StatusSrb = RADIO_CONFIG_OK;//RADIO CFG UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Srb_info.Srb_id = 2; // copy default configuration for now // memcpy(&UE_rrc_inst[ue_mod_idP].Srb2[eNB_index].Srb_info.Lchan_desc[0],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h index 6615541662..1c02c3de46 100644 --- a/openair2/RRC/LTE/rrc_defs.h +++ b/openair2/RRC/LTE/rrc_defs.h @@ -519,13 +519,13 @@ typedef struct RB_INFO_TABLE_ENTRY_s { RB_INFO Rb_info; uint8_t Active; uint32_t Next_check_frame; - uint8_t Status; + uint8_t StatusRb; } RB_INFO_TABLE_ENTRY; typedef struct SRB_INFO_TABLE_ENTRY_s { SRB_INFO Srb_info; uint8_t Active; - uint8_t Status; + uint8_t StatusSrb; uint32_t Next_check_frame; } SRB_INFO_TABLE_ENTRY; @@ -599,7 +599,7 @@ typedef struct eNB_RRC_UE_s { LTE_CipheringAlgorithm_r12_t ciphering_algorithm; e_LTE_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm; - uint8_t Status; // RRC status, type enum UE_STATE_t + uint8_t StatusRrc; // RRC status, type enum UE_STATE_t rnti_t rnti; int gnb_rnti; //RNTI of the UE at the gNB if in ENDC connection int gnb_x2_assoc_id; diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 881e5b8ad1..006f03a63e 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -997,6 +997,7 @@ void put_UE_in_freelist(module_id_t mod_id, rnti_t rnti, boolean_t removeFlag) { 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->UE_free_ctrl[free_list->tail_freelist].raFlag = 0; free_list->num_UEs++; eNB_MAC->UE_release_req.ue_release_request_body.ue_release_request_TLVs_list[eNB_MAC->UE_release_req.ue_release_request_body.number_of_TLVs].rnti = rnti; eNB_MAC->UE_release_req.ue_release_request_body.number_of_TLVs++; @@ -1046,17 +1047,17 @@ void release_UE_in_freeList(module_id_t mod_id) { eNB_PHY = RC.eNB[mod_id][CC_id]; int id; // clean ULSCH entries for rnti - id = find_ulsch(rnti,eNB_PHY,SEARCH_EXIST); + id = find_ulsch(rnti,eNB_PHY,eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].raFlag ? SEARCH_EXIST_RA : SEARCH_EXIST); if (id>=0) clean_eNb_ulsch(eNB_PHY->ulsch[id]); // clean DLSCH entries for rnti - id = find_dlsch(rnti,eNB_PHY,SEARCH_EXIST); + id = find_dlsch(rnti,eNB_PHY,eNB_MAC->UE_free_list.UE_free_ctrl[ue_num].raFlag ? SEARCH_EXIST_RA : SEARCH_EXIST); if (id>=0) clean_eNb_dlsch(eNB_PHY->dlsch[id][0]); // clean UCI entries for rnti - for (i=0; iuci_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)); @@ -1090,7 +1091,7 @@ void release_UE_in_freeList(module_id_t mod_id) { clean_eNb_ulsch(ulsch); } - for (i=0; iuci_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)); @@ -1202,7 +1203,7 @@ rrc_eNB_process_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.Status = RRC_CONNECTED; + ue_context_pP->ue_context.StatusRrc = RRC_CONNECTED; ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity timer when UE goes into RRC_CONNECTED T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), @@ -1578,7 +1579,7 @@ rrc_eNB_process_RRCConnectionReestablishmentComplete( int measurements_enabled; uint8_t next_xid = rrc_eNB_get_next_transaction_identifier(ctxt_pP->module_id); int ret = 0; - ue_context_pP->ue_context.Status = RRC_CONNECTED; + ue_context_pP->ue_context.StatusRrc = 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]; @@ -2208,7 +2209,7 @@ rrc_eNB_generate_RRCConnectionRelease( #if 0 if(ue_context_pP != NULL) { - if(ue_context_pP->ue_context.Status == RRC_NR_NSA) { + if(ue_context_pP->ue_context.StatusRrc == RRC_NR_NSA) { //rrc_eNB_generate_SgNBReleaseRequest(ctxt_pP,ue_context_pP); } } @@ -3442,6 +3443,7 @@ void rrc_eNB_generate_defaultRRCConnectionReconfiguration(const protocol_ctxt_t ASN_SEQUENCE_ADD(&ReportConfig_list->list, ReportConfig_A5); if (ue_context_pP->ue_context.does_nr) { + LOG_I(RRC,"Configuring measurement for NR cell\n"); ReportConfig_NR->reportConfigId = 7; ReportConfig_NR->reportConfig.present = LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigInterRAT; ReportConfig_NR->reportConfig.choice.reportConfigInterRAT.triggerType.present = LTE_ReportConfigInterRAT__triggerType_PR_event; @@ -4568,7 +4570,6 @@ rrc_eNB_process_MeasurementReport( case 7: LOG_D(RRC, "NR event frame %d subframe %d\n", ctxt_pP->frame, ctxt_pP->subframe); - printf("NR event frame %d subframe %d\n", ctxt_pP->frame, ctxt_pP->subframe); break; default: @@ -4586,13 +4587,16 @@ rrc_eNB_process_MeasurementReport( /* TODO: improve NR triggering */ if (measResults2->measId == 7) { - if ((ue_context_pP->ue_context.Status != RRC_NR_NSA) && (ue_context_pP->ue_context.Status != RRC_NR_NSA_RECONFIGURED)) { + if ((ue_context_pP->ue_context.StatusRrc != RRC_NR_NSA) && (ue_context_pP->ue_context.StatusRrc != RRC_NR_NSA_RECONFIGURED)) { MessageDef *msg; - ue_context_pP->ue_context.Status = RRC_NR_NSA; + ue_context_pP->ue_context.StatusRrc = RRC_NR_NSA; ue_context_pP->ue_context.gnb_rnti = -1; // set when receiving X2AP_ENDC_SGNB_ADDITION_REQ_ACK ue_context_pP->ue_context.gnb_x2_assoc_id = -1; // set when receiving X2AP_ENDC_SGNB_ADDITION_REQ_ACK if(is_en_dc_supported(ue_context_pP->ue_context.UE_Capability)) { + + AssertFatal(measResults2->measResultNeighCells!=NULL,"no measResultNeighCells, shouldn't happen!\n"); + AssertFatal(measResults2->measResultNeighCells->present==LTE_MeasResults__measResultNeighCells_PR_measResultNeighCellListNR_r15,"field is not LTE_MeasResults__measResultNeighCells_PR_measResultNeighCellListNR_r15"); /** to add gNB as Secondary node CG-ConfigInfo to be added as per 36.423 r15 **/ if(encode_CG_ConfigInfo(enc_buf,sizeof(enc_buf),ue_context_pP,&enc_size) == RRC_OK) LOG_I(RRC,"CG-ConfigInfo encoded successfully\n"); @@ -4611,6 +4615,7 @@ rrc_eNB_process_MeasurementReport( X2AP_ENDC_SGNB_ADDITION_REQ(msg).rrc_buffer_size = enc_size; X2AP_ENDC_SGNB_ADDITION_REQ(msg).target_physCellId + //= measResults2->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->pci_r15; = measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId; //For the moment we have a single E-RAB which will be the one to be added to the gNB @@ -4633,6 +4638,32 @@ rrc_eNB_process_MeasurementReport( return; } } + + if (!ue_context_pP->ue_context.measResults->measResultNeighCells) { + ue_context_pP->ue_context.measResults->measResultNeighCells = calloc(1,sizeof(*ue_context_pP->ue_context.measResults->measResultNeighCells)); + ue_context_pP->ue_context.measResults->measResultNeighCells->present = LTE_MeasResults__measResultNeighCells_PR_measResultNeighCellListNR_r15; + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array = calloc(1, sizeof(*ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array)); + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0] = calloc(1, sizeof(*ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0])); + ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.count = 1; + } + struct LTE_MeasResultCellNR_r15 *ueCtxtMeasResultCellNR_r15 = ue_context_pP->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]; + const struct LTE_MeasResultCellNR_r15 *measNeighCellNR0 = measResults2->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]; + ueCtxtMeasResultCellNR_r15->pci_r15 = measNeighCellNR0->pci_r15; + if (!ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrpResult_r15) + ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrpResult_r15 = calloc(1, sizeof(*ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrpResult_r15)); + if (!ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrqResult_r15) + ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrqResult_r15 = calloc(1, sizeof(*ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrqResult_r15)); + *ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrpResult_r15 = *measNeighCellNR0->measResultCell_r15.rsrpResult_r15; + *ueCtxtMeasResultCellNR_r15->measResultCell_r15.rsrqResult_r15 = *measNeighCellNR0->measResultCell_r15.rsrqResult_r15; + if (measNeighCellNR0->measResultRS_IndexList_r15) { + if (!ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15) { + ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15 = calloc(1,sizeof(*ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15)); + ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15->list.array = calloc(1, sizeof(ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15->list.array)); + ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15->list.array[0] = calloc(1, sizeof(*ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15->list.array)); + ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15->list.count = 1; + } + ueCtxtMeasResultCellNR_r15->measResultRS_IndexList_r15->list.array[0]->ssb_Index_r15 = measNeighCellNR0->measResultRS_IndexList_r15->list.array[0]->ssb_Index_r15; + } } if (measResults2->measResultNeighCells == NULL) @@ -4694,12 +4725,12 @@ rrc_eNB_process_MeasurementReport( LOG_D(RRC, "A3 event is triggered...\n"); /* if the UE is not in handover mode, start handover procedure */ - if (ue_context_pP->ue_context.Status != RRC_HO_EXECUTION) { + if (ue_context_pP->ue_context.StatusRrc != RRC_HO_EXECUTION) { MessageDef *msg; LOG_I(RRC, "Send HO preparation message at frame %d and subframe %d \n", ctxt_pP->frame, ctxt_pP->subframe); /* HO info struct may not be needed anymore */ ue_context_pP->ue_context.handover_info = CALLOC(1, sizeof(*(ue_context_pP->ue_context.handover_info))); - ue_context_pP->ue_context.Status = RRC_HO_EXECUTION; + ue_context_pP->ue_context.StatusRrc = RRC_HO_EXECUTION; ue_context_pP->ue_context.handover_info->state = HO_REQUEST; /* HO Preparation message */ msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_HANDOVER_REQ); @@ -4831,7 +4862,7 @@ void rrc_eNB_process_handoverPreparationInformation(int mod_id, x2ap_handover_re RB_INSERT(rrc_ue_tree_s, &RC.rrc[mod_id]->rrc_ue_head, ue_context_target_p); LOG_D(RRC, "eNB %d: Created new UE context uid %u\n", mod_id, ue_context_target_p->local_uid); ue_context_target_p->ue_context.handover_info = CALLOC(1, sizeof(*(ue_context_target_p->ue_context.handover_info))); - //ue_context_target_p->ue_context.Status = RRC_HO_EXECUTION; + //ue_context_target_p->ue_context.StatusRrc = RRC_HO_EXECUTION; //ue_context_target_p->ue_context.handover_info->state = HO_ACK; ue_context_target_p->ue_context.handover_info->x2_id = m->x2_id; ue_context_target_p->ue_context.handover_info->assoc_id = m->target_assoc_id; @@ -4906,7 +4937,7 @@ void rrc_eNB_process_handoverPreparationInformation(int mod_id, x2ap_handover_re } rrc_eNB_process_X2AP_TUNNEL_SETUP_REQ(mod_id, ue_context_target_p); - ue_context_target_p->ue_context.Status = RRC_HO_EXECUTION; + ue_context_target_p->ue_context.StatusRrc = RRC_HO_EXECUTION; ue_context_target_p->ue_context.handover_info->state = HO_ACK; } @@ -5021,7 +5052,7 @@ flexran_rrc_eNB_trigger_handover (int mod_id, LOG_D(RRC, "Handover is triggered by FlexRAN controller...\n"); /* if the UE is not in handover mode, start handover procedure */ - if (ue_context_pP->ue_context.Status != RRC_HO_EXECUTION) { + if (ue_context_pP->ue_context.StatusRrc != RRC_HO_EXECUTION) { MessageDef *msg; LOG_I(RRC, "Send HO preparation message at frame %d and subframe %d \n", ctxt_pP->frame, ctxt_pP->subframe); /* Check memory leakage for handover info */ @@ -5029,7 +5060,7 @@ flexran_rrc_eNB_trigger_handover (int mod_id, //free(ue_context_pP->ue_context.handover_info); //} ue_context_pP->ue_context.handover_info = CALLOC(1, sizeof(*(ue_context_pP->ue_context.handover_info))); - ue_context_pP->ue_context.Status = RRC_HO_EXECUTION; + ue_context_pP->ue_context.StatusRrc = RRC_HO_EXECUTION; ue_context_pP->ue_context.handover_info->state = HO_REQUEST; /* HO Preparation message */ msg = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_HANDOVER_REQ); @@ -5090,7 +5121,7 @@ check_handovers( 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 (ue_context_p->ue_context.Status == RRC_HO_EXECUTION && ue_context_p->ue_context.handover_info != NULL) { + if (ue_context_p->ue_context.StatusRrc == RRC_HO_EXECUTION && ue_context_p->ue_context.handover_info != NULL) { /* in the source, UE in HO_PREPARE mode */ if (ue_context_p->ue_context.handover_info->state == HO_PREPARE) { LOG_D(RRC, @@ -5141,7 +5172,7 @@ check_handovers( } } - if (ue_context_p->ue_context.Status == RRC_RECONFIGURED + if (ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED && ue_context_p->ue_context.handover_info != NULL && ue_context_p->ue_context.handover_info->forwarding_state == FORWARDING_NO_EMPTY ) { MessageDef *msg_p; @@ -5207,7 +5238,7 @@ check_handovers( ue_context_p->ue_context.handover_info->forwarding_state = FORWARDING_EMPTY; } - if( ue_context_p->ue_context.Status == RRC_RECONFIGURED && + if( ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED && ue_context_p->ue_context.handover_info != NULL && ue_context_p->ue_context.handover_info->forwarding_state == FORWARDING_EMPTY && ue_context_p->ue_context.handover_info->endmark_state == ENDMARK_NO_EMPTY && @@ -5710,7 +5741,7 @@ rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ct //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; + LTE_SchedulingRequestConfig__setup__dsr_TransMax_n64; 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); @@ -7198,7 +7229,7 @@ rrc_eNB_decode_ccch( } //c-plane not end - if((ue_context_p->ue_context.Status != RRC_RECONFIGURED) && (ue_context_p->ue_context.reestablishment_cause == LTE_ReestablishmentCause_spare1)) { + if((ue_context_p->ue_context.StatusRrc != RRC_RECONFIGURED) && (ue_context_p->ue_context.reestablishment_cause == LTE_ReestablishmentCause_spare1)) { LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" LTE_RRCConnectionReestablishmentRequest (UE %x c-plane is not end), let's reject the UE\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),c_rnti); @@ -7210,9 +7241,9 @@ rrc_eNB_decode_ccch( LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" RRRCConnectionReconfigurationComplete(Previous) don't receive, delete the Previous UE,\nprevious Status %d, new Status RRC_RECONFIGURED\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p->ue_context.Status + ue_context_p->ue_context.StatusRrc ); - ue_context_p->ue_context.Status = RRC_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = RRC_RECONFIGURED; protocol_ctxt_t ctxt_old_p; PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt_old_p, ctxt_pP->instance, @@ -7581,7 +7612,205 @@ rrc_eNB_decode_ccch( return rval; } +#define NCE nonCriticalExtension + +static void +get_ue_Category( + LTE_UE_EUTRA_Capability_t *c, + long *catDL, + long *catUL +) +{ + if (c != NULL) { // v8.6 + *catDL=c->ue_Category; *catUL=c->ue_Category; + struct LTE_UE_EUTRA_Capability_v920_IEs *c92=c->NCE; + if (c92 != NULL) { // v9.2 + struct LTE_UE_EUTRA_Capability_v940_IEs *c94=c92->NCE; + if (c94 != NULL) { // v9.4 + struct LTE_UE_EUTRA_Capability_v1020_IEs *c102=c94->NCE; + if (c102 != NULL) { // v10.2 + if (c102->ue_Category_v1020) {*catDL=*c102->ue_Category_v1020;*catUL=*c102->ue_Category_v1020;} + struct LTE_UE_EUTRA_Capability_v1060_IEs *c106=c102->NCE; + if (c106 != NULL) { // v10.6 + struct LTE_UE_EUTRA_Capability_v1090_IEs *c109=c106->NCE; + if (c109 != NULL) { // v10.9 + struct LTE_UE_EUTRA_Capability_v1130_IEs *c113=c109->NCE; + if (c113 != NULL) { // v11.3 + struct LTE_UE_EUTRA_Capability_v1170_IEs *c117=c113->NCE; + if (c117 != NULL) { // v11.7 + if (c117->ue_Category_v1170) {*catDL=*c117->ue_Category_v1170; + struct LTE_UE_EUTRA_Capability_v1180_IEs *c118=c117->NCE; + if (c118 != NULL) { // v11.8 + struct LTE_UE_EUTRA_Capability_v11a0_IEs *c11a=c118->NCE; + if (c11a != NULL) { // v11.a + if (c11a->ue_Category_v11a0) {*catDL=*c11a->ue_Category_v11a0;*catUL=*c11a->ue_Category_v11a0;} + struct LTE_UE_EUTRA_Capability_v1250_IEs *c125=c11a->NCE; + if (c125 != NULL) { // v12.5 + if (c125->ue_CategoryDL_r12) *catDL=*c125->ue_CategoryDL_r12; + if (c125->ue_CategoryUL_r12) *catUL=*c125->ue_CategoryUL_r12; + struct LTE_UE_EUTRA_Capability_v1260_IEs *c126=c125->NCE; + if (c126 != NULL) { // v12.6 + if (c126->ue_CategoryDL_v1260) *catDL=*c126->ue_CategoryDL_v1260; + struct LTE_UE_EUTRA_Capability_v1270_IEs *c127=c126->NCE; + if (c127 != NULL) { // v12.7 + struct LTE_UE_EUTRA_Capability_v1280_IEs *c128=c127->NCE; + if (c128 != NULL) { // v12.8 + struct LTE_UE_EUTRA_Capability_v1310_IEs *c131=c128->NCE; + if (c131 != NULL) { // v13.1 + if (c131->ue_CategoryDL_v1310 && *c131->ue_CategoryDL_v1310 == 0) *catDL=17; + if (c131->ue_CategoryDL_v1310 && *c131->ue_CategoryDL_v1310 == 1) *catDL=-1; + if (c131->ue_CategoryUL_v1310 && *c131->ue_CategoryUL_v1310 == 0) *catUL=14; + if (c131->ue_CategoryUL_v1310 && *c131->ue_CategoryUL_v1310 == 1) *catUL=-1; + struct LTE_UE_EUTRA_Capability_v1320_IEs *c132=c131->NCE; + if (c132 != NULL) { //v13.2 + struct LTE_UE_EUTRA_Capability_v1330_IEs *c133=c132->NCE; + if (c133 != NULL) { // v13.3 + if (c133->ue_CategoryDL_v1330) *catDL=*c133->ue_CategoryDL_v1330; + struct LTE_UE_EUTRA_Capability_v1340_IEs *c134=c133->NCE; + if (c134 != NULL) { // v13.4 + if (c134->ue_CategoryUL_v1340) *catUL=*c134->ue_CategoryUL_v1340; + struct LTE_UE_EUTRA_Capability_v1350_IEs *c135=c134->NCE; + if (c135 != NULL) { // v13.5 + if (c135->ue_CategoryDL_v1350) *catDL=99; // Cat 1Bis + if (c135->ue_CategoryUL_v1350) *catUL=99; // Cat 1Bis + struct LTE_UE_EUTRA_Capability_v1360_IEs *c136=c135->NCE; + if (c136 != NULL) { // v13.6 + struct LTE_UE_EUTRA_Capability_v1430_IEs *c143=c136->NCE; + if (c143 != NULL) { // v14.3 + if (c143->ue_CategoryDL_v1430 && *c143->ue_CategoryDL_v1430 == LTE_UE_EUTRA_Capability_v1430_IEs__ue_CategoryDL_v1430_m2) *catDL=-2; + if (c143->ue_CategoryUL_v1430 && *c143->ue_CategoryUL_v1430 == LTE_UE_EUTRA_Capability_v1430_IEs__ue_CategoryDL_v1430_m2) *catUL=-2; + if (c143->ue_CategoryUL_v1430) *catUL=16+*c143->ue_CategoryUL_v1430; + if (c143->ue_CategoryUL_v1430b)*catUL=21; + struct LTE_UE_EUTRA_Capability_v1440_IEs *c144=c143->NCE; + if (c144 != NULL) { // v14.4 + struct LTE_UE_EUTRA_Capability_v1450_IEs *c145=c144->NCE; + if (c145 != NULL) { // v14.5 + if (c145->ue_CategoryDL_v1450) *catDL=*c145->ue_CategoryDL_v1450; + struct LTE_UE_EUTRA_Capability_v1460_IEs *c146=c145->NCE; + if (c146 != NULL) { // v14.6 + if (c146->ue_CategoryDL_v1460) *catDL=*c146->ue_CategoryDL_v1460; + struct LTE_UE_EUTRA_Capability_v1510_IEs *c151=c146->NCE; + if (c151 != NULL) { // v15.1 + struct LTE_UE_EUTRA_Capability_v1520_IEs *c152=c151->NCE; + if (c152 != NULL) { // v15.20 + struct LTE_UE_EUTRA_Capability_v1530_IEs *c153=c152->NCE; + if (c153 != NULL) { // v15.30 + if (c153->ue_CategoryDL_v1530) *catDL=*c153->ue_CategoryDL_v1530; + if (c153->ue_CategoryUL_v1530) *catUL=*c153->ue_CategoryUL_v1530; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + +static int +is_ul_64QAM_supported( + LTE_UE_EUTRA_Capability_t *c +) //----------------------------------------------------------------------------- +{ + return c != NULL // R8 + && c->NCE != NULL // R92 + && c->NCE->NCE != NULL // R94 + && c->NCE->NCE->NCE != NULL // R102 + && c->NCE->NCE->NCE->NCE != NULL // R106 + && c->NCE->NCE->NCE->NCE->NCE != NULL // R109 + && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R113 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R117 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R118 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R11a + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R125 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250->list.array != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250->list.array[0]->ul_64QAM_r12 != NULL + && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250->list.array[0]->ul_64QAM_r12==LTE_SupportedBandEUTRA_v1250__ul_64QAM_r12_supported; +} + +static int +is_dl_256QAM_supported( + LTE_UE_EUTRA_Capability_t *c +) +//----------------------------------------------------------------------------- +{ + return c != NULL // R8 + && c->NCE != NULL // R92 + && c->NCE->NCE != NULL // R94 + && c->NCE->NCE->NCE != NULL // R102 + && c->NCE->NCE->NCE->NCE != NULL // R106 + && c->NCE->NCE->NCE->NCE->NCE != NULL // R109 + && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R113 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R117 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R118 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R11a + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R125 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250->list.array != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250->list.array[0]->dl_256QAM_r12 != NULL + && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1250->supportedBandListEUTRA_v1250->list.array[0]->dl_256QAM_r12==LTE_SupportedBandEUTRA_v1250__dl_256QAM_r12_supported; + +} +static int +is_ul_256QAM_supported( + LTE_UE_EUTRA_Capability_t *c +) +//----------------------------------------------------------------------------- +{ + return c != NULL // R8 + && c->NCE != NULL // R92 + && c->NCE->NCE != NULL // R94 + && c->NCE->NCE->NCE != NULL // R102 + && c->NCE->NCE->NCE->NCE != NULL // R106 + && c->NCE->NCE->NCE->NCE->NCE != NULL // R109 + && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R113 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R117 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R118 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R11a + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R125 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R126 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // 127 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // 128 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //131 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //132 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //133 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //134 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //135 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //136 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //143 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430->supportedBandCombination_v1430 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430->supportedBandCombination_v1430->list.array != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430->supportedBandCombination_v1430->list.array[0]->bandParameterList_v1430 != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430->supportedBandCombination_v1430->list.array[0]->bandParameterList_v1430->list.array != NULL + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430->supportedBandCombination_v1430->list.array[0]->bandParameterList_v1430->list.array[0]->ul_256QAM_r14!=NULL + && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->rf_Parameters_v1430->supportedBandCombination_v1430->list.array[0]->bandParameterList_v1430->list.array[0]->ul_256QAM_r14==LTE_BandParameters_v1430__ul_256QAM_r14_supported; +} + static int is_en_dc_supported( LTE_UE_EUTRA_Capability_t *c @@ -7591,32 +7820,31 @@ is_en_dc_supported( /* to be refined - check that the bands supported by the UE include * the band of the gNB */ -#define NCE nonCriticalExtension - return c != NULL - && c->NCE != NULL - && c->NCE->NCE != NULL - && c->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL - && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL + return c != NULL // R8 + && c->NCE != NULL // R92 + && c->NCE->NCE != NULL // R94 + && c->NCE->NCE->NCE != NULL // R102 + && c->NCE->NCE->NCE->NCE != NULL // R106 + && c->NCE->NCE->NCE->NCE->NCE != NULL // R109 + && c->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R113 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R117 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R118 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R11a + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R125 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // R126 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // 127 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL // 128 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //131 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //132 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //133 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //134 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //135 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //136 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //143 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //144 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //145 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //146 + && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE != NULL //151 && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15 != NULL && c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 != NULL && *c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->irat_ParametersNR_r15->en_DC_r15 == @@ -7624,6 +7852,45 @@ is_en_dc_supported( #undef NCE } +int to_nr_rsrpq(long rsrpq_result,int nr_band) { + + switch(nr_band) { + case 1: // A + case 70: + case 74: + case 34: + case 38: + case 39: + case 40: + case 50: + case 51: + return((rsrpq_result*10)-1180); + case 66: // B + return((rsrpq_result*10)-1175); + case 77: // C + case 78: + case 79: + return((rsrpq_result*10)-1170); + case 28: // D + return((rsrpq_result*10)-1165); + case 2: + case 5: + case 7: + case 41: // E + return((rsrpq_result*10)-1160); + case 3: // G + case 8: + case 12: + case 20: + case 71: + return((rsrpq_result*10)-1150); + case 25: // H + return((rsrpq_result*10)-1145); + default: + AssertFatal(1==0,"Illegal NR band %d\n",nr_band); + } +} + //----------------------------------------------------------------------------- int rrc_eNB_decode_dcch( @@ -7748,7 +8015,7 @@ rrc_eNB_decode_dcch( int flexran_agent_handover = 0; if (EPC_MODE_ENABLED) { - if (ue_context_p->ue_context.Status == RRC_RECONFIGURED) { + if (ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED) { dedicated_DRB = 1; LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_RECONFIGURED (dedicated DRB, xid %ld)\n", @@ -7773,7 +8040,7 @@ rrc_eNB_decode_dcch( dedicated_DRB = 2; RC.mac[ctxt_pP->module_id]->UE_info.UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; } - } else if (ue_context_p->ue_context.Status == RRC_HO_EXECUTION) { + } else if (ue_context_p->ue_context.StatusRrc == RRC_HO_EXECUTION) { int16_t UE_id = find_UE_id(ctxt_pP->module_id, ctxt_pP->rnti); if(UE_id == -1) { @@ -7787,7 +8054,7 @@ rrc_eNB_decode_dcch( RC.rrc[ctxt_pP->module_id]->Nb_ue++; dedicated_DRB = 3; RC.mac[ctxt_pP->module_id]->UE_info.UE_sched_ctrl[UE_id].crnti_reconfigurationcomplete_flag = 0; - ue_context_p->ue_context.Status = RRC_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = RRC_RECONFIGURED; if(ue_context_p->ue_context.handover_info) { ue_context_p->ue_context.handover_info->state = HO_CONFIGURED; @@ -7796,7 +8063,7 @@ rrc_eNB_decode_dcch( LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_HO_EXECUTION (xid %ld)\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP),ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.rrc_TransactionIdentifier); - } else if(ue_context_p->ue_context.Status == RRC_NR_NSA) { + } else if(ue_context_p->ue_context.StatusRrc == RRC_NR_NSA) { //Looking for a condition to trigger S1AP E-RAB-Modification-indication, based on the reception of RRCConnectionReconfigurationComplete //including NR specific elements. if(ul_dcch_msg->message.choice.c1.choice.rrcConnectionReconfigurationComplete.criticalExtensions.choice.rrcConnectionReconfigurationComplete_r8. @@ -7815,7 +8082,7 @@ rrc_eNB_decode_dcch( nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension->nonCriticalExtension ->scg_ConfigResponseNR_r15!=NULL) { dedicated_DRB = -1; /* put a value that does not run anything below */ - ue_context_p->ue_context.Status = RRC_NR_NSA_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = RRC_NR_NSA_RECONFIGURED; /*Trigger E-RAB Modification Indication */ rrc_eNB_send_E_RAB_Modification_Indication(ctxt_pP, ue_context_p); /* send reconfiguration complete to gNB */ @@ -7829,7 +8096,7 @@ rrc_eNB_decode_dcch( } } else { dedicated_DRB = 0; - ue_context_p->ue_context.Status = RRC_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = 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); @@ -7838,7 +8105,7 @@ rrc_eNB_decode_dcch( ue_context_p->ue_context.reestablishment_xid = -1; } else { dedicated_DRB = 1; - ue_context_p->ue_context.Status = RRC_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = 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); @@ -8193,7 +8460,7 @@ rrc_eNB_decode_dcch( ASN_STRUCT_FREE(asn_DEF_NR_UE_NR_Capability,ue_context_p->ue_context.UE_Capability_nr); ue_context_p->ue_context.UE_Capability_nr = 0; } - + LOG_I(RRC,"Received NR_UE_Capabilities\n"); dec_rval = uper_decode(NULL, &asn_DEF_NR_UE_NR_Capability, (void **)&ue_context_p->ue_context.UE_Capability_nr, @@ -8218,6 +8485,8 @@ rrc_eNB_decode_dcch( if (ul_dcch_msg->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[i]->rat_Type == LTE_RAT_Type_eutra_nr) { + LOG_I(RRC,"Received UE_Capabilities_MRDC\n"); + if(ue_context_p->ue_context.UE_Capability_MRDC) { ASN_STRUCT_FREE(asn_DEF_NR_UE_MRDC_Capability,ue_context_p->ue_context.UE_Capability_MRDC); ue_context_p->ue_context.UE_Capability_MRDC = 0; @@ -8574,13 +8843,12 @@ void handle_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].nr_cellid = rrc->nr_cellid; F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].nrpci = f1_setup_req->nr_pci[i]; int num_SI= 0; - if (rrc->carrier[0].SIB23) { - F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container[num_SI] = rrc->carrier[0].SIB23; - F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container_length[num_SI] = rrc->carrier[0].sizeof_SIB23; - //printf("SI %d size %d: ", 0, F1AP_SETUP_RESP(msg_p).SI_container_length[j][num_SI]); - //for (int n = 0; n < F1AP_SETUP_RESP(msg_p).SI_container_length[j][num_SI]; n++) - // printf("%02x ", F1AP_SETUP_RESP(msg_p).SI_container[0][num_SI][n]); + F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container[2+num_SI] = rrc->carrier[0].SIB23; + F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container_length[2+num_SI] = rrc->carrier[0].sizeof_SIB23; + //printf("SI %d size %d: ", 0, F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container_length[2+num_SI]); + //for (int n = 0; n < F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container_length[2+num_SI]; n++) + // printf("%02x ", F1AP_SETUP_RESP (msg_p).cells_to_activate[cu_cell_ind].SI_container[2+num_SI][n]); //printf("\n"); num_SI++; } @@ -8780,10 +9048,6 @@ void rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { struct rrc_eNB_ue_context_s *ue_to_be_removed[NUMBER_OF_UE_MAX]; int removed_ue_count = 0; int cur_ue; -#ifdef LOCALIZATION - double estimated_distance = 0; - protocol_ctxt_t ctxt; -#endif MessageDef *msg; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX, VCD_FUNCTION_IN); @@ -8795,22 +9059,53 @@ void rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { } // check for UL failure or for UE to be released + FILE *fd=NULL; + if ((ctxt_pP->frame&127) == 0 && ctxt_pP->subframe ==0) + fd=fopen("RRC_stats.log","w+"); + 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 ((ctxt_pP->frame&127) == 0 && ctxt_pP->subframe ==0) { + if (fd) { + if (ue_context_p->ue_context.Initialue_identity_s_TMSI.presence == TRUE) { + fprintf(fd,"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 { + fprintf(fd,"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.UE_Capability) { + long catDL,catUL; + get_ue_Category(ue_context_p->ue_context.UE_Capability,&catDL,&catUL); + fprintf(fd,"RRC UE cap: CatDL %ld, CatUL %ld, 64QAM UL %s, 256 QAM DL %s, 256 QAM UL %s, ENDC %s,\n", + catDL,catUL, + is_ul_64QAM_supported(ue_context_p->ue_context.UE_Capability) == 1 ? "yes" : "no", + is_dl_256QAM_supported(ue_context_p->ue_context.UE_Capability) == 1 ? "yes" : "no", + is_ul_256QAM_supported(ue_context_p->ue_context.UE_Capability) == 1 ? "yes" : "no", + is_en_dc_supported(ue_context_p->ue_context.UE_Capability) == 1 ? "yes" : "no"); + } + if (ue_context_p->ue_context.measResults) { + fprintf(fd, "RRC PCell RSRP %ld, RSRQ %ld\n", ue_context_p->ue_context.measResults->measResultPCell.rsrpResult-140, + ue_context_p->ue_context.measResults->measResultPCell.rsrqResult/2 - 20); + if (ue_context_p->ue_context.measResults->measResultNeighCells && + ue_context_p->ue_context.measResults->measResultNeighCells->present == LTE_MeasResults__measResultNeighCells_PR_measResultNeighCellListNR_r15) { + + fprintf(fd,"NR_pci %ld\n",ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->pci_r15); + if(ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->measResultCell_r15.rsrpResult_r15) + fprintf(fd,"NR_rsrp %f dB\n",to_nr_rsrpq(*ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->measResultCell_r15.rsrpResult_r15,RC.rrc[ctxt_pP->module_id]->nr_gnb_freq_band[0][0])/10.0); + if (ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->measResultCell_r15.rsrqResult_r15) + fprintf(fd,"NR_rsrq %f dB\n",to_nr_rsrpq(*ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->measResultCell_r15.rsrqResult_r15,RC.rrc[ctxt_pP->module_id]->nr_gnb_freq_band[0][0])/10.0); + if (ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->measResultRS_IndexList_r15) + fprintf(fd,"NR_ssb_index %ld\n",ue_context_p->ue_context.measResults->measResultNeighCells->choice.measResultNeighCellListNR_r15.list.array[0]->measResultRS_IndexList_r15->list.array[0]->ssb_Index_r15); + } + } } } - if (ue_context_p->ue_context.ul_failure_timer > 0) { ue_context_p->ue_context.ul_failure_timer++; @@ -8978,8 +9273,8 @@ void rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { } /* remove UE from gNB if UE is in NSA mode */ - if (ue_to_be_removed[cur_ue]->ue_context.Status == RRC_NR_NSA || - ue_to_be_removed[cur_ue]->ue_context.Status == RRC_NR_NSA_RECONFIGURED) { + if (ue_to_be_removed[cur_ue]->ue_context.StatusRrc == RRC_NR_NSA || + ue_to_be_removed[cur_ue]->ue_context.StatusRrc == RRC_NR_NSA_RECONFIGURED) { MessageDef *message_p; message_p = itti_alloc_new_message(TASK_RRC_ENB, 0, X2AP_ENDC_SGNB_RELEASE_REQUEST); X2AP_ENDC_SGNB_RELEASE_REQUEST(message_p).rnti = ue_to_be_removed[cur_ue]->ue_context.gnb_rnti; @@ -8987,7 +9282,7 @@ void rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { X2AP_ENDC_SGNB_RELEASE_REQUEST(message_p).cause = X2AP_CAUSE_RADIO_CONNECTION_WITH_UE_LOST; itti_send_msg_to_task(TASK_X2AP, ctxt_pP->module_id, message_p); /* set state to RRC_NR_NSA_DELETED to avoid sending X2AP_ENDC_SGNB_RELEASE_REQUEST again later */ - ue_to_be_removed[cur_ue]->ue_context.Status = RRC_NR_NSA_DELETED; + ue_to_be_removed[cur_ue]->ue_context.StatusRrc = RRC_NR_NSA_DELETED; } rrc_eNB_free_UE(ctxt_pP->module_id, ue_to_be_removed[cur_ue]); @@ -9002,31 +9297,9 @@ void rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { } } -#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 (fd!=NULL) fclose(fd); + - 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" */ @@ -9179,13 +9452,13 @@ void rrc_eNB_process_ENDC_DC_prep_timeout(module_id_t module_id, x2ap_ENDC_dc_pr return; } - if (ue_context->ue_context.Status != RRC_NR_NSA) { + if (ue_context->ue_context.StatusRrc != RRC_NR_NSA) { LOG_E(RRC, "receiving DC prep timeout for UE rnti %d not in state RRC_NR_NSA\n", m->rnti); return; } LOG_I(RRC, "DC prep timeout for UE rnti %d, put back to RRC_RECONFIGURED mode\n", m->rnti); - ue_context->ue_context.Status = RRC_RECONFIGURED; + ue_context->ue_context.StatusRrc = RRC_RECONFIGURED; } void rrc_eNB_process_ENDC_sgNB_release_required(module_id_t module_id, x2ap_ENDC_sgnb_release_required_t *m) @@ -9206,7 +9479,7 @@ void rrc_eNB_process_ENDC_sgNB_release_required(module_id_t module_id, x2ap_ENDC ue_context->ue_context.ue_release_timer_thres_rrc = 100; ue_context->ue_context.ue_release_timer_rrc = 1; - ue_context->ue_context.Status = RRC_NR_NSA_DELETED; + ue_context->ue_context.StatusRrc = RRC_NR_NSA_DELETED; PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, module_id, /* TODO: should be 'instance' */ @@ -9472,7 +9745,7 @@ void *rrc_enb_process_itti_msg(void *notUsed) { if (X2AP_HANDOVER_CANCEL(msg_p).cause == X2AP_T_RELOC_PREP_TIMEOUT) { /* for prep timeout, simply return to normal state */ /* TODO: be sure that it's correct to set Status to RRC_RECONFIGURED */ - ue_context_p->ue_context.Status = RRC_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = RRC_RECONFIGURED; /* TODO: be sure free is enough here (check memory leaks) */ free(ue_context_p->ue_context.handover_info); ue_context_p->ue_context.handover_info = NULL; diff --git a/openair2/RRC/LTE/rrc_eNB_GTPV1U.c b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c index 6683d91556..a6af6a4163 100644 --- a/openair2/RRC/LTE/rrc_eNB_GTPV1U.c +++ b/openair2/RRC/LTE/rrc_eNB_GTPV1U.c @@ -188,7 +188,7 @@ boolean_t gtpv_data_req_new ( struct rrc_eNB_ue_context_s *ue_context_p = rrc_eNB_get_ue_context(RC.rrc[ctxt->module_id], ctxt->rnti); if(ue_context_p == NULL || ue_context_p->ue_context.handover_info == NULL || - ue_context_p->ue_context.Status != RRC_HO_EXECUTION) { + ue_context_p->ue_context.StatusRrc != RRC_HO_EXECUTION) { LOG_E(RRC,"incoming GTP-U for X2 in non HO context\n"); return false; } @@ -215,7 +215,7 @@ boolean_t gtpv_data_req_new ( /* target enb */ // We have 2*2=4 cases (data or end marker) * (from source, from EPC) - if (ue_context_p->ue_context.Status == RRC_RECONFIGURED) { + if (ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED) { // It should come from remote eNB // case end marker by EPC is not possible ? if (task==TASK_END_MARKER) { @@ -249,7 +249,6 @@ boolean_t gtpv_data_req_new ( return result; } else { /* It is from from epc message */ /* in the source enb, UE in RRC_HO_EXECUTION mode */ - MessageDef *msg; // ????? return true; } diff --git a/openair2/RRC/LTE/rrc_eNB_S1AP.c b/openair2/RRC/LTE/rrc_eNB_S1AP.c index f64a109f75..1cb575d1dd 100644 --- a/openair2/RRC/LTE/rrc_eNB_S1AP.c +++ b/openair2/RRC/LTE/rrc_eNB_S1AP.c @@ -1072,7 +1072,7 @@ int rrc_eNB_process_S1AP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, const char ue_context_p->ue_context.nr_security.kgNB); // in case, send the S1SP initial context response if it is not sent with the attach complete message - if (ue_context_p->ue_context.Status == RRC_RECONFIGURED) { + if (ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED) { LOG_I(RRC, "Sending rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP, cause %ld\n", ue_context_p->ue_context.reestablishment_cause); //if(ue_context_p->ue_context.reestablishment_cause == ReestablishmentCause_spare1){} rrc_eNB_send_S1AP_INITIAL_CONTEXT_SETUP_RESP(&ctxt,ue_context_p); diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c index dc12e96830..2eb439b9e9 100644 --- a/openair2/RRC/NAS/nas_config.c +++ b/openair2/RRC/NAS/nas_config.c @@ -61,9 +61,9 @@ void nas_getparams(void) { /* configuration parameters for netlink, includes network parameters when running in noS1 mode */ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*--------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ - {"NetworkPrefix", NASHLP_NETPREFIX, 0, strptr:&baseNetAddress, defstrval:"60.60", TYPE_STRING, 0 }, + {"NetworkPrefix", NASHLP_NETPREFIX, 0, strptr:&baseNetAddress, defstrval:"10.0", TYPE_STRING, 0 }, {"NetworkMask", NASHLP_NETMASK, 0, strptr:&netMask, defstrval:"255.255.255.0", TYPE_STRING, 0 }, - {"BroadcastAddr", NASHLP_BROADCASTADDR, 0, strptr:&broadcastAddr, defstrval:"60.60.255.255", TYPE_STRING, 0 }, + {"BroadcastAddr", NASHLP_BROADCASTADDR, 0, strptr:&broadcastAddr, defstrval:"10.0.255.255", TYPE_STRING, 0 }, }; config_get( nasoptions,sizeof(nasoptions)/sizeof(paramdef_t),"nas.noS1"); } diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index f8cb75c74d..8a6e164999 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -28,6 +28,7 @@ * \email: raymond.knopp@eurecom.fr, kroempa@gmail.com */ +#include #include "platform_types.h" #include "nr_rrc_defs.h" #include "nr_rrc_extern.h" @@ -44,7 +45,7 @@ #include "NR_BCCH-BCH-Message.h" #include "rrc_gNB_UE_context.h" #include -#include +#include extern RAN_CONTEXT_t RC; @@ -167,7 +168,7 @@ nr_rrc_data_req( //------------------------------------------------------------------------------ { if(sdu_sizeP == 255) { - LOG_I(NR_RRC,"sdu_sizeP == 255"); + LOG_D(RRC,"sdu_sizeP == 255"); return FALSE; } @@ -208,7 +209,6 @@ nr_rrc_data_req( message_p); LOG_I(NR_RRC,"send RRC_DCCH_DATA_REQ to PDCP\n"); - //trace_NRpdu(DIRECTION_DOWNLINK, message_buffer, sdu_sizeP, 0, WS_M_RNTI, ctxt_pP->rnti, ctxt_pP->frame, ctxt_pP->subframe,0, 0); /* Hack: only trigger PDCP if in CU, otherwise it is triggered by RU threads * Ideally, PDCP would not neet to be triggered like this but react to ITTI * messages automatically */ @@ -334,7 +334,7 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, int sdu2_len = (enc_rval.encoded+7)/8; if (enc_rval.encoded == -1) { - LOG_I(F1AP,"Could not encoded cellGroupConfig, failed element %s\n",enc_rval.failed_type->name); + LOG_E(F1AP,"Could not encoded cellGroupConfig, failed element %s\n",enc_rval.failed_type->name); exit(-1); } /* do ITTI message */ @@ -345,7 +345,7 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, rntiP, sduP, sdu_lenP, - sdu2, + (const int8_t*)sdu2, sdu2_len ); return(0); @@ -364,3 +364,22 @@ int8_t nr_mac_rrc_data_ind(const module_id_t module_idP, return 0; } + +void nr_mac_gNB_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_gNB_ue_context_s *ue_context_p = NULL; + ue_context_p = rrc_gNB_get_ue_context( + RC.nrrrc[Mod_instP], + rntiP); + + if (ue_context_p != NULL) { + LOG_D(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 { + LOG_D(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP); + } +} diff --git a/openair2/RRC/NR/MESSAGES/asn1_msg.c b/openair2/RRC/NR/MESSAGES/asn1_msg.c index 286e756193..7621a636f4 100755 --- a/openair2/RRC/NR/MESSAGES/asn1_msg.c +++ b/openair2/RRC/NR/MESSAGES/asn1_msg.c @@ -1089,40 +1089,36 @@ void fill_initial_SpCellConfig(rnti_t rnti, void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup) { - NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; - NR_RLC_Config_t *rlc_Config = NULL; - NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; - - long *logicalChannelGroup = NULL; - cellGroupConfig->cellGroupId = 0; + cellGroupConfig->rlc_BearerToReleaseList = NULL; + cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); - /* Rlc Bearer Config */ - /* TS38.331 9.2.1 Default SRB configurations */ - cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList)); + // RLC Bearer Config + // TS38.331 9.2.1 Default SRB configurations + NR_RLC_BearerConfig_t *rlc_BearerConfig = NULL; + NR_RLC_Config_t *rlc_Config = NULL; + NR_LogicalChannelConfig_t *logicalChannelConfig = NULL; + long *logicalChannelGroup = NULL; rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); rlc_BearerConfig->logicalChannelIdentity = 2; rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 2; rlc_BearerConfig->reestablishRLC = NULL; - //if (0) { - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config->present = NR_RLC_Config_PR_am; - rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); - rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; - rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; - rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; - rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; - rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; - rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; - //} + rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); + rlc_Config->present = NR_RLC_Config_PR_am; + rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); + rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; + rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; + rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; + rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; + rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; + rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; rlc_BearerConfig->rlc_Config = rlc_Config; - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); logicalChannelConfig->ul_SpecificParameters->priority = 3; @@ -1135,55 +1131,50 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - //} rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); - /*DRB Configuration*/ - rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t)); - rlc_BearerConfig->logicalChannelIdentity = 4; - rlc_BearerConfig->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig->servedRadioBearer)); - rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; - rlc_BearerConfig->servedRadioBearer->choice.drb_Identity = 1; - rlc_BearerConfig->reestablishRLC = NULL; - //if (0) { - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config->present = NR_RLC_Config_PR_am; - rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); - rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; - rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms80; - rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms10; - rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; - rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms80; - rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64; - rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB125; - rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t4; - //} - rlc_BearerConfig->rlc_Config = rlc_Config; - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); - logicalChannelConfig->ul_SpecificParameters->priority = 13; - logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; - logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; - logicalChannelGroup = CALLOC(1, sizeof(long)); - *logicalChannelGroup = 1; - logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; - logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - - rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; - - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); - ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig); - - cellGroupConfig->rlc_BearerToReleaseList = NULL; - + // DRB Configuration + NR_RLC_BearerConfig_t *rlc_BearerConfig_drb = NULL; + NR_RLC_Config_t *rlc_Config_drb = NULL; + NR_LogicalChannelConfig_t *logicalChannelConfig_drb = NULL; + long *logicalChannelGroup_drb = NULL; + rlc_BearerConfig_drb = calloc(1, sizeof(NR_RLC_BearerConfig_t)); + rlc_BearerConfig_drb->logicalChannelIdentity = 4; + rlc_BearerConfig_drb->servedRadioBearer = calloc(1, sizeof(*rlc_BearerConfig_drb->servedRadioBearer)); + rlc_BearerConfig_drb->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity; + rlc_BearerConfig_drb->servedRadioBearer->choice.drb_Identity = 1; + rlc_BearerConfig_drb->reestablishRLC = NULL; + rlc_Config_drb = calloc(1, sizeof(NR_RLC_Config_t)); + rlc_Config_drb->present = NR_RLC_Config_PR_am; + rlc_Config_drb->choice.am = calloc(1, sizeof(*rlc_Config_drb->choice.am)); + rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config_drb->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; + rlc_Config_drb->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms80; + rlc_Config_drb->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms10; + rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config_drb->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size18; + rlc_Config_drb->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms80; + rlc_Config_drb->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64; + rlc_Config_drb->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB125; + rlc_Config_drb->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t4; + rlc_BearerConfig_drb->rlc_Config = rlc_Config_drb; + logicalChannelConfig_drb = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig_drb->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters)); + logicalChannelConfig_drb->ul_SpecificParameters->priority = 13; + logicalChannelConfig_drb->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_kBps8; + logicalChannelConfig_drb->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100; + logicalChannelGroup_drb = CALLOC(1, sizeof(long)); + *logicalChannelGroup_drb = 1; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup_drb; + logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig_drb->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig_drb->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; + rlc_BearerConfig_drb->mac_LogicalChannelConfig = logicalChannelConfig_drb; + ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); + ASN_SEQUENCE_ADD(&ue_context_mastercellGroup->rlc_BearerToAddModList->list, rlc_BearerConfig_drb); } void fill_initial_cellGroupConfig(rnti_t rnti, @@ -1208,39 +1199,32 @@ void fill_initial_cellGroupConfig(rnti_t rnti, rlc_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity; rlc_BearerConfig->servedRadioBearer->choice.srb_Identity = 1; rlc_BearerConfig->reestablishRLC = NULL; - //if (0) { - rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); - rlc_Config->present = NR_RLC_Config_PR_am; - rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); - rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; - rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; - rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); - *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; - rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; - rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; - rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; - rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; - //} + rlc_Config = calloc(1, sizeof(NR_RLC_Config_t)); + rlc_Config->present = NR_RLC_Config_PR_am; + rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am)); + rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms35; + rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms0; + rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(NR_SN_FieldLengthAM_t)); + *(rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength) = NR_SN_FieldLengthAM_size12; + rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45; + rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_infinity; + rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_infinity; + rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t8; rlc_BearerConfig->rlc_Config = rlc_Config; - - - //if (0) { - logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); - logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); - logicalChannelConfig->ul_SpecificParameters->priority = 1; - logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; - logicalChannelGroup = CALLOC(1, sizeof(long)); - *logicalChannelGroup = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; - logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); - *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; - logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; - //} + logicalChannelConfig = calloc(1, sizeof(NR_LogicalChannelConfig_t)); + logicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*logicalChannelConfig->ul_SpecificParameters)); + logicalChannelConfig->ul_SpecificParameters->priority = 1; + logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity; + logicalChannelGroup = CALLOC(1, sizeof(long)); + *logicalChannelGroup = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = logicalChannelGroup; + logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = CALLOC(1, sizeof(*logicalChannelConfig->ul_SpecificParameters->schedulingRequestID)); + *logicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = 0; + logicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = 0; rlc_BearerConfig->mac_LogicalChannelConfig = logicalChannelConfig; - ASN_SEQUENCE_ADD(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig); cellGroupConfig->rlc_BearerToReleaseList = NULL; @@ -1364,7 +1348,6 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t)); fill_initial_cellGroupConfig(ue_context_pP->ue_context.rnti,cellGroupConfig,scc); - enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)cellGroupConfig, @@ -1386,7 +1369,7 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, ue_p->masterCellGroup = cellGroupConfig; if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)&dl_ccch_msg); + xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)&dl_ccch_msg); } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_CCCH_Message, NULL, @@ -1403,7 +1386,6 @@ uint8_t do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP, LOG_D(NR_RRC,"RRCSetup Encoded %zd bits (%zd bytes)\n", enc_rval.encoded,(enc_rval.encoded+7)/8); return((enc_rval.encoded+7)/8); - } uint8_t do_NR_SecurityModeCommand( @@ -1433,9 +1415,9 @@ uint8_t do_NR_SecurityModeCommand( dl_dcch_msg.message.choice.c1->choice.securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm = integrityProtAlgorithm; -// if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout, &asn_DEF_NR_DL_DCCH_Message, (void *)&dl_dcch_msg); -// } + } enc_rval = uper_encode_to_buffer(&asn_DEF_NR_DL_DCCH_Message, NULL, @@ -1597,7 +1579,7 @@ uint8_t do_NR_RRCRelease(uint8_t *buffer, } //------------------------------------------------------------------------------ -uint16_t do_RRCReconfiguration( +int16_t do_RRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, uint8_t *buffer, uint8_t Transaction_id, @@ -1607,8 +1589,7 @@ uint16_t do_RRCReconfiguration( NR_SecurityConfig_t *security_config, NR_SDAP_Config_t *sdap_config, NR_MeasConfig_t *meas_config, - struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList - *dedicatedNAS_MessageList, + struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList, NR_MAC_CellGroupConfig_t *mac_CellGroupConfig, NR_CellGroupConfig_t *cellGroupConfig) //------------------------------------------------------------------------------ @@ -1652,7 +1633,8 @@ uint16_t do_RRCReconfiguration( // 1, // 1, // carrier->pdsch_AntennaPorts, - // carrier->initial_csi_index[gnb_rrc_inst->Nb_ue]); + // carrier->initial_csi_index[ue_context_p->local_uid + 1], + // ue_context_pP->local_uid); /******************** Meas Config ********************/ // measConfig @@ -1661,8 +1643,12 @@ uint16_t do_RRCReconfiguration( ie->lateNonCriticalExtension = NULL; // nonCriticalExtension - if (cellGroupConfig || dedicatedNAS_MessageList) - ie->nonCriticalExtension = calloc(1, sizeof(NR_RRCReconfiguration_v1530_IEs_t)); + if (cellGroupConfig || dedicatedNAS_MessageList) { + ie->nonCriticalExtension = calloc(1, sizeof(NR_RRCReconfiguration_v1530_IEs_t)); + if (dedicatedNAS_MessageList) + ie->nonCriticalExtension->dedicatedNAS_MessageList = dedicatedNAS_MessageList; + } + if(cellGroupConfig!=NULL){ enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, @@ -1681,9 +1667,6 @@ uint16_t do_RRCReconfiguration( ie->nonCriticalExtension->masterCellGroup->size = (enc_rval.encoded+7)/8; } - if (dedicatedNAS_MessageList) - ie->nonCriticalExtension->dedicatedNAS_MessageList = dedicatedNAS_MessageList; - dl_dcch_msg.message.choice.c1->choice.rrcReconfiguration->criticalExtensions.choice.rrcReconfiguration = ie; //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { @@ -1893,8 +1876,8 @@ do_NR_DLInformationTransfer( encoded = uper_encode_to_new_buffer (&asn_DEF_NR_DL_DCCH_Message, NULL, (void *) &dl_dcch_msg, (void **)buffer); AssertFatal(encoded > 0,"ASN1 message encoding failed (%s, %ld)!\n", "DLInformationTransfer", encoded); - LOG_I(NR_RRC,"DLInformationTransfer Encoded %zd bytes\n", encoded); - for (int i=0;iue_context.rnti, - ue_context_pP->ue_context.masterCellGroup - ); + get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : (NR_CellGroupConfig_t *)NULL); nr_rrc_rlc_config_asn1_req(ctxt_pP, ue_context_pP->ue_context.SRB_configList, NULL, NULL, NULL, - ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList, - NULL); + get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); + } void apply_pdcp_config(rrc_gNB_ue_context_t *const ue_context_pP, @@ -419,7 +417,7 @@ void apply_pdcp_config(rrc_gNB_ue_context_t *const ue_context_pP, NULL, NULL, NULL, - ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList); + get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); } @@ -435,7 +433,6 @@ rrc_gNB_generate_RRCSetup( //----------------------------------------------------------------------------- { LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup \n"); - NR_SRB_ToAddModList_t **SRB_configList = NULL; MessageDef *message_p; // T(T_GNB_RRC_SETUP, @@ -483,7 +480,7 @@ rrc_gNB_generate_RRCSetup( F1AP_DL_RRC_MESSAGE (message_p).RAT_frequency_priority_information.en_dc = 0; itti_send_msg_to_task (TASK_CU_F1, ctxt_pP->module_id, message_p); LOG_D(NR_RRC, "Send F1AP_DL_RRC_MESSAGE with ITTI\n"); - + break; case ngran_gNB_DU: @@ -556,7 +553,6 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( //----------------------------------------------------------------------------- { LOG_I(NR_RRC, "generate RRCSetup for RRCReestablishmentRequest \n"); - NR_SRB_ToAddModList_t **SRB_configList = NULL; rrc_gNB_ue_context_t *ue_context_pP = NULL; gNB_RRC_INST *rrc_instance_p = RC.nrrrc[ctxt_pP->module_id]; NR_ServingCellConfigCommon_t *scc=rrc_instance_p->carrier.servingcellconfigcommon; @@ -564,7 +560,6 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( ue_context_pP = rrc_gNB_get_next_free_ue_context(ctxt_pP, rrc_instance_p, 0); gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; - SRB_configList = &ue_p->SRB_configList; ue_p->Srb0.Tx_buffer.payload_size = do_RRCSetup(ue_context_pP, (uint8_t *) ue_p->Srb0.Tx_buffer.Payload, rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id), @@ -590,7 +585,7 @@ rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest( ue_context_pP->ue_context.rnti, (NR_CellGroupConfig_t *)NULL ); - + MSC_LOG_TX_MESSAGE( MSC_RRC_GNB, MSC_RRC_UE, @@ -713,7 +708,7 @@ rrc_gNB_process_RRCSetupComplete( PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); ue_context_pP->ue_context.Srb1.Active = 1; ue_context_pP->ue_context.Srb1.Srb_info.Srb_id = 1; - ue_context_pP->ue_context.Status = NR_RRC_CONNECTED; + ue_context_pP->ue_context.StatusRrc = NR_RRC_CONNECTED; if (AMF_MODE_ENABLED) { rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete); @@ -811,18 +806,18 @@ rrc_gNB_generate_defaultRRCReconfiguration( /* Add all NAS PDUs to the list */ for (int i = 0; i < ue_context_pP->ue_context.nb_of_pdusessions; i++) { - if (ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer != NULL) { + if (ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer != NULL) { dedicatedNAS_Message = CALLOC(1, sizeof(NR_DedicatedNAS_Message_t)); memset(dedicatedNAS_Message, 0, sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(dedicatedNAS_Message, - (char *)ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer, - ue_context_pP->ue_context.pdusession[i].param.nas_pdu.length); + (char *)ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.pduSession[i].param.nas_pdu.length); ASN_SEQUENCE_ADD(&dedicatedNAS_MessageList->list, dedicatedNAS_Message); } - ue_context_pP->ue_context.pdusession[i].status = PDU_SESSION_STATUS_DONE; + ue_context_pP->ue_context.pduSession[i].status = PDU_SESSION_STATUS_DONE; LOG_D(NR_RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", - i, ue_context_pP->ue_context.pdusession[i].status, "PDU_SESSION_STATUS_DONE"); + i, ue_context_pP->ue_context.pduSession[i].status, "PDU_SESSION_STATUS_DONE"); } if (ue_context_pP->ue_context.nas_pdu_flag == 1) { @@ -843,8 +838,8 @@ rrc_gNB_generate_defaultRRCReconfiguration( memset(buffer, 0, RRC_BUF_SIZE); size = do_RRCReconfiguration(ctxt_pP, buffer, xid, - NULL,//*SRB_configList2, - NULL,//*DRB_configList, + NULL, //*SRB_configList2, + NULL, //*DRB_configList, NULL, NULL, NULL, @@ -859,9 +854,9 @@ rrc_gNB_generate_defaultRRCReconfiguration( /* Free all NAS PDUs */ for (int i = 0; i < ue_context_pP->ue_context.nb_of_pdusessions; i++) { - if (ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer != NULL) { - free(ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer); - ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer = NULL; + if (ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer != NULL) { + free(ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer); + ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer = NULL; } } @@ -930,14 +925,14 @@ rrc_gNB_generate_defaultRRCReconfiguration( // rrc_rlc_config_asn1_req } break; - + default : LOG_W(NR_RRC, "Unknown node type %d\n", RC.nrrrc[ctxt_pP->module_id]->node_type); } } //----------------------------------------------------------------------------- -void +void rrc_gNB_generate_dedicatedRRCReconfiguration( const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP @@ -950,7 +945,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( NR_DRB_ToAddModList_t **DRB_configList = NULL; NR_DRB_ToAddModList_t **DRB_configList2 = NULL; NR_SRB_ToAddModList_t **SRB_configList2 = NULL; - NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; + NR_SRB_ToAddModList_t *SRB_configList = ue_context_pP->ue_context.SRB_configList; struct NR_RRCReconfiguration_v1530_IEs__dedicatedNAS_MessageList *dedicatedNAS_MessageList = NULL; NR_DedicatedNAS_Message_t *dedicatedNAS_Message = NULL; @@ -996,7 +991,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( break; } - if (ue_context_pP->ue_context.pdusession[i].status >= PDU_SESSION_STATUS_DONE) { + if (ue_context_pP->ue_context.pduSession[i].status >= PDU_SESSION_STATUS_DONE) { continue; } @@ -1007,15 +1002,15 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( // sdap_Config sdap_config = CALLOC(1, sizeof(NR_SDAP_Config_t)); memset(sdap_config, 0, sizeof(NR_SDAP_Config_t)); - sdap_config->pdu_Session = ue_context_pP->ue_context.pdusession[i].param.pdusession_id; + sdap_config->pdu_Session = ue_context_pP->ue_context.pduSession[i].param.pdusession_id; sdap_config->sdap_HeaderDL = NR_SDAP_Config__sdap_HeaderDL_absent; - sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_present; + sdap_config->sdap_HeaderUL = NR_SDAP_Config__sdap_HeaderUL_absent; sdap_config->defaultDRB = TRUE; sdap_config->mappedQoS_FlowsToAdd = calloc(1, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd)); memset(sdap_config->mappedQoS_FlowsToAdd, 0, sizeof(struct NR_SDAP_Config__mappedQoS_FlowsToAdd)); - for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pdusession[i].param.nb_qos; qos_flow_index++) { - qfi = ue_context_pP->ue_context.pdusession[i].param.qos[qos_flow_index].qfi; + for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pduSession[i].param.nb_qos; qos_flow_index++) { + qfi = ue_context_pP->ue_context.pduSession[i].param.qos[qos_flow_index].qfi; ASN_SEQUENCE_ADD(&sdap_config->mappedQoS_FlowsToAdd->list, &qfi); } sdap_config->mappedQoS_FlowsToRelease = NULL; @@ -1045,8 +1040,8 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( DRB_config->pdcp_Config->ext1 = NULL; // Reference TS23501 Table 5.7.4-1: Standardized 5QI to QoS characteristics mapping - for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pdusession[i].param.nb_qos; qos_flow_index++) { - switch (ue_context_pP->ue_context.pdusession[i].param.qos[qos_flow_index].fiveQI) { + for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pduSession[i].param.nb_qos; qos_flow_index++) { + switch (ue_context_pP->ue_context.pduSession[i].param.qos[qos_flow_index].fiveQI) { case 1: //100ms case 2: //150ms case 3: //50ms @@ -1060,9 +1055,9 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( break; default: - LOG_E(NR_RRC,"not supported 5qi %lu\n", ue_context_pP->ue_context.pdusession[i].param.qos[qos_flow_index].fiveQI); - ue_context_pP->ue_context.pdusession[i].status = PDU_SESSION_STATUS_FAILED; - ue_context_pP->ue_context.pdusession[i].xid = xid; + LOG_E(NR_RRC,"not supported 5qi %lu\n", ue_context_pP->ue_context.pduSession[i].param.qos[qos_flow_index].fiveQI); + ue_context_pP->ue_context.pduSession[i].status = PDU_SESSION_STATUS_FAILED; + ue_context_pP->ue_context.pduSession[i].xid = xid; pdu_sessions_done++; free(DRB_config); continue; @@ -1072,18 +1067,18 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( ASN_SEQUENCE_ADD(&(*DRB_configList)->list, DRB_config); ASN_SEQUENCE_ADD(&(*DRB_configList2)->list, DRB_config); - ue_context_pP->ue_context.pdusession[i].status = PDU_SESSION_STATUS_DONE; - ue_context_pP->ue_context.pdusession[i].xid = xid; + ue_context_pP->ue_context.pduSession[i].status = PDU_SESSION_STATUS_DONE; + ue_context_pP->ue_context.pduSession[i].xid = xid; - if (ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer != NULL) { + if (ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer != NULL) { dedicatedNAS_Message = CALLOC(1, sizeof(NR_DedicatedNAS_Message_t)); memset(dedicatedNAS_Message, 0, sizeof(OCTET_STRING_t)); OCTET_STRING_fromBuf(dedicatedNAS_Message, - (char *)ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer, - ue_context_pP->ue_context.pdusession[i].param.nas_pdu.length); + (char *)ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer, + ue_context_pP->ue_context.pduSession[i].param.nas_pdu.length); ASN_SEQUENCE_ADD(&dedicatedNAS_MessageList->list, dedicatedNAS_Message); - LOG_I(NR_RRC,"add NAS info with size %d (pdusession id %d)\n",ue_context_pP->ue_context.pdusession[i].param.nas_pdu.length, i); + LOG_I(NR_RRC,"add NAS info with size %d (pdusession id %d)\n",ue_context_pP->ue_context.pduSession[i].param.nas_pdu.length, i); } else { // TODO LOG_E(NR_RRC,"no NAS info (pdusession id %d)\n", i); @@ -1101,7 +1096,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( fill_mastercellGroupConfig(cellGroupConfig, ue_context_pP->ue_context.masterCellGroup); size = do_RRCReconfiguration(ctxt_pP, buffer, xid, - *SRB_configList2, + *SRB_configList2, *DRB_configList, NULL, NULL, @@ -1114,10 +1109,10 @@ rrc_gNB_generate_dedicatedRRCReconfiguration( /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_pdusessions; i++) { - if (ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer != NULL) { + if (ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer != NULL) { /* Free the NAS PDU buffer and invalidate it */ - free(ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer); - ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer = NULL; + free(ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer); + ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer = NULL; } } @@ -1186,7 +1181,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( *DRB_Release_configList2 = CALLOC(1, sizeof(**DRB_Release_configList2)); for(i = 0; i < NB_RB_MAX; i++) { - if((ue_context_pP->ue_context.pdusession[i].status == PDU_SESSION_STATUS_TORELEASE) && ue_context_pP->ue_context.pdusession[i].xid == xid) { + if((ue_context_pP->ue_context.pduSession[i].status == PDU_SESSION_STATUS_TORELEASE) && ue_context_pP->ue_context.pduSession[i].xid == xid) { DRB_release = CALLOC(1, sizeof(NR_DRB_Identity_t)); *DRB_release = i+1; ASN_SEQUENCE_ADD(&(*DRB_Release_configList2)->list, DRB_release); @@ -1287,6 +1282,7 @@ rrc_gNB_process_RRCReconfigurationComplete( NR_DRB_ToReleaseList_t *DRB_Release_configList2 = ue_context_pP->ue_context.DRB_Release_configList2[xid]; NR_DRB_Identity_t *drb_id_p = NULL; // uint8_t nr_DRB2LCHAN[8]; + gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; ue_context_pP->ue_context.ue_reestablishment_timer = 0; @@ -1311,8 +1307,8 @@ rrc_gNB_process_RRCReconfigurationComplete( ue_context_pP->ue_context.rnti); #ifndef ITTI_SIM - LOG_I(NR_RRC,"Configuring PDCP DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti); - + LOG_D(NR_RRC,"Configuring PDCP DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti); + nr_rrc_pdcp_config_asn1_req(ctxt_pP, SRB_configList, // NULL, DRB_configList, @@ -1324,17 +1320,27 @@ rrc_gNB_process_RRCReconfigurationComplete( NULL, NULL, NULL, - ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList); + get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); /* Refresh SRBs/DRBs */ + if (!NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { - LOG_I(NR_RRC,"Configuring RLC DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti); + rrc_mac_config_req_gNB(rrc->module_id, + rrc->carrier.ssb_SubcarrierOffset, + rrc->carrier.pdsch_AntennaPorts, + rrc->carrier.pusch_AntennaPorts, + rrc->carrier.sib1_tda, + NULL, + 0, + ue_context_pP->ue_context.rnti, + ue_context_pP->ue_context.masterCellGroup + ); + LOG_D(NR_RRC,"Configuring RLC DRBs/SRBs for UE %x\n",ue_context_pP->ue_context.rnti); nr_rrc_rlc_config_asn1_req(ctxt_pP, - SRB_configList, // NULL, - DRB_configList, - DRB_Release_configList2, - NULL, - ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList, - NULL); + SRB_configList, // NULL, + DRB_configList, + DRB_Release_configList2, + NULL, + get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup->rlc_BearerToAddModList : NULL); } #endif @@ -1546,7 +1552,7 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( uint8_t next_xid = rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id); int ret = 0; - ue_context_pP->ue_context.Status = NR_RRC_CONNECTED; + ue_context_pP->ue_context.StatusRrc = NR_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]; @@ -1642,13 +1648,13 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( 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.pdusession[i].status == PDU_SESSION_STATUS_ESTABLISHED || ue_context_pP->ue_context.pdusession[i].status == PDU_SESSION_STATUS_DONE) { - create_tunnel_req.pdusession_id[j] = ue_context_pP->ue_context.pdusession[i].param.pdusession_id; - create_tunnel_req.upf_NGu_teid[j] = ue_context_pP->ue_context.pdusession[i].param.gtp_teid; + if (ue_context_pP->ue_context.pduSession[i].status == PDU_SESSION_STATUS_ESTABLISHED || ue_context_pP->ue_context.pduSession[i].status == PDU_SESSION_STATUS_DONE) { + create_tunnel_req.pdusession_id[j] = ue_context_pP->ue_context.pduSession[i].param.pdusession_id; + create_tunnel_req.upf_NGu_teid[j] = ue_context_pP->ue_context.pduSession[i].param.gtp_teid; memcpy(create_tunnel_req.upf_addr[j].buffer, - ue_context_pP->ue_context.pdusession[i].param.upf_addr.buffer, + ue_context_pP->ue_context.pduSession[i].param.upf_addr.buffer, sizeof(uint8_t)*20); - create_tunnel_req.upf_addr[j].length = ue_context_pP->ue_context.pdusession[i].param.upf_addr.length; + create_tunnel_req.upf_addr[j].length = ue_context_pP->ue_context.pduSession[i].param.upf_addr.length; j++; } } @@ -1708,10 +1714,10 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( /* TODO parameters yet to process ... */ /* TODO should test if pdu session are Ok before! */ - ue_context_pP->ue_context.pdusession[i].status = PDU_SESSION_STATUS_DONE; - ue_context_pP->ue_context.pdusession[i].xid = xid; + ue_context_pP->ue_context.pduSession[i].status = PDU_SESSION_STATUS_DONE; + ue_context_pP->ue_context.pduSession[i].xid = xid; LOG_D(NR_RRC, "setting the status for the default DRB (index %d) to (%d,%s)\n", - i, ue_context_pP->ue_context.pdusession[i].status, "PDU_SESSION_STATUS_DONE"); + i, ue_context_pP->ue_context.pduSession[i].status, "PDU_SESSION_STATUS_DONE"); } memset(buffer, 0, RRC_BUF_SIZE); @@ -1732,10 +1738,10 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( /* Free all NAS PDUs */ for (i = 0; i < ue_context_pP->ue_context.nb_of_pdusessions; i++) { - if (ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer != NULL) { + if (ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer != NULL) { /* Free the NAS PDU buffer and invalidate it */ - free(ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer); - ue_context_pP->ue_context.pdusession[i].param.nas_pdu.buffer = NULL; + free(ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer); + ue_context_pP->ue_context.pduSession[i].param.nas_pdu.buffer = NULL; } } @@ -1787,7 +1793,7 @@ rrc_gNB_process_RRCConnectionReestablishmentComplete( int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, const uint8_t *buffer, int buffer_length, - OCTET_STRING_t *du_to_cu_rrc_container, + OCTET_STRING_t *du_to_cu_rrc_container, const int CC_id) { module_id_t Idx; @@ -1912,9 +1918,9 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, LOG_E(RRC, "%s:%d:%s: rrc_gNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__); } - if (ue_context_p != NULL) { - ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence = TRUE; - ue_context_p->ue_context.ng_5G_S_TMSI_Part1 = s_tmsi_part1; + if (ue_context_p != NULL) { + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence = TRUE; + ue_context_p->ue_context.ng_5G_S_TMSI_Part1 = s_tmsi_part1; } } } else { @@ -1938,11 +1944,8 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, rrc_gNB_generate_RRCSetup(ctxt_pP, rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rnti), du_to_cu_rrc_container, - gnb_rrc_inst->carrier.servingcellconfigcommon, - CC_id); - - // FIXME: Check the best place to perform this DRB configuration - //nr_DRB_preconfiguration(ctxt_pP->rnti); + gnb_rrc_inst->carrier.servingcellconfigcommon, + CC_id); } break; @@ -2041,7 +2044,7 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, } #endif //c-plane not end - if((ue_context_p->ue_context.Status != NR_RRC_RECONFIGURED) && (ue_context_p->ue_context.reestablishment_cause == NR_ReestablishmentCause_spare1)) { + if((ue_context_p->ue_context.StatusRrc != NR_RRC_RECONFIGURED) && (ue_context_p->ue_context.reestablishment_cause == NR_ReestablishmentCause_spare1)) { LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" NR_RRCReestablishmentRequest (UE %x c-plane is not end), RRC establishment failed \n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP),c_rnti); @@ -2053,9 +2056,9 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, LOG_E(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" RRRCReconfigurationComplete(Previous) don't receive, delete the Previous UE,\nprevious Status %d, new Status NR_RRC_RECONFIGURED\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), - ue_context_p->ue_context.Status + ue_context_p->ue_context.StatusRrc ); - ue_context_p->ue_context.Status = NR_RRC_RECONFIGURED; + ue_context_p->ue_context.StatusRrc = NR_RRC_RECONFIGURED; protocol_ctxt_t ctxt_old_p; PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt_old_p, ctxt_pP->instance, @@ -2068,10 +2071,10 @@ int nr_rrc_gNB_decode_ccch(protocol_ctxt_t *const ctxt_pP, ue_context_p->ue_context.reestablishment_xid); for (uint8_t pdusessionid = 0; pdusessionid < ue_context_p->ue_context.nb_of_pdusessions; pdusessionid++) { - if (ue_context_p->ue_context.pdusession[pdusessionid].status == PDU_SESSION_STATUS_DONE) { - ue_context_p->ue_context.pdusession[pdusessionid].status = PDU_SESSION_STATUS_ESTABLISHED; + if (ue_context_p->ue_context.pduSession[pdusessionid].status == PDU_SESSION_STATUS_DONE) { + ue_context_p->ue_context.pduSession[pdusessionid].status = PDU_SESSION_STATUS_ESTABLISHED; } else { - ue_context_p->ue_context.pdusession[pdusessionid].status = PDU_SESSION_STATUS_FAILED; + ue_context_p->ue_context.pduSession[pdusessionid].status = PDU_SESSION_STATUS_FAILED; } } } @@ -2230,8 +2233,10 @@ rrc_gNB_decode_dcch( LOG_D(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Decoding UL-DCCH Message\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP)); - for (int i=0;iue_context.rnti; for(i = 0; i < NB_RB_MAX; i++) { - if(xid == ue_context_p->ue_context.pdusession[i].xid) { + if(xid == ue_context_p->ue_context.pduSession[i].xid) { GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).pdusession_id[GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_pdusession++] = ue_context_p->ue_context.gnb_gtp_psi[i]; ue_context_p->ue_context.gnb_gtp_teid[i] = 0; @@ -2765,13 +2773,13 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { if (msg_p2 == NULL) { msg_p2 = itti_alloc_new_message (TASK_RRC_GNB, 0, F1AP_GNB_CU_CONFIGURATION_UPDATE); } - + F1AP_SETUP_RESP (msg_p).gNB_CU_name = rrc->node_name; F1AP_SETUP_RESP (msg_p).num_cells_to_activate = 0; } - F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).gNB_CU_name = rrc->node_name; + F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).gNB_CU_name = rrc->node_name; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].mcc = rrc->configuration.mcc[0]; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].mnc = rrc->configuration.mnc[0]; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).cells_to_activate[cu_cell_ind].mnc_digit_length = rrc->configuration.mnc_digit_length[0]; @@ -2789,7 +2797,7 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) { cu_cell_ind++; found_cell=1; F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p2).num_cells_to_activate = cu_cell_ind; - // send + // send break; } else {// setup_req mcc/mnc match rrc internal list element LOG_W(NR_RRC,"[Inst %d] No matching MCC/MNC: rrc->mcc/f1_setup_req->mcc %d/%d rrc->mnc/f1_setup_req->mnc %d/%d rrc->nr_cellid/f1_setup_req->nr_cellid %ld/%ld \n", @@ -2826,8 +2834,290 @@ void rrc_gNB_process_dc_overall_timeout(const module_id_t gnb_mod_idP, x2ap_ENDC rrc_remove_nsa_user(rrc, m->rnti); } +unsigned int mask_flip(unsigned int x) { + return((((x>>8) + (x<<8))&0xffff)>>6); +} + +unsigned int get_dl_bw_mask(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { + + + int common_band = *rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + int common_scs = rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { + NR_BandNR_t *bandNRinfo = cap->rf_Parameters.supportedBandListNR.list.array[i]; + if (bandNRinfo->bandNR == common_band) { + if (common_band < 257) { // FR1 + switch (common_scs) { + case NR_SubcarrierSpacing_kHz15 : + if (bandNRinfo->channelBWs_DL && + bandNRinfo->channelBWs_DL->choice.fr1 && + bandNRinfo->channelBWs_DL->choice.fr1->scs_15kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_DL->choice.fr1->scs_15kHz->buf)); + break; + case NR_SubcarrierSpacing_kHz30 : + if (bandNRinfo->channelBWs_DL && + bandNRinfo->channelBWs_DL->choice.fr1 && + bandNRinfo->channelBWs_DL->choice.fr1->scs_30kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_DL->choice.fr1->scs_30kHz->buf)); + break; + case NR_SubcarrierSpacing_kHz60 : + if (bandNRinfo->channelBWs_DL && + bandNRinfo->channelBWs_DL->choice.fr1 && + bandNRinfo->channelBWs_DL->choice.fr1->scs_60kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_DL->choice.fr1->scs_60kHz->buf)); + break; + } + } + else { + switch (common_scs) { + case NR_SubcarrierSpacing_kHz60 : + if (bandNRinfo->channelBWs_DL && + bandNRinfo->channelBWs_DL->choice.fr2 && + bandNRinfo->channelBWs_DL->choice.fr2->scs_60kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_DL->choice.fr2->scs_60kHz->buf)); + break; + case NR_SubcarrierSpacing_kHz120 : + if (bandNRinfo->channelBWs_DL && + bandNRinfo->channelBWs_DL->choice.fr2 && + bandNRinfo->channelBWs_DL->choice.fr2->scs_120kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_DL->choice.fr2->scs_120kHz->buf)); + break; + } + } + } + } + return(0); +} + +unsigned int get_ul_bw_mask(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { + + + int common_band = *rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]; + int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { + NR_BandNR_t *bandNRinfo = cap->rf_Parameters.supportedBandListNR.list.array[i]; + if (bandNRinfo->bandNR == common_band) { + if (common_band < 257) { // FR1 + switch (common_scs) { + case NR_SubcarrierSpacing_kHz15 : + if (bandNRinfo->channelBWs_UL && + bandNRinfo->channelBWs_UL->choice.fr1 && + bandNRinfo->channelBWs_UL->choice.fr1->scs_15kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_UL->choice.fr1->scs_15kHz->buf)); + break; + case NR_SubcarrierSpacing_kHz30 : + if (bandNRinfo->channelBWs_UL && + bandNRinfo->channelBWs_UL->choice.fr1 && + bandNRinfo->channelBWs_UL->choice.fr1->scs_30kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_UL->choice.fr1->scs_30kHz->buf)); + break; + case NR_SubcarrierSpacing_kHz60 : + if (bandNRinfo->channelBWs_UL && + bandNRinfo->channelBWs_UL->choice.fr1 && + bandNRinfo->channelBWs_UL->choice.fr1->scs_60kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_UL->choice.fr1->scs_60kHz->buf)); + break; + } + } + else { + switch (common_scs) { + case NR_SubcarrierSpacing_kHz60 : + if (bandNRinfo->channelBWs_UL && + bandNRinfo->channelBWs_UL->choice.fr2 && + bandNRinfo->channelBWs_UL->choice.fr2->scs_60kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_UL->choice.fr2->scs_60kHz->buf)); + break; + case NR_SubcarrierSpacing_kHz120 : + if (bandNRinfo->channelBWs_UL && + bandNRinfo->channelBWs_UL->choice.fr2 && + bandNRinfo->channelBWs_UL->choice.fr2->scs_120kHz) + return(mask_flip((unsigned int)*(uint16_t*)bandNRinfo->channelBWs_UL->choice.fr2->scs_120kHz->buf)); + break; + } + } + } + } + return(0); +} + +int is_dl_256QAM_supported(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { + int common_band = *rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0]; + int common_scs = rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + if (common_band>256) { + for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { + NR_BandNR_t *bandNRinfo = cap->rf_Parameters.supportedBandListNR.list.array[i]; + if (bandNRinfo->bandNR == common_band && !bandNRinfo->pdsch_256QAM_FR2) return (0); + } + } + else if (cap->phy_Parameters.phy_ParametersFR1 && !cap->phy_Parameters.phy_ParametersFR1->pdsch_256QAM_FR1) return(0); + + // check featureSet + NR_FeatureSets_t *fs=cap->featureSets; + if (fs) { + // go through DL feature sets and look for one with current SCS + for (int i=0;ifeatureSetsDownlinkPerCC->list.count;i++) { + if (fs->featureSetsDownlinkPerCC->list.array[i]->supportedSubcarrierSpacingDL == common_scs && + fs->featureSetsDownlinkPerCC->list.array[i]->supportedModulationOrderDL && + *fs->featureSetsDownlinkPerCC->list.array[i]->supportedModulationOrderDL == NR_ModulationOrder_qam256) return(1); + } + } + return(0); +} + +int is_ul_256QAM_supported(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { + int common_band = *rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->frequencyBandList->list.array[0]; + int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + for (int i=0;irf_Parameters.supportedBandListNR.list.count;i++) { + NR_BandNR_t *bandNRinfo = cap->rf_Parameters.supportedBandListNR.list.array[i]; + if (bandNRinfo->bandNR == common_band && !bandNRinfo->pusch_256QAM) return (0); + } + + // check featureSet + NR_FeatureSets_t *fs=cap->featureSets; + if (fs) { + // go through UL feature sets and look for one with current SCS + for (int i=0;ifeatureSetsUplinkPerCC->list.count;i++) { + if (fs->featureSetsUplinkPerCC->list.array[i]->supportedSubcarrierSpacingUL == common_scs && + fs->featureSetsUplinkPerCC->list.array[i]->supportedModulationOrderUL && + *fs->featureSetsUplinkPerCC->list.array[i]->supportedModulationOrderUL == NR_ModulationOrder_qam256) return(1); + } + } + return(0); +} + +int get_ul_mimo_layersCB(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { + int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + + // check featureSet + NR_FeatureSets_t *fs=cap->featureSets; + if (fs) { + // go through UL feature sets and look for one with current SCS + for (int i=0;ifeatureSetsUplinkPerCC->list.count;i++) { + if (fs->featureSetsUplinkPerCC->list.array[i]->supportedSubcarrierSpacingUL == common_scs && + fs->featureSetsUplinkPerCC->list.array[i]->mimo_CB_PUSCH && + fs->featureSetsUplinkPerCC->list.array[i]->mimo_CB_PUSCH->maxNumberMIMO_LayersCB_PUSCH) + return(1<<*fs->featureSetsUplinkPerCC->list.array[i]->mimo_CB_PUSCH->maxNumberMIMO_LayersCB_PUSCH); + } + } + return(1); +} + +int get_ul_mimo_layers(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { + int common_scs = rrc->carrier.servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + + // check featureSet + NR_FeatureSets_t *fs=cap->featureSets; + if (fs) { + // go through UL feature sets and look for one with current SCS + for (int i=0;ifeatureSetsUplinkPerCC->list.count;i++) { + if (fs->featureSetsUplinkPerCC->list.array[i]->supportedSubcarrierSpacingUL == common_scs && + fs->featureSetsUplinkPerCC->list.array[i]->maxNumberMIMO_LayersNonCB_PUSCH) + return(1<<*fs->featureSetsUplinkPerCC->list.array[i]->maxNumberMIMO_LayersNonCB_PUSCH); + } + } + return(1); +} + +int get_dl_mimo_layers(gNB_RRC_INST *rrc,NR_UE_NR_Capability_t *cap) { + int common_scs = rrc->carrier.servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->subcarrierSpacing; + + // check featureSet + NR_FeatureSets_t *fs=cap->featureSets; + if (fs) { + // go through UL feature sets and look for one with current SCS + for (int i=0;ifeatureSetsDownlinkPerCC->list.count;i++) { + if (fs->featureSetsUplinkPerCC->list.array[i]->supportedSubcarrierSpacingUL == common_scs && + fs->featureSetsDownlinkPerCC->list.array[i]->maxNumberMIMO_LayersPDSCH) + return(2<<*fs->featureSetsDownlinkPerCC->list.array[i]->maxNumberMIMO_LayersPDSCH); + } + } + return(1); +} void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) { + MessageDef *msg; + rrc_gNB_ue_context_t *ue_context_p = NULL; + FILE *fd=NULL;//fopen("nrRRCstats.log","w"); + RB_FOREACH(ue_context_p, rrc_nr_ue_tree_s, &(RC.nrrrc[ctxt_pP->module_id]->rrc_ue_head)) { + ctxt_pP->rnti = ue_context_p->ue_id_rnti; + + if (fd) { + if (ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.presence == TRUE) { + fprintf(fd,"NR RRC UE rnti %x: S-TMSI %x failure timer %d/8\n", + ue_context_p->ue_id_rnti, + ue_context_p->ue_context.Initialue_identity_5g_s_TMSI.fiveg_tmsi, + ue_context_p->ue_context.ul_failure_timer); + } else { + fprintf(fd,"NR RRC UE rnti %x failure timer %d/8\n", + ue_context_p->ue_id_rnti, + ue_context_p->ue_context.ul_failure_timer); + } + + if (ue_context_p->ue_context.UE_Capability_nr) { + fprintf(fd,"NR RRC UE cap: BW DL %x. BW UL %x, 256 QAM DL %s, 256 QAM UL %s, DL MIMO Layers %d UL MIMO Layers (CB) %d UL MIMO Layers (nonCB) %d\n", + get_dl_bw_mask(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), + get_ul_bw_mask(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), + is_dl_256QAM_supported(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr) == 1 ? "yes" : "no", + is_ul_256QAM_supported(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr) == 1 ? "yes" : "no", + get_dl_mimo_layers(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), + get_ul_mimo_layersCB(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr), + get_ul_mimo_layers(RC.nrrrc[0],ue_context_p->ue_context.UE_Capability_nr)); + } + } + 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); + if(ue_context_p->ue_context.StatusRrc >= NR_RRC_CONNECTED){ + rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_REQ( + ctxt_pP->module_id, + ue_context_p, + NGAP_CAUSE_RADIO_NETWORK, + 30); + }else{ + mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); + rrc_rlc_remove_ue(ctxt_pP); + pdcp_remove_UE(ctxt_pP); + + /* remove RRC UE Context */ + ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rnti); + if (ue_context_p) { + rrc_gNB_remove_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], ue_context_p); + LOG_I(NR_RRC, "remove UE %x \n", ctxt_pP->rnti); + } + } + 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(NR_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; + + mac_remove_nr_ue(ctxt_pP->module_id, ctxt_pP->rnti); + rrc_rlc_remove_ue(ctxt_pP); + pdcp_remove_UE(ctxt_pP); + + /* remove RRC UE Context */ + ue_context_p = rrc_gNB_get_ue_context(RC.nrrrc[ctxt_pP->module_id], ctxt_pP->rnti); + if (ue_context_p) { + rrc_gNB_remove_ue_context(ctxt_pP, RC.nrrrc[ctxt_pP->module_id], ue_context_p); + LOG_I(NR_RRC, "remove UE %x \n", ctxt_pP->rnti); + } + + break; // break RB_FOREACH + } + } + } + + if (fd) fclose(fd); /* send a tick to x2ap */ if (is_x2ap_enabled()){ @@ -2904,14 +3194,16 @@ void *rrc_gnb_task(void *args_p) { } nr_rrc_gNB_decode_ccch(&ctxt, - (uint8_t *)NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container, - NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id); + (uint8_t *)NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).sdu_size, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container, + NR_RRC_MAC_CCCH_DATA_IND(msg_p).CC_id); + if (NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container) { - free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container->buf); - free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container); + free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container->buf); + free(NR_RRC_MAC_CCCH_DATA_IND(msg_p).du_to_cu_rrc_container); } + break; /* Messages from PDCP */ @@ -3000,11 +3292,7 @@ void *rrc_gnb_task(void *args_p) { ///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.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti) - && rrc_eNB_get_ue_context(RC.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc > 0) { - rrc_eNB_get_ue_context(RC.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_rrc = - rrc_eNB_get_ue_context(RC.nrrrc[instance], GTPV1U_ENB_DELETE_TUNNEL_RESP(msg_p).rnti)->ue_context.ue_release_timer_thres_rrc; - } + AssertFatal(false, "Removed double mechanism for same feature: now delete_tunnel() function should be called\n"); break; #endif @@ -3145,14 +3433,14 @@ rrc_gNB_generate_SecurityModeCommand( GNB_RRC_DCCH_DATA_IND (message_p).size = size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #else - LOG_I(NR_RRC,"calling rrc_data_req :securityModeCommand\n"); + LOG_D(NR_RRC,"calling rrc_data_req :securityModeCommand\n"); nr_rrc_data_req(ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + DCCH, + rrc_gNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); #endif break; @@ -3227,14 +3515,13 @@ rrc_gNB_generate_UECapabilityEnquiry( GNB_RRC_DCCH_DATA_IND (message_p).size = size; itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #else - nr_rrc_data_req( - ctxt_pP, - DCCH, - rrc_gNB_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + nr_rrc_data_req(ctxt_pP, + DCCH, + rrc_gNB_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); #endif break; @@ -3263,6 +3550,8 @@ rrc_gNB_generate_RRCRelease( size = do_NR_RRCRelease(buffer,rrc_gNB_get_next_transaction_identifier(ctxt_pP->module_id)); ue_context_pP->ue_context.ue_reestablishment_timer = 0; ue_context_pP->ue_context.ue_release_timer = 0; + ue_context_pP->ue_context.ul_failure_timer = 0; + ue_context_pP->ue_context.ue_release_timer_rrc = 0; LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT" Logical Channel DL-DCCH, Generate RRCRelease (bytes %d)\n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP), @@ -3296,11 +3585,13 @@ rrc_gNB_generate_RRCRelease( itti_send_msg_to_task (TASK_RRC_UE_SIM, ctxt_pP->instance, message_p); #else if (NODE_IS_CU(RC.nrrrc[ctxt_pP->module_id]->node_type)) { + uint8_t *message_buffer = itti_malloc (TASK_RRC_GNB, TASK_CU_F1, size); + memcpy (message_buffer, buffer, size); MessageDef *m = itti_alloc_new_message(TASK_RRC_GNB, 0, F1AP_UE_CONTEXT_RELEASE_CMD); F1AP_UE_CONTEXT_RELEASE_CMD(m).rnti = ctxt_pP->rnti; F1AP_UE_CONTEXT_RELEASE_CMD(m).cause = F1AP_CAUSE_RADIO_NETWORK; F1AP_UE_CONTEXT_RELEASE_CMD(m).cause_value = 10; // 10 = F1AP_CauseRadioNetwork_normal_release - F1AP_UE_CONTEXT_RELEASE_CMD(m).rrc_container = buffer; + F1AP_UE_CONTEXT_RELEASE_CMD(m).rrc_container = message_buffer; F1AP_UE_CONTEXT_RELEASE_CMD(m).rrc_container_length = size; itti_send_msg_to_task(TASK_CU_F1, ctxt_pP->module_id, m); } else { @@ -3311,6 +3602,9 @@ rrc_gNB_generate_RRCRelease( size, buffer, PDCP_TRANSMISSION_MODE_CONTROL); + + rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE(ctxt_pP->instance, ue_context_pP->ue_context.gNB_ue_ngap_id); + ue_context_pP->ue_context.ue_release_timer_rrc = 1; } #endif } diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 5595f87d14..b7f9d2c671 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -306,13 +306,12 @@ nr_rrc_pdcp_config_security( uint8_t *kRRCenc = NULL; uint8_t *kRRCint = NULL; uint8_t *kUPenc = NULL; - uint8_t *k_kdf = NULL; - pdcp_t *pdcp_p = NULL; - static int print_keys= 1; - hashtable_rc_t h_rc; - hash_key_t key; + static int print_keys= 1; #ifndef PHYSIM + + uint8_t *k_kdf = NULL; + /* Derive the keys from kgnb */ if (SRB_configList != NULL) { k_kdf = NULL; @@ -493,7 +492,6 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ( itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, message_p); } - //------------------------------------------------------------------------------ int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( @@ -539,20 +537,20 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( if (nb_pdusessions_tosetup != 0) { memset(&create_tunnel_req, 0, sizeof(gtpv1u_gnb_create_tunnel_req_t)); for (int i = 0; i < NR_NB_RB_MAX - 3; i++) { - if(ue_context_p->ue_context.pdusession[i].status >= PDU_SESSION_STATUS_DONE) + if(ue_context_p->ue_context.pduSession[i].status >= PDU_SESSION_STATUS_DONE) continue; - ue_context_p->ue_context.pdusession[i].status = PDU_SESSION_STATUS_NEW; - ue_context_p->ue_context.pdusession[i].param = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done]; + ue_context_p->ue_context.pduSession[i].status = PDU_SESSION_STATUS_NEW; + ue_context_p->ue_context.pduSession[i].param = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done]; create_tunnel_req.pdusession_id[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].pdusession_id; create_tunnel_req.upf_NGu_teid[pdu_sessions_done] = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].gtp_teid; - create_tunnel_req.upf_addr[pdu_sessions_done].length = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[i].upf_addr.length; + create_tunnel_req.upf_addr[pdu_sessions_done].length = NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].upf_addr.length; memcpy(create_tunnel_req.upf_addr[pdu_sessions_done].buffer, - NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[i].upf_addr.buffer, + NGAP_INITIAL_CONTEXT_SETUP_REQ (msg_p).pdusession_param[pdu_sessions_done].upf_addr.buffer, sizeof(uint8_t)*20); LOG_I(NR_RRC, "PDUSESSION SETUP: local index %d teid %u, pdusession id %d \n", i, - create_tunnel_req.upf_NGu_teid[i], - create_tunnel_req.pdusession_id[i]); + create_tunnel_req.upf_NGu_teid[pdu_sessions_done], + create_tunnel_req.pdusession_id[pdu_sessions_done]); inde_list[pdu_sessions_done] = i; pdu_sessions_done++; @@ -623,7 +621,7 @@ rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ( } // in case, send the S1SP initial context response if it is not sent with the attach complete message - if (ue_context_p->ue_context.Status == NR_RRC_RECONFIGURED) { + if (ue_context_p->ue_context.StatusRrc == NR_RRC_RECONFIGURED) { LOG_I(NR_RRC, "Sending rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP, cause %ld\n", ue_context_p->ue_context.reestablishment_cause); rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP(&ctxt,ue_context_p); } @@ -649,24 +647,24 @@ rrc_gNB_send_NGAP_INITIAL_CONTEXT_SETUP_RESP( NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).gNB_ue_ngap_id = ue_context_pP->ue_context.gNB_ue_ngap_id; for (pdusession = 0; pdusession < ue_context_pP->ue_context.nb_of_pdusessions; pdusession++) { - if (ue_context_pP->ue_context.pdusession[pdusession].status == PDU_SESSION_STATUS_DONE) { + if (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_DONE) { pdu_sessions_done++; - NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pdusession[pdusession].param.pdusession_id; + NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; // TODO add other information from S1-U when it will be integrated NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].gtp_teid = ue_context_pP->ue_context.gnb_gtp_teid[pdusession]; memcpy(NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].gNB_addr.buffer , ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].buffer, 20); NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].gNB_addr.length = 4; - ue_context_pP->ue_context.pdusession[pdusession].status = PDU_SESSION_STATUS_ESTABLISHED; - NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].nb_of_qos_flow = ue_context_pP->ue_context.pdusession[pdusession].param.nb_qos; - for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pdusession[pdusession].param.nb_qos; qos_flow_index++) { + ue_context_pP->ue_context.pduSession[pdusession].status = PDU_SESSION_STATUS_ESTABLISHED; + NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].nb_of_qos_flow = ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos; + for (qos_flow_index = 0; qos_flow_index < ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos; qos_flow_index++) { NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qfi = - ue_context_pP->ue_context.pdusession[pdusession].param.qos[qos_flow_index].qfi; + ue_context_pP->ue_context.pduSession[pdusession].param.qos[qos_flow_index].qfi; NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qos_flow_mapping_ind = QOSFLOW_MAPPING_INDICATION_DL; } } else { pdu_sessions_failed++; - ue_context_pP->ue_context.pdusession[pdusession].status = PDU_SESSION_STATUS_FAILED; - NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions_failed[pdusession].pdusession_id = ue_context_pP->ue_context.pdusession[pdusession].param.pdusession_id; + ue_context_pP->ue_context.pduSession[pdusession].status = PDU_SESSION_STATUS_FAILED; + NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions_failed[pdusession].pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; // TODO add cause when it will be integrated NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions_failed[pdusession].cause = NGAP_Cause_PR_radioNetwork; NGAP_INITIAL_CONTEXT_SETUP_RESP (msg_p).pdusessions_failed[pdusession].cause_value = NGAP_CauseRadioNetwork_unknown_PDU_session_ID; @@ -739,7 +737,7 @@ rrc_gNB_process_security( /* Save security parameters */ ue_context_pP->ue_context.security_capabilities = *security_capabilities_pP; // translation - LOG_I(NR_RRC, + LOG_D(NR_RRC, "[gNB %d] NAS security_capabilities.encryption_algorithms %u AS ciphering_algorithm %lu NAS security_capabilities.integrity_algorithms %u AS integrity_algorithm %u\n", ctxt_pP->module_id, ue_context_pP->ue_context.security_capabilities.nRencryption_algorithms, @@ -788,8 +786,6 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS( struct rrc_gNB_ue_context_s *ue_context_p = NULL; protocol_ctxt_t ctxt; memset(&ctxt, 0, sizeof(protocol_ctxt_t)); - MessageDef *message_p; - ue_initial_id = NGAP_DOWNLINK_NAS (msg_p).ue_initial_id; gNB_ue_ngap_id = NGAP_DOWNLINK_NAS (msg_p).gNB_ue_ngap_id; ue_context_p = rrc_gNB_get_ue_context_from_ngap_ids(instance, ue_initial_id, gNB_ue_ngap_id); @@ -881,7 +877,7 @@ rrc_gNB_process_NGAP_DOWNLINK_NAS( uint8_t *message_buffer; message_buffer = itti_malloc (TASK_RRC_GNB, TASK_RRC_UE_SIM, length); memcpy (message_buffer, buffer, length); - message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); + MessageDef *message_p = itti_alloc_new_message (TASK_RRC_GNB, 0, GNB_RRC_DCCH_DATA_IND); GNB_RRC_DCCH_DATA_IND (message_p).rbid = DCCH; GNB_RRC_DCCH_DATA_IND (message_p).sdu = message_buffer; GNB_RRC_DCCH_DATA_IND (message_p).size = length; @@ -957,10 +953,10 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( for (pdusession = 0; pdusession < ue_context_pP->ue_context.setup_pdu_sessions; pdusession++) { // if (xid == ue_context_pP->ue_context.pdusession[pdusession].xid) { - if (ue_context_pP->ue_context.pdusession[pdusession].status == PDU_SESSION_STATUS_DONE) { - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pdusession[pdusession].param.pdusession_id; + if (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_DONE) { + NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; // NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].pdusession_id = 1; - NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].nb_of_qos_flow = ue_context_pP->ue_context.pdusession[pdusession].param.nb_qos; + NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].nb_of_qos_flow = ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos; NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gtp_teid = ue_context_pP->ue_context.gnb_gtp_teid[pdusession]; NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.pdu_session_type = PDUSessionType_ipv4; NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.length = ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].length; @@ -968,13 +964,13 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].buffer, sizeof(uint8_t)*20); for (qos_flow_index = 0; qos_flow_index < NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].nb_of_qos_flow; qos_flow_index++) { NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qfi = - ue_context_pP->ue_context.pdusession[pdusession].param.qos[qos_flow_index].qfi; + ue_context_pP->ue_context.pduSession[pdusession].param.qos[qos_flow_index].qfi; NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qos_flow_mapping_ind = QOSFLOW_MAPPING_INDICATION_DL; } - ue_context_pP->ue_context.pdusession[pdusession].status = PDU_SESSION_STATUS_ESTABLISHED; + ue_context_pP->ue_context.pduSession[pdusession].status = PDU_SESSION_STATUS_ESTABLISHED; LOG_I (NR_RRC,"gnb_gtp_addr (msg index %d, pdu_sessions index %d, status %d, xid %d): nb_of_pdusessions %d, pdusession_id %d, teid: %u, addr: %d.%d.%d.%d \n ", - pdu_sessions_done, pdusession, ue_context_pP->ue_context.pdusession[pdusession].status, xid, + pdu_sessions_done, pdusession, ue_context_pP->ue_context.pduSession[pdusession].status, xid, ue_context_pP->ue_context.nb_of_pdusessions, NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].pdusession_id, NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gtp_teid, @@ -983,12 +979,12 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[2], NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[3]); pdu_sessions_done++; - } else if ((ue_context_pP->ue_context.pdusession[pdusession].status == PDU_SESSION_STATUS_NEW) || - (ue_context_pP->ue_context.pdusession[pdusession].status == PDU_SESSION_STATUS_ESTABLISHED)) { + } else if ((ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_NEW) || + (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_ESTABLISHED)) { LOG_D (NR_RRC,"PDU-SESSION is NEW or already ESTABLISHED\n"); } else { /* to be improved */ - ue_context_pP->ue_context.pdusession[pdusession].status = PDU_SESSION_STATUS_FAILED; - NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions_failed[pdu_sessions_failed].pdusession_id = ue_context_pP->ue_context.pdusession[pdusession].param.pdusession_id; + ue_context_pP->ue_context.pduSession[pdusession].status = PDU_SESSION_STATUS_FAILED; + NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions_failed[pdu_sessions_failed].pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; pdu_sessions_failed++; // TODO add cause when it will be integrated } @@ -1017,7 +1013,7 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( } for(int i = 0; i < NB_RB_MAX; i++) { - ue_context_pP->ue_context.pdusession[i].xid = -1; + ue_context_pP->ue_context.pduSession[i].xid = -1; } return; @@ -1063,20 +1059,20 @@ rrc_gNB_process_NGAP_PDUSESSION_SETUP_REQ( PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); for (int i = 0; i < NR_NB_RB_MAX - 3; i++) { - if(ue_context_p->ue_context.pdusession[i].status >= PDU_SESSION_STATUS_DONE) + if(ue_context_p->ue_context.pduSession[i].status >= PDU_SESSION_STATUS_DONE) continue; - ue_context_p->ue_context.pdusession[i].status = PDU_SESSION_STATUS_NEW; - ue_context_p->ue_context.pdusession[i].param = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done]; + ue_context_p->ue_context.pduSession[i].status = PDU_SESSION_STATUS_NEW; + ue_context_p->ue_context.pduSession[i].param = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done]; create_tunnel_req.pdusession_id[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].pdusession_id; create_tunnel_req.upf_NGu_teid[pdu_sessions_done] = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].gtp_teid; memcpy(create_tunnel_req.upf_addr[pdu_sessions_done].buffer, - NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[i].upf_addr.buffer, + NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].upf_addr.buffer, sizeof(uint8_t)*20); - create_tunnel_req.upf_addr[pdu_sessions_done].length = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[i].upf_addr.length; + create_tunnel_req.upf_addr[pdu_sessions_done].length = NGAP_PDUSESSION_SETUP_REQ(msg_p).pdusession_setup_params[pdu_sessions_done].upf_addr.length; LOG_I(NR_RRC,"NGAP PDUSESSION SETUP REQ: local index %d teid %u, pdusession id %d \n", i, - create_tunnel_req.upf_NGu_teid[i], - create_tunnel_req.pdusession_id[i]); + create_tunnel_req.upf_NGu_teid[pdu_sessions_done], + create_tunnel_req.pdusession_id[pdu_sessions_done]); inde_list[pdu_sessions_done] = i; pdu_sessions_done++; @@ -1144,7 +1140,7 @@ rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_REQ( NGAP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).cause_value = cause_valueP; NGAP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).nb_of_pdusessions = ue_context_pP->ue_context.setup_pdu_sessions; for (int pdusession = 0; pdusession < ue_context_pP->ue_context.setup_pdu_sessions; pdusession++) { - NGAP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pdusession[pdusession].param.pdusession_id; + NGAP_UE_CONTEXT_RELEASE_REQ(msg_context_release_req_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; } itti_send_msg_to_task(TASK_NGAP, GNB_MODULE_ID_TO_INSTANCE(gnb_mod_idP), msg_context_release_req_p); } @@ -1229,11 +1225,25 @@ rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_COMMAND( return -1; } else { ue_context_p->ue_context.ue_release_timer_ng = 0; + ue_context_p->ue_context.ue_release_timer_thres_rrc = 1000; PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_YES, ue_context_p->ue_context.rnti, 0, 0); + ctxt.eNB_index = 0; rrc_gNB_generate_RRCRelease(&ctxt, ue_context_p); return 0; } } + +void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE( + instance_t instance, + uint32_t gNB_ue_ngap_id) { + MSC_LOG_TX_MESSAGE(MSC_RRC_GNB, MSC_NGAP_GNB, NULL, 0, + "0 NGAP_UE_CONTEXT_RELEASE_COMPLETE gNB_ue_ngap_id 0x%06"PRIX32" ", + gNB_ue_ngap_id); + MessageDef *msg = itti_alloc_new_message(TASK_RRC_GNB, 0, NGAP_UE_CONTEXT_RELEASE_COMPLETE); + NGAP_UE_CONTEXT_RELEASE_COMPLETE(msg).gNB_ue_ngap_id = gNB_ue_ngap_id; + itti_send_msg_to_task(TASK_NGAP, instance, msg); +} + //------------------------------------------------------------------------------ /* * Remove UE ids (ue_initial_id and ng_id) from hashtables. @@ -1343,12 +1353,12 @@ rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE( NGAP_PDUSESSION_RELEASE_RESPONSE (msg_p).gNB_ue_ngap_id = ue_context_pP->ue_context.gNB_ue_ngap_id; for (int i = 0; i < NB_RB_MAX; i++) { - if (xid == ue_context_pP->ue_context.pdusession[i].xid) { + if (xid == ue_context_pP->ue_context.pduSession[i].xid) { NGAP_PDUSESSION_RELEASE_RESPONSE (msg_p).pdusession_release[pdu_sessions_released].pdusession_id = - ue_context_pP->ue_context.pdusession[i].param.pdusession_id; + ue_context_pP->ue_context.pduSession[i].param.pdusession_id; pdu_sessions_released++; //clear - memset(&ue_context_pP->ue_context.pdusession[i], 0, sizeof(pdu_session_param_t)); + memset(&ue_context_pP->ue_context.pduSession[i], 0, sizeof(pdu_session_param_t)); } } @@ -1364,7 +1374,7 @@ rrc_gNB_send_NGAP_PDUSESSION_RELEASE_RESPONSE( //clear xid for(int i = 0; i < NB_RB_MAX; i++) { - ue_context_pP->ue_context.pdusession[i].xid = -1; + ue_context_pP->ue_context.pduSession[i].xid = -1; } //clear release pdusessions @@ -1425,7 +1435,7 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND( } for (i = 0; i < NR_NB_RB_MAX; i++) { - if (pdusession_release_params[pdusession].pdusession_id == ue_context_p->ue_context.pdusession[i].param.pdusession_id) { + if (pdusession_release_params[pdusession].pdusession_id == ue_context_p->ue_context.pduSession[i].param.pdusession_id) { b_existed = 1; break; } @@ -1439,13 +1449,13 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND( ue_context_p->ue_context.pdusessions_release_failed[ue_context_p->ue_context.nb_release_of_pdusessions].cause_value = 30; ue_context_p->ue_context.nb_release_of_pdusessions++; } else { - if(ue_context_p->ue_context.pdusession[i].status == PDU_SESSION_STATUS_FAILED) { - ue_context_p->ue_context.pdusession[i].xid = xid; + if(ue_context_p->ue_context.pduSession[i].status == PDU_SESSION_STATUS_FAILED) { + ue_context_p->ue_context.pduSession[i].xid = xid; continue; - } else if(ue_context_p->ue_context.pdusession[i].status == PDU_SESSION_STATUS_ESTABLISHED) { - LOG_I(NR_RRC, "RELEASE pdusession %d \n", ue_context_p->ue_context.pdusession[i].param.pdusession_id); - ue_context_p->ue_context.pdusession[i].status = PDU_SESSION_STATUS_TORELEASE; - ue_context_p->ue_context.pdusession[i].xid = xid; + } else if(ue_context_p->ue_context.pduSession[i].status == PDU_SESSION_STATUS_ESTABLISHED) { + LOG_I(NR_RRC, "RELEASE pdusession %d \n", ue_context_p->ue_context.pduSession[i].param.pdusession_id); + ue_context_p->ue_context.pduSession[i].status = PDU_SESSION_STATUS_TORELEASE; + ue_context_p->ue_context.pduSession[i].xid = xid; pdusession_release_drb++; } else { // pdusession_id status NG @@ -1469,7 +1479,7 @@ rrc_gNB_process_NGAP_PDUSESSION_RELEASE_COMMAND( GTPV1U_GNB_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.pdusession[i].xid) { + if(xid == ue_context_p->ue_context.pduSession[i].xid) { GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).pdusession_id[GTPV1U_GNB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).num_pdusession++] = ue_context_p->ue_context.gnb_gtp_psi[i]; ue_context_p->ue_context.gnb_gtp_teid[i] = 0; memset(&ue_context_p->ue_context.gnb_gtp_addrs[i], 0, sizeof(ue_context_p->ue_context.gnb_gtp_addrs[i])); diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.h b/openair2/RRC/NR/rrc_gNB_NGAP.h index f13c468f94..8779d62ff6 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.h +++ b/openair2/RRC/NR/rrc_gNB_NGAP.h @@ -129,6 +129,10 @@ rrc_gNB_process_NGAP_UE_CONTEXT_RELEASE_COMMAND( instance_t instance ); +void rrc_gNB_send_NGAP_UE_CONTEXT_RELEASE_COMPLETE( + instance_t instance, + uint32_t gNB_ue_ngap_id); + void rrc_gNB_NGAP_remove_ue_ids( gNB_RRC_INST *const rrc_instance_pP, diff --git a/openair2/RRC/NR/rrc_gNB_UE_context.c b/openair2/RRC/NR/rrc_gNB_UE_context.c index 988db09cc1..eb7559f69d 100644 --- a/openair2/RRC/NR/rrc_gNB_UE_context.c +++ b/openair2/RRC/NR/rrc_gNB_UE_context.c @@ -135,7 +135,7 @@ rrc_gNB_allocate_new_UE_context( for(int i = 0; i < NB_RB_MAX; i++) { new_p->ue_context.e_rab[i].xid = -1; - new_p->ue_context.pdusession[i].xid = -1; + new_p->ue_context.pduSession[i].xid = -1; new_p->ue_context.modify_e_rab[i].xid = -1; } diff --git a/openair2/RRC/NR/rrc_gNB_nsa.c b/openair2/RRC/NR/rrc_gNB_nsa.c index da7e3b1867..93a50dcd4e 100644 --- a/openair2/RRC/NR/rrc_gNB_nsa.c +++ b/openair2/RRC/NR/rrc_gNB_nsa.c @@ -63,8 +63,7 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con const NR_DRB_ToAddModList_t * const drb2add_listP, const NR_DRB_ToReleaseList_t * const drb2release_listP, const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_srb_bearer2add_list, - struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_drb_bearer2add_list); + struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t *cg_config_info) { struct rrc_gNB_ue_context_s *ue_context_p = NULL; @@ -153,7 +152,7 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ ue_context_p->ue_context.reconfig->criticalExtensions.present = NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration; NR_RRCReconfiguration_IEs_t *reconfig_ies=calloc(1,sizeof(NR_RRCReconfiguration_IEs_t)); ue_context_p->ue_context.reconfig->criticalExtensions.choice.rrcReconfiguration = reconfig_ies; - carrier->initial_csi_index[rrc->Nb_ue] = 0; + carrier->initial_csi_index[ue_context_p->local_uid + 1] = 0; ue_context_p->ue_context.rb_config = calloc(1,sizeof(NR_RRCReconfiguration_t)); if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1 || get_softmodem_params()->sa == 1){ fill_default_rbconfig(ue_context_p->ue_context.rb_config, @@ -246,14 +245,16 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ reconfig_ies, ue_context_p->ue_context.secondaryCellGroup, carrier->pdsch_AntennaPorts, - carrier->initial_csi_index[rrc->Nb_ue]); + carrier->initial_csi_index[ue_context_p->local_uid + 1], + ue_context_p->local_uid); } else { fill_default_reconfig(carrier->servingcellconfigcommon, NULL, reconfig_ies, ue_context_p->ue_context.secondaryCellGroup, carrier->pdsch_AntennaPorts, - carrier->initial_csi_index[rrc->Nb_ue]); + carrier->initial_csi_index[ue_context_p->local_uid + 1], + ue_context_p->local_uid); } ue_context_p->ue_id_rnti = ue_context_p->ue_context.secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity; NR_CG_Config_t *CG_Config = calloc(1,sizeof(*CG_Config)); @@ -376,27 +377,25 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ ctxt.eNB_index); } - nr_rrc_pdcp_config_asn1_req( - &ctxt, - (NR_SRB_ToAddModList_t *) NULL, - ue_context_p->ue_context.rb_config->drb_ToAddModList , - ue_context_p->ue_context.rb_config->drb_ToReleaseList, - (ue_context_p->ue_context.integrity_algorithm << 4) | ue_context_p->ue_context.ciphering_algorithm, - NULL, /* kRRCenc - unused */ - NULL, /* kRRCint - unused */ - kUPenc, /* kUPenc */ - NULL, /* kUPint - unused */ - NULL, - NULL, - ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); + nr_rrc_pdcp_config_asn1_req(&ctxt, + get_softmodem_params()->sa ? ue_context_p->ue_context.rb_config->srb_ToAddModList : (NR_SRB_ToAddModList_t *) NULL, + ue_context_p->ue_context.rb_config->drb_ToAddModList , + ue_context_p->ue_context.rb_config->drb_ToReleaseList, + (ue_context_p->ue_context.integrity_algorithm << 4) | ue_context_p->ue_context.ciphering_algorithm, + NULL, /* kRRCenc - unused */ + NULL, /* kRRCint - unused */ + kUPenc, /* kUPenc */ + NULL, /* kUPint - unused */ + NULL, + NULL, + ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); nr_rrc_rlc_config_asn1_req (&ctxt, - (NR_SRB_ToAddModList_t *) NULL, - ue_context_p->ue_context.rb_config->drb_ToAddModList, - ue_context_p->ue_context.rb_config->drb_ToReleaseList, - (LTE_PMCH_InfoList_r9_t *) NULL, - NULL, - ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); + get_softmodem_params()->sa ? ue_context_p->ue_context.rb_config->srb_ToAddModList : (NR_SRB_ToAddModList_t *) NULL, + ue_context_p->ue_context.rb_config->drb_ToAddModList, + ue_context_p->ue_context.rb_config->drb_ToReleaseList, + (LTE_PMCH_InfoList_r9_t *) NULL, + ue_context_p->ue_context.secondaryCellGroup->rlc_BearerToAddModList); LOG_D(RRC, "%s:%d: done RRC PDCP/RLC ASN1 request for UE rnti %x\n", __FUNCTION__, __LINE__, ctxt.rnti); @@ -405,7 +404,6 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) { protocol_ctxt_t ctxt; rrc_gNB_ue_context_t *ue_context; - MessageDef *msg_delete_tunnels_p; int e_rab; LOG_D(RRC, "calling rrc_remove_nsa_user rnti %d\n", rnti); @@ -422,25 +420,18 @@ void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti) { rrc_rlc_remove_ue(&ctxt); mac_remove_nr_ue(rrc->module_id, rnti); - - /* delete gtp tunnel */ - msg_delete_tunnels_p = itti_alloc_new_message(TASK_RRC_GNB, 0, 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 = rnti; - GTPV1U_ENB_DELETE_TUNNEL_REQ(msg_delete_tunnels_p).from_gnb = 1; - - LOG_D(RRC, "ue_context->ue_context.nb_of_e_rabs %d\n", ue_context->ue_context.nb_of_e_rabs); + gtpv1u_enb_delete_tunnel_req_t tmp={0}; + tmp.rnti=rnti; + tmp.from_gnb=1; + LOG_D(RRC, "ue_context->ue_context.nb_of_e_rabs %d will be deleted for rnti %d\n", ue_context->ue_context.nb_of_e_rabs, rnti); for (e_rab = 0; e_rab < ue_context->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->ue_context.gnb_gtp_ebi[e_rab]; + tmp.eps_bearer_id[tmp.num_erab++]= ue_context->ue_context.gnb_gtp_ebi[e_rab]; // erase data ue_context->ue_context.gnb_gtp_teid[e_rab] = 0; memset(&ue_context->ue_context.gnb_gtp_addrs[e_rab], 0, sizeof(ue_context->ue_context.gnb_gtp_addrs[e_rab])); ue_context->ue_context.gnb_gtp_ebi[e_rab] = 0; } - - itti_send_msg_to_task(TASK_VARIABLE, rrc->module_id, msg_delete_tunnels_p); - + gtpv1u_delete_s1u_tunnel(rrc->module_id, &tmp); /* remove context */ rrc_gNB_remove_ue_context(&ctxt, rrc, ue_context); } diff --git a/openair2/RRC/NR/rrc_gNB_reconfig.c b/openair2/RRC/NR/rrc_gNB_reconfig.c index 63cef7ffc0..ff4f2d93c6 100644 --- a/openair2/RRC/NR/rrc_gNB_reconfig.c +++ b/openair2/RRC/NR/rrc_gNB_reconfig.c @@ -55,7 +55,8 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco int scg_id, int servCellIndex, int n_physical_antenna_ports, - int initial_csi_index) { + int initial_csi_index, + int uid) { AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n"); AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n"); @@ -88,12 +89,22 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->rlc_BearerToAddModList = calloc(1,sizeof(*secondaryCellGroup->rlc_BearerToAddModList)); ASN_SEQUENCE_ADD(&secondaryCellGroup->rlc_BearerToAddModList->list, RLC_BearerConfig); + secondaryCellGroup->mac_CellGroupConfig=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig)); secondaryCellGroup->mac_CellGroupConfig->drx_Config = NULL; - secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig = NULL; + secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig)); + secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList)); + NR_SchedulingRequestToAddMod_t *SchedulingRequestConf = calloc(1,sizeof(*SchedulingRequestConf)); + SchedulingRequestConf->schedulingRequestId = 0; //Could be changed + SchedulingRequestConf->sr_ProhibitTimer = calloc(1,sizeof(*SchedulingRequestConf->sr_ProhibitTimer)); + *SchedulingRequestConf->sr_ProhibitTimer = NR_SchedulingRequestToAddMod__sr_ProhibitTimer_ms16; + SchedulingRequestConf->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n32; + ASN_SEQUENCE_ADD(&secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list,SchedulingRequestConf); + secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToReleaseList = NULL; + secondaryCellGroup->mac_CellGroupConfig->bsr_Config=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->bsr_Config)); - secondaryCellGroup->mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf80; - secondaryCellGroup->mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf320; + secondaryCellGroup->mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10; + secondaryCellGroup->mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf160; secondaryCellGroup->mac_CellGroupConfig->tag_Config=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->tag_Config)); secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL; secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList)); @@ -130,7 +141,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco *secondaryCellGroup->spCellConfig->servCellIndex = servCellIndex; secondaryCellGroup->spCellConfig->reconfigurationWithSync=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->reconfigurationWithSync)); secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon=servingcellconfigcommon; - secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity=0x1234;//(get_softmodem_params()->phy_test==1) ? 0x1234 : (taus()&0xffff); + secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity=(get_softmodem_params()->phy_test==1) ? 0x1234 : (taus()&0xffff); secondaryCellGroup->spCellConfig->reconfigurationWithSync->t304=NR_ReconfigurationWithSync__t304_ms2000; secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = NULL; secondaryCellGroup->spCellConfig->reconfigurationWithSync->ext1 = NULL; @@ -157,7 +168,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco if ((bitmap>>(63-i))&0x01){ ssbElem[n_ssb] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource)); ssbElem[n_ssb]->ssb = i; - ssbElem[n_ssb]->ra_PreambleIndex = 63; + ssbElem[n_ssb]->ra_PreambleIndex = 63 - (uid % 64); ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[n_ssb]); n_ssb++; } @@ -169,8 +180,8 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco secondaryCellGroup->spCellConfig->rlf_TimersAndConstants = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants)); secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup; secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup)); - secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->t310 = NR_RLF_TimersAndConstants__t310_ms2000; - secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n310 = NR_RLF_TimersAndConstants__n310_n10; + secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->t310 = NR_RLF_TimersAndConstants__t310_ms4000; + secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n310 = NR_RLF_TimersAndConstants__n310_n20; secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n311 = NR_RLF_TimersAndConstants__n311_n1; secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1 = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1)); secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1->t311 = NR_RLF_TimersAndConstants__ext1__t311_ms30000; @@ -855,22 +866,16 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1)); pucchresset0->pucch_ResourceSetId = 0; NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0)); - NR_PUCCH_ResourceId_t *pucchresset0id1=calloc(1,sizeof(*pucchresset0id1)); *pucchresset0id0=1; ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0); - *pucchresset0id1=2; - ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id1); pucchresset0->maxPayloadSize=NULL; ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0); pucchresset1->pucch_ResourceSetId = 1; NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0)); - NR_PUCCH_ResourceId_t *pucchresset1id1=calloc(1,sizeof(*pucchresset1id1)); - *pucchresset1id0=3; + *pucchresset1id0=2; ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0); - *pucchresset1id1=4; - ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id1); pucchresset1->maxPayloadSize=NULL; ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1); @@ -880,8 +885,9 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco NR_PUCCH_Resource_t *pucchres1=calloc(1,sizeof(*pucchres1)); NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2)); NR_PUCCH_Resource_t *pucchres3=calloc(1,sizeof(*pucchres3)); + pucchres0->pucch_ResourceId=1; - pucchres0->startingPRB=8; + pucchres0->startingPRB= (8 + uid) % curr_bwp; pucchres0->intraSlotFrequencyHopping=NULL; pucchres0->secondHopPRB=NULL; pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0; @@ -891,18 +897,7 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucchres0->format.choice.format0->startingSymbolIndex=13; ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0); - pucchres1->pucch_ResourceId=2; - pucchres1->startingPRB=8; - pucchres1->intraSlotFrequencyHopping=NULL; - pucchres1->secondHopPRB=NULL; - pucchres1->format.present= NR_PUCCH_Resource__format_PR_format0; - pucchres1->format.choice.format0=calloc(1,sizeof(*pucchres1->format.choice.format0)); - pucchres1->format.choice.format0->initialCyclicShift=0; - pucchres1->format.choice.format0->nrofSymbols=1; - pucchres1->format.choice.format0->startingSymbolIndex=12; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres1); - - pucchres2->pucch_ResourceId=3; + pucchres2->pucch_ResourceId=2; pucchres2->startingPRB=0; pucchres2->intraSlotFrequencyHopping=NULL; pucchres2->secondHopPRB=NULL; @@ -913,17 +908,6 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucchres2->format.choice.format2->startingSymbolIndex=13; ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2); - pucchres3->pucch_ResourceId=4; - pucchres3->startingPRB=0; - pucchres3->intraSlotFrequencyHopping=NULL; - pucchres3->secondHopPRB=NULL; - pucchres3->format.present= NR_PUCCH_Resource__format_PR_format2; - pucchres3->format.choice.format2=calloc(1,sizeof(*pucchres3->format.choice.format2)); - pucchres3->format.choice.format2->nrofPRBs=8; - pucchres3->format.choice.format2->nrofSymbols=1; - pucchres3->format.choice.format2->startingSymbolIndex=12; - ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres3); - pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2)); pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup; NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2)); @@ -931,11 +915,24 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco pucchfmt2->interslotFrequencyHopping=NULL; pucchfmt2->additionalDMRS=NULL; pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate)); - *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot25; + *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35; pucchfmt2->nrofSlots=NULL; pucchfmt2->pi2BPSK=NULL; - pucchfmt2->simultaneousHARQ_ACK_CSI=NULL; - pucch_Config->schedulingRequestResourceToAddModList=NULL; + pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI)); + *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true; + + // for scheduling requestresource + pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList)); + NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig)); + schedulingRequestResourceConfig->schedulingRequestResourceId = 1; + schedulingRequestResourceConfig->schedulingRequestID = 0; + schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset)); + schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10; + schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 7; + schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource)); + *schedulingRequestResourceConfig->resource = 1; + ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig); + pucch_Config->schedulingRequestResourceToReleaseList=NULL; pucch_Config->multi_CSI_PUCCH_ResourceList=NULL; pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK)); @@ -1083,10 +1080,10 @@ void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellco csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic; csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic)); csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320; - csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 49; + csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (10 * uid) % 320; NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1)); pucchcsires1->uplinkBandwidthPartId=1; - pucchcsires1->pucch_Resource=3; + pucchcsires1->pucch_Resource=2; ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1); csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP; csirep1->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0; @@ -1147,14 +1144,22 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon NR_RRCReconfiguration_IEs_t *reconfig, NR_CellGroupConfig_t *secondaryCellGroup, int n_physical_antenna_ports, - int initial_csi_index) { + int initial_csi_index, + int uid) { AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n"); AssertFatal(reconfig!=NULL,"reconfig is null\n"); AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n"); // radioBearerConfig reconfig->radioBearerConfig=NULL; // secondaryCellGroup - fill_default_secondaryCellGroup(servingcellconfigcommon,servingcellconfigdedicated,secondaryCellGroup,1,1,n_physical_antenna_ports,initial_csi_index); + fill_default_secondaryCellGroup(servingcellconfigcommon, + servingcellconfigdedicated, + secondaryCellGroup, + 1, + 1, + n_physical_antenna_ports, + initial_csi_index, + uid); xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup); char scg_buffer[1024]; diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index 1be3fb6225..5c9293dcf9 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -83,7 +83,7 @@ nr_mac_rrc_data_ind_ue( case CCCH: if (pdu_len>0) { - LOG_I(NR_RRC,"[UE %d] Received SDU for CCCH on SRB %u from gNB %d\n",module_id,channel & RAB_OFFSET,gNB_index); + LOG_T(NR_RRC,"[UE %d] Received SDU for CCCH on SRB %u from gNB %d\n",module_id,channel & RAB_OFFSET,gNB_index); MessageDef *message_p; int msg_sdu_size = CCCH_SDU_SIZE; @@ -129,13 +129,12 @@ int8_t nr_mac_rrc_data_req_ue(const module_id_t Mod_idP, //NR_UE_rrc_inst[Mod_idP].Info[gNB_id].T300_active = 1; //NR_UE_rrc_inst[Mod_idP].Info[gNB_id].T300_cnt = 0; - LOG_I(NR_RRC, "nr_mac_rrc_data_req_ue: Payload size = %i\n", NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size); + LOG_D(NR_RRC, "nr_mac_rrc_data_req_ue: Payload size = %i\n", NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size); memcpy(buffer_pP, (uint8_t*)NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.Payload, NR_UE_rrc_inst[Mod_idP].Srb0[gNB_id].Tx_buffer.payload_size); for(int i = 0; iframe; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index ad96dd39ce..a769acd144 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -69,9 +69,7 @@ #include "SIMULATION/TOOLS/sim.h" // for taus #include -#if defined(ITTI_SIM) || defined(RFSIM_NAS) #include "nr_nas_msg_sim.h" -#endif NR_UE_RRC_INST_t *NR_UE_rrc_inst; /* NAS Attach request with IMSI */ @@ -201,6 +199,7 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con const NR_DRB_ToReleaseList_t * const drb2release_listP, const LTE_PMCH_InfoList_r9_t * const pmch_InfoList_r9_pP, struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list); + // from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded) int8_t nr_rrc_ue_decode_secondary_cellgroup_config( const module_id_t module_id, @@ -565,9 +564,9 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( (void **)&bcch_message, (const void *)bufferP, buffer_len ); - + if ((dec_rval.code != RC_OK) || (dec_rval.consumed == 0)) { - LOG_I(NR_RRC,"NR_BCCH_BCH decode error\n"); + LOG_E(NR_RRC,"NR_BCCH_BCH decode error\n"); // free the memory SEQUENCE_free( &asn_DEF_NR_BCCH_BCH_Message, (void *)bcch_message, 1 ); return -1; @@ -582,10 +581,10 @@ int8_t nr_rrc_ue_decode_NR_BCCH_BCH_Message( nr_rrc_mac_config_req_ue( 0, 0, 0, NR_UE_rrc_inst[module_id].mib, NULL, NULL, NULL); } + return 0; } - const char siWindowLength[10][5] = {"5s", "10s", "20s", "40s", "80s", "160s", "320s", "640s", "1280s","ERR"};// {"1ms","2ms","5ms","10ms","15ms","20ms","40ms","80ms","ERR"}; const short siWindowLength_int[9] = {5,10,20,40,80,160,320,640,1280};//{1,2,5,10,15,20,40,80}; @@ -1175,7 +1174,7 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, if(sib1 != NULL){ SEQUENCE_free(&asn_DEF_NR_SIB1, (void *)sib1, 1 ); } - NR_UE_rrc_inst[module_id].Info[gNB_index].SIStatus|=1; + NR_UE_rrc_inst[module_id].Info[gNB_index].SIStatus|=1; sib1 = bcch_message->message.choice.c1->choice.systemInformationBlockType1; if (*(int64_t*)sib1 != 1) { NR_UE_rrc_inst[module_id].sib1[gNB_index] = sib1; @@ -1184,19 +1183,19 @@ int8_t nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(module_id_t module_id, } LOG_I(NR_RRC, "SIB1 decoded\n"); - /// dump_SIB1(); + /// dump_SIB1(); // FIXME: improve condition for the RA trigger // Check for on-demand not broadcasted SI check_requested_SI_List(module_id, NR_UE_rrc_inst[module_id].requested_SI_List, *sib1); if( nr_rrc_get_state(module_id) <= RRC_STATE_IDLE_NR ) { NR_UE_rrc_inst[module_id].ra_trigger = INITIAL_ACCESS_FROM_RRC_IDLE; - LOG_I(NR_RRC,"Setting state to NR_RRC_SI_RECEIVED\n"); - nr_rrc_set_state (module_id, NR_RRC_SI_RECEIVED); + LOG_D(PHY,"Setting state to NR_RRC_SI_RECEIVED\n"); + nr_rrc_set_state (module_id, NR_RRC_SI_RECEIVED); } - // take ServingCellConfigCommon and configure L1/L2 - NR_UE_rrc_inst[module_id].servingCellConfigCommonSIB = sib1->servingCellConfigCommon; - nr_rrc_mac_config_req_ue(module_id,0,0,NULL,sib1->servingCellConfigCommon,NULL,NULL); - nr_rrc_ue_generate_ra_msg(module_id,gNB_index); + // take ServingCellConfigCommon and configure L1/L2 + NR_UE_rrc_inst[module_id].servingCellConfigCommonSIB = sib1->servingCellConfigCommon; + nr_rrc_mac_config_req_ue(module_id,0,0,NULL,sib1->servingCellConfigCommon,NULL,NULL); + nr_rrc_ue_generate_ra_msg(module_id,gNB_index); } else { LOG_E(NR_RRC, "SIB1 not decoded\n"); } @@ -1251,17 +1250,21 @@ nr_rrc_ue_process_masterCellGroup( { NR_CellGroupConfig_t *cellGroupConfig=NULL; uper_decode(NULL, - &asn_DEF_NR_CellGroupConfig, //might be added prefix later - (void **)&cellGroupConfig, - (uint8_t *)masterCellGroup->buf, - masterCellGroup->size, 0, 0); + &asn_DEF_NR_CellGroupConfig, //might be added prefix later + (void **)&cellGroupConfig, + (uint8_t *)masterCellGroup->buf, + masterCellGroup->size, 0, 0); xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig); + if( cellGroupConfig->spCellConfig != NULL && cellGroupConfig->spCellConfig->reconfigurationWithSync != NULL){ //TODO (perform Reconfiguration with sync according to 5.3.5.5.2) //TODO (resume all suspended radio bearers and resume SCG transmission for all radio bearers, if suspended) // NSA procedures } - + + if(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config == NULL){ + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = calloc(1,sizeof(NR_CellGroupConfig_t)); + } if( cellGroupConfig->rlc_BearerToReleaseList != NULL){ //TODO (perform RLC bearer release as specified in 5.3.5.5.3) @@ -1269,10 +1272,24 @@ nr_rrc_ue_process_masterCellGroup( if( cellGroupConfig->rlc_BearerToAddModList != NULL){ //TODO (perform the RLC bearer addition/modification as specified in 5.3.5.5.4) + if(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList != NULL){ + free(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); + } + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList = calloc(1, sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList)); + memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList,cellGroupConfig->rlc_BearerToAddModList, + sizeof(struct NR_CellGroupConfig__rlc_BearerToAddModList)); } if( cellGroupConfig->mac_CellGroupConfig != NULL){ //TODO (configure the MAC entity of this cell group as specified in 5.3.5.5.5) + LOG_I(RRC, "Received mac_CellGroupConfig from gNB\n"); + if(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig != NULL){ + LOG_E(RRC, "UE RRC instance already contains mac CellGroupConfig which will be overwritten\n"); + free(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig); + } + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig = malloc(sizeof(struct NR_MAC_CellGroupConfig)); + memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->mac_CellGroupConfig,cellGroupConfig->mac_CellGroupConfig, + sizeof(struct NR_MAC_CellGroupConfig)); } if( cellGroupConfig->sCellToReleaseList != NULL){ @@ -1281,16 +1298,16 @@ nr_rrc_ue_process_masterCellGroup( if( cellGroupConfig->spCellConfig != NULL){ if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config && - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig) { + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig) { memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig,cellGroupConfig->spCellConfig, sizeof(struct NR_SpCellConfig)); } else { if (NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config) - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig = cellGroupConfig->spCellConfig; - else - NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = cellGroupConfig; + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->spCellConfig = cellGroupConfig->spCellConfig; + else + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config = cellGroupConfig; } - LOG_I(RRC,"Sending CellGroupConfig to MAC\n"); + LOG_D(RRC,"Sending CellGroupConfig to MAC\n"); nr_rrc_mac_config_req_ue(ctxt_pP->module_id,0,0,NULL,NULL,cellGroupConfig,NULL); //TODO (configure the SpCell as specified in 5.3.5.5.7) } @@ -1328,14 +1345,21 @@ static void rrc_ue_generate_RRCSetupComplete( AssertFatal(1==0,"2 > csi_MeasConfig is not null\n"); if (AMF_MODE_ENABLED) { -#if defined(ITTI_SIM) || defined(RFSIM_NAS) +#if defined(ITTI_SIM) as_nas_info_t initialNasMsg; - generateRegistrationRequest(&initialNasMsg); + generateRegistrationRequest(&initialNasMsg, ctxt_pP->module_id); nas_msg = (char*)initialNasMsg.data; nas_msg_length = initialNasMsg.length; #else - nas_msg = (char *) NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; - nas_msg_length = NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; + if (get_softmodem_params()->sa) { + as_nas_info_t initialNasMsg; + generateRegistrationRequest(&initialNasMsg, ctxt_pP->module_id); + nas_msg = (char*)initialNasMsg.data; + nas_msg_length = initialNasMsg.length; + } else { + nas_msg = (char *) NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data; + nas_msg_length = NR_UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.length; + } #endif } else { nas_msg = nr_nas_attach_req_imsi; @@ -1348,17 +1372,18 @@ static void rrc_ue_generate_RRCSetupComplete( "[FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCSetupComplete to gNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", ctxt_pP->frame, ctxt_pP->module_id+NB_RN_INST, size, gNB_index, nr_rrc_mui, ctxt_pP->module_id+NB_eNB_INST, DCCH); - for (int i=0;irnti; - rrc_data_req_ue( - ctxt_pP, - DCCH, - nr_rrc_mui++, - SDU_CONFIRM_NO, - size, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + rrc_data_req_ue(ctxt_pP, + DCCH, + nr_rrc_mui++, + SDU_CONFIRM_NO, + size, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); + #ifdef ITTI_SIM MessageDef *message_p; uint8_t *message_buffer; @@ -1378,7 +1403,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB asn_dec_rval_t dec_rval; int rval=0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_IN); - LOG_I(RRC,"[NR UE%d] Decoding DL-CCCH message (%d bytes), State %d\n",ctxt_pP->module_id,Srb_info->Rx_buffer.payload_size, + LOG_D(RRC,"[NR UE%d] Decoding DL-CCCH message (%d bytes), State %d\n",ctxt_pP->module_id,Srb_info->Rx_buffer.payload_size, NR_UE_rrc_inst[ctxt_pP->module_id].Info[gNB_index].State); dec_rval = uper_decode(NULL, &asn_DEF_NR_DL_CCCH_Message, @@ -1386,9 +1411,9 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB (uint8_t *)Srb_info->Rx_buffer.Payload, 100,0,0); - //if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { + if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { xer_fprint(stdout,&asn_DEF_NR_DL_CCCH_Message,(void *)dl_ccch_msg); - //} + } if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%zu bytes)\n",ctxt_pP->module_id,ctxt_pP->frame,dec_rval.consumed); @@ -1471,7 +1496,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB MessageDef *msg_p; asn_dec_rval_t dec_rval = uper_decode( NULL, - &asn_DEF_NR_DL_DCCH_Message, + &asn_DEF_NR_DL_DCCH_Message, (void**)&nr_dl_dcch_msg, (uint8_t *)bufferP, buffer_len, 0, 0); @@ -1486,7 +1511,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB } if(nr_dl_dcch_msg != NULL){ - switch(nr_dl_dcch_msg->message.present){ + switch(nr_dl_dcch_msg->message.present){ case NR_DL_DCCH_MessageType_PR_c1: switch(nr_dl_dcch_msg->message.choice.c1->present){ case NR_DL_DCCH_MessageType__c1_PR_rrcReconfiguration: @@ -1588,19 +1613,19 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB { switch (*securityModeCommand->criticalExtensions.choice.securityModeCommand->securityConfigSMC.securityAlgorithmConfig.integrityProtAlgorithm) { case NR_IntegrityProtAlgorithm_nia1: - LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to nia1\n",ctxt_pP->module_id); - securityMode |= 1 << 5; - break; + LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to nia1\n",ctxt_pP->module_id); + securityMode |= 1 << 5; + break; case NR_IntegrityProtAlgorithm_nia2: - LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to nia2\n",ctxt_pP->module_id); - securityMode |= 1 << 6; - break; + LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to nia2\n",ctxt_pP->module_id); + securityMode |= 1 << 6; + break; default: - LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id); - securityMode |= 0x70 ; - break; + LOG_I(NR_RRC,"[UE %d] Integrity protection algorithm is set to none\n",ctxt_pP->module_id); + securityMode |= 0x70 ; + break; } NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm = @@ -1629,8 +1654,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB pdcp_t *pdcp_p = NULL; hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; hashtable_rc_t h_rc; - key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_pP->rnti, - ctxt_pP->enb_flag, DCCH, SRB_FLAG_YES); + 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); if (h_rc == HASH_TABLE_OK) { @@ -1658,12 +1682,11 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB if (securityMode != 0xff) { pdcp_config_set_security(ctxt_pP, pdcp_p, 0, 0, - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm - | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), - kRRCenc, kRRCint, kUPenc); + NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm + | (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), + kRRCenc, kRRCint, kUPenc); } else { - LOG_I(NR_RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", - securityMode); + LOG_I(NR_RRC, "skipped pdcp_config_set_security() as securityMode == 0x%02x", securityMode); } } else { LOG_I(NR_RRC, "Could not get PDCP instance where key=0x%ld\n", key); @@ -1678,10 +1701,10 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB LOG_I(NR_RRC,"[UE %d] SFN/SF %d/%d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (gNB %d), rrc_TransactionIdentifier: %ld\n", ctxt_pP->module_id,ctxt_pP->frame, ctxt_pP->subframe, gNB_index, securityModeCommand->rrc_TransactionIdentifier); enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UL_DCCH_Message, - NULL, - (void *)&ul_dcch_msg, - buffer, - 100); + NULL, + (void *)&ul_dcch_msg, + buffer, + 100); AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded); @@ -1709,14 +1732,13 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB GNB_RRC_DCCH_DATA_IND (message_p).size = (enc_rval.encoded + 7) / 8; itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); #else - rrc_data_req_ue ( - ctxt_pP, - DCCH, - nr_rrc_mui++, - SDU_CONFIRM_NO, - (enc_rval.encoded + 7) / 8, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); + rrc_data_req_ue (ctxt_pP, + DCCH, + nr_rrc_mui++, + SDU_CONFIRM_NO, + (enc_rval.encoded + 7) / 8, + buffer, + PDCP_TRANSMISSION_MODE_CONTROL); #endif } else LOG_W(NR_RRC,"securityModeCommand->criticalExtensions.present (%d) != NR_SecurityModeCommand__criticalExtensions_PR_securityModeCommand\n", @@ -1753,79 +1775,66 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB module_id, NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size, gNB_index); for (i=0; imodule_id].Srb0[gNB_index].Tx_buffer.Payload,NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size, - LOG_DUMP_CHAR,"RRCSetupRequest :\n"); - rrc_data_req_ue ( - ctxt_pP, - DCCH, - nr_rrc_mui++, - SDU_CONFIRM_NO, - NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size, - (uint8_t *)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, - PDCP_TRANSMISSION_MODE_CONTROL); - */ +#ifdef ITTI_SIM + MessageDef *message_p; + uint8_t *message_buffer; + message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM, + NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size); + memcpy (message_buffer, (uint8_t*)NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.Payload, + NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size); + message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_CCCH_DATA_IND); + GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; + GNB_RRC_CCCH_DATA_IND (message_p).size = NR_UE_rrc_inst[module_id].Srb0[gNB_index].Tx_buffer.payload_size; + itti_send_msg_to_task (TASK_RRC_GNB_SIM, gNB_index, message_p); +#endif + } +} - #ifdef ITTI_SIM - MessageDef *message_p; - uint8_t *message_buffer; - message_buffer = itti_malloc (TASK_RRC_NRUE,TASK_RRC_GNB_SIM, - NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size); - memcpy (message_buffer, (uint8_t*)NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.Payload, - NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size); - message_p = itti_alloc_new_message (TASK_RRC_NRUE, 0, UE_RRC_CCCH_DATA_IND); - GNB_RRC_CCCH_DATA_IND (message_p).sdu = message_buffer; - GNB_RRC_CCCH_DATA_IND (message_p).size = NR_UE_rrc_inst[ctxt_pP->module_id].Srb0[gNB_index].Tx_buffer.payload_size; - itti_send_msg_to_task (TASK_RRC_GNB_SIM, ctxt_pP->instance, message_p); - #endif - } - } +//----------------------------------------------------------------------------- +int32_t +nr_rrc_ue_establish_srb1( + module_id_t ue_mod_idP, + frame_t frameP, + uint8_t gNB_index, + NR_SRB_ToAddMod_t *SRB_config +) +//----------------------------------------------------------------------------- +{ + // add descriptor from RRC PDU + NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Active = 1; + NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].status = RADIO_CONFIG_OK;//RADIO CFG + NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Srb_info.Srb_id = 1; + LOG_I(NR_RRC, "[UE %d], CONFIG_SRB1 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH, gNB_index); + return(0); +} - //----------------------------------------------------------------------------- - int32_t - nr_rrc_ue_establish_srb1( - module_id_t ue_mod_idP, - frame_t frameP, - uint8_t gNB_index, - NR_SRB_ToAddMod_t *SRB_config - ) - //----------------------------------------------------------------------------- - { - // add descriptor from RRC PDU - NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Active = 1; - NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG - NR_UE_rrc_inst[ue_mod_idP].Srb1[gNB_index].Srb_info.Srb_id = 1; - LOG_I(NR_RRC, "[UE %d], CONFIG_SRB1 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH, gNB_index); - return(0); - } - - //----------------------------------------------------------------------------- - int32_t - nr_rrc_ue_establish_srb2( - module_id_t ue_mod_idP, - frame_t frameP, - uint8_t gNB_index, - NR_SRB_ToAddMod_t *SRB_config - ) - //----------------------------------------------------------------------------- - { - // add descriptor from RRC PDU - NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Active = 1; - NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG - NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Srb_info.Srb_id = 2; - LOG_I(NR_RRC, "[UE %d], CONFIG_SRB2 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH1, gNB_index); - return(0); - } +//----------------------------------------------------------------------------- +int32_t +nr_rrc_ue_establish_srb2( + module_id_t ue_mod_idP, + frame_t frameP, + uint8_t gNB_index, + NR_SRB_ToAddMod_t *SRB_config +) +//----------------------------------------------------------------------------- +{ + // add descriptor from RRC PDU + NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Active = 1; + NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].status = RADIO_CONFIG_OK;//RADIO CFG + NR_UE_rrc_inst[ue_mod_idP].Srb2[gNB_index].Srb_info.Srb_id = 2; + LOG_I(NR_RRC, "[UE %d], CONFIG_SRB2 %d corresponding to gNB_index %d\n", ue_mod_idP, DCCH1, gNB_index); + return(0); +} //----------------------------------------------------------------------------- int32_t @@ -1891,8 +1900,8 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB if (measConfig->measObjectToRemoveList != NULL) { for (i = 0; i < measConfig->measObjectToRemoveList->list.count; i++) { - ind = *measConfig->measObjectToRemoveList->list.array[i]; - free(NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1]); + ind = *measConfig->measObjectToRemoveList->list.array[i]; + free(NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1]); } } @@ -1903,10 +1912,10 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB ind = measConfig->measObjectToAddModList->list.array[i]->measObjectId; if (NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1]) { - LOG_D(NR_RRC, "Modifying measurement object %ld\n",ind); - memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1], - (char *)measObj, - sizeof(NR_MeasObjectToAddMod_t)); + LOG_D(NR_RRC, "Modifying measurement object %ld\n",ind); + memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].MeasObj[gNB_index][ind-1], + (char *)measObj, + sizeof(NR_MeasObjectToAddMod_t)); } else { LOG_I(NR_RRC, "Adding measurement object %ld\n", ind); @@ -1922,8 +1931,8 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB if (measConfig->reportConfigToRemoveList != NULL) { for (i = 0; i < measConfig->reportConfigToRemoveList->list.count; i++) { - ind = *measConfig->reportConfigToRemoveList->list.array[i]; - free(NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1]); + ind = *measConfig->reportConfigToRemoveList->list.array[i]; + free(NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1]); } } @@ -1934,23 +1943,23 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB reportConfig = measConfig->reportConfigToAddModList->list.array[i]; if (NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1]) { - LOG_I(NR_RRC, "Modifying Report Configuration %ld\n", ind-1); - memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1], - (char *)measConfig->reportConfigToAddModList->list.array[i], - sizeof(NR_ReportConfigToAddMod_t)); + LOG_I(NR_RRC, "Modifying Report Configuration %ld\n", ind-1); + memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1], + (char *)measConfig->reportConfigToAddModList->list.array[i], + sizeof(NR_ReportConfigToAddMod_t)); } else { - LOG_D(NR_RRC,"Adding Report Configuration %ld %p \n", ind-1, measConfig->reportConfigToAddModList->list.array[i]); - if (reportConfig->reportConfig.present == NR_ReportConfigToAddMod__reportConfig_PR_reportConfigNR) { - NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; - } + LOG_D(NR_RRC,"Adding Report Configuration %ld %p \n", ind-1, measConfig->reportConfigToAddModList->list.array[i]); + if (reportConfig->reportConfig.present == NR_ReportConfigToAddMod__reportConfig_PR_reportConfigNR) { + NR_UE_rrc_inst[ctxt_pP->module_id].ReportConfig[gNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; + } } } } if (measConfig->measIdToRemoveList != NULL) { for (i = 0; i < measConfig->measIdToRemoveList->list.count; i++) { - ind = *measConfig->measIdToRemoveList->list.array[i]; - free(NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1]); + ind = *measConfig->measIdToRemoveList->list.array[i]; + free(NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1]); } } @@ -1959,13 +1968,13 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB ind = measConfig->measIdToAddModList->list.array[i]->measId; if (NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1]) { - LOG_D(NR_RRC, "Modifying Measurement ID %ld\n",ind-1); - memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1], - (char *)measConfig->measIdToAddModList->list.array[i], - sizeof(NR_MeasIdToAddMod_t)); + LOG_D(NR_RRC, "Modifying Measurement ID %ld\n",ind-1); + memcpy((char *)NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1], + (char *)measConfig->measIdToAddModList->list.array[i], + sizeof(NR_MeasIdToAddMod_t)); } else { - LOG_D(NR_RRC, "Adding Measurement ID %ld %p\n", ind-1, measConfig->measIdToAddModList->list.array[i]); - NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; + LOG_D(NR_RRC, "Adding Measurement ID %ld %p\n", ind-1, measConfig->measIdToAddModList->list.array[i]); + NR_UE_rrc_inst[ctxt_pP->module_id].MeasId[gNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; } } } @@ -2020,10 +2029,8 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB if (radioBearerConfig->srb_ToAddModList != NULL) { if (radioBearerConfig->securityConfig != NULL) { if (*radioBearerConfig->securityConfig->keyToUse == NR_SecurityConfig__keyToUse_master) { - NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm = - radioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm; - NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm = - *radioBearerConfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm; + NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm = radioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm; + NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm = *radioBearerConfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm; } } @@ -2062,7 +2069,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB if (SRB_id == 1) { if (NR_UE_rrc_inst[ctxt_pP->module_id].SRB1_config[gNB_index]) { memcpy(NR_UE_rrc_inst[ctxt_pP->module_id].SRB1_config[gNB_index], - radioBearerConfig->srb_ToAddModList->list.array[cnt], + radioBearerConfig->srb_ToAddModList->list.array[cnt], sizeof(NR_SRB_ToAddMod_t)); } else { NR_UE_rrc_inst[ctxt_pP->module_id].SRB1_config[gNB_index] = radioBearerConfig->srb_ToAddModList->list.array[cnt]; @@ -2128,28 +2135,27 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4)); // Refresh DRBs - // nr_rrc_pdcp_config_asn1_req(ctxt_pP, - // NULL, - // radioBearerConfig->drb_ToAddModList, - // NULL, - // NR_UE_rrc_inst[ctxt_pP->module_id].cipheringAlgorithm | - // (NR_UE_rrc_inst[ctxt_pP->module_id].integrityProtAlgorithm << 4), - // NULL, - // NULL, - // kUPenc, - // NULL, - // NULL, - // NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB, - // NULL); + nr_rrc_pdcp_config_asn1_req(ctxt_pP, + NULL, + radioBearerConfig->drb_ToAddModList, + NULL, + 0, + NULL, + NULL, + kUPenc, + NULL, + NULL, + NR_UE_rrc_inst[ctxt_pP->module_id].defaultDRB, + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList); // Refresh DRBs - // nr_rrc_rlc_config_asn1_req(ctxt_pP, - // NULL, - // radioBearerConfig->drb_ToAddModList, - // NULL, - // NULL, - // NULL - // ); - } // drb_ToAddModList + nr_rrc_rlc_config_asn1_req(ctxt_pP, + NULL, + radioBearerConfig->drb_ToAddModList, + NULL, + NULL, + NR_UE_rrc_inst[ctxt_pP->module_id].cell_group_config->rlc_BearerToAddModList + ); + } // drb_ToAddModList // if (radioBearerConfig->drb_ToReleaseList != NULL) { for (i = 0; i < radioBearerConfig->drb_ToReleaseList->list.count; i++) { @@ -2184,9 +2190,17 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB // nr_rrc_ue_process_measConfig(ctxt_pP, gNB_index, ie->measConfig); } + if(ie->nonCriticalExtension->masterCellGroup!=NULL) { + nr_rrc_ue_process_masterCellGroup( + ctxt_pP, + gNB_index, + ie->nonCriticalExtension->masterCellGroup); + } + + if (ie->radioBearerConfig != NULL) { LOG_I(NR_RRC, "radio Bearer Configuration is present\n"); - // nr_sa_rrc_ue_process_radioBearerConfig(ctxt_pP, gNB_index, ie->radioBearerConfig); + nr_sa_rrc_ue_process_radioBearerConfig(ctxt_pP, gNB_index, ie->radioBearerConfig); } /* Check if there is dedicated NAS information to forward to NAS */ @@ -2268,8 +2282,7 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB if (Srb_id != 1) { LOG_E(NR_RRC,"[UE %d] Frame %d: Received message on DL-DCCH (SRB%ld), should not have ...\n", - ctxt_pP->module_id, ctxt_pP->frame, Srb_id); - return -1; + ctxt_pP->module_id, ctxt_pP->frame, Srb_id); } else { LOG_D(NR_RRC, "Received message on SRB%ld\n", Srb_id); } @@ -2327,40 +2340,39 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB itti_send_msg_to_task(TASK_NAS_UE, ctxt_pP->instance, msg_p); break; case NR_DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: - LOG_I(NR_RRC, "[UE %d] Received Capability Enquiry (gNB %d)\n", - ctxt_pP->module_id,gNB_indexP); - nr_rrc_ue_process_ueCapabilityEnquiry( - ctxt_pP, - dl_dcch_msg->message.choice.c1->choice.ueCapabilityEnquiry, - gNB_indexP); - break; + LOG_I(NR_RRC, "[UE %d] Received Capability Enquiry (gNB %d)\n", ctxt_pP->module_id,gNB_indexP); + nr_rrc_ue_process_ueCapabilityEnquiry( + ctxt_pP, + dl_dcch_msg->message.choice.c1->choice.ueCapabilityEnquiry, + gNB_indexP); + break; case NR_DL_DCCH_MessageType__c1_PR_rrcReestablishment: - LOG_I(NR_RRC, - "[UE%d] Frame %d : Logical Channel DL-DCCH (SRB1), Received RRCReestablishment\n", - ctxt_pP->module_id, - ctxt_pP->frame); - nr_rrc_ue_generate_rrcReestablishmentComplete( - ctxt_pP, - dl_dcch_msg->message.choice.c1->choice.rrcReestablishment, - gNB_indexP); - break; + LOG_I(NR_RRC, + "[UE%d] Frame %d : Logical Channel DL-DCCH (SRB1), Received RRCReestablishment\n", + ctxt_pP->module_id, + ctxt_pP->frame); + nr_rrc_ue_generate_rrcReestablishmentComplete( + ctxt_pP, + dl_dcch_msg->message.choice.c1->choice.rrcReestablishment, + gNB_indexP); + break; case NR_DL_DCCH_MessageType__c1_PR_dlInformationTransfer: { - NR_DLInformationTransfer_t *dlInformationTransfer = dl_dcch_msg->message.choice.c1->choice.dlInformationTransfer; + NR_DLInformationTransfer_t *dlInformationTransfer = dl_dcch_msg->message.choice.c1->choice.dlInformationTransfer; - if (dlInformationTransfer->criticalExtensions.present - == NR_DLInformationTransfer__criticalExtensions_PR_dlInformationTransfer) { - /* This message hold a dedicated info NAS payload, forward it to NAS */ - NR_DedicatedNAS_Message_t *dedicatedNAS_Message = - dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message; + if (dlInformationTransfer->criticalExtensions.present + == NR_DLInformationTransfer__criticalExtensions_PR_dlInformationTransfer) { + /* This message hold a dedicated info NAS payload, forward it to NAS */ + NR_DedicatedNAS_Message_t *dedicatedNAS_Message = + dlInformationTransfer->criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message; - MessageDef *msg_p; - msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_DOWNLINK_DATA_IND); - NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ? - NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = dedicatedNAS_Message->size; - NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = dedicatedNAS_Message->buf; - itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p); - } + MessageDef *msg_p; + msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NAS_DOWNLINK_DATA_IND); + NAS_DOWNLINK_DATA_IND(msg_p).UEid = ctxt_pP->module_id; // TODO set the UEid to something else ? + NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = dedicatedNAS_Message->size; + NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = dedicatedNAS_Message->buf; + itti_send_msg_to_task(TASK_NAS_NRUE, ctxt_pP->instance, msg_p); + } } break; @@ -2375,15 +2387,15 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB case NR_DL_DCCH_MessageType__c1_PR_counterCheck: break; case NR_DL_DCCH_MessageType__c1_PR_securityModeCommand: - LOG_I(NR_RRC, "[UE %d] Received securityModeCommand (gNB %d)\n", - ctxt_pP->module_id, gNB_indexP); - nr_rrc_ue_process_securityModeCommand( - ctxt_pP, - dl_dcch_msg->message.choice.c1->choice.securityModeCommand, - gNB_indexP); + LOG_I(NR_RRC, "[UE %d] Received securityModeCommand (gNB %d)\n", + ctxt_pP->module_id, gNB_indexP); + nr_rrc_ue_process_securityModeCommand( + ctxt_pP, + dl_dcch_msg->message.choice.c1->choice.securityModeCommand, + gNB_indexP); - break; - } + break; + } } return 0; } @@ -2406,48 +2418,48 @@ int8_t nr_rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const NR_SRB switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: - LOG_W(NR_RRC, " *** Exiting RRC thread\n"); - itti_exit_task (); - break; + LOG_W(NR_RRC, " *** Exiting RRC thread\n"); + itti_exit_task (); + break; case MESSAGE_TEST: - LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); - break; + LOG_D(NR_RRC, "[UE %d] Received %s\n", ue_mod_id, ITTI_MSG_NAME (msg_p)); + break; case NR_RRC_MAC_BCCH_DATA_IND: - LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), - NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); - nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message (ctxt.module_id, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, - NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); - break; + LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p), + NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); + PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index); + nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message (ctxt.module_id, + NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index, + NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu, + NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size, + NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, + NR_RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); + break; case NR_RRC_MAC_CCCH_DATA_IND: - LOG_I(NR_RRC, "[UE %d] RNTI %x Received %s: frameP %d, gNB %d\n", - ue_mod_id, - NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, - ITTI_MSG_NAME (msg_p), - NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, - NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); - srb_info_p = &NR_UE_rrc_inst[ue_mod_id].Srb0[NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index]; - memcpy (srb_info_p->Rx_buffer.Payload, NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu, - NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size); - srb_info_p->Rx_buffer.payload_size = NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size; - PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0); - // PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); - nr_rrc_ue_decode_ccch (&ctxt, - srb_info_p, - NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); - break; + LOG_D(NR_RRC, "[UE %d] RNTI %x Received %s: frameP %d, gNB %d\n", + ue_mod_id, + NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, + ITTI_MSG_NAME (msg_p), + NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, + NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); + srb_info_p = &NR_UE_rrc_inst[ue_mod_id].Srb0[NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index]; + memcpy (srb_info_p->Rx_buffer.Payload, NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu, + NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size); + srb_info_p->Rx_buffer.payload_size = NR_RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size; + PROTOCOL_CTXT_SET_BY_INSTANCE(&ctxt, instance, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0); + // PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NR_RRC_MAC_CCCH_DATA_IND (msg_p).rnti, NR_RRC_MAC_CCCH_DATA_IND (msg_p).frame, 0, NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); + nr_rrc_ue_decode_ccch (&ctxt, + srb_info_p, + NR_RRC_MAC_CCCH_DATA_IND (msg_p).gnb_index); + break; /* PDCP messages */ case NR_RRC_DCCH_DATA_IND: PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, NR_RRC_DCCH_DATA_IND (msg_p).module_id, GNB_FLAG_NO, NR_RRC_DCCH_DATA_IND (msg_p).rnti, NR_RRC_DCCH_DATA_IND (msg_p).frame, 0,NR_RRC_DCCH_DATA_IND (msg_p).gNB_index); - LOG_I(NR_RRC, "[UE %d] Received %s: frameP %d, DCCH %d, gNB %d\n", + LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, DCCH %d, gNB %d\n", NR_RRC_DCCH_DATA_IND (msg_p).module_id, ITTI_MSG_NAME (msg_p), NR_RRC_DCCH_DATA_IND (msg_p).frame, diff --git a/openair2/SIMULATION/NR_RRC/itti_sim.c b/openair2/SIMULATION/NR_RRC/itti_sim.c index 01b3fbfa35..0cd022217d 100644 --- a/openair2/SIMULATION/NR_RRC/itti_sim.c +++ b/openair2/SIMULATION/NR_RRC/itti_sim.c @@ -81,6 +81,8 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "RRC/NR_UE/rrc_proto.h" #include "RRC/NR_UE/rrc_vars.h" #include "openair3/NAS/UE/nas_ue_task.h" +#include +#include #if ITTI_SIM #include "nr_nas_msg_sim.h" #endif @@ -89,7 +91,6 @@ pthread_cond_t nfapi_sync_cond; pthread_mutex_t nfapi_sync_mutex; int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex -uint8_t nfapi_mode = 0; // Default to monolithic mode uint32_t timing_advance = 0; uint64_t num_missed_slots=0; @@ -97,7 +98,18 @@ int split73=0; void sendFs6Ul(PHY_VARS_eNB *eNB, int UE_id, int harq_pid, int segmentID, int16_t *data, int dataLen, int r_offset) { AssertFatal(false, "Must not be called in this context\n"); } +void sendFs6Ulharq(enum pckType type, int UEid, PHY_VARS_eNB *eNB, LTE_eNB_UCI *uci, int frame, int subframe, uint8_t *harq_ack, uint8_t tdd_mapping_mode, uint16_t tdd_multiplexing_mask, uint16_t rnti, int32_t stat) { + AssertFatal(false, "Must not be called in this context\n"); +} +nrUE_params_t nrUE_params; +nrUE_params_t *get_nrUE_params(void) { + return &nrUE_params; +} + +void processSlotTX(void *arg) {} + +THREAD_STRUCT thread_struct; pthread_cond_t sync_cond; pthread_mutex_t sync_mutex; int sync_var=-1; //!< protected by mutex \ref sync_mutex. @@ -404,7 +416,7 @@ int create_tasks_nrue(uint32_t ue_nb) { return -1; } - printf("create TASK_NAS_NRUE\n"); + LOG_D(NR_RRC,"create TASK_NAS_NRUE\n"); if (itti_create_task (TASK_NAS_NRUE, nas_nrue_task, NULL) < 0) { LOG_E(NR_RRC, "Create task for NAS UE failed\n"); return -1; diff --git a/openair2/UTIL/OPT/opt.h b/openair2/UTIL/OPT/opt.h index a3a790cf97..ae6a3eb2a6 100644 --- a/openair2/UTIL/OPT/opt.h +++ b/openair2/UTIL/OPT/opt.h @@ -59,12 +59,7 @@ typedef uint16_t guint16; typedef uint32_t guint32; typedef guint8 gboolean; -#include "packet-mac-lte.h" -#include "packet-rlc-lte.h" -#include "packet-pdcp-lte.h" -#include "packet-mac-nr.h" -#include "packet-rlc-nr.h" -#include "packet-pdcp-nr.h" +#include #include "mac_pcap.h" diff --git a/openair2/UTIL/OPT/packet-mac-lte.h b/openair2/UTIL/OPT/packet-mac-lte.h deleted file mode 100644 index 33e987c4ab..0000000000 --- a/openair2/UTIL/OPT/packet-mac-lte.h +++ /dev/null @@ -1,299 +0,0 @@ -/* packet-mac-lte.h - * - * Martin Mathieson - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - * - * This header file may also be distributed under - * the terms of the BSD Licence as follows: - * - * Copyright (C) 2009 Martin Mathieson. All rights reserved. - * - * SPDX-License-Identifier: BSD-2-Clause - */ - - /* - this is wireshark, commit: commit eda834b6e29c36e05a63a6056afa98390ff79357 - Date: Wed Aug 22 14:36:20 2018 +0200 - modified to be used in OpenAir to create the LTE MAC/RLC encapsulated in UDP as per Wireshark feature - */ - -#ifndef __UTIL_OPT_PACKET_MAC_LTE__H__ -#define __UTIL_OPT_PACKET_MAC_LTE__H__ - -#include "ws_symbol_export.h" - -/** data structure to hold time values with nanosecond resolution*/ -typedef struct { - time_t secs; - int nsecs; -} nstime_t; - - -/* radioType */ -#define FDD_RADIO 1 -#define TDD_RADIO 2 - -/* Direction */ -#define DIRECTION_UPLINK 0 -#define DIRECTION_DOWNLINK 1 - -/* rntiType */ -#define WS_NO_RNTI 0 -#define WS_P_RNTI 1 -#define WS_RA_RNTI 2 -#define WS_C_RNTI 3 -#define WS_SI_RNTI 4 -#define WS_SPS_RNTI 5 -#define WS_M_RNTI 6 -#define WS_SL_BCH_RNTI 7 -#define WS_SL_RNTI 8 -#define WS_SC_RNTI 9 -#define WS_G_RNTI 10 - -typedef enum mac_lte_oob_event { - ltemac_send_preamble, - ltemac_send_sr, - ltemac_sr_failure -} mac_lte_oob_event; - -typedef enum mac_lte_dl_retx { - dl_retx_no, - dl_retx_yes, - dl_retx_unknown -} mac_lte_dl_retx; - -typedef enum mac_lte_crc_status { - crc_fail = 0, - crc_success = 1, - crc_high_code_rate = 2, - crc_pdsch_lost = 3, - crc_duplicate_nonzero_rv = 4, - crc_false_dci = 5 -} mac_lte_crc_status; - -/* N.B. for SCellIndex-r13 extends to 31 */ -typedef enum mac_lte_carrier_id { - carrier_id_primary, - carrier_id_secondary_1, - carrier_id_secondary_2, - carrier_id_secondary_3, - carrier_id_secondary_4, - carrier_id_secondary_5, - carrier_id_secondary_6, - carrier_id_secondary_7 -} mac_lte_carrier_id; - -typedef enum mac_lte_ce_mode { - no_ce_mode = 0, - ce_mode_a = 1, - ce_mode_b = 2 -} mac_lte_ce_mode; - -typedef enum mac_lte_nb_mode { - no_nb_mode = 0, - nb_mode = 1 -} mac_lte_nb_mode; - -/* Context info attached to each LTE MAC frame */ -typedef struct mac_lte_info -{ - /* Needed for decode */ - guint8 radioType; - guint8 direction; - guint8 rntiType; - - /* Extra info to display */ - guint16 rnti; - guint16 ueid; - - /* Timing info */ - guint16 sysframeNumber; - guint16 subframeNumber; - gboolean sfnSfInfoPresent; - - /* Optional field. More interesting for TDD (FDD is always -4 subframeNumber) */ - gboolean subframeNumberOfGrantPresent; - guint16 subframeNumberOfGrant; - - /* Flag set only if doing PHY-level data test - i.e. there may not be a - well-formed MAC PDU so just show as raw data */ - gboolean isPredefinedData; - - /* Length of DL PDU or UL grant size in bytes */ - guint16 length; - - /* 0=newTx, 1=first-retx, etc */ - guint8 reTxCount; - guint8 isPHICHNACK; /* FALSE=PDCCH retx grant, TRUE=PHICH NACK */ - - /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set */ - gboolean isExtendedBSRSizes; - - /* UL only. Indicates if the R10 simultaneousPUCCH-PUSCH parameter is set for PCell */ - gboolean isSimultPUCCHPUSCHPCell; - - /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set for PSCell */ - gboolean isSimultPUCCHPUSCHPSCell; - - /* Status of CRC check. For UE it is DL only. For eNodeB it is UL - only. For an analyzer, it is present for both DL and UL. */ - gboolean crcStatusValid; - mac_lte_crc_status crcStatus; - - /* Carrier ID */ - mac_lte_carrier_id carrierId; - - /* DL only. Is this known to be a retransmission? */ - mac_lte_dl_retx dl_retx; - - /* DL only. CE mode to be used for RAR decoding */ - mac_lte_ce_mode ceMode; - - /* DL and UL. NB-IoT mode of the UE */ - mac_lte_nb_mode nbMode; - - /* UL only, for now used for CE mode A RAR decoding */ - guint8 nUlRb; - - /* More Physical layer info (see direction above for which side of union to use) */ - union { - struct mac_lte_ul_phy_info - { - guint8 present; /* Remaining UL fields are present and should be displayed */ - guint8 modulation_type; - guint8 tbs_index; - guint8 resource_block_length; - guint8 resource_block_start; - guint8 harq_id; - gboolean ndi; - } ul_info; - struct mac_lte_dl_phy_info - { - guint8 present; /* Remaining DL fields are present and should be displayed */ - guint8 dci_format; - guint8 resource_allocation_type; - guint8 aggregation_level; - guint8 mcs_index; - guint8 redundancy_version_index; - guint8 resource_block_length; - guint8 harq_id; - gboolean ndi; - guint8 transport_block; /* 0..1 */ - } dl_info; - } detailed_phy_info; - - /* Relating to out-of-band events */ - /* N.B. dissector will only look to these fields if length is 0... */ - mac_lte_oob_event oob_event; - guint8 rapid; - guint8 rach_attempt_number; - #define MAX_SRs 20 - guint16 number_of_srs; - guint16 oob_ueid[MAX_SRs]; - guint16 oob_rnti[MAX_SRs]; -} mac_lte_info; - - /* 0 to 10 and 32 to 38 */ -#define MAC_LTE_DATA_LCID_COUNT_MAX 18 - - - - -/* Accessor function to check if a frame was considered to be ReTx */ - -/**********************************************************************/ -/* UDP framing format */ -/* ----------------------- */ -/* Several people have asked about dissecting MAC by framing */ -/* PDUs over IP. A suggested format over UDP has been created */ -/* and implemented by this dissector, using the definitions */ -/* below. A link to an example program showing you how to encode */ -/* these headers and send LTE MAC PDUs on a UDP socket is */ -/* provided at https://gitlab.com/wireshark/wireshark/-/wikis/MAC-LTE */ -/* */ -/* A heuristic dissector (enabled by a preference) will */ -/* recognise a signature at the beginning of these frames. */ -/**********************************************************************/ - - -/* Signature. Rather than try to define a port for this, or make the - port number a preference, frames will start with this string (with no - terminating NULL */ -#define MAC_LTE_START_STRING "mac-lte" - -/* Fixed fields. This is followed by the following 3 mandatory fields: - - radioType (1 byte) - - direction (1 byte) - - rntiType (1 byte) - (where the allowed values are defined above */ - -/* Optional fields. Attaching this info to frames will allow you - to show you display/filter/plot/add-custom-columns on these fields, so should - be added if available. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag) */ - -#define MAC_LTE_RNTI_TAG 0x02 -/* 2 bytes, network order */ - -#define MAC_LTE_UEID_TAG 0x03 -/* 2 bytes, network order */ - -#define MAC_LTE_FRAME_SUBFRAME_TAG 0x04 -/* 2 bytes, network order, SFN is stored in 12 MSB and SF in 4 LSB */ - -#define MAC_LTE_PREDEFINED_DATA_TAG 0x05 -/* 1 byte */ - -#define MAC_LTE_RETX_TAG 0x06 -/* 1 byte */ - -#define MAC_LTE_CRC_STATUS_TAG 0x07 -/* 1 byte */ - -#define MAC_LTE_EXT_BSR_SIZES_TAG 0x08 -/* 0 byte */ - -#define MAC_LTE_SEND_PREAMBLE_TAG 0x09 -/* 2 bytes, RAPID value (1 byte) followed by RACH attempt number (1 byte) */ - -#define MAC_LTE_CARRIER_ID_TAG 0x0A -/* 1 byte */ - -#define MAC_LTE_PHY_TAG 0x0B -/* variable length, length (1 byte) then depending on direction - in UL: modulation type (1 byte), TBS index (1 byte), RB length (1 byte), - RB start (1 byte), HARQ id (1 byte), NDI (1 byte) - in DL: DCI format (1 byte), resource allocation type (1 byte), aggregation level (1 byte), - MCS index (1 byte), redundancy version (1 byte), resource block length (1 byte), - HARQ id (1 byte), NDI (1 byte), TB (1 byte), DL reTx (1 byte) */ - -#define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL_TAG 0x0C -/* 0 byte */ - -#define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL_TAG 0x0D -/* 0 byte */ - -#define MAC_LTE_CE_MODE_TAG 0x0E -/* 1 byte containing mac_lte_ce_mode enum value */ - -#define MAC_LTE_NB_MODE_TAG 0x0F -/* 1 byte containing mac_lte_nb_mode enum value */ - -#define MAC_LTE_N_UL_RB_TAG 0x10 -/* 1 byte containing the number of UL resource blocks: 6, 15, 25, 50, 75 or 100 */ - -#define MAC_LTE_SR_TAG 0x11 -/* 2 bytes for the number of items, followed by that number of ueid, rnti (2 bytes each) */ - - -/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU - continues until the end of the frame) */ -#define MAC_LTE_PAYLOAD_TAG 0x01 - -#endif diff --git a/openair2/UTIL/OPT/packet-mac-nr.h b/openair2/UTIL/OPT/packet-mac-nr.h deleted file mode 100644 index 8a1627a8ef..0000000000 --- a/openair2/UTIL/OPT/packet-mac-nr.h +++ /dev/null @@ -1,142 +0,0 @@ -/* packet-mac-nr.h - * - * Martin Mathieson - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -/* radioType */ -#define FDD_RADIO 1 -#define TDD_RADIO 2 - -/* Direction */ -#define DIRECTION_UPLINK 0 -#define DIRECTION_DOWNLINK 1 - -/* rntiType */ -#define WS_NO_RNTI 0 -#define WS_P_RNTI 1 -#define WS_RA_RNTI 2 -#define WS_C_RNTI 3 -#define WS_SI_RNTI 4 -#define WS_CS_RNTI 5 - -/* Context info attached to each NR MAC frame */ -typedef struct mac_nr_info -{ - /* Needed for decode */ - guint8 radioType; - guint8 direction; - guint8 rntiType; - - /* Extra info to display */ - guint16 rnti; - guint16 ueid; - guint8 harqid; - - /* Will these be included in the ME PHR report? */ - guint8 phr_type2_othercell; - - /* Timing info */ - gboolean sfnSlotInfoPresent; - guint16 sysframeNumber; - guint16 slotNumber; - - /* Length of DL PDU or UL grant size in bytes */ - guint16 length; - -} mac_nr_info; - - -/*****************************************************************/ -/* UDP framing format */ -/* ----------------------- */ -/* Several people have asked about dissecting MAC by framing */ -/* PDUs over IP. A suggested format over UDP has been created */ -/* and implemented by this dissector, using the definitions */ -/* below. */ -/* */ -/* A heuristic dissector (enabled by a preference) will */ -/* recognise a signature at the beginning of these frames. */ -/*****************************************************************/ - - -/* Signature. Rather than try to define a port for this, or make the - port number a preference, frames will start with this string (with no - terminating NULL */ -#define MAC_NR_START_STRING "mac-nr" - -/* Fixed fields. This is followed by the following 3 mandatory fields: - - radioType (1 byte) - - direction (1 byte) - - rntiType (1 byte) - (where the allowed values are defined above */ - -/* Optional fields. Attaching this info to frames will allow you - to show you display/filter/plot/add-custom-columns on these fields, so should - be added if available. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag) */ - -#define MAC_NR_RNTI_TAG 0x02 -/* 2 bytes, network order */ - -#define MAC_NR_UEID_TAG 0x03 -/* 2 bytes, network order */ - -#define MAC_NR_FRAME_SUBFRAME_TAG 0x04 -/* 2 bytes, deprecated, do not use it */ - -#define MAC_NR_PHR_TYPE2_OTHERCELL_TAG 0x05 -/* 1 byte, TRUE/FALSE */ - -#define MAC_NR_HARQID 0x06 -/* 1 byte */ - -#define MAC_NR_FRAME_SLOT_TAG 0x07 -/* 4 bytes, network order, SFN is stored in the 2 first bytes and slot number in the 2 last bytes */ - -/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU - continues until the end of the frame) */ -#define MAC_NR_PAYLOAD_TAG 0x01 - - -/* Type to store parameters for configuring LCID->RLC channel settings for DRB */ -/* Some are optional, and may not be seen (e.g. on reestablishment) */ -typedef struct nr_drb_mac_rlc_mapping_t -{ - gboolean active; - guint16 ueid; /* Mandatory */ - guint8 drbid; /* Mandatory */ - - gboolean lcid_present; - guint8 lcid; /* Part of LogicalChannelConfig - optional */ - gboolean rlcMode_present; - guint8 rlcMode; /* Part of RLC config - optional */ - - guint8 tempDirection; /* So know direction of next SN length... */ - - gboolean rlcUlSnLength_present; - guint8 rlcUlSnLength; /* Part of RLC config - optional */ - gboolean rlcDlSnLength_present; - guint8 rlcDlSnLength; /* Part of RLC config - optional */ -} nr_drb_mac_rlc_mapping_t; - - - -/* - * Editor modelines - https://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/openair2/UTIL/OPT/packet-pdcp-lte.h b/openair2/UTIL/OPT/packet-pdcp-lte.h deleted file mode 100644 index 19a371011b..0000000000 --- a/openair2/UTIL/OPT/packet-pdcp-lte.h +++ /dev/null @@ -1,172 +0,0 @@ -/* packet-pdcp-lte.h - * - * Martin Mathieson - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - - - -/* Direction */ -#define DIRECTION_UPLINK 0 -#define DIRECTION_DOWNLINK 1 - -enum pdcp_plane -{ - SIGNALING_PLANE = 1, - USER_PLANE = 2 -}; - -typedef enum LogicalChannelType -{ - Channel_DCCH=1, - Channel_BCCH=2, - Channel_CCCH=3, - Channel_PCCH=4, - Channel_DCCH_NB=5, - Channel_BCCH_NB=6, - Channel_CCCH_NB=7, - Channel_PCCH_NB=8 -} LogicalChannelType; - -typedef enum -{ - BCH_TRANSPORT=1, - DLSCH_TRANSPORT=2 -} BCCHTransportType; - -#define PDCP_SN_LENGTH_5_BITS 5 -#define PDCP_SN_LENGTH_7_BITS 7 -#define PDCP_SN_LENGTH_12_BITS 12 -#define PDCP_SN_LENGTH_15_BITS 15 -#define PDCP_SN_LENGTH_18_BITS 18 - -enum lte_security_integrity_algorithm_e { eia0, eia1, eia2, eia3 }; -enum lte_security_ciphering_algorithm_e { eea0, eea1, eea2, eea3 }; - -typedef struct pdcp_lte_security_info_t -{ - guint32 configuration_frame; - gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */ - enum lte_security_integrity_algorithm_e integrity; - enum lte_security_ciphering_algorithm_e ciphering; - - /* Store previous settings so can revert if get SecurityModeFailure */ - guint32 previous_configuration_frame; - enum lte_security_integrity_algorithm_e previous_integrity; - enum lte_security_ciphering_algorithm_e previous_ciphering; -} pdcp_lte_security_info_t; - - -/***********************************************************************/ -/* UDP framing format */ -/* ----------------------- */ -/* Several people have asked about dissecting PDCP by framing */ -/* PDUs over IP. A suggested format over UDP has been defined */ -/* and implemented by this dissector, using the definitions */ -/* below. A link to an example program showing you how to encode */ -/* these headers and send LTE PDCP PDUs on a UDP socket is */ -/* provided at https://gitlab.com/wireshark/wireshark/-/wikis/PDCP-LTE */ -/* */ -/* A heuristic dissecter (enabled by a preference) will */ -/* recognise a signature at the beginning of these frames. */ -/* Until someone is using this format, suggestions for changes */ -/* are welcome. */ -/***********************************************************************/ - - -/* Signature. Rather than try to define a port for this, or make the - port number a preference, frames will start with this string (with no - terminating NULL */ -#define PDCP_LTE_START_STRING "pdcp-lte" - -/* Fixed fields. This is followed by the following 3 mandatory fields: - - no_header_pdu (1 byte) - - plane (1 byte) - - rohc_compression ( byte) - (where the allowed values are defined above) */ - -/* Conditional field. This field is mandatory in case of User Plane PDCP PDU. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag). The allowed values are defined above. */ - -#define PDCP_LTE_SEQNUM_LENGTH_TAG 0x02 -/* 1 byte */ - -/* Optional fields. Attaching this info to frames will allow you - to show you display/filter/plot/add-custom-columns on these fields, so should - be added if available. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag) */ - -#define PDCP_LTE_DIRECTION_TAG 0x03 -/* 1 byte */ - -#define PDCP_LTE_LOG_CHAN_TYPE_TAG 0x04 -/* 1 byte */ - -#define PDCP_LTE_BCCH_TRANSPORT_TYPE_TAG 0x05 -/* 1 byte */ - -#define PDCP_LTE_ROHC_IP_VERSION_TAG 0x06 -/* 2 bytes, network order */ - -#define PDCP_LTE_ROHC_CID_INC_INFO_TAG 0x07 -/* 1 byte */ - -#define PDCP_LTE_ROHC_LARGE_CID_PRES_TAG 0x08 -/* 1 byte */ - -#define PDCP_LTE_ROHC_MODE_TAG 0x09 -/* 1 byte */ - -#define PDCP_LTE_ROHC_RND_TAG 0x0A -/* 1 byte */ - -#define PDCP_LTE_ROHC_UDP_CHECKSUM_PRES_TAG 0x0B -/* 1 byte */ - -#define PDCP_LTE_ROHC_PROFILE_TAG 0x0C -/* 2 bytes, network order */ - -#define PDCP_LTE_CHANNEL_ID_TAG 0x0D -/* 2 bytes, network order */ - -#define PDCP_LTE_UEID_TAG 0x0E -/* 2 bytes, network order */ - -/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU - continues until the end of the frame) */ -#define PDCP_LTE_PAYLOAD_TAG 0x01 - - - -/* Called by RRC, or other configuration protocols */ - -/* Function to configure ciphering & integrity algorithms */ -void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_lte_security_info_t *security_info); - -/* Function to indicate securityModeCommand did not complete */ -void set_pdcp_lte_security_algorithms_failed(guint16 ueid); - - -/* Called by external dissectors */ -void set_pdcp_lte_rrc_ciphering_key(guint16 ueid, const char *key); -void set_pdcp_lte_rrc_integrity_key(guint16 ueid, const char *key); -void set_pdcp_lte_up_ciphering_key(guint16 ueid, const char *key); - -/* - * Editor modelines - https://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/openair2/UTIL/OPT/packet-pdcp-nr.h b/openair2/UTIL/OPT/packet-pdcp-nr.h deleted file mode 100644 index 79f784c1c3..0000000000 --- a/openair2/UTIL/OPT/packet-pdcp-nr.h +++ /dev/null @@ -1,168 +0,0 @@ -/* packet-pdcp-nr.h - * - * Martin Mathieson - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - - -/* Direction */ -#define PDCP_NR_DIRECTION_UPLINK 0 -#define PDCP_NR_DIRECTION_DOWNLINK 1 - -enum pdcp_nr_plane -{ - NR_SIGNALING_PLANE = 1, - NR_USER_PLANE = 2 -}; - -typedef enum NRBearerType -{ - Bearer_DCCH=1, - Bearer_BCCH_BCH=2, - Bearer_BCCH_DL_SCH=3, - Bearer_CCCH=4, - Bearer_PCCH=5, -} NRBearerType; - - -#define PDCP_NR_SN_LENGTH_12_BITS 12 -#define PDCP_NR_SN_LENGTH_18_BITS 18 - -#define PDCP_NR_UL_SDAP_HEADER_PRESENT 0x01 -#define PDCP_NR_DL_SDAP_HEADER_PRESENT 0x02 - -enum nr_security_integrity_algorithm_e { nia0, nia1, nia2, nia3 }; -enum nr_security_ciphering_algorithm_e { nea0, nea1, nea2, nea3, nea_disabled=999}; - -typedef struct pdcp_nr_security_info_t -{ - guint32 configuration_frame; - gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */ - enum nr_security_integrity_algorithm_e integrity; - enum nr_security_ciphering_algorithm_e ciphering; - - /* Store previous settings so can revert if get SecurityModeFailure */ - guint32 previous_configuration_frame; - enum nr_security_integrity_algorithm_e previous_integrity; - enum nr_security_ciphering_algorithm_e previous_ciphering; -} pdcp_nr_security_info_t; - - -/*****************************************************************/ -/* UDP framing format */ -/* ----------------------- */ -/* Several people have asked about dissecting PDCP by framing */ -/* PDUs over IP. A suggested format over UDP has been defined */ -/* and implemented by this dissector, using the definitions */ -/* below. */ -/* */ -/* A heuristic dissector (enabled by a preference) will */ -/* recognise a signature at the beginning of these frames. */ -/* Until someone is using this format, suggestions for changes */ -/* are welcome. */ -/*****************************************************************/ - - -/* Signature. Rather than try to define a port for this, or make the - port number a preference, frames will start with this string (with no - terminating NULL */ -#define PDCP_NR_START_STRING "pdcp-nr" - -/* Fixed fields: - - plane (1 byte) */ - -/* Conditional field. This field is mandatory in case of User Plane PDCP PDU. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag). The allowed values are defined above. */ - -#define PDCP_NR_SEQNUM_LENGTH_TAG 0x02 -/* 1 byte */ - -/* Optional fields. Attaching this info should be added if available. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag) */ - -#define PDCP_NR_DIRECTION_TAG 0x03 -/* 1 byte */ - -#define PDCP_NR_BEARER_TYPE_TAG 0x04 -/* 1 byte */ - -#define PDCP_NR_BEARER_ID_TAG 0x05 -/* 1 byte */ - -#define PDCP_NR_UEID_TAG 0x06 -/* 2 bytes, network order */ - -#define PDCP_NR_ROHC_COMPRESSION_TAG 0x07 -/* 0 byte */ - -/* N.B. The following ROHC values only have significance if rohc_compression - is in use for the current channel */ - -#define PDCP_NR_ROHC_IP_VERSION_TAG 0x08 -/* 1 byte */ - -#define PDCP_NR_ROHC_CID_INC_INFO_TAG 0x09 -/* 0 byte */ - -#define PDCP_NR_ROHC_LARGE_CID_PRES_TAG 0x0A -/* 0 byte */ - -#define PDCP_NR_ROHC_MODE_TAG 0x0B -/* 1 byte */ - -#define PDCP_NR_ROHC_RND_TAG 0x0C -/* 0 byte */ - -#define PDCP_NR_ROHC_UDP_CHECKSUM_PRES_TAG 0x0D -/* 0 byte */ - -#define PDCP_NR_ROHC_PROFILE_TAG 0x0E -/* 2 bytes, network order */ - -#define PDCP_NR_MACI_PRES_TAG 0x0F -/* 0 byte */ - -#define PDCP_NR_SDAP_HEADER_TAG 0x10 -/* 1 byte, bitmask with PDCP_NR_UL_SDAP_HEADER_PRESENT and/or PDCP_NR_DL_SDAP_HEADER_PRESENT */ - -#define PDCP_NR_CIPHER_DISABLED_TAG 0x11 -/* 0 byte */ - -/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU - continues until the end of the frame) */ -#define PDCP_NR_PAYLOAD_TAG 0x01 - - -/* Called by RRC, or other configuration protocols */ - -/* Function to configure ciphering & integrity algorithms */ -void set_pdcp_nr_security_algorithms(guint16 ueid, pdcp_nr_security_info_t *security_info); - -/* Function to indicate securityModeCommand did not complete */ -void set_pdcp_nr_security_algorithms_failed(guint16 ueid); - - -/* Called by external dissectors */ -void set_pdcp_nr_rrc_ciphering_key(guint16 ueid, const char *key); -void set_pdcp_nr_rrc_integrity_key(guint16 ueid, const char *key); -void set_pdcp_nr_up_ciphering_key(guint16 ueid, const char *key); -void set_pdcp_nr_up_integrity_key(guint16 ueid, const char *key); - -/* - * Editor modelines - https://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/openair2/UTIL/OPT/packet-rlc-lte.h b/openair2/UTIL/OPT/packet-rlc-lte.h deleted file mode 100644 index e5b03d5f8e..0000000000 --- a/openair2/UTIL/OPT/packet-rlc-lte.h +++ /dev/null @@ -1,151 +0,0 @@ -/* packet-rlc-lte.h - * - * Martin Mathieson - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef PACKET_RLC_LTE_H -#define PACKET_RLC_LTE_H - -/* rlcMode */ -#define RLC_TM_MODE 1 -#define RLC_UM_MODE 2 -#define RLC_AM_MODE 4 -#define RLC_PREDEF 8 - -/* direction */ -#define DIRECTION_UPLINK 0 -#define DIRECTION_DOWNLINK 1 - -/* priority ? */ - -/* channelType */ -#define CHANNEL_TYPE_CCCH 1 -#define CHANNEL_TYPE_BCCH_BCH 2 -#define CHANNEL_TYPE_PCCH 3 -#define CHANNEL_TYPE_SRB 4 -#define CHANNEL_TYPE_DRB 5 -#define CHANNEL_TYPE_BCCH_DL_SCH 6 -#define CHANNEL_TYPE_MCCH 7 -#define CHANNEL_TYPE_MTCH 8 - -/* sequenceNumberLength */ -#define UM_SN_LENGTH_5_BITS 5 -#define UM_SN_LENGTH_10_BITS 10 -#define AM_SN_LENGTH_10_BITS 10 -#define AM_SN_LENGTH_16_BITS 16 - - -typedef enum rlc_lte_nb_mode { - rlc_no_nb_mode = 0, - rlc_nb_mode = 1 -} rlc_lte_nb_mode; - - -/* Info attached to each LTE RLC frame */ -typedef struct rlc_lte_info -{ - guint8 rlcMode; - guint8 direction; - guint8 priority; - guint8 sequenceNumberLength; - guint16 ueid; - guint16 channelType; - guint16 channelId; /* for SRB: 1=SRB1, 2=SRB2, 3=SRB1bis; for DRB: DRB ID */ - guint16 pduLength; - gboolean extendedLiField; - rlc_lte_nb_mode nbMode; -} rlc_lte_info; - - -typedef struct rlc_lte_tap_info { - /* Info from context */ - guint8 rlcMode; - guint8 direction; - guint8 priority; - guint16 ueid; - guint16 channelType; - guint16 channelId; - guint16 pduLength; - guint8 sequenceNumberLength; - - nstime_t rlc_lte_time; - guint8 loggedInMACFrame; - guint16 sequenceNumber; - guint8 isResegmented; - guint8 isControlPDU; - guint16 ACKNo; - #define MAX_NACKs 128 - guint16 noOfNACKs; - guint16 NACKs[MAX_NACKs]; - - guint16 missingSNs; -} rlc_lte_tap_info; - - -/* Signature. Rather than try to define a port for this, or make the - port number a preference, frames will start with this string (with no - terminating NULL */ -#define RLC_LTE_START_STRING "rlc-lte" - -/* Fixed field. This is followed by the following 1 mandatory field: - - rlcMode (1 byte) - (where the allowed values are defined above */ - -/* Conditional field. This field is mandatory in case of RLC Unacknowledged mode. - In case of RLC Acknowledged mode, the field is optional (assume 10 bits by default). - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag). The allowed values are defined above. */ - -#define RLC_LTE_SN_LENGTH_TAG 0x02 -/* 1 byte */ - -/* Optional fields. Attaching this info to frames will allow you - to show you display/filter/plot/add-custom-columns on these fields, so should - be added if available. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag) */ - -#define RLC_LTE_DIRECTION_TAG 0x03 -/* 1 byte */ - -#define RLC_LTE_PRIORITY_TAG 0x04 -/* 1 byte */ - -#define RLC_LTE_UEID_TAG 0x05 -/* 2 bytes, network order */ - -#define RLC_LTE_CHANNEL_TYPE_TAG 0x06 -/* 2 bytes, network order */ - -#define RLC_LTE_CHANNEL_ID_TAG 0x07 -/* 2 bytes, network order */ - -#define RLC_LTE_EXT_LI_FIELD_TAG 0x08 -/* 0 byte, tag presence indicates that AM DRB PDU is using an extended LI field of 15 bits */ - -#define RLC_LTE_NB_MODE_TAG 0x09 -/* 1 byte containing rlc_lte_nb_mode enum value */ - -/* RLC PDU. Following this tag comes the actual RLC PDU (there is no length, the PDU - continues until the end of the frame) */ -#define RLC_LTE_PAYLOAD_TAG 0x01 - -#endif - -/* - * Editor modelines - https://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/openair2/UTIL/OPT/packet-rlc-nr.h b/openair2/UTIL/OPT/packet-rlc-nr.h deleted file mode 100644 index 290eba1898..0000000000 --- a/openair2/UTIL/OPT/packet-rlc-nr.h +++ /dev/null @@ -1,136 +0,0 @@ -/* packet-rlc-nr.h - * - * Pascal Quantin - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#ifndef PACKET_RLC_NR_H -#define PACKET_RLC_NR_H - -/* rlcMode */ -#define RLC_TM_MODE 1 -#define RLC_UM_MODE 2 -#define RLC_AM_MODE 4 - -/* direction */ -#define DIRECTION_UPLINK 0 -#define DIRECTION_DOWNLINK 1 - -/* bearerType */ -#define BEARER_TYPE_CCCH 1 -#define BEARER_TYPE_BCCH_BCH 2 -#define BEARER_TYPE_PCCH 3 -#define BEARER_TYPE_SRB 4 -#define BEARER_TYPE_DRB 5 -#define BEARER_TYPE_BCCH_DL_SCH 6 - -/* sequenceNumberLength */ -#define TM_SN_LENGTH_0_BITS 0 -#define UM_SN_LENGTH_6_BITS 6 -#define UM_SN_LENGTH_12_BITS 12 -#define AM_SN_LENGTH_12_BITS 12 -#define AM_SN_LENGTH_18_BITS 18 - -/* Info attached to each NR RLC frame */ -typedef struct rlc_nr_info -{ - guint8 rlcMode; - guint8 direction; - guint8 sequenceNumberLength; - guint8 bearerType; - guint8 bearerId; - guint16 ueid; - guint16 pduLength; -} rlc_nr_info; - -typedef struct nr_drb_rlc_pdcp_mapping_t -{ - gboolean active; - guint16 ueid; /* Mandatory */ - guint8 drbid; /* Mandatory */ - - gboolean pdcpUlSnLength_present; - guint8 pdcpUlSnLength; /* Part of PDCP config - optional */ - gboolean pdcpDlSnLength_present; - guint8 pdcpDlSnLength; /* Part of PDCP config - optional */ - gboolean pdcpUlSdap; - gboolean pdcpDlSdap; - gboolean pdcpIntegrityProtection; - gboolean pdcpCipheringDisabled; - -} nr_drb_rlc_pdcp_mapping_t; - -/* TODO: could probably merge this struct with above */ -typedef struct pdcp_ue_parameters { - guint32 id; - guint8 pdcp_sn_bits_ul; - guint8 pdcp_sn_bits_dl; - gboolean pdcp_sdap_ul; - gboolean pdcp_sdap_dl; - gboolean pdcp_integrity; - gboolean pdcp_ciphering_disabled; -} pdcp_bearer_parameters; - -/*****************************************************************/ -/* UDP framing format */ -/* ----------------------- */ -/* Several people have asked about dissecting RLC by framing */ -/* PDUs over IP. A suggested format over UDP has been defined */ -/* and implemented by this dissector, using the definitions */ -/* below. */ -/* */ -/* A heuristic dissector (enabled by a preference) will */ -/* recognise a signature at the beginning of these frames. */ -/*****************************************************************/ - - -/* Signature. Rather than try to define a port for this, or make the - port number a preference, frames will start with this string (with no - terminating NULL */ -#define RLC_NR_START_STRING "rlc-nr" - -/* Fixed field. This is followed by the following 2 mandatory field: - - rlcMode (1 byte) - - sequenceNumberLength (1 byte) - (where the allowed values are defined above) */ - -/* Optional fields. Attaching this info to frames will allow you - to show you display/filter/plot/add-custom-columns on these fields, so should - be added if available. - The format is to have the tag, followed by the value (there is no length field, - it's implicit from the tag) */ - -#define RLC_NR_DIRECTION_TAG 0x02 -/* 1 byte */ - -#define RLC_NR_UEID_TAG 0x03 -/* 2 bytes, network order */ - -#define RLC_NR_BEARER_TYPE_TAG 0x04 -/* 1 byte */ - -#define RLC_NR_BEARER_ID_TAG 0x05 -/* 1 byte */ - -/* RLC PDU. Following this tag comes the actual RLC PDU (there is no length, the PDU - continues until the end of the frame) */ -#define RLC_NR_PAYLOAD_TAG 0x01 - -#endif - -/* - * Editor modelines - https://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/openair2/UTIL/OPT/probe.c b/openair2/UTIL/OPT/probe.c index 2966c4672c..e64f7724c6 100644 --- a/openair2/UTIL/OPT/probe.c +++ b/openair2/UTIL/OPT/probe.c @@ -441,6 +441,10 @@ static void SendFrameNR(guint8 radioType, guint8 direction, guint8 rntiType, tmp16 = htons(subframe); // frame counter : this will give an expert info as wireshark expects SF and not F memcpy(frameBuffer+frameOffset, &tmp16, 2); frameOffset += 2; + if (direction == 0 ) { //ulink + frameBuffer[frameOffset++] = MAC_NR_PHR_TYPE2_OTHERCELL_TAG; + frameBuffer[frameOffset++] = 0; + } /***************************************/ /* Now write the MAC PDU */ diff --git a/openair2/UTIL/OPT/wireshark_headers.h b/openair2/UTIL/OPT/wireshark_headers.h new file mode 100644 index 0000000000..27d8753ffe --- /dev/null +++ b/openair2/UTIL/OPT/wireshark_headers.h @@ -0,0 +1,895 @@ +/* packet-mac-lte.h + * + * Martin Mathieson + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * Copyright (C) 2009 Martin Mathieson. All rights reserved. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + + /* + this is wireshark, commit: commit eda834b6e29c36e05a63a6056afa98390ff79357 + Date: Wed Aug 22 14:36:20 2018 +0200 + modified to be used in OpenAir to create the LTE MAC/RLC encapsulated in UDP as per Wireshark feature + */ + +#ifndef __UTIL_OPT_PACKET_MAC_LTE__H__ +#define __UTIL_OPT_PACKET_MAC_LTE__H__ + +/** data structure to hold time values with nanosecond resolution*/ +typedef struct { + time_t secs; + int nsecs; +} nstime_t; + + +/* radioType */ +#define FDD_RADIO 1 +#define TDD_RADIO 2 + +/* Direction */ +#define DIRECTION_UPLINK 0 +#define DIRECTION_DOWNLINK 1 + +/* rntiType */ +#define WS_NO_RNTI 0 +#define WS_P_RNTI 1 +#define WS_RA_RNTI 2 +#define WS_C_RNTI 3 +#define WS_SI_RNTI 4 +#define WS_SPS_RNTI 5 +#define WS_M_RNTI 6 +#define WS_SL_BCH_RNTI 7 +#define WS_SL_RNTI 8 +#define WS_SC_RNTI 9 +#define WS_G_RNTI 10 + +#define WS_CS_RNTI 5 + +typedef enum mac_lte_oob_event { + ltemac_send_preamble, + ltemac_send_sr, + ltemac_sr_failure +} mac_lte_oob_event; + +typedef enum mac_lte_dl_retx { + dl_retx_no, + dl_retx_yes, + dl_retx_unknown +} mac_lte_dl_retx; + +typedef enum mac_lte_crc_status { + crc_fail = 0, + crc_success = 1, + crc_high_code_rate = 2, + crc_pdsch_lost = 3, + crc_duplicate_nonzero_rv = 4, + crc_false_dci = 5 +} mac_lte_crc_status; + +/* N.B. for SCellIndex-r13 extends to 31 */ +typedef enum mac_lte_carrier_id { + carrier_id_primary, + carrier_id_secondary_1, + carrier_id_secondary_2, + carrier_id_secondary_3, + carrier_id_secondary_4, + carrier_id_secondary_5, + carrier_id_secondary_6, + carrier_id_secondary_7 +} mac_lte_carrier_id; + +typedef enum mac_lte_ce_mode { + no_ce_mode = 0, + ce_mode_a = 1, + ce_mode_b = 2 +} mac_lte_ce_mode; + +typedef enum mac_lte_nb_mode { + no_nb_mode = 0, + nb_mode = 1 +} mac_lte_nb_mode; + +/* Context info attached to each LTE MAC frame */ +typedef struct mac_lte_info +{ + /* Needed for decode */ + guint8 radioType; + guint8 direction; + guint8 rntiType; + + /* Extra info to display */ + guint16 rnti; + guint16 ueid; + + /* Timing info */ + guint16 sysframeNumber; + guint16 subframeNumber; + gboolean sfnSfInfoPresent; + + /* Optional field. More interesting for TDD (FDD is always -4 subframeNumber) */ + gboolean subframeNumberOfGrantPresent; + guint16 subframeNumberOfGrant; + + /* Flag set only if doing PHY-level data test - i.e. there may not be a + well-formed MAC PDU so just show as raw data */ + gboolean isPredefinedData; + + /* Length of DL PDU or UL grant size in bytes */ + guint16 length; + + /* 0=newTx, 1=first-retx, etc */ + guint8 reTxCount; + guint8 isPHICHNACK; /* FALSE=PDCCH retx grant, TRUE=PHICH NACK */ + + /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set */ + gboolean isExtendedBSRSizes; + + /* UL only. Indicates if the R10 simultaneousPUCCH-PUSCH parameter is set for PCell */ + gboolean isSimultPUCCHPUSCHPCell; + + /* UL only. Indicates if the R10 extendedBSR-Sizes parameter is set for PSCell */ + gboolean isSimultPUCCHPUSCHPSCell; + + /* Status of CRC check. For UE it is DL only. For eNodeB it is UL + only. For an analyzer, it is present for both DL and UL. */ + gboolean crcStatusValid; + mac_lte_crc_status crcStatus; + + /* Carrier ID */ + mac_lte_carrier_id carrierId; + + /* DL only. Is this known to be a retransmission? */ + mac_lte_dl_retx dl_retx; + + /* DL only. CE mode to be used for RAR decoding */ + mac_lte_ce_mode ceMode; + + /* DL and UL. NB-IoT mode of the UE */ + mac_lte_nb_mode nbMode; + + /* UL only, for now used for CE mode A RAR decoding */ + guint8 nUlRb; + + /* More Physical layer info (see direction above for which side of union to use) */ + union { + struct mac_lte_ul_phy_info + { + guint8 present; /* Remaining UL fields are present and should be displayed */ + guint8 modulation_type; + guint8 tbs_index; + guint8 resource_block_length; + guint8 resource_block_start; + guint8 harq_id; + gboolean ndi; + } ul_info; + struct mac_lte_dl_phy_info + { + guint8 present; /* Remaining DL fields are present and should be displayed */ + guint8 dci_format; + guint8 resource_allocation_type; + guint8 aggregation_level; + guint8 mcs_index; + guint8 redundancy_version_index; + guint8 resource_block_length; + guint8 harq_id; + gboolean ndi; + guint8 transport_block; /* 0..1 */ + } dl_info; + } detailed_phy_info; + + /* Relating to out-of-band events */ + /* N.B. dissector will only look to these fields if length is 0... */ + mac_lte_oob_event oob_event; + guint8 rapid; + guint8 rach_attempt_number; + #define MAX_SRs 20 + guint16 number_of_srs; + guint16 oob_ueid[MAX_SRs]; + guint16 oob_rnti[MAX_SRs]; +} mac_lte_info; + + /* 0 to 10 and 32 to 38 */ +#define MAC_LTE_DATA_LCID_COUNT_MAX 18 +#define MAC_LTE_START_STRING "mac-lte" + +/* Fixed fields. This is followed by the following 3 mandatory fields: + - radioType (1 byte) + - direction (1 byte) + - rntiType (1 byte) + (where the allowed values are defined above */ + +/* Optional fields. Attaching this info to frames will allow you + to show you display/filter/plot/add-custom-columns on these fields, so should + be added if available. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag) */ + +#define MAC_LTE_RNTI_TAG 0x02 +/* 2 bytes, network order */ + +#define MAC_LTE_UEID_TAG 0x03 +/* 2 bytes, network order */ + +#define MAC_LTE_FRAME_SUBFRAME_TAG 0x04 +/* 2 bytes, network order, SFN is stored in 12 MSB and SF in 4 LSB */ + +#define MAC_LTE_PREDEFINED_DATA_TAG 0x05 +/* 1 byte */ + +#define MAC_LTE_RETX_TAG 0x06 +/* 1 byte */ + +#define MAC_LTE_CRC_STATUS_TAG 0x07 +/* 1 byte */ + +#define MAC_LTE_EXT_BSR_SIZES_TAG 0x08 +/* 0 byte */ + +#define MAC_LTE_SEND_PREAMBLE_TAG 0x09 +/* 2 bytes, RAPID value (1 byte) followed by RACH attempt number (1 byte) */ + +#define MAC_LTE_CARRIER_ID_TAG 0x0A +/* 1 byte */ + +#define MAC_LTE_PHY_TAG 0x0B +/* variable length, length (1 byte) then depending on direction + in UL: modulation type (1 byte), TBS index (1 byte), RB length (1 byte), + RB start (1 byte), HARQ id (1 byte), NDI (1 byte) + in DL: DCI format (1 byte), resource allocation type (1 byte), aggregation level (1 byte), + MCS index (1 byte), redundancy version (1 byte), resource block length (1 byte), + HARQ id (1 byte), NDI (1 byte), TB (1 byte), DL reTx (1 byte) */ + +#define MAC_LTE_SIMULT_PUCCH_PUSCH_PCELL_TAG 0x0C +/* 0 byte */ + +#define MAC_LTE_SIMULT_PUCCH_PUSCH_PSCELL_TAG 0x0D +/* 0 byte */ + +#define MAC_LTE_CE_MODE_TAG 0x0E +/* 1 byte containing mac_lte_ce_mode enum value */ + +#define MAC_LTE_NB_MODE_TAG 0x0F +/* 1 byte containing mac_lte_nb_mode enum value */ + +#define MAC_LTE_N_UL_RB_TAG 0x10 +/* 1 byte containing the number of UL resource blocks: 6, 15, 25, 50, 75 or 100 */ + +#define MAC_LTE_SR_TAG 0x11 +/* 2 bytes for the number of items, followed by that number of ueid, rnti (2 bytes each) */ + + +/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU + continues until the end of the frame) */ +#define MAC_LTE_PAYLOAD_TAG 0x01 + +/* rlcMode */ +#define RLC_TM_MODE 1 +#define RLC_UM_MODE 2 +#define RLC_AM_MODE 4 +#define RLC_PREDEF 8 + +/* priority ? */ + +/* channelType */ +#define CHANNEL_TYPE_CCCH 1 +#define CHANNEL_TYPE_BCCH_BCH 2 +#define CHANNEL_TYPE_PCCH 3 +#define CHANNEL_TYPE_SRB 4 +#define CHANNEL_TYPE_DRB 5 +#define CHANNEL_TYPE_BCCH_DL_SCH 6 +#define CHANNEL_TYPE_MCCH 7 +#define CHANNEL_TYPE_MTCH 8 + +/* sequenceNumberLength */ +#define UM_SN_LENGTH_5_BITS 5 +#define UM_SN_LENGTH_10_BITS 10 +#define AM_SN_LENGTH_10_BITS 10 +#define AM_SN_LENGTH_16_BITS 16 + + +typedef enum rlc_lte_nb_mode { + rlc_no_nb_mode = 0, + rlc_nb_mode = 1 +} rlc_lte_nb_mode; + + +/* Info attached to each LTE RLC frame */ +typedef struct rlc_lte_info +{ + guint8 rlcMode; + guint8 direction; + guint8 priority; + guint8 sequenceNumberLength; + guint16 ueid; + guint16 channelType; + guint16 channelId; /* for SRB: 1=SRB1, 2=SRB2, 3=SRB1bis; for DRB: DRB ID */ + guint16 pduLength; + gboolean extendedLiField; + rlc_lte_nb_mode nbMode; +} rlc_lte_info; + + +typedef struct rlc_lte_tap_info { + /* Info from context */ + guint8 rlcMode; + guint8 direction; + guint8 priority; + guint16 ueid; + guint16 channelType; + guint16 channelId; + guint16 pduLength; + guint8 sequenceNumberLength; + + nstime_t rlc_lte_time; + guint8 loggedInMACFrame; + guint16 sequenceNumber; + guint8 isResegmented; + guint8 isControlPDU; + guint16 ACKNo; + #define MAX_NACKs 128 + guint16 noOfNACKs; + guint16 NACKs[MAX_NACKs]; + + guint16 missingSNs; +} rlc_lte_tap_info; + + +/* Signature. Rather than try to define a port for this, or make the + port number a preference, frames will start with this string (with no + terminating NULL */ +#define RLC_LTE_START_STRING "rlc-lte" + +/* Fixed field. This is followed by the following 1 mandatory field: + - rlcMode (1 byte) + (where the allowed values are defined above */ + +/* Conditional field. This field is mandatory in case of RLC Unacknowledged mode. + In case of RLC Acknowledged mode, the field is optional (assume 10 bits by default). + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag). The allowed values are defined above. */ + +#define RLC_LTE_SN_LENGTH_TAG 0x02 +/* 1 byte */ + +/* Optional fields. Attaching this info to frames will allow you + to show you display/filter/plot/add-custom-columns on these fields, so should + be added if available. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag) */ + +#define RLC_LTE_DIRECTION_TAG 0x03 +/* 1 byte */ + +#define RLC_LTE_PRIORITY_TAG 0x04 +/* 1 byte */ + +#define RLC_LTE_UEID_TAG 0x05 +/* 2 bytes, network order */ + +#define RLC_LTE_CHANNEL_TYPE_TAG 0x06 +/* 2 bytes, network order */ + +#define RLC_LTE_CHANNEL_ID_TAG 0x07 +/* 2 bytes, network order */ + +#define RLC_LTE_EXT_LI_FIELD_TAG 0x08 +/* 0 byte, tag presence indicates that AM DRB PDU is using an extended LI field of 15 bits */ + +#define RLC_LTE_NB_MODE_TAG 0x09 +/* 1 byte containing rlc_lte_nb_mode enum value */ + +/* RLC PDU. Following this tag comes the actual RLC PDU (there is no length, the PDU + continues until the end of the frame) */ +#define RLC_LTE_PAYLOAD_TAG 0x01 + +enum pdcp_plane +{ + SIGNALING_PLANE = 1, + USER_PLANE = 2 +}; + +typedef enum LogicalChannelType +{ + Channel_DCCH=1, + Channel_BCCH=2, + Channel_CCCH=3, + Channel_PCCH=4, + Channel_DCCH_NB=5, + Channel_BCCH_NB=6, + Channel_CCCH_NB=7, + Channel_PCCH_NB=8 +} LogicalChannelType; + +typedef enum +{ + BCH_TRANSPORT=1, + DLSCH_TRANSPORT=2 +} BCCHTransportType; + +#define PDCP_SN_LENGTH_5_BITS 5 +#define PDCP_SN_LENGTH_7_BITS 7 +#define PDCP_SN_LENGTH_12_BITS 12 +#define PDCP_SN_LENGTH_15_BITS 15 +#define PDCP_SN_LENGTH_18_BITS 18 + +enum lte_security_integrity_algorithm_e { eia0, eia1, eia2, eia3 }; +enum lte_security_ciphering_algorithm_e { eea0, eea1, eea2, eea3 }; + +typedef struct pdcp_lte_security_info_t +{ + guint32 configuration_frame; + gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */ + enum lte_security_integrity_algorithm_e integrity; + enum lte_security_ciphering_algorithm_e ciphering; + + /* Store previous settings so can revert if get SecurityModeFailure */ + guint32 previous_configuration_frame; + enum lte_security_integrity_algorithm_e previous_integrity; + enum lte_security_ciphering_algorithm_e previous_ciphering; +} pdcp_lte_security_info_t; + + +/***********************************************************************/ +/* UDP framing format */ +/* ----------------------- */ +/* Several people have asked about dissecting PDCP by framing */ +/* PDUs over IP. A suggested format over UDP has been defined */ +/* and implemented by this dissector, using the definitions */ +/* below. A link to an example program showing you how to encode */ +/* these headers and send LTE PDCP PDUs on a UDP socket is */ +/* provided at https://gitlab.com/wireshark/wireshark/-/wikis/PDCP-LTE */ +/* */ +/* A heuristic dissecter (enabled by a preference) will */ +/* recognise a signature at the beginning of these frames. */ +/* Until someone is using this format, suggestions for changes */ +/* are welcome. */ +/***********************************************************************/ + + +/* Signature. Rather than try to define a port for this, or make the + port number a preference, frames will start with this string (with no + terminating NULL */ +#define PDCP_LTE_START_STRING "pdcp-lte" + +/* Fixed fields. This is followed by the following 3 mandatory fields: + - no_header_pdu (1 byte) + - plane (1 byte) + - rohc_compression ( byte) + (where the allowed values are defined above) */ + +/* Conditional field. This field is mandatory in case of User Plane PDCP PDU. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag). The allowed values are defined above. */ + +#define PDCP_LTE_SEQNUM_LENGTH_TAG 0x02 +/* 1 byte */ + +/* Optional fields. Attaching this info to frames will allow you + to show you display/filter/plot/add-custom-columns on these fields, so should + be added if available. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag) */ + +#define PDCP_LTE_DIRECTION_TAG 0x03 +/* 1 byte */ + +#define PDCP_LTE_LOG_CHAN_TYPE_TAG 0x04 +/* 1 byte */ + +#define PDCP_LTE_BCCH_TRANSPORT_TYPE_TAG 0x05 +/* 1 byte */ + +#define PDCP_LTE_ROHC_IP_VERSION_TAG 0x06 +/* 2 bytes, network order */ + +#define PDCP_LTE_ROHC_CID_INC_INFO_TAG 0x07 +/* 1 byte */ + +#define PDCP_LTE_ROHC_LARGE_CID_PRES_TAG 0x08 +/* 1 byte */ + +#define PDCP_LTE_ROHC_MODE_TAG 0x09 +/* 1 byte */ + +#define PDCP_LTE_ROHC_RND_TAG 0x0A +/* 1 byte */ + +#define PDCP_LTE_ROHC_UDP_CHECKSUM_PRES_TAG 0x0B +/* 1 byte */ + +#define PDCP_LTE_ROHC_PROFILE_TAG 0x0C +/* 2 bytes, network order */ + +#define PDCP_LTE_CHANNEL_ID_TAG 0x0D +/* 2 bytes, network order */ + +#define PDCP_LTE_UEID_TAG 0x0E +/* 2 bytes, network order */ + +/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU + continues until the end of the frame) */ +#define PDCP_LTE_PAYLOAD_TAG 0x01 + + + +/* Called by RRC, or other configuration protocols */ + +/* Function to configure ciphering & integrity algorithms */ +void set_pdcp_lte_security_algorithms(guint16 ueid, pdcp_lte_security_info_t *security_info); + +/* Function to indicate securityModeCommand did not complete */ +void set_pdcp_lte_security_algorithms_failed(guint16 ueid); + + +/* Called by external dissectors */ +void set_pdcp_lte_rrc_ciphering_key(guint16 ueid, const char *key); +void set_pdcp_lte_rrc_integrity_key(guint16 ueid, const char *key); +void set_pdcp_lte_up_ciphering_key(guint16 ueid, const char *key); + + + +/* Context info attached to each NR MAC frame */ +typedef struct mac_nr_info +{ + /* Needed for decode */ + guint8 radioType; + guint8 direction; + guint8 rntiType; + + /* Extra info to display */ + guint16 rnti; + guint16 ueid; + guint8 harqid; + + /* Will these be included in the ME PHR report? */ + guint8 phr_type2_othercell; + + /* Timing info */ + gboolean sfnSlotInfoPresent; + guint16 sysframeNumber; + guint16 slotNumber; + + /* Length of DL PDU or UL grant size in bytes */ + guint16 length; + +} mac_nr_info; + + +/*****************************************************************/ +/* UDP framing format */ +/* ----------------------- */ +/* Several people have asked about dissecting MAC by framing */ +/* PDUs over IP. A suggested format over UDP has been created */ +/* and implemented by this dissector, using the definitions */ +/* below. */ +/* */ +/* A heuristic dissector (enabled by a preference) will */ +/* recognise a signature at the beginning of these frames. */ +/*****************************************************************/ + + +/* Signature. Rather than try to define a port for this, or make the + port number a preference, frames will start with this string (with no + terminating NULL */ +#define MAC_NR_START_STRING "mac-nr" + +/* Fixed fields. This is followed by the following 3 mandatory fields: + - radioType (1 byte) + - direction (1 byte) + - rntiType (1 byte) + (where the allowed values are defined above */ + +/* Optional fields. Attaching this info to frames will allow you + to show you display/filter/plot/add-custom-columns on these fields, so should + be added if available. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag) */ + +#define MAC_NR_RNTI_TAG 0x02 +/* 2 bytes, network order */ + +#define MAC_NR_UEID_TAG 0x03 +/* 2 bytes, network order */ + +#define MAC_NR_FRAME_SUBFRAME_TAG 0x04 +/* 2 bytes, deprecated, do not use it */ + +#define MAC_NR_PHR_TYPE2_OTHERCELL_TAG 0x05 +/* 1 byte, TRUE/FALSE */ + +#define MAC_NR_HARQID 0x06 +/* 1 byte */ + +#define MAC_NR_FRAME_SLOT_TAG 0x07 +/* 4 bytes, network order, SFN is stored in the 2 first bytes and slot number in the 2 last bytes */ + +/* MAC PDU. Following this tag comes the actual MAC PDU (there is no length, the PDU + continues until the end of the frame) */ +#define MAC_NR_PAYLOAD_TAG 0x01 + + +/* Type to store parameters for configuring LCID->RLC channel settings for DRB */ +/* Some are optional, and may not be seen (e.g. on reestablishment) */ +typedef struct nr_drb_mac_rlc_mapping_t +{ + gboolean active; + guint16 ueid; /* Mandatory */ + guint8 drbid; /* Mandatory */ + + gboolean lcid_present; + guint8 lcid; /* Part of LogicalChannelConfig - optional */ + gboolean rlcMode_present; + guint8 rlcMode; /* Part of RLC config - optional */ + + guint8 tempDirection; /* So know direction of next SN length... */ + + gboolean rlcUlSnLength_present; + guint8 rlcUlSnLength; /* Part of RLC config - optional */ + gboolean rlcDlSnLength_present; + guint8 rlcDlSnLength; /* Part of RLC config - optional */ +} nr_drb_mac_rlc_mapping_t; + +/* rlcMode */ +#define RLC_TM_MODE 1 +#define RLC_UM_MODE 2 +#define RLC_AM_MODE 4 + +/* bearerType */ +#define BEARER_TYPE_CCCH 1 +#define BEARER_TYPE_BCCH_BCH 2 +#define BEARER_TYPE_PCCH 3 +#define BEARER_TYPE_SRB 4 +#define BEARER_TYPE_DRB 5 +#define BEARER_TYPE_BCCH_DL_SCH 6 + +/* sequenceNumberLength */ +#define TM_SN_LENGTH_0_BITS 0 +#define UM_SN_LENGTH_6_BITS 6 +#define UM_SN_LENGTH_12_BITS 12 +#define AM_SN_LENGTH_12_BITS 12 +#define AM_SN_LENGTH_18_BITS 18 + +/* Info attached to each NR RLC frame */ +typedef struct rlc_nr_info +{ + guint8 rlcMode; + guint8 direction; + guint8 sequenceNumberLength; + guint8 bearerType; + guint8 bearerId; + guint16 ueid; + guint16 pduLength; +} rlc_nr_info; + +typedef struct nr_drb_rlc_pdcp_mapping_t +{ + gboolean active; + guint16 ueid; /* Mandatory */ + guint8 drbid; /* Mandatory */ + + gboolean pdcpUlSnLength_present; + guint8 pdcpUlSnLength; /* Part of PDCP config - optional */ + gboolean pdcpDlSnLength_present; + guint8 pdcpDlSnLength; /* Part of PDCP config - optional */ + gboolean pdcpUlSdap; + gboolean pdcpDlSdap; + gboolean pdcpIntegrityProtection; + gboolean pdcpCipheringDisabled; + +} nr_drb_rlc_pdcp_mapping_t; + +/* TODO: could probably merge this struct with above */ +typedef struct pdcp_ue_parameters { + guint32 id; + guint8 pdcp_sn_bits_ul; + guint8 pdcp_sn_bits_dl; + gboolean pdcp_sdap_ul; + gboolean pdcp_sdap_dl; + gboolean pdcp_integrity; + gboolean pdcp_ciphering_disabled; +} pdcp_bearer_parameters; + +/*****************************************************************/ +/* UDP framing format */ +/* ----------------------- */ +/* Several people have asked about dissecting RLC by framing */ +/* PDUs over IP. A suggested format over UDP has been defined */ +/* and implemented by this dissector, using the definitions */ +/* below. */ +/* */ +/* A heuristic dissector (enabled by a preference) will */ +/* recognise a signature at the beginning of these frames. */ +/*****************************************************************/ + + +/* Signature. Rather than try to define a port for this, or make the + port number a preference, frames will start with this string (with no + terminating NULL */ +#define RLC_NR_START_STRING "rlc-nr" + +/* Fixed field. This is followed by the following 2 mandatory field: + - rlcMode (1 byte) + - sequenceNumberLength (1 byte) + (where the allowed values are defined above) */ + +/* Optional fields. Attaching this info to frames will allow you + to show you display/filter/plot/add-custom-columns on these fields, so should + be added if available. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag) */ + +#define RLC_NR_DIRECTION_TAG 0x02 +/* 1 byte */ + +#define RLC_NR_UEID_TAG 0x03 +/* 2 bytes, network order */ + +#define RLC_NR_BEARER_TYPE_TAG 0x04 +/* 1 byte */ + +#define RLC_NR_BEARER_ID_TAG 0x05 +/* 1 byte */ + +/* RLC PDU. Following this tag comes the actual RLC PDU (there is no length, the PDU + continues until the end of the frame) */ +#define RLC_NR_PAYLOAD_TAG 0x01 + +enum pdcp_nr_plane +{ + NR_SIGNALING_PLANE = 1, + NR_USER_PLANE = 2 +}; + +typedef enum NRBearerType +{ + Bearer_DCCH=1, + Bearer_BCCH_BCH=2, + Bearer_BCCH_DL_SCH=3, + Bearer_CCCH=4, + Bearer_PCCH=5, +} NRBearerType; + + +#define PDCP_NR_SN_LENGTH_12_BITS 12 +#define PDCP_NR_SN_LENGTH_18_BITS 18 + +#define PDCP_NR_UL_SDAP_HEADER_PRESENT 0x01 +#define PDCP_NR_DL_SDAP_HEADER_PRESENT 0x02 + +enum nr_security_integrity_algorithm_e { nia0, nia1, nia2, nia3 }; +enum nr_security_ciphering_algorithm_e { nea0, nea1, nea2, nea3, nea_disabled=999}; + +typedef struct pdcp_nr_security_info_t +{ + guint32 configuration_frame; + gboolean seen_next_ul_pdu; /* i.e. have we seen SecurityModeResponse */ + enum nr_security_integrity_algorithm_e integrity; + enum nr_security_ciphering_algorithm_e ciphering; + + /* Store previous settings so can revert if get SecurityModeFailure */ + guint32 previous_configuration_frame; + enum nr_security_integrity_algorithm_e previous_integrity; + enum nr_security_ciphering_algorithm_e previous_ciphering; +} pdcp_nr_security_info_t; + + +/*****************************************************************/ +/* UDP framing format */ +/* ----------------------- */ +/* Several people have asked about dissecting PDCP by framing */ +/* PDUs over IP. A suggested format over UDP has been defined */ +/* and implemented by this dissector, using the definitions */ +/* below. */ +/* */ +/* A heuristic dissector (enabled by a preference) will */ +/* recognise a signature at the beginning of these frames. */ +/* Until someone is using this format, suggestions for changes */ +/* are welcome. */ +/*****************************************************************/ + + +/* Signature. Rather than try to define a port for this, or make the + port number a preference, frames will start with this string (with no + terminating NULL */ +#define PDCP_NR_START_STRING "pdcp-nr" + +/* Fixed fields: + - plane (1 byte) */ + +/* Conditional field. This field is mandatory in case of User Plane PDCP PDU. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag). The allowed values are defined above. */ + +#define PDCP_NR_SEQNUM_LENGTH_TAG 0x02 +/* 1 byte */ + +/* Optional fields. Attaching this info should be added if available. + The format is to have the tag, followed by the value (there is no length field, + it's implicit from the tag) */ + +#define PDCP_NR_DIRECTION_TAG 0x03 +/* 1 byte */ + +#define PDCP_NR_BEARER_TYPE_TAG 0x04 +/* 1 byte */ + +#define PDCP_NR_BEARER_ID_TAG 0x05 +/* 1 byte */ + +#define PDCP_NR_UEID_TAG 0x06 +/* 2 bytes, network order */ + +#define PDCP_NR_ROHC_COMPRESSION_TAG 0x07 +/* 0 byte */ + +/* N.B. The following ROHC values only have significance if rohc_compression + is in use for the current channel */ + +#define PDCP_NR_ROHC_IP_VERSION_TAG 0x08 +/* 1 byte */ + +#define PDCP_NR_ROHC_CID_INC_INFO_TAG 0x09 +/* 0 byte */ + +#define PDCP_NR_ROHC_LARGE_CID_PRES_TAG 0x0A +/* 0 byte */ + +#define PDCP_NR_ROHC_MODE_TAG 0x0B +/* 1 byte */ + +#define PDCP_NR_ROHC_RND_TAG 0x0C +/* 0 byte */ + +#define PDCP_NR_ROHC_UDP_CHECKSUM_PRES_TAG 0x0D +/* 0 byte */ + +#define PDCP_NR_ROHC_PROFILE_TAG 0x0E +/* 2 bytes, network order */ + +#define PDCP_NR_MACI_PRES_TAG 0x0F +/* 0 byte */ + +#define PDCP_NR_SDAP_HEADER_TAG 0x10 +/* 1 byte, bitmask with PDCP_NR_UL_SDAP_HEADER_PRESENT and/or PDCP_NR_DL_SDAP_HEADER_PRESENT */ + +#define PDCP_NR_CIPHER_DISABLED_TAG 0x11 +/* 0 byte */ + +/* PDCP PDU. Following this tag comes the actual PDCP PDU (there is no length, the PDU + continues until the end of the frame) */ +#define PDCP_NR_PAYLOAD_TAG 0x01 + + +/* Called by RRC, or other configuration protocols */ + +/* Function to configure ciphering & integrity algorithms */ +void set_pdcp_nr_security_algorithms(guint16 ueid, pdcp_nr_security_info_t *security_info); + +/* Function to indicate securityModeCommand did not complete */ +void set_pdcp_nr_security_algorithms_failed(guint16 ueid); + + +/* Called by external dissectors */ +void set_pdcp_nr_rrc_ciphering_key(guint16 ueid, const char *key); +void set_pdcp_nr_rrc_integrity_key(guint16 ueid, const char *key); +void set_pdcp_nr_up_ciphering_key(guint16 ueid, const char *key); +void set_pdcp_nr_up_integrity_key(guint16 ueid, const char *key); + +/* + * Editor modelines - https://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ +#endif diff --git a/openair2/UTIL/OTG/otg_defs.h b/openair2/UTIL/OTG/otg_defs.h index 6c9944014f..af0260587f 100644 --- a/openair2/UTIL/OTG/otg_defs.h +++ b/openair2/UTIL/OTG/otg_defs.h @@ -34,13 +34,8 @@ # define __OTG_DEFS_H__ /* \brief To define the NUMBER_OF_eNB_MAX and MAX_MOBILES_PER_ENB */ -#if STANDALONE==1 - #include "openairinterface5g_limits.h" -#else - // impl_defs_top.h includes openairinterface5g_limits.h - #include "PHY/impl_defs_top.h" -#endif - +#include "openairinterface5g_limits.h" +#include #include "otg_config.h" /** diff --git a/openair2/X2AP/x2ap_eNB.c b/openair2/X2AP/x2ap_eNB.c index 321190015d..38e6149ccd 100644 --- a/openair2/X2AP/x2ap_eNB.c +++ b/openair2/X2AP/x2ap_eNB.c @@ -115,7 +115,12 @@ void x2ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa if (x2ap_enb_data_p != NULL) { /* some sanity check - to be refined at some point */ if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) { - X2AP_ERROR("x2ap_enb_data_p not NULL and sctp state not SCTP_STATE_ESTABLISHED, what to do?\n"); + X2AP_ERROR("x2ap_enb_data_p not NULL and sctp state not SCTP_STATE_ESTABLISHED?\n"); + if (sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN){ + RB_REMOVE(x2ap_enb_map, &instance_p->x2ap_enb_head, x2ap_enb_data_p); + return; + } + exit(1); } @@ -130,6 +135,18 @@ void x2ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa DevAssert(x2ap_enb_data_p != NULL); dump_trees(); + /* gNB: exit if connection to eNB failed - to be modified if needed. + * We may want to try to connect over and over again until we succeed + * but the modifications to the code to get this behavior are complex. + * Exit on error is a simple solution that can be caught by a script + * for example. + */ + if (instance_p->cell_type == CELL_MACRO_GNB + && sctp_new_association_resp->sctp_state == SCTP_STATE_UNREACHABLE) { + X2AP_ERROR("association with eNB failed, is it running? If no, run it first. If yes, check IP addresses in your configuration file.\n"); + exit(1); + } + if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) { X2AP_WARN("Received unsuccessful result for SCTP association (%u), instance %ld, cnx_id %u\n", sctp_new_association_resp->sctp_state, diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index e1ea5cb08e..0fe2741d7b 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -281,7 +281,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( (ue_context_p->ue_context.handover_info->state < HO_FORWARDING_COMPLETE)) { if(msgType == NW_GTP_END_MARKER) { /* in the source enb, UE in RRC_HO_EXECUTION mode */ - if (ue_context_p->ue_context.Status == RRC_HO_EXECUTION && ue_context_p->ue_context.handover_info->state == HO_COMPLETE) { + if (ue_context_p->ue_context.StatusRrc == RRC_HO_EXECUTION && ue_context_p->ue_context.handover_info->state == HO_COMPLETE) { /* set handover state */ //ue_context_p->ue_context.handover_info->state = HO_END_MARKER; MessageDef *msg; @@ -299,10 +299,10 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( } } - if (ue_context_p->ue_context.Status == RRC_HO_EXECUTION || ue_context_p->ue_context.Status == RRC_RECONFIGURED) { + if (ue_context_p->ue_context.StatusRrc == RRC_HO_EXECUTION || ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED) { int msgsrc = gtpv1u_eNB_get_msgsource(ue_context_p, teid); LOG_D(GTPU,"UE INFO.ueStatus %d, handover state %d, forwarding state %d, from %s. message type %s\n", - ue_context_p->ue_context.Status, + ue_context_p->ue_context.StatusRrc, ue_context_p->ue_context.handover_info->state, ue_context_p->ue_context.handover_info->forwarding_state, msgsrc == GTPV1U_MSG_FROM_SOURCE_ENB?"Source eNB":"EPC", diff --git a/openair3/GTPV1-U/gtpv1u_gNB.c b/openair3/GTPV1-U/gtpv1u_gNB.c index cc21b27ab5..d3f26aeff1 100644 --- a/openair3/GTPV1-U/gtpv1u_gNB.c +++ b/openair3/GTPV1-U/gtpv1u_gNB.c @@ -925,6 +925,8 @@ static int gtpv1u_gnb_tunnel_data_req(gtpv1u_gnb_tunnel_data_req_t *gnb_tunnel_d VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_PROCESS_TUNNEL_DATA_REQ, VCD_FUNCTION_OUT); /* Buffer still needed, do not free it */ //itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), data_req_p->buffer); + + return 0; } //----------------------------------------------------------------------------- diff --git a/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c b/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c index 5479e176eb..0d962cad7d 100644 --- a/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c +++ b/openair3/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c @@ -59,7 +59,7 @@ extern "C" { #endif -#define LOG_GTPU 1 +//#define LOG_GTPU 1 /*--------------------------------------------------------------------------* * P R I V A T E F U N C T I O N S * *--------------------------------------------------------------------------*/ @@ -901,7 +901,7 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, case NW_GTP_END_MARKER: #if defined(LOG_GTPU) && LOG_GTPU > 0 for(int i =1; i<= udpDataLen; i++){ - printf("%02x ", udpData[i-1]); + printf("%02x ", (uint8_t)udpData[i-1]); if(i % 20 == 0)printf("\n"); } #endif diff --git a/openair3/NAS/COMMON/EMM/MSG/CsServiceNotification.h b/openair3/NAS/COMMON/EMM/MSG/CsServiceNotification.h index c173d3b729..4bed349327 100644 --- a/openair3/NAS/COMMON/EMM/MSG/CsServiceNotification.h +++ b/openair3/NAS/COMMON/EMM/MSG/CsServiceNotification.h @@ -26,7 +26,7 @@ #include "ProtocolDiscriminator.h" #include "SecurityHeaderType.h" #include "MessageType.h" -#include "PagingIdentity.h" +#include "NasPagingIdentity.h" #include "Cli.h" #include "SsCode.h" #include "LcsIndicator.h" diff --git a/openair3/NAS/COMMON/IES/FGSMobileIdentity.c b/openair3/NAS/COMMON/IES/FGSMobileIdentity.c index e3204b4c0c..5f920105f9 100644 --- a/openair3/NAS/COMMON/IES/FGSMobileIdentity.c +++ b/openair3/NAS/COMMON/IES/FGSMobileIdentity.c @@ -194,23 +194,23 @@ static int encode_guti_5gs_mobile_identity(Guti5GSMobileIdentity_t *guti, uint8_ static int encode_suci_5gs_mobile_identity(Suci5GSMobileIdentity_t *suci, uint8_t *buffer) { uint32_t encoded = 0; - *(buffer + encoded) = 0x00 | (suci->supiformat << 4) | (suci->typeofidentity); + *(buffer + encoded) = (suci->supiformat << 4) | (suci->typeofidentity); encoded++; - *(buffer + encoded) = 0x00 | ((suci->mccdigit2 & 0xf) << 4) | + *(buffer + encoded) = ((suci->mccdigit2 & 0xf) << 4) | (suci->mccdigit1 & 0xf); encoded++; - *(buffer + encoded) = 0x00 | ((suci->mncdigit3 & 0xf) << 4) | + *(buffer + encoded) = ((suci->mncdigit3 & 0xf) << 4) | (suci->mccdigit3 & 0xf); encoded++; - *(buffer + encoded) = 0x00 | ((suci->mncdigit2 & 0xf) << 4) | + *(buffer + encoded) = ((suci->mncdigit2 & 0xf) << 4) | (suci->mncdigit1 & 0xf); encoded++; - *(buffer + encoded) = 0x00 | ((suci->routingindicatordigit2 & 0xf) << 4) | + *(buffer + encoded) = ((suci->routingindicatordigit2 & 0xf) << 4) | (suci->routingindicatordigit1 & 0xf); encoded++; - *(buffer + encoded) = 0x00 | ((suci->routingindicatordigit4 & 0xf) << 4) | + *(buffer + encoded) = ((suci->routingindicatordigit4 & 0xf) << 4) | (suci->routingindicatordigit3 & 0xf); encoded++; @@ -220,8 +220,15 @@ static int encode_suci_5gs_mobile_identity(Suci5GSMobileIdentity_t *suci, uint8_ *(buffer + encoded) = suci->homenetworkpki; encoded++; - IES_ENCODE_U32(buffer, encoded, suci->schemeoutput); + char *ptr=suci->schemeoutput; + while ( ptr < suci->schemeoutput+strlen(suci->schemeoutput) ) { + buffer[encoded]=((*(ptr+1)-'0')<<4) | (*(ptr) -'0'); + encoded++; + ptr+=2; + } + if (strlen(suci->schemeoutput)%2 == 1) + buffer[encoded++]=((*(ptr-1)-'0')) | 0xF0; return encoded; } diff --git a/openair3/NAS/COMMON/IES/FGSMobileIdentity.h b/openair3/NAS/COMMON/IES/FGSMobileIdentity.h index a673a86dd1..7968bc3300 100644 --- a/openair3/NAS/COMMON/IES/FGSMobileIdentity.h +++ b/openair3/NAS/COMMON/IES/FGSMobileIdentity.h @@ -64,7 +64,7 @@ typedef struct { uint8_t spare6:1; uint8_t protectionschemeId:4; uint8_t homenetworkpki; - uint32_t schemeoutput; + char schemeoutput[32]; } Suci5GSMobileIdentity_t; typedef struct { diff --git a/openair3/NAS/COMMON/IES/NasPagingIdentity.h b/openair3/NAS/COMMON/IES/NasPagingIdentity.h new file mode 100644 index 0000000000..3e03128006 --- /dev/null +++ b/openair3/NAS/COMMON/IES/NasPagingIdentity.h @@ -0,0 +1,43 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +#include +#include +#include + +#include "OctetString.h" + +#ifndef NASPAGING_IDENTITY_H_ +#define NASPAGING_IDENTITY_H_ + +#define PAGING_IDENTITY_MINIMUM_LENGTH 2 +#define PAGING_IDENTITY_MAXIMUM_LENGTH 2 + +typedef uint8_t PagingIdentity; + +int encode_paging_identity(PagingIdentity *pagingidentity, uint8_t iei, uint8_t *buffer, uint32_t len); + +void dump_paging_identity_xml(PagingIdentity *pagingidentity, uint8_t iei); + +int decode_paging_identity(PagingIdentity *pagingidentity, uint8_t iei, uint8_t *buffer, uint32_t len); + +#endif /* PAGING IDENTITY_H_ */ + diff --git a/openair3/NAS/COMMON/NR_NAS_defs.h b/openair3/NAS/COMMON/NR_NAS_defs.h index 906c0cf504..54ac8c037e 100644 --- a/openair3/NAS/COMMON/NR_NAS_defs.h +++ b/openair3/NAS/COMMON/NR_NAS_defs.h @@ -387,5 +387,6 @@ void processNAS(void *msg, NRUEcontext_t *UE); int identityRequest(void **msg, NRUEcontext_t *UE); int authenticationRequest(void **msg, NRUEcontext_t *UE); int securityModeCommand(void **msg, NRUEcontext_t *UE); +void servingNetworkName(uint8_t *msg, char * imsiStr, int nmc_size); #endif diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.c b/openair3/NAS/NR_UE/nr_nas_msg_sim.c index d862091776..7308f677a1 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.c +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.c @@ -38,25 +38,15 @@ #include "aka_functions.h" #include "secu_defs.h" #include "PduSessionEstablishRequest.h" -# include "intertask_interface.h" - -/*char netName[] = "5G:mnc093.mcc208.3gppnetwork.org"; -char imsi[] = "2089300007487"; -// USIM_API_K: 5122250214c33e723a5dd523fc145fc0 -uint8_t k[16] = {0x51, 0x22, 0x25, 0x02, 0x14,0xc3, 0x3e, 0x72, 0x3a, 0x5d, 0xd5, 0x23, 0xfc, 0x14, 0x5f, 0xc0}; -// OPC: 981d464c7c52eb6e5036234984ad0bcf -const uint8_t opc[16] = {0x98, 0x1d, 0x46, 0x4c,0x7c,0x52,0xeb, 0x6e, 0x50, 0x36, 0x23, 0x49, 0x84, 0xad, 0x0b, 0xcf};*/ - - -char netName[] = "5G:mnc099.mcc208.3gppnetwork.org"; -char imsi[] = "2089900007487"; //"208990100001100"; -// USIM_API_K: fe c8 6b a6 eb 70 7e d0 89 05 75 7b 1b b4 4b 8f -uint8_t k[16] = {0xfe, 0xc8, 0x6b, 0xa6, 0xeb, 0x70, 0x7e, 0xd0, 0x89, 0x05, 0x75, 0x7b, 0x1b, 0xb4, 0x4b, 0x8f}; -// OPC: c4 24 49 36 3b ba d0 2b 66 d1 6b c9 75 d7 7c c1 -const uint8_t opc[16] = {0xc4, 0x24, 0x49, 0x36, 0x3b, 0xba, 0xd0, 0x2b, 0x66, 0xd1, 0x6b, 0xc9, 0x75, 0xd7, 0x7c, 0xc1}; +#include "intertask_interface.h" +#include "openair2/RRC/NAS/nas_config.h" +#include +#include +#include uint8_t *registration_request_buf; uint32_t registration_request_len; +extern char *baseNetAddress; static int nas_protected_security_header_encode( char *buffer, @@ -161,11 +151,11 @@ int mm_msg_encode(MM_msg *mm_msg, uint8_t *buffer, uint32_t len) { LOG_FUNC_RETURN (header_result + encode_result); } -void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16], uint8_t *output) { - uint8_t S[100]; +void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16], uint8_t *output, uicc_t* uicc) { + uint8_t S[100]={0}; S[0] = 0x6B; - int netNamesize = strlen(netName); - memcpy(&S[1], netName, netNamesize); + servingNetworkName (S+1, uicc->imsiStr, uicc->nmc_size); + int netNamesize = strlen((char*)S+1); S[1 + netNamesize] = (netNamesize & 0xff00) >> 8; S[2 + netNamesize] = (netNamesize & 0x00ff); for (int i = 0; i < 16; i++) @@ -202,14 +192,15 @@ void transferRES(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16 output[i] = out[16 + i]; } -void derive_kausf(uint8_t ck[16], uint8_t ik[16], uint8_t sqn[6], uint8_t kausf[32]) { - uint8_t S[100]; +void derive_kausf(uint8_t ck[16], uint8_t ik[16], uint8_t sqn[6], uint8_t kausf[32], uicc_t *uicc) { + uint8_t S[100]={0}; uint8_t key[32]; - int netNamesize = strlen(netName); + memcpy(&key[0], ck, 16); memcpy(&key[16], ik, 16); //KEY S[0] = 0x6A; - memcpy(&S[1], netName, netNamesize); + servingNetworkName (S+1, uicc->imsiStr, uicc->nmc_size); + int netNamesize = strlen((char*)S+1); S[1 + netNamesize] = (uint8_t)((netNamesize & 0xff00) >> 8); S[2 + netNamesize] = (uint8_t)(netNamesize & 0x00ff); for (int i = 0; i < 6; i++) { @@ -220,21 +211,21 @@ void derive_kausf(uint8_t ck[16], uint8_t ik[16], uint8_t sqn[6], uint8_t kausf[ kdf(key, 32, S, 11 + netNamesize, kausf, 32); } -void derive_kseaf(uint8_t kausf[32], uint8_t kseaf[32]) { - uint8_t S[100]; - int netNamesize = strlen(netName); +void derive_kseaf(uint8_t kausf[32], uint8_t kseaf[32], uicc_t *uicc) { + uint8_t S[100]={0}; S[0] = 0x6C; //FC - memcpy(&S[1], netName, netNamesize); + servingNetworkName (S+1, uicc->imsiStr, uicc->nmc_size); + int netNamesize = strlen((char*)S+1); S[1 + netNamesize] = (uint8_t)((netNamesize & 0xff00) >> 8); S[2 + netNamesize] = (uint8_t)(netNamesize & 0x00ff); kdf(kausf, 32, S, 3 + netNamesize, kseaf, 32); } -void derive_kamf(uint8_t *kseaf, uint8_t *kamf, uint16_t abba) { - int imsiLen = strlen(imsi); +void derive_kamf(uint8_t *kseaf, uint8_t *kamf, uint16_t abba, uicc_t* uicc) { + int imsiLen = strlen(uicc->imsiStr); uint8_t S[100]; S[0] = 0x6D; //FC = 0x6D - memcpy(&S[1], imsi, imsiLen); + memcpy(&S[1], uicc->imsiStr, imsiLen ); S[1 + imsiLen] = (uint8_t)((imsiLen & 0xff00) >> 8); S[2 + imsiLen] = (uint8_t)(imsiLen & 0x00ff); S[3 + imsiLen] = abba & 0x00ff; @@ -260,11 +251,11 @@ void derive_knas(algorithm_type_dist_t nas_alg_type, uint8_t nas_alg_id, uint8_t knas_int[i] = out[16 + i]; } -void generateRegistrationRequest(as_nas_info_t *initialNasMsg) { +void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id) { int size = sizeof(mm_msg_header_t); - fgs_nas_message_t nas_msg; - memset(&nas_msg, 0, sizeof(fgs_nas_message_t)); + fgs_nas_message_t nas_msg={0}; MM_msg *mm_msg; + uicc_t * uicc=checkUicc(Mod_id); mm_msg = &nas_msg.plain.mm_msg; // set header @@ -289,26 +280,31 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg) { mm_msg->registration_request.fgsmobileidentity.guti.amfpointer = 0; mm_msg->registration_request.fgsmobileidentity.guti.amfsetid = 1016; mm_msg->registration_request.fgsmobileidentity.guti.tmsi = 10; - mm_msg->registration_request.fgsmobileidentity.guti.mncdigit1 = 9; - mm_msg->registration_request.fgsmobileidentity.guti.mncdigit2 = 9; - mm_msg->registration_request.fgsmobileidentity.guti.mncdigit3 = 0xf; - mm_msg->registration_request.fgsmobileidentity.guti.mccdigit1 = 2; - mm_msg->registration_request.fgsmobileidentity.guti.mccdigit2 = 0; - mm_msg->registration_request.fgsmobileidentity.guti.mccdigit3 = 8; + mm_msg->registration_request.fgsmobileidentity.guti.mncdigit1 = + uicc->nmc_size==2 ? uicc->imsiStr[3]-'0' : uicc->imsiStr[4]-'0'; + mm_msg->registration_request.fgsmobileidentity.guti.mncdigit2 = + uicc->nmc_size==2 ? uicc->imsiStr[4]-'0' : uicc->imsiStr[5]-'0'; + mm_msg->registration_request.fgsmobileidentity.guti.mncdigit3 = + uicc->nmc_size==2 ? 0xf : uicc->imsiStr[3]-'0'; + mm_msg->registration_request.fgsmobileidentity.guti.mccdigit1 = uicc->imsiStr[0]-'0'; + mm_msg->registration_request.fgsmobileidentity.guti.mccdigit2 = uicc->imsiStr[1]-'0'; + mm_msg->registration_request.fgsmobileidentity.guti.mccdigit3 = uicc->imsiStr[2]-'0'; size += 13; } else { mm_msg->registration_request.fgsmobileidentity.suci.typeofidentity = FGS_MOBILE_IDENTITY_SUCI; - mm_msg->registration_request.fgsmobileidentity.suci.mncdigit1 = 9; - mm_msg->registration_request.fgsmobileidentity.suci.mncdigit2 = 9; - mm_msg->registration_request.fgsmobileidentity.suci.mncdigit3 = 0xf; - mm_msg->registration_request.fgsmobileidentity.suci.mccdigit1 = 2; - mm_msg->registration_request.fgsmobileidentity.suci.mccdigit2 = 0; - mm_msg->registration_request.fgsmobileidentity.suci.mccdigit3 = 8; - mm_msg->registration_request.fgsmobileidentity.suci.schemeoutput = 0x4778; - - size += 14; + mm_msg->registration_request.fgsmobileidentity.suci.mncdigit1 = + uicc->nmc_size==2 ? uicc->imsiStr[3]-'0' : uicc->imsiStr[4]-'0'; + mm_msg->registration_request.fgsmobileidentity.suci.mncdigit2 = + uicc->nmc_size==2 ? uicc->imsiStr[4]-'0' : uicc->imsiStr[5]-'0'; + mm_msg->registration_request.fgsmobileidentity.suci.mncdigit3 = + uicc->nmc_size==2 ? 0xf : uicc->imsiStr[3]-'0'; + mm_msg->registration_request.fgsmobileidentity.suci.mccdigit1 = uicc->imsiStr[0]-'0'; + mm_msg->registration_request.fgsmobileidentity.suci.mccdigit2 = uicc->imsiStr[1]-'0'; + mm_msg->registration_request.fgsmobileidentity.suci.mccdigit3 = uicc->imsiStr[2]-'0'; + memcpy(mm_msg->registration_request.fgsmobileidentity.suci.schemeoutput, uicc->imsiStr+3+uicc->nmc_size, strlen(uicc->imsiStr) - (3+uicc->nmc_size)); + size += sizeof(Suci5GSMobileIdentity_t); } mm_msg->registration_request.presencemask |= REGISTRATION_REQUEST_5GMM_CAPABILITY_PRESENT; @@ -335,7 +331,7 @@ void generateRegistrationRequest(as_nas_info_t *initialNasMsg) { } -void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype) { +void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype, uicc_t* uicc) { int size = sizeof(mm_msg_header_t); fgs_nas_message_t nas_msg; memset(&nas_msg, 0, sizeof(fgs_nas_message_t)); @@ -357,15 +353,17 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype size += 1; if(identitytype == FGS_MOBILE_IDENTITY_SUCI){ mm_msg->fgs_identity_response.fgsmobileidentity.suci.typeofidentity = FGS_MOBILE_IDENTITY_SUCI; - mm_msg->fgs_identity_response.fgsmobileidentity.suci.mncdigit1 = 9; - mm_msg->fgs_identity_response.fgsmobileidentity.suci.mncdigit2 = 9; - mm_msg->fgs_identity_response.fgsmobileidentity.suci.mncdigit3 = 0xf; - mm_msg->fgs_identity_response.fgsmobileidentity.suci.mccdigit1 = 2; - mm_msg->fgs_identity_response.fgsmobileidentity.suci.mccdigit2 = 0; - mm_msg->fgs_identity_response.fgsmobileidentity.suci.mccdigit3 = 8; - mm_msg->fgs_identity_response.fgsmobileidentity.suci.schemeoutput = 0x4778; - - size += 14; + mm_msg->fgs_identity_response.fgsmobileidentity.suci.mncdigit1 = + uicc->nmc_size==2 ? uicc->imsiStr[3]-'0' : uicc->imsiStr[4]-'0'; + mm_msg->fgs_identity_response.fgsmobileidentity.suci.mncdigit2 = + uicc->nmc_size==2 ? uicc->imsiStr[4]-'0' : uicc->imsiStr[5]-'0'; + mm_msg->fgs_identity_response.fgsmobileidentity.suci.mncdigit3 = + uicc->nmc_size==2? 0xF : uicc->imsiStr[3]-'0'; + mm_msg->fgs_identity_response.fgsmobileidentity.suci.mccdigit1 = uicc->imsiStr[0]-'0'; + mm_msg->fgs_identity_response.fgsmobileidentity.suci.mccdigit2 = uicc->imsiStr[1]-'0'; + mm_msg->fgs_identity_response.fgsmobileidentity.suci.mccdigit3 = uicc->imsiStr[2]-'0'; + memcpy(mm_msg->registration_request.fgsmobileidentity.suci.schemeoutput, uicc->imsiStr+3+uicc->nmc_size, strlen(uicc->imsiStr) - (3+uicc->nmc_size)); + size += sizeof(Suci5GSMobileIdentity_t); } // encode the message @@ -376,7 +374,7 @@ void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype } OctetString knas_int; -void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf){ +static void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf, uicc_t *uicc){ uint8_t ak[6]; @@ -394,9 +392,9 @@ void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf){ uint8_t resTemp[16]; uint8_t ck[16], ik[16], output[16]; - f2345(k, rand, resTemp, ck, ik, ak, opc); + f2345(uicc->key, rand, resTemp, ck, ik, ak, uicc->opc); - transferRES(ck, ik, resTemp, rand, output); + transferRES(ck, ik, resTemp, rand, output, uicc); // get knas_int knas_int.length = 16; @@ -405,9 +403,9 @@ void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf){ sqn[index] = buf[26+index]; } - derive_kausf(ck, ik, sqn, kausf); - derive_kseaf(kausf, kseaf); - derive_kamf(kseaf, kamf, 0x0000); + derive_kausf(ck, ik, sqn, kausf, uicc); + derive_kseaf(kausf, kseaf, uicc); + derive_kamf(kseaf, kamf, 0x0000, uicc); derive_knas(0x02, 2, kamf, knas_int.value); printf("kausf:"); @@ -614,6 +612,19 @@ void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentCo } } +void decodeDownlinkNASTransport(as_nas_info_t *initialNasMsg, uint8_t * pdu_buffer){ + uint8_t msg_type = *(pdu_buffer + 16); + if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ + sprintf(baseNetAddress, "%d.%d", *(pdu_buffer + 39),*(pdu_buffer + 40)); + int third_octet = *(pdu_buffer + 41); + int fourth_octet = *(pdu_buffer + 42); + LOG_I(NAS, "Received PDU Session Establishment Accept\n"); + nas_config(1,third_octet,fourth_octet,"ue"); + } else { + LOG_E(NAS, "Received unexpected message in DLinformationTransfer %d\n", msg_type); + } +} + void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg){ //wait send RegistrationComplete usleep(100*150); @@ -701,6 +712,7 @@ void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg){ } } + void *nas_nrue_task(void *args_p) { MessageDef *msg_p; @@ -720,6 +732,8 @@ void *nas_nrue_task(void *args_p) if (msg_p != NULL) { instance = msg_p->ittiMsgHeader.originInstance; Mod_id = instance ; + uicc_t *uicc=checkUicc(Mod_id); + if (instance == INSTANCE_DEFAULT) { printf("%s:%d: FATAL: instance is INSTANCE_DEFAULT, should not happen.\n", __FILE__, __LINE__); @@ -816,6 +830,16 @@ void *nas_nrue_task(void *args_p) LOG_I(NAS, "Send NAS_UPLINK_DATA_REQ message(PduSessionEstablishRequest)\n"); } } + else if((pdu_buffer + 16) != NULL){ + msg_type = *(pdu_buffer + 16); + if(msg_type == FGS_PDU_SESSION_ESTABLISHMENT_ACC){ + sprintf(baseNetAddress, "%d.%d", *(pdu_buffer + 39),*(pdu_buffer + 40)); + int third_octet = *(pdu_buffer + 41); + int fourth_octet = *(pdu_buffer + 42); + LOG_I(NAS, "Received PDU Session Establishment Accept\n"); + nas_config(1,third_octet,fourth_octet,"ue"); + } + } break; } @@ -839,8 +863,7 @@ void *nas_nrue_task(void *args_p) Mod_id, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length, NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data); - as_nas_info_t initialNasMsg; - memset(&initialNasMsg, 0, sizeof(as_nas_info_t)); + as_nas_info_t initialNasMsg={0}; pdu_buffer = NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data; if((pdu_buffer + 1) != NULL){ @@ -857,14 +880,18 @@ void *nas_nrue_task(void *args_p) switch(msg_type){ case FGS_IDENTITY_REQUEST: - generateIdentityResponse(&initialNasMsg,*(pdu_buffer+3)); + generateIdentityResponse(&initialNasMsg,*(pdu_buffer+3), uicc); break; case FGS_AUTHENTICATION_REQUEST: - generateAuthenticationResp(&initialNasMsg, pdu_buffer); + generateAuthenticationResp(&initialNasMsg, pdu_buffer, uicc); break; case FGS_SECURITY_MODE_COMMAND: generateSecurityModeComplete(&initialNasMsg); break; + case FGS_DOWNLINK_NAS_TRANSPORT: + decodeDownlinkNASTransport(&initialNasMsg, pdu_buffer); + break; + default: LOG_W(NR_RRC,"unknow message type %d\n",msg_type); break; diff --git a/openair3/NAS/NR_UE/nr_nas_msg_sim.h b/openair3/NAS/NR_UE/nr_nas_msg_sim.h index 2f123a6f04..348c27ecc8 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg_sim.h +++ b/openair3/NAS/NR_UE/nr_nas_msg_sim.h @@ -56,9 +56,11 @@ #define FGS_SECURITY_MODE_COMMAND 0b01011101 /* 93 = 0x5d */ #define FGS_SECURITY_MODE_COMPLETE 0b01011110 /* 94 = 0x5e */ #define FGS_UPLINK_NAS_TRANSPORT 0b01100111 /* 103= 0x67 */ +#define FGS_DOWNLINK_NAS_TRANSPORT 0b01101000 /* 104= 0x68 */ // message type for 5GS session management #define FGS_PDU_SESSION_ESTABLISHMENT_REQ 0b11000001 /* 193= 0xc1 */ +#define FGS_PDU_SESSION_ESTABLISHMENT_ACC 0b11000010 /* 194= 0xc2 */ #define INITIAL_REGISTRATION 0b001 @@ -114,9 +116,7 @@ typedef union { fgs_nas_message_plain_t plain; } fgs_nas_message_t; -void generateRegistrationRequest(as_nas_info_t *initialNasMsg); -void generateIdentityResponse(as_nas_info_t *initialNasMsg, uint8_t identitytype); -void generateAuthenticationResp(as_nas_info_t *initialNasMsg, uint8_t *buf); +void generateRegistrationRequest(as_nas_info_t *initialNasMsg, int Mod_id); void generateSecurityModeComplete(as_nas_info_t *initialNasMsg); void generateRegistrationComplete(as_nas_info_t *initialNasMsg, SORTransparentContainer *sortransparentcontainer); void generatePduSessionEstablishRequest(as_nas_info_t *initialNasMsg); diff --git a/openair3/NAS/TOOLS/ue_sim_ci.conf b/openair3/NAS/TOOLS/ue_sim_ci.conf new file mode 100644 index 0000000000..5d95c9ba3f --- /dev/null +++ b/openair3/NAS/TOOLS/ue_sim_ci.conf @@ -0,0 +1,45 @@ +# List of known PLMNS +PLMN: { + PLMN0: { + FULLNAME="OpenAirInterface"; + SHORTNAME="OAICN"; + MNC="96"; + MCC="208"; + }; +}; + +UE0: +{ + USER: { + IMEI="356113022094149"; + MANUFACTURER="OAI"; + MODEL="LTE SoftModem"; + PIN="0000"; + }; + + SIM: { + MSIN="0100001111"; + USIM_API_K="8baf473f2f8fd09487cccbd7097c6862"; + OPC="e734f8734007d6c5ce7a0508809e7e9c"; + MSISDN="33611123456"; + }; + + # Home PLMN Selector with Access Technology + HPLMN= "20896"; + + # User controlled PLMN Selector with Access Technology + UCPLMN_LIST = (); + + # Operator PLMN List + OPLMN_LIST = ("20896"); + + # Operator controlled PLMN Selector with Access Technology + OCPLMN_LIST = (); + + # Forbidden plmns + FPLMN_LIST = (); + + # Equivalent home plmns + EHPLMN_LIST = (); + +}; diff --git a/openair3/SCTP/sctp_eNB_task.c b/openair3/SCTP/sctp_eNB_task.c index af49c5c350..a14d4b9780 100644 --- a/openair3/SCTP/sctp_eNB_task.c +++ b/openair3/SCTP/sctp_eNB_task.c @@ -985,6 +985,7 @@ sctp_eNB_read_from_socket( if (SCTP_SHUTDOWN_EVENT == snp->sn_header.sn_type) { itti_unsubscribe_event_fd(TASK_SCTP, sctp_cnx->sd); + SCTP_WARN("Received SCTP SHUTDOWN EVENT\n"); close(sctp_cnx->sd); sctp_itti_send_association_resp( @@ -1026,7 +1027,14 @@ sctp_eNB_read_from_socket( break; default: - SCTP_WARN("unhandled: SCTP_ASSOC_CHANGE to %d\n", sctp_assoc_changed->sac_state); + if ( sctp_assoc_changed->sac_state == SCTP_SHUTDOWN_COMP) + SCTP_WARN("SCTP_ASSOC_CHANGE to SSCTP_SHUTDOWN_COMP\n"); + if ( sctp_assoc_changed->sac_state == SCTP_RESTART) + SCTP_WARN("SCTP_ASSOC_CHANGE to SCTP_RESTART\n"); + if ( sctp_assoc_changed->sac_state == SCTP_CANT_STR_ASSOC) + SCTP_ERROR("SCTP_ASSOC_CHANGE to SCTP_CANT_STR_ASSOC\n"); + if ( sctp_assoc_changed->sac_state == SCTP_COMM_LOST) + SCTP_ERROR("SCTP_ASSOC_CHANGE to SCTP_COMM_LOST\n"); break; } } diff --git a/openair3/UDP/udp_eNB_task.c b/openair3/UDP/udp_eNB_task.c index 515dd9a17f..05729ba6b1 100644 --- a/openair3/UDP/udp_eNB_task.c +++ b/openair3/UDP/udp_eNB_task.c @@ -169,8 +169,8 @@ int udp_eNB_create_socket(int port, char *ip_addr, task_id_t task_id) if ((rc = bind(sd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in))) < 0) { close(sd); - AssertFatal(rc >= 0, "UDP: Failed to bind socket: (%s:%d) address %s port %d\n", - strerror(errno), errno, ip_addr, port); + LOG_E(UDP_, "Failed to bind socket: (%s:%d) address %s port %d\n", strerror(errno), errno, ip_addr, port); + return -1; } /* Create a new descriptor for this connection */ diff --git a/openair3/UICC/usim_interface.c b/openair3/UICC/usim_interface.c index 15a4e2e540..0973d75082 100644 --- a/openair3/UICC/usim_interface.c +++ b/openair3/UICC/usim_interface.c @@ -20,9 +20,11 @@ * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ +#include #include #include +extern uint16_t NB_UE_INST; #define UICC_SECTION "uicc" #define UICC_CONFIG_HELP_OPTIONS " list of comma separated options to interface a simulated (real UICC to be developped). Available options: \n"\ @@ -34,18 +36,20 @@ /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define UICC_PARAMS_DESC {\ - {"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsiStr), defstrval:"", TYPE_STRING, 0 },\ + {"imsi", "USIM IMSI\n", 0, strptr:&(uicc->imsiStr), defstrval:"2089900007487", TYPE_STRING, 0 },\ {"nmc_size" "number of digits in NMC", 0, iptr:&(uicc->nmc_size), defintval:2, TYPE_INT, 0 },\ - {"key", "USIM Ki\n", 0, strptr:&(uicc->keyStr), defstrval:"", TYPE_STRING, 0 },\ - {"opc", "USIM OPc\n", 0, strptr:&(uicc->opcStr), defstrval:"", TYPE_STRING, 0 },\ + {"key", "USIM Ki\n", 0, strptr:&(uicc->keyStr), defstrval:"fec86ba6eb707ed08905757b1bb44b8f", TYPE_STRING, 0 },\ + {"opc", "USIM OPc\n", 0, strptr:&(uicc->opcStr), defstrval:"c42449363bbad02b66d16bc975d77cc1", TYPE_STRING, 0 },\ {"amf", "USIM amf\n", 0, strptr:&(uicc->amfStr), defstrval:"8000", TYPE_STRING, 0 },\ {"sqn", "USIM sqn\n", 0, strptr:&(uicc->sqnStr), defstrval:"000000", TYPE_STRING, 0 },\ }; +static uicc_t** uiccArray=NULL; + const char *hexTable="0123456789abcdef"; static inline uint8_t mkDigit(unsigned char in) { for (int i=0; i<16; i++) - if (in==hexTable[i]) + if (tolower(in)==hexTable[i]) return i; LOG_E(SIM,"Impossible hexa input: %c\n",in); return 0; @@ -65,7 +69,7 @@ uicc_t *init_uicc(char *sectionName) { // we can read the IMSI from the USIM // key, OPc, sqn, amf don't need to be read from the true USIM int ret = config_get( uicc_params,sizeof(uicc_params)/sizeof(paramdef_t),sectionName); - AssertFatal(ret >= 0, "configuration couldn't be performed"); + AssertFatal(ret >= 0, "configuration couldn't be performed for uicc name: %s", sectionName); LOG_I(SIM, "UICC simulation: IMSI=%s, Ki=%s, OPc=%s\n", uicc->imsiStr, uicc->keyStr, uicc->opcStr); to_hex(uicc->keyStr,uicc->key, sizeof(uicc->key) ); to_hex(uicc->opcStr,uicc->opc, sizeof(uicc->opc) ); @@ -90,3 +94,15 @@ void uicc_milenage_generate(uint8_t *autn, uicc_t *uicc) { log_dump(SIM,autn,sizeof(autn), LOG_DUMP_CHAR,"milenage output autn:"); } +uicc_t * checkUicc(int Mod_id) { + AssertFatal(Mod_id < NB_UE_INST, "Mod_id must be less than NB_UE_INST. Mod_id:%d NB_UE_INST:%d", Mod_id,NB_UE_INST); + if(uiccArray==NULL){ + uiccArray=(uicc_t **)calloc(1,sizeof(uicc_t*)*NB_UE_INST); + } + if (!uiccArray[Mod_id]) { + char uiccName[64]; + sprintf(uiccName,"uicc%d", Mod_id); + uiccArray[Mod_id]=(void*)init_uicc(uiccName); + } + return (uicc_t*) uiccArray[Mod_id]; +} diff --git a/openair3/UICC/usim_interface.h b/openair3/UICC/usim_interface.h index e8f241c1e8..44c27c772e 100644 --- a/openair3/UICC/usim_interface.h +++ b/openair3/UICC/usim_interface.h @@ -66,6 +66,8 @@ typedef struct { /* * Read the configuration file, section name variable to be able to manage several UICC */ +uicc_t *checkUicc(int Mod_id); uicc_t *init_uicc(char *sectionName); void uicc_milenage_generate(uint8_t * autn, uicc_t *uicc); +uicc_t * checkUicc(int Mod_id); #endif diff --git a/openair3/ocp-gtpu/gtp_itf.cpp b/openair3/ocp-gtpu/gtp_itf.cpp index 2862a4d906..e12a4d66a8 100644 --- a/openair3/ocp-gtpu/gtp_itf.cpp +++ b/openair3/ocp-gtpu/gtp_itf.cpp @@ -62,7 +62,7 @@ typedef struct { typedef struct { rnti_t rnti; - ebi_t rb_id; + ebi_t incoming_rb_id; gtpCallback callBack; } rntiData_t; @@ -121,10 +121,8 @@ static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, te msgHdr->version=1; msgHdr->msgType=GTP_GPDU; msgHdr->msgLength=htons(msgLen); - if ( seqNumFlag || extHdrFlag || npduNumFlag) msgHdr->msgLength+=4; - msgHdr->teid=htonl(teid); if(seqNumFlag || extHdrFlag || npduNumFlag) { @@ -156,14 +154,14 @@ static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, te static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, bool seqNumFlag, bool npduNumFlag) { uint8_t *buffer=req->buffer+req->offset; size_t length=req->length; - uint64_t rnti=req->rnti; + rnti_t rnti=req->rnti; int rab_id=req->rab_id; pthread_mutex_lock(&globGtp.gtp_lock); auto inst=&globGtp.instances[compatInst(instance)]; auto ptrRnti=inst->ue2te_mapping.find(rnti); if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %lx in hashtable ue_mapping\n", rnti); + LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", rnti); pthread_mutex_unlock(&globGtp.gtp_lock); return; } @@ -171,11 +169,11 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b auto ptr=ptrRnti->second.bearers; if ( ptr.find(rab_id) == ptr.end() ) { - LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %lx/%x\n", rnti, rab_id); + LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %x/%x\n", rnti, rab_id); pthread_mutex_unlock(&globGtp.gtp_lock); return; } else - LOG_D(GTPU,"sending a packet to RNTI:RAB:teid %lx/%x/%x, len %lu, oldseq %d, oldnum %d\n", + LOG_D(GTPU,"sending a packet to RNTI:RAB:teid %x/%x/%x, len %lu, oldseq %d, oldnum %d\n", rnti, rab_id,ptr[rab_id].teid_outgoing,length, ptr[rab_id].seqNum,ptr[rab_id].npduNum ); if(seqNumFlag) @@ -197,14 +195,14 @@ static void gtpv1uSend(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req, b static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, bool seqNumFlag, bool npduNumFlag) { uint8_t *buffer=req->buffer+req->offset; size_t length=req->length; - uint64_t rnti=req->rnti; + rnti_t rnti=req->rnti; int rab_id=req->pdusession_id; pthread_mutex_lock(&globGtp.gtp_lock); auto inst=&globGtp.instances[compatInst(instance)]; auto ptrRnti=inst->ue2te_mapping.find(rnti); if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %lx in hashtable ue_mapping\n", rnti); + LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", rnti); pthread_mutex_unlock(&globGtp.gtp_lock); return; } @@ -212,11 +210,11 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, auto ptr=ptrRnti->second.bearers; if ( ptr.find(rab_id) == ptr.end() ) { - LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %lx/%x\n", rnti, rab_id); + LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %x/%x\n", rnti, rab_id); pthread_mutex_unlock(&globGtp.gtp_lock); return; } else - LOG_D(GTPU,"sending a packet to RNTI:RAB:teid %lx/%x/%x, len %lu, oldseq %d, oldnum %d\n", + LOG_D(GTPU,"sending a packet to RNTI:RAB:teid %x/%x/%x, len %lu, oldseq %d, oldnum %d\n", rnti, rab_id,ptr[rab_id].teid_outgoing,length, ptr[rab_id].seqNum,ptr[rab_id].npduNum ); if(seqNumFlag) @@ -236,14 +234,14 @@ static void gtpv1uSend2(instance_t instance, gtpv1u_gnb_tunnel_data_req_t *req, } static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *req) { - uint64_t rnti=req->rnti; + rnti_t rnti=req->rnti; int rab_id=req->rab_id; pthread_mutex_lock(&globGtp.gtp_lock); auto inst=&globGtp.instances[compatInst(instance)]; auto ptrRnti=inst->ue2te_mapping.find(rnti); if ( ptrRnti==inst->ue2te_mapping.end() ) { - LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %lx in hashtable ue_mapping\n", rnti); + LOG_E(GTPU, "gtpv1uSend failed: while getting ue rnti %x in hashtable ue_mapping\n", rnti); pthread_mutex_unlock(&globGtp.gtp_lock); return; } @@ -251,11 +249,11 @@ static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *r auto ptr=ptrRnti->second.bearers; if ( ptr.find(rab_id) == ptr.end() ) { - LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %lx/%x\n", rnti, rab_id); + LOG_E(GTPU,"sending a packet to a non existant RNTI:RAB: %x/%x\n", rnti, rab_id); pthread_mutex_unlock(&globGtp.gtp_lock); return; } else - LOG_D(GTPU,"sending a end packet packet to RNTI:RAB:teid %lx/%x/%x\n", + LOG_D(GTPU,"sending a end packet packet to RNTI:RAB:teid %x/%x/%x\n", rnti, rab_id,ptr[rab_id].teid_outgoing); ocp_gtpv1u_bearer_t tmp=ptr[rab_id]; @@ -277,12 +275,15 @@ static void gtpv1uEndTunnel(instance_t instance, gtpv1u_enb_tunnel_data_req_t *r to.sin_family = AF_INET; to.sin_port = htons(tmp.outgoing_port); to.sin_addr.s_addr = tmp.outgoing_ip_addr; + + char ip4[INET_ADDRSTRLEN]; + //char ip6[INET6_ADDRSTRLEN]; LOG_D(GTPU,"sending end packet to %s\n", inet_ntoa(to.sin_addr) ); if (sendto(compatInst(instance), (void *)&msgHdr, sizeof(msgHdr), 0,(struct sockaddr *)&to, sizeof(to) ) != sizeof(msgHdr)) { LOG_E(GTPU, - "[SD %ld] Failed to send data to " IPV4_ADDR " on port %d, buffer size %lu\n", - compatInst(instance), IPV4_ADDR_FORMAT(tmp.outgoing_ip_addr), tmp.outgoing_port, sizeof(msgHdr)); + "[SD %ld] Failed to send data to %s on port %d, buffer size %lu\n", + compatInst(instance), inet_ntop(AF_INET, &tmp.outgoing_ip_addr, ip4, INET_ADDRSTRLEN), tmp.outgoing_port, sizeof(msgHdr)); } } @@ -386,8 +387,8 @@ instance_t ocp_gtpv1Init(openAddr_t context) { return id; } -teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int bearer_id, teid_t outgoing_teid, - transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { +teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_bearer_id, teid_t outgoing_teid, + transport_layer_addr_t remoteAddr, int port, gtpCallback callBack) { pthread_mutex_lock(&globGtp.gtp_lock); auto inst=&globGtp.instances[instance]; auto it=inst->ue2te_mapping.find(rnti); @@ -400,17 +401,17 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int bearer_id, teid uint32_t incoming_teid=gtpv1uNewTeid(); while ( inst->te2ue_mapping.find(incoming_teid) != inst->te2ue_mapping.end() ) { - LOG_W(GTPU, "generated a random Teid that exists, re-generating (%u)\n",incoming_teid); + LOG_W(GTPU, "generated a random Teid that exists, re-generating (%x)\n",incoming_teid); incoming_teid=gtpv1uNewTeid(); }; inst->te2ue_mapping[incoming_teid].rnti=rnti; - inst->te2ue_mapping[incoming_teid].rb_id= outgoing_teid; + inst->te2ue_mapping[incoming_teid].incoming_rb_id= incoming_bearer_id; inst->te2ue_mapping[incoming_teid].callBack=callBack; - auto tmp=&inst->ue2te_mapping[rnti].bearers[bearer_id]; + auto tmp=&inst->ue2te_mapping[rnti].bearers[outgoing_bearer_id]; int addrs_length_in_bytes = remoteAddr.length / 8; @@ -433,28 +434,39 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int bearer_id, teid default: AssertFatal(false, "SGW Address size impossible"); } - + tmp->teid_incoming = incoming_teid; tmp->outgoing_port=port; tmp->teid_outgoing= outgoing_teid; pthread_mutex_unlock(&globGtp.gtp_lock); - LOG_I(GTPU, "Created tunnel for RNTI %x, teid for DL: %d, teid for UL %d\n", + char ip4[INET_ADDRSTRLEN]; + char ip6[INET6_ADDRSTRLEN]; + + LOG_I(GTPU, "Created tunnel for RNTI %x, teid for DL: %d, teid for UL %d to remote IPv4: %s, IPv6 %s\n", rnti, - tmp->teid_incoming, - tmp->teid_outgoing); + tmp->teid_incoming, + tmp->teid_outgoing, + inet_ntop(AF_INET,(void*)&tmp->outgoing_ip_addr, ip4,INET_ADDRSTRLEN ), + inet_ntop(AF_INET6,(void*)&tmp->outgoing_ip6_addr.s6_addr, ip6, INET6_ADDRSTRLEN)); + return incoming_teid; } int ocp_gtpv1u_create_s1u_tunnel(instance_t instance, const gtpv1u_enb_create_tunnel_req_t *create_tunnel_req, gtpv1u_enb_create_tunnel_resp_t *create_tunnel_resp) { - LOG_D(GTPU, "Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %d\n", + LOG_D(GTPU, "Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %x\n", create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->sgw_S1u_teid[0]); for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { + AssertFatal(create_tunnel_req->eps_bearer_id[i] > 4, + "From legacy code not clear, seems impossible (bearer=%d)\n", + create_tunnel_req->eps_bearer_id[i]); + int incoming_rb_id=create_tunnel_req->eps_bearer_id[i]-4; teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti, + incoming_rb_id, create_tunnel_req->eps_bearer_id[i], create_tunnel_req->sgw_S1u_teid[i], create_tunnel_req->sgw_addr[i], 2152, @@ -477,7 +489,7 @@ int ocp_gtpv1u_update_s1u_tunnel( const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req, const rnti_t prior_rnti ) { - LOG_D(GTPU, "Start update tunnels for old RNTI %x, new RNTI %x, num_tunnels %d, sgw_S1u_teid %d, eps_bearer_id %d\n", + LOG_D(GTPU, "Start update tunnels for old RNTI %x, new RNTI %x, num_tunnels %d, sgw_S1u_teid %x, eps_bearer_id %x\n", prior_rnti, create_tunnel_req->rnti, create_tunnel_req->num_tunnels, @@ -509,13 +521,14 @@ int ocp_gtpv1u_update_s1u_tunnel( int gtpv1u_create_ngu_tunnel( const instance_t instance, const gtpv1u_gnb_create_tunnel_req_t *const create_tunnel_req, gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp) { - LOG_D(GTPU, "Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %d\n", + LOG_D(GTPU, "Start create tunnels for RNTI %x, num_tunnels %d, sgw_S1u_teid %x\n", create_tunnel_req->rnti, create_tunnel_req->num_tunnels, create_tunnel_req->upf_NGu_teid[0]); for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti, + create_tunnel_req->pdusession_id[i], create_tunnel_req->pdusession_id[i], create_tunnel_req->upf_NGu_teid[i], create_tunnel_req->upf_addr[i], 2152, @@ -537,6 +550,7 @@ int gtpv1u_update_ngu_tunnel( const gtpv1u_gnb_create_tunnel_req_t *const create_tunnel_req_pP, const rnti_t prior_rnti ) { + AssertFatal( false, "to be developped\n"); return GTPNOK; } @@ -560,13 +574,18 @@ int newGtpuDeleteTunnel(instance_t instance, rnti_t rnti) { return -1; } + int nb=0; + for (auto j=it->second.bearers.begin(); j!=it->second.bearers.end(); - ++j) + ++j) { inst->te2ue_mapping.erase(j->second.teid_incoming); + nb++; + } inst->ue2te_mapping.erase(it); pthread_mutex_unlock(&globGtp.gtp_lock); + LOG_I(GTPU, "Deleted all tunnels for RNTI %d (%d tunnels deleted)\n", rnti, nb); return !GTPNOK; } @@ -634,7 +653,7 @@ static int Gtpv1uHandleEndMarker(int h, auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid)); if ( tunnel == inst->te2ue_mapping.end() ) { - LOG_E(GTPU,"Received a incoming packet on unknown teid (%d) Dropping!\n", msgHdr->teid); + LOG_E(GTPU,"Received a incoming packet on unknown teid (%x) Dropping!\n", msgHdr->teid); pthread_mutex_unlock(&globGtp.gtp_lock); return GTPNOK; } @@ -653,7 +672,7 @@ static int Gtpv1uHandleEndMarker(int h, ctxt.configured = 0; ctxt.brOption = 0; const srb_flag_t srb_flag=SRB_FLAG_NO; - const rb_id_t rb_id=tunnel->second.rb_id; + const rb_id_t rb_id=tunnel->second.incoming_rb_id; const mui_t mui=RLC_MUI_UNDEFINED; const confirm_t confirm=RLC_SDU_CONFIRM_NO; const pdcp_transmission_mode_t mode=PDCP_TRANSMISSION_MODE_DATA; @@ -695,7 +714,7 @@ static int Gtpv1uHandleGpdu(int h, auto tunnel=inst->te2ue_mapping.find(ntohl(msgHdr->teid)); if ( tunnel == inst->te2ue_mapping.end() ) { - LOG_E(GTPU,"Received a incoming packet on unknown teid (%d) Dropping!\n", msgHdr->teid); + LOG_E(GTPU,"Received a incoming packet on unknown teid (%x) Dropping!\n", msgHdr->teid); pthread_mutex_unlock(&globGtp.gtp_lock); return GTPNOK; } @@ -703,7 +722,7 @@ static int Gtpv1uHandleGpdu(int h, int offset=8; if( msgHdr->E || msgHdr->S ||msgHdr->PN) - offset+=4; + offset+=8; // This context is not good for gtp // frame, ... has no meaning @@ -719,7 +738,7 @@ static int Gtpv1uHandleGpdu(int h, ctxt.configured = 0; ctxt.brOption = 0; const srb_flag_t srb_flag=SRB_FLAG_NO; - const rb_id_t rb_id=tunnel->second.rb_id; + const rb_id_t rb_id=tunnel->second.incoming_rb_id; const mui_t mui=RLC_MUI_UNDEFINED; const confirm_t confirm=RLC_SDU_CONFIRM_NO; const sdu_size_t sdu_buffer_size=msgBufLen-offset; @@ -801,8 +820,8 @@ void gtpv1uReceiver(int h) { void *ocp_gtpv1uTask(void *args) { while(1) { /* Trying to fetch a message from the message queue. - If the queue is empty, this function will block till a - message is sent to the task. + If the queue is empty, this function will block till a + message is sent to the task. */ MessageDef *message_p = NULL; itti_receive_msg(OCP_GTPV1_U, &message_p); diff --git a/openair3/ocp-gtpu/gtp_itf.h b/openair3/ocp-gtpu/gtp_itf.h index 9819ed9485..dd406e27cd 100644 --- a/openair3/ocp-gtpu/gtp_itf.h +++ b/openair3/ocp-gtpu/gtp_itf.h @@ -60,7 +60,7 @@ int ocp_gtpv1u_create_x2u_tunnel( // New API -teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int bearer_id, teid_t teid, +teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer_id, int outgoing_rb_id, teid_t teid, transport_layer_addr_t remoteAddr, int port, gtpCallback callBack); instance_t ocp_gtpv1Init(openAddr_t context); void *ocp_gtpv1uTask(void *args); diff --git a/openshift/oai-physim-image-stream.yml b/openshift/oai-physim-image-stream.yml new file mode 100644 index 0000000000..9ef338f139 --- /dev/null +++ b/openshift/oai-physim-image-stream.yml @@ -0,0 +1,29 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + name: oai-physim +spec: + lookupPolicy: + local: true diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c index 3a69d4c991..2758d01de3 100644 --- a/targets/ARCH/COMMON/common_lib.c +++ b/targets/ARCH/COMMON/common_lib.c @@ -40,7 +40,8 @@ #include "assertions.h" #include "common/utils/load_module_shlib.h" #include "common/utils/LOG/log.h" -#include "targets/RT/USER/lte-softmodem.h" +//#include "targets/RT/USER/lte-softmodem.h" +#include "executables/softmodem-common.h" char *get_devname(int devtype) { char *devnames[MAX_RF_DEV_TYPE]=DEVTYPE_NAMES; diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h index 2ab6d29d30..7b934822ea 100644 --- a/targets/ARCH/COMMON/common_lib.h +++ b/targets/ARCH/COMMON/common_lib.h @@ -561,7 +561,10 @@ extern int read_recplayconfig(recplay_conf_t **recplay_conf, recplay_state_t **r extern void iqrecorder_end(openair0_device *device); +#include +#ifndef gettid #define gettid() syscall(__NR_gettid) +#endif /*@}*/ diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c index 2dfb4a7bf1..ee0dce48f0 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c @@ -45,7 +45,6 @@ #include "common_lib.h" #include "ethernet_lib.h" -#include "common/ran_context.h" //#define DEBUG 1 @@ -414,7 +413,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi char *temp_rx0 = ((char *)&temp_rx[1])-APP_HEADER_SIZE_BYTES; #endif #elif defined(__arm__) || defined(__aarch64__) - int nsamps2 = (payload_size>>4)+1 + int nsamps2 = (payload_size>>4)+1; int16x8_t temp_rx[nsamps2]; char *temp_rx0 = ((char *)&temp_rx[1])-APP_HEADER_SIZE_BYTES; #else diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c index f35a18eb0e..dce410de47 100644 --- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c +++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "common_lib.h" #include "ethernet_lib.h" diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index 351813e7c9..877f607990 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -385,14 +385,14 @@ static int trx_usrp_write(openair0_device *device, #if defined(__x86_64) || defined(__i386__) #ifdef __AVX2__ nsamps2 = (nsamps+7)>>3; - __m256i buff_tx[8][nsamps2]; + __m256i buff_tx[cc<2?2:cc][nsamps2]; #else nsamps2 = (nsamps+3)>>2; - __m128i buff_tx[8][nsamps2]; + __m128i buff_tx[cc<2?2:cc][nsamps2]; #endif #elif defined(__arm__) nsamps2 = (nsamps+3)>>2; - int16x8_t buff_tx[8][nsamps2]; + int16x8_t buff_tx[cc<2?2:cc][nsamps2]; #else #error Unsupported CPU architecture, USRP device cannot be built #endif @@ -464,6 +464,7 @@ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_BEAM_SWITCHI write_package[end].buff[i] = buff[i]; write_thread->count_write++; write_thread->end = (write_thread->end + 1)% MAX_WRITE_THREAD_PACKAGE; + LOG_D(HW,"Signaling TX TS %llu\n",(unsigned long long)timestamp); pthread_cond_signal(&write_thread->cond_write); pthread_mutex_unlock(&write_thread->mutex_write); return 0; @@ -522,14 +523,14 @@ void *trx_usrp_write_thread(void * arg){ #if defined(__x86_64) || defined(__i386__) #ifdef __AVX2__ nsamps2 = (nsamps+7)>>3; - __m256i buff_tx[8][nsamps2]; + __m256i buff_tx[cc<2?2:cc][nsamps2]; #else nsamps2 = (nsamps+3)>>2; - __m128i buff_tx[8][nsamps2]; + __m128i buff_tx[cc<2?2:cc][nsamps2]; #endif #elif defined(__arm__) nsamps2 = (nsamps+3)>>2; - int16x8_t buff_tx[8][nsamps2]; + int16x8_t buff_tx[cc<2?2:cc][nsamps2]; #else #error Unsupported CPU architecture, USRP device cannot be built #endif @@ -623,40 +624,53 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp #if defined(__x86_64) || defined(__i386__) #ifdef __AVX2__ nsamps2 = (nsamps+7)>>3; - __m256i buff_tmp[2][nsamps2]; + __m256i buff_tmp[cc<2 ? 2 : cc][nsamps2]; #else nsamps2 = (nsamps+3)>>2; - __m128i buff_tmp[2][nsamps2]; + __m128i buff_tmp[cc<2 ? 2 : cc][nsamps2]; #endif #elif defined(__arm__) nsamps2 = (nsamps+3)>>2; - int16x8_t buff_tmp[2][nsamps2]; + int16x8_t buff_tmp[cc<2 ? 2 : cc][nsamps2]; #endif - if (cc>1) { + int rxshift; + switch (device->type) { + case USRP_B200_DEV: + rxshift=4; + break; + case USRP_X300_DEV: + case USRP_N300_DEV: + rxshift=2; + break; + default: + AssertFatal(1==0,"Shouldn't be here\n"); + } + + samples_received=0; + while (samples_received != nsamps) { + + if (cc>1) { // receive multiple channels (e.g. RF A and RF B) - std::vector buff_ptrs; + std::vector buff_ptrs; - for (int i=0; irx_stream->recv(buff_ptrs, nsamps, s->rx_md); - } else { + samples_received += s->rx_stream->recv(buff_ptrs, nsamps, s->rx_md); + } else { // receive a single channel (e.g. from connector RF A) - samples_received=0; - while (samples_received != nsamps) { samples_received += s->rx_stream->recv((void*)((int32_t*)buff_tmp[0]+samples_received), nsamps-samples_received, s->rx_md); - - if ((s->wait_for_first_pps == 0) && (s->rx_md.error_code!=uhd::rx_metadata_t::ERROR_CODE_NONE)) - break; - - if ((s->wait_for_first_pps == 1) && (samples_received != nsamps)) { - printf("sleep...\n"); //usleep(100); - } } - if (samples_received == nsamps) s->wait_for_first_pps=0; + if ((s->wait_for_first_pps == 0) && (s->rx_md.error_code!=uhd::rx_metadata_t::ERROR_CODE_NONE)) + break; + + if ((s->wait_for_first_pps == 1) && (samples_received != nsamps)) { + printf("sleep...\n"); //usleep(100); + } } + if (samples_received == nsamps) s->wait_for_first_pps=0; // bring RX data into 12 LSBs for softmodem RX for (int i=0; iusrp->get_rx_gain_range(i); // limit to maximum gain - AssertFatal( openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i] <= gain_range.stop(), - "RX Gain too high, lower by %f dB\n", - openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i] - gain_range.stop()); - s->usrp->set_rx_gain(openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],i); + double gain=openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i]; + if ( gain > gain_range.stop()) { + LOG_E(HW,"RX Gain too high, lower by %f dB\n", + gain - gain_range.stop()); + gain=gain_range.stop(); + } + + s->usrp->set_rx_gain(gain,i); LOG_I(HW,"RX Gain %d %f (%f) => %f (max %f)\n",i, openair0_cfg[0].rx_gain[i],openair0_cfg[0].rx_gain_offset[i], openair0_cfg[0].rx_gain[i]-openair0_cfg[0].rx_gain_offset[i],gain_range.stop()); @@ -1284,8 +1302,10 @@ extern "C" { LOG_I(HW,"rx_max_num_samps %zu\n", s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps()); - for (int i = 0; irx_stream = s->usrp->get_rx_stream(stream_args_rx); uhd::stream_args_t stream_args_tx("sc16", "sc16"); diff --git a/targets/ARCH/rfsimulator/simulator.c b/targets/ARCH/rfsimulator/simulator.c index f80f77f39c..3bd4285cff 100644 --- a/targets/ARCH/rfsimulator/simulator.c +++ b/targets/ARCH/rfsimulator/simulator.c @@ -61,10 +61,7 @@ #define MAX_SIMULATION_CONNECTED_NODES 5 #define GENERATE_CHANNEL 10 //each frame in DL -// Fixme: datamodel, external variables in .h files, ... -#include -extern RAN_CONTEXT_t RC; // #define RFSIMU_SECTION "rfsimulator" diff --git a/targets/COMMON/openairinterface5g_limits.h b/targets/COMMON/openairinterface5g_limits.h index ad98a6091b..de1502112b 100644 --- a/targets/COMMON/openairinterface5g_limits.h +++ b/targets/COMMON/openairinterface5g_limits.h @@ -6,23 +6,39 @@ # define NUMBER_OF_gNB_MAX 1 # define NUMBER_OF_RU_MAX 2 # define NUMBER_OF_NR_RU_MAX 2 +# define NUMBER_OF_UCI_MAX 16 +# define NUMBER_OF_ULSCH_MAX 8 +# define NUMBER_OF_DLSCH_MAX 8 +# define NUMBER_OF_SRS_MAX 16 +# define NUMBER_OF_NR_ULSCH_MAX 8 +# define NUMBER_OF_NR_DLSCH_MAX 8 +# define NUMBER_OF_NR_UCI_MAX 16 +# define nUMBER_OF_NR_SRS_MAX 16 +# define NUMBER_OF_SCH_STATS_MAX 16 + +# define NUMBER_OF_NR_SCH_STATS_MAX 16 + +# define NUMBER_OF_NR_PUCCH_MAX 16 +# define NUMBER_OF_NR_SR_MAX 16 +# define NUMBER_OF_NR_PDCCH_MAX 16 + +#define MAX_MANAGED_ENB_PER_MOBILE 2 +#define MAX_MANAGED_GNB_PER_MOBILE 2 + # ifndef PHYSIM # ifndef UE_EXPANSION # define NUMBER_OF_UE_MAX 4 # define NUMBER_OF_NR_UE_MAX 4 -# define NUMBER_OF_UCI_VARS_MAX 14 # define NUMBER_OF_CONNECTED_eNB_MAX 1 # define NUMBER_OF_CONNECTED_gNB_MAX 1 # else # define NUMBER_OF_UE_MAX 256 -# define NUMBER_OF_UCI_VARS_MAX 256 # define NUMBER_OF_CONNECTED_eNB_MAX 1 # define NUMBER_OF_CONNECTED_gNB_MAX 1 # endif # else # define NUMBER_OF_UE_MAX 4 # define NUMBER_OF_NR_UE_MAX 4 -# define NUMBER_OF_UCI_VARS_MAX 56 # define NUMBER_OF_CONNECTED_eNB_MAX 1 # define NUMBER_OF_CONNECTED_gNB_MAX 1 # endif diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf index a426c39a7a..cc44ffd27b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/benetel-5g.conf @@ -15,7 +15,8 @@ gNBs = // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({mcc = 222; mnc = 01; mnc_length = 2;}); + #plmn_list = ({mcc = 222; mnc = 01; mnc_length = 2;}); + plmn_list = ({mcc = 208; mnc = 99; mnc_length = 2;}); tr_s_preference = "local_mac" @@ -92,9 +93,9 @@ gNBs = prach_msg1_FDM = 0; prach_msg1_FrequencyStart = 74; zeroCorrelationZoneConfig = 13; - preambleReceivedTargetPower = -118; + #preambleReceivedTargetPower = -118; #preambleReceivedTargetPower = -104; - #preambleReceivedTargetPower = -108; + preambleReceivedTargetPower = -108; #preamblTransMax (0...10) = (3,4,5,6,7,8,10,20,50,100,200) preambleTransMax = 6; #powerRampingStep @@ -124,13 +125,13 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; # used for UL slot + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - initialULBWPstartSymbolAndLength_0 = 55; # this is SS=0 L=12 + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; # used for mixed slot + initialULBWPk2_1 = 2; # used for mixed slot initialULBWPmappingType_1 = 1; - initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; @@ -196,7 +197,7 @@ gNBs = ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.18.99"; + mme_ip_address = ( { ipv4 = "192.168.18.150"; #"192.168.18.99"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf deleted file mode 100644 index 5fd4b465b3..0000000000 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band22.tm1.106PRB.adrv9371zc706.conf +++ /dev/null @@ -1,289 +0,0 @@ -Active_gNBs = ( "gNB-Eurecom-5GNRBox"); -# Asn1_verbosity, choice in: none, info, annoying -Asn1_verbosity = "none"; - -gNBs = -( - { - ////////// Identification parameters: - gNB_ID = 0xe00; - - cell_type = "CELL_MACRO_GNB"; - - gNB_name = "gNB-Eurecom-5GNRBox"; - - // Tracking area code, 0x0000 and 0xfffe are reserved values - tracking_area_code = 1; - - plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); - - tr_s_preference = "local_mac" - - ////////// Physical parameters: - - component_carriers = ( - { - node_function = "3GPP_gNODEB"; - node_timing = "synch_to_ext_device"; - node_synch_ref = 0; - frame_type = "TDD"; - DL_prefix_type = "NORMAL"; - UL_prefix_type = "NORMAL"; - eutra_band = 78; - downlink_frequency = 3510000000L; - uplink_frequency_offset = -120000000; - Nid_cell = 0; - N_RB_DL = 106; - nb_antenna_ports = 1; - nb_antennas_tx = 1; - nb_antennas_rx = 1; - tx_gain = 90; - rx_gain = 125; - MIB_subCarrierSpacingCommon = 30; - MIB_ssb_SubcarrierOffset = 0; - MIB_dmrs_TypeA_Position = 2; - pdcch_ConfigSIB1 = 0; - SIB1_frequencyOffsetSSB = "khz5"; - SIB1_ssb_PeriodicityServingCell = 5; - SIB1_ss_PBCH_BlockPower = -60; - absoluteFrequencySSB = 0; - DL_FreqBandIndicatorNR = 15; - DL_absoluteFrequencyPointA = 15; - DL_offsetToCarrier = 15; - DL_SCS_SubcarrierSpacing = "kHz30"; - DL_SCS_SpecificCarrier_k0 = 0; - DL_carrierBandwidth = 15; - DL_locationAndBandwidth = 15; - DL_BWP_SubcarrierSpacing = "kHz30"; - DL_BWP_prefix_type = "NORMAL"; - UL_FreqBandIndicatorNR = 15; - UL_absoluteFrequencyPointA = 13; - UL_additionalSpectrumEmission = 3; - UL_p_Max = -1; - UL_frequencyShift7p5khz = "TRUE"; - UL_offsetToCarrier = 10; - UL_SCS_SubcarrierSpacing = "kHz30"; - UL_SCS_SpecificCarrier_k0 = 0; - UL_carrierBandwidth = 15; - UL_locationAndBandwidth = 15; - UL_BWP_SubcarrierSpacing = "kHz30"; - UL_BWP_prefix_type = "NORMAL"; - UL_timeAlignmentTimerCommon = "infinity"; - ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" - ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 10; - ServingCellConfigCommon_dmrs_TypeA_Position = 2; - NIA_SubcarrierSpacing = "kHz15"; - ServingCellConfigCommon_ss_PBCH_BlockPower = -60; - referenceSubcarrierSpacing = "kHz15"; - dl_UL_TransmissionPeriodicity = "ms0p5"; - nrofDownlinkSlots = 10; - nrofDownlinkSymbols = 10; - nrofUplinkSlots = 10; - nrofUplinkSymbols = 10; - rach_totalNumberOfRA_Preambles = 63; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice = "oneEighth"; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth = 4; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth = 8; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf = 16; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one = 24; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two = 32; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four = 8; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight = 4; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen = 2; - rach_groupBconfigured = "ENABLE"; - rach_ra_Msg3SizeGroupA = 56; - rach_messagePowerOffsetGroupB = "dB0"; - rach_numberOfRA_PreamblesGroupA = 32; - rach_ra_ContentionResolutionTimer = 8; - rsrp_ThresholdSSB = 64; - rsrp_ThresholdSSB_SUL = 64; - prach_RootSequenceIndex_choice = "l839"; - prach_RootSequenceIndex_l839 = 0; - prach_RootSequenceIndex_l139 = 0; - prach_msg1_SubcarrierSpacing = "kHz30"; - restrictedSetConfig = "unrestrictedSet"; - msg3_transformPrecoding = "ENABLE"; - prach_ConfigurationIndex = 10; - prach_msg1_FDM = "one"; - prach_msg1_FrequencyStart = 10; - zeroCorrelationZoneConfig = 10; - preambleReceivedTargetPower = -150; - preambleTransMax = 6; - powerRampingStep = "dB0"; - ra_ResponseWindow = 8; - groupHoppingEnabledTransformPrecoding = "ENABLE"; - msg3_DeltaPreamble = 0; - p0_NominalWithGrant = 0; - PUSCH_TimeDomainResourceAllocation_k2 = 0; - PUSCH_TimeDomainResourceAllocation_mappingType = "typeA"; - PUSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; - pucch_ResourceCommon = 0; - pucch_GroupHopping = "neither"; - hoppingId = 0; - p0_nominal = -30; - PDSCH_TimeDomainResourceAllocation_k0 = 2; - PDSCH_TimeDomainResourceAllocation_mappingType = "typeA"; - PDSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; - rateMatchPatternId = 0; - RateMatchPattern_patternType = "bitmaps"; - symbolsInResourceBlock = "oneSlot"; - periodicityAndPattern = 2; - RateMatchPattern_controlResourceSet = 5; - RateMatchPattern_subcarrierSpacing = "kHz30"; - RateMatchPattern_mode = "dynamic"; - controlResourceSetZero = 0; - searchSpaceZero = 0; - searchSpaceSIB1 = 10; - searchSpaceOtherSystemInformation = 10; - pagingSearchSpace = 10; - ra_SearchSpace = 10; - PDCCH_common_controlResourceSetId = 5; - PDCCH_common_ControlResourceSet_duration = 2; - PDCCH_cce_REG_MappingType = "nonInterleaved"; - PDCCH_reg_BundleSize = 3; - PDCCH_interleaverSize = 3; - PDCCH_shiftIndex = 10; - PDCCH_precoderGranularity = "sameAsREG-bundle"; - PDCCH_TCI_StateId = 32; - tci_PresentInDCI = "ENABLE"; - PDCCH_DMRS_ScramblingID = 0; - SearchSpaceId = 10; - commonSearchSpaces_controlResourceSetId = 5; - SearchSpace_monitoringSlotPeriodicityAndOffset_choice = "sl1"; - SearchSpace_monitoringSlotPeriodicityAndOffset_value = 0; - SearchSpace_duration = 2; - SearchSpace_nrofCandidates_aggregationLevel1 = 0; - SearchSpace_nrofCandidates_aggregationLevel2 = 0; - SearchSpace_nrofCandidates_aggregationLevel4 = 0; - SearchSpace_nrofCandidates_aggregationLevel8 = 0; - SearchSpace_nrofCandidates_aggregationLevel16 = 0; - SearchSpace_searchSpaceType = "common"; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 = 1; - Common_dci_Format2_3_monitoringPeriodicity = 1; - Common_dci_Format2_3_nrofPDCCH_Candidates = 1; - ue_Specific__dci_Formats = "formats0-0-And-1-0"; - RateMatchPatternLTE_CRS_carrierFreqDL = 6; - RateMatchPatternLTE_CRS_carrierBandwidthDL = 6; - RateMatchPatternLTE_CRS_nrofCRS_Ports = 1; - RateMatchPatternLTE_CRS_v_Shift = 0; - RateMatchPatternLTE_CRS_radioframeAllocationPeriod = 1; - RateMatchPatternLTE_CRS_radioframeAllocationOffset = 0; - RateMatchPatternLTE_CRS_subframeAllocation_choice = "oneFrame"; - } - ); - - - srb1_parameters : - { - # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] - timer_poll_retransmit = 80; - - # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] - timer_reordering = 35; - - # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] - timer_status_prohibit = 0; - - # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] - poll_pdu = 4; - - # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] - poll_byte = 99999; - - # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] - max_retx_threshold = 4; - } - - # ------- SCTP definitions - SCTP : - { - # Number of streams to use in input/output - SCTP_INSTREAMS = 2; - SCTP_OUTSTREAMS = 2; - }; - - - ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.12.26"; - ipv6 = "192:168:30::17"; - active = "yes"; - preference = "ipv4"; - } - ); - - NETWORK_INTERFACES : - { - - GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; - GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; - GNB_PORT_FOR_S1U = 2152; # Spec 2152 - }; - } -); - -MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - } -); - -L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - } -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 0 - att_rx = 0; - bands = [7]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 114; - eNB_instances = [0]; - sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,mgmt_addr=192.168.100.8"; - - } -); - -NETWORK_CONTROLLER : -{ - FLEXRAN_ENABLED = "no"; - FLEXRAN_INTERFACE_NAME = "lo"; - FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; - FLEXRAN_PORT = 2210; - FLEXRAN_CACHE = "/mnt/oai_agent_cache"; - FLEXRAN_AWAIT_RECONF = "no"; -}; - - log_config : - { - global_log_level ="info"; - global_log_verbosity ="medium"; - hw_log_level ="info"; - hw_log_verbosity ="medium"; - phy_log_level ="info"; - phy_log_verbosity ="medium"; - mac_log_level ="info"; - mac_log_verbosity ="high"; - rlc_log_level ="info"; - rlc_log_verbosity ="medium"; - pdcp_log_level ="info"; - pdcp_log_verbosity ="medium"; - rrc_log_level ="info"; - rrc_log_verbosity ="medium"; - }; - diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf index 477240a3a0..e0b721bf5e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpn300.conf @@ -58,27 +58,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_3 = 0; #for mixed slot + initialDLBWPmappingType_3 = 0; + initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 261; @@ -135,8 +122,7 @@ gNBs = # pusch-ConfigCommon (up to 16 elements) initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf index 8b1079350b..bf581f78ba 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.32PRB.usrpx300.conf @@ -58,27 +58,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 257; @@ -133,20 +120,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 4; + initialULBWPk2_2 = 4; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf index 3bfcc01703..e018aef006 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band257.tm1.66PRB.usrpn300.conf @@ -56,22 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot (but is not used here) + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 257; @@ -126,15 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 2; # used for mixed slot (not used here) initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf index e1bf1b9818..a2233b72bc 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band261.tm1.32PRB.usrpn300.conf @@ -58,27 +58,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 261; @@ -133,20 +120,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 4; + initialULBWPk2_2 = 4; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf index ceba30dacf..2028f40552 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpn300.conf @@ -56,27 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 66; @@ -132,20 +119,18 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf index 115ed6f6f0..35c4924ba1 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band66.tm1.106PRB.usrpx300.conf @@ -56,27 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 66; @@ -132,20 +119,18 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 + msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf index b83999f25e..f90adae46b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.30kHz,usrpb2x0.conf @@ -56,22 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -126,16 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + initialULBWPk2_1 = 2; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf index 27ade965dc..aa61153c93 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.106PRB.slave.conf @@ -56,27 +56,13 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 - initialDLBWPstartSymbolAndLength_3 = 57; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -132,21 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 2; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf index 9bb9132917..a0ee7f8a6d 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.slave.conf @@ -56,22 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot (but not used here) + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -126,16 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + initialULBWPk2_1 = 2; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 63; # this is SS=7 L=5 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 91; # this is SS=7 L=7 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf index ffced2055a..d08234ab16 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.PTRS.usrpx300.conf @@ -56,27 +56,13 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 - initialDLBWPstartSymbolAndLength_3 = 57; + initialDLBWPk0_3 = 0; #for mixed slot + initialDLBWPmappingType_3 = 0; + initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -134,8 +120,7 @@ gNBs = # pusch-ConfigCommon (up to 16 elements) initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf deleted file mode 100644 index 5610694d7d..0000000000 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.adrv9371zc706.conf +++ /dev/null @@ -1,288 +0,0 @@ -Active_gNBs = ( "gNB-Eurecom-5GNRBox"); -# Asn1_verbosity, choice in: none, info, annoying -Asn1_verbosity = "none"; - -gNBs = -( - { - ////////// Identification parameters: - gNB_ID = 0xe00; - - cell_type = "CELL_MACRO_GNB"; - - gNB_name = "gNB-Eurecom-5GNRBox"; - - // Tracking area code, 0x0000 and 0xfffe are reserved values - tracking_area_code = 1; - - plmn_list = ({mcc = 208; mnc = 93; mnc_length = 2;}); - - tr_s_preference = "local_mac" - - ////////// Physical parameters: - - component_carriers = ( - { - node_function = "3GPP_gNODEB"; - node_timing = "synch_to_ext_device"; - node_synch_ref = 0; - frame_type = "TDD"; - DL_prefix_type = "NORMAL"; - UL_prefix_type = "NORMAL"; - eutra_band = 78; - downlink_frequency = 3510000000L; - uplink_frequency_offset = 0; - Nid_cell = 0; - N_RB_DL = 106; - nb_antenna_ports = 1; - nb_antennas_tx = 1; - nb_antennas_rx = 1; - tx_gain = 90; - rx_gain = 125; - MIB_subCarrierSpacingCommon = 30; - MIB_ssb_SubcarrierOffset = 0; - MIB_dmrs_TypeA_Position = 2; - pdcch_ConfigSIB1 = 0; - SIB1_frequencyOffsetSSB = "khz5"; - SIB1_ssb_PeriodicityServingCell = 5; - SIB1_ss_PBCH_BlockPower = -60; - absoluteFrequencySSB = 0; - DL_FreqBandIndicatorNR = 15; - DL_absoluteFrequencyPointA = 15; - DL_offsetToCarrier = 15; - DL_SCS_SubcarrierSpacing = "kHz30"; - DL_SCS_SpecificCarrier_k0 = 0; - DL_carrierBandwidth = 15; - DL_locationAndBandwidth = 15; - DL_BWP_SubcarrierSpacing = "kHz30"; - DL_BWP_prefix_type = "NORMAL"; - UL_FreqBandIndicatorNR = 15; - UL_absoluteFrequencyPointA = 13; - UL_additionalSpectrumEmission = 3; - UL_p_Max = -1; - UL_frequencyShift7p5khz = "TRUE"; - UL_offsetToCarrier = 10; - UL_SCS_SubcarrierSpacing = "kHz30"; - UL_SCS_SpecificCarrier_k0 = 0; - UL_carrierBandwidth = 15; - UL_locationAndBandwidth = 15; - UL_BWP_SubcarrierSpacing = "kHz30"; - UL_BWP_prefix_type = "NORMAL"; - UL_timeAlignmentTimerCommon = "infinity"; - ServingCellConfigCommon_n_TimingAdvanceOffset = "n0" - ServingCellConfigCommon_ssb_PositionsInBurst_PR = 0x01; - ServingCellConfigCommon_ssb_periodicityServingCell = 10; - ServingCellConfigCommon_dmrs_TypeA_Position = 2; - NIA_SubcarrierSpacing = "kHz15"; - ServingCellConfigCommon_ss_PBCH_BlockPower = -60; - referenceSubcarrierSpacing = "kHz15"; - dl_UL_TransmissionPeriodicity = "ms0p5"; - nrofDownlinkSlots = 10; - nrofDownlinkSymbols = 10; - nrofUplinkSlots = 10; - nrofUplinkSymbols = 10; - rach_totalNumberOfRA_Preambles = 63; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_choice = "oneEighth"; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneEighth = 4; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneFourth = 8; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_oneHalf = 16; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_one = 24; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_two = 32; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_four = 8; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_eight = 4; - rach_ssb_perRACH_OccasionAndCB_PreamblesPerSSB_sixteen = 2; - rach_groupBconfigured = "ENABLE"; - rach_ra_Msg3SizeGroupA = 56; - rach_messagePowerOffsetGroupB = "dB0"; - rach_numberOfRA_PreamblesGroupA = 32; - rach_ra_ContentionResolutionTimer = 8; - rsrp_ThresholdSSB = 64; - rsrp_ThresholdSSB_SUL = 64; - prach_RootSequenceIndex_choice = "l839"; - prach_RootSequenceIndex_l839 = 0; - prach_RootSequenceIndex_l139 = 0; - prach_msg1_SubcarrierSpacing = "kHz30"; - restrictedSetConfig = "unrestrictedSet"; - msg3_transformPrecoding = "ENABLE"; - prach_ConfigurationIndex = 10; - prach_msg1_FDM = "one"; - prach_msg1_FrequencyStart = 10; - zeroCorrelationZoneConfig = 10; - preambleReceivedTargetPower = -150; - preambleTransMax = 6; - powerRampingStep = "dB0"; - ra_ResponseWindow = 8; - groupHoppingEnabledTransformPrecoding = "ENABLE"; - msg3_DeltaPreamble = 0; - p0_NominalWithGrant = 0; - PUSCH_TimeDomainResourceAllocation_k2 = 0; - PUSCH_TimeDomainResourceAllocation_mappingType = "typeA"; - PUSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; - pucch_ResourceCommon = 0; - pucch_GroupHopping = "neither"; - hoppingId = 0; - p0_nominal = -30; - PDSCH_TimeDomainResourceAllocation_k0 = 2; - PDSCH_TimeDomainResourceAllocation_mappingType = "typeA"; - PDSCH_TimeDomainResourceAllocation_startSymbolAndLength = 0; - rateMatchPatternId = 0; - RateMatchPattern_patternType = "bitmaps"; - symbolsInResourceBlock = "oneSlot"; - periodicityAndPattern = 2; - RateMatchPattern_controlResourceSet = 5; - RateMatchPattern_subcarrierSpacing = "kHz30"; - RateMatchPattern_mode = "dynamic"; - controlResourceSetZero = 0; - searchSpaceZero = 0; - searchSpaceSIB1 = 10; - searchSpaceOtherSystemInformation = 10; - pagingSearchSpace = 10; - ra_SearchSpace = 10; - PDCCH_common_controlResourceSetId = 5; - PDCCH_common_ControlResourceSet_duration = 2; - PDCCH_cce_REG_MappingType = "nonInterleaved"; - PDCCH_reg_BundleSize = 3; - PDCCH_interleaverSize = 3; - PDCCH_shiftIndex = 10; - PDCCH_precoderGranularity = "sameAsREG-bundle"; - PDCCH_TCI_StateId = 32; - tci_PresentInDCI = "ENABLE"; - PDCCH_DMRS_ScramblingID = 0; - SearchSpaceId = 10; - commonSearchSpaces_controlResourceSetId = 5; - SearchSpace_monitoringSlotPeriodicityAndOffset_choice = "sl1"; - SearchSpace_monitoringSlotPeriodicityAndOffset_value = 0; - SearchSpace_duration = 2; - SearchSpace_nrofCandidates_aggregationLevel1 = 0; - SearchSpace_nrofCandidates_aggregationLevel2 = 0; - SearchSpace_nrofCandidates_aggregationLevel4 = 0; - SearchSpace_nrofCandidates_aggregationLevel8 = 0; - SearchSpace_nrofCandidates_aggregationLevel16 = 0; - SearchSpace_searchSpaceType = "common"; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel1 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel2 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel4 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel8 = 1; - Common_dci_Format2_0_nrofCandidates_SFI_aggregationLevel16 = 1; - Common_dci_Format2_3_monitoringPeriodicity = 1; - Common_dci_Format2_3_nrofPDCCH_Candidates = 1; - ue_Specific__dci_Formats = "formats0-0-And-1-0"; - RateMatchPatternLTE_CRS_carrierFreqDL = 6; - RateMatchPatternLTE_CRS_carrierBandwidthDL = 6; - RateMatchPatternLTE_CRS_nrofCRS_Ports = 1; - RateMatchPatternLTE_CRS_v_Shift = 0; - RateMatchPatternLTE_CRS_radioframeAllocationPeriod = 1; - RateMatchPatternLTE_CRS_radioframeAllocationOffset = 0; - RateMatchPatternLTE_CRS_subframeAllocation_choice = "oneFrame"; - } - ); - - - srb1_parameters : - { - # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] - timer_poll_retransmit = 80; - - # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] - timer_reordering = 35; - - # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] - timer_status_prohibit = 0; - - # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] - poll_pdu = 4; - - # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] - poll_byte = 99999; - - # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] - max_retx_threshold = 4; - } - - # ------- SCTP definitions - SCTP : - { - # Number of streams to use in input/output - SCTP_INSTREAMS = 2; - SCTP_OUTSTREAMS = 2; - }; - - - ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.12.26"; - ipv6 = "192:168:30::17"; - active = "yes"; - preference = "ipv4"; - } - ); - - NETWORK_INTERFACES : - { - - GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; - GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; - GNB_PORT_FOR_S1U = 2152; # Spec 2152 - }; - } -); - -MACRLCs = ( - { - num_cc = 1; - tr_s_preference = "local_L1"; - tr_n_preference = "local_RRC"; - } -); - -L1s = ( - { - num_cc = 1; - tr_n_preference = "local_mac"; - } -); - -RUs = ( - { - local_rf = "yes" - nb_tx = 1 - nb_rx = 1 - att_tx = 0 - att_rx = 0; - bands = [7]; - max_pdschReferenceSignalPower = -27; - max_rxgain = 114; - eNB_instances = [0]; - sdr_addrs = "addr=192.168.10.2,second_addr=192.168.20.2,mgmt_addr=192.168.100.8"; - - } -); - -NETWORK_CONTROLLER : -{ - FLEXRAN_ENABLED = "no"; - FLEXRAN_INTERFACE_NAME = "lo"; - FLEXRAN_IPV4_ADDRESS = "127.0.0.1"; - FLEXRAN_PORT = 2210; - FLEXRAN_CACHE = "/mnt/oai_agent_cache"; - FLEXRAN_AWAIT_RECONF = "no"; -}; - - log_config : - { - global_log_level ="info"; - global_log_verbosity ="medium"; - hw_log_level ="info"; - hw_log_verbosity ="medium"; - phy_log_level ="info"; - phy_log_verbosity ="medium"; - mac_log_level ="info"; - mac_log_verbosity ="high"; - rlc_log_level ="info"; - rlc_log_verbosity ="medium"; - pdcp_log_level ="info"; - pdcp_log_verbosity ="medium"; - rrc_log_level ="info"; - rrc_log_verbosity ="medium"; - }; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf index b517bea8ee..f22d5f781f 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpb210.conf @@ -56,22 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=2,L=3 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -126,16 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + initialULBWPk2_1 = 2; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf index 7080aff8ea..b57cb00779 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf @@ -33,7 +33,7 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP), points to Subcarrier 0 of RB#10 of SSB block absoluteFrequencySSB = 641032; dl_frequencyBand = 78; # this is 3600 MHz @@ -46,37 +46,23 @@ gNBs = dl_carrierBandwidth = 106; #initialDownlinkBWP #genericParameters - # this is RBstart=41,L=24 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 6368; + # this is RBstart=33 (Start RB of SSB block),L=24 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6358; #6368; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 0; #12; initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; # used for (full) DL slot + initialDLBWPmappingType_0 = 0; # 0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; # this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; + initialDLBWPk0_1 = 0; # used for DL part mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; # this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -90,7 +76,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 6368; + initialULBWPlocationAndBandwidth = 6358;#6368; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -132,20 +118,17 @@ gNBs = restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for (full) UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for UL part mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf index 4039012fe1..862185835e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpx300.conf @@ -33,7 +33,7 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP) + # this is 3600 MHz + 43 PRBs@30kHz SCS (same as initial BWP). points to Subcarrier 0 of RB#10 of SSB block absoluteFrequencySSB = 641032; dl_frequencyBand = 78; # this is 3600 MHz @@ -46,37 +46,24 @@ gNBs = dl_carrierBandwidth = 106; #initialDownlinkBWP #genericParameters - # this is RBstart=0,L=50 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 6368; + # this is RBstart=33 (Start RB of SSB block),L=24 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 6358; #6368; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -90,7 +77,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 6368; + initialULBWPlocationAndBandwidth = 6358; #6368; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -132,20 +119,17 @@ gNBs = restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf index 20e8aabf98..335c3d9f0b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpn300.conf @@ -33,7 +33,7 @@ gNBs = # downlinkConfigCommon #frequencyInfoDL - # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP) + # this is 3600 MHz + 84 PRBs@30kHz SCS (same as initial BWP). Points to Subcarrier 0 of RB#10 of SSB block absoluteFrequencySSB = 642016;#642364; dl_frequencyBand = 78; # this is 3600 MHz @@ -46,37 +46,24 @@ gNBs = dl_carrierBandwidth = 217; #initialDownlinkBWP #genericParameters - # this is RBstart=84,L=50 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 13559; + # this is RBstart=74 (Start RB of SSB block),L=50 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 13549; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -89,7 +76,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 13559; + initialULBWPlocationAndBandwidth = 13549; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -131,21 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; #2; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 6; #2; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -250,6 +233,7 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; + pusch_proc_threads = 8; } ); @@ -292,7 +276,7 @@ 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 ="info"; mac_log_verbosity ="high"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf index fc8bda5d53..bf75edc360 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.217PRB.usrpx300.conf @@ -46,37 +46,24 @@ gNBs = dl_carrierBandwidth = 217; #initialDownlinkBWP #genericParameters - # this is RBstart=84,L=50 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 13559; + # this is RBstart=74,L=50 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 13549; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -89,7 +76,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 13559; + initialULBWPlocationAndBandwidth = 13549; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -131,16 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + initialULBWPk2_1 = 2; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA + initialULBWPmappingType_2 = 1; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -229,6 +217,7 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; + pusch_proc_threads = 8; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf index 89dda14e20..b4f40d2205 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpb210.conf @@ -56,27 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_3 = 0; #for mixed slot + initialDLBWPmappingType_3 = 0; + initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -134,17 +121,14 @@ gNBs = # pusch-ConfigCommon (up to 16 elements) initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 initialULBWPstartSymbolAndLength_1 = 69; initialULBWPk2_2 = 7; initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf index 7954b3c201..639b11828b 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpn300.conf @@ -56,27 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_3 = 0; #for mixed slot + initialDLBWPmappingType_3 = 0; + initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -134,17 +121,14 @@ gNBs = # pusch-ConfigCommon (up to 16 elements) initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 initialULBWPstartSymbolAndLength_1 = 69; initialULBWPk2_2 = 7; initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf index bd88ed88c7..b93b530bed 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.24PRB.usrpx300.conf @@ -56,27 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_3 = 0; #for mixed slot + initialDLBWPmappingType_3 = 0; + initialDLBWPstartSymbolAndLength_3 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL @@ -134,17 +121,14 @@ gNBs = # pusch-ConfigCommon (up to 16 elements) initialULBWPk2_0 = 6; initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 initialULBWPk2_1 = 6; initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 initialULBWPstartSymbolAndLength_1 = 69; initialULBWPk2_2 = 7; initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 initialULBWPstartSymbolAndLength_2 = 52; msg3_DeltaPreamble = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf index 694b78e08d..50276c3289 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.273PRB.usrpn300.conf @@ -46,37 +46,24 @@ gNBs = dl_carrierBandwidth = 273; #initialDownlinkBWP #genericParameters - # this is RBstart=84,L=50 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 13559; + # this is RBstart=74,L=50 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 13549; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; #pdcch-ConfigCommon - initialDLBWPcontrolResourceSetZero = 12; + initialDLBWPcontrolResourceSetZero = 0; initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -89,7 +76,7 @@ gNBs = pMax = 20; #initialUplinkBWP #genericParameters - initialULBWPlocationAndBandwidth = 13559; + initialULBWPlocationAndBandwidth = 13549; # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialULBWPsubcarrierSpacing = 1; @@ -131,21 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6;#2; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 6;#2; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 + + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 69; # this is SS=10 L=2 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; - + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -234,6 +217,7 @@ L1s = ( { num_cc = 1; tr_n_preference = "local_mac"; + pusch_proc_threads = 8; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf index 1e32905733..1d8f61e442 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_eNB_band13.conf @@ -240,7 +240,7 @@ MACRLCs = ( THREAD_STRUCT = ( { parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; - worker_config = "ENABLE"; + worker_config = "WORKER_ENABLE"; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_enb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_enb.conf index d26ebcd590..7e9a55d924 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_enb.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_enb.conf @@ -241,7 +241,7 @@ MACRLCs = ( THREAD_STRUCT = ( { parallel_config = "PARALLEL_RU_L1_TRX_SPLIT"; - worker_config = "ENABLE"; + worker_config = "WORKER_ENABLE"; } ); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf index ece681bc6e..c7ffc1a29a 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb.conf @@ -58,27 +58,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -133,20 +120,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_2 = 7; + initialULBWPk2_1 = 2; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf index 185edc5666..febf152387 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_24PRB.conf @@ -135,8 +135,8 @@ gNBs = # pusch-ConfigCommon (up to 16 elements) initialULBWPk2_0 = 2; initialULBWPmappingType_0 = 1 - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_0 = 55; + # this is SS=0 L=13 + initialULBWPstartSymbolAndLength_0 = 41; initialULBWPk2_1 = 2; initialULBWPmappingType_1 = 1; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf index e8fcced386..767459aecb 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/testing_gnb_n310.conf @@ -56,27 +56,14 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=4 //5 (4 is for 43, 5 is for 57) - initialDLBWPstartSymbolAndLength_3 = 57; //43; //57; #uplinkConfigCommon #frequencyInfoUL ul_frequencyBand = 78; @@ -131,20 +118,17 @@ gNBs = # 0=unrestricted, 1=restricted type A, 2=restricted type B restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 2; + initialULBWPk2_0 = 2; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; - - initialULBWPk2_1 = 2; - initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_2 = 7; + initialULBWPk2_1 = 2; # used for mixed slot + initialULBWPmappingType_1 = 1; + initialULBWPstartSymbolAndLength_1 = 24; # this is SS=10 L=2 + + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf index b64e9d1cbc..0b7b8e351b 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band41.fr1.106PRB.usrpb210.conf @@ -7,15 +7,28 @@ gNBs = { ////////// Identification parameters: gNB_ID = 0xe00; - - cell_type = "CELL_MACRO_GNB"; gNB_name = "gNB-Eurecom-5GNRBox"; // Tracking area code, 0x0000 and 0xfffe are reserved values tracking_area_code = 1; - plmn_list = ({mcc = 208; mnc = 92; mnc_length = 2;}); + plmn_list = ({ + mcc = 208; + mnc = 99; + mnc_length = 2; + snssaiList = ( + { + sst = 1; + sd = 0x1; // 0 false, else true + }, + { + sst = 1; + sd = 0x112233; // 0 false, else true + } + ); - tr_s_preference = "local_mac" + }); + + nr_cellid = 12345678L; ////////// Physical parameters: @@ -52,8 +65,8 @@ gNBs = dl_carrierBandwidth = 106; #initialDownlinkBWP #genericParameters - # this is RBstart=41,L=24 (275*(L-1))+RBstart - initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 + # this is RBstart=27,L=48 (275*(L-1))+RBstart + initialDLBWPlocationAndBandwidth = 12952; # 6366 12925 12956 28875 12952 # subcarrierSpacing # 0=kHz15, 1=kHz30, 2=kHz60, 3=kHz120 initialDLBWPsubcarrierSpacing = 1; @@ -62,27 +75,13 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -138,20 +137,17 @@ gNBs = restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -209,35 +205,21 @@ gNBs = ////////// MME parameters: - mme_ip_address = ( { ipv4 = "192.168.12.26"; + amf_ip_address = ( { ipv4 = "192.168.70.132"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; } ); - ///X2 - enable_x2 = "no"; - t_reloc_prep = 1000; /* unit: millisecond */ - tx2_reloc_overall = 2000; /* unit: millisecond */ - t_dc_prep = 1000; /* unit: millisecond */ - t_dc_overall = 2000; /* unit: millisecond */ - target_enb_x2_ip_address = ( - { ipv4 = "CI_FR1_CTL_ENB_IP_ADDR"; - ipv6 = "192:168:30::17"; - preference = "ipv4"; - } - ); NETWORK_INTERFACES : { - GNB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1_MME = "CI_GNB_IP_ADDR"; - GNB_INTERFACE_NAME_FOR_S1U = "eth0"; - GNB_IPV4_ADDRESS_FOR_S1U = "CI_GNB_IP_ADDR"; + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 - GNB_IPV4_ADDRESS_FOR_X2C = "CI_GNB_IP_ADDR"; - GNB_PORT_FOR_X2C = 36422; # Spec 36422 }; } @@ -256,7 +238,7 @@ L1s = ( num_cc = 1; tr_n_preference = "local_mac"; pusch_proc_threads = 8; - } + } ); RUs = ( @@ -310,5 +292,7 @@ rfsimulator : pdcp_log_verbosity ="medium"; rrc_log_level ="info"; rrc_log_verbosity ="medium"; + ngap_log_level ="debug"; + ngap_log_verbosity ="medium"; }; diff --git a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf index a3548b61df..009e557fb9 100644 --- a/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf @@ -7,8 +7,6 @@ gNBs = { ////////// Identification parameters: gNB_ID = 0xe00; - - cell_type = "CELL_MACRO_GNB"; gNB_name = "gNB-Eurecom-5GNRBox"; // Tracking area code, 0x0000 and 0xfffe are reserved values @@ -17,20 +15,20 @@ gNBs = mcc = 208; mnc = 99; mnc_length = 2; - snssaiList = ( - { + snssaiList = ( + { sst = 1; - sd = 0x010203; // 0 false, else true + sd = 0x1; // 0 false, else true }, - { + { sst = 1; sd = 0x112233; // 0 false, else true } ); }); - - tr_s_preference = "local_mac" + + nr_cellid = 12345678L; ////////// Physical parameters: @@ -77,27 +75,13 @@ gNBs = initialDLBWPsearchSpaceZero = 0; #pdsch-ConfigCommon #pdschTimeDomainAllocationList (up to 16 entries) - initialDLBWPk0_0 = 0; - #initialULBWPmappingType - #0=typeA,1=typeB - initialDLBWPmappingType_0 = 0; - #this is SS=1,L=13 - initialDLBWPstartSymbolAndLength_0 = 40; + initialDLBWPk0_0 = 0; #for DL slot + initialDLBWPmappingType_0 = 0; #0=typeA,1=typeB + initialDLBWPstartSymbolAndLength_0 = 40; #this is SS=1,L=13 - initialDLBWPk0_1 = 0; - initialDLBWPmappingType_1 = 0; - #this is SS=2,L=12 - initialDLBWPstartSymbolAndLength_1 = 53; - - initialDLBWPk0_2 = 0; - initialDLBWPmappingType_2 = 0; - #this is SS=1,L=12 - initialDLBWPstartSymbolAndLength_2 = 54; - - initialDLBWPk0_3 = 0; - initialDLBWPmappingType_3 = 0; - #this is SS=1,L=5 - initialDLBWPstartSymbolAndLength_3 = 57; + initialDLBWPk0_1 = 0; #for mixed slot + initialDLBWPmappingType_1 = 0; + initialDLBWPstartSymbolAndLength_1 = 57; #this is SS=1,L=5 #uplinkConfigCommon #frequencyInfoUL @@ -153,20 +137,17 @@ gNBs = restrictedSetConfig = 0, # pusch-ConfigCommon (up to 16 elements) - initialULBWPk2_0 = 6; + initialULBWPk2_0 = 6; # used for UL slot initialULBWPmappingType_0 = 1 - # this is SS=0 L=11 - initialULBWPstartSymbolAndLength_0 = 55; + initialULBWPstartSymbolAndLength_0 = 41; # this is SS=0 L=13 - initialULBWPk2_1 = 6; + initialULBWPk2_1 = 6; # used for mixed slot initialULBWPmappingType_1 = 1; - # this is SS=0 L=12 - initialULBWPstartSymbolAndLength_1 = 69; + initialULBWPstartSymbolAndLength_1 = 52; # this is SS=10 L=4 - initialULBWPk2_2 = 7; + initialULBWPk2_2 = 7; # used for Msg.3 during RA initialULBWPmappingType_2 = 1; - # this is SS=10 L=4 - initialULBWPstartSymbolAndLength_2 = 52; + initialULBWPstartSymbolAndLength_2 = 52; # this is SS=10 L=4 msg3_DeltaPreamble = 1; p0_NominalWithGrant =-90; @@ -224,35 +205,21 @@ gNBs = ////////// MME parameters: - amf_ip_address = ( { ipv4 = "192.168.69.131"; + amf_ip_address = ( { ipv4 = "192.168.70.132"; ipv6 = "192:168:30::17"; active = "yes"; preference = "ipv4"; } ); - ///X2 - enable_x2 = "no"; - t_reloc_prep = 1000; /* unit: millisecond */ - tx2_reloc_overall = 2000; /* unit: millisecond */ - t_dc_prep = 1000; /* unit: millisecond */ - t_dc_overall = 2000; /* unit: millisecond */ - target_enb_x2_ip_address = ( - { ipv4 = "CI_FR1_CTL_ENB_IP_ADDR"; - ipv6 = "192:168:30::17"; - preference = "ipv4"; - } - ); NETWORK_INTERFACES : { - GNB_INTERFACE_NAME_FOR_NG_AMF = "eth0"; - GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.18.198/24"; - GNB_INTERFACE_NAME_FOR_NGU = "eth0"; - GNB_IPV4_ADDRESS_FOR_NGU = "192.168.18.198/24"; + GNB_INTERFACE_NAME_FOR_NG_AMF = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NG_AMF = "192.168.70.129/24"; + GNB_INTERFACE_NAME_FOR_NGU = "demo-oai"; + GNB_IPV4_ADDRESS_FOR_NGU = "192.168.70.129/24"; GNB_PORT_FOR_S1U = 2152; # Spec 2152 - GNB_IPV4_ADDRESS_FOR_X2C = "192.168.18.198/24"; - GNB_PORT_FOR_X2C = 36422; # Spec 36422 }; } diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index 074e3b1324..8f3aeaac62 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,13 +1,13 @@ [*] [*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI -[*] Sun May 19 21:39:57 2019 +[*] Tue Jan 26 21:45:57 2021 [*] -[dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Sun May 19 21:30:25 2019" -[dumpfile_size] 11590554 -[savefile] "/home/sphex/raymond/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" -[timestart] 7629910000 -[size] 1840 795 +[dumpfile] "/home/eurecom/raymond/gtkw/openair_dump_eNB.vcd" +[dumpfile_mtime] "Tue Jan 26 21:26:33 2021" +[dumpfile_size] 180869253 +[savefile] "/home/eurecom/raymond/openairinterface5g_2/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" +[timestart] 11468800000 +[size] 1693 785 [pos] -1 -1 *-21.832302 7639830000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 386 @@ -16,17 +16,22 @@ [sst_vpaned_height] 303 @28 functions.trx_read +@29 +functions.trx_write_thread +@28 functions.trx_write @24 variables.trx_ts[63:0] variables.trx_tst[63:0] +variables.trx_write_flags[63:0] @28 functions.eNB_thread_rxtx0 +@420 +variables.l1_proc_tx_ic[63:0] +variables.l1_proc_ic[63:0] @24 variables.frame_number_RX0_RU[63:0] -@25 variables.tti_number_RX0_RU[63:0] -@24 variables.frame_number_TX0_RU[63:0] variables.tti_number_TX0_RU[63:0] @28 diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 5316705809..31c142c8da 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -70,6 +70,7 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" +#include "PHY/LTE_ESTIMATION/lte_estimation.h" #include "PHY/phy_extern.h" @@ -96,6 +97,9 @@ #include "T.h" +#include "common/ran_context.h" +extern RAN_CONTEXT_t RC; + //#define DEBUG_THREADS 1 //#define USRP_DEBUG 1 @@ -261,7 +265,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB, 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, proc); + eNB->if_inst->UL_indication(&eNB->UL_INFO, (void*)proc); AssertFatal((ret= pthread_mutex_unlock(&eNB->UL_INFO_mutex))==0,"error unlocking UL_INFO_mutex, return %d\n",ret); /* this conflict resolution may be totally wrong, to be tested */ /* CONFLICT RESOLUTION: BEGIN */ @@ -323,7 +327,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB, static void *L1_thread_tx(void *param) { L1_proc_t *eNB_proc = (L1_proc_t *)param; L1_rxtx_proc_t *proc = &eNB_proc->L1_proc_tx; - PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; + PHY_VARS_eNB *eNB = eNB_proc->eNB; char thread_name[100]; sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.L1_proc == proc ? 0 : 1); thread_top_init(thread_name,1,470000,500000,500000); @@ -331,6 +335,7 @@ static void *L1_thread_tx(void *param) { //wait_sync("tx_thread"); + proc->respEncode = eNB->proc.L1_proc.respEncode; while (!oai_exit) { LOG_D(PHY,"Waiting for TX (IC %d)\n",proc->instance_cnt); @@ -351,21 +356,19 @@ static void *L1_thread_tx(void *param) { LOG_D(PHY,"L1 TX processing %d.%d\n",proc->frame_tx,proc->subframe_tx); phy_procedures_eNB_TX(eNB, proc, 1); AssertFatal((ret= pthread_mutex_lock( &proc->mutex ))==0,"error locking L1_proc_tx mutex, return %d\n",ret); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_TX_IC,proc->instance_cnt); int subframe_tx = proc->subframe_tx; int frame_tx = proc->frame_tx; uint64_t timestamp_tx = proc->timestamp_tx; proc->instance_cnt = -1; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_TX_IC,proc->instance_cnt); LOG_D(PHY,"L1 TX signaling done for %d.%d\n",proc->frame_tx,proc->subframe_tx); // the thread can now be woken up LOG_D(PHY,"L1_thread_tx: signaling completion in %d.%d\n",proc->frame_tx,proc->subframe_tx); - if (pthread_cond_signal(&proc->cond) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - } - + AssertFatal((ret=pthread_cond_signal(&proc->cond))== 0, "ERROR pthread_cond_signal for eNB TXnp4 thread ret %d\n",ret); AssertFatal((ret= pthread_mutex_unlock( &proc->mutex ))==0,"error unlocking L1_proc_tx mutex, return %d\n",ret); + + wakeup_txfh(eNB,proc,frame_tx,subframe_tx,timestamp_tx); } @@ -391,6 +394,8 @@ static void *L1_thread( void *param ) { } PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; + + char thread_name[100]; cpu_set_t cpuset; CPU_ZERO(&cpuset); @@ -402,7 +407,7 @@ static void *L1_thread( void *param ) { 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 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0, 0 ); T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); LOG_D(PHY,"L1RX waiting for RU RX\n"); @@ -410,7 +415,7 @@ static void *L1_thread( void *param ) { LOG_D(PHY,"L1RX starting in %d.%d\n",proc->frame_rx,proc->subframe_rx); 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_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0, 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); @@ -424,6 +429,8 @@ static void *L1_thread( void *param ) { LOG_D(PHY,"L1 RX %d.%d done\n",proc->frame_rx,proc->subframe_rx); + if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_IC, proc->instance_cnt); if (NFAPI_MODE!=NFAPI_MODE_VNF) { if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB,proc->frame_rx,proc->subframe_rx,proc->frame_tx,proc->subframe_tx,proc->timestamp_tx); else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) { @@ -432,9 +439,7 @@ static void *L1_thread( void *param ) { } } - if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break; } // 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; @@ -530,6 +535,7 @@ int wakeup_txfh(PHY_VARS_eNB *eNB, AssertFatal(pthread_cond_signal(&ru_proc->cond_eNBs) == 0, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); AssertFatal((ret=pthread_mutex_unlock(&ru_proc->mutex_eNBs))==0,"mutex_unlock returned %d\n",ret); + } return(0); @@ -542,19 +548,19 @@ int wakeup_tx(PHY_VARS_eNB *eNB, int frame_tx, int subframe_tx, uint64_t timestamp_tx) { - L1_rxtx_proc_t *L1_proc = &eNB->proc.L1_proc; L1_rxtx_proc_t *L1_proc_tx = &eNB->proc.L1_proc_tx; int ret; LOG_D(PHY,"ENTERED wakeup_tx (IC %d)\n",L1_proc_tx->instance_cnt); + // check if subframe is a has TX else return + if (subframe_select(&eNB->frame_parms,subframe_tx) == SF_UL) return 0; AssertFatal((ret = pthread_mutex_lock(&L1_proc_tx->mutex))==0,"mutex_lock returns %d\n",ret); - LOG_D(PHY,"L1 RX %d.%d Waiting to wake up L1 TX %d.%d (IC L1TX %d)\n",L1_proc->frame_rx,L1_proc->subframe_rx,L1_proc->frame_tx,L1_proc->subframe_tx,L1_proc_tx->instance_cnt); + LOG_D(PHY,"L1 RX %d.%d Waiting to wake up L1 TX %d.%d (IC L1TX %d)\n",frame_rx,subframe_rx,frame_tx,subframe_tx,L1_proc_tx->instance_cnt); while(L1_proc_tx->instance_cnt == 0) { pthread_cond_wait(&L1_proc_tx->cond,&L1_proc_tx->mutex); } LOG_D(PHY,"L1 RX Got signal that TX %d.%d is done\n",L1_proc_tx->frame_tx,L1_proc_tx->subframe_tx); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_TX_IC,L1_proc_tx->instance_cnt); L1_proc_tx->instance_cnt = 0; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_TX_IC,L1_proc_tx->instance_cnt); L1_proc_tx->subframe_rx = subframe_rx; @@ -563,9 +569,11 @@ int wakeup_tx(PHY_VARS_eNB *eNB, L1_proc_tx->frame_tx = frame_tx; L1_proc_tx->timestamp_tx = timestamp_tx; // the thread can now be woken up - LOG_D(PHY,"L1 RX Waking up L1 TX %d.%d\n",L1_proc->frame_tx,L1_proc->subframe_tx); + LOG_D(PHY,"L1 RX Waking up L1 TX %d.%d\n",frame_tx,subframe_tx); + AssertFatal(pthread_cond_signal(&L1_proc_tx->cond) == 0, "ERROR pthread_cond_signal for eNB L1 thread tx\n"); AssertFatal((ret=pthread_mutex_unlock(&L1_proc_tx->mutex))==0,"mutex_unlock returns %d\n",ret); + return(0); } @@ -585,10 +593,16 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB, if (L1_proc->instance_cnt == 0) { // L1_thread is busy so abort the subframe AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"mutex_unlock return %d\n",ret); LOG_W(PHY,"L1_thread isn't ready in %d.%d, aborting RX processing\n",ru_proc->frame_rx,ru_proc->tti_rx); +/* AssertFatal(1==0,"L1_thread isn't ready in %d.%d (L1RX %d.%d), aborting RX, exiting\n", + ru_proc->frame_rx,ru_proc->tti_rx,L1_proc->frame_rx,L1_proc->subframe_rx); +*/ return(0); + } ++L1_proc->instance_cnt; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_IC, L1_proc->instance_cnt); + // 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). @@ -606,14 +620,12 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB, VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_TX_RU+ru->idx, L1_proc->frame_tx); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU+ru->idx, L1_proc->subframe_tx); - // the thread can now be woken up - if (pthread_cond_signal(&L1_proc->cond) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(-1); - } + // the thread can now be woken up + AssertFatal((ret=pthread_cond_signal(&L1_proc->cond))== 0, "ERROR pthread_cond_signal for eNB RXn-TXnp4 thread, ret %d\n",ret); AssertFatal((ret=pthread_mutex_unlock( &L1_proc->mutex))==0,"mutex_unlock return %d\n",ret); + + return(0); } @@ -837,6 +849,21 @@ static void *process_stats_thread(void *param) { return(NULL); } +void *L1_stats_thread(void *param) { + PHY_VARS_eNB *eNB = (PHY_VARS_eNB *)param; + wait_sync("L1_stats_thread"); + FILE *fd; + while (!oai_exit) { + sleep(1); + fd=fopen("L1_stats.log","w"); + AssertFatal(fd!=NULL,"Cannot open L1_stats.log\n"); + dump_I0_stats(fd,eNB); + dump_ulsch_stats(fd,eNB,eNB->proc.L1_proc_tx.frame_tx); + dump_uci_stats(fd,eNB,eNB->proc.L1_proc_tx.frame_tx); + fclose(fd); + } + return(NULL); +} void init_eNB_proc(int inst) { /*int i=0;*/ @@ -858,6 +885,7 @@ void init_eNB_proc(int inst) { L1_proc_tx->instance_cnt = -1; L1_proc->instance_cnt_RUs = 0; L1_proc_tx->instance_cnt_RUs = 0; + proc->eNB = eNB; proc->instance_cnt_prach = -1; proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_synch = -1; @@ -930,6 +958,7 @@ void init_eNB_proc(int inst) { 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); + pthread_create(&proc->L1_stats_thread,NULL,L1_stats_thread,(void*)eNB); } //for multiple CCs: setup master and slaves @@ -1060,60 +1089,47 @@ void print_opp_meas(void) { void free_transport(PHY_VARS_eNB *eNB) { - for (int i=0; idlsch[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]); + for (int i=0;iulsch[i]); + } } 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"); if (NFAPI_MODE!=NFAPI_MODE_VNF) { - for (i=0; idlsch[i][j] = new_eNB_dlsch(1,8,NSOFT,fp->N_RB_DL,0,fp); - + LOG_I(PHY,"eNB->dlsch[%d][%d] %p\n",i,j,eNB->dlsch[i][j]); if (!eNB->dlsch[i][j]) { - LOG_E(PHY,"Can't get eNB dlsch structures for UE %d \n", i); + LOG_E(PHY,"Can't get eNB dlsch structures for DLSCH %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); } } + } + for (int i=0;iulsch[1+i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); + LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH %d/%d\n",i,NUMBER_OF_ULSCH_MAX); + eNB->ulsch[i] = new_eNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0); - if (!eNB->ulsch[1+i]) { + if (!eNB->ulsch[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); @@ -1126,7 +1142,7 @@ void init_transport(PHY_VARS_eNB *eNB) { eNB->rx_total_gain_dB=130; - for(i=0; imu_mimo_mode[i].dl_pow_off = 2; eNB->check_for_total_transmissions = 0; @@ -1134,11 +1150,13 @@ void init_transport(PHY_VARS_eNB *eNB) { eNB->FULL_MUMIMO_transmissions = 0; eNB->check_for_SUMIMO_transmissions = 0; fp->pucch_config_common.deltaPUCCH_Shift = 1; + if (eNB->use_DTX == 0) fill_subframe_mask(eNB); + } void init_eNB_afterRU(void) { - int inst,CC_id,ru_id,i,aa; + int inst,CC_id,i; PHY_VARS_eNB *eNB; LOG_I(PHY,"%s() RC.nb_inst:%d\n", __FUNCTION__, RC.nb_inst); @@ -1148,13 +1166,14 @@ void init_eNB_afterRU(void) { for (CC_id=0; CC_idnum_RU>0,"Number of RU attached to eNB %d is zero\n",eNB->Mod_id); - + // map antennas and PRACH signals to eNB RX 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,"eNB->num_RU:%d\n", eNB->num_RU); + if (NFAPI_MODE==NFAPI_MODE_PNF) AssertFatal(eNB->num_RU>0,"Number of RU attached to eNB %d is zero\n",eNB->Mod_id); + for (int ru_id=0; ru_idnum_RU; ru_id++) + eNB->frame_parms.nb_antennas_rx += eNB->RU_list[ru_id]->nb_rx; + phy_init_lte_eNB(eNB,0,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 *)); @@ -1163,10 +1182,8 @@ void init_eNB_afterRU(void) { eNB->prach_vars_br.rxsigF[ce_level] = (int16_t **)malloc16(64*sizeof(int16_t *)); } - LOG_I(PHY,"eNB->num_RU:%d\n", eNB->num_RU); - for (ru_id=0,aa=0; ru_idnum_RU; ru_id++) { - eNB->frame_parms.nb_antennas_rx += eNB->RU_list[ru_id]->nb_rx; + for (int ru_id=0,aa=0; ru_idnum_RU; ru_id++) { AssertFatal(eNB->RU_list[ru_id]->common.rxdataF!=NULL, "RU %d : common.rxdataF is NULL\n", @@ -1214,7 +1231,7 @@ void init_eNB_afterRU(void) { init_eNB_proc(inst); } - for (ru_id=0; ru_idwakeup_rxtx = wakeup_rxtx; RC.ru[ru_id]->wakeup_prach_eNB = wakeup_prach_eNB; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 4682c5989e..86d3a88781 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -51,7 +51,6 @@ #include "assertions.h" #include "msc.h" #include "PHY/defs_common.h" -#include "PHY/phy_extern.h" #include "PHY/types.h" #include "PHY/INIT/phy_init.h" #include "PHY/LTE_ESTIMATION/lte_estimation.h" @@ -59,23 +58,11 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" -#include "PHY_INTERFACE/phy_interface.h" -#include "LAYER2/MAC/mac.h" -#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/mac_proto.h" -#include "RRC/LTE/rrc_extern.h" -#include "SCHED/sched_eNB.h" -#include "UTIL/OPT/opt.h" -#include "UTIL/OTG/otg_tx.h" -#include "UTIL/OTG/otg_externs.h" -#include "UTIL/MATH/oml.h" +#include "SCHED/sched_common.h" #include "common/utils/LOG/log.h" #include "common/utils/LOG/vcd_signal_dumper.h" -#include "nfapi/oai_integration/vendor_ext.h" -#include "enb_config.h" #include "targets/ARCH/COMMON/common_lib.h" #include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h" -#include "targets/RT/USER/lte-softmodem.h" //#include "PHY/TOOLS/time_meas.h" /* these variables have to be defined before including ENB_APP/enb_paramdef.h */ @@ -86,29 +73,25 @@ static int DEFBFW[] = {0x00007fff}; #include "ENB_APP/enb_paramdef.h" #include "common/config/config_userapi.h" -#ifndef OPENAIR2 - #include "UTIL/OTG/otg_extern.h" -#endif - -#include "s1ap_eNB.h" #include "SIMULATION/ETH_TRANSPORT/proto.h" #include "T.h" -#include "pdcp.h" +#include "executables/softmodem-common.h" #define MBMS_EXPERIMENTAL extern volatile int oai_exit; -extern int emulate_rf; -extern int numerology; extern clock_source_t clock_source; #include "executables/thread-common.h" //extern PARALLEL_CONF_t get_thread_parallel_conf(void); //extern WORKER_CONF_t get_thread_worker_conf(void); extern void phy_init_RU(RU_t *); -void stop_RU(int nb_ru); +void prach_procedures(PHY_VARS_eNB *eNB,int br_flag); + +void stop_RU(RU_t **rup,int nb_ru); + void do_ru_synch(RU_t *ru); void configure_ru(int idx, @@ -124,13 +107,24 @@ void wait_eNBs(void); const char ru_states[6][9] = {"RU_IDLE","RU_CONFIG","RU_READY","RU_RUN","RU_ERROR","RU_SYNC"}; +extern const char NB_functions[7][20]; +extern const char NB_timing[2][20]; + extern uint16_t sf_ahead; +extern const char ru_if_types[MAX_RU_IF_TYPES][20]; + + #if defined(PRE_SCD_THREAD) +#include "common/ran_context.h" +#include "nfapi/oai_integration/vendor_ext.h" +#include "openair2/LAYER2/MAC/mac_extern.h" extern uint8_t dlsch_ue_select_tbl_in_use; void init_ru_vnf(void); + extern RAN_CONTEXT_t RC; #endif +RU_t **RCconfig_RU(int nb_RU,int nb_L1_inst,PHY_VARS_eNB ***eNB,uint64_t *ru_mask,pthread_mutex_t *ru_mutex,pthread_cond_t *ru_cond); /*************************************************************/ /* Functions to attach and configure RRU */ @@ -141,7 +135,7 @@ extern uint16_t sf_ahead; // southbound IF5 fronthaul for 16-bit OAI format static inline void fh_if5_south_out(RU_t *ru,int frame, int subframe, uint64_t timestamp) { - if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); ru->south_out_cnt++; @@ -149,14 +143,12 @@ static inline void fh_if5_south_out(RU_t *ru,int frame, int subframe, uint64_t t } - - // southbound IF4p5 fronthaul static inline void fh_if4p5_south_out(RU_t *ru, int frame, int subframe, uint64_t timestamp) { - if (ru == RC.ru[0]) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); + if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, ru->proc.timestamp_tx&0xffffffff ); LOG_D(PHY,"ENTERED fh_if4p5_south_out Sending IF4p5 for frame %d subframe %d ru %d\n",ru->proc.frame_tx,ru->proc.tti_tx,ru->idx); @@ -166,7 +158,7 @@ static inline void fh_if4p5_south_out(RU_t *ru, LOG_D(PHY,"south_out_cnt %d\n",ru->south_out_cnt); } - /*if (ru == RC.ru[0] || ru == RC.ru[1]) { + /*if (ru->idx == 0 || ru->idx == ru) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU+ru->idx, ru->proc.frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU+ru->idx, ru->proc.subframe_tx ); }*/ @@ -227,31 +219,30 @@ void fh_if4p5_south_in(RU_t *ru, symbol_mask_full = (1<symbols_per_tti)-1; LOG_D(PHY,"fh_if4p5_south_in: RU %d, frame %d, subframe %d, ru %d, mask %x\n",ru->idx,*frame,*subframe,ru->idx,proc->symbol_mask[*subframe]); - AssertFatal(proc->symbol_mask[*subframe]==0 || proc->symbol_mask[*subframe]==symbol_mask_full,"rx_fh_if4p5: proc->symbol_mask[%d] = %x\n",*subframe,proc->symbol_mask[*subframe]); + //AssertFatal(proc->symbol_mask[*subframe]==0 || proc->symbol_mask[*subframe]>=symbol_mask_full,"rx_fh_if4p5: proc->symbol_mask[%d] = %x\n",*subframe,proc->symbol_mask[*subframe]); // >= because PULTICK for S-subframe could have been received during normal subframe - if (proc->symbol_mask[*subframe]==0) { // this is normal case, if not true then we received a PULTICK before the previous subframe was finished + if (proc->symbol_mask[*subframe]idx,*frame,*subframe,f,sf); + LOG_D(PHY,"fh_if4p5_south_in (%s/%d): RU %d, frame %d, subframe %d, f %d, sf %d, symbol %d\n",packet_type == IF4p5_PULFFT ? "PULFFT" : "PULTICK",packet_type,ru->idx,*frame,*subframe,f,sf,symbol_number); if (oai_exit == 1 || ru->cmd== STOP_RU) break; if (packet_type == IF4p5_PULFFT) proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<symbol_mask[sf] = symbol_mask_full; + proc->symbol_mask[sf] = 0xffff; pultick_received++; - /* if ((proc->first_rx==0) && (f!=*frame)) LOG_E(PHY,"rx_fh_if4p5: PULTICK received frame %d != expected %d (RU %d) \n",f,*frame, ru->idx); else if ((proc->first_rx==0) && (sf!=*subframe)) LOG_E(PHY,"rx_fh_if4p5: PULTICK received subframe %d != expected %d (first_rx %d)\n",sf,*subframe,proc->first_rx); else break; */ - if (f==*frame || sf==*subframe) break; + //if (f==*frame || sf==*subframe) break; } else if (packet_type == IF4p5_PRACH) { // nothing in RU for RAU } - LOG_D(PHY,"rx_fh_if4p5 for RU %d: subframe %d, sf %d, symbol mask %x\n",ru->idx,*subframe,sf,proc->symbol_mask[sf]); - } while(proc->symbol_mask[sf] != symbol_mask_full); + LOG_D(PHY,"rx_fh_if4p5 for RU %d: subframe %d, sf %d, symbol %d, symbol mask %x\n",ru->idx,*subframe,sf,symbol_number,proc->symbol_mask[sf]); + } while(proc->symbol_mask[*subframe] < symbol_mask_full); } else { f = *frame; sf = *subframe; @@ -263,7 +254,7 @@ void fh_if4p5_south_in(RU_t *ru, proc->timestamp_rx = ((proc->frame_rx * 10) + proc->tti_rx ) * fp->samples_per_tti ; // proc->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); - if (get_nprocs()<=4) { + if (get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD) { proc->tti_tx = (sf+sf_ahead)%10; proc->frame_tx = (sf>(9-sf_ahead)) ? (f+1)&1023 : f; } @@ -291,7 +282,7 @@ void fh_if4p5_south_in(RU_t *ru, *subframe = proc->tti_rx; } - /*if (ru == RC.ru[0] || ru == RC.ru[1]) { + /*if (ru->idx == 0 || ru->idx == 1) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU+ru->idx, f ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_RU+ru->idx, sf ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, f ); @@ -399,7 +390,7 @@ void fh_if4p5_north_in(RU_t *ru, ru->north_in_cnt++; // dump VCD output for first RU in list - if (ru == RC.ru[0]) { + if (ru->idx == 0) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, *frame ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, *subframe ); } @@ -491,7 +482,7 @@ void fh_if4p5_north_asynch_in(RU_t *ru, LOG_D(PHY,"RU %d/%d TST %llu, frame %d, subframe %d\n",ru->idx,0,(long long unsigned int)proc->timestamp_tx,frame_tx,tti_tx); // dump VCD output for first RU in list - if (ru == RC.ru[0]) { + if (ru->idx == 0) { /*VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, tti_tx );*/ VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_NORTH_ASYNCH_IN, frame_tx); @@ -557,8 +548,8 @@ volatile late_control_e late_control=STATE_BURST_NORMAL; static void *emulatedRF_thread(void *param) { RU_proc_t *proc = (RU_proc_t *) param; int microsec = 500; // length of time to sleep, in miliseconds + int numerology = 0 ; struct timespec req = {0}; - int numerology = get_softmodem_params()->numerology; req.tv_sec = 0; req.tv_nsec = (numerology>0)? ((microsec * 1000L)/numerology):(microsec * 1000L)*2; cpu_set_t cpuset; @@ -609,7 +600,7 @@ void rx_rf(RU_t *ru, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); old_ts = proc->timestamp_rx; - if(get_softmodem_params()->emulate_rf) { + if(ru->emulate_rf) { wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); rxs = fp->samples_per_tti; @@ -662,7 +653,7 @@ void rx_rf(RU_t *ru, proc->tti_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; // synchronize first reception to frame 0 subframe 0 - if (ru->fh_north_asynch_in == NULL) { + if (get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD && ru->fh_north_asynch_in == NULL) { #ifdef PHY_TX_THREAD proc->timestamp_phy_tx = proc->timestamp_rx+((sf_ahead-1)*fp->samples_per_tti); proc->subframe_phy_tx = (proc->tti_rx+(sf_ahead-1))%10; @@ -690,16 +681,12 @@ void rx_rf(RU_t *ru, proc->frame_rx, proc->tti_rx); - // dump VCD output for first RU in list - if (ru == RC.ru[0]) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, proc->frame_rx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_RX0_RU, proc->tti_rx ); + } - if (ru->fh_north_asynch_in == NULL) { - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, proc->tti_tx ); - } - } + // dump VCD output for first RU in list + if (ru->idx == 0) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, proc->frame_rx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_RX0_RU, proc->tti_rx ); } if (proc->first_rx == 0) { @@ -790,6 +777,7 @@ void tx_rf(RU_t *ru, /* add fail safe for late command */ if(late_control!=STATE_BURST_NORMAL) { //stop burst + LOG_E(PHY,"%d.%d late_control : %d\n",frame,subframe,late_control); switch (late_control) { case STATE_BURST_TERMINATE: flags=10; // end of burst and no time spec @@ -818,12 +806,13 @@ void tx_rf(RU_t *ru, break; } } - - /* add fail safe for late command end */ VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, subframe); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_WRITE_FLAGS,flags); + + /* add fail safe for late command end */ + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); // prepare tx buffer pointers txs = ru->rfdevice.trx_write_func(&ru->rfdevice, timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, @@ -841,7 +830,7 @@ void tx_rf(RU_t *ru, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); // AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %d/%d)\n",txs, siglen); - if( (txs != siglen+sf_extension) && (late_control==STATE_BURST_NORMAL) ) { /* add fail safe for late command */ + if( usrp_tx_thread == 0 && (txs != siglen+sf_extension) && (late_control==STATE_BURST_NORMAL) ) { /* add fail safe for late command */ late_control=STATE_BURST_TERMINATE; LOG_E(PHY,"TX : Timeout (sent %d/%d) state =%d\n",txs, siglen,late_control); } @@ -954,7 +943,7 @@ void *ru_thread_prach( void *param ) { thread_top_init("ru_thread_prach",1,500000,1000000,20000000); //wait_sync("ru_thread_prach"); - while (RC.ru_mask>0 && ru->function!=eNodeB_3GPP) { + while (*ru->ru_mask>0 && ru->function!=eNodeB_3GPP) { usleep(1e6); LOG_D(PHY,"%s() RACH waiting for RU to be configured\n", __FUNCTION__); } @@ -1167,7 +1156,7 @@ void wakeup_L1s(RU_t *ru) { if (ru == eNB->RU_list[i] && eNB->RU_list[i]->wait_cnt == 0) { //AssertFatal((proc->RU_mask&(1<Mod_id,ru->proc.frame_rx,ru->proc.tti_rx,ru->idx,eNB->num_RU,proc->RU_mask); proc->RU_mask[ru->proc.tti_rx] |= (1<RU_list[i]->state == RU_SYNC ||*/(eNB->RU_list[i]->is_slave==1 && eNB->RU_list[i]->wait_cnt>0 && ru!=eNB->RU_list[i] && ru->is_slave==0) ) { + } else if (eNB->RU_list[i]->state == RU_SYNC ||(eNB->RU_list[i]->is_slave==1 && eNB->RU_list[i]->wait_cnt>0 && ru!=eNB->RU_list[i] /*&& ru->is_slave==0*/) ) { proc->RU_mask[ru->proc.tti_rx] |= (1<numerology; if(fp->N_RB_DL == 100) { - if(numerology == 0) { + if(ru->numerology == 0) { if (fp->threequarter_fs) { cfg->sample_rate=23.04e6; cfg->samples_per_frame = 230400; @@ -1319,12 +1308,12 @@ void fill_rf_config(RU_t *ru, cfg->tx_bw = 10e6; cfg->rx_bw = 10e6; } - } else if(numerology == 1) { + } else if(ru->numerology == 1) { cfg->sample_rate=61.44e6; cfg->samples_per_frame = 307200; cfg->tx_bw = 20e6; cfg->rx_bw = 20e6; - } else if(numerology == 2) { + } else if(ru->numerology == 2) { cfg->sample_rate=122.88e6; cfg->samples_per_frame = 307200; cfg->tx_bw = 40e6; @@ -1523,36 +1512,43 @@ static void *ru_thread_tx( void *param ) { LOG_D(PHY,"ru_thread_tx (ru %d): Waiting for TX processing\n",ru->idx); // wait until eNBs are finished subframe RX n and TX n+4 wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); - LOG_D(PHY,"ru_thread_tx: TX in %d.%d\n",ru->proc.frame_tx,ru->proc.tti_tx); + ret = pthread_mutex_lock(&proc->mutex_eNBs); + AssertFatal(ret == 0,"mutex_lock return %d\n",ret); + int frame_tx=proc->frame_tx; + int tti_tx =proc->tti_tx; + uint64_t timestamp_tx = proc->timestamp_tx; + ret = pthread_mutex_unlock(&proc->mutex_eNBs); + AssertFatal(ret == 0,"mutex_lock returns %d\n",ret); + if (oai_exit) break; // do TX front-end processing if needed (precoding and/or IDFTs) - if (ru->feptx_prec) ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx); + if (ru->feptx_prec) ru->feptx_prec(ru,frame_tx,tti_tx); // do OFDM if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru,proc->frame_tx,proc->tti_tx); + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru,frame_tx,tti_tx); - if(!(get_softmodem_params()->emulate_rf)) { //if(!emulate_rf){ + if(!(ru->emulate_rf)) { //if(!emulate_rf){ // do outgoing fronthaul (south) if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx); + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,frame_tx,tti_tx,timestamp_tx); if (ru->fh_north_out) ru->fh_north_out(ru); } else { for (int i=0; inb_tx; i++) { - if(proc->frame_tx == 2) { - sprintf(filename,"txdataF%d_frame%d_sf%d.m",i,proc->frame_tx,proc->tti_tx); + if(frame_tx == 2) { + sprintf(filename,"txdataF%d_frame%d_sf%d.m",i,frame_tx,tti_tx); LOG_M(filename,"txdataF_frame",ru->common.txdataF_BF[i],fp->symbols_per_tti*fp->ofdm_symbol_size, 1, 1); } - if(proc->frame_tx == 2 && proc->tti_tx==0) { - sprintf(filename,"txdata%d_frame%d.m",i,proc->frame_tx); + if(frame_tx == 2 && tti_tx==0) { + sprintf(filename,"txdata%d_frame%d.m",i,frame_tx); LOG_M(filename,"txdata_frame",ru->common.txdata[i],fp->samples_per_tti*10, 1, 1); } } } - LOG_D(PHY,"ru_thread_tx: releasing RU TX in %d.%d\n", proc->frame_tx, proc->tti_tx); + LOG_D(PHY,"ru_thread_tx: releasing RU TX in %d.%d\n", frame_tx, tti_tx); release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); for(int i = 0; inum_eNB; i++) { @@ -1568,7 +1564,7 @@ static void *ru_thread_tx( void *param ) { eNB->Mod_id,eNB_proc->frame_rx,eNB_proc->subframe_rx,ru->idx,eNB->num_RU,eNB_proc->RU_mask_tx); eNB_proc->RU_mask_tx |= (1<RU_list[j]->state==RU_SYNC ||*/ (eNB->RU_list[j]->is_slave==1 && eNB->RU_list[j]->wait_cnt>0 && ru!=eNB->RU_list[j] && ru->is_slave==0)) { + } else if (eNB->RU_list[j]->state==RU_SYNC ||(eNB->RU_list[j]->is_slave==1 && eNB->RU_list[j]->wait_cnt>0 && ru!=eNB->RU_list[j])) { eNB_proc->RU_mask_tx |= (1<mutex_RU_tx))==0,"mutex_unlock returns %d\n",ret); AssertFatal((ret=pthread_mutex_lock( &L1_proc->mutex_RUs))==0,"mutex_lock returns %d\n",ret); L1_proc->instance_cnt_RUs = 0; - LOG_D(PHY,"ru_thread_tx: Signaling RU TX done in %d.%d\n", proc->frame_tx, proc->tti_tx); + LOG_D(PHY,"ru_thread_tx: Signaling RU TX done in %d.%d\n", frame_tx, tti_tx); // the thread can now be woken up LOG_D(PHY,"ru_thread_tx: clearing mask and Waking up L1 thread\n"); @@ -1637,10 +1633,10 @@ static void *ru_thread( void *param ) { } LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); - AssertFatal((ret=pthread_mutex_lock(&RC.ru_mutex))==0,"mutex_lock returns %d\n",ret); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - AssertFatal((ret=pthread_mutex_unlock(&RC.ru_mutex))==0,"mutex_unlock returns %d\n",ret); + AssertFatal((ret=pthread_mutex_lock(ru->ru_mutex))==0,"mutex_lock returns %d\n",ret); + *ru->ru_mask &= ~(1<idx); + pthread_cond_signal(ru->ru_cond); + AssertFatal((ret=pthread_mutex_unlock(ru->ru_mutex))==0,"mutex_unlock returns %d\n",ret); ru->state = RU_RUN; } else if (ru->has_ctrl_prt == 0) { // There is no control port: start everything here @@ -1660,10 +1656,10 @@ static void *ru_thread( void *param ) { exit(-1); } - AssertFatal((ret=pthread_mutex_lock(&RC.ru_mutex))==0,"mutex_lock returns %d\n",ret); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - AssertFatal((ret=pthread_mutex_unlock(&RC.ru_mutex))==0,"mutex_unlock returns %d\n",ret); + AssertFatal((ret=pthread_mutex_lock(ru->ru_mutex))==0,"mutex_lock returns %d\n",ret); + *ru->ru_mask &= ~(1<idx); + pthread_cond_signal(ru->ru_cond); + AssertFatal((ret=pthread_mutex_unlock(ru->ru_mutex))==0,"mutex_unlock returns %d\n",ret); ru->state = RU_RUN; } @@ -1672,6 +1668,17 @@ static void *ru_thread( void *param ) { pthread_cond_signal(&proc->cond_FH1); AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_FH1))==0,"mutex_unlock returns %d\n",ret); + if(usrp_tx_thread == 1){ + if (ru->start_write_thread){ + if(ru->start_write_thread(ru) != 0){ + LOG_E(HW,"Could not start tx write thread\n"); + } + else{ + LOG_I(PHY,"tx write thread ready\n"); + } + } + } + while (!oai_exit) { if (ru->if_south != LOCAL_RF && ru->is_slave==1) { ru->wait_cnt = 100; @@ -1682,10 +1689,12 @@ static void *ru_thread( void *param ) { // wait to be woken up if (ru->function!=eNodeB_3GPP && ru->has_ctrl_prt == 1) { + LOG_D(PHY,"RU %d: Waiting for control thread to say go\n",ru->idx); if (wait_on_condition(&ru->proc.mutex_ru,&ru->proc.cond_ru_thread,&ru->proc.instance_cnt_ru,"ru_thread")<0) break; - } else wait_sync("ru_thread"); + } else wait_sync("ru_thread"); + LOG_D(PHY,"RU %d: Got start from control thread\n",ru->idx); - if(!(get_softmodem_params()->emulate_rf)) { + if(!(ru->emulate_rf)) { if (ru->is_slave == 0) AssertFatal(ru->state == RU_RUN,"ru-%d state = %s != RU_RUN\n",ru->idx,ru_states[ru->state]); else if (ru->is_slave == 1) AssertFatal(ru->state == RU_SYNC || ru->state == RU_RUN || ru->state == RU_CHECK_SYNC,"ru %d state = %s != RU_SYNC or RU_RUN or RU_CHECK_SYNC\n",ru->idx,ru_states[ru->state]); @@ -1711,7 +1720,7 @@ static void *ru_thread( void *param ) { // if this is a slave RRU, try to synchronize on the DL frequency if ((ru->is_slave == 1) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); - LOG_D(PHY,"Starting steady-state operation\n"); + if (ru->state == RU_RUN || ru->state == RU_CHECK_SYNC) LOG_I(PHY,"RU %d Starting steady-state operation\n",ru->idx); // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (ru->state == RU_RUN || ru->state == RU_CHECK_SYNC) { @@ -1772,14 +1781,14 @@ static void *ru_thread( void *param ) { ru->wait_cnt--; LOG_D(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt); - if (ru->if_south!=LOCAL_RF && ru->wait_cnt <=20 && subframe == 5 && frame != RC.ru[0]->proc.frame_rx && resynch_done == 0) { + if (ru->if_south!=LOCAL_RF && ru->wait_cnt <=20 && subframe == 5 && frame != ru->ru0->proc.frame_rx && resynch_done == 0) { // Send RRU_frame adjust RRU_CONFIG_msg_t rru_config_msg; rru_config_msg.type = RRU_frame_resynch; rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len - ((uint16_t *)&rru_config_msg.msg[0])[0] = RC.ru[0]->proc.frame_rx; + ((uint16_t *)&rru_config_msg.msg[0])[0] = ru->ru0->proc.frame_rx; ru->cmd=WAIT_RESYNCH; - LOG_I(PHY,"Sending Frame Resynch %d to RRU %d\n", RC.ru[0]->proc.frame_rx,ru->idx); + LOG_I(PHY,"Sending Frame Resynch %d to RRU %d\n", ru->ru0->proc.frame_rx,ru->idx); AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU\n"); resynch_done=1; } @@ -1837,9 +1846,9 @@ static void *ru_thread( void *param ) { #ifdef MBMS_EXPERIMENTAL //Workaround ... this must be properly handled - if(ru->if_south==LOCAL_RF && ru->function==eNodeB_3GPP && RC.eNB[0][0]!=NULL){ - if(ru->frame_parms->num_MBSFN_config!=RC.eNB[0][0]->frame_parms.num_MBSFN_config){ - ru->frame_parms = &RC.eNB[0][0]->frame_parms;//->frame_parms; + if(ru->if_south==LOCAL_RF && ru->function==eNodeB_3GPP && ru->eNB_list[0]!=NULL){ + if(ru->frame_parms->num_MBSFN_config!=ru->eNB_list[0]->frame_parms.num_MBSFN_config){ + ru->frame_parms = &ru->eNB_list[0]->frame_parms;//->frame_parms; LOG_W(PHY,"RU MBSFN SF PARAMS Updated\n"); } } @@ -1854,7 +1863,7 @@ static void *ru_thread( void *param ) { // do OFDM if needed if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru, proc->frame_tx, proc->tti_tx); - if(!(get_softmodem_params()->emulate_rf)) { //if(!emulate_rf){ + if(!(ru->emulate_rf)) { //if(!emulate_rf){ // do outgoing fronthaul (south) if needed if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru, proc->frame_tx, proc->tti_tx, proc->timestamp_tx); @@ -1888,12 +1897,12 @@ static void *ru_thread( void *param ) { #endif } // else wait_cnt == 0 - } // ru->state = RU_RUN + } // ru->state = RU_RUN || RU_CHECK_SYNC } // while !oai_exit LOG_I(PHY, "Exiting ru_thread \n"); - if (!(get_softmodem_params()->emulate_rf)) { + if (!(ru->emulate_rf)) { if (ru->stop_rf != NULL) { if (ru->stop_rf(ru) != 0) LOG_E(HW,"Could not stop the RF device\n"); @@ -1908,7 +1917,7 @@ static void *ru_thread( void *param ) { // This thread run the initial synchronization like a UE void *ru_thread_synch(void *arg) { RU_t *ru = (RU_t *)arg; - LTE_DL_FRAME_PARMS *fp = ru->frame_parms; + LTE_DL_FRAME_PARMS *fp; int64_t peak_val, avg; static int ru_thread_synch_status = 0; int cnt=0; @@ -1917,6 +1926,8 @@ void *ru_thread_synch(void *arg) { // initialize variables for PSS detection ru_sync_time_init(ru); //lte_sync_time_init(ru->frame_parms); + fp = ru->frame_parms; + int last_rxoff=0; while (!oai_exit) { // wait to be woken up if (wait_on_condition(&ru->proc.mutex_synch,&ru->proc.cond_synch,&ru->proc.instance_cnt_synch,"ru_thread_synch")<0) break; @@ -1930,17 +1941,18 @@ void *ru_thread_synch(void *arg) { &avg); LOG_I(PHY,"RU synch cnt %d: %d, val %llu (%d dB,%d dB)\n",cnt,ru->rx_offset,(unsigned long long)peak_val,dB_fixed64(peak_val),dB_fixed64(avg)); cnt++; - - //if (/*ru->rx_offset >= 0*/dB_fixed(peak_val)>=85 && cnt>10) { - if (ru->rx_offset >= 0 && avg>0 && dB_fixed(peak_val/avg)>=15 && cnt>10) { + int abs_diff= ru->rx_offset - last_rxoff; + if (abs_diff<0) abs_diff=-abs_diff; + if (ru->rx_offset >= 0 && abs_diff<6 && avg>0 && dB_fixed(peak_val/avg)>=15 && cnt>10) { LOG_I(PHY,"Estimated peak_val %d dB, avg %d => timing offset %llu\n",dB_fixed(peak_val),dB_fixed(avg),(unsigned long long int)ru->rx_offset); ru->in_synch = 1; - /* + /* LOG_M("ru_sync_rx.m","rurx",&ru->common.rxdata[0][0],LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti,1,1); LOG_M("ru_sync_corr.m","sync_corr",ru->dmrs_corr,LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*fp->samples_per_tti,1,6); LOG_M("ru_dmrs.m","rudmrs",&ru->dmrssync[0],fp->ofdm_symbol_size,1,1); - */ - //exit(-1); + + exit(-1); + */ } // sync_pos > 0 else { //AssertFatal(cnt<1000,"Cannot find synch reference\n"); if (cnt>200) { @@ -1950,6 +1962,7 @@ void *ru_thread_synch(void *arg) { exit(-1); } } + last_rxoff=ru->rx_offset; } // ru->in_synch==0 if (release_thread(&ru->proc.mutex_synch,&ru->proc.instance_cnt_synch,"ru_synch_thread") < 0) break; @@ -2113,7 +2126,7 @@ static void *rf_tx( void *param ) { // do OFDM if needed if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru,proc->frame_tx,proc->tti_tx); - if(!emulate_rf) { + if(!ru->emulate_rf) { // do outgoing fronthaul (south) if needed if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx); @@ -2185,6 +2198,9 @@ void reset_proc(RU_t *ru) { for (i=0; i<10; i++) proc->symbol_mask[i]=0; } +int start_write_thread(RU_t *ru) { + return(ru->rfdevice.trx_write_init(&ru->rfdevice)); +} void init_RU_proc(RU_t *ru) { int i=0; @@ -2282,7 +2298,7 @@ void init_RU_proc(RU_t *ru) { pthread_create( &proc->pthread_rf_tx, NULL, rf_tx, (void *)ru ); #endif - if (get_softmodem_params()->emulate_rf) + if (ru->emulate_rf) pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void *)proc ); if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) @@ -2317,10 +2333,10 @@ void init_RU_proc(RU_t *ru) { if (ru->function == eNodeB_3GPP) { usleep(10000); LOG_I(PHY, "Signaling main thread that RU %d (is_slave %d,send_dmrs %d) is ready in state %s\n",ru->idx,ru->is_slave,ru->generate_dmrs_sync,ru_states[ru->state]); - AssertFatal((ret=pthread_mutex_lock(&RC.ru_mutex))==0,"mutex_lock returns %d\n",ret); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - AssertFatal((ret=pthread_mutex_unlock(&RC.ru_mutex))==0,"mutex_unlock returns %d\n",ret); + AssertFatal((ret=pthread_mutex_lock(ru->ru_mutex))==0,"mutex_lock returns %d\n",ret); + *ru->ru_mask &= ~(1<idx); + pthread_cond_signal(ru->ru_cond); + AssertFatal((ret=pthread_mutex_unlock(ru->ru_mutex))==0,"mutex_unlock returns %d\n",ret); } */ } @@ -2448,22 +2464,22 @@ void kill_RU_proc(RU_t *ru) { } -void init_precoding_weights(PHY_VARS_eNB *eNB) { - int layer,ru_id,aa,re,ue,tb; +void init_precoding_weights(RU_t **rup,int nb_RU,PHY_VARS_eNB *eNB) { + int layer,ru_id,aa,re,tb; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; RU_t *ru; LTE_eNB_DLSCH_t *dlsch; // init precoding weigths - for (ue=0; uedlsch[ue][tb]; + dlsch = eNB->dlsch[dlsch_id][tb]; for (layer=0; layer<4; layer++) { int nb_tx=0; - for (ru_id=0; ru_idnb_tx; } @@ -2547,6 +2563,7 @@ void set_function_spec_param(RU_t *ru) { ru->fh_north_out = NULL; // no outgoing fronthaul to north ru->start_if = NULL; // no if interface ru->rfdevice.host_type = RAU_HOST; + ru->start_write_thread = start_write_thread; } ru->fh_south_in = rx_rf; // local synchronous RF RX @@ -2641,60 +2658,61 @@ void set_function_spec_param(RU_t *ru) { } -//extern void RCconfig_RU(void); +void init_RU0(RU_t *ru,int ru_id,char *rf_config_file, int send_dmrssync) { + ru->rf_config_file = rf_config_file; + ru->idx = ru_id; + ru->ts_offset = 0; + + if (ru->is_slave == 1) { + ru->in_synch = 0; + ru->generate_dmrs_sync = 0; + } else { + ru->in_synch = 1; + ru->generate_dmrs_sync = send_dmrssync; + } + + ru->cmd = EMPTY; + ru->south_out_cnt = 0; + // use eNB_list[0] as a reference for RU frame parameters + // NOTE: multiple CC_id are not handled here yet! + + //ru->generate_dmrs_sync = (ru->is_slave == 0) ? 1 : 0; + if ((ru->is_slave == 0) && (ru->ota_sync_enable == 1)) + ru->generate_dmrs_sync = 1; + else + ru->generate_dmrs_sync = 0; + + ru->wakeup_L1_sleeptime = 2000; + ru->wakeup_L1_sleep_cnt_max = 3; + -void init_RU(char *rf_config_file, int send_dmrssync) { +} + +// This part if on eNB side +void init_RU(RU_t **rup,int nb_RU,PHY_VARS_eNB ***eNBp,int nb_L1,int *nb_CC,char *rf_config_file, int send_dmrssync) { int ru_id, i, CC_id; RU_t *ru; PHY_VARS_eNB *eNB0 = (PHY_VARS_eNB *)NULL; LTE_DL_FRAME_PARMS *fp = (LTE_DL_FRAME_PARMS *)NULL; // create status mask - RC.ru_mask= (1 << RC.nb_RU) - 1; - pthread_mutex_init(&RC.ru_mutex,NULL); - pthread_cond_init(&RC.ru_cond,NULL); + if (nb_CC != NULL) + for (i=0; inum_RU=0; - if (RC.nb_CC != 0) - for (i=0; inum_RU=0; - - LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",RC.nb_RU); - - for (ru_id=0; ru_idrf_config_file = rf_config_file; - ru->idx = ru_id; - ru->ts_offset = 0; - - if (ru->is_slave == 1) { - ru->in_synch = 0; - ru->generate_dmrs_sync = 0; - } else { - ru->in_synch = 1; - ru->generate_dmrs_sync = send_dmrssync; - } - - ru->cmd = EMPTY; - ru->south_out_cnt = 0; - // use eNB_list[0] as a reference for RU frame parameters - // NOTE: multiple CC_id are not handled here yet! - - //ru->generate_dmrs_sync = (ru->is_slave == 0) ? 1 : 0; - if ((ru->is_slave == 0) && (ru->ota_sync_enable == 1)) - ru->generate_dmrs_sync = 1; - else - ru->generate_dmrs_sync = 0; - - ru->wakeup_L1_sleeptime = 2000; - ru->wakeup_L1_sleep_cnt_max = 3; + LOG_D(PHY,"Process RUs RC.nb_RU:%d\n",nb_RU); + for (ru_id=0; ru_idru0 = rup[0]; if (ru->num_eNB > 0) { - LOG_D(PHY, "%s() RC.ru[%d].num_eNB:%d ru->eNB_list[0]:%p RC.eNB[0][0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], RC.eNB[0][0], ru->rf_config_file); - + LOG_D(PHY, "%s() ru[%d].num_eNB:%d ru->eNB_list[0]:%p eNB[0][0]:%p rf_config_file:%s\n", __FUNCTION__, ru_id, ru->num_eNB, ru->eNB_list[0], eNBp[0][0], ru->rf_config_file); + if (ru->eNB_list[0] == 0) { - LOG_E(PHY,"%s() DJP - ru->eNB_list ru->num_eNB are not initialized - so do it manually\n", __FUNCTION__); - ru->eNB_list[0] = RC.eNB[0][0]; + LOG_E(PHY,"%s() DJP - ru->eNB_list ru->num_eNB are not initialized - so do it manually\n", __FUNCTION__); + ru->eNB_list[0] = eNBp[0][0]; ru->num_eNB=1; // // DJP - feptx_prec() / feptx_ofdm() parses the eNB_list (based on num_eNB) and copies the txdata_F to txdata in RU @@ -2703,7 +2721,7 @@ void init_RU(char *rf_config_file, int send_dmrssync) { LOG_E(PHY,"DJP - delete code above this %s:%d\n", __FILE__, __LINE__); } } - + eNB0 = ru->eNB_list[0]; fp = ru->frame_parms; LOG_D(PHY, "RU FUnction:%d ru->if_south:%d\n", ru->function, ru->if_south); @@ -2777,10 +2795,10 @@ void stop_ru(RU_t *ru) { } -void stop_RU(int nb_ru) { +void stop_RU(RU_t **rup,int nb_ru) { for (int inst = 0; inst < nb_ru; inst++) { LOG_I(PHY, "Stopping RU %d processing threads\n", inst); - kill_RU_proc(RC.ru[inst]); + kill_RU_proc(rup[inst]); } } @@ -2801,7 +2819,7 @@ void init_ru_vnf(void) { pthread_cond_init(&RC.ru_cond,NULL); // read in configuration file) LOG_I(PHY,"configuring RU from file\n"); - RCconfig_RU(); + RC.ru = RCconfig_RU(RC.nb_RU,RC.nb_L1_inst,RC.eNB,&RC.ru_mask,&RC.ru_mutex,&RC.ru_cond); LOG_I(PHY,"number of L1 instances %d, number of RU %d, number of CPU cores %d\n",RC.nb_L1_inst,RC.nb_RU,get_nprocs()); if (RC.nb_CC != 0) @@ -2877,183 +2895,185 @@ void init_ru_vnf(void) { /* --------------------------------------------------------*/ /* from here function to use configuration module */ -void RCconfig_RU(void) { +RU_t **RCconfig_RU(int nb_RU,int nb_L1_inst,PHY_VARS_eNB ***eNB,uint64_t *ru_mask,pthread_mutex_t *ru_mutex,pthread_cond_t *ru_cond) { int i = 0; paramdef_t RUParams[] = RUPARAMS_DESC; paramlist_def_t RUParamList = {CONFIG_STRING_RU_LIST,NULL,0}; config_getlist( &RUParamList,RUParams,sizeof(RUParams)/sizeof(paramdef_t), NULL); - + RU_t **ru=NULL; if ( RUParamList.numelt > 0) { - RC.ru = (RU_t **)malloc(RC.nb_RU*sizeof(RU_t *)); + ru = (RU_t **)malloc(nb_RU*sizeof(RU_t *)); - for (int j = 0; j < RC.nb_RU; j++) { - RC.ru[j] = (RU_t *)malloc(sizeof(RU_t)); - memset((void *)RC.ru[j],0,sizeof(RU_t)); - RC.ru[j]->idx = j; - LOG_I(PHY,"Creating RC.ru[%d]:%p\n", j, RC.ru[j]); - RC.ru[j]->if_timing = synch_to_ext_device; + for (int j = 0; j < nb_RU; j++) { + ru[j] = (RU_t *)malloc(sizeof(RU_t)); + memset((void *)ru[j],0,sizeof(RU_t)); + ru[j]->idx = j; + LOG_I(PHY,"Creating ru[%d]:%p\n", j, ru[j]); + ru[j]->if_timing = synch_to_ext_device; - if (RC.nb_L1_inst >0) - RC.ru[j]->num_eNB = RUParamList.paramarray[j][RU_ENB_LIST_IDX].numelt; + ru[j]->ru_mask = ru_mask; + ru[j]->ru_mutex = ru_mutex; + ru[j]->ru_cond = ru_cond; + if (nb_L1_inst >0) + ru[j]->num_eNB = RUParamList.paramarray[j][RU_ENB_LIST_IDX].numelt; else - RC.ru[j]->num_eNB = 0; + ru[j]->num_eNB = 0; - for (i=0; inum_eNB; i++) RC.ru[j]->eNB_list[i] = RC.eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; + for (i=0; inum_eNB; i++) ru[j]->eNB_list[i] = eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; - RC.ru[j]->has_ctrl_prt = 0; + ru[j]->has_ctrl_prt = 0; if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) { - RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr)); + ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr)); } if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) { if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) { - RC.ru[j]->openair0_cfg.clock_source = internal; + ru[j]->openair0_cfg.clock_source = internal; LOG_D(PHY, "RU clock source set as internal\n"); } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) { - RC.ru[j]->openair0_cfg.clock_source = external; + ru[j]->openair0_cfg.clock_source = external; LOG_D(PHY, "RU clock source set as external\n"); } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) { - RC.ru[j]->openair0_cfg.clock_source = gpsdo; + ru[j]->openair0_cfg.clock_source = gpsdo; LOG_D(PHY, "RU clock source set as gpsdo\n"); } else { LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); } } else { - RC.ru[j]->openair0_cfg.clock_source = unset; + ru[j]->openair0_cfg.clock_source = unset; } if (config_isparamset(RUParamList.paramarray[j], RU_SDR_TME_SRC)) { if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "internal") == 0) { - RC.ru[j]->openair0_cfg.time_source = internal; + ru[j]->openair0_cfg.time_source = internal; LOG_D(PHY, "RU time source set as internal\n"); } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "external") == 0) { - RC.ru[j]->openair0_cfg.time_source = external; + ru[j]->openair0_cfg.time_source = external; LOG_D(PHY, "RU time source set as external\n"); } else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_TME_SRC].strptr), "gpsdo") == 0) { - RC.ru[j]->openair0_cfg.time_source = gpsdo; + ru[j]->openair0_cfg.time_source = gpsdo; LOG_D(PHY, "RU time source set as gpsdo\n"); } else { LOG_E(PHY, "Erroneous RU time source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr)); } } else { - RC.ru[j]->openair0_cfg.time_source = unset; + ru[j]->openair0_cfg.time_source = unset; } + LOG_I(PHY,"RU %d is_slave=%s\n",j,*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr)); + + if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) ru[j]->is_slave=1; + else ru[j]->is_slave=0; + + LOG_I(PHY,"RU %d ota_sync_enabled=%s\n",j,*(RUParamList.paramarray[j][RU_OTA_SYNC_ENABLE_IDX].strptr)); + + if (strcmp(*(RUParamList.paramarray[j][RU_OTA_SYNC_ENABLE_IDX].strptr), "yes") == 0) ru[j]->ota_sync_enable=1; + else ru[j]->ota_sync_enable=0; + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = eNodeB_3GPP; - RC.ru[j]->state = RU_RUN; - LOG_I(PHY,"Setting function for RU %d to eNodeB_3GPP\n",j); + ru[j]->if_south = LOCAL_RF; + ru[j]->function = eNodeB_3GPP; + ru[j]->state = RU_RUN; + printf("Setting function for RU %d to eNodeB_3GPP\n",j); } else { - RC.ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); - RC.ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); - RC.ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); + ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); + ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); + ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); + ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); + ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); // Check if control port set if (!(config_isparamset(RUParamList.paramarray[j],RU_REMOTE_PORTC_IDX)) ) { LOG_I(PHY,"Removing control port for RU %d\n",j); - RC.ru[j]->has_ctrl_prt = 0; + ru[j]->has_ctrl_prt = 0; } else { - RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); - RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); - LOG_I(PHY," Control port %u \n",RC.ru[j]->eth_params.my_portc); + ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); + ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + LOG_I(PHY," Control port %u \n",ru[j]->eth_params.my_portc); } if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; + ru[j]->if_south = LOCAL_RF; + ru[j]->function = NGFI_RRU_IF5; + ru[j]->eth_params.transp_preference = ETH_UDP_MODE; LOG_I(PHY,"Setting function for RU %d to NGFI_RRU_IF5 (udp)\n",j); } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE; + ru[j]->if_south = LOCAL_RF; + ru[j]->function = NGFI_RRU_IF5; + ru[j]->eth_params.transp_preference = ETH_RAW_MODE; LOG_I(PHY,"Setting function for RU %d to NGFI_RRU_IF5 (raw)\n",j); } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; - RC.ru[j]->has_ctrl_prt =1; + ru[j]->if_south = LOCAL_RF; + ru[j]->function = NGFI_RRU_IF4p5; + ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; + ru[j]->has_ctrl_prt =1; LOG_I(PHY,"Setting function for RU %d to NGFI_RRU_IF4p5 (udp)\n",j); } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { - RC.ru[j]->if_south = LOCAL_RF; - RC.ru[j]->function = NGFI_RRU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; - RC.ru[j]->has_ctrl_prt =1; + ru[j]->if_south = LOCAL_RF; + ru[j]->function = NGFI_RRU_IF4p5; + ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; + ru[j]->has_ctrl_prt =1; LOG_I(PHY,"Setting function for RU %d to NGFI_RRU_IF4p5 (raw)\n",j); } - - LOG_I(PHY,"RU %d is_slave=%s\n",j,*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr)); - - if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) RC.ru[j]->is_slave=1; - else RC.ru[j]->is_slave=0; - - LOG_I(PHY,"RU %d ota_sync_enabled=%s\n",j,*(RUParamList.paramarray[j][RU_OTA_SYNC_ENABLE_IDX].strptr)); - - if (strcmp(*(RUParamList.paramarray[j][RU_OTA_SYNC_ENABLE_IDX].strptr), "yes") == 0) RC.ru[j]->ota_sync_enable=1; - else RC.ru[j]->ota_sync_enable=0; } - RC.ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; - RC.ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); - RC.ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; + ru[j]->max_pdschReferenceSignalPower = *(RUParamList.paramarray[j][RU_MAX_RS_EPRE_IDX].uptr);; + ru[j]->max_rxgain = *(RUParamList.paramarray[j][RU_MAX_RXGAIN_IDX].uptr); + ru[j]->num_bands = RUParamList.paramarray[j][RU_BAND_LIST_IDX].numelt; /* sf_extension is in unit of samples for 30.72MHz here, has to be scaled later */ - RC.ru[j]->sf_extension = *(RUParamList.paramarray[j][RU_SF_EXTENSION_IDX].uptr); + ru[j]->sf_extension = *(RUParamList.paramarray[j][RU_SF_EXTENSION_IDX].uptr); - for (i=0; inum_bands; i++) RC.ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; + for (i=0; inum_bands; i++) ru[j]->band[i] = RUParamList.paramarray[j][RU_BAND_LIST_IDX].iptr[i]; } //strcmp(local_rf, "yes") == 0 -else { + else { LOG_I(PHY,"RU %d: Transport %s\n",j,*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr)); - RC.ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); - RC.ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); - RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); - RC.ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); - RC.ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); + ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); + ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); + ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); + ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); + ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); + ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { - RC.ru[j]->if_south = REMOTE_IF5; - RC.ru[j]->function = NGFI_RAU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; + ru[j]->if_south = REMOTE_IF5; + ru[j]->function = NGFI_RAU_IF5; + ru[j]->eth_params.transp_preference = ETH_UDP_MODE; } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_ecpri_if5") == 0) { - RC.ru[j]->if_south = REMOTE_IF5; - RC.ru[j]->function = NGFI_RAU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF5_ECPRI_MODE; + ru[j]->if_south = REMOTE_IF5; + ru[j]->function = NGFI_RAU_IF5; + ru[j]->eth_params.transp_preference = ETH_UDP_IF5_ECPRI_MODE; } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { - RC.ru[j]->if_south = REMOTE_IF5; - RC.ru[j]->function = NGFI_RAU_IF5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE; + ru[j]->if_south = REMOTE_IF5; + ru[j]->function = NGFI_RAU_IF5; + ru[j]->eth_params.transp_preference = ETH_RAW_MODE; } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { - RC.ru[j]->if_south = REMOTE_IF4p5; - RC.ru[j]->function = NGFI_RAU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; - RC.ru[j]->has_ctrl_prt = 1; + ru[j]->if_south = REMOTE_IF4p5; + ru[j]->function = NGFI_RAU_IF4p5; + ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; + ru[j]->has_ctrl_prt = 1; } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { - RC.ru[j]->if_south = REMOTE_IF4p5; - RC.ru[j]->function = NGFI_RAU_IF4p5; - RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; - RC.ru[j]->has_ctrl_prt = 1; + ru[j]->if_south = REMOTE_IF4p5; + ru[j]->function = NGFI_RAU_IF4p5; + ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; + ru[j]->has_ctrl_prt = 1; - if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) RC.ru[j]->is_slave=1; - else RC.ru[j]->is_slave=0; + if (strcmp(*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr), "yes") == 0) ru[j]->is_slave=1; + else ru[j]->is_slave=0; } } /* strcmp(local_rf, "yes") != 0 */ - RC.ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); - RC.ru[j]->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); - RC.ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); - RC.ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); + ru[j]->nb_tx = *(RUParamList.paramarray[j][RU_NB_TX_IDX].uptr); + ru[j]->nb_rx = *(RUParamList.paramarray[j][RU_NB_RX_IDX].uptr); + ru[j]->att_tx = *(RUParamList.paramarray[j][RU_ATT_TX_IDX].uptr); + ru[j]->att_rx = *(RUParamList.paramarray[j][RU_ATT_RX_IDX].uptr); + *ru_mask= (*ru_mask)|(1<configured = 0; + for (int ru_id=0;ru_idnum_RU;ru_id++) { + int ru_idx = RC.eNB[enb_id][cc_id]->RU_list[ru_id]->idx; + RC.ru_mask |= (1 << ru_idx); + set_function_spec_param(RC.ru[ru_idx]); + } } - - RC.ru_mask |= (1 << ru->idx); - set_function_spec_param(RC.ru[enb_id]); /* reset the list of connected UEs in the MAC, since in this process with * loose all UEs (have to reconnect) */ init_UE_info(&RC.mac[enb_id]->UE_info); @@ -464,9 +466,15 @@ int restart_L1L2(module_id_t enb_id) { /* 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;*/ + for (int cc_id=0;cc_idnum_RU;ru_id++) { + int ru_idx = RC.eNB[enb_id][cc_id]->RU_list[ru_id]->idx; + + init_RU_proc(RC.ru[ru_idx]); + RC.ru[ru_idx]->rf_map.card = 0; + RC.ru[ru_idx]->rf_map.chain = 0; /* CC_id + chain_offset;*/ + } + } wait_RUs(); init_eNB_afterRU(); printf("Sending sync to all threads\n"); @@ -579,7 +587,7 @@ int main ( int argc, char **argv ) /* We need to read RU configuration before FlexRAN starts so it knows what * splits to report. Actual RU start comes later. */ if (RC.nb_RU > 0 && NFAPI_MODE != NFAPI_MODE_VNF) { - RCconfig_RU(); + RC.ru = RCconfig_RU(RC.nb_RU,RC.nb_L1_inst,RC.eNB,&RC.ru_mask,&RC.ru_mutex,&RC.ru_cond); LOG_I(PHY, "number of L1 instances %d, number of RU %d, number of CPU cores %d\n", RC.nb_L1_inst, RC.nb_RU, get_nprocs()); @@ -656,6 +664,7 @@ int main ( int argc, char **argv ) for (int x=0; x < RC.nb_L1_inst; x++) for (int CC_id=0; CC_idproc.L1_proc; + L1_rxtx_proc_t *L1proctx= &RC.eNB[x][CC_id]->proc.L1_proc_tx; L1proc->threadPool=(tpool_t*)malloc(sizeof(tpool_t)); L1proc->respEncode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); L1proc->respDecode=(notifiedFIFO_t*) malloc(sizeof(notifiedFIFO_t)); @@ -663,9 +672,11 @@ int main ( int argc, char **argv ) initTpool(get_softmodem_params()->threadPoolConfig, L1proc->threadPool, true); else initTpool("n", L1proc->threadPool, true); - initNotifiedFIFO(L1proc->respEncode); - initNotifiedFIFO(L1proc->respDecode); - RC.eNB[x][CC_id]->proc.L1_proc_tx.threadPool = L1proc->threadPool; + initNotifiedFIFO(L1proc->respEncode); + initNotifiedFIFO(L1proc->respDecode); + L1proctx->threadPool=L1proc->threadPool; + L1proctx->respEncode=L1proc->respEncode; + L1proctx->nbEncode=L1proc->nbEncode; } @@ -680,7 +691,7 @@ int main ( int argc, char **argv ) // some initialization is necessary and init_ru_vnf do this. if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) { printf("Initializing RU threads\n"); - init_RU(get_softmodem_params()->rf_config_file,get_softmodem_params()->send_dmrs_sync); + init_RU(RC.ru,RC.nb_RU,RC.eNB,RC.nb_L1_inst,RC.nb_L1_CC,get_softmodem_params()->rf_config_file,get_softmodem_params()->send_dmrs_sync); for (ru_id=0; ru_idrf_map.card=0; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 4adab5fa24..a1b261f263 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -78,7 +78,6 @@ #define CONFIG_HLP_UESCAN "set UE to scan around carrier\n" #define CONFIG_HLP_EMULIFACE "Set the interface name for the multicast transport for emulation mode (e.g. eth0, lo, etc.) \n" #define CONFIG_HLP_PRB "Set the PRB, valid values: 6, 25, 50, 100 \n" -#define CONFIG_HLP_SSC "Set the start subcarrier \n" #define CONFIG_HLP_DLSHIFT "dynamic shift for LLR compuation for TM3/4 (default 0)\n" #define CONFIG_HLP_USRP_ARGS "set the arguments to identify USRP (same syntax as in UHD)\n" #define CONFIG_HLP_DMAMAP "sets flag for improved EXMIMO UE performance\n" @@ -98,7 +97,6 @@ /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_UEPARAMS_DESC { \ - {"siml1", CONFIG_HLP_SIML1, PARAMFLAG_BOOL, iptr:&simL1flag, defintval:0, TYPE_INT, 0}, \ {"U", CONFIG_HLP_NUMUE, 0, u16ptr:&NB_UE_INST, defuintval:1, TYPE_UINT16, 0}, \ {"ue-rxgain", CONFIG_HLP_UERXG, 0, dblptr:&(rx_gain[0][0]), defdblval:130, TYPE_DOUBLE, 0}, \ {"ue-rxgain-off", CONFIG_HLP_UERXGOFF, 0, dblptr:&rx_gain_off, defdblval:0, TYPE_DOUBLE, 0}, \ @@ -172,7 +170,7 @@ extern void init_RU_proc(RU_t *ru); extern void stop_RU(int nb_ru); extern void kill_RU_proc(RU_t *ru); extern void set_function_spec_param(RU_t *ru); -extern void init_RU(char *, int send_dmrssync); +extern void init_RU(RU_t **rup,int nb_RU,PHY_VARS_eNB ***eNBp,int nb_L1,int *nb_CC,char *rf_config_file, int send_dmrssync); // In lte-ue.c extern int setup_ue_buffers(PHY_VARS_UE **phy_vars_ue, openair0_config_t *openair0_cfg); @@ -200,7 +198,6 @@ extern void init_te_thread(PHY_VARS_eNB *); extern void kill_td_thread(PHY_VARS_eNB *); extern void kill_te_thread(PHY_VARS_eNB *); -extern void RCConfig_sim(void); extern void init_ocm(void); extern void init_ue_devices(PHY_VARS_UE *); diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 82140ea5aa..6e6c2533b4 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -32,6 +32,7 @@ #include "lte-softmodem.h" #include "rt_wrapper.h" +#include "system.h" #include "LAYER2/MAC/mac.h" #include "RRC/LTE/rrc_extern.h" @@ -230,14 +231,23 @@ void init_thread(int sched_runtime, } #else + int settingPriority = 1; - if (CPU_COUNT(cpuset) > 0) - AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), ""); + if (checkIfFedoraDistribution()) + if (checkIfGenericKernelOnFedora()) + if (checkIfInsideContainer()) + settingPriority = 0; + + if (settingPriority) { + if (CPU_COUNT(cpuset) > 0) + AssertFatal( 0 == pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), cpuset), ""); + + struct sched_param sp; + sp.sched_priority = sched_fifo; + AssertFatal(pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp)==0, + "Can't set thread priority, Are you root?\n"); + } - struct sched_param sp; - sp.sched_priority = sched_fifo; - AssertFatal(pthread_setschedparam(pthread_self(),SCHED_FIFO,&sp)==0, - "Can't set thread priority, Are you root?\n"); /* Check the actual affinity mask assigned to the thread */ cpu_set_t *cset=CPU_ALLOC(CPU_SETSIZE); @@ -283,13 +293,7 @@ void init_UE(int nb_inst, LOG_I(PHY,"Allocating UE context %d\n",inst); - if ( !IS_SOFTMODEM_SIML1 ) PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0); - else { - // needed for memcopy below. these are not used in the RU, but needed for UE - RC.ru[0]->frame_parms->nb_antennas_rx = fp0->nb_antennas_rx; - RC.ru[0]->frame_parms->nb_antennas_tx = fp0->nb_antennas_tx; - PHY_vars_UE_g[inst][0] = init_ue_vars(RC.ru[0]->frame_parms,inst,0); - } + PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0); // turn off timing control loop in UE PHY_vars_UE_g[inst][0]->no_timing_correction = timing_correction; @@ -371,17 +375,13 @@ void init_UE(int nb_inst, */ UE->N_TA_offset = 0; - if (IS_SOFTMODEM_SIML1 ) init_ue_devices(UE); - LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); init_UE_threads(inst); - if (!IS_SOFTMODEM_SIML1 ) { - ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]); + ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]); - if (ret !=0) { - exit_fun("Error loading device library"); - } + if (ret !=0) { + exit_fun("Error loading device library"); } UE->rfdevice.host_type = RAU_HOST; diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 3714b0dc6f..026e6d4a60 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -86,7 +86,6 @@ #include "lte-softmodem.h" -msc_interface_t msc_interface; /* temporary compilation wokaround (UE/eNB split */ uint16_t sf_ahead; @@ -193,6 +192,9 @@ int oaisim_flag=0; */ uint8_t abstraction_flag=0; +// needed for pdcp.c +RAN_CONTEXT_t RC; + /* forward declarations */ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]); @@ -286,7 +288,6 @@ static void get_options(void) { int dumpframe=0; int timingadv=0; uint8_t nfapi_mode = NFAPI_MONOLITHIC; - int simL1flag =0; set_default_frame_parms(frame_parms); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); @@ -300,8 +301,6 @@ static void get_options(void) { config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); nfapi_setmode(nfapi_mode); - if (simL1flag) - set_softmodem_optmask(SOFTMODEM_SIML1_BIT); if (loopfile != NULL) { printf("Input file for hardware emulation: %s",loopfile); @@ -574,11 +573,6 @@ int main( int argc, char **argv ) { EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1; printf("Running with %d UE instances\n",NB_UE_INST); - if (NB_UE_INST > 1 && (!IS_SOFTMODEM_SIML1) && NFAPI_MODE!=NFAPI_UE_STUB_PNF) { - printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n"); - abort(); - } - // Checking option of nums_ue_thread. if(NB_THREAD_INST < 1) { printf("Running with 0 UE rxtx thread, exiting.\n"); @@ -649,9 +643,6 @@ int main( int argc, char **argv ) { } } else init_openair0(frame_parms[0],(int)rx_gain[0][0]); - if (IS_SOFTMODEM_SIML1 ) { - RCConfig_sim(); - } cpuf=get_cpu_freq_GHz(); @@ -753,10 +744,6 @@ int main( int argc, char **argv ) { //p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX; - if (IS_SOFTMODEM_SIML1 ) { - init_ocm(); - PHY_vars_UE_g[0][0]->no_timing_correction = 1; - } if(IS_SOFTMODEM_DOSCOPE) load_softscope("ue",NULL); diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index b051868825..da3a2d3cfe 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -43,6 +43,7 @@ #include #include #include "rt_wrapper.h" +#include "system.h" #include #include @@ -294,6 +295,7 @@ void thread_top_init(char *thread_name, struct sched_param sparam; char cpu_affinity[1024]; cpu_set_t cpuset; + int settingPriority = 1; /* Set affinity mask to include CPUs 2 to MAX_CPUS */ /* CPU 0 is reserved for UHD threads */ @@ -340,30 +342,37 @@ void thread_top_init(char *thread_name, } } - memset(&sparam, 0, sizeof(sparam)); - sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); - policy = SCHED_FIFO ; - - s = pthread_setschedparam(pthread_self(), policy, &sparam); - if (s != 0) { - perror("pthread_setschedparam : "); - exit_fun("Error setting thread priority"); - } - - s = pthread_getschedparam(pthread_self(), &policy, &sparam); - if (s != 0) { - perror("pthread_getschedparam : "); - exit_fun("Error getting thread priority"); - } + if (checkIfFedoraDistribution()) + if (checkIfGenericKernelOnFedora()) + if (checkIfInsideContainer()) + settingPriority = 0; - pthread_setname_np(pthread_self(), thread_name); + if (settingPriority) { + memset(&sparam, 0, sizeof(sparam)); + sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); + policy = SCHED_FIFO; + + s = pthread_setschedparam(pthread_self(), policy, &sparam); + if (s != 0) { + perror("pthread_setschedparam : "); + exit_fun("Error setting thread priority"); + } + + s = pthread_getschedparam(pthread_self(), &policy, &sparam); + if (s != 0) { + perror("pthread_getschedparam : "); + exit_fun("Error getting thread priority"); + } - LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(), - (policy == SCHED_FIFO) ? "SCHED_FIFO" : - (policy == SCHED_RR) ? "SCHED_RR" : - (policy == SCHED_OTHER) ? "SCHED_OTHER" : - "???", - sparam.sched_priority, cpu_affinity ); + pthread_setname_np(pthread_self(), thread_name); + + LOG_I(HW, "[SCHED][eNB] %s started on CPU %d, sched_policy = %s , priority = %d, CPU Affinity=%s \n",thread_name,sched_getcpu(), + (policy == SCHED_FIFO) ? "SCHED_FIFO" : + (policy == SCHED_RR) ? "SCHED_RR" : + (policy == SCHED_OTHER) ? "SCHED_OTHER" : + "???", + sparam.sched_priority, cpu_affinity ); + } #endif //LOW_LATENCY diff --git a/targets/RT/USER/ru_control.c b/targets/RT/USER/ru_control.c index 7ac6a8913e..95b5ce6155 100644 --- a/targets/RT/USER/ru_control.c +++ b/targets/RT/USER/ru_control.c @@ -61,30 +61,17 @@ #include "PHY/LTE_TRANSPORT/if4_tools.h" #include "PHY/LTE_TRANSPORT/if5_tools.h" -#include "PHY/phy_extern.h" -#include "LAYER2/MAC/mac_extern.h" #include "PHY/LTE_TRANSPORT/transport_proto.h" #include "SCHED/sched_eNB.h" #include "PHY/LTE_ESTIMATION/lte_estimation.h" #include "PHY/INIT/phy_init.h" -#include "LAYER2/MAC/mac.h" -#include "LAYER2/MAC/mac_extern.h" -#include "LAYER2/MAC/mac_proto.h" -#include "RRC/LTE/rrc_extern.h" -#include "PHY_INTERFACE/phy_interface.h" - #include "common/utils/LOG/log.h" -#include "UTIL/OTG/otg_tx.h" -#include "UTIL/OTG/otg_externs.h" -#include "UTIL/MATH/oml.h" -#include "UTIL/OPT/opt.h" -#include "enb_config.h" int attach_rru(RU_t *ru); -void configure_ru(int idx, void *arg); -void configure_rru(int idx, void *arg); +void configure_ru(RU_t *ru, void *arg); +void configure_rru(RU_t *ru, void *arg); void fill_rf_config(RU_t *ru, char *rf_config_file); void* ru_thread_control( void* param ); @@ -164,7 +151,7 @@ int send_capab(RU_t *ru) cap->FH_fmt = MBP_IF5; break; default: - AssertFatal(1==0,"RU_function is unknown %d\n",RC.ru[0]->function); + AssertFatal(1==0,"RU_function is unknown %d\n",ru->function); break; } cap->num_bands = ru->num_bands; @@ -224,7 +211,7 @@ int attach_rru(RU_t *ru) LOG_E(PHY,"Received incorrect message %d from RRU %d\n",rru_config_msg.type,ru->idx); } } - configure_ru(ru->idx, + configure_ru(ru, (RRU_capabilities_t *)&rru_config_msg.msg[0]); rru_config_msg.type = RRU_config; @@ -296,7 +283,7 @@ int connect_rau(RU_t *ru) cap->FH_fmt = MBP_IF5; break; default: - AssertFatal(1==0,"RU_function is unknown %d\n",RC.ru[0]->function); + AssertFatal(1==0,"RU_function is unknown %d\n",ru->function); break; } cap->num_bands = ru->num_bands; @@ -335,7 +322,7 @@ int connect_rau(RU_t *ru) ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); - configure_rru(ru->idx, + configure_rru(ru, (void*)&rru_config_msg.msg[0]); configuration_received = 1; } @@ -388,21 +375,20 @@ int check_capabilities(RU_t *ru, return(-1); } -void configure_ru(int idx, +void configure_ru(RU_t *ru, void *arg) { - RU_t *ru = RC.ru[idx]; RRU_config_t *config = (RRU_config_t *)arg; RRU_capabilities_t *capabilities = (RRU_capabilities_t*)arg; int ret; - LOG_I(PHY, "Received capabilities from RRU %d\n",idx); + LOG_I(PHY, "Received capabilities from RRU %d\n",ru->idx); if (capabilities->FH_fmt < MAX_FH_FMTs) LOG_I(PHY, "RU FH options %s\n",rru_format_options[capabilities->FH_fmt]); AssertFatal((ret=check_capabilities(ru,capabilities)) == 0, - "Cannot configure RRU %d, check_capabilities returned %d\n", idx,ret); + "Cannot configure RRU %d, check_capabilities returned %d\n", ru->idx,ret); // take antenna capabilities of RRU ru->nb_tx = capabilities->nb_tx[0]; ru->nb_rx = capabilities->nb_rx[0]; @@ -440,11 +426,10 @@ void configure_ru(int idx, phy_init_RU(ru); } -void configure_rru(int idx, +void configure_rru(RU_t *ru, void *arg) { RRU_config_t *config = (RRU_config_t *)arg; - RU_t *ru = RC.ru[idx]; ru->frame_parms->eutra_band = config->band_list[0]; ru->frame_parms->dl_CarrierFreq = config->tx_freq[0]; @@ -486,7 +471,6 @@ void configure_rru(int idx, static int send_update_rru(RU_t * ru, LTE_DL_FRAME_PARMS * fp){ //ssize_t msg_len/*,len*/; int i; - //LTE_DL_FRAME_PARMS *fp = &RC.eNB[0][0]->frame_parms; RRU_CONFIG_msg_t rru_config_msg; memset((void *)&rru_config_msg,0,sizeof(rru_config_msg)); rru_config_msg.type = RRU_config_update; @@ -535,7 +519,7 @@ void* ru_thread_control( void* param ) send_tick(ru); if (ru->state == RU_RUN && ru->if_south != LOCAL_RF){ - LTE_DL_FRAME_PARMS *fp = &RC.eNB[0][0]->frame_parms; + LTE_DL_FRAME_PARMS *fp = &ru->eNB_list[0]->frame_parms; LOG_D(PHY,"Check MBSFN SF changes\n"); if(fp->num_MBSFN_config != ru_sf_update){ ru_sf_update = fp->num_MBSFN_config; @@ -579,7 +563,7 @@ void* ru_thread_control( void* param ) ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_tx[0], ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_rx[0]); - configure_ru(ru->idx,(RRU_capabilities_t *)&rru_config_msg.msg[0]); + configure_ru(ru,(RRU_capabilities_t *)&rru_config_msg.msg[0]); // send config if (send_config(ru,rru_config_msg) == 0) ru->state = RU_CONFIG; @@ -603,7 +587,7 @@ void* ru_thread_control( void* param ) ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); ru->frame_parms = calloc(1, sizeof(*ru->frame_parms)); - configure_rru(ru->idx, (void*)&rru_config_msg.msg[0]); + configure_rru(ru, (void*)&rru_config_msg.msg[0]); fill_rf_config(ru,ru->rf_config_file); @@ -652,10 +636,10 @@ void* ru_thread_control( void* param ) LOG_I(PHY, "Signaling main thread that RU %d (is_slave %d) is ready in state %s\n",ru->idx,ru->is_slave,ru_states[ru->state]); - pthread_mutex_lock(&RC.ru_mutex); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - pthread_mutex_unlock(&RC.ru_mutex); + pthread_mutex_lock(ru->ru_mutex); + *ru->ru_mask &= ~(1<idx); + pthread_cond_signal(ru->ru_cond); + pthread_mutex_unlock(ru->ru_mutex); wait_sync("ru_thread_control"); @@ -710,10 +694,10 @@ void* ru_thread_control( void* param ) if (ru->state == RU_READY){ LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); - pthread_mutex_lock(&RC.ru_mutex); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - pthread_mutex_unlock(&RC.ru_mutex); + pthread_mutex_lock(ru->ru_mutex); + *ru->ru_mask &= ~(1<idx); + pthread_cond_signal(ru->ru_cond); + pthread_mutex_unlock(ru->ru_mutex); wait_sync("ru_thread_control"); @@ -736,7 +720,7 @@ void* ru_thread_control( void* param ) break; case RRU_sync_ok: //RAU - if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_config_ok msg...Ignoring\n"); + if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_sync_ok msg...Ignoring\n"); else{ if (ru->is_slave == 1){ printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Received RRU_sync_ok from RRU %d\n",ru->idx);