Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet formats from the LWA352 OVRO bifrost branch #206

Merged
merged 112 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
4db60f2
Merge remote-tracking branch 'jayce/disk-readers' into py3-disk-reader
jack-h Jun 11, 2020
357283e
Add LWA352 packet format
jack-h Jun 16, 2020
9fb5a09
Add xGPU bindings
Jun 18, 2020
1cf8cdb
remove print
Jun 19, 2020
6d088a2
Add Kernel-only xgpu functions
Jun 21, 2020
9310406
add xgpuSubSelect; fix xgpuKernel
Jun 22, 2020
d18fbe9
Add beamforming code to bifrost
Jun 30, 2020
056d98c
gitignore ctags files
Jun 30, 2020
55b2d6f
Update GPU arch
Jun 30, 2020
0812937
Add embryonic ibverbs packet RX support
Jun 30, 2020
f5d60e4
IBVerbs integration
Jul 2, 2020
324bb2c
Add flag to use ibverbs
Jul 2, 2020
30217af
Change function names to match `bfFunctionName` convention
Jul 2, 2020
faca6c0
Change IB verbs packet capture method name to "udp_capture"
Jul 2, 2020
c411072
Packet receiver OK @ ~28Gb/s
Jul 3, 2020
42c696a
Py2->3 decode; tweak exception raising
Jul 6, 2020
2ec319c
Add gbps throughput to like_top
Jul 6, 2020
498034e
Create new sequences every 480 time samples for SNAP2 packets
Jul 6, 2020
dfdfef8
Merge pull request #1 from realtimeradio/lwa352-ibv
Jul 7, 2020
42619e1
Split up beamforming GEM and dynamic spectra / transpose / integrate
Jul 23, 2020
ce28180
Merge branch 'lwa352' of https://github.com/realtimeradio/bifrost int…
Jul 23, 2020
9f077f2
Add missing ifdefs for IBV code
Jul 24, 2020
6192bc6
Merge remote-tracking branch 'jayce/ibverb-support' into lwa352-ibv
Jul 29, 2020
d0a907a
Remove remnants of JH's hashpipe IBV code
Jul 29, 2020
76da1eb
Remove remnants of JH's hashpipe IBV code
Jul 29, 2020
951b741
Default to buffer 32k packets
Jul 29, 2020
5448539
Merge branch 'lwa352-ibv' into lwa352
Jul 29, 2020
d863296
Remove some unused code
Jul 29, 2020
35e819d
Change how bifrost sequences are defined
Jul 29, 2020
6d42e90
Merge commit '35e819d' into HEAD
Jul 29, 2020
f889f15
Don't use VMA or HWLOC
Jul 29, 2020
d52ebb2
VERMS doesn't need -lvma
Jul 30, 2020
6ee33a1
Tweaks to sequence boundaries
Jul 30, 2020
9206d8f
Make new sequence start when packet seq number resets
Jul 30, 2020
e6fdff1
handle StopIteration exceptions
Aug 1, 2020
f953072
Remove debug print
Aug 1, 2020
fa671f4
Tweak SNAP2 packet format to contain sync time
Aug 10, 2020
8e92235
Add option to sum over freq chans while subselecting baselines
Aug 16, 2020
99c0b5b
Add methods for converting an input order to a visibility order
Aug 16, 2020
63f84d9
Remove IBV option from UDPCapture constructor
Aug 17, 2020
3cb5105
Add function to reorder DP4A xGPU output into visibility matrix
Aug 17, 2020
2eb5ff2
Remove debugging prints
Aug 17, 2020
d9f42e9
Fix conjugations
Sep 4, 2020
4251159
Fix source ID computation
Sep 10, 2020
5f22727
Py3-ize pipeline2dot
Oct 7, 2020
5cc85c5
Add option to conjugate baselines while subselecting
Oct 7, 2020
db72993
Beamformer fixes and comment updates
Oct 20, 2020
246af1c
Add LWA352 voltage packet output
Oct 28, 2020
9c693fd
Syntax error in BfBeamformIntegrate declaration
Nov 17, 2020
d10f38a
Header docstring
Dec 15, 2020
25b74e5
Merge remote-tracking branch 'jayce/disk-readers' into lwa352
jack-h Feb 11, 2021
e2a43cd
Merge branch 'lwa352' of https://github.com/realtimeradio/bifrost int…
jack-h Feb 11, 2021
01a09dc
Merge remote-tracking branch 'origin/lwa-packet-outputs' into lwa352
Feb 11, 2021
fb7db55
Fix mismerge
Feb 11, 2021
72791ee
Re-enable NUMA memory
May 11, 2021
aa70eed
Add back in snap2 packet callback
May 11, 2021
08f8ed8
Merge fix again -- helps if ibverbs actually uses ibverbs(!)
May 11, 2021
91e57fe
Add some debug prints
May 14, 2021
4fb0d0b
Enable HWLOC
May 14, 2021
7aa790e
Allow (hopefully) buffer size and slot size to be different for SNAP2…
May 19, 2021
aebba82
Tweak sequence-has-changed condition
May 20, 2021
39d133b
Remove pring when trying to blank packets
Jun 8, 2021
7ee4b77
Merge remote-tracking branch 'jayce/ibverb-support' into HEAD
Jun 22, 2021
bcbd251
Remove _timeout use (which causes segfaults?)
Jun 22, 2021
d923891
Merge remote-tracking branch 'jayce/ibverb-support' into jayce-ibv-merge
Jun 25, 2021
8c5c52d
Hack to pass through chan0 to bifrost pipeline
Jun 29, 2021
2d89136
Merge branch 'ibverb-support' of https://github.com/jaycedowell/bifro…
Jul 8, 2021
d463a25
Py3 re-fixes
Jul 13, 2021
55784ee
Remove some divergences from JD's ibverb-support branch
Jul 15, 2021
e39cf99
Make compiling actually work when XGPU isn't used
Jul 15, 2021
2e7fb1c
Don't use "pragma pack"
Jul 15, 2021
29536e7
Merge branch 'lwa352-like-top-py3' into lwa352
Jul 15, 2021
f46f364
Always include xgpu header file
Jul 15, 2021
5767a0e
Bigger packet buffers
Jul 15, 2021
fc4704b
re-speedup IBV (and presumably fix a bug)
Jul 20, 2021
35a7b46
Make beamformer GEMM do the right thing
Aug 17, 2021
e2b3b97
Update beamformer calls to match actual data ordering
Aug 17, 2021
787464e
The COR packets 'navg' field has the same units as 'time_tag'.
jaycedowell Aug 17, 2021
9a6e56a
Supply beam coeffs in chan x beam x input [C-ordered] order
Aug 18, 2021
b9bda79
Catch mmap error
Aug 27, 2021
b107bfc
Implement source blanking.
Nov 18, 2021
316871d
Revert "Implement source blanking."
jack-h Jan 9, 2022
8c0699f
Add option to transpose xgpu output
Jan 21, 2022
474d870
Merge pull request #2 from jaycedowell/caltech-bifrost-dsp
jack-h Mar 31, 2022
bb09b87
Merge branch 'ibverb-support' of https://github.com/ledatelescope/bif…
jaycedowell Jun 1, 2023
8a953cc
Need to actually save files...
jaycedowell Jun 1, 2023
9088671
Revert to the ibverb-support version.
jaycedowell Jun 1, 2023
aa064b1
Focus on packet formats for now.
jaycedowell Jun 1, 2023
4e1d318
Focus on packet formats for now.
jaycedowell Jun 1, 2023
4972230
Move verbs buffer control into configure.
jaycedowell Jun 1, 2023
d07b153
lwa352_vbeam_* -> vbeam_*
jaycedowell Jun 1, 2023
b37bf9b
Remove some debugging.
jaycedowell Jun 1, 2023
9d67edb
Catch here as well.
jaycedowell Jun 1, 2023
bc6add7
Attempt to add a non-AVX version of the snap2 packet processor.
jaycedowell Jun 1, 2023
7432067
Now in formats/base.hpp.
jaycedowell Jun 1, 2023
d9736b4
Revert to the ibverb-support version.
jaycedowell Jun 1, 2023
70bf291
Ugh.
jaycedowell Jun 1, 2023
21210ba
This block seems to be causing problems in CI.
jaycedowell Jun 1, 2023
f352ab7
Merge branch 'ibverb-support' into lwa352
jaycedowell Jul 20, 2023
02e2e94
Clean up header filler.
jaycedowell Jul 20, 2023
e783a24
Re-enable missing source blanking.
jaycedowell Jul 20, 2023
ae61dd8
Ugh.
jaycedowell Jul 20, 2023
75c74f6
Fix an off-by-one error from a header mis-match in how packets are ge…
jaycedowell Dec 4, 2023
fae28f7
Merge pull request #3 from jaycedowell/caltech-bifrost-dsp
jaycedowell Dec 8, 2023
84cde94
Merge remote-tracking branch 'upstream/ibverb-support' into lwa352
jaycedowell Dec 8, 2023
b0254e8
I thought this was in configure.ac already.
jaycedowell Dec 8, 2023
b16dc15
Fix a bad merge.
jaycedowell Dec 8, 2023
749f0ba
Give up on packet pacing for now.
jaycedowell Dec 8, 2023
53e4189
Merge remote-tracking branch 'upstream/ibverb-support' into lwa352
jaycedowell Dec 11, 2023
a2aea31
Merge remote-tracking branch 'upstream/ibverb-support' into lwa352
jaycedowell Dec 11, 2023
4562c9d
Merge remote-tracking branch 'upstream/ibverb-support' into lwa352
jaycedowell Mar 19, 2024
e32a32b
Nice.
jaycedowell Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/bifrost/packet_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
self._ref_cache['chips'] = _bf.BFpacketcapture_chips_sequence_callback(fnc)
_check(_bf.bfPacketCaptureCallbackSetCHIPS(
self.obj, self._ref_cache['chips']))
def set_snap2(self, fnc: _bf.BFpacketcapture_snap2_sequence_callback):
self._ref_cache['snap2'] = _bf.BFpacketcapture_snap2_sequence_callback(fnc)
_check(_bf.bfPacketCaptureCallbackSetSNAP2(

Check warning on line 61 in python/bifrost/packet_capture.py

View check run for this annotation

Codecov / codecov/patch

python/bifrost/packet_capture.py#L60-L61

Added lines #L60 - L61 were not covered by tests
self.obj, self._ref_cache['snap2']))
def set_ibeam(self, fnc: _bf.BFpacketcapture_ibeam_sequence_callback):
self._ref_cache['ibeam'] = _bf.BFpacketcapture_ibeam_sequence_callback(fnc)
_check(_bf.bfPacketCaptureCallbackSetIBeam(
Expand Down
4 changes: 4 additions & 0 deletions src/bifrost/packet_capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ typedef int (*BFpacketcapture_simple_sequence_callback)(BFoffset, int, int, int,
BFoffset*, void const**, size_t*);
typedef int (*BFpacketcapture_chips_sequence_callback)(BFoffset, int, int, int,
BFoffset*, void const**, size_t*);
typedef int (*BFpacketcapture_snap2_sequence_callback)(BFoffset, int, int, int,
BFoffset*, void const**, size_t*);
typedef int (*BFpacketcapture_ibeam_sequence_callback)(BFoffset, int, int, int,
BFoffset*, void const**, size_t*);
typedef int (*BFpacketcapture_pbeam_sequence_callback)(BFoffset, BFoffset, int, int, int,
Expand All @@ -65,6 +67,8 @@ BFstatus bfPacketCaptureCallbackSetSIMPLE(BFpacketcapture_callback obj,
BFpacketcapture_simple_sequence_callback callback);
BFstatus bfPacketCaptureCallbackSetCHIPS(BFpacketcapture_callback obj,
BFpacketcapture_chips_sequence_callback callback);
BFstatus bfPacketCaptureCallbackSetSNAP2(BFpacketcapture_callback obj,
BFpacketcapture_snap2_sequence_callback callback);
BFstatus bfPacketCaptureCallbackSetIBeam(BFpacketcapture_callback obj,
BFpacketcapture_ibeam_sequence_callback callback);
BFstatus bfPacketCaptureCallbackSetPBeam(BFpacketcapture_callback obj,
Expand Down
4 changes: 4 additions & 0 deletions src/formats/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ struct PacketDesc {
int src;
int nchan;
int chan0;
int nchan_tot;
int npol;
int pol0;
int npol_tot;
uint32_t sync;
uint64_t time_tag;
int tuning;
Expand Down
4 changes: 3 additions & 1 deletion src/formats/formats.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2023, The Bifrost Authors. All rights reserved.
* Copyright (c) 2019-2024, The Bifrost Authors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -36,5 +36,7 @@
#include "tbn.hpp"
#include "tbf.hpp"
#include "ibeam.hpp"
#include "snap2.hpp"
#include "pbeam.hpp"
#include "simple.hpp"
#include "vbeam.hpp"
2 changes: 1 addition & 1 deletion src/formats/pbeam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class PBeamDecoder: virtual public PacketDecoder {
int pld_size = pkt_size - sizeof(pbeam_hdr_type);
pkt->decimation = be16toh(pkt_hdr->navg);
pkt->time_tag = be64toh(pkt_hdr->seq);
pkt->seq = (pkt->time_tag - 1) / pkt->decimation;
pkt->seq = pkt->time_tag / pkt->decimation;
//pkt->nsrc = pkt_hdr->nserver;
pkt->nsrc = _nsrc;
pkt->src = (pkt_hdr->beam - _src0) * pkt_hdr->nserver + (pkt_hdr->server - 1);
Expand Down
216 changes: 216 additions & 0 deletions src/formats/snap2.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/*
* Copyright (c) 2019-2023, The Bifrost Authors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of The Bifrost Authors nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include "base.hpp"

// All entries are network (i.e. big) endian
struct __attribute__((packed)) snap2_hdr_type {
uint64_t seq; // Spectra counter == packet counter
uint32_t sync_time; // UNIX sync time
uint16_t npol; // Number of pols in this packet
uint16_t npol_tot; // Number of pols total
uint16_t nchan; // Number of channels in this packet
uint16_t nchan_tot; // Number of channels total (for this pipeline)
uint32_t chan_block_id; // ID of this block of chans
uint32_t chan0; // First channel in this packet
uint32_t pol0; // First pol in this packet
};

/*
* The PacketDecoder's job is to unpack
* a packet into a standard PacketDesc
* format, and verify that a packet
* is valid.
*/

#define BF_SNAP2_DEBUG 0

class SNAP2Decoder : virtual public PacketDecoder {
protected:
inline bool valid_packet(const PacketDesc* pkt) const {
//#if BF_SNAP2_DEBUG
// cout << "seq: "<< pkt->seq << endl;
// cout << "src: "<< pkt->src << endl;
// cout << "nsrc: "<< pkt->nsrc << endl;
// cout << "nchan: "<< pkt->nchan << endl;
// cout << "chan0: "<< pkt->chan0 << endl;
//#endif
return (
pkt->seq >= 0
&& pkt->src >= 0
&& pkt->src < _nsrc
&& pkt->nsrc == _nsrc
&& pkt->chan0 >= 0
);
}
public:
SNAP2Decoder(int nsrc, int src0) : PacketDecoder(nsrc, src0) {}
inline bool operator()(const uint8_t* pkt_ptr,
int pkt_size,
PacketDesc* pkt) const {
if( pkt_size < (int)sizeof(snap2_hdr_type) ) {
return false;
}
const snap2_hdr_type* pkt_hdr = (snap2_hdr_type*)pkt_ptr;
const uint8_t* pkt_pld = pkt_ptr + sizeof(snap2_hdr_type);
int pld_size = pkt_size - sizeof(snap2_hdr_type);
pkt->seq = be64toh(pkt_hdr->seq);
pkt->time_tag = be32toh(pkt_hdr->sync_time);
#if BF_SNAP2_DEBUG
fprintf(stderr, "seq: %lu\t", pkt->seq);
fprintf(stderr, "sync_time: %lu\t", pkt->time_tag);
fprintf(stderr, "nchan: %lu\t", be16toh(pkt_hdr->nchan));
fprintf(stderr, "npol: %lu\t", be16toh(pkt_hdr->npol));
#endif
int npol_blocks = (be16toh(pkt_hdr->npol_tot) / be16toh(pkt_hdr->npol));
int nchan_blocks = (be16toh(pkt_hdr->nchan_tot) / be16toh(pkt_hdr->nchan));

pkt->tuning = be32toh(pkt_hdr->chan0); // Abuse this so we can use chan0 to reference channel within pipeline
pkt->nsrc = npol_blocks * nchan_blocks;// _nsrc;
pkt->nchan = be16toh(pkt_hdr->nchan);
pkt->chan0 = be32toh(pkt_hdr->chan_block_id) * be16toh(pkt_hdr->nchan);
pkt->nchan_tot = be16toh(pkt_hdr->nchan_tot);
pkt->npol = be16toh(pkt_hdr->npol);
pkt->npol_tot = be16toh(pkt_hdr->npol_tot);
pkt->pol0 = be32toh(pkt_hdr->pol0);
pkt->src = (pkt->pol0 / pkt->npol) + be32toh(pkt_hdr->chan_block_id) * npol_blocks;
pkt->payload_size = pld_size;
pkt->payload_ptr = pkt_pld;
#if BF_SNAP2_DEBUG
fprintf(stderr, "nsrc: %lu\t", pkt->nsrc);
fprintf(stderr, "src: %lu\t", pkt->src);
fprintf(stderr, "chan0: %lu\t", pkt->chan0);
fprintf(stderr, "chan_block_id: %lu\t", be32toh(pkt_hdr->chan_block_id));
fprintf(stderr, "nchan_tot: %lu\t", pkt->nchan_tot);
fprintf(stderr, "npol_tot: %lu\t", pkt->npol_tot);
fprintf(stderr, "pol0: %lu\n", pkt->pol0);
#endif
return this->valid_packet(pkt);
}
};

class SNAP2Processor : virtual public PacketProcessor {
public:
inline void operator()(const PacketDesc* pkt,
uint64_t seq0,
uint64_t nseq_per_obuf,
int nbuf,
uint8_t* obufs[],
size_t ngood_bytes[],
size_t* src_ngood_bytes[]) {
int obuf_idx = ((pkt->seq - seq0 >= 1*nseq_per_obuf) +
(pkt->seq - seq0 >= 2*nseq_per_obuf));
size_t obuf_seq0 = seq0 + obuf_idx*nseq_per_obuf;
size_t nbyte = pkt->payload_size * BF_UNPACK_FACTOR;
ngood_bytes[obuf_idx] += nbyte;
src_ngood_bytes[obuf_idx][pkt->src] += nbyte;
int payload_size = pkt->payload_size;

size_t obuf_offset = (pkt->seq-obuf_seq0)*pkt->nsrc*payload_size;
typedef unaligned256_type itype; //256 bits = 32 pols / word
typedef aligned256_type otype;

obuf_offset *= BF_UNPACK_FACTOR;

// Note: Using these SSE types allows the compiler to use SSE instructions
// However, they require aligned memory (otherwise segfault)
itype const* __restrict__ in = (itype const*)pkt->payload_ptr;
otype* __restrict__ out = (otype* )&obufs[obuf_idx][obuf_offset];

int words_per_chan_out = pkt->npol_tot >> 5;
int pol_offset_out = pkt->pol0 >> 5;
int pkt_chan = pkt->chan0; // The first channel in this packet

// Copy packet payload one channel at a time.
// Packets have payload format nchans x npols x complexity.
// Output buffer order is chans * npol_total * complexity
// Spacing with which channel chunks are copied depends
// on the total number of channels/pols in the system
int c=0;
#if defined BF_AVX_ENABLED && BF_AVX_ENABLED
__m256i *dest_p;
__m256i vecbuf[2];
uint64_t *in64 = (uint64_t *)in;
dest_p = (__m256i *)(out + (words_per_chan_out * (pkt_chan)) + pol_offset_out);
#endif
//if((pol_offset_out == 0) && (pkt_chan==0) && ((pkt->seq % 120)==0) ){
// fprintf(stderr, "nsrc: %d seq: %d, dest_p: %p obuf idx %d, obuf offset %lu, nseq_per_obuf %d, seq0 %d, nbuf: %d\n", pkt->nsrc, pkt->seq, dest_p, obuf_idx, obuf_offset, nseq_per_obuf, seq0, nbuf);
//}
for(c=0; c<pkt->nchan; c++) {
#if defined BF_AVX_ENABLED && BF_AVX_ENABLED
vecbuf[0] = _mm256_set_epi64x(in64[3], in64[2], in64[1], in64[0]);
vecbuf[1] = _mm256_set_epi64x(in64[7], in64[6], in64[5], in64[4]);
_mm256_stream_si256(dest_p, vecbuf[0]);
_mm256_stream_si256(dest_p+1, vecbuf[1]);
in64 += 8;
dest_p += words_per_chan_out;
#else
::memcpy(&out[pkt->src + pkt->nsrc*c],
&in[c], sizeof(otype));
#endif
}
}

inline void blank_out_source(uint8_t* data,
int src,
int nsrc,
int nchan,
int nseq) {
typedef aligned256_type otype;
otype* __restrict__ aligned_data = (otype*)data;
for( int t=0; t<nseq; ++t ) {
for( int c=0; c<nchan; ++c ) {
::memset(&aligned_data[src + nsrc*(c + nchan*t)],
0, sizeof(otype));
}
}
}
};

class SNAP2HeaderFiller : virtual public PacketHeaderFiller {
public:
inline int get_size() { return sizeof(snap2_hdr_type); }
inline void operator()(const PacketDesc* hdr_base,
BFoffset framecount,
char* hdr) {
snap2_hdr_type* header = reinterpret_cast<snap2_hdr_type*>(hdr);
memset(header, 0, sizeof(snap2_hdr_type));

header->seq = htobe64(hdr_base->seq);
header->npol = 2;
header->npol_tot = 2;
header->nchan = hdr_base->nchan;
header->nchan_tot = hdr_base->nchan * hdr_base->nsrc;
header->chan_block_id = hdr_base->src;
header->chan0 = htons(hdr_base->chan0);
header->pol0 = 0;

}
};
56 changes: 56 additions & 0 deletions src/formats/vbeam.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2019, The Bifrost Authors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of The Bifrost Authors nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include "base.hpp"

struct __attribute__((packed)) vbeam_hdr_type {
uint64_t sync_word;
uint64_t sync_time;
uint64_t time_tag;
double bw_hz;
double sfreq;
uint32_t nchan;
uint32_t chan0;
uint32_t npol;
};

class VBeamHeaderFiller : virtual public PacketHeaderFiller {
public:
inline int get_size() { return sizeof(vbeam_hdr_type); }
inline void operator()(const PacketDesc* hdr_base,
BFoffset framecount,
char* hdr) {
vbeam_hdr_type* header = reinterpret_cast<vbeam_hdr_type*>(hdr);
memset(header, 0, sizeof(vbeam_hdr_type));

header->sync_word = 0xAABBCCDD00000000L;
header->time_tag = htobe64(hdr_base->seq);
}
};
7 changes: 7 additions & 0 deletions src/packet_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ BFstatus bfPacketCaptureCallbackSetCHIPS(BFpacketcapture_callback obj,
return BF_STATUS_SUCCESS;
}

BFstatus bfPacketCaptureCallbackSetSNAP2(BFpacketcapture_callback obj,
BFpacketcapture_snap2_sequence_callback callback) {
BF_ASSERT(obj, BF_STATUS_INVALID_HANDLE);
obj->set_snap2(callback);
return BF_STATUS_SUCCESS;
}

BFstatus bfPacketCaptureCallbackSetIBeam(BFpacketcapture_callback obj,
BFpacketcapture_ibeam_sequence_callback callback) {
BF_ASSERT(obj, BF_STATUS_INVALID_HANDLE);
Expand Down
Loading
Loading