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