From: Krishna Kumar <krkumar2@in.ibm.com>
To: johnpol@2ka.mipt.ru, sri@us.ibm.com,
shemminger@linux-foundation.org, kaber@trash.net,
davem@davemloft.net
Cc: jagana@us.ibm.com, Robert.Olsson@data.slu.se, rick.jones2@hp.com,
herbert@gondor.apana.org.au, gaagaan@gmail.com,
kumarkr@linux.ibm.com, rdreier@cisco.com,
peter.p.waskiewicz.jr@intel.com, mcarlson@broadcom.com,
jeff@garzik.org, general@lists.openfabrics.org,
mchan@broadcom.com, tgraf@suug.ch, hadi@cyberus.ca,
netdev@vger.kernel.org, Krishna Kumar <krkumar2@in.ibm.com>,
xma@us.ibm.com
Subject: [PATCH 2/9 Rev3] [core] Add skb_blist & hard_start_xmit_batch
Date: Wed, 08 Aug 2007 15:01:35 +0530 [thread overview]
Message-ID: <20070808093135.15396.29687.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20070808093114.15396.22797.sendpatchset@localhost.localdomain>
Introduce skb_blist and hard_start_xmit_batch API, handle driver's usage
of the new API, and add support routines.
Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---
include/linux/netdevice.h | 8 +++
net/core/dev.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 106 insertions(+)
diff -ruNp ORG/include/linux/netdevice.h NEW/include/linux/netdevice.h
--- ORG/include/linux/netdevice.h 2007-08-06 08:25:37.000000000 +0530
+++ NEW/include/linux/netdevice.h 2007-08-07 13:11:19.000000000 +0530
@@ -456,6 +456,9 @@ struct net_device
/* Partially transmitted GSO packet. */
struct sk_buff *gso_skb;
+ /* List of batch skbs (optional, used if driver supports batching API */
+ struct sk_buff_head *skb_blist;
+
/* ingress path synchronizer */
spinlock_t ingress_lock;
struct Qdisc *qdisc_ingress;
@@ -472,6 +475,9 @@ struct net_device
void *priv; /* pointer to private data */
int (*hard_start_xmit) (struct sk_buff *skb,
struct net_device *dev);
+ int (*hard_start_xmit_batch) (struct net_device
+ *dev);
+
/* These may be needed for future network-power-down code. */
unsigned long trans_start; /* Time (in jiffies) of last Tx */
@@ -832,6 +838,8 @@ extern int dev_set_mac_address(struct n
struct sockaddr *);
extern int dev_hard_start_xmit(struct sk_buff *skb,
struct net_device *dev);
+extern int dev_add_skb_to_blist(struct sk_buff *skb,
+ struct net_device *dev);
extern void dev_init(void);
diff -ruNp ORG/net/core/dev.c NEW/net/core/dev.c
--- ORG/net/core/dev.c 2007-08-06 08:25:40.000000000 +0530
+++ NEW/net/core/dev.c 2007-08-07 13:11:19.000000000 +0530
@@ -897,6 +897,55 @@ void netdev_state_change(struct net_devi
}
}
+static void free_batching(struct net_device *dev)
+{
+ if (dev->skb_blist) {
+ if (!skb_queue_empty(dev->skb_blist))
+ skb_queue_purge(dev->skb_blist);
+ kfree(dev->skb_blist);
+ dev->skb_blist = NULL;
+ }
+}
+
+int dev_change_tx_batch_skb(struct net_device *dev, unsigned long new_batch_skb)
+{
+ int ret = 0;
+ struct sk_buff_head *blist;
+
+ if (!dev->hard_start_xmit_batch) {
+ /* Driver doesn't support batching skb API */
+ ret = -ENOTSUPP;
+ goto out;
+ }
+
+ /* Handle invalid argument */
+ if (new_batch_skb < 0) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ /* Check if new value is same as the current */
+ if (!!dev->skb_blist == !!new_batch_skb)
+ goto out;
+
+ if (new_batch_skb &&
+ (blist = kmalloc(sizeof *blist, GFP_KERNEL)) == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ spin_lock(&dev->queue_lock);
+ if (new_batch_skb) {
+ skb_queue_head_init(blist);
+ dev->skb_blist = blist;
+ } else
+ free_batching(dev);
+ spin_unlock(&dev->queue_lock);
+
+out:
+ return ret;
+}
+
/**
* dev_load - load a network module
* @name: name of interface
@@ -1459,6 +1508,45 @@ static int dev_gso_segment(struct sk_buf
return 0;
}
+/*
+ * Add skb (skbs in case segmentation is required) to dev->skb_blist. We are
+ * holding QDISC RUNNING bit, so no one else can add to this list. Also, skbs
+ * are dequeued from this list when we call the driver, so the list is safe
+ * from simultaneous deletes too.
+ *
+ * Returns count of successful skb(s) added to skb_blist.
+ */
+int dev_add_skb_to_blist(struct sk_buff *skb, struct net_device *dev)
+{
+ if (!list_empty(&ptype_all))
+ dev_queue_xmit_nit(skb, dev);
+
+ if (netif_needs_gso(dev, skb)) {
+ if (unlikely(dev_gso_segment(skb))) {
+ kfree(skb);
+ return 0;
+ }
+
+ if (skb->next) {
+ int count = 0;
+
+ do {
+ struct sk_buff *nskb = skb->next;
+
+ skb->next = nskb->next;
+ __skb_queue_tail(dev->skb_blist, nskb);
+ count++;
+ } while (skb->next);
+
+ skb->destructor = DEV_GSO_CB(skb)->destructor;
+ kfree_skb(skb);
+ return count;
+ }
+ }
+ __skb_queue_tail(dev->skb_blist, skb);
+ return 1;
+}
+
int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
if (likely(!skb->next)) {
@@ -3446,6 +3535,13 @@ int register_netdevice(struct net_device
}
}
+ if (dev->hard_start_xmit_batch) {
+ /* Driver supports batching skb API */
+ dev->skb_blist = kmalloc(sizeof *dev->skb_blist, GFP_KERNEL);
+ if (dev->skb_blist)
+ skb_queue_head_init(dev->skb_blist);
+ }
+
/*
* nil rebuild_header routine,
* that should be never called and used as just bug trap.
@@ -3787,6 +3882,9 @@ void unregister_netdevice(struct net_dev
synchronize_net();
+ /* Deallocate batching structure */
+ free_batching(dev);
+
/* Shutdown queueing discipline. */
dev_shutdown(dev);
next prev parent reply other threads:[~2007-08-08 9:30 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-08 9:31 [ofa-general] [PATCH 0/9 Rev3] Implement batching skb API and support in IPoIB Krishna Kumar
2007-08-08 9:31 ` [PATCH 1/9 Rev3] [Doc] HOWTO Documentation for batching Krishna Kumar
2007-08-08 9:31 ` Krishna Kumar [this message]
2007-08-08 10:59 ` [ofa-general] Re: [PATCH 2/9 Rev3] [core] Add skb_blist & hard_start_xmit_batch Stephen Hemminger
2007-08-08 11:24 ` Krishna Kumar2
2007-08-08 12:01 ` Evgeniy Polyakov
2007-08-09 3:09 ` Krishna Kumar2
2007-08-08 9:31 ` [PATCH 3/9 Rev3] [sched] Modify qdisc_run to support batching Krishna Kumar
2007-08-08 12:14 ` [ofa-general] " Evgeniy Polyakov
2007-08-09 3:13 ` Krishna Kumar2
2007-08-08 14:05 ` Patrick McHardy
2007-08-08 15:26 ` [ofa-general] " jamal
2007-08-09 4:06 ` Krishna Kumar2
2007-08-08 9:31 ` [PATCH 4/9 Rev3] [ethtool] Add ethtool support Krishna Kumar
2007-08-08 9:32 ` [ofa-general] [PATCH 5/9 Rev3] [IPoIB] Header file changes Krishna Kumar
2007-08-08 9:32 ` [ofa-general] [PATCH 6/9 Rev3] [IPoIB] CM & Multicast changes Krishna Kumar
2007-08-08 9:32 ` [ofa-general] [PATCH 7/9 Rev3] [IPoIB] Verb changes Krishna Kumar
2007-08-08 9:32 ` [PATCH 8/9 Rev3] [IPoIB] Post and work completion handler changes Krishna Kumar
2007-08-08 9:32 ` [PATCH 9/9 Rev3] [IPoIB] Implement the new batching API Krishna Kumar
2007-08-08 10:49 ` [ofa-general] Re: [PATCH 0/9 Rev3] Implement batching skb API and support in IPoIB David Miller
2007-08-08 11:09 ` Krishna Kumar2
2007-08-08 22:01 ` [ofa-general] " David Miller
2007-08-09 4:19 ` Krishna Kumar2
2007-08-09 4:27 ` David Miller
2007-08-09 6:26 ` Krishna Kumar2
2007-08-08 13:42 ` [ofa-general] " Herbert Xu
2007-08-08 15:14 ` jamal
2007-08-08 20:55 ` Stephen Hemminger
2007-08-08 22:40 ` jamal
2007-08-08 22:22 ` David Miller
2007-08-08 22:53 ` jamal
2007-08-09 0:06 ` Shirley Ma
2007-08-09 3:19 ` [ofa-general] " Krishna Kumar2
2007-08-14 9:02 ` Krishna Kumar2
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=20070808093135.15396.29687.sendpatchset@localhost.localdomain \
--to=krkumar2@in.ibm.com \
--cc=Robert.Olsson@data.slu.se \
--cc=davem@davemloft.net \
--cc=gaagaan@gmail.com \
--cc=general@lists.openfabrics.org \
--cc=hadi@cyberus.ca \
--cc=herbert@gondor.apana.org.au \
--cc=jagana@us.ibm.com \
--cc=jeff@garzik.org \
--cc=johnpol@2ka.mipt.ru \
--cc=kaber@trash.net \
--cc=kumarkr@linux.ibm.com \
--cc=mcarlson@broadcom.com \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=peter.p.waskiewicz.jr@intel.com \
--cc=rdreier@cisco.com \
--cc=rick.jones2@hp.com \
--cc=shemminger@linux-foundation.org \
--cc=sri@us.ibm.com \
--cc=tgraf@suug.ch \
--cc=xma@us.ibm.com \
/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