]>
Commit | Line | Data |
---|---|---|
0de1b425 WT |
1 | /* |
2 | * Copyright (c) 2019 Nicira, Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at: | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #ifndef NETDEV_LINUX_PRIVATE_H | |
18 | #define NETDEV_LINUX_PRIVATE_H 1 | |
19 | ||
20 | #include <linux/filter.h> | |
21 | #include <linux/gen_stats.h> | |
22 | #include <linux/if_ether.h> | |
23 | #include <linux/if_tun.h> | |
24 | #include <linux/types.h> | |
25 | #include <linux/ethtool.h> | |
26 | #include <linux/mii.h> | |
27 | #include <stdint.h> | |
28 | #include <stdbool.h> | |
29 | ||
30 | #include "netdev-afxdp.h" | |
31 | #include "netdev-afxdp-pool.h" | |
32 | #include "netdev-provider.h" | |
33 | #include "netdev-vport.h" | |
34 | #include "openvswitch/thread.h" | |
35 | #include "ovs-atomic.h" | |
36 | #include "timer.h" | |
37 | ||
38 | struct netdev; | |
39 | ||
40 | struct netdev_rxq_linux { | |
41 | struct netdev_rxq up; | |
42 | bool is_tap; | |
43 | int fd; | |
44 | }; | |
45 | ||
f627cf1d | 46 | int netdev_linux_construct(struct netdev *); |
0de1b425 WT |
47 | void netdev_linux_run(const struct netdev_class *); |
48 | ||
49 | int get_stats_via_netlink(const struct netdev *netdev_, | |
50 | struct netdev_stats *stats); | |
51 | ||
52 | struct netdev_linux { | |
53 | struct netdev up; | |
54 | ||
55 | /* Protects all members below. */ | |
56 | struct ovs_mutex mutex; | |
57 | ||
58 | unsigned int cache_valid; | |
59 | ||
60 | bool miimon; /* Link status of last poll. */ | |
61 | long long int miimon_interval; /* Miimon Poll rate. Disabled if <= 0. */ | |
62 | struct timer miimon_timer; | |
63 | ||
64 | int netnsid; /* Network namespace ID. */ | |
65 | /* The following are figured out "on demand" only. They are only valid | |
66 | * when the corresponding VALID_* bit in 'cache_valid' is set. */ | |
67 | int ifindex; | |
68 | struct eth_addr etheraddr; | |
69 | int mtu; | |
70 | unsigned int ifi_flags; | |
71 | long long int carrier_resets; | |
72 | uint32_t kbits_rate; /* Policing data. */ | |
73 | uint32_t kbits_burst; | |
74 | int vport_stats_error; /* Cached error code from vport_get_stats(). | |
75 | 0 or an errno value. */ | |
76 | int netdev_mtu_error; /* Cached error code from SIOCGIFMTU | |
77 | * or SIOCSIFMTU. | |
78 | */ | |
79 | int ether_addr_error; /* Cached error code from set/get etheraddr. */ | |
80 | int netdev_policing_error; /* Cached error code from set policing. */ | |
81 | int get_features_error; /* Cached error code from ETHTOOL_GSET. */ | |
82 | int get_ifindex_error; /* Cached error code from SIOCGIFINDEX. */ | |
83 | ||
84 | enum netdev_features current; /* Cached from ETHTOOL_GSET. */ | |
85 | enum netdev_features advertised; /* Cached from ETHTOOL_GSET. */ | |
86 | enum netdev_features supported; /* Cached from ETHTOOL_GSET. */ | |
87 | ||
88 | struct ethtool_drvinfo drvinfo; /* Cached from ETHTOOL_GDRVINFO. */ | |
89 | struct tc *tc; | |
90 | ||
91 | /* For devices of class netdev_tap_class only. */ | |
92 | int tap_fd; | |
93 | bool present; /* If the device is present in the namespace */ | |
94 | uint64_t tx_dropped; /* tap device can drop if the iface is down */ | |
95 | ||
96 | /* LAG information. */ | |
97 | bool is_lag_master; /* True if the netdev is a LAG master. */ | |
98 | ||
99 | #ifdef HAVE_AF_XDP | |
100 | /* AF_XDP information. */ | |
101 | struct xsk_socket_info **xsks; | |
102 | int requested_n_rxq; | |
e8f56344 IM |
103 | |
104 | enum afxdp_mode xdp_mode; /* Configured AF_XDP mode. */ | |
105 | enum afxdp_mode requested_xdp_mode; /* Requested AF_XDP mode. */ | |
106 | enum afxdp_mode xdp_mode_in_use; /* Effective AF_XDP mode. */ | |
107 | ||
e50547b5 WT |
108 | bool use_need_wakeup; |
109 | bool requested_need_wakeup; | |
e8f56344 | 110 | |
0de1b425 WT |
111 | struct ovs_spin *tx_locks; /* spin lock array for TX queues. */ |
112 | #endif | |
113 | }; | |
114 | ||
115 | static bool | |
116 | is_netdev_linux_class(const struct netdev_class *netdev_class) | |
117 | { | |
118 | return netdev_class->run == netdev_linux_run; | |
119 | } | |
120 | ||
121 | static struct netdev_linux * | |
122 | netdev_linux_cast(const struct netdev *netdev) | |
123 | { | |
124 | ovs_assert(is_netdev_linux_class(netdev_get_class(netdev))); | |
125 | ||
126 | return CONTAINER_OF(netdev, struct netdev_linux, up); | |
127 | } | |
128 | ||
129 | static struct netdev_rxq_linux * | |
130 | netdev_rxq_linux_cast(const struct netdev_rxq *rx) | |
131 | { | |
132 | ovs_assert(is_netdev_linux_class(netdev_get_class(rx->netdev))); | |
133 | ||
134 | return CONTAINER_OF(rx, struct netdev_rxq_linux, up); | |
135 | } | |
136 | ||
137 | #endif /* netdev-linux-private.h */ |