Add static_arp config for sriov diabled mode

Also change network configs from list to dict to make it easier to override.

Change-Id: I03f193ab7fdaa91ac8e35f4e2d8d2a5a9f17baa0
diff --git a/mcord-release/mcord-services/Chart.yaml b/mcord-release/mcord-services/Chart.yaml
index b962502..c52dfe9 100644
--- a/mcord-release/mcord-services/Chart.yaml
+++ b/mcord-release/mcord-services/Chart.yaml
@@ -18,4 +18,4 @@
 appVersion: "1.0"
 description: M-CORD services with OMEC inside
 name: mcord-services
-version: 0.1.5
+version: 0.1.6
diff --git a/mcord-release/mcord-services/templates/bin/_spgwu-launch.sh.tpl b/mcord-release/mcord-services/templates/bin/_spgwu-launch.sh.tpl
index c795c01..99ff9ea 100644
--- a/mcord-release/mcord-services/templates/bin/_spgwu-launch.sh.tpl
+++ b/mcord-release/mcord-services/templates/bin/_spgwu-launch.sh.tpl
@@ -21,10 +21,12 @@
 mkdir -p $RUN_DIR/config
 cd $RUN_DIR/config
 cp /etc/dp/config/{cdr.cfg,dp_config.cfg,interface.cfg} .
+{{- if not .Values.network.sriov.enabled }}
+cp /etc/dp/config/static_arp.cfg .
+{{- end }}
 
 sed -i "s/CP_ADDR/$CP_ADDR/g" interface.cfg
 sed -i "s/DP_ADDR/$DP_ADDR/g" interface.cfg
 
 source dp_config.cfg
-
 ngic_dataplane $EAL_ARGS -- $APP_ARGS
diff --git a/mcord-release/mcord-services/templates/configmap-spgwu.yaml b/mcord-release/mcord-services/templates/configmap-spgwu.yaml
index 895bf6c..a984e23 100644
--- a/mcord-release/mcord-services/templates/configmap-spgwu.yaml
+++ b/mcord-release/mcord-services/templates/configmap-spgwu.yaml
@@ -46,6 +46,15 @@
     cp_comm_ip = CP_ADDR
     cp_comm_port = 21
 {{- if not .Values.network.sriov.enabled }}
+  static_arp.cfg: |
+    [sgi]
+{{- range .Values.network.sgi.static_arp }}
+    {{ .ip }}   = {{ .mac }}
+{{- end }}
+    [s1u]
+{{- range .Values.network.s1u.static_arp }}
+    {{ .ip }}   = {{ .mac }}
+{{- end }}
   setup-af-iface.sh: |
 {{ tuple "bin/_spgwu-setup-af-iface.sh.tpl" . | include "mcord-services.template" | indent 4 }}
 {{- end }}
diff --git a/mcord-release/mcord-services/templates/networks.yaml b/mcord-release/mcord-services/templates/networks.yaml
index 8ea9d8e..856345d 100644
--- a/mcord-release/mcord-services/templates/networks.yaml
+++ b/mcord-release/mcord-services/templates/networks.yaml
@@ -14,29 +14,51 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-{{- range .Values.network.networks }}
 ---
 apiVersion: "k8s.cni.cncf.io/v1"
 kind: NetworkAttachmentDefinition
 metadata:
-  name: {{ .name }}
+  name: s1u-net
 {{- if $.Values.network.sriov.enabled }}
   annotations:
     k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_vfio
 {{- end }}
 spec:
   config: '{
-    "type": {{ .type | quote }},
+    "type": {{ .Values.network.s1u.cni_plugin | quote }},
     "ipam": {
-        "type": {{ .ipam | quote }},
-    {{- if eq .ipam "host-local" }}
-        "subnet": {{ .subnet | quote }},
-        "gateway": {{ .gateway | quote }}
-    {{- else if eq .ipam "centralip" }}
+        "type": {{ .Values.network.s1u.ipam | quote }},
+    {{- if eq .Values.network.s1u.ipam "host-local" }}
+        "subnet": {{ .Values.network.s1u.subnet | quote }},
+        "gateway": {{ .Values.network.s1u.gateway | quote }}
+    {{- else if eq .Values.network.s1u.ipam "centralip" }}
         "ipType": "cluster",
-        "network": {{ .subnet | quote }},
-        "etcdURL": {{ $.Values.global.etcdurl | quote }}
+        "network": {{ .Values.network.s1u.subnet | quote }},
+        "etcdURL": {{ .Values.global.etcdurl | quote }}
     {{- end }}
     }
   }'
+---
+apiVersion: "k8s.cni.cncf.io/v1"
+kind: NetworkAttachmentDefinition
+metadata:
+  name: sgi-net
+{{- if $.Values.network.sriov.enabled }}
+  annotations:
+    k8s.v1.cni.cncf.io/resourceName: intel.com/sriov_vfio
 {{- end }}
+spec:
+  config: '{
+    "type": {{ .Values.network.sgi.cni_plugin | quote }},
+    "ipam": {
+        "type": {{ .Values.network.sgi.ipam | quote }},
+    {{- if eq .Values.network.sgi.ipam "host-local" }}
+        "subnet": {{ .Values.network.sgi.subnet | quote }},
+        "gateway": {{ .Values.network.sgi.gateway | quote }}
+    {{- else if eq .Values.network.sgi.ipam "centralip" }}
+        "ipType": "cluster",
+        "network": {{ .Values.network.sgi.subnet | quote }},
+        "etcdURL": {{ .Values.global.etcdurl | quote }}
+    {{- end }}
+    }
+  }'
diff --git a/mcord-release/mcord-services/values.yaml b/mcord-release/mcord-services/values.yaml
index dc4342f..d0970e0 100644
--- a/mcord-release/mcord-services/values.yaml
+++ b/mcord-release/mcord-services/values.yaml
@@ -121,26 +121,36 @@
 
 # Network block defines the networks
 # Note that currently we use fixed list of networks, s1u-net and sgi-net
-# type: provide what type of cni will be used
-#       possible options are vfioveth and ptp
-#       use vfioveth when sriov enabled, and ptp otherwise
+#
+# cni_plugin: provide what type of cni will be used
 # ipam: provide what type of ipam will be used
 #       possible options are centralip and host-local
 #       note that centralip requires etcd cluster
 # subnet: provide subnet range to be assigned to the pod
 # gateway: provide default gateway of the network
-#          valid only when centralip is used
+#       valid only when centralip is used
+# static_arp: provide static arp entries for each network port
+#       valid only when sriov is disabled
+# example usage)
+# - ip: <ip_addr_start> <ip_addr_end>
+#   mac: <ethernet_mac_addr>
+# - ip: <ip_addr>
+#   mac: <ethernet_mac_addr>
+
 network:
   sriov:
     enabled: true
-  networks:
-    - name: s1u-net
-      type: vfioveth
-      ipam: centralip
-      subnet: 119.0.0.0/24
-      gateway: 119.0.0.254
-    - name: sgi-net
-      type: vfioveth
-      ipam: centralip
-      subnet: 13.1.1.0/24
-      gateway: 13.1.1.254
+  s1u:
+    cni_plugin: vfioveth
+    ipam: centralip
+    subnet: 119.0.0.0/24
+    gateway: 119.0.0.254
+    static_arp: null
+  sgi:
+    cni_plugin: vfioveth
+    ipam: centralip
+    subnet: 13.1.1.0/24
+    gateway: 13.1.1.254
+    static_arp:
+    - ip: 13.1.1.254
+      mac: 0e:00:00:00:00:01