Program Listing for File IBVQueue.h
↰ Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/ska-telescope-ska-pst-recv/checkouts/latest/src/ska/pst/recv/network/IBVQueue.h
)
/*
* Copyright 2022 Square Kilometre Array Observatory
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. Neither the name of the copyright holder 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 AND CONTRIBUTORS "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 HOLDER 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.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <memory>
#include <string>
#include "ska/pst/recv/network/SocketReceive.h"
#include "ska/pst/recv/network/IBVUtils.h"
#include "ska/pst/recv/network/PacketUtils.h"
#ifndef SKA_PST_RECV_NETWORK_IBVSocket_h
#define SKA_PST_RECV_NETWORK_IBVSocket_h
namespace ska::pst::recv {
class IBVQueue : public SocketReceive {
public:
static constexpr size_t max_queue_length = 8192;
IBVQueue() = default;
~IBVQueue();
void allocate_resources(size_t npackets, size_t packet_size);
void configure(const std::string& ip_address, int port);
void deconfigure_beam();
size_t clear_buffered_packets();
void open(const std::string& ipv4_address, int port);
int acquire_packet();
void release_packet(int index);
uint64_t process_sleeps();
char * get_buf_ptr(int slot_index);
protected:
private:
std::vector<char> buffer;
size_t max_raw_size{0};
size_t min_raw_size{0};
size_t n_slots{0};
std::unique_ptr<RDMAEventChannel> ec{nullptr};
std::unique_ptr<RDMACommunicationManager> cm{nullptr};
std::unique_ptr<IBVCompletionQueue> cq{nullptr};
std::unique_ptr<IBVProtectionDomain> pd{nullptr};
std::unique_ptr<IBVQueuePair> qp{nullptr};
std::unique_ptr<IBVMemoryRegion> mr{nullptr};
std::unique_ptr<IBVFlow> fl{nullptr};
PacketBuffer payload;
std::vector<ibv_slot_t> slots;
std::vector<ibv_wc> wc;
std::vector<char *> ptrs;
int curr_slot{-1};
int ipacket{0};
int npackets{0};
};
} // namespace ska::pst::recv
#endif // SKA_PST_RECV_NETWORK_IBVQueue_h