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 struct dp_packet
*aux_bufs
[NETDEV_MAX_BURST
]; /* Preallocated TSO
52 int netdev_linux_construct(struct netdev
*);
53 void netdev_linux_run(const struct netdev_class
*);
55 int get_stats_via_netlink(const struct netdev
*netdev_
,
56 struct netdev_stats
*stats
);
61 /* Protects all members below. */
62 struct ovs_mutex mutex
;
64 unsigned int cache_valid
;
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
;
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. */
74 struct eth_addr etheraddr
;
76 unsigned int ifi_flags
;
77 long long int carrier_resets
;
78 uint32_t kbits_rate
; /* Policing data. */
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
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. */
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. */
94 struct ethtool_drvinfo drvinfo
; /* Cached from ETHTOOL_GDRVINFO. */
97 /* For devices of class netdev_tap_class only. */
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 */
101 uint64_t rx_dropped
; /* Packets dropped while recv from kernel. */
103 /* LAG information. */
104 bool is_lag_master
; /* True if the netdev is a LAG master. */
106 int numa_id
; /* NUMA node id. */
109 /* AF_XDP information. */
110 struct xsk_socket_info
**xsks
;
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. */
117 bool use_need_wakeup
;
118 bool requested_need_wakeup
;
120 struct netdev_afxdp_tx_lock
*tx_locks
; /* Array of locks for TX queues. */
125 is_netdev_linux_class(const struct netdev_class
*netdev_class
)
127 return netdev_class
->run
== netdev_linux_run
;
130 static struct netdev_linux
*
131 netdev_linux_cast(const struct netdev
*netdev
)
133 ovs_assert(is_netdev_linux_class(netdev_get_class(netdev
)));
135 return CONTAINER_OF(netdev
, struct netdev_linux
, up
);
138 static struct netdev_rxq_linux
*
139 netdev_rxq_linux_cast(const struct netdev_rxq
*rx
)
141 ovs_assert(is_netdev_linux_class(netdev_get_class(rx
->netdev
)));
143 return CONTAINER_OF(rx
, struct netdev_rxq_linux
, up
);
146 #endif /* netdev-linux-private.h */