]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/lib/librte_eal/common/eal_filesystem.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / dpdk / lib / librte_eal / common / eal_filesystem.h
CommitLineData
11fdf7f2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
3 */
4
5/**
6 * @file
7 * Stores functions and path defines for files and directories
8 * on the filesystem for Linux, that are used by the Linux EAL.
9 */
10
11#ifndef EAL_FILESYSTEM_H
12#define EAL_FILESYSTEM_H
13
14/** Path of rte config file. */
15
16#include <stdint.h>
17#include <limits.h>
18#include <unistd.h>
19#include <stdlib.h>
20
21#include <rte_string_fns.h>
22#include "eal_internal_cfg.h"
23
24/* sets up platform-specific runtime data dir */
25int
26eal_create_runtime_dir(void);
27
9f95a23c
TL
28int
29eal_clean_runtime_dir(void);
30
31/** Function to return hugefile prefix that's currently set up */
11fdf7f2 32const char *
9f95a23c 33eal_get_hugefile_prefix(void);
11fdf7f2
TL
34
35#define RUNTIME_CONFIG_FNAME "config"
36static inline const char *
37eal_runtime_config_path(void)
38{
39 static char buffer[PATH_MAX]; /* static so auto-zeroed */
40
9f95a23c 41 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
11fdf7f2
TL
42 RUNTIME_CONFIG_FNAME);
43 return buffer;
44}
45
46/** Path of primary/secondary communication unix socket file. */
47#define MP_SOCKET_FNAME "mp_socket"
48static inline const char *
49eal_mp_socket_path(void)
50{
51 static char buffer[PATH_MAX]; /* static so auto-zeroed */
52
9f95a23c 53 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
11fdf7f2
TL
54 MP_SOCKET_FNAME);
55 return buffer;
56}
57
58#define FBARRAY_NAME_FMT "%s/fbarray_%s"
59static inline const char *
60eal_get_fbarray_path(char *buffer, size_t buflen, const char *name) {
9f95a23c
TL
61 snprintf(buffer, buflen, FBARRAY_NAME_FMT, rte_eal_get_runtime_dir(),
62 name);
11fdf7f2
TL
63 return buffer;
64}
65
66/** Path of hugepage info file. */
67#define HUGEPAGE_INFO_FNAME "hugepage_info"
68static inline const char *
69eal_hugepage_info_path(void)
70{
71 static char buffer[PATH_MAX]; /* static so auto-zeroed */
72
9f95a23c 73 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
11fdf7f2
TL
74 HUGEPAGE_INFO_FNAME);
75 return buffer;
76}
77
78/** Path of hugepage data file. */
79#define HUGEPAGE_DATA_FNAME "hugepage_data"
80static inline const char *
81eal_hugepage_data_path(void)
82{
83 static char buffer[PATH_MAX]; /* static so auto-zeroed */
84
9f95a23c 85 snprintf(buffer, sizeof(buffer) - 1, "%s/%s", rte_eal_get_runtime_dir(),
11fdf7f2
TL
86 HUGEPAGE_DATA_FNAME);
87 return buffer;
88}
89
90/** String format for hugepage map files. */
91#define HUGEFILE_FMT "%s/%smap_%d"
92static inline const char *
93eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir, int f_id)
94{
95 snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
9f95a23c 96 eal_get_hugefile_prefix(), f_id);
11fdf7f2
TL
97 buffer[buflen - 1] = '\0';
98 return buffer;
99}
100
101/** define the default filename prefix for the %s values above */
102#define HUGEFILE_PREFIX_DEFAULT "rte"
103
104/** Function to read a single numeric value from a file on the filesystem.
105 * Used to read information from files on /sys */
106int eal_parse_sysfs_value(const char *filename, unsigned long *val);
107
108#endif /* EAL_FILESYSTEM_H */