about summary refs log tree commit diff
path: root/src/libnm-core-public/nm-setting-sriov.h
blob: affccc48928a84d643f68b4067b1068c9655094f (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2018 Red Hat, Inc.
 */

#ifndef NM_SETTING_SRIOV_H
#define NM_SETTING_SRIOV_H

#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION)
#error "Only <NetworkManager.h> can be included directly."
#endif

#include "nm-setting.h"

G_BEGIN_DECLS

#define NM_TYPE_SETTING_SRIOV (nm_setting_sriov_get_type())
#define NM_SETTING_SRIOV(obj) \
    (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_SETTING_SRIOV, NMSettingSriov))
#define NM_SETTING_SRIOV_CLASS(klass) \
    (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_SETTING_SRIOV, NMSettingSriovClass))
#define NM_IS_SETTING_SRIOV(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_SETTING_SRIOV))
#define NM_IS_SETTING_SRIOV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_SETTING_SRIOV))
#define NM_SETTING_SRIOV_GET_CLASS(obj) \
    (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_SETTING_SRIOV, NMSettingSriovClass))

#define NM_SETTING_SRIOV_SETTING_NAME "sriov"

#define NM_SETTING_SRIOV_TOTAL_VFS           "total-vfs"
#define NM_SETTING_SRIOV_VFS                 "vfs"
#define NM_SETTING_SRIOV_AUTOPROBE_DRIVERS   "autoprobe-drivers"
#define NM_SETTING_SRIOV_ESWITCH_MODE        "eswitch-mode"
#define NM_SETTING_SRIOV_ESWITCH_INLINE_MODE "eswitch-inline-mode"
#define NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE  "eswitch-encap-mode"

#define NM_SRIOV_VF_ATTRIBUTE_MAC         "mac"
#define NM_SRIOV_VF_ATTRIBUTE_SPOOF_CHECK "spoof-check"
#define NM_SRIOV_VF_ATTRIBUTE_TRUST       "trust"
#define NM_SRIOV_VF_ATTRIBUTE_MIN_TX_RATE "min-tx-rate"
#define NM_SRIOV_VF_ATTRIBUTE_MAX_TX_RATE "max-tx-rate"

typedef struct _NMSettingSriovClass NMSettingSriovClass;
typedef struct _NMSriovVF           NMSriovVF;

/**
 * NMSriovVFVlanProtocol:
 * @NM_SRIOV_VF_VLAN_PROTOCOL_802_1Q:  use 802.1Q
 * @NM_SRIOV_VF_VLAN_PROTOCOL_802_1AD: use 802.1ad
 *
 * #NMSriovVFVlanProtocol indicates the VLAN protocol to use.
 *
 * Since: 1.14
 */
typedef enum {
    NM_SRIOV_VF_VLAN_PROTOCOL_802_1Q  = 0,
    NM_SRIOV_VF_VLAN_PROTOCOL_802_1AD = 1,
} NMSriovVFVlanProtocol;

/**
 * NMSriovEswitchMode:
 * @NM_SRIOV_ESWITCH_MODE_PRESERVE:  don't modify current eswitch mode
 * @NM_SRIOV_ESWITCH_MODE_LEGACY:    use legacy SRIOV
 * @NM_SRIOV_ESWITCH_MODE_SWITCHDEV: use switchdev mode
 *
 * Since: 1.46
 */
typedef enum {
    NM_SRIOV_ESWITCH_MODE_PRESERVE  = -1,
    NM_SRIOV_ESWITCH_MODE_UNKNOWN   = -1, /*< skip >*/
    NM_SRIOV_ESWITCH_MODE_LEGACY    = 0,
    NM_SRIOV_ESWITCH_MODE_SWITCHDEV = 1,
} NMSriovEswitchMode;

/**
 * NMSriovEswitchInlineMode:
 * @NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE:  don't modify current inline-mode
 * @NM_SRIOV_ESWITCH_INLINE_MODE_NONE:      don't use inline mode
 * @NM_SRIOV_ESWITCH_INLINE_MODE_LINK:      L2 mode
 * @NM_SRIOV_ESWITCH_INLINE_MODE_NETWORK:   L3 mode
 * @NM_SRIOV_ESWITCH_INLINE_MODE_TRANSPORT: L4 mode
 *
 * Since: 1.46
 */
typedef enum {
    NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE  = -1,
    NM_SRIOV_ESWITCH_INLINE_MODE_UNKNOWN   = -1, /*< skip >*/
    NM_SRIOV_ESWITCH_INLINE_MODE_NONE      = 0,
    NM_SRIOV_ESWITCH_INLINE_MODE_LINK      = 1,
    NM_SRIOV_ESWITCH_INLINE_MODE_NETWORK   = 2,
    NM_SRIOV_ESWITCH_INLINE_MODE_TRANSPORT = 3,
} NMSriovEswitchInlineMode;

