Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 289730
b: refs/heads/master
c: cf66f9d
h: refs/heads/master
v: v3
  • Loading branch information
Konrad Rzeszutek Wilk authored and David S. Miller committed Jan 25, 2012
1 parent 0409c0b commit 83f1277
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c54a45700195d9491e2cc2115ea61315a8ba3927
refs/heads/master: cf66f9d48a9c95baf8f13b199a633ce1c4cf952a
57 changes: 34 additions & 23 deletions trunk/drivers/net/xen-netfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
int frags = skb_shinfo(skb)->nr_frags;
unsigned int offset = offset_in_page(data);
unsigned int len = skb_headlen(skb);
unsigned long flags;

frags += DIV_ROUND_UP(offset + len, PAGE_SIZE);
if (unlikely(frags > MAX_SKB_FRAGS + 1)) {
Expand All @@ -498,12 +499,12 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
goto drop;
}

spin_lock_irq(&np->tx_lock);
spin_lock_irqsave(&np->tx_lock, flags);

if (unlikely(!netif_carrier_ok(dev) ||
(frags > 1 && !xennet_can_sg(dev)) ||
netif_needs_gso(skb, netif_skb_features(skb)))) {
spin_unlock_irq(&np->tx_lock);
spin_unlock_irqrestore(&np->tx_lock, flags);
goto drop;
}

Expand Down Expand Up @@ -574,7 +575,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (!netfront_tx_slot_available(np))
netif_stop_queue(dev);

spin_unlock_irq(&np->tx_lock);
spin_unlock_irqrestore(&np->tx_lock, flags);

return NETDEV_TX_OK;

Expand Down Expand Up @@ -1228,6 +1229,33 @@ static int xennet_set_features(struct net_device *dev,
return 0;
}

static irqreturn_t xennet_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
struct netfront_info *np = netdev_priv(dev);
unsigned long flags;

spin_lock_irqsave(&np->tx_lock, flags);

if (likely(netif_carrier_ok(dev))) {
xennet_tx_buf_gc(dev);
/* Under tx_lock: protects access to rx shared-ring indexes. */
if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
napi_schedule(&np->napi);
}

spin_unlock_irqrestore(&np->tx_lock, flags);

return IRQ_HANDLED;
}

#ifdef CONFIG_NET_POLL_CONTROLLER
static void xennet_poll_controller(struct net_device *dev)
{
xennet_interrupt(0, dev);
}
#endif

static const struct net_device_ops xennet_netdev_ops = {
.ndo_open = xennet_open,
.ndo_uninit = xennet_uninit,
Expand All @@ -1239,6 +1267,9 @@ static const struct net_device_ops xennet_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
.ndo_fix_features = xennet_fix_features,
.ndo_set_features = xennet_set_features,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = xennet_poll_controller,
#endif
};

static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev)
Expand Down Expand Up @@ -1448,26 +1479,6 @@ static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
return 0;
}

static irqreturn_t xennet_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
struct netfront_info *np = netdev_priv(dev);
unsigned long flags;

spin_lock_irqsave(&np->tx_lock, flags);

if (likely(netif_carrier_ok(dev))) {
xennet_tx_buf_gc(dev);
/* Under tx_lock: protects access to rx shared-ring indexes. */
if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
napi_schedule(&np->napi);
}

spin_unlock_irqrestore(&np->tx_lock, flags);

return IRQ_HANDLED;
}

static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info)
{
struct xen_netif_tx_sring *txs;
Expand Down

0 comments on commit 83f1277

Please sign in to comment.