From 804ffa12571a8efa137bde08618e136cdb00c40a Mon Sep 17 00:00:00 2001
From: Eric Kooistra <kooistra@astron.nl>
Date: Fri, 26 Nov 2021 12:43:26 +0100
Subject: [PATCH] Changed c_sdp_stat_hdr_field_sel: Changed
 sdp_source_info_reserved and sdp_reserved field in statistics header to MM
 programmable to support future control (default 0). Changed udp_checksum
 field in statistics header to data path driven (will be send as default 0).

---
 .../lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd |  3 +-
 .../sdp/src/vhdl/sdp_statistics_offload.vhd   | 32 ++++++++++++++++---
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd
index 0bb9d3da63..89783576f6 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd
@@ -193,7 +193,8 @@ PACKAGE sdp_pkg is
 
   CONSTANT c_sdp_stat_version_id        : NATURAL := 5;
   CONSTANT c_sdp_stat_nof_hdr_fields    : NATURAL := 1+3+12+4+20+1; -- 608b; 19 32b words
-  CONSTANT c_sdp_stat_hdr_field_sel     : STD_LOGIC_VECTOR(c_sdp_stat_nof_hdr_fields-1 DOWNTO 0) := "1"&"101"&"111011111001"&"0101"&"0100"&"000000000"&"0000100"&"0";  -- 0=data path, 1=MM controlled TODO
+  CONSTANT c_sdp_stat_hdr_field_sel     : STD_LOGIC_VECTOR(c_sdp_stat_nof_hdr_fields-1 DOWNTO 0) := "1"&"101"&"111011111001"&"0100"&"0100"&"000000010"&"1000100"&"0";  -- 0=data path, 1=MM controlled
+--CONSTANT c_sdp_stat_hdr_field_sel     : STD_LOGIC_VECTOR(c_sdp_stat_nof_hdr_fields-1 DOWNTO 0) := "1"&"101"&"111011111001"&"0101"&"0100"&"000000000"&"0000100"&"0";  -- 0=data path, 1=MM controlled TODO (26 nov 2021)
 --CONSTANT c_sdp_stat_hdr_field_sel     : STD_LOGIC_VECTOR(c_sdp_stat_nof_hdr_fields-1 DOWNTO 0) := "0"&"100"&"000000010001"&"0100"&"0100"&"000000010"&"1000000"&"0";  -- 0=data path, 1=MM controlled TODO
 
   CONSTANT c_sdp_stat_hdr_field_arr : t_common_field_arr(c_sdp_stat_nof_hdr_fields-1 DOWNTO 0) := (
diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd
index bab8bb8ca2..93007e6438 100644
--- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd
+++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_statistics_offload.vhd
@@ -159,12 +159,36 @@ BEGIN
   END GENERATE;
     
   -------------------------------------------------------------------------------
-  -- Assemble offload header info
+  -- Assemble offload header info, for data path fields that are selected by:
+  --   c_sdp_stat_hdr_field_sel = "1"&"101"&"111011111001"&"0100"&"0100"&"000000010"&"1000100"&"0"
+  --                                   eth   ip             udp    app
+  --   where 0 = data path, 1 = MM controlled. The '0' fields are assigned here in dp_header_info
+  --   in order:
+  --   . eth: eth_src_mac
+  --   . ip:  ip_total_length,
+  --          ip_header_checksum (not here, will be filled in by 1GbE eth component),
+  --          ip_src_addr
+  --   . udp: udp_src_port,
+  --          udp_total_length
+  --          udp_checksum, (not here, also not calculated in 1GbE eth component because would
+  --            require store and forward, send default 0)
+  --   . app: - sdp_marker, sdp_observation_id, sdp_station_id,
+  --          - sdp_source_info_antenna_band_id,
+  --            sdp_source_info_nyquist_zone_id,
+  --            sdp_source_info_f_adc,
+  --            sdp_source_info_fsub_type,
+  --            sdp_source_info_payload_error,
+  --            sdp_source_info_beam_repositioning_flag,
+  --            sdp_source_info_subband_calibrated_flag,
+  --            sdp_source_info_gn_id,
+  --          - sdp_integration_interval, sdp_data_id, sdp_nof_signal_inputs,
+  --            sdp_nof_statistics_per_packet, sdp_block_period
+  --          - dp_bsn
   -------------------------------------------------------------------------------
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "eth_src_mac"                             ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "eth_src_mac"                             )) <= eth_src_mac;
-  dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "udp_src_port"                            ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "udp_src_port"                            )) <= udp_src_port;
-  dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "ip_src_addr"                             ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "ip_src_addr"                             )) <= ip_src_addr;
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "ip_total_length"                         ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "ip_total_length"                         )) <= TO_UVEC(c_ip_total_length, 16);
+  dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "ip_src_addr"                             ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "ip_src_addr"                             )) <= ip_src_addr;
+  dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "udp_src_port"                            ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "udp_src_port"                            )) <= udp_src_port;
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "udp_total_length"                        ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "udp_total_length"                        )) <= TO_UVEC(c_udp_total_length, 16);
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_marker"                              ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_marker"                              )) <= TO_UVEC(c_marker, 8);
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_observation_id"                      ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_observation_id"                      )) <= sdp_info.observation_id;
@@ -176,9 +200,7 @@ BEGIN
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_source_info_payload_error"           ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_source_info_payload_error"           )) <= SLV(r.payload_err);
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_source_info_beam_repositioning_flag" ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_source_info_beam_repositioning_flag" )) <= SLV(sdp_info.beam_repositioning_flag);
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_source_info_subband_calibrated_flag" ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_source_info_subband_calibrated_flag" )) <= SLV(subband_calibrated_flag);
-  dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_source_info_reserved"                ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_source_info_reserved"                )) <= (OTHERS => '0');
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_source_info_gn_id"                   ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_source_info_gn_id"                   )) <= TO_UVEC(gn_index, 5);
-  dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_reserved"                            ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_reserved"                            )) <= (OTHERS => '0');
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_integration_interval"                ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_integration_interval"                )) <= TO_UVEC(r.integration_interval, 24);
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_data_id"                             ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_data_id"                             )) <= r.data_id;
   dp_header_info(field_hi(c_sdp_stat_hdr_field_arr, "sdp_nof_signal_inputs"                   ) DOWNTO field_lo(c_sdp_stat_hdr_field_arr,  "sdp_nof_signal_inputs"                   )) <= TO_UVEC(c_nof_signal_inputs, 8);
-- 
GitLab