/**
 * NMSriovEswitchEncapMode:
 * @NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE: don't modify current encap-mode
 * @NM_SRIOV_ESWITCH_ENCAP_MODE_NONE: disable encapsulation mode
 * @NM_SRIOV_ESWITCH_ENCAP_MODE_BASIC: enable encapsulation mode
 *
 * Since: 1.46
 */
typedef enum {
    NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE = -1,
    NM_SRIOV_ESWITCH_ENCAP_MODE_UNKNOWN  = -1, /*< skip >*/
    NM_SRIOV_ESWITCH_ENCAP_MODE_NONE     = 0,
    NM_SRIOV_ESWITCH_ENCAP_MODE_BASIC    = 1,
} NMSriovEswitchEncapMode;

NM_AVAILABLE_IN_1_14
GType nm_setting_sriov_get_type(void);
NM_AVAILABLE_IN_1_14
NMSetting *nm_setting_sriov_new(void);
NM_AVAILABLE_IN_1_14
guint nm_setting_sriov_get_total_vfs(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_14
guint nm_setting_sriov_get_num_vfs(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_14
NMSriovVF *nm_setting_sriov_get_vf(NMSettingSriov *setting, guint idx);
NM_AVAILABLE_IN_1_14
void nm_setting_sriov_add_vf(NMSettingSriov *setting, NMSriovVF *vf);
NM_AVAILABLE_IN_1_14
void nm_setting_sriov_remove_vf(NMSettingSriov *setting, guint idx);
NM_AVAILABLE_IN_1_14
gboolean nm_setting_sriov_remove_vf_by_index(NMSettingSriov *setting, guint index);
NM_AVAILABLE_IN_1_14
void nm_setting_sriov_clear_vfs(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_14
NMTernary nm_setting_sriov_get_autoprobe_drivers(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_46
NMSriovEswitchMode nm_setting_sriov_get_eswitch_mode(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_46
NMSriovEswitchInlineMode nm_setting_sriov_get_eswitch_inline_mode(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_46
NMSriovEswitchEncapMode nm_setting_sriov_get_eswitch_encap_mode(NMSettingSriov *setting);

NM_AVAILABLE_IN_1_14
gboolean nm_sriov_vf_add_vlan(NMSriovVF *vf, guint vlan_id);
NM_AVAILABLE_IN_1_14
gboolean nm_sriov_vf_remove_vlan(NMSriovVF *vf, guint vlan_id);
NM_AVAILABLE_IN_1_14
const guint *nm_sriov_vf_get_vlan_ids(const NMSriovVF *vf, guint *length);
NM_AVAILABLE_IN_1_14
void nm_sriov_vf_set_vlan_qos(NMSriovVF *vf, guint vlan_id, guint32 qos);
NM_AVAILABLE_IN_1_14
void nm_sriov_vf_set_vlan_protocol(NMSriovVF *vf, guint vlan_id, NMSriovVFVlanProtocol protocol);
NM_AVAILABLE_IN_1_14
guint32 nm_sriov_vf_get_vlan_qos(const NMSriovVF *vf, guint vlan_id);
NM_AVAILABLE_IN_1_14
NMSriovVFVlanProtocol nm_sriov_vf_get_vlan_protocol(const NMSriovVF *vf, guint vlan_id);

NM_AVAILABLE_IN_1_14
GType nm_sriov_vf_get_type(void);
NM_AVAILABLE_IN_1_14
NMSriovVF *nm_sriov_vf_new(guint index);
NM_AVAILABLE_IN_1_14
void nm_sriov_vf_ref(NMSriovVF *vf);
NM_AVAILABLE_IN_1_14
void nm_sriov_vf_unref(NMSriovVF *vf);
NM_AVAILABLE_IN_1_14
gboolean nm_sriov_vf_equal(const NMSriovVF *vf, const NMSriovVF *other);
NM_AVAILABLE_IN_1_14
NMSriovVF *nm_sriov_vf_dup(const NMSriovVF *vf);
NM_AVAILABLE_IN_1_14
guint nm_sriov_vf_get_index(const NMSriovVF *vf);
NM_AVAILABLE_IN_1_14
void nm_sriov_vf_set_attribute(NMSriovVF *vf, const char *name, GVariant *value);
NM_AVAILABLE_IN_1_14
const char **nm_sriov_vf_get_attribute_names(const NMSriovVF *vf);
NM_AVAILABLE_IN_1_14
GVariant *nm_sriov_vf_get_attribute(const NMSriovVF *vf, const char *name);
NM_AVAILABLE_IN_1_42
gboolean
nm_sriov_vf_attribute_validate(const char *name, GVariant *value, gboolean *known, GError **error);

G_END_DECLS

#endif /* NM_SETTING_SRIOV_H */