2 * Copyright (c) 2019 Nicira, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef NETDEV_LINUX_PRIVATE_H
18 #define NETDEV_LINUX_PRIVATE_H 1
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>
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"
41 /* The maximum packet length is 16 bits */
42 #define LINUX_RXQ_TSO_MAX_LEN 65535
44 struct netdev_rxq_linux
{
48 char *aux_bufs
[NETDEV_MAX_BURST
]; /* Batch of preallocated TSO buffers. */
51 int netdev_linux_construct(struct netdev
*);
52 void netdev_linux_run(const struct netdev_class
*);
54 int get_stats_via_netlink(const struct netdev
*netdev_
,
55 struct netdev_stats
*stats
);
60 /* Protects all members below. */
61 struct ovs_mutex mutex
;
63 unsigned int cache_valid
;
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
;
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. */
73 struct eth_addr etheraddr
;
75 unsigned int ifi_flags
;
76 long long int carrier_resets
;
77 uint32_t kbits_rate
; /* Policing data. */
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
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. */
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. */
93 struct ethtool_drvinfo drvinfo
; /* Cached from ETHTOOL_GDRVINFO. */
96 /* For devices of class netdev_tap_class only. */
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. */
102 /* LAG information. */
103 bool is_lag_master
; /* True if the netdev is a LAG master. */
105 int numa_id
; /* NUMA node id. */
108 /* AF_XDP information. */
109 struct xsk_socket_info
**xsks
;
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. */
116 bool use_need_wakeup
;
117 bool requested_need_wakeup
;
119 struct netdev_afxdp_tx_lock
*tx_locks
; /* Array of locks for TX queues. */
124 is_netdev_linux_class(const struct netdev_class
*netdev_class
)
126 return netdev_class
->run
== netdev_linux_run
;
129 static struct netdev_linux
*
130 netdev_linux_cast(const struct netdev
*netdev
)
132 ovs_assert(is_netdev_linux_class(netdev_get_class(netdev
)));
134 return CONTAINER_OF(netdev
, struct netdev_linux
, up
);
137 static struct netdev_rxq_linux
*
138 netdev_rxq_linux_cast(const struct netdev_rxq
*rx
)
140 ovs_assert(is_netdev_linux_class(netdev_get_class(rx
->netdev
)));
142 return CONTAINER_OF(rx
, struct netdev_rxq_linux
, up
);
145 #endif /* netdev-linux-private.h */