NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
control_channel.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2025 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #ifndef APPLICATIONS_STORAGE_STORAGE_COMMON_CONTROL_CHANNEL_HPP_
27 #define APPLICATIONS_STORAGE_STORAGE_COMMON_CONTROL_CHANNEL_HPP_
28 
29 #include <cstdint>
30 #include <functional>
31 #include <memory>
32 #include <vector>
33 
34 #include <doca_dev.h>
35 #include <doca_comch.h>
36 
39 
40 namespace storage::control {
41 
42 class channel {
43 public:
44  virtual ~channel() = default;
45 
46  virtual bool is_connected() = 0;
47  virtual void send_message(message const &msg) = 0;
49 };
50 
52 public:
53  virtual doca_comch_connection *get_comch_connection() const noexcept = 0;
54 
55  using consumer_event_callback = std::function<void(void *user_data, uint32_t consumer_id)>;
56 };
57 
59  doca_dev *dev,
60  char const *channel_name,
61  void *callback_user_data,
62  comch_channel::consumer_event_callback new_consumer_event_cb,
63  comch_channel::consumer_event_callback expired_consumer_event_cb);
64 
66  doca_dev *dev,
67  doca_dev_rep *dev_rep,
68  char const *channel_name,
69  void *callback_user_data,
70  comch_channel::consumer_event_callback new_consumer_event_cb,
71  comch_channel::consumer_event_callback expired_consumer_event_cb);
72 
73 std::unique_ptr<storage::control::channel> make_tcp_client_control_channel(storage::ip_address const &server_address);
74 
75 std::unique_ptr<storage::control::channel> make_tcp_server_control_channel(uint16_t listen_port);
76 
77 } // namespace storage::control
78 
79 #endif /* APPLICATIONS_STORAGE_STORAGE_COMMON_CONTROL_CHANNEL_HPP_ */
virtual ~channel()=default
virtual bool is_connected()=0
virtual storage::control::message * poll()=0
virtual void send_message(message const &msg)=0
virtual doca_comch_connection * get_comch_connection() const noexcept=0
std::function< void(void *user_data, uint32_t consumer_id)> consumer_event_callback
std::unique_ptr< storage::control::comch_channel > make_comch_client_control_channel(doca_dev *dev, char const *channel_name, void *callback_user_data, comch_channel::consumer_event_callback new_consumer_event_cb, comch_channel::consumer_event_callback expired_consumer_event_cb)
std::unique_ptr< storage::control::comch_channel > make_comch_server_control_channel(doca_dev *dev, doca_dev_rep *dev_rep, char const *channel_name, void *callback_user_data, comch_channel::consumer_event_callback new_consumer_event_cb, comch_channel::consumer_event_callback expired_consumer_event_cb)
std::unique_ptr< storage::control::channel > make_tcp_client_control_channel(storage::ip_address const &server_address)
std::unique_ptr< storage::control::channel > make_tcp_server_control_channel(uint16_t listen_port)