/src/openvswitch/lib/netdev-linux-private.h
Line | Count | Source (jump to first uncovered line) |
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 "dp-packet.h" |
31 | | #include "netdev-afxdp.h" |
32 | | #include "netdev-afxdp-pool.h" |
33 | | #include "netdev-provider.h" |
34 | | #include "netdev-vport.h" |
35 | | #include "openvswitch/thread.h" |
36 | | #include "ovs-atomic.h" |
37 | | #include "timer.h" |
38 | | |
39 | | struct netdev; |
40 | | |
41 | | /* The maximum packet length is 16 bits */ |
42 | 0 | #define LINUX_RXQ_TSO_MAX_LEN 65535 |
43 | | |
44 | | struct netdev_rxq_linux { |
45 | | struct netdev_rxq up; |
46 | | bool is_tap; |
47 | | int fd; |
48 | | struct dp_packet *aux_bufs[NETDEV_MAX_BURST]; /* Preallocated TSO |
49 | | packets. */ |
50 | | }; |
51 | | |
52 | | int netdev_linux_construct(struct netdev *); |
53 | | int netdev_linux_get_status(const struct netdev *, struct smap *); |
54 | | void netdev_linux_run(const struct netdev_class *); |
55 | | |
56 | | int get_stats_via_netlink(const struct netdev *netdev_, |
57 | | struct netdev_stats *stats); |
58 | | |
59 | | struct netdev_linux { |
60 | | struct netdev up; |
61 | | |
62 | | /* Protects all members below. */ |
63 | | struct ovs_mutex mutex; |
64 | | |
65 | | unsigned int cache_valid; |
66 | | |
67 | | bool miimon; /* Link status of last poll. */ |
68 | | long long int miimon_interval; /* Miimon Poll rate. Disabled if <= 0. */ |
69 | | struct timer miimon_timer; |
70 | | |
71 | | int netnsid; /* Network namespace ID. */ |
72 | | /* The following are figured out "on demand" only. They are only valid |
73 | | * when the corresponding VALID_* bit in 'cache_valid' is set. */ |
74 | | int ifindex; |
75 | | struct eth_addr etheraddr; |
76 | | int mtu; |
77 | | unsigned int ifi_flags; |
78 | | long long int carrier_resets; |
79 | | uint32_t kbits_rate; /* Policing data - kbps */ |
80 | | uint32_t kbits_burst; |
81 | | uint32_t kpkts_rate; /* Policing data - kpps */ |
82 | | uint32_t kpkts_burst; |
83 | | int vport_stats_error; /* Cached error code from vport_get_stats(). |
84 | | 0 or an errno value. */ |
85 | | int netdev_mtu_error; /* Cached error code from SIOCGIFMTU |
86 | | * or SIOCSIFMTU. |
87 | | */ |
88 | | int ether_addr_error; /* Cached error code from set/get etheraddr. */ |
89 | | int netdev_policing_error; /* Cached error code from set policing. */ |
90 | | int get_features_error; /* Cached error code from ETHTOOL_GSET. */ |
91 | | int get_ifindex_error; /* Cached error code from SIOCGIFINDEX. */ |
92 | | |
93 | | enum netdev_features current; /* Cached from ETHTOOL_GSET. */ |
94 | | enum netdev_features advertised; /* Cached from ETHTOOL_GSET. */ |
95 | | enum netdev_features supported; /* Cached from ETHTOOL_GSET. */ |
96 | | uint32_t current_speed; /* Cached from ETHTOOL_GSET. */ |
97 | | |
98 | | struct ethtool_drvinfo drvinfo; /* Cached from ETHTOOL_GDRVINFO. */ |
99 | | struct tc *tc; |
100 | | |
101 | | /* For devices of class netdev_tap_class only. */ |
102 | | int tap_fd; |
103 | | bool present; /* If the device is present in the namespace */ |
104 | | uint64_t tx_dropped; /* tap device can drop if the iface is down */ |
105 | | uint64_t rx_dropped; /* Packets dropped while recv from kernel. */ |
106 | | |
107 | | /* LAG information. */ |
108 | | bool is_lag_primary; /* True if the netdev is a LAG primary. */ |
109 | | |
110 | | int numa_id; /* NUMA node id. */ |
111 | | |
112 | | #ifdef HAVE_AF_XDP |
113 | | /* AF_XDP information. */ |
114 | | struct xsk_socket_info **xsks; |
115 | | int requested_n_rxq; |
116 | | |
117 | | enum afxdp_mode xdp_mode; /* Configured AF_XDP mode. */ |
118 | | enum afxdp_mode requested_xdp_mode; /* Requested AF_XDP mode. */ |
119 | | enum afxdp_mode xdp_mode_in_use; /* Effective AF_XDP mode. */ |
120 | | |
121 | | bool use_need_wakeup; |
122 | | bool requested_need_wakeup; |
123 | | |
124 | | struct netdev_afxdp_tx_lock *tx_locks; /* Array of locks for TX queues. */ |
125 | | #endif |
126 | | }; |
127 | | |
128 | | static bool |
129 | | is_netdev_linux_class(const struct netdev_class *netdev_class) |
130 | 0 | { |
131 | 0 | return netdev_class->run == netdev_linux_run; |
132 | 0 | } |
133 | | |
134 | | static struct netdev_linux * |
135 | | netdev_linux_cast(const struct netdev *netdev) |
136 | 0 | { |
137 | 0 | ovs_assert(is_netdev_linux_class(netdev_get_class(netdev))); |
138 | |
|
139 | 0 | return CONTAINER_OF(netdev, struct netdev_linux, up); |
140 | 0 | } |
141 | | |
142 | | static struct netdev_rxq_linux * |
143 | | netdev_rxq_linux_cast(const struct netdev_rxq *rx) |
144 | 0 | { |
145 | 0 | ovs_assert(is_netdev_linux_class(netdev_get_class(rx->netdev))); |
146 | |
|
147 | 0 | return CONTAINER_OF(rx, struct netdev_rxq_linux, up); |
148 | 0 | } |
149 | | |
150 | | #endif /* netdev-linux-private.h */ |