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