1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
7 #include "conf-parser.h"
8 #include "ethtool-util.h"
10 #include "net-condition.h"
12 typedef struct LinkConfigContext LinkConfigContext
;
13 typedef struct LinkConfig LinkConfig
;
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
,
23 typedef enum NamePolicy
{
32 _NAMEPOLICY_INVALID
= -EINVAL
,
39 LIST_HEAD(Condition
, conditions
);
42 struct ether_addr
*mac
;
43 MACAddressPolicy mac_address_policy
;
44 NamePolicy
*name_policy
;
45 NamePolicy
*alternative_names_policy
;
47 char **alternative_names
;
53 uint32_t gso_max_segments
;
58 uint32_t advertise
[N_ADVERTISE
];
61 int features
[_NET_DEV_FEAT_MAX
];
62 netdev_channels channels
;
63 netdev_ring_param ring
;
66 int autoneg_flow_control
;
67 netdev_coalesce_param coalesce
;
69 LIST_FIELDS(LinkConfig
, links
);
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
);
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
);
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
);
84 const char *name_policy_to_string(NamePolicy p
) _const_
;
85 NamePolicy
name_policy_from_string(const char *p
) _pure_
;
87 const char *alternative_names_policy_to_string(NamePolicy p
) _const_
;
88 NamePolicy
alternative_names_policy_from_string(const char *p
) _pure_
;
90 const char *mac_address_policy_to_string(MACAddressPolicy p
) _const_
;
91 MACAddressPolicy
mac_address_policy_from_string(const char *p
) _pure_
;
93 /* gperf lookup function */
94 const struct ConfigPerfItem
* link_config_gperf_lookup(const char *key
, GPERF_LEN_TYPE length
);
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
);