From: Jeff Moyer <jmoyer@redhat.com>
To: mpm@selenic.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [rfc | patch 5/6] netpoll: modify bonding driver to support netpoll
Date: Fri, 1 Jul 2005 19:09:42 -0400 [thread overview]
Message-ID: <17093.52534.420781.92366@segfault.boston.redhat.com> (raw)
In-Reply-To: <17093.52306.136742.190912@segfault.boston.redhat.com>
Implement netpoll hooks in the bonding driver. We register the following
netpoll specific routines:
bond_netpoll_setup
This routine associates the struct netpoll_info of the master device with
each of the slave devices.
bond_xmit_netpoll
This routine sets bonding->netpoll to the struct netpoll provided by
netpoll_send_skb. This pointer is then passed along to netpoll_send_skb
in bond_dev_queue_xmit, when we are ready to send the skb out over the
real network device.
bond_poll_controller
This routine calls netpoll_poll_dev for each of the slaves in the bond.
When a new slave is added to the bond, if it does not support netpoll, then
netpoll is disabled for the bond. When a slave is released, that slave's
npinfo pointer is cleared.
I have tested this code extensively, and it works well in my environment.
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
--- linux-2.6.12/drivers/net/bonding/bond_main.c.orig 2005-06-29 14:28:08.000000000 -0400
+++ linux-2.6.12/drivers/net/bonding/bond_main.c 2005-06-30 19:33:50.641009622 -0400
@@ -821,8 +821,12 @@ int bond_dev_queue_xmit(struct bonding *
}
skb->priority = 1;
- dev_queue_xmit(skb);
-
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ if (bond->netpoll)
+ netpoll_send_skb(bond->netpoll, skb);
+ else
+#endif
+ dev_queue_xmit(skb);
return 0;
}
@@ -1567,6 +1571,45 @@ static void bond_detach_slave(struct bon
bond->slave_cnt--;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static int slaves_support_netpoll(struct net_device *bond_dev)
+{
+ struct bonding *bond = bond_dev->priv;
+ struct slave *slave;
+ int i;
+
+ bond_for_each_slave(bond, slave, i) {
+ if (!slave->dev->poll_controller)
+ return 0;
+ }
+
+ return 1;
+}
+
+static void bond_poll_controller(struct net_device *bond_dev)
+{
+ struct bonding *bond = bond_dev->priv;
+ struct slave *slave;
+ int i;
+
+ bond_for_each_slave(bond, slave, i) {
+ if (slave->dev->poll_controller)
+ netpoll_poll_dev(slave->dev);
+ }
+}
+
+static void bond_netpoll_setup(struct net_device *bond_dev,
+ struct netpoll_info *npinfo)
+{
+ struct bonding *bond = bond_dev->priv;
+ struct slave *slave;
+ int i;
+
+ bond_for_each_slave(bond, slave, i)
+ slave->dev->npinfo = npinfo;
+}
+#endif
+
/*---------------------------------- IOCTL ----------------------------------*/
static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev)
@@ -1969,6 +2012,17 @@ static int bond_enslave(struct net_devic
new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup",
new_slave->link != BOND_LINK_DOWN ? "n up" : " down");
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ if (slaves_support_netpoll(bond_dev)) {
+ bond_dev->poll_controller = bond_poll_controller;
+ slave_dev->npinfo = bond_dev->npinfo;
+ } else if (bond_dev->poll_controller) {
+ bond_dev->poll_controller = NULL;
+ printk("New slave device %s does not support netpoll.\n",
+ slave_dev->name);
+ printk("netpoll disabled for %s.\n", bond_dev->name);
+ }
+#endif
/* enslave is successful */
return 0;
@@ -2173,6 +2227,9 @@ static int bond_release(struct net_devic
slave_dev->flags &= ~IFF_NOARP;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ slave_dev->npinfo = NULL;
+#endif
kfree(slave);
return 0; /* deletion OK */
@@ -4203,6 +4260,21 @@ out:
return 0;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+int bond_xmit_netpoll(struct netpoll *np, struct sk_buff *skb,
+ struct net_device *bond_dev)
+{
+ struct bonding *bond = bond_dev->priv;
+ int ret;
+
+ bond->netpoll = np;
+ ret = bond_dev->hard_start_xmit(skb, bond_dev);
+ bond->netpoll = NULL;
+
+ return ret;
+}
+#endif
+
/*------------------------- Device initialization ---------------------------*/
/*
@@ -4277,6 +4349,10 @@ static int __init bond_init(struct net_d
bond_dev->destructor = free_netdev;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ bond_dev->netpoll_setup = bond_netpoll_setup;
+ bond_dev->netpoll_start_xmit = bond_xmit_netpoll;
+#endif
/* Initialize the device options */
bond_dev->tx_queue_len = 0;
bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
--- linux-2.6.12/drivers/net/bonding/bonding.h.orig 2005-06-29 14:29:40.000000000 -0400
+++ linux-2.6.12/drivers/net/bonding/bonding.h 2005-06-30 19:02:54.000000000 -0400
@@ -33,6 +33,7 @@
#include <linux/timer.h>
#include <linux/proc_fs.h>
#include <linux/if_bonding.h>
+#include <linux/netpoll.h>
#include "bond_3ad.h"
#include "bond_alb.h"
@@ -203,6 +204,9 @@ struct bonding {
struct bond_params params;
struct list_head vlan_list;
struct vlan_group *vlgrp;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ struct netpoll *netpoll;
+#endif
};
/**
next prev parent reply other threads:[~2005-07-01 23:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-01 23:05 [rfc | patch 0/6] netpoll: add support for the bonding driver Jeff Moyer
2005-07-01 23:06 ` Jeff Moyer
2005-07-01 23:06 ` Jeff Moyer
2005-07-01 23:08 ` [rfc | patch 3/6] netpoll: change poll_napi to take a net_device Jeff Moyer
2005-07-01 23:08 ` [rfc | patch 4/6] netpoll: add netpoll hooks to support the bonding driver Jeff Moyer
2005-07-01 23:09 ` Jeff Moyer [this message]
2005-07-01 23:10 ` [rfc | patch 6/6] netpoll: fix deadlock in arp_reply Jeff Moyer
2005-07-01 23:38 ` [rfc | patch 0/6] netpoll: add support for the bonding driver Matt Mackall
2005-07-01 23:43 ` Jeff Moyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17093.52534.420781.92366@segfault.boston.redhat.com \
--to=jmoyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®