]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/net/link-config.h
udevd: Add ReceivePacketSteeringCPUMask for systemd.link
[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 #include "sd-netlink.h"
6
7 #include "condition.h"
8 #include "conf-parser.h"
9 #include "cpu-set-util.h"
10 #include "ethtool-util.h"
11 #include "hashmap.h"
12 #include "list.h"
13 #include "net-condition.h"
14 #include "netif-naming-scheme.h"
15
16 typedef struct LinkConfigContext LinkConfigContext;
17 typedef struct LinkConfig LinkConfig;
18
19 typedef enum MACAddressPolicy {
20 MAC_ADDRESS_POLICY_PERSISTENT,
21 MAC_ADDRESS_POLICY_RANDOM,
22 MAC_ADDRESS_POLICY_NONE,
23 _MAC_ADDRESS_POLICY_MAX,
24 _MAC_ADDRESS_POLICY_INVALID = -EINVAL,
25 } MACAddressPolicy;
26
27 typedef struct Link {
28 int ifindex;
29 const char *ifname;
30 const char *new_name;
31 char **altnames;
32
33 LinkConfig *config;
34 sd_device *device;
35 sd_device *device_db_clone;
36 sd_device_action_t action;
37
38 char *kind;
39 const char *driver;
40 uint16_t iftype;
41 uint32_t flags;
42 struct hw_addr_data hw_addr;
43 struct hw_addr_data permanent_hw_addr;
44 unsigned name_assign_type;
45 unsigned addr_assign_type;
46 } Link;
47
48 struct LinkConfig {
49 char *filename;
50 char **dropins;
51
52 NetMatch match;
53 LIST_HEAD(Condition, conditions);
54
55 char *description;
56 char **properties;
57 char **import_properties;
58 char **unset_properties;
59 struct hw_addr_data hw_addr;
60 MACAddressPolicy mac_address_policy;
61 NamePolicy *name_policy;
62 NamePolicy *alternative_names_policy;
63 char *name;
64 char **alternative_names;
65 char *alias;
66 uint32_t txqueues;
67 uint32_t rxqueues;
68 uint32_t txqueuelen;
69 uint32_t mtu;
70 uint32_t gso_max_segments;
71 size_t gso_max_size;
72 uint64_t speed;
73 Duplex duplex;
74 int autonegotiation;
75 uint32_t advertise[N_ADVERTISE];
76 uint32_t wol;
77 char *wol_password_file;
78 uint8_t *wol_password;
79 NetDevPort port;
80 int features[_NET_DEV_FEAT_MAX];
81 netdev_channels channels;
82 netdev_ring_param ring;
83 int rx_flow_control;
84 int tx_flow_control;
85 int autoneg_flow_control;
86 netdev_coalesce_param coalesce;
87 uint8_t mdi;
88 CPUSet *rps_cpu_mask;
89
90 uint32_t sr_iov_num_vfs;
91 OrderedHashmap *sr_iov_by_section;
92
93 LIST_FIELDS(LinkConfig, configs);
94 };
95
96 int link_config_ctx_new(LinkConfigContext **ret);
97 LinkConfigContext* link_config_ctx_free(LinkConfigContext *ctx);
98 DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfigContext*, link_config_ctx_free);
99
100 int link_load_one(LinkConfigContext *ctx, const char *filename);
101 int link_config_load(LinkConfigContext *ctx);
102 bool link_config_should_reload(LinkConfigContext *ctx);
103
104 int link_new(LinkConfigContext *ctx, sd_netlink **rtnl, sd_device *device, sd_device *device_db_clone, Link **ret);
105 Link *link_free(Link *link);
106 DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
107
108 int link_get_config(LinkConfigContext *ctx, Link *link);
109 int link_apply_config(LinkConfigContext *ctx, sd_netlink **rtnl, Link *link, bool test);
110
111 const char *mac_address_policy_to_string(MACAddressPolicy p) _const_;
112 MACAddressPolicy mac_address_policy_from_string(const char *p) _pure_;
113
114 /* gperf lookup function */
115 const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
116
117 CONFIG_PARSER_PROTOTYPE(config_parse_udev_property);
118 CONFIG_PARSER_PROTOTYPE(config_parse_udev_property_name);
119 CONFIG_PARSER_PROTOTYPE(config_parse_ifalias);
120 CONFIG_PARSER_PROTOTYPE(config_parse_rx_tx_queues);
121 CONFIG_PARSER_PROTOTYPE(config_parse_txqueuelen);
122 CONFIG_PARSER_PROTOTYPE(config_parse_wol_password);
123 CONFIG_PARSER_PROTOTYPE(config_parse_mac_address_policy);
124 CONFIG_PARSER_PROTOTYPE(config_parse_name_policy);
125 CONFIG_PARSER_PROTOTYPE(config_parse_alternative_names_policy);
126 CONFIG_PARSER_PROTOTYPE(config_parse_rps_cpu_mask);