33 #include <linux/ethtool.h>
34 #include <linux/rtnetlink.h>
35 #include <linux/if_vlan.h>
37 #include <xen/events.h>
38 #include <asm/xen/hypercall.h>
40 #define XENVIF_QUEUE_LENGTH 32
55 return netif_running(vif->
dev) && netif_carrier_ok(vif->
dev);
58 static int xenvif_rx_schedulable(
struct xenvif *vif)
72 if (xenvif_rx_schedulable(vif))
73 netif_wake_queue(vif->
dev);
80 struct xenvif *vif = netdev_priv(dev);
88 if (!xenvif_rx_schedulable(vif))
96 netif_stop_queue(dev);
103 vif->
dev->stats.tx_dropped++;
115 if (netif_queue_stopped(vif->
dev) && xenvif_rx_schedulable(vif))
116 netif_wake_queue(vif->
dev);
121 struct xenvif *vif = netdev_priv(dev);
122 return &vif->
dev->stats;
125 static void xenvif_up(
struct xenvif *vif)
132 static void xenvif_down(
struct xenvif *vif)
139 static int xenvif_open(
struct net_device *dev)
141 struct xenvif *vif = netdev_priv(dev);
142 if (netif_carrier_ok(dev))
144 netif_start_queue(dev);
148 static int xenvif_close(
struct net_device *dev)
150 struct xenvif *vif = netdev_priv(dev);
151 if (netif_carrier_ok(dev))
153 netif_stop_queue(dev);
157 static int xenvif_change_mtu(
struct net_device *dev,
int mtu)
159 struct xenvif *vif = netdev_priv(dev);
171 struct xenvif *vif = netdev_priv(dev);
183 static const struct xenvif_stat {
188 "rx_gso_checksum_fixup",
193 static int xenvif_get_sset_count(
struct net_device *dev,
int string_set)
195 switch (string_set) {
203 static void xenvif_get_ethtool_stats(
struct net_device *dev,
206 void *vif = netdev_priv(dev);
209 for (i = 0; i <
ARRAY_SIZE(xenvif_stats); i++)
210 data[i] = *(
unsigned long *)(vif + xenvif_stats[
i].offset);
213 static void xenvif_get_strings(
struct net_device *dev,
u32 stringset,
u8 * data)
219 for (i = 0; i <
ARRAY_SIZE(xenvif_stats); i++)
221 xenvif_stats[i].
name, ETH_GSTRING_LEN);
226 static const struct ethtool_ops xenvif_ethtool_ops = {
229 .get_sset_count = xenvif_get_sset_count,
230 .get_ethtool_stats = xenvif_get_ethtool_stats,
231 .get_strings = xenvif_get_strings,
235 .ndo_start_xmit = xenvif_start_xmit,
236 .ndo_get_stats = xenvif_get_stats,
237 .ndo_open = xenvif_open,
238 .ndo_stop = xenvif_close,
239 .ndo_change_mtu = xenvif_change_mtu,
240 .ndo_fix_features = xenvif_fix_features,
254 pr_warn(
"Could not allocate netdev\n");
260 vif = netdev_priv(dev);
298 netdev_warn(dev,
"Could not register device: err=%d\n", err);
303 netdev_dbg(dev,
"Successfully created xenvif\n");
308 unsigned long rx_ring_ref,
unsigned int evtchn)
321 vif->
domid, evtchn, xenvif_interrupt, 0,
322 vif->
dev->name, vif);
335 if (netif_running(vif->
dev))
349 if (netif_carrier_ok(dev)) {
352 if (netif_running(dev))