From: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
To: unlisted-recipients:; (no To-header on input)
Cc: "Hans Westgaard Ry" <hans.westgaard.ry@oracle.com>,
"Doug Ledford" <dledford@redhat.com>,
"Sean Hefty" <sean.hefty@intel.com>,
"Hal Rosenstock" <hal.rosenstock@gmail.com>,
"Bart Van Assche" <bart.vanassche@sandisk.com>,
"Yuval Shaia" <yuval.shaia@oracle.com>,
"Christian Marie" <christian@ponies.io>,
"Jason Gunthorpe" <jgunthorpe@obsidianresearch.com>,
"Håkon Bugge" <haakon.bugge@oracle.com>,
"Wei Lin Guay" <wei.lin.guay@oracle.com>,
"Or Gerlitz" <ogerlitz@mellanox.com>,
"Erez Shitrit" <erezsh@mellanox.com>,
"Haggai Eran" <haggaie@mellanox.com>,
"Chuck Lever" <chuck.lever@oracle.com>,
"Matan Barak" <matanb@mellanox.com>,
linux-rdma@vger.kernel.org (open list:INFINIBAND SUBSYSTEM),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] IB/ipoib: Add handling of skb with many frags
Date: Thu, 18 Feb 2016 09:37:54 +0100 [thread overview]
Message-ID: <1455784674-8412-1-git-send-email-hans.westgaard.ry@oracle.com> (raw)
IPoIB converts skb-fragments to sge adding 1 extra sge when offloading
is enabled. Current codepath assumes that the max number of sge a device
support is at least MAX_SKB_FRAGS+1, there is no interaction with upper
layers to limit number of fragments in an skb if a device suports fewer
sge. The assumptions also lead to requesting a fixed number ot sge when
IPoIB creates queue-pairs with scatter/gather enabled.
A fallback/slowpath is implemented using skb_linearize to
handle cases where the conversion would result in more sges than supported.
Signed-off-by: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
Reviewed-by: Wei Lin Guay <wei.lin.guay@oracle.com>
---
drivers/infiniband/ulp/ipoib/ipoib_cm.c | 4 +++-
drivers/infiniband/ulp/ipoib/ipoib_ib.c | 9 +++++++++
drivers/infiniband/ulp/ipoib/ipoib_verbs.c | 4 +++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 917e46e..0a2bd43 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -1031,7 +1031,9 @@ static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ipoib_
struct ib_qp *tx_qp;
if (dev->features & NETIF_F_SG)
- attr.cap.max_send_sge = MAX_SKB_FRAGS + 1;
+ attr.cap.max_send_sge = min_t(u32,
+ priv->ca->attrs.max_sge,
+ MAX_SKB_FRAGS + 1);
tx_qp = ib_create_qp(priv->pd, &attr);
if (PTR_ERR(tx_qp) == -EINVAL) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 5ea0c14..b4f2240 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -541,6 +541,15 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
int hlen, rc;
void *phead;
+ if (skb_shinfo(skb)->nr_frags >= priv->ca->attrs.max_sge) {
+ if (skb_linearize(skb) != 0) {
+ ipoib_warn(priv, "skb could not be linearized\n");
+ ++dev->stats.tx_dropped;
+ ++dev->stats.tx_errors;
+ dev_kfree_skb_any(skb);
+ return;
+ }
+ }
if (skb_is_gso(skb)) {
hlen = skb_transport_offset(skb) + tcp_hdrlen(skb);
phead = skb->data;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index d48c5ba..62f8ec3 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -206,7 +206,9 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
init_attr.create_flags |= IB_QP_CREATE_NETIF_QP;
if (dev->features & NETIF_F_SG)
- init_attr.cap.max_send_sge = MAX_SKB_FRAGS + 1;
+ init_attr.cap.max_send_sge = min_t(u32,
+ priv->ca->attrs.max_sge,
+ MAX_SKB_FRAGS + 1);
priv->qp = ib_create_qp(priv->pd, &init_attr);
if (IS_ERR(priv->qp)) {
--
2.4.3
next reply other threads:[~2016-02-18 8:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-18 8:37 Hans Westgaard Ry [this message]
2016-03-02 12:44 ` [PATCH v2] IB/ipoib: Add handling for sending " Hans Westgaard Ry
2016-03-03 15:11 ` Doug Ledford
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=1455784674-8412-1-git-send-email-hans.westgaard.ry@oracle.com \
--to=hans.westgaard.ry@oracle.com \
--cc=bart.vanassche@sandisk.com \
--cc=christian@ponies.io \
--cc=chuck.lever@oracle.com \
--cc=dledford@redhat.com \
--cc=erezsh@mellanox.com \
--cc=haakon.bugge@oracle.com \
--cc=haggaie@mellanox.com \
--cc=hal.rosenstock@gmail.com \
--cc=jgunthorpe@obsidianresearch.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=matanb@mellanox.com \
--cc=ogerlitz@mellanox.com \
--cc=sean.hefty@intel.com \
--cc=wei.lin.guay@oracle.com \
--cc=yuval.shaia@oracle.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
all inboxes | Powered by JetHome®