aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/dev_ena/ena_inlines.h
blob: 106bd5eaa21e4ada88236dfbbc4dc5b8b98f8367 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: Apache-2.0
 * Copyright(c) 2023 Cisco Systems, Inc.
 */

#ifndef _ENA_INLINES_H_
#define _ENA_INLINES_H_

#include <vppinfra/clib.h>
#include <vppinfra/error_bootstrap.h>
#include <dev_ena/ena.h>

#define ena_log_is_debug()                                                    \
  vlib_log_is_enabled (VLIB_LOG_LEVEL_DEBUG, ena_log.class)

#define ena_stats_log_err(dev, f, ...)                                        \
  vlib_log (VLIB_LOG_LEVEL_ERR, ena_stats_log.class, "%U: " f,                \
	    format_vnet_dev_addr, dev, ##__VA_ARGS__)

#define ena_stats_log_debug(dev, f, ...)                                      \
  vlib_log (VLIB_LOG_LEVEL_DEBUG, ena_stats_log.class, "%U: " f,              \
	    format_vnet_dev_addr, dev, ##__VA_ARGS__)

#define ena_stats_log_is_debug()                                              \
  vlib_log_is_enabled (VLIB_LOG_LEVEL_DEBUG, ena_stats_log.class)

static_always_inline void
ena_set_mem_addr (vlib_main_t *vm, vnet_dev_t *dev, ena_mem_addr_t *m, void *p)
{
  u64 pa = vnet_dev_get_dma_addr (vm, dev, p);
  *m = (ena_mem_addr_t){ .addr_lo = (u32) pa, .addr_hi = (u16) (pa >> 32) };
}

static_always_inline int
ena_aq_feature_is_supported (vnet_dev_t *dev, ena_aq_feature_id_t feat_id)
{
  ena_device_t *ed = vnet_dev_get_data (dev);
  return (ed->dev_attr.supported_features & (1U << feat_id)) != 0;
}

#endif /* ENA_INLINES_H */