From b99d0f348eada0500ea5d668d5eba283afa6c4a4 Mon Sep 17 00:00:00 2001 From: Ashish Chaudhari Date: Tue, 28 May 2019 13:21:08 -0700 Subject: rfnoc: Added link/graph specific stream managers - Fleshed out mb_iface - Managers currently only export ctrl APIs. Data APIs TBD --- host/lib/include/uhdlib/rfnoc/epid_allocator.hpp | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 host/lib/include/uhdlib/rfnoc/epid_allocator.hpp (limited to 'host/lib/include/uhdlib/rfnoc/epid_allocator.hpp') diff --git a/host/lib/include/uhdlib/rfnoc/epid_allocator.hpp b/host/lib/include/uhdlib/rfnoc/epid_allocator.hpp new file mode 100644 index 000000000..c92ca013d --- /dev/null +++ b/host/lib/include/uhdlib/rfnoc/epid_allocator.hpp @@ -0,0 +1,58 @@ +// +// Copyright 2019 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_LIBUHD_EPID_ALLOCATOR_HPP +#define INCLUDED_LIBUHD_EPID_ALLOCATOR_HPP + +#include +#include +#include +#include + +namespace uhd { namespace rfnoc { + +/*! A class that is responsible for allocating and keeping track of endpoint + * IDs. There shall be one instance of this class per rfnoc_graph + */ +class epid_allocator +{ +public: + using sptr = std::shared_ptr; + + epid_allocator(sep_id_t start_epid = 1); + epid_allocator(const epid_allocator& rhs) = delete; + epid_allocator(epid_allocator&& rhs) = delete; + + /*! \brief Allocate an EPID for the specified endpoint. + * + * \param addr The physical address (device, instance) of the stream endpoint + * \return The allocated EPID + */ + sep_id_t allocate_epid(const sep_addr_t& addr); + + /*! \brief Lookup an EPID and return the address associated with it. + * + * \param epid The allocated EPID + * \return The physical address (device, instance) of the stream endpoint + */ + sep_addr_t lookup_epid(const sep_id_t& epid) const; + + /*! \brief Deallocate the specified EPID. + * + * \param epid The EPID to deallocate + */ + void deallocate_epid(sep_id_t epid); + +private: + std::map _epid_map; + std::map _addr_map; + sep_id_t _next_epid; + mutable std::mutex _mutex; +}; + +}} /* namespace uhd::rfnoc */ + +#endif /* INCLUDED_LIBUHD_EPID_ALLOCATOR_HPP */ -- cgit v1.2.3