* RE: [PATCH 6/6] gianfar: Revive SKB recycling
From: Kumar Gopalpet-B05799 @ 2009-11-11 4:20 UTC (permalink / raw)
To: Anton Vorontsov, David Miller
Cc: Fleming Andy-AFLEMING, Jon Loeliger, Lennert Buytenhek,
Stephen Hemminger, netdev, linuxppc-dev
In-Reply-To: <20091111001110.GF8817@oksana.dev.rtsoft.ru>
>-----Original Message-----
>From: Anton Vorontsov [mailto:avorontsov@ru.mvista.com]
>Sent: Wednesday, November 11, 2009 5:41 AM
>To: David Miller
>Cc: Fleming Andy-AFLEMING; Jon Loeliger; Kumar
>Gopalpet-B05799; Lennert Buytenhek; Stephen Hemminger;
>netdev@vger.kernel.org; linuxppc-dev@ozlabs.org
>Subject: [PATCH 6/6] gianfar: Revive SKB recycling
>
>Before calling gfar_clean_tx_ring() the driver grabs an
>irqsave spinlock, and then tries to recycle skbs. But since
>skb_recycle_check() returns 0 with IRQs disabled, we'll never
>recycle any skbs.
>
>It appears that gfar_clean_tx_ring() and gfar_start_xmit() are
>mostly idependent and can work in parallel, except when they
>modify num_txbdfree.
>
>So we can drop the lock from most sections and thus fix the
>skb recycling.
>
>Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>---
> drivers/net/gianfar.c | 31 +++++++++++++++++++------------
> 1 files changed, 19 insertions(+), 12 deletions(-)
>
>diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
>index fde430a..16def13 100644
>--- a/drivers/net/gianfar.c
>+++ b/drivers/net/gianfar.c
>@@ -1928,14 +1928,11 @@ static int gfar_start_xmit(struct
>sk_buff *skb, struct net_device *dev)
> /* total number of fragments in the SKB */
> nr_frags = skb_shinfo(skb)->nr_frags;
>
>- spin_lock_irqsave(&tx_queue->txlock, flags);
>-
> /* check if there is space to queue this packet */
> if ((nr_frags+1) > tx_queue->num_txbdfree) {
> /* no space, stop the queue */
> netif_tx_stop_queue(txq);
> dev->stats.tx_fifo_errors++;
>- spin_unlock_irqrestore(&tx_queue->txlock, flags);
> return NETDEV_TX_BUSY;
> }
>
>@@ -1999,6 +1996,20 @@ static int gfar_start_xmit(struct
>sk_buff *skb, struct net_device *dev)
> lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb);
>
> /*
>+ * We can work in parallel with gfar_clean_tx_ring(), except
>+ * when modifying num_txbdfree. Note that we didn't
>grab the lock
>+ * when we were reading the num_txbdfree and checking
>for available
>+ * space, that's because outside of this function it
>can only grow,
>+ * and once we've got needed space, it cannot suddenly
>disappear.
>+ *
>+ * The lock also protects us from gfar_error(), which can modify
>+ * regs->tstat and thus retrigger the transfers, which is why we
>+ * also must grab the lock before setting ready bit for
>the first
>+ * to be transmitted BD.
>+ */
>+ spin_lock_irqsave(&tx_queue->txlock, flags);
>+
>+ /*
> * The powerpc-specific eieio() is used, as wmb() has too strong
> * semantics (it requires synchronization between cacheable and
> * uncacheable mappings, which eieio doesn't provide
>and which we @@ -2225,6 +2236,8 @@ static int
>gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
> skb_dirtytx = tx_queue->skb_dirtytx;
>
> while ((skb = tx_queue->tx_skbuff[skb_dirtytx])) {
>+ unsigned long flags;
>+
> frags = skb_shinfo(skb)->nr_frags;
> lbdp = skip_txbd(bdp, frags, base, tx_ring_size);
>
>@@ -2269,7 +2282,9 @@ static int gfar_clean_tx_ring(struct
>gfar_priv_tx_q *tx_queue)
> TX_RING_MOD_MASK(tx_ring_size);
>
> howmany++;
>+ spin_lock_irqsave(&tx_queue->txlock, flags);
> tx_queue->num_txbdfree += frags + 1;
>+ spin_unlock_irqrestore(&tx_queue->txlock, flags);
> }
>
> /* If we freed a buffer, we can restart transmission,
>if necessary */ @@ -2548,7 +2563,6 @@ static int
>gfar_poll(struct napi_struct *napi, int budget)
> int tx_cleaned = 0, i, left_over_budget = budget;
> unsigned long serviced_queues = 0;
> int num_queues = 0;
>- unsigned long flags;
>
> num_queues = gfargrp->num_rx_queues;
> budget_per_queue = budget/num_queues;
>@@ -2568,14 +2582,7 @@ static int gfar_poll(struct napi_struct
>*napi, int budget)
> rx_queue = priv->rx_queue[i];
> tx_queue = priv->tx_queue[rx_queue->qindex];
>
>- /* If we fail to get the lock,
>- * don't bother with the TX BDs */
>- if
>(spin_trylock_irqsave(&tx_queue->txlock, flags)) {
>- tx_cleaned +=
>gfar_clean_tx_ring(tx_queue);
>-
>spin_unlock_irqrestore(&tx_queue->txlock,
>- flags);
>- }
>-
>+ tx_cleaned += gfar_clean_tx_ring(tx_queue);
> rx_cleaned_per_queue =
>gfar_clean_rx_ring(rx_queue,
>
>budget_per_queue);
> rx_cleaned += rx_cleaned_per_queue;
>--
Anton, we tried some experiments too at our end, and removing the
spinlocks did help improve the performance and recycling was effective
although, I don't have exact numbers to specify.
But overall I agree with you in removing the spinlocks from the
gfar_poll context.
--
Thanks
Sandeep
^ permalink raw reply
* RE: [PATCH 3/6] gianfar: Fix build with CONFIG_PM=y
From: Kumar Gopalpet-B05799 @ 2009-11-11 4:27 UTC (permalink / raw)
To: Anton Vorontsov, David Miller
Cc: Jon Loeliger, netdev, linuxppc-dev, Fleming Andy-AFLEMING,
Stephen Hemminger, Lennert Buytenhek
In-Reply-To: <20091111001105.GC8817@oksana.dev.rtsoft.ru>
>-----Original Message-----
>From: Anton Vorontsov [mailto:avorontsov@ru.mvista.com]
>Sent: Wednesday, November 11, 2009 5:41 AM
>To: David Miller
>Cc: Fleming Andy-AFLEMING; Jon Loeliger; Kumar
>Gopalpet-B05799; Lennert Buytenhek; Stephen Hemminger;
>netdev@vger.kernel.org; linuxppc-dev@ozlabs.org
>Subject: [PATCH 3/6] gianfar: Fix build with CONFIG_PM=y
>
>commit fba4ed030cfae7efdb6b79a57b0c5a9d72c9 ("gianfar: Add
>Multiple Queue Support") introduced the following build failure:
>
> CC gianfar.o
>gianfar.c: In function 'gfar_restore':
>gianfar.c:1249: error: request for member 'napi' in something
>not a structure or union
>
>This patch fixes the issue.
>
>Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>---
> drivers/net/gianfar.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
>index 79c28f5..a5b0038 100644
>--- a/drivers/net/gianfar.c
>+++ b/drivers/net/gianfar.c
>@@ -1246,7 +1246,7 @@ static int gfar_restore(struct device *dev)
> phy_start(priv->phydev);
>
> netif_device_attach(ndev);
>- napi_enable(&priv->gfargrp.napi);
>+ enable_napi(priv);
>
> return 0;
> }
I am extreemely sorry for introducing this error, I missed it while
porting my last set of patches.
Thanks for fixing it.
--
Thanks
Sandeep
^ permalink raw reply
* Re: [PATCH 01/75] netx: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:31 UTC (permalink / raw)
To: ben; +Cc: s.hauer, netdev
In-Reply-To: <1257629856.15927.370.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:37:36 +0000
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 02/75] solos-pci: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:31 UTC (permalink / raw)
To: ben; +Cc: chas, linux-atm-general, netdev
In-Reply-To: <1257630032.15927.377.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:40:32 +0000
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 08/75] ambassador: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:31 UTC (permalink / raw)
To: ben; +Cc: chas, linux-atm-general, netdev
In-Reply-To: <1257630367.15927.395.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:46:07 +0000
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 39/75] bnx2x: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:32 UTC (permalink / raw)
To: ben; +Cc: eilong, netdev
In-Reply-To: <1257630819.15927.437.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:53:39 +0000
> Replace run-time string formatting with preprocessor string
> manipulation.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 40/75] cxgb3: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:32 UTC (permalink / raw)
To: ben; +Cc: divy, netdev
In-Reply-To: <1257630832.15927.440.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:53:52 +0000
> Replace run-time string formatting with preprocessor string
> manipulation.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 42/75] myri10ge: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:33 UTC (permalink / raw)
To: ben; +Cc: gallatin, brice, netdev
In-Reply-To: <1257630884.15927.442.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:54:44 +0000
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 43/75] spider-net: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:33 UTC (permalink / raw)
To: ben; +Cc: kou.ishizaki, jens, netdev
In-Reply-To: <1257630907.15927.445.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:55:07 +0000
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 44/75] tms380tr: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:34 UTC (permalink / raw)
To: ben; +Cc: netdev
In-Reply-To: <1257630920.15927.446.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 21:55:20 +0000
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH 58/75] pcnet-cs: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:34 UTC (permalink / raw)
To: ben; +Cc: netdev, linux-pcmcia
In-Reply-To: <1257631449.15927.478.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 07 Nov 2009 22:04:09 +0000
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
Thanks Ben.
^ permalink raw reply
* Re: [PATCH 43/75] spider-net: declare MODULE_FIRMWARE
From: David Miller @ 2009-11-11 4:35 UTC (permalink / raw)
To: jens; +Cc: ben, kou.ishizaki, jens, netdev, arnd
In-Reply-To: <200911091258.13989.jens@linux.vnet.ibm.com>
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Mon, 9 Nov 2009 12:58:13 +0100
> In spider_net, the filesystem is checked for a valid firmware first, if it
> does not exist, the firmware is taken from the device tree (which is the
> default case).
>
> Do you expect this behaviour to cause problems together with MODULE_FIRMWARE ?
I think it should be OK.
^ permalink raw reply
* Re: [PATCH, WTF] atm: move all compat_ioctl handling to atm/ioctl.c
From: David Miller @ 2009-11-11 4:41 UTC (permalink / raw)
To: arnd; +Cc: dwmw2, linux-kernel, netdev, eric.dumazet
In-Reply-To: <200911061500.01651.arnd@arndb.de>
I agree that this should be done in one place, rather than split up
like it is now. Can you please respin your changes against
net-next-2.6 since the code you are changing here is no longer in
fs/compat_ioctl.c due to your other patch set?
Thanks.
^ permalink raw reply
* xfrm command fails
From: Naveen BN @ 2009-11-11 5:28 UTC (permalink / raw)
To: netdev
Hi All
I am trying to create a security association using ip xfrm command, but
i get an message saying
"*RTNETLINK answers: Function not implemented*" and ip xfrm state
succeeds in displaying sa written using setkey .
ip xfrm state add src 192.168.1.20 dst 192.168.1.5 proto esp spi
0x354cb04b mode tunnel reqid 16385 replay-window 32 auth hmac
0xecf02a5cf6568556e1bdcd961c7ec3f92afd01cc enc cbc
0x5c0cfa9672ce67ba545b593076dfb278 sel src 0.0.0.0/0 dst 0.0.0.0/0
ERROR message => "RTNETLINK answers: Function not implemented"
Regards
Naveen
^ permalink raw reply
* Re: [PATCH 10/10] CAN: use dev_get_by_index_rcu
From: Oliver Hartkopp @ 2009-11-11 5:54 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Stephen Hemminger, David Miller, netdev
In-Reply-To: <4AF9B21E.50805@gmail.com>
Eric Dumazet wrote:
> Stephen Hemminger a écrit :
>> Use new function to avoid doing read_lock().
>>
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>>
>> --- a/net/can/bcm.c 2009-11-10 09:45:16.301376272 -0800
>> +++ b/net/can/bcm.c 2009-11-10 09:46:30.125005956 -0800
>> @@ -139,13 +139,13 @@ static char *bcm_proc_getifname(char *re
>> if (!ifindex)
>> return "any";
>>
>> - read_lock(&dev_base_lock);
>> - dev = __dev_get_by_index(&init_net, ifindex);
>> + rcu_read_lock();
>> + dev = dev_get_by_index_rcu(&init_net, ifindex);
>> if (dev)
>> strcpy(result, dev->name);
>> else
>> strcpy(result, "???");
>> - read_unlock(&dev_base_lock);
>> + rcu_read_unlock();
>>
>> return result;
>> }
>>
>
> I was pretty sure I had already done this one...
>
> Ah yes, that was planned after a bugfix for net-2.6.
>
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
>
Thanks everyone!
Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
^ permalink raw reply
* SO_TIMESTAMPING: AF_INET6 and AF_PACKET now working
From: Marcus D. Leech @ 2009-11-11 6:20 UTC (permalink / raw)
To: netdev
I have SO_TIMESTAMPING work for AF_INET6 and AF_PACKET now, against a
2.6.30 kernel.
I'll test it over the next couple of days, and then I guess post a patch
against the
2.6.32-rc6 kernel.
Cheers
Marcus
^ permalink raw reply
* Re: xfrm command fails
From: Naveen BN @ 2009-11-11 6:07 UTC (permalink / raw)
To: netdev
In-Reply-To: <4AFA4B60.3090306@globaledgesoft.com>
I am using fedora with version => 2.6.23.1-42.fc8.
Please guide me to solve the error message "RTNETLINK answers: Function
not implemented"
Regards
Naveen
Naveen BN wrote:
> Hi All
> I am trying to create a security association using ip xfrm command,
> but i get an message saying
> "*RTNETLINK answers: Function not implemented*" and ip xfrm state
> succeeds in displaying sa written using setkey .
>
> ip xfrm state add src 192.168.1.20 dst 192.168.1.5 proto esp spi
> 0x354cb04b mode tunnel reqid 16385 replay-window 32 auth hmac
> 0xecf02a5cf6568556e1bdcd961c7ec3f92afd01cc enc cbc
> 0x5c0cfa9672ce67ba545b593076dfb278 sel src 0.0.0.0/0 dst 0.0.0.0/0
>
> ERROR message => "RTNETLINK answers: Function not implemented"
>
> Regards
> Naveen
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [PATCH] ifb: add multi-queue support
From: Changli Gao @ 2009-11-11 6:30 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Eric Dumazet, Patrick McHardy, David S. Miller, netdev,
Tom Herbert
In-Reply-To: <20091110084516.15659fcc@nehalam>
[-- Attachment #1: Type: text/plain, Size: 750 bytes --]
On Wed, Nov 11, 2009 at 12:45 AM, Stephen Hemminger
<shemminger@vyatta.com> wrote:
> On Tue, 10 Nov 2009 21:49:31 +0800
> Changli Gao <xiaosuo@gmail.com> wrote:
>
>
> Distro's would find that hard, also it would cause people to forgot binary
> API compatibility.
>
Get it. Thanks.
The new version of ifb is attached:
1. fixbug: a deadlock.
2. fixbug: statistics data corruption.
3. fixbug: can't work with ip link command.
Dear Patrick:
The support for specifying the number of TX queues with ip link
command is comming soon. I do think the corresponding kernel module
parameter is needed for the default option and the ifbs created when
module loading, so I preserve it.
--
Regards,
Changli Gao(xiaosuo@gmail.com)
[-- Attachment #2: ifb.c --]
[-- Type: application/octet-stream, Size: 10030 bytes --]
/* drivers/net/ifb.c:
The purpose of this driver is to provide a device that allows
for sharing of resources:
1) qdiscs/policies that are per device as opposed to system wide.
ifb allows for a device which can be redirected to thus providing
an impression of sharing.
2) Allows for queueing incoming traffic for shaping instead of
dropping.
The original concept is based on what is known as the IMQ
driver initially written by Martin Devera, later rewritten
by Patrick McHardy and then maintained by Andre Correa.
You need the tc action mirror or redirect to feed this device
packets.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version
2 of the License, or (at your option) any later version.
Authors: Jamal Hadi Salim (2005)
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/moduleparam.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <net/ip.h>
#include <net/pkt_sched.h>
#include <net/net_namespace.h>
#define TX_Q_LIMIT 32
struct ifb_private_q {
struct net_device *dev;
struct sk_buff_head rq;
struct sk_buff_head tq;
wait_queue_head_t wq;
struct task_struct *task;
unsigned long rx_packets;
unsigned long rx_bytes;
unsigned long rx_dropped;
} ____cacheline_aligned_in_smp;
struct ifb_private {
struct ifb_private_q *pq;
};
/* Number of ifb devices to be set up by this module. */
static int numifbs = 2;
module_param(numifbs, int, 0444);
MODULE_PARM_DESC(numifbs, "Number of ifb devices");
/* Number of TX queues per ifb */
static int numtxqs = 1;
module_param(numtxqs, int, 0444);
MODULE_PARM_DESC(numtxqs, "Number of TX queues per ifb");
static int ifb_thread(void *priv)
{
struct ifb_private_q *pq = priv;
struct net_device *dev = pq->dev;
int num = pq - ((struct ifb_private *)netdev_priv(dev))->pq;
struct netdev_queue *txq = netdev_get_tx_queue(dev, num);
struct sk_buff *skb;
DEFINE_WAIT(wait);
while (1) {
/* move skb from rq to tq */
while (1) {
prepare_to_wait(&pq->wq, &wait, TASK_UNINTERRUPTIBLE);
__netif_tx_lock_bh(txq);
while ((skb = skb_dequeue(&pq->rq)) != NULL)
skb_queue_tail(&pq->tq, skb);
if (netif_queue_stopped(dev))
netif_wake_queue(dev);
__netif_tx_unlock_bh(txq);
if (kthread_should_stop() || !skb_queue_empty(&pq->tq))
break;
schedule();
}
finish_wait(&pq->wq, &wait);
if (kthread_should_stop())
break;
if (need_resched())
schedule();
/* transfer packets */
while ((skb = skb_dequeue(&pq->tq)) != NULL) {
u32 from = G_TC_FROM(skb->tc_verd);
skb->tc_verd = 0;
skb->tc_verd = SET_TC_NCLS(skb->tc_verd);
txq->tx_packets++;
txq->tx_bytes +=skb->len;
rcu_read_lock();
skb->dev = dev_get_by_index_rcu(&init_net, skb->iif);
if (!skb->dev) {
rcu_read_unlock();
dev_kfree_skb(skb);
txq->tx_dropped++;
break;
}
rcu_read_unlock();
skb->iif = dev->ifindex;
if (from & AT_EGRESS) {
dev_queue_xmit(skb);
} else if (from & AT_INGRESS) {
skb_pull(skb, skb->dev->hard_header_len);
netif_rx_ni(skb);
} else
BUG();
}
}
return 0;
}
struct net_device_stats* ifb_get_stats(struct net_device *dev)
{
struct net_device_stats *stats = &dev->stats;
struct ifb_private *dp = netdev_priv(dev);
struct ifb_private_q *pq = dp->pq;
struct netdev_queue *txq;
int i;
unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0;
unsigned long tx_packets = 0, tx_bytes = 0, tx_dropped = 0;
for (i = 0; i < dev->real_num_tx_queues; i++) {
rx_packets += pq[i].rx_packets;
rx_bytes += pq[i].rx_bytes;
rx_dropped += pq[i].rx_dropped;
txq = netdev_get_tx_queue(dev, i);
tx_packets += txq->tx_packets;
tx_bytes += txq->tx_bytes;
tx_dropped += txq->tx_dropped;
}
stats->rx_packets = rx_packets;
stats->rx_bytes = rx_bytes;
stats->rx_dropped = rx_dropped;
stats->tx_packets = tx_packets;
stats->tx_bytes = tx_bytes;
stats->tx_dropped = tx_dropped;
return stats;
}
static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
{
u32 from = G_TC_FROM(skb->tc_verd);
int num = skb_get_queue_mapping(skb);
struct ifb_private *dp = netdev_priv(dev);
struct ifb_private_q *pq = dp->pq + num;
struct netdev_queue *txq = netdev_get_tx_queue(dev, num);
pq->rx_packets++;
pq->rx_bytes += skb->len;
if (!(from & (AT_INGRESS|AT_EGRESS)) || !skb->iif) {
dev_kfree_skb(skb);
pq->rx_dropped++;
return NETDEV_TX_OK;
}
txq->trans_start = jiffies;
skb_queue_tail(&pq->rq, skb);
if (skb_queue_len(&pq->rq) >= dev->tx_queue_len)
netif_stop_queue(dev);
if (skb_queue_len(&pq->rq) == 1)
wake_up(&pq->wq);
return NETDEV_TX_OK;
}
static int ifb_close(struct net_device *dev)
{
struct ifb_private *dp = netdev_priv(dev);
struct ifb_private_q *pq = dp->pq;
int i;
netif_stop_queue(dev);
for (i = 0; i < dev->real_num_tx_queues; i++) {
kthread_stop(pq[i].task);
skb_queue_purge(&pq[i].tq);
skb_queue_purge(&pq[i].rq);
}
return 0;
}
static int ifb_open(struct net_device *dev)
{
struct ifb_private *dp = netdev_priv(dev);
struct ifb_private_q *pq = dp->pq;
int i;
for (i = 0; i < dev->real_num_tx_queues; i++) {
pq[i].task = kthread_run(ifb_thread, &pq[i], "%s/%d", dev->name,
i);
if (IS_ERR(pq[i].task)) {
int err = PTR_ERR(pq[i].task);
while (--i >= 0)
kthread_stop(pq[i].task);
return err;
}
}
netif_start_queue(dev);
return 0;
}
static u32 simple_tx_hashrnd;
static u16 ifb_select_queue(struct net_device *dev, struct sk_buff *skb)
{
u32 addr1, addr2;
u32 hash, ihl;
union {
u16 in16[2];
u32 in32;
} ports;
u8 ip_proto;
if ((hash = skb_rx_queue_recorded(skb))) {
while (hash >= dev->real_num_tx_queues)
hash -= dev->real_num_tx_queues;
return hash;
}
switch (skb->protocol) {
case __constant_htons(ETH_P_IP):
if (!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)))
ip_proto = ip_hdr(skb)->protocol;
else
ip_proto = 0;
addr1 = ip_hdr(skb)->saddr;
addr2 = ip_hdr(skb)->daddr;
ihl = ip_hdr(skb)->ihl << 2;
break;
case __constant_htons(ETH_P_IPV6):
ip_proto = ipv6_hdr(skb)->nexthdr;
addr1 = ipv6_hdr(skb)->saddr.s6_addr32[3];
addr2 = ipv6_hdr(skb)->daddr.s6_addr32[3];
ihl = 10;
break;
default:
return 0;
}
if (addr1 > addr2)
swap(addr1, addr2);
switch (ip_proto) {
case IPPROTO_TCP:
case IPPROTO_UDP:
case IPPROTO_DCCP:
case IPPROTO_ESP:
case IPPROTO_AH:
case IPPROTO_SCTP:
case IPPROTO_UDPLITE:
ports.in32 = *((u32 *) (skb_network_header(skb) + ihl));
if (ports.in16[0] > ports.in16[1])
swap(ports.in16[0], ports.in16[1]);
break;
default:
ports.in32 = 0;
break;
}
hash = jhash_3words(addr1, addr2, ports.in32,
simple_tx_hashrnd ^ ip_proto);
return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32);
}
static int ifb_init(struct net_device *dev)
{
struct ifb_private *dp = netdev_priv(dev);
struct ifb_private_q *pq = dp->pq;
int i;
pq = kmalloc(sizeof(*pq) * dev->real_num_tx_queues, GFP_KERNEL);
if (pq == NULL)
return -ENOMEM;
dp->pq = pq;
for (i = 0; i < dev->real_num_tx_queues; i++) {
pq[i].dev = dev;
skb_queue_head_init(&pq[i].rq);
skb_queue_head_init(&pq[i].tq);
init_waitqueue_head(&pq[i].wq);
pq[i].rx_packets = 0;
pq[i].rx_bytes = 0;
pq[i].rx_dropped = 0;
}
return 0;
}
static void ifb_uninit(struct net_device *dev)
{
struct ifb_private *dp = netdev_priv(dev);
kfree(dp->pq);
}
static const struct net_device_ops ifb_netdev_ops = {
.ndo_init = ifb_init,
.ndo_uninit = ifb_uninit,
.ndo_open = ifb_open,
.ndo_stop = ifb_close,
.ndo_start_xmit = ifb_xmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_select_queue = ifb_select_queue,
.ndo_get_stats = ifb_get_stats,
};
static void ifb_setup(struct net_device *dev)
{
/* Initialize the device structure. */
dev->destructor = free_netdev;
dev->netdev_ops = &ifb_netdev_ops;
/* Fill in device structure with ethernet-generic values. */
ether_setup(dev);
dev->tx_queue_len = TX_Q_LIMIT;
dev->flags |= IFF_NOARP;
dev->flags &= ~IFF_MULTICAST;
dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
random_ether_addr(dev->dev_addr);
}
static int ifb_validate(struct nlattr *tb[], struct nlattr *data[])
{
if (tb[IFLA_ADDRESS]) {
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
return -EINVAL;
if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
return -EADDRNOTAVAIL;
}
return 0;
}
static int ifb_get_tx_queues(struct net *net, struct nlattr *tb[],
unsigned int *num_tx_queues,
unsigned int *real_num_tx_queues)
{
*num_tx_queues = numtxqs;
*real_num_tx_queues = numtxqs;
return 0;
}
static struct rtnl_link_ops ifb_link_ops __read_mostly = {
.kind = "ifb",
.setup = ifb_setup,
.validate = ifb_validate,
.get_tx_queues = ifb_get_tx_queues,
.priv_size = sizeof(struct ifb_private),
};
static int __init ifb_init_one(int index)
{
struct net_device *dev_ifb;
int err;
dev_ifb = alloc_netdev_mq(sizeof(struct ifb_private), "ifb%d",
ifb_setup, numtxqs);
if (!dev_ifb)
return -ENOMEM;
err = dev_alloc_name(dev_ifb, dev_ifb->name);
if (err < 0)
goto err;
dev_ifb->rtnl_link_ops = &ifb_link_ops;
err = register_netdevice(dev_ifb);
if (err < 0)
goto err;
return 0;
err:
free_netdev(dev_ifb);
return err;
}
static int __init ifb_init_module(void)
{
int i, err;
get_random_bytes(&simple_tx_hashrnd, 4);
rtnl_lock();
err = __rtnl_link_register(&ifb_link_ops);
for (i = 0; i < numifbs && !err; i++)
err = ifb_init_one(i);
if (err)
__rtnl_link_unregister(&ifb_link_ops);
rtnl_unlock();
return err;
}
static void __exit ifb_cleanup_module(void)
{
rtnl_link_unregister(&ifb_link_ops);
}
module_init(ifb_init_module);
module_exit(ifb_cleanup_module);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jamal Hadi Salim");
MODULE_ALIAS_RTNL_LINK("ifb");
^ permalink raw reply
* Re: [PATCH] usbnet: Set link down initially for drivers that update link state
From: David Miller @ 2009-11-11 6:31 UTC (permalink / raw)
To: ben; +Cc: dbrownell, greg, jacmet, netdev
In-Reply-To: <1257384592.3136.473.camel@localhost>
From: Ben Hutchings <ben@decadent.org.uk>
Date: Thu, 05 Nov 2009 01:29:52 +0000
> Some usbnet drivers update link state while others do not due to
> hardware limitations. Add a flag to distinguish those that do, and
> set the link down initially for their devices.
>
> This is intended to fix this bug: http://bugs.debian.org/444043
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Applied to net-next-2.6
^ permalink raw reply
* RE: PATCH: Network Device Naming mechanism and policy
From: Narendra_K @ 2009-11-11 6:31 UTC (permalink / raw)
To: shemminger
Cc: md, Matt_Domsch, bryan, dannf, bhutchings, netdev, linux-hotplug,
Jordan_Hargrave, Charles_Rose, Sandeep_K_Shandilya
In-Reply-To: <20091110092328.336cf60e@nehalam>
>> >> Fair enough - but would you object if we changed the
>naming scheme
>> >> from eth%d to something else?
>> >I suppose that this would depend on what else. :-) Since you want
>> >radical changes I recommend that you design the new
>persistent naming
>> >infrastructure in a way that will allow root to choose to use the
>> >classic naming scheme, or many users will scream a lot and at least
>> >some distributions will do it anyway.
>> >I also expect that providing choice at the beginning of development
>> >may lead to more acceptance later if and when the new scheme will
>> >have proved itself to be superior (at least in some situations).
>> >You have tought about this for a long time and if so far
>you have not
>> >found a solution which is widely considered superior then I doubt
>> >that one will appear soon. Providing your favourite naming
>scheme as
>> >an optional add on will immediately benefit those who like it and
>> >greatly reduce opposition from those who do not.
>>
>> In that way, I suppose char device node solution fits the scheme
>> perfectly. It doesn't change or interfere with the kernel's default
>> naming scheme (ethN) in any way. Also, the applications continue to
>> work the way they did and in addition to supporting
>traditional names,
>> they would also support pathnames. Whether all the user space
>> applications need to be patched can be discussed and
>debated. But, we
>> can patch applications like, installers and firewall code,
>which when
>> don't see determinism ("eth0 mapping to integrated port 1"),
>fail and
>> cause very high impact could be patched. Since users are already
>> familiar with pathnames like /dev/disk/by-id{label, uuid}, I suppose
>> it might not be very difficult to get used to pathnames like
>> /dev/netdev/by-chassis-label/Embedded_NIC_1. Would that be
>acceptable ?
>>
>
>IFNAMSIZ = 16 is hardwired as part of the kernel binary user space API.
This factor is taken into consideration. The user space applications
take this pathname, map it to the kernel name and use the kernel name to
issue ioctls (http://linux.dell.com/wiki/index.php/Oss/libnetdevname).
The pathname was suggested because it provides a way to get to the right
interface when "integrated port 1" doesn't get the expected name "eth0".
With regards,
Narendra K
^ permalink raw reply
* Re: [PATCH] net: netlink_getname, packet_getname -- use DECLARE_SOCKADDR guard
From: David Miller @ 2009-11-11 6:31 UTC (permalink / raw)
To: gorcunov; +Cc: netdev, eric.dumazet
In-Reply-To: <20091108155119.GA25940@lenovo>
From: Cyrill Gorcunov <gorcunov@openvz.org>
Date: Sun, 8 Nov 2009 18:51:19 +0300
> Use guard DECLARE_SOCKADDR in a few more places which allow
> us to catch if the structure copied back is too big.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Applied to net-next-2.6, thanks.
^ permalink raw reply
* Re: [PATCH net-next] Phonet: put sockets in a hash table
From: David Miller @ 2009-11-11 6:31 UTC (permalink / raw)
To: remi; +Cc: netdev, remi.denis-courmont
In-Reply-To: <1257769021-521-1-git-send-email-remi@remlab.net>
From: Rémi Denis-Courmont <remi@remlab.net>
Date: Mon, 9 Nov 2009 14:17:01 +0200
> From: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
>
> Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH net-next] Phonet: allocate and copy for pipe TX without sock lock
From: David Miller @ 2009-11-11 6:32 UTC (permalink / raw)
To: remi; +Cc: netdev, remi.denis-courmont
In-Reply-To: <1257775600-23389-1-git-send-email-remi@remlab.net>
From: Rémi Denis-Courmont <remi@remlab.net>
Date: Mon, 9 Nov 2009 16:06:40 +0200
> From: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
>
> Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH]Use DMA_BIT_MASK(44) instead of deprecated DMA_44BIT_MASK
From: David Miller @ 2009-11-11 6:31 UTC (permalink / raw)
To: mitov; +Cc: linux-kernel, netdev
In-Reply-To: <200911081759.27263.mitov@issp.bas.bg>
From: Marin Mitov <mitov@issp.bas.bg>
Date: Sun, 8 Nov 2009 17:59:27 +0200
> Use DMA_BIT_MASK(44) instead of deprecated DMA_44BIT_MASK
>
> Signed-off-by: Marin Mitov <mitov@issp.bas.bg>
Applied to net-next-2.6
^ permalink raw reply
* Re: [PATCH net-next-2.6] udp: bind() optimisation
From: David Miller @ 2009-11-11 6:32 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, lgrijincu, opurdila
In-Reply-To: <4AF834A9.2050005@gmail.com>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 09 Nov 2009 16:26:33 +0100
> UDP bind() can be O(N^2) in some pathological cases.
>
> Thanks to secondary hash tables, we can make it O(N)
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied to net-next-2.6
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox