Skip to content

Commit cf66f9d

Browse files
konradwilkdavem330
authored andcommitted
xen/netfront: add netconsole support.
add polling interface to xen-netfront device to support netconsole This patch also alters the spin_lock usage to use irqsave variant. Documentation/networking/netdevices.txt states that start_xmit can be called with interrupts disabled by netconsole and therefore using the irqsave/restore locking in this function is looks correct. Signed-off-by: Tina.Yang <tina.yang@oracle.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Signed-off-by: Zhenzhong.Duan <zhenzhong.duan@oracle.com> Tested-by: gurudas.pai <gurudas.pai@oracle.com> [v1: Copy-n-pasted Ian Campbell comments] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c54a457 commit cf66f9d

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

drivers/net/xen-netfront.c

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
489489
int frags = skb_shinfo(skb)->nr_frags;
490490
unsigned int offset = offset_in_page(data);
491491
unsigned int len = skb_headlen(skb);
492+
unsigned long flags;
492493

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

501-
spin_lock_irq(&np->tx_lock);
502+
spin_lock_irqsave(&np->tx_lock, flags);
502503

503504
if (unlikely(!netif_carrier_ok(dev) ||
504505
(frags > 1 && !xennet_can_sg(dev)) ||
505506
netif_needs_gso(skb, netif_skb_features(skb)))) {
506-
spin_unlock_irq(&np->tx_lock);
507+
spin_unlock_irqrestore(&np->tx_lock, flags);
507508
goto drop;
508509
}
509510

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

577-
spin_unlock_irq(&np->tx_lock);
578+
spin_unlock_irqrestore(&np->tx_lock, flags);
578579

579580
return NETDEV_TX_OK;
580581

@@ -1228,6 +1229,33 @@ static int xennet_set_features(struct net_device *dev,
12281229
return 0;
12291230
}
12301231

1232+
static irqreturn_t xennet_interrupt(int irq, void *dev_id)
1233+
{
1234+
struct net_device *dev = dev_id;
1235+
struct netfront_info *np = netdev_priv(dev);
1236+
unsigned long flags;
1237+
1238+
spin_lock_irqsave(&np->tx_lock, flags);
1239+
1240+
if (likely(netif_carrier_ok(dev))) {
1241+
xennet_tx_buf_gc(dev);
1242+
/* Under tx_lock: protects access to rx shared-ring indexes. */
1243+
if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
1244+
napi_schedule(&np->napi);
1245+
}
1246+
1247+
spin_unlock_irqrestore(&np->tx_lock, flags);
1248+
1249+
return IRQ_HANDLED;
1250+
}
1251+
1252+
#ifdef CONFIG_NET_POLL_CONTROLLER
1253+
static void xennet_poll_controller(struct net_device *dev)
1254+
{
1255+
xennet_interrupt(0, dev);
1256+
}
1257+
#endif
1258+
12311259
static const struct net_device_ops xennet_netdev_ops = {
12321260
.ndo_open = xennet_open,
12331261
.ndo_uninit = xennet_uninit,
@@ -1239,6 +1267,9 @@ static const struct net_device_ops xennet_netdev_ops = {
12391267
.ndo_validate_addr = eth_validate_addr,
12401268
.ndo_fix_features = xennet_fix_features,
12411269
.ndo_set_features = xennet_set_features,
1270+
#ifdef CONFIG_NET_POLL_CONTROLLER
1271+
.ndo_poll_controller = xennet_poll_controller,
1272+
#endif
12421273
};
12431274

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

1451-
static irqreturn_t xennet_interrupt(int irq, void *dev_id)
1452-
{
1453-
struct net_device *dev = dev_id;
1454-
struct netfront_info *np = netdev_priv(dev);
1455-
unsigned long flags;
1456-
1457-
spin_lock_irqsave(&np->tx_lock, flags);
1458-
1459-
if (likely(netif_carrier_ok(dev))) {
1460-
xennet_tx_buf_gc(dev);
1461-
/* Under tx_lock: protects access to rx shared-ring indexes. */
1462-
if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
1463-
napi_schedule(&np->napi);
1464-
}
1465-
1466-
spin_unlock_irqrestore(&np->tx_lock, flags);
1467-
1468-
return IRQ_HANDLED;
1469-
}
1470-
14711482
static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info)
14721483
{
14731484
struct xen_netif_tx_sring *txs;

0 commit comments

Comments
 (0)