NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
definitions.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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_DEFINITIONS_HPP_
27 #define APPLICATIONS_STORAGE_STORAGE_COMMON_DEFINITIONS_HPP_
28 
29 #include <stdexcept>
30 #include <string>
31 
32 #include <doca_error.h>
33 
34 namespace storage {
35 
36 /*
37  * The size of a CPU cache line. This value is typically right but it can be modified if the given platform has a
38  * different cache line size
39  */
40 uint32_t constexpr cache_line_size = 64;
41 
42 /*
43  * Maximum number of supported control messages
44  */
45 uint32_t constexpr max_concurrent_control_messages = 8;
46 
47 /*
48  * Header data placed before the data of a compressed block
49  */
51  uint32_t original_size;
52  uint32_t compressed_size;
53 };
54 
55 /*
56  * Trailer data placed after the data of a compressed block
57  */
59  uint32_t reserved;
60 };
61 
62 /*
63  *
64  */
65 class runtime_error : public std::runtime_error {
66 public:
67  ~runtime_error() override = default;
68  [[maybe_unused]] runtime_error(doca_error_t error, std::string const &msg)
69  : std::runtime_error{msg},
70  m_err{error}
71  {
72  }
73  [[maybe_unused]] runtime_error(doca_error_t error, char const *msg) : std::runtime_error{msg}, m_err{error}
74  {
75  }
76  runtime_error(runtime_error const &) = default;
77  runtime_error(runtime_error &&) noexcept = default;
78  runtime_error &operator=(runtime_error const &) = default;
79  runtime_error &operator=(runtime_error &&) noexcept = default;
80 
81  [[nodiscard]] doca_error_t get_doca_error() const noexcept
82  {
83  return m_err;
84  }
85 
86 private:
87  doca_error_t m_err;
88 };
89 
90 } /* namespace storage */
91 
92 #endif /* APPLICATIONS_STORAGE_STORAGE_COMMON_DEFINITIONS_HPP_ */
runtime_error(runtime_error &&) noexcept=default
~runtime_error() override=default
runtime_error(runtime_error const &)=default
runtime_error(doca_error_t error, char const *msg)
Definition: definitions.hpp:73
runtime_error(doca_error_t error, std::string const &msg)
Definition: definitions.hpp:68
doca_error_t get_doca_error() const noexcept
Definition: definitions.hpp:81
enum doca_error doca_error_t
DOCA API return codes.
constexpr uint32_t cache_line_size
Definition: definitions.hpp:40
constexpr uint32_t max_concurrent_control_messages
Definition: definitions.hpp:45