Debian Codegraph @

src/shared/netif-sriov.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include <linux/if_link.h>
5 #include <net/ethernet.h>
6
7 #include "conf-parser-forward.h"
8 #include "shared-forward.h"
9
10 typedef enum SRIOVAttribute {
11 SR_IOV_VF_MAC,
12 SR_IOV_VF_SPOOFCHK,
13 SR_IOV_VF_RSS_QUERY_EN,
14 SR_IOV_VF_TRUST,
15 SR_IOV_VF_LINK_STATE,
16 SR_IOV_VF_VLAN_LIST,
17 _SR_IOV_ATTRIBUTE_MAX,
18 _SR_IOV_ATTRIBUTE_INVALID = -EINVAL,
19 } SRIOVAttribute;
20
21 typedef enum SRIOVLinkState {
22 SR_IOV_LINK_STATE_AUTO = IFLA_VF_LINK_STATE_AUTO,
23 SR_IOV_LINK_STATE_ENABLE = IFLA_VF_LINK_STATE_ENABLE,
24 SR_IOV_LINK_STATE_DISABLE = IFLA_VF_LINK_STATE_DISABLE,
25 _SR_IOV_LINK_STATE_MAX,
26 _SR_IOV_LINK_STATE_INVALID = -EINVAL,
27 } SRIOVLinkState;
28
29 typedef struct SRIOV {
30 ConfigSection *section;
31 OrderedHashmap *sr_iov_by_section;
32
33 uint32_t vf; /* 0 - 2147483646 */
34 uint32_t vlan; /* 0 - 4095, 0 disables VLAN filter */
35 uint32_t qos;
36 uint16_t vlan_proto; /* ETH_P_8021Q or ETH_P_8021AD */
37 int vf_spoof_check_setting;
38 int query_rss;
39 int trust;
40 SRIOVLinkState link_state;
41 struct ether_addr mac;
42 } SRIOV;
43
44 DECLARE_STRING_TABLE_LOOKUP_TO_STRING(sr_iov_attribute, SRIOVAttribute);
45
46 void sr_iov_hash_func(const SRIOV *sr_iov, struct siphash *state);
47 int sr_iov_compare_func(const SRIOV *s1, const SRIOV *s2);
48 bool sr_iov_has_config(SRIOV *sr_iov, SRIOVAttribute attr);
49 int sr_iov_set_netlink_message(SRIOV *sr_iov, SRIOVAttribute attr, sd_netlink_message *req);
50 int sr_iov_get_num_vfs(sd_device *device, uint32_t *ret);
51 int sr_iov_set_num_vfs(sd_device *device, uint32_t num_vfs, OrderedHashmap *sr_iov_by_section);
52 int sr_iov_drop_invalid_sections(uint32_t num_vfs, OrderedHashmap *sr_iov_by_section);
53
54 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_uint32);
55 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_boolean);
56 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_link_state);
57 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_vlan_proto);
58 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_mac);
59 CONFIG_PARSER_PROTOTYPE(config_parse_sr_iov_num_vfs);