| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | /* |
| 3 | * Copyright (C) 2018 Red Hat, Inc. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NM_SETTING_SRIOV_H |
| 7 | #define NM_SETTING_SRIOV_H |
| 8 | |
| 9 | #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) |
| 10 | #error "Only <NetworkManager.h> can be included directly." |
| 11 | #endif |
| 12 | |
| 13 | #include "nm-setting.h" |
| 14 | |
| 15 | G_BEGIN_DECLS |
| 16 | |
| 17 | #define NM_TYPE_SETTING_SRIOV (nm_setting_sriov_get_type()) |
| 18 | #define NM_SETTING_SRIOV(obj) \ |
| 19 | (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_SETTING_SRIOV, NMSettingSriov)) |
| 20 | #define NM_SETTING_SRIOV_CLASS(klass) \ |
| 21 | (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_SETTING_SRIOV, NMSettingSriovClass)) |
| 22 | #define NM_IS_SETTING_SRIOV(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_SETTING_SRIOV)) |
| 23 | #define NM_IS_SETTING_SRIOV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_SETTING_SRIOV)) |
| 24 | #define NM_SETTING_SRIOV_GET_CLASS(obj) \ |
| 25 | (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_SETTING_SRIOV, NMSettingSriovClass)) |
| 26 | |
| 27 | #define NM_SETTING_SRIOV_SETTING_NAME "sriov" |
| 28 | |
| 29 | #define NM_SETTING_SRIOV_TOTAL_VFS "total-vfs" |
| 30 | #define NM_SETTING_SRIOV_VFS "vfs" |
| 31 | #define NM_SETTING_SRIOV_AUTOPROBE_DRIVERS "autoprobe-drivers" |
| 32 | #define NM_SETTING_SRIOV_ESWITCH_MODE "eswitch-mode" |
| 33 | #define NM_SETTING_SRIOV_ESWITCH_INLINE_MODE "eswitch-inline-mode" |
| 34 | #define NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE "eswitch-encap-mode" |
| 35 | |
| 36 | #define NM_SRIOV_VF_ATTRIBUTE_MAC "mac" |
| 37 | #define NM_SRIOV_VF_ATTRIBUTE_SPOOF_CHECK "spoof-check" |
| 38 | #define NM_SRIOV_VF_ATTRIBUTE_TRUST "trust" |
| 39 | #define NM_SRIOV_VF_ATTRIBUTE_MIN_TX_RATE "min-tx-rate" |
| 40 | #define NM_SRIOV_VF_ATTRIBUTE_MAX_TX_RATE "max-tx-rate" |
| 41 | |
| 42 | typedef struct _NMSettingSriovClass NMSettingSriovClass; |
| 43 | typedef struct _NMSriovVF NMSriovVF; |
| 44 | |
| 45 | /** |
| 46 | * NMSriovVFVlanProtocol: |
| 47 | * @NM_SRIOV_VF_VLAN_PROTOCOL_802_1Q: use 802.1Q |
| 48 | * @NM_SRIOV_VF_VLAN_PROTOCOL_802_1AD: use 802.1ad |
| 49 | * |
| 50 | * #NMSriovVFVlanProtocol indicates the VLAN protocol to use. |
| 51 | * |
| 52 | * Since: 1.14 |
| 53 | */ |
| 54 | typedef enum { |
| 55 | NM_SRIOV_VF_VLAN_PROTOCOL_802_1Q = 0, |
| 56 | NM_SRIOV_VF_VLAN_PROTOCOL_802_1AD = 1, |
| 57 | } NMSriovVFVlanProtocol; |
| 58 | |
| 59 | /** |
| 60 | * NMSriovEswitchMode: |
| 61 | * @NM_SRIOV_ESWITCH_MODE_PRESERVE: don't modify current eswitch mode |
| 62 | * @NM_SRIOV_ESWITCH_MODE_LEGACY: use legacy SRIOV |
| 63 | * @NM_SRIOV_ESWITCH_MODE_SWITCHDEV: use switchdev mode |
| 64 | * |
| 65 | * Since: 1.46 |
| 66 | */ |
| 67 | typedef enum { |
| 68 | NM_SRIOV_ESWITCH_MODE_PRESERVE = -1, |
| 69 | NM_SRIOV_ESWITCH_MODE_UNKNOWN = -1, /*< skip >*/ |
| 70 | NM_SRIOV_ESWITCH_MODE_LEGACY = 0, |
| 71 | NM_SRIOV_ESWITCH_MODE_SWITCHDEV = 1, |
| 72 | } NMSriovEswitchMode; |
| 73 | |
| 74 | /** |
| 75 | * NMSriovEswitchInlineMode: |
| 76 | * @NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE: don't modify current inline-mode |
| 77 | * @NM_SRIOV_ESWITCH_INLINE_MODE_NONE: don't use inline mode |
| 78 | * @NM_SRIOV_ESWITCH_INLINE_MODE_LINK: L2 mode |
| 79 | * @NM_SRIOV_ESWITCH_INLINE_MODE_NETWORK: L3 mode |
| 80 | * @NM_SRIOV_ESWITCH_INLINE_MODE_TRANSPORT: L4 mode |
| 81 | * |
| 82 | * Since: 1.46 |
| 83 | */ |
| 84 | typedef enum { |
| 85 | NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE = -1, |
| 86 | NM_SRIOV_ESWITCH_INLINE_MODE_UNKNOWN = -1, /*< skip >*/ |
| 87 | NM_SRIOV_ESWITCH_INLINE_MODE_NONE = 0, |
| 88 | NM_SRIOV_ESWITCH_INLINE_MODE_LINK = 1, |
| 89 | NM_SRIOV_ESWITCH_INLINE_MODE_NETWORK = 2, |
| 90 | NM_SRIOV_ESWITCH_INLINE_MODE_TRANSPORT = 3, |
| 91 | } NMSriovEswitchInlineMode; |
| 92 | |
| 93 | /** |
| 94 | * NMSriovEswitchEncapMode: |
| 95 | * @NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE: don't modify current encap-mode |
| 96 | * @NM_SRIOV_ESWITCH_ENCAP_MODE_NONE: disable encapsulation mode |
| 97 | * @NM_SRIOV_ESWITCH_ENCAP_MODE_BASIC: enable encapsulation mode |
| 98 | * |
| 99 | * Since: 1.46 |
| 100 | */ |
| 101 | typedef enum { |
| 102 | NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE = -1, |
| 103 | NM_SRIOV_ESWITCH_ENCAP_MODE_UNKNOWN = -1, /*< skip >*/ |
| 104 | NM_SRIOV_ESWITCH_ENCAP_MODE_NONE = 0, |
| 105 | NM_SRIOV_ESWITCH_ENCAP_MODE_BASIC = 1, |
| 106 | } NMSriovEswitchEncapMode; |
| 107 | |
| 108 | NM_AVAILABLE_IN_1_14 |
| 109 | GType nm_setting_sriov_get_type(void); |
| 110 | NM_AVAILABLE_IN_1_14 |
| 111 | NMSetting *nm_setting_sriov_new(void); |
| 112 | NM_AVAILABLE_IN_1_14 |
| 113 | guint nm_setting_sriov_get_total_vfs(NMSettingSriov *setting); |
| 114 | NM_AVAILABLE_IN_1_14 |
| 115 | guint nm_setting_sriov_get_num_vfs(NMSettingSriov *setting); |
| 116 | NM_AVAILABLE_IN_1_14 |
| 117 | NMSriovVF *nm_setting_sriov_get_vf(NMSettingSriov *setting, guint idx); |
| 118 | NM_AVAILABLE_IN_1_14 |
| 119 | void nm_setting_sriov_add_vf(NMSettingSriov *setting, NMSriovVF *vf); |
| 120 | NM_AVAILABLE_IN_1_14 |
| 121 | void nm_setting_sriov_remove_vf(NMSettingSriov *setting, guint idx); |
| 122 | NM_AVAILABLE_IN_1_14 |
| 123 | gboolean nm_setting_sriov_remove_vf_by_index(NMSettingSriov *setting, guint index); |
| 124 | NM_AVAILABLE_IN_1_14 |
| 125 | void nm_setting_sriov_clear_vfs(NMSettingSriov *setting); |
| 126 | NM_AVAILABLE_IN_1_14 |
| 127 | NMTernary nm_setting_sriov_get_autoprobe_drivers(NMSettingSriov *setting); |
| 128 | NM_AVAILABLE_IN_1_46 |
| 129 | NMSriovEswitchMode nm_setting_sriov_get_eswitch_mode(NMSettingSriov *setting); |
| 130 | NM_AVAILABLE_IN_1_46 |
| 131 | NMSriovEswitchInlineMode nm_setting_sriov_get_eswitch_inline_mode(NMSettingSriov *setting); |
| 132 | NM_AVAILABLE_IN_1_46 |
| 133 | NMSriovEswitchEncapMode nm_setting_sriov_get_eswitch_encap_mode(NMSettingSriov *setting); |
| 134 | |
| 135 | NM_AVAILABLE_IN_1_14 |
| 136 | gboolean nm_sriov_vf_add_vlan(NMSriovVF *vf, guint vlan_id); |
| 137 | NM_AVAILABLE_IN_1_14 |
| 138 | gboolean nm_sriov_vf_remove_vlan(NMSriovVF *vf, guint vlan_id); |
| 139 | NM_AVAILABLE_IN_1_14 |
| 140 | const guint *nm_sriov_vf_get_vlan_ids(const NMSriovVF *vf, guint *length); |
| 141 | NM_AVAILABLE_IN_1_14 |
| 142 | void nm_sriov_vf_set_vlan_qos(NMSriovVF *vf, guint vlan_id, guint32 qos); |
| 143 | NM_AVAILABLE_IN_1_14 |
| 144 | void nm_sriov_vf_set_vlan_protocol(NMSriovVF *vf, guint vlan_id, NMSriovVFVlanProtocol protocol); |
| 145 | NM_AVAILABLE_IN_1_14 |
| 146 | guint32 nm_sriov_vf_get_vlan_qos(const NMSriovVF *vf, guint vlan_id); |
| 147 | NM_AVAILABLE_IN_1_14 |
| 148 | NMSriovVFVlanProtocol nm_sriov_vf_get_vlan_protocol(const NMSriovVF *vf, guint vlan_id); |
| 149 | |
| 150 | NM_AVAILABLE_IN_1_14 |
| 151 | GType nm_sriov_vf_get_type(void); |
| 152 | NM_AVAILABLE_IN_1_14 |
| 153 | NMSriovVF *nm_sriov_vf_new(guint index); |
| 154 | NM_AVAILABLE_IN_1_14 |
| 155 | void nm_sriov_vf_ref(NMSriovVF *vf); |
| 156 | NM_AVAILABLE_IN_1_14 |
| 157 | void nm_sriov_vf_unref(NMSriovVF *vf); |
| 158 | NM_AVAILABLE_IN_1_14 |
| 159 | gboolean nm_sriov_vf_equal(const NMSriovVF *vf, const NMSriovVF *other); |
| 160 | NM_AVAILABLE_IN_1_14 |
| 161 | NMSriovVF *nm_sriov_vf_dup(const NMSriovVF *vf); |
| 162 | NM_AVAILABLE_IN_1_14 |
| 163 | guint nm_sriov_vf_get_index(const NMSriovVF *vf); |
| 164 | NM_AVAILABLE_IN_1_14 |
| 165 | void nm_sriov_vf_set_attribute(NMSriovVF *vf, const char *name, GVariant *value); |
| 166 | NM_AVAILABLE_IN_1_14 |
| 167 | const char **nm_sriov_vf_get_attribute_names(const NMSriovVF *vf); |
| 168 | NM_AVAILABLE_IN_1_14 |
| 169 | GVariant *nm_sriov_vf_get_attribute(const NMSriovVF *vf, const char *name); |
| 170 | NM_AVAILABLE_IN_1_42 |
| 171 | gboolean |
| 172 | nm_sriov_vf_attribute_validate(const char *name, GVariant *value, gboolean *known, GError **error); |
| 173 | |
| 174 | G_END_DECLS |
| 175 | |
| 176 | #endif /* NM_SETTING_SRIOV_H */ |
| 177 | |