]> git.proxmox.com Git - systemd.git/blame - src/udev/net/link-config.h
New upstream version 249~rc1
[systemd.git] / src / udev / net / link-config.h
CommitLineData
a032b68d 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
aa27b158
MP
2#pragma once
3
6e866b33 4#include "sd-device.h"
db2df898 5
f47781d8 6#include "condition.h"
6e866b33 7#include "conf-parser.h"
db2df898 8#include "ethtool-util.h"
60f067b4 9#include "list.h"
3a6ce677 10#include "net-condition.h"
60f067b4 11
8b3d4ff0
MB
12typedef struct LinkConfigContext LinkConfigContext;
13typedef struct LinkConfig LinkConfig;
60f067b4 14
bb4f798a
MB
15typedef enum MACAddressPolicy {
16 MAC_ADDRESS_POLICY_PERSISTENT,
17 MAC_ADDRESS_POLICY_RANDOM,
18 MAC_ADDRESS_POLICY_NONE,
19 _MAC_ADDRESS_POLICY_MAX,
3a6ce677 20 _MAC_ADDRESS_POLICY_INVALID = -EINVAL,
bb4f798a 21} MACAddressPolicy;
60f067b4
JS
22
23typedef enum NamePolicy {
5eef597e 24 NAMEPOLICY_KERNEL,
7c20daf6 25 NAMEPOLICY_KEEP,
60f067b4
JS
26 NAMEPOLICY_DATABASE,
27 NAMEPOLICY_ONBOARD,
28 NAMEPOLICY_SLOT,
29 NAMEPOLICY_PATH,
30 NAMEPOLICY_MAC,
31 _NAMEPOLICY_MAX,
3a6ce677 32 _NAMEPOLICY_INVALID = -EINVAL,
60f067b4
JS
33} NamePolicy;
34
8b3d4ff0 35struct LinkConfig {
60f067b4
JS
36 char *filename;
37
3a6ce677 38 NetMatch match;
bb4f798a 39 LIST_HEAD(Condition, conditions);
60f067b4
JS
40
41 char *description;
42 struct ether_addr *mac;
bb4f798a 43 MACAddressPolicy mac_address_policy;
60f067b4 44 NamePolicy *name_policy;
46cdbd49 45 NamePolicy *alternative_names_policy;
60f067b4 46 char *name;
46cdbd49 47 char **alternative_names;
60f067b4 48 char *alias;
3a6ce677
BR
49 uint32_t txqueues;
50 uint32_t rxqueues;
51 uint32_t txqueuelen;
b012e921 52 uint32_t mtu;
3a6ce677
BR
53 uint32_t gso_max_segments;
54 size_t gso_max_size;
46cdbd49 55 uint64_t speed;
60f067b4 56 Duplex duplex;
2897b343 57 int autonegotiation;
f2dec872 58 uint32_t advertise[N_ADVERTISE];
8b3d4ff0 59 uint32_t wol;
81c58355 60 NetDevPort port;
6e866b33 61 int features[_NET_DEV_FEAT_MAX];
b012e921 62 netdev_channels channels;
e1f67bc7 63 netdev_ring_param ring;
a10f5d05
MB
64 int rx_flow_control;
65 int tx_flow_control;
66 int autoneg_flow_control;
60f067b4 67
8b3d4ff0 68 LIST_FIELDS(LinkConfig, links);
60f067b4
JS
69};
70
8b3d4ff0
MB
71int link_config_ctx_new(LinkConfigContext **ret);
72LinkConfigContext* link_config_ctx_free(LinkConfigContext *ctx);
73DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfigContext*, link_config_ctx_free);
60f067b4 74
8b3d4ff0
MB
75int link_load_one(LinkConfigContext *ctx, const char *filename);
76int link_config_load(LinkConfigContext *ctx);
77bool link_config_should_reload(LinkConfigContext *ctx);
60f067b4 78
8b3d4ff0
MB
79int link_config_get(LinkConfigContext *ctx, sd_device *device, LinkConfig **ret);
80int link_config_apply(LinkConfigContext *ctx, const LinkConfig *config, sd_device *device, const char **ret_name);
81int link_get_driver(LinkConfigContext *ctx, sd_device *device, char **ret);
60f067b4
JS
82
83const char *name_policy_to_string(NamePolicy p) _const_;
84NamePolicy name_policy_from_string(const char *p) _pure_;
85
46cdbd49
BR
86const char *alternative_names_policy_to_string(NamePolicy p) _const_;
87NamePolicy alternative_names_policy_from_string(const char *p) _pure_;
88
bb4f798a
MB
89const char *mac_address_policy_to_string(MACAddressPolicy p) _const_;
90MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
60f067b4
JS
91
92/* gperf lookup function */
2897b343 93const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
60f067b4 94
3a6ce677
BR
95CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
96CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues);
97CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen);
bb4f798a 98CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
6e866b33 99CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
46cdbd49 100CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy);