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