2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
|
2005-08-11 14:03:10 +08:00
|
|
|
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
|
|
|
|
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
|
|
|
|
* Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the
|
|
|
|
* OpenIB.org BSD license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or
|
|
|
|
* without modification, are permitted provided that the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/delay.h>
|
2011-08-31 00:32:52 +08:00
|
|
|
#include <linux/moduleparam.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/dma-mapping.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-17 12:09:27 +08:00
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/tcp.h>
|
2018-06-05 13:40:22 +08:00
|
|
|
#include <rdma/ib_cache.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "ipoib.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG_DATA
|
|
|
|
static int data_debug_level;
|
|
|
|
|
|
|
|
module_param(data_debug_level, int, 0644);
|
|
|
|
MODULE_PARM_DESC(data_debug_level,
|
|
|
|
"Enable data path debug tracing if > 0");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
|
2017-04-30 02:41:18 +08:00
|
|
|
struct ib_pd *pd, struct rdma_ah_attr *attr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct ipoib_ah *ah;
|
2011-11-21 21:43:54 +08:00
|
|
|
struct ib_ah *vah;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-07-05 05:52:51 +08:00
|
|
|
ah = kmalloc(sizeof(*ah), GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!ah)
|
2011-11-21 21:43:54 +08:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ah->dev = dev;
|
|
|
|
ah->last_send = 0;
|
|
|
|
kref_init(&ah->ref);
|
|
|
|
|
2018-12-12 17:09:05 +08:00
|
|
|
vah = rdma_create_ah(pd, attr, RDMA_CREATE_AH_SLEEPABLE);
|
2011-11-21 21:43:54 +08:00
|
|
|
if (IS_ERR(vah)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(ah);
|
2011-11-21 21:43:54 +08:00
|
|
|
ah = (struct ipoib_ah *)vah;
|
|
|
|
} else {
|
|
|
|
ah->ah = vah;
|
2017-04-10 16:22:29 +08:00
|
|
|
ipoib_dbg(ipoib_priv(dev), "Created ah %p\n", ah->ah);
|
2011-11-21 21:43:54 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return ah;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ipoib_free_ah(struct kref *kref)
|
|
|
|
{
|
|
|
|
struct ipoib_ah *ah = container_of(kref, struct ipoib_ah, ref);
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(ah->dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
unsigned long flags;
|
|
|
|
|
2006-06-18 11:37:34 +08:00
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
list_add_tail(&ah->list, &priv->dead_ahs);
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-04-24 02:55:45 +08:00
|
|
|
static void ipoib_ud_dma_unmap_rx(struct ipoib_dev_priv *priv,
|
|
|
|
u64 mapping[IPOIB_UD_RX_SG])
|
|
|
|
{
|
IB/ipoib: Use one linear skb in RX flow
The current code in the RX flow uses two sg entries for each incoming
packet, the first one was for the IB headers and the second for the rest
of the data, that causes two dma map/unmap and two allocations, and few
more actions that were done at the data path.
Use only one linear skb on each incoming packet, for the data (IB
headers and payload), that reduces the packet processing in the
data-path (only one skb, no frags, the first frag was not used anyway,
less memory allocations) and the dma handling (only one dma map/unmap
over each incoming packet instead of two map/unmap per each incoming packet).
After commit 73d3fe6d1c6d ("gro: fix aggregation for skb using frag_list") from
Eric Dumazet, we will get full aggregation for large packets.
When running bandwidth tests before and after the (over the card's numa node),
using "netperf -H 1.1.1.3 -T -t TCP_STREAM", the results before are ~12Gbs before
and after ~16Gbs on my setup (Mellanox's ConnectX3).
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2015-04-02 18:39:00 +08:00
|
|
|
ib_dma_unmap_single(priv->ca, mapping[0],
|
|
|
|
IPOIB_UD_BUF_SIZE(priv->max_ib_mtu),
|
|
|
|
DMA_FROM_DEVICE);
|
2008-04-24 02:55:45 +08:00
|
|
|
}
|
|
|
|
|
2005-10-29 06:30:34 +08:00
|
|
|
static int ipoib_ib_post_receive(struct net_device *dev, int id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-10-29 06:30:34 +08:00
|
|
|
int ret;
|
|
|
|
|
2008-04-24 02:55:45 +08:00
|
|
|
priv->rx_wr.wr_id = id | IPOIB_OP_RECV;
|
|
|
|
priv->rx_sge[0].addr = priv->rx_ring[id].mapping[0];
|
|
|
|
priv->rx_sge[1].addr = priv->rx_ring[id].mapping[1];
|
2005-10-29 06:30:34 +08:00
|
|
|
|
|
|
|
|
2018-07-19 00:25:18 +08:00
|
|
|
ret = ib_post_recv(priv->qp, &priv->rx_wr, NULL);
|
2005-10-29 06:30:34 +08:00
|
|
|
if (unlikely(ret)) {
|
|
|
|
ipoib_warn(priv, "receive failed for buf %d (%d)\n", id, ret);
|
2008-04-24 02:55:45 +08:00
|
|
|
ipoib_ud_dma_unmap_rx(priv, priv->rx_ring[id].mapping);
|
2005-10-29 06:30:34 +08:00
|
|
|
dev_kfree_skb_any(priv->rx_ring[id].skb);
|
|
|
|
priv->rx_ring[id].skb = NULL;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-10-29 06:30:34 +08:00
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-04-24 02:55:45 +08:00
|
|
|
static struct sk_buff *ipoib_alloc_rx_skb(struct net_device *dev, int id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
struct sk_buff *skb;
|
2008-04-24 02:55:45 +08:00
|
|
|
int buf_size;
|
|
|
|
u64 *mapping;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
IB/ipoib: Use one linear skb in RX flow
The current code in the RX flow uses two sg entries for each incoming
packet, the first one was for the IB headers and the second for the rest
of the data, that causes two dma map/unmap and two allocations, and few
more actions that were done at the data path.
Use only one linear skb on each incoming packet, for the data (IB
headers and payload), that reduces the packet processing in the
data-path (only one skb, no frags, the first frag was not used anyway,
less memory allocations) and the dma handling (only one dma map/unmap
over each incoming packet instead of two map/unmap per each incoming packet).
After commit 73d3fe6d1c6d ("gro: fix aggregation for skb using frag_list") from
Eric Dumazet, we will get full aggregation for large packets.
When running bandwidth tests before and after the (over the card's numa node),
using "netperf -H 1.1.1.3 -T -t TCP_STREAM", the results before are ~12Gbs before
and after ~16Gbs on my setup (Mellanox's ConnectX3).
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2015-04-02 18:39:00 +08:00
|
|
|
buf_size = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu);
|
2008-04-24 02:55:45 +08:00
|
|
|
|
IB/ipoib: move back IB LL address into the hard header
After the commit 9207f9d45b0a ("net: preserve IP control block
during GSO segmentation"), the GSO CB and the IPoIB CB conflict.
That destroy the IPoIB address information cached there,
causing a severe performance regression, as better described here:
http://marc.info/?l=linux-kernel&m=146787279825501&w=2
This change moves the data cached by the IPoIB driver from the
skb control lock into the IPoIB hard header, as done before
the commit 936d7de3d736 ("IPoIB: Stop lying about hard_header_len
and use skb->cb to stash LL addresses").
In order to avoid GRO issue, on packet reception, the IPoIB driver
stash into the skb a dummy pseudo header, so that the received
packets have actually a hard header matching the declared length.
To avoid changing the connected mode maximum mtu, the allocated
head buffer size is increased by the pseudo header length.
After this commit, IPoIB performances are back to pre-regression
value.
v2 -> v3: rebased
v1 -> v2: avoid changing the max mtu, increasing the head buf size
Fixes: 9207f9d45b0a ("net: preserve IP control block during GSO segmentation")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-14 00:26:56 +08:00
|
|
|
skb = dev_alloc_skb(buf_size + IPOIB_HARD_LEN);
|
2008-04-24 02:55:45 +08:00
|
|
|
if (unlikely(!skb))
|
|
|
|
return NULL;
|
2005-10-29 06:30:34 +08:00
|
|
|
|
|
|
|
/*
|
IB/ipoib: move back IB LL address into the hard header
After the commit 9207f9d45b0a ("net: preserve IP control block
during GSO segmentation"), the GSO CB and the IPoIB CB conflict.
That destroy the IPoIB address information cached there,
causing a severe performance regression, as better described here:
http://marc.info/?l=linux-kernel&m=146787279825501&w=2
This change moves the data cached by the IPoIB driver from the
skb control lock into the IPoIB hard header, as done before
the commit 936d7de3d736 ("IPoIB: Stop lying about hard_header_len
and use skb->cb to stash LL addresses").
In order to avoid GRO issue, on packet reception, the IPoIB driver
stash into the skb a dummy pseudo header, so that the received
packets have actually a hard header matching the declared length.
To avoid changing the connected mode maximum mtu, the allocated
head buffer size is increased by the pseudo header length.
After this commit, IPoIB performances are back to pre-regression
value.
v2 -> v3: rebased
v1 -> v2: avoid changing the max mtu, increasing the head buf size
Fixes: 9207f9d45b0a ("net: preserve IP control block during GSO segmentation")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-14 00:26:56 +08:00
|
|
|
* the IP header will be at IPOIP_HARD_LEN + IB_GRH_BYTES, that is
|
|
|
|
* 64 bytes aligned
|
2005-10-29 06:30:34 +08:00
|
|
|
*/
|
IB/ipoib: move back IB LL address into the hard header
After the commit 9207f9d45b0a ("net: preserve IP control block
during GSO segmentation"), the GSO CB and the IPoIB CB conflict.
That destroy the IPoIB address information cached there,
causing a severe performance regression, as better described here:
http://marc.info/?l=linux-kernel&m=146787279825501&w=2
This change moves the data cached by the IPoIB driver from the
skb control lock into the IPoIB hard header, as done before
the commit 936d7de3d736 ("IPoIB: Stop lying about hard_header_len
and use skb->cb to stash LL addresses").
In order to avoid GRO issue, on packet reception, the IPoIB driver
stash into the skb a dummy pseudo header, so that the received
packets have actually a hard header matching the declared length.
To avoid changing the connected mode maximum mtu, the allocated
head buffer size is increased by the pseudo header length.
After this commit, IPoIB performances are back to pre-regression
value.
v2 -> v3: rebased
v1 -> v2: avoid changing the max mtu, increasing the head buf size
Fixes: 9207f9d45b0a ("net: preserve IP control block during GSO segmentation")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-14 00:26:56 +08:00
|
|
|
skb_reserve(skb, sizeof(struct ipoib_pseudo_header));
|
2005-10-29 06:30:34 +08:00
|
|
|
|
2008-04-24 02:55:45 +08:00
|
|
|
mapping = priv->rx_ring[id].mapping;
|
|
|
|
mapping[0] = ib_dma_map_single(priv->ca, skb->data, buf_size,
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
if (unlikely(ib_dma_mapping_error(priv->ca, mapping[0])))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
priv->rx_ring[id].skb = skb;
|
|
|
|
return skb;
|
|
|
|
error:
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
return NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ipoib_ib_post_receives(struct net_device *dev)
|
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
2006-04-11 00:43:58 +08:00
|
|
|
for (i = 0; i < ipoib_recvq_size; ++i) {
|
2008-04-24 02:55:45 +08:00
|
|
|
if (!ipoib_alloc_rx_skb(dev, i)) {
|
2005-10-29 06:30:34 +08:00
|
|
|
ipoib_warn(priv, "failed to allocate receive buffer %d\n", i);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ipoib_ib_post_receive(dev, i)) {
|
|
|
|
ipoib_warn(priv, "ipoib_ib_post_receive failed for buf %d\n", i);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-09-23 06:22:52 +08:00
|
|
|
static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2006-09-23 06:22:52 +08:00
|
|
|
unsigned int wr_id = wc->wr_id & ~IPOIB_OP_RECV;
|
|
|
|
struct sk_buff *skb;
|
2008-04-24 02:55:45 +08:00
|
|
|
u64 mapping[IPOIB_UD_RX_SG];
|
2010-08-27 21:29:38 +08:00
|
|
|
union ib_gid *dgid;
|
2016-03-12 04:58:43 +08:00
|
|
|
union ib_gid *sgid;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-04-19 11:20:53 +08:00
|
|
|
ipoib_dbg_data(priv, "recv completion: id %d, status: %d\n",
|
|
|
|
wr_id, wc->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-23 06:22:52 +08:00
|
|
|
if (unlikely(wr_id >= ipoib_recvq_size)) {
|
|
|
|
ipoib_warn(priv, "recv completion event with wrid %d (> %d)\n",
|
|
|
|
wr_id, ipoib_recvq_size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb = priv->rx_ring[wr_id].skb;
|
|
|
|
|
|
|
|
if (unlikely(wc->status != IB_WC_SUCCESS)) {
|
|
|
|
if (wc->status != IB_WC_WR_FLUSH_ERR)
|
2017-09-28 02:26:08 +08:00
|
|
|
ipoib_warn(priv,
|
|
|
|
"failed recv event (status=%d, wrid=%d vend_err %#x)\n",
|
2006-09-23 06:22:52 +08:00
|
|
|
wc->status, wr_id, wc->vendor_err);
|
2008-04-24 02:55:45 +08:00
|
|
|
ipoib_ud_dma_unmap_rx(priv, priv->rx_ring[wr_id].mapping);
|
2006-09-23 06:22:52 +08:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
priv->rx_ring[wr_id].skb = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-24 02:55:45 +08:00
|
|
|
memcpy(mapping, priv->rx_ring[wr_id].mapping,
|
2018-07-05 05:52:51 +08:00
|
|
|
IPOIB_UD_RX_SG * sizeof(*mapping));
|
2008-04-24 02:55:45 +08:00
|
|
|
|
2006-09-23 06:22:52 +08:00
|
|
|
/*
|
|
|
|
* If we can't allocate a new RX buffer, dump
|
|
|
|
* this packet and reuse the old buffer.
|
|
|
|
*/
|
2008-04-24 02:55:45 +08:00
|
|
|
if (unlikely(!ipoib_alloc_rx_skb(dev, wr_id))) {
|
2007-09-29 06:33:51 +08:00
|
|
|
++dev->stats.rx_dropped;
|
2006-09-23 06:22:52 +08:00
|
|
|
goto repost;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n",
|
|
|
|
wc->byte_len, wc->slid);
|
|
|
|
|
2008-04-24 02:55:45 +08:00
|
|
|
ipoib_ud_dma_unmap_rx(priv, mapping);
|
IB/ipoib: Use one linear skb in RX flow
The current code in the RX flow uses two sg entries for each incoming
packet, the first one was for the IB headers and the second for the rest
of the data, that causes two dma map/unmap and two allocations, and few
more actions that were done at the data path.
Use only one linear skb on each incoming packet, for the data (IB
headers and payload), that reduces the packet processing in the
data-path (only one skb, no frags, the first frag was not used anyway,
less memory allocations) and the dma handling (only one dma map/unmap
over each incoming packet instead of two map/unmap per each incoming packet).
After commit 73d3fe6d1c6d ("gro: fix aggregation for skb using frag_list") from
Eric Dumazet, we will get full aggregation for large packets.
When running bandwidth tests before and after the (over the card's numa node),
using "netperf -H 1.1.1.3 -T -t TCP_STREAM", the results before are ~12Gbs before
and after ~16Gbs on my setup (Mellanox's ConnectX3).
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2015-04-02 18:39:00 +08:00
|
|
|
|
|
|
|
skb_put(skb, wc->byte_len);
|
2006-09-23 06:22:52 +08:00
|
|
|
|
2010-08-27 21:29:38 +08:00
|
|
|
/* First byte of dgid signals multicast when 0xff */
|
|
|
|
dgid = &((struct ib_grh *)skb->data)->dgid;
|
|
|
|
|
|
|
|
if (!(wc->wc_flags & IB_WC_GRH) || dgid->raw[0] != 0xff)
|
|
|
|
skb->pkt_type = PACKET_HOST;
|
|
|
|
else if (memcmp(dgid, dev->broadcast + 4, sizeof(union ib_gid)) == 0)
|
|
|
|
skb->pkt_type = PACKET_BROADCAST;
|
|
|
|
else
|
|
|
|
skb->pkt_type = PACKET_MULTICAST;
|
|
|
|
|
2016-03-12 04:58:43 +08:00
|
|
|
sgid = &((struct ib_grh *)skb->data)->sgid;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Drop packets that this interface sent, ie multicast packets
|
|
|
|
* that the HCA has replicated.
|
|
|
|
*/
|
|
|
|
if (wc->slid == priv->local_lid && wc->src_qp == priv->qp->qp_num) {
|
|
|
|
int need_repost = 1;
|
|
|
|
|
|
|
|
if ((wc->wc_flags & IB_WC_GRH) &&
|
|
|
|
sgid->global.interface_id != priv->local_gid.global.interface_id)
|
|
|
|
need_repost = 0;
|
|
|
|
|
|
|
|
if (need_repost) {
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
goto repost;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-23 06:22:52 +08:00
|
|
|
skb_pull(skb, IB_GRH_BYTES);
|
|
|
|
|
2007-07-11 04:43:53 +08:00
|
|
|
skb->protocol = ((struct ipoib_header *) skb->data)->proto;
|
IB/ipoib: move back IB LL address into the hard header
After the commit 9207f9d45b0a ("net: preserve IP control block
during GSO segmentation"), the GSO CB and the IPoIB CB conflict.
That destroy the IPoIB address information cached there,
causing a severe performance regression, as better described here:
http://marc.info/?l=linux-kernel&m=146787279825501&w=2
This change moves the data cached by the IPoIB driver from the
skb control lock into the IPoIB hard header, as done before
the commit 936d7de3d736 ("IPoIB: Stop lying about hard_header_len
and use skb->cb to stash LL addresses").
In order to avoid GRO issue, on packet reception, the IPoIB driver
stash into the skb a dummy pseudo header, so that the received
packets have actually a hard header matching the declared length.
To avoid changing the connected mode maximum mtu, the allocated
head buffer size is increased by the pseudo header length.
After this commit, IPoIB performances are back to pre-regression
value.
v2 -> v3: rebased
v1 -> v2: avoid changing the max mtu, increasing the head buf size
Fixes: 9207f9d45b0a ("net: preserve IP control block during GSO segmentation")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-14 00:26:56 +08:00
|
|
|
skb_add_pseudo_hdr(skb);
|
2007-07-11 04:43:53 +08:00
|
|
|
|
2007-09-29 06:33:51 +08:00
|
|
|
++dev->stats.rx_packets;
|
|
|
|
dev->stats.rx_bytes += skb->len;
|
2017-07-10 23:12:43 +08:00
|
|
|
if (skb->pkt_type == PACKET_MULTICAST)
|
|
|
|
dev->stats.multicast++;
|
2007-07-11 04:43:53 +08:00
|
|
|
|
|
|
|
skb->dev = dev;
|
2012-01-12 01:03:51 +08:00
|
|
|
if ((dev->features & NETIF_F_RXCSUM) &&
|
|
|
|
likely(wc->wc_flags & IB_WC_IP_CSUM_OK))
|
2008-04-17 12:01:10 +08:00
|
|
|
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
napi_gro_receive(&priv->recv_napi, skb);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-23 06:22:52 +08:00
|
|
|
repost:
|
|
|
|
if (unlikely(ipoib_ib_post_receive(dev, wr_id)))
|
|
|
|
ipoib_warn(priv, "ipoib_ib_post_receive failed "
|
|
|
|
"for buf %d\n", wr_id);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-07-12 16:24:09 +08:00
|
|
|
int ipoib_dma_map_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req)
|
2008-01-31 00:30:53 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *skb = tx_req->skb;
|
|
|
|
u64 *mapping = tx_req->mapping;
|
|
|
|
int i;
|
2008-04-17 12:09:27 +08:00
|
|
|
int off;
|
2008-01-31 00:30:53 +08:00
|
|
|
|
2008-04-17 12:09:27 +08:00
|
|
|
if (skb_headlen(skb)) {
|
|
|
|
mapping[0] = ib_dma_map_single(ca, skb->data, skb_headlen(skb),
|
|
|
|
DMA_TO_DEVICE);
|
|
|
|
if (unlikely(ib_dma_mapping_error(ca, mapping[0])))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
off = 1;
|
|
|
|
} else
|
|
|
|
off = 0;
|
2008-01-31 00:30:53 +08:00
|
|
|
|
|
|
|
for (i = 0; i < skb_shinfo(skb)->nr_frags; ++i) {
|
2011-10-19 05:00:24 +08:00
|
|
|
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
|
2011-08-25 06:28:10 +08:00
|
|
|
mapping[i + off] = ib_dma_map_page(ca,
|
|
|
|
skb_frag_page(frag),
|
2019-07-30 22:40:33 +08:00
|
|
|
skb_frag_off(frag),
|
|
|
|
skb_frag_size(frag),
|
2008-01-31 00:30:53 +08:00
|
|
|
DMA_TO_DEVICE);
|
2008-04-17 12:09:27 +08:00
|
|
|
if (unlikely(ib_dma_mapping_error(ca, mapping[i + off])))
|
2008-01-31 00:30:53 +08:00
|
|
|
goto partial_error;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
partial_error:
|
|
|
|
for (; i > 0; --i) {
|
2011-10-19 05:00:24 +08:00
|
|
|
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
|
|
|
|
|
|
|
|
ib_dma_unmap_page(ca, mapping[i - !off], skb_frag_size(frag), DMA_TO_DEVICE);
|
2008-01-31 00:30:53 +08:00
|
|
|
}
|
2008-04-17 12:09:27 +08:00
|
|
|
|
|
|
|
if (off)
|
|
|
|
ib_dma_unmap_single(ca, mapping[0], skb_headlen(skb), DMA_TO_DEVICE);
|
|
|
|
|
2008-01-31 00:30:53 +08:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2015-07-12 16:24:09 +08:00
|
|
|
void ipoib_dma_unmap_tx(struct ipoib_dev_priv *priv,
|
|
|
|
struct ipoib_tx_buf *tx_req)
|
2008-01-31 00:30:53 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *skb = tx_req->skb;
|
|
|
|
u64 *mapping = tx_req->mapping;
|
|
|
|
int i;
|
2008-04-17 12:09:27 +08:00
|
|
|
int off;
|
2008-01-31 00:30:53 +08:00
|
|
|
|
2008-04-17 12:09:27 +08:00
|
|
|
if (skb_headlen(skb)) {
|
2015-07-12 16:24:09 +08:00
|
|
|
ib_dma_unmap_single(priv->ca, mapping[0], skb_headlen(skb),
|
|
|
|
DMA_TO_DEVICE);
|
2008-04-17 12:09:27 +08:00
|
|
|
off = 1;
|
|
|
|
} else
|
|
|
|
off = 0;
|
2008-01-31 00:30:53 +08:00
|
|
|
|
|
|
|
for (i = 0; i < skb_shinfo(skb)->nr_frags; ++i) {
|
2011-10-19 05:00:24 +08:00
|
|
|
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
|
|
|
|
|
2015-07-12 16:24:09 +08:00
|
|
|
ib_dma_unmap_page(priv->ca, mapping[i + off],
|
|
|
|
skb_frag_size(frag), DMA_TO_DEVICE);
|
2008-01-31 00:30:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 18:39:02 +08:00
|
|
|
/*
|
|
|
|
* As the result of a completion error the QP Can be transferred to SQE states.
|
|
|
|
* The function checks if the (send)QP is in SQE state and
|
|
|
|
* moves it back to RTS state, that in order to have it functional again.
|
|
|
|
*/
|
|
|
|
static void ipoib_qp_state_validate_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ipoib_qp_state_validate *qp_work =
|
|
|
|
container_of(work, struct ipoib_qp_state_validate, work);
|
|
|
|
|
|
|
|
struct ipoib_dev_priv *priv = qp_work->priv;
|
|
|
|
struct ib_qp_attr qp_attr;
|
|
|
|
struct ib_qp_init_attr query_init_attr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ib_query_qp(priv->qp, &qp_attr, IB_QP_STATE, &query_init_attr);
|
|
|
|
if (ret) {
|
|
|
|
ipoib_warn(priv, "%s: Failed to query QP ret: %d\n",
|
|
|
|
__func__, ret);
|
|
|
|
goto free_res;
|
|
|
|
}
|
|
|
|
pr_info("%s: QP: 0x%x is in state: %d\n",
|
|
|
|
__func__, priv->qp->qp_num, qp_attr.qp_state);
|
|
|
|
|
|
|
|
/* currently support only in SQE->RTS transition*/
|
|
|
|
if (qp_attr.qp_state == IB_QPS_SQE) {
|
|
|
|
qp_attr.qp_state = IB_QPS_RTS;
|
|
|
|
|
|
|
|
ret = ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE);
|
|
|
|
if (ret) {
|
|
|
|
pr_warn("failed(%d) modify QP:0x%x SQE->RTS\n",
|
|
|
|
ret, priv->qp->qp_num);
|
|
|
|
goto free_res;
|
|
|
|
}
|
|
|
|
pr_info("%s: QP: 0x%x moved from IB_QPS_SQE to IB_QPS_RTS\n",
|
|
|
|
__func__, priv->qp->qp_num);
|
|
|
|
} else {
|
|
|
|
pr_warn("QP (%d) will stay in state: %d\n",
|
|
|
|
priv->qp->qp_num, qp_attr.qp_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
free_res:
|
|
|
|
kfree(qp_work);
|
|
|
|
}
|
|
|
|
|
2006-09-23 06:22:52 +08:00
|
|
|
static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
|
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2006-09-23 06:22:52 +08:00
|
|
|
unsigned int wr_id = wc->wr_id;
|
|
|
|
struct ipoib_tx_buf *tx_req;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-04-19 11:20:53 +08:00
|
|
|
ipoib_dbg_data(priv, "send completion: id %d, status: %d\n",
|
|
|
|
wr_id, wc->status);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-23 06:22:52 +08:00
|
|
|
if (unlikely(wr_id >= ipoib_sendq_size)) {
|
|
|
|
ipoib_warn(priv, "send completion event with wrid %d (> %d)\n",
|
|
|
|
wr_id, ipoib_sendq_size);
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-09-23 06:22:52 +08:00
|
|
|
|
|
|
|
tx_req = &priv->tx_ring[wr_id];
|
|
|
|
|
2015-07-12 16:24:09 +08:00
|
|
|
ipoib_dma_unmap_tx(priv, tx_req);
|
2006-09-23 06:22:52 +08:00
|
|
|
|
2007-09-29 06:33:51 +08:00
|
|
|
++dev->stats.tx_packets;
|
|
|
|
dev->stats.tx_bytes += tx_req->skb->len;
|
2006-09-23 06:22:52 +08:00
|
|
|
|
|
|
|
dev_kfree_skb_any(tx_req->skb);
|
|
|
|
|
|
|
|
++priv->tx_tail;
|
2017-10-19 12:56:43 +08:00
|
|
|
|
|
|
|
if (unlikely(netif_queue_stopped(dev) &&
|
|
|
|
((priv->tx_head - priv->tx_tail) <= ipoib_sendq_size >> 1) &&
|
|
|
|
test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)))
|
2006-09-23 06:22:52 +08:00
|
|
|
netif_wake_queue(dev);
|
|
|
|
|
|
|
|
if (wc->status != IB_WC_SUCCESS &&
|
2015-04-02 18:39:02 +08:00
|
|
|
wc->status != IB_WC_WR_FLUSH_ERR) {
|
|
|
|
struct ipoib_qp_state_validate *qp_work;
|
2017-09-28 02:26:08 +08:00
|
|
|
ipoib_warn(priv,
|
|
|
|
"failed send event (status=%d, wrid=%d vend_err %#x)\n",
|
2006-09-23 06:22:52 +08:00
|
|
|
wc->status, wr_id, wc->vendor_err);
|
2015-04-02 18:39:02 +08:00
|
|
|
qp_work = kzalloc(sizeof(*qp_work), GFP_ATOMIC);
|
2016-11-03 22:44:25 +08:00
|
|
|
if (!qp_work)
|
2015-04-02 18:39:02 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
INIT_WORK(&qp_work->work, ipoib_qp_state_validate_work);
|
|
|
|
qp_work->priv = priv;
|
|
|
|
queue_work(priv->wq, &qp_work->work);
|
|
|
|
}
|
2006-09-23 06:22:52 +08:00
|
|
|
}
|
|
|
|
|
2008-04-30 04:46:53 +08:00
|
|
|
static int poll_tx(struct ipoib_dev_priv *priv)
|
|
|
|
{
|
|
|
|
int n, i;
|
2017-10-19 12:56:43 +08:00
|
|
|
struct ib_wc *wc;
|
2008-04-30 04:46:53 +08:00
|
|
|
|
|
|
|
n = ib_poll_cq(priv->send_cq, MAX_SEND_CQE, priv->send_wc);
|
2017-10-19 12:56:43 +08:00
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
wc = priv->send_wc + i;
|
|
|
|
if (wc->wr_id & IPOIB_OP_CM)
|
|
|
|
ipoib_cm_handle_tx_wc(priv->dev, priv->send_wc + i);
|
|
|
|
else
|
|
|
|
ipoib_ib_handle_tx_wc(priv->dev, priv->send_wc + i);
|
|
|
|
}
|
2008-04-30 04:46:53 +08:00
|
|
|
return n == MAX_SEND_CQE;
|
|
|
|
}
|
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
int ipoib_rx_poll(struct napi_struct *napi, int budget)
|
2006-09-23 06:22:52 +08:00
|
|
|
{
|
2017-10-19 12:56:43 +08:00
|
|
|
struct ipoib_dev_priv *priv =
|
|
|
|
container_of(napi, struct ipoib_dev_priv, recv_napi);
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
struct net_device *dev = priv->dev;
|
2007-05-07 12:05:32 +08:00
|
|
|
int done;
|
|
|
|
int t;
|
|
|
|
int n, i;
|
|
|
|
|
|
|
|
done = 0;
|
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
poll_more:
|
|
|
|
while (done < budget) {
|
|
|
|
int max = (budget - done);
|
|
|
|
|
2007-05-07 12:05:32 +08:00
|
|
|
t = min(IPOIB_NUM_WC, max);
|
2008-04-30 04:46:53 +08:00
|
|
|
n = ib_poll_cq(priv->recv_cq, t, priv->ibwc);
|
2007-05-07 12:05:32 +08:00
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
for (i = 0; i < n; i++) {
|
2007-05-07 12:05:32 +08:00
|
|
|
struct ib_wc *wc = priv->ibwc + i;
|
|
|
|
|
2007-08-16 20:36:16 +08:00
|
|
|
if (wc->wr_id & IPOIB_OP_RECV) {
|
2007-05-07 12:05:32 +08:00
|
|
|
++done;
|
2007-08-16 20:36:16 +08:00
|
|
|
if (wc->wr_id & IPOIB_OP_CM)
|
|
|
|
ipoib_cm_handle_rx_wc(dev, wc);
|
|
|
|
else
|
|
|
|
ipoib_ib_handle_rx_wc(dev, wc);
|
2017-10-19 12:56:43 +08:00
|
|
|
} else {
|
|
|
|
pr_warn("%s: Got unexpected wqe id\n", __func__);
|
|
|
|
}
|
2007-05-07 12:05:32 +08:00
|
|
|
}
|
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
if (n != t)
|
2007-05-07 12:05:32 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
if (done < budget) {
|
2009-01-20 08:43:59 +08:00
|
|
|
napi_complete(napi);
|
2008-04-30 04:46:53 +08:00
|
|
|
if (unlikely(ib_req_notify_cq(priv->recv_cq,
|
2007-05-07 12:05:32 +08:00
|
|
|
IB_CQ_NEXT_COMP |
|
|
|
|
IB_CQ_REPORT_MISSED_EVENTS)) &&
|
2009-01-20 08:43:59 +08:00
|
|
|
napi_reschedule(napi))
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
goto poll_more;
|
2007-05-07 12:05:32 +08:00
|
|
|
}
|
|
|
|
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
return done;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
int ipoib_tx_poll(struct napi_struct *napi, int budget)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-10-19 12:56:43 +08:00
|
|
|
struct ipoib_dev_priv *priv = container_of(napi, struct ipoib_dev_priv,
|
|
|
|
send_napi);
|
|
|
|
struct net_device *dev = priv->dev;
|
|
|
|
int n, i;
|
|
|
|
struct ib_wc *wc;
|
[NET]: Make NAPI polling independent of struct net_device objects.
Several devices have multiple independant RX queues per net
device, and some have a single interrupt doorbell for several
queues.
In either case, it's easier to support layouts like that if the
structure representing the poll is independant from the net
device itself.
The signature of the ->poll() call back goes from:
int foo_poll(struct net_device *dev, int *budget)
to
int foo_poll(struct napi_struct *napi, int budget)
The caller is returned the number of RX packets processed (or
the number of "NAPI credits" consumed if you want to get
abstract). The callee no longer messes around bumping
dev->quota, *budget, etc. because that is all handled in the
caller upon return.
The napi_struct is to be embedded in the device driver private data
structures.
Furthermore, it is the driver's responsibility to disable all NAPI
instances in it's ->stop() device close handler. Since the
napi_struct is privatized into the driver's private data structures,
only the driver knows how to get at all of the napi_struct instances
it may have per-device.
With lots of help and suggestions from Rusty Russell, Roland Dreier,
Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
[ Ported to current tree and all drivers converted. Integrated
Stephen's follow-on kerneldoc additions, and restored poll_list
handling to the old style to fix mutual exclusion issues. -DaveM ]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-10-04 07:41:36 +08:00
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
poll_more:
|
|
|
|
n = ib_poll_cq(priv->send_cq, MAX_SEND_CQE, priv->send_wc);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
wc = priv->send_wc + i;
|
|
|
|
if (wc->wr_id & IPOIB_OP_CM)
|
|
|
|
ipoib_cm_handle_tx_wc(dev, wc);
|
|
|
|
else
|
|
|
|
ipoib_ib_handle_tx_wc(dev, wc);
|
|
|
|
}
|
2008-05-01 11:02:45 +08:00
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
if (n < budget) {
|
|
|
|
napi_complete(napi);
|
|
|
|
if (unlikely(ib_req_notify_cq(priv->send_cq, IB_CQ_NEXT_COMP |
|
|
|
|
IB_CQ_REPORT_MISSED_EVENTS)) &&
|
|
|
|
napi_reschedule(napi))
|
|
|
|
goto poll_more;
|
|
|
|
}
|
|
|
|
return n < 0 ? 0 : n;
|
|
|
|
}
|
2008-05-01 11:02:45 +08:00
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
void ipoib_ib_rx_completion(struct ib_cq *cq, void *ctx_ptr)
|
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv = ctx_ptr;
|
2008-05-01 11:02:45 +08:00
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
napi_schedule(&priv->recv_napi);
|
2008-05-01 11:02:45 +08:00
|
|
|
}
|
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
void ipoib_ib_tx_completion(struct ib_cq *cq, void *ctx_ptr)
|
2008-05-01 11:02:45 +08:00
|
|
|
{
|
2017-10-19 12:56:43 +08:00
|
|
|
struct ipoib_dev_priv *priv = ctx_ptr;
|
2008-10-01 01:36:21 +08:00
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
napi_schedule(&priv->send_napi);
|
2008-05-01 11:02:45 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline int post_send(struct ipoib_dev_priv *priv,
|
|
|
|
unsigned int wr_id,
|
2017-04-10 16:22:28 +08:00
|
|
|
struct ib_ah *address, u32 dqpn,
|
2008-04-17 12:09:27 +08:00
|
|
|
struct ipoib_tx_buf *tx_req,
|
|
|
|
void *head, int hlen)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-04-17 12:09:27 +08:00
|
|
|
struct sk_buff *skb = tx_req->skb;
|
|
|
|
|
2015-07-12 16:24:09 +08:00
|
|
|
ipoib_build_sge(priv, tx_req);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-10-08 16:16:33 +08:00
|
|
|
priv->tx_wr.wr.wr_id = wr_id;
|
2017-04-10 16:22:28 +08:00
|
|
|
priv->tx_wr.remote_qpn = dqpn;
|
2015-10-08 16:16:33 +08:00
|
|
|
priv->tx_wr.ah = address;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-17 12:09:27 +08:00
|
|
|
if (head) {
|
2015-10-08 16:16:33 +08:00
|
|
|
priv->tx_wr.mss = skb_shinfo(skb)->gso_size;
|
|
|
|
priv->tx_wr.header = head;
|
|
|
|
priv->tx_wr.hlen = hlen;
|
|
|
|
priv->tx_wr.wr.opcode = IB_WR_LSO;
|
2008-04-17 12:09:27 +08:00
|
|
|
} else
|
2015-10-08 16:16:33 +08:00
|
|
|
priv->tx_wr.wr.opcode = IB_WR_SEND;
|
2008-04-17 12:09:27 +08:00
|
|
|
|
2018-07-19 00:25:18 +08:00
|
|
|
return ib_post_send(priv->qp, &priv->tx_wr.wr, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
int ipoib_send(struct net_device *dev, struct sk_buff *skb,
|
|
|
|
struct ib_ah *address, u32 dqpn)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-10-29 06:30:34 +08:00
|
|
|
struct ipoib_tx_buf *tx_req;
|
2010-03-04 21:17:37 +08:00
|
|
|
int hlen, rc;
|
2008-04-17 12:09:27 +08:00
|
|
|
void *phead;
|
2018-07-05 05:52:48 +08:00
|
|
|
unsigned int usable_sge = priv->max_send_sge - !!skb_headlen(skb);
|
2008-04-17 12:09:27 +08:00
|
|
|
|
|
|
|
if (skb_is_gso(skb)) {
|
|
|
|
hlen = skb_transport_offset(skb) + tcp_hdrlen(skb);
|
|
|
|
phead = skb->data;
|
|
|
|
if (unlikely(!skb_pull(skb, hlen))) {
|
|
|
|
ipoib_warn(priv, "linear data too small\n");
|
|
|
|
++dev->stats.tx_dropped;
|
|
|
|
++dev->stats.tx_errors;
|
|
|
|
dev_kfree_skb_any(skb);
|
2017-04-10 16:22:30 +08:00
|
|
|
return -1;
|
2008-04-17 12:09:27 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (unlikely(skb->len > priv->mcast_mtu + IPOIB_ENCAP_LEN)) {
|
|
|
|
ipoib_warn(priv, "packet len %d (> %d) too long to send, dropping\n",
|
|
|
|
skb->len, priv->mcast_mtu + IPOIB_ENCAP_LEN);
|
|
|
|
++dev->stats.tx_dropped;
|
|
|
|
++dev->stats.tx_errors;
|
|
|
|
ipoib_cm_skb_too_long(dev, skb, priv->mcast_mtu);
|
2017-04-10 16:22:30 +08:00
|
|
|
return -1;
|
2008-04-17 12:09:27 +08:00
|
|
|
}
|
|
|
|
phead = NULL;
|
|
|
|
hlen = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2016-03-02 20:44:28 +08:00
|
|
|
if (skb_shinfo(skb)->nr_frags > usable_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);
|
2017-04-10 16:22:30 +08:00
|
|
|
return -1;
|
2016-03-02 20:44:28 +08:00
|
|
|
}
|
|
|
|
/* Does skb_linearize return ok without reducing nr_frags? */
|
|
|
|
if (skb_shinfo(skb)->nr_frags > usable_sge) {
|
|
|
|
ipoib_warn(priv, "too many frags after skb linearize\n");
|
|
|
|
++dev->stats.tx_dropped;
|
|
|
|
++dev->stats.tx_errors;
|
|
|
|
dev_kfree_skb_any(skb);
|
2017-04-10 16:22:30 +08:00
|
|
|
return -1;
|
2016-03-02 20:44:28 +08:00
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-04-10 16:22:28 +08:00
|
|
|
ipoib_dbg_data(priv,
|
|
|
|
"sending packet, length=%d address=%p dqpn=0x%06x\n",
|
|
|
|
skb->len, address, dqpn);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We put the skb into the tx_ring _before_ we call post_send()
|
|
|
|
* because it's entirely possible that the completion handler will
|
|
|
|
* run before we execute anything after the post_send(). That
|
|
|
|
* means we have to make sure everything is properly recorded and
|
|
|
|
* our state is consistent before we call post_send().
|
|
|
|
*/
|
2006-04-11 00:43:58 +08:00
|
|
|
tx_req = &priv->tx_ring[priv->tx_head & (ipoib_sendq_size - 1)];
|
2005-04-17 06:20:36 +08:00
|
|
|
tx_req->skb = skb;
|
2008-01-31 00:30:53 +08:00
|
|
|
if (unlikely(ipoib_dma_map_tx(priv->ca, tx_req))) {
|
2007-09-29 06:33:51 +08:00
|
|
|
++dev->stats.tx_errors;
|
2006-10-11 03:50:38 +08:00
|
|
|
dev_kfree_skb_any(skb);
|
2017-04-10 16:22:30 +08:00
|
|
|
return -1;
|
2006-10-11 03:50:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-17 12:01:10 +08:00
|
|
|
if (skb->ip_summed == CHECKSUM_PARTIAL)
|
2015-10-08 16:16:33 +08:00
|
|
|
priv->tx_wr.wr.send_flags |= IB_SEND_IP_CSUM;
|
2008-04-17 12:01:10 +08:00
|
|
|
else
|
2015-10-08 16:16:33 +08:00
|
|
|
priv->tx_wr.wr.send_flags &= ~IB_SEND_IP_CSUM;
|
2017-10-19 12:56:42 +08:00
|
|
|
/* increase the tx_head after send success, but use it for queue state */
|
|
|
|
if (priv->tx_head - priv->tx_tail == ipoib_sendq_size - 1) {
|
2008-05-01 11:02:45 +08:00
|
|
|
ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n");
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
}
|
|
|
|
|
2013-02-04 23:29:10 +08:00
|
|
|
skb_orphan(skb);
|
|
|
|
skb_dst_drop(skb);
|
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
if (netif_queue_stopped(dev))
|
|
|
|
if (ib_req_notify_cq(priv->send_cq, IB_CQ_NEXT_COMP |
|
2018-01-03 20:39:50 +08:00
|
|
|
IB_CQ_REPORT_MISSED_EVENTS) < 0)
|
2017-10-19 12:56:43 +08:00
|
|
|
ipoib_warn(priv, "request notify on send CQ failed\n");
|
|
|
|
|
2010-03-04 21:17:37 +08:00
|
|
|
rc = post_send(priv, priv->tx_head & (ipoib_sendq_size - 1),
|
2017-04-10 16:22:30 +08:00
|
|
|
address, dqpn, tx_req, phead, hlen);
|
2010-03-04 21:17:37 +08:00
|
|
|
if (unlikely(rc)) {
|
|
|
|
ipoib_warn(priv, "post_send failed, error %d\n", rc);
|
2007-09-29 06:33:51 +08:00
|
|
|
++dev->stats.tx_errors;
|
2015-07-12 16:24:09 +08:00
|
|
|
ipoib_dma_unmap_tx(priv, tx_req);
|
2005-04-17 06:20:36 +08:00
|
|
|
dev_kfree_skb_any(skb);
|
2008-05-01 11:02:45 +08:00
|
|
|
if (netif_queue_stopped(dev))
|
|
|
|
netif_wake_queue(dev);
|
2017-04-10 16:22:30 +08:00
|
|
|
rc = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2016-05-03 22:33:13 +08:00
|
|
|
netif_trans_update(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
rc = priv->tx_head;
|
2005-04-17 06:20:36 +08:00
|
|
|
++priv->tx_head;
|
|
|
|
}
|
2017-04-10 16:22:30 +08:00
|
|
|
return rc;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __ipoib_reap_ah(struct net_device *dev)
|
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
struct ipoib_ah *ah, *tah;
|
2008-10-01 01:36:21 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
netif_tx_lock_bh(dev);
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
list_for_each_entry_safe(ah, tah, &priv->dead_ahs, list)
|
2005-07-28 05:41:32 +08:00
|
|
|
if ((int) priv->tx_tail - (int) ah->last_send >= 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
list_del(&ah->list);
|
2018-12-12 17:09:06 +08:00
|
|
|
rdma_destroy_ah(ah->ah, 0);
|
2006-06-18 11:37:34 +08:00
|
|
|
kfree(ah);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2008-10-01 01:36:21 +08:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
netif_tx_unlock_bh(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-11-22 22:57:56 +08:00
|
|
|
void ipoib_reap_ah(struct work_struct *work)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-11-22 22:57:56 +08:00
|
|
|
struct ipoib_dev_priv *priv =
|
|
|
|
container_of(work, struct ipoib_dev_priv, ah_reap_task.work);
|
|
|
|
struct net_device *dev = priv->dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
__ipoib_reap_ah(dev);
|
|
|
|
|
|
|
|
if (!test_bit(IPOIB_STOP_REAPER, &priv->flags))
|
IB/ipoib: Use dedicated workqueues per interface
During my recent work on the rtnl lock deadlock in the IPoIB driver, I
saw that even once I fixed the apparent races for a single device, as
soon as that device had any children, new races popped up. It turns
out that this is because no matter how well we protect against races
on a single device, the fact that all devices use the same workqueue,
and flush_workqueue() flushes *everything* from that workqueue means
that we would also have to prevent all races between different devices
(for instance, ipoib_mcast_restart_task on interface ib0 can race with
ipoib_mcast_flush_dev on interface ib0.8002, resulting in a deadlock on
the rtnl_lock).
There are several possible solutions to this problem:
Make carrier_on_task and mcast_restart_task try to take the rtnl for
some set period of time and if they fail, then bail. This runs the
real risk of dropping work on the floor, which can end up being its
own separate kind of deadlock.
Set some global flag in the driver that says some device is in the
middle of going down, letting all tasks know to bail. Again, this can
drop work on the floor.
Or the method this patch attempts to use, which is when we bring an
interface up, create a workqueue specifically for that interface, so
that when we take it back down, we are flushing only those tasks
associated with our interface. In addition, keep the global
workqueue, but now limit it to only flush tasks. In this way, the
flush tasks can always flush the device specific work queues without
having deadlock issues.
Signed-off-by: Doug Ledford <dledford@redhat.com>
2015-02-22 08:27:03 +08:00
|
|
|
queue_delayed_work(priv->wq, &priv->ah_reap_task,
|
2007-10-15 13:50:56 +08:00
|
|
|
round_jiffies_relative(HZ));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2015-02-22 08:27:04 +08:00
|
|
|
static void ipoib_flush_ah(struct net_device *dev)
|
2015-02-22 08:26:59 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2015-02-22 08:26:59 +08:00
|
|
|
|
|
|
|
cancel_delayed_work(&priv->ah_reap_task);
|
2015-02-22 08:27:04 +08:00
|
|
|
flush_workqueue(priv->wq);
|
2015-02-22 08:26:59 +08:00
|
|
|
ipoib_reap_ah(&priv->ah_reap_task.work);
|
|
|
|
}
|
|
|
|
|
2015-02-22 08:27:04 +08:00
|
|
|
static void ipoib_stop_ah(struct net_device *dev)
|
2015-02-22 08:26:59 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2015-02-22 08:26:59 +08:00
|
|
|
|
|
|
|
set_bit(IPOIB_STOP_REAPER, &priv->flags);
|
2015-02-22 08:27:04 +08:00
|
|
|
ipoib_flush_ah(dev);
|
2015-02-22 08:26:59 +08:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:22:27 +08:00
|
|
|
static int recvs_pending(struct net_device *dev)
|
2008-05-01 11:02:45 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2017-04-10 16:22:27 +08:00
|
|
|
int pending = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ipoib_recvq_size; ++i)
|
|
|
|
if (priv->rx_ring[i].skb)
|
|
|
|
++pending;
|
|
|
|
|
|
|
|
return pending;
|
2008-05-01 11:02:45 +08:00
|
|
|
}
|
|
|
|
|
2017-07-13 19:29:08 +08:00
|
|
|
static void check_qp_movement_and_print(struct ipoib_dev_priv *priv,
|
|
|
|
struct ib_qp *qp,
|
|
|
|
enum ib_qp_state new_state)
|
|
|
|
{
|
|
|
|
struct ib_qp_attr qp_attr;
|
|
|
|
struct ib_qp_init_attr query_init_attr;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ib_query_qp(qp, &qp_attr, IB_QP_STATE, &query_init_attr);
|
|
|
|
if (ret) {
|
|
|
|
ipoib_warn(priv, "%s: Failed to query QP\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* print according to the new-state and the previous state.*/
|
|
|
|
if (new_state == IB_QPS_ERR && qp_attr.qp_state == IB_QPS_RESET)
|
|
|
|
ipoib_dbg(priv, "Failed modify QP, IB_QPS_RESET to IB_QPS_ERR, acceptable\n");
|
|
|
|
else
|
|
|
|
ipoib_warn(priv, "Failed to modify QP to state: %d from state: %d\n",
|
|
|
|
new_state, qp_attr.qp_state);
|
|
|
|
}
|
|
|
|
|
2017-10-19 12:56:43 +08:00
|
|
|
static void ipoib_napi_enable(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
|
|
|
|
|
|
|
napi_enable(&priv->recv_napi);
|
|
|
|
napi_enable(&priv->send_napi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ipoib_napi_disable(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
|
|
|
|
|
|
|
napi_disable(&priv->recv_napi);
|
|
|
|
napi_disable(&priv->send_napi);
|
|
|
|
}
|
|
|
|
|
2017-04-10 16:22:27 +08:00
|
|
|
int ipoib_ib_dev_stop_default(struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2017-04-10 16:22:27 +08:00
|
|
|
struct ib_qp_attr qp_attr;
|
|
|
|
unsigned long begin;
|
|
|
|
struct ipoib_tx_buf *tx_req;
|
|
|
|
int i;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
|
2017-10-19 12:56:43 +08:00
|
|
|
ipoib_napi_disable(dev);
|
2014-08-07 02:40:32 +08:00
|
|
|
|
2017-04-10 16:22:27 +08:00
|
|
|
ipoib_cm_dev_stop(dev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move our QP to the error state and then reinitialize in
|
|
|
|
* when all work requests have completed or have been flushed.
|
|
|
|
*/
|
|
|
|
qp_attr.qp_state = IB_QPS_ERR;
|
|
|
|
if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE))
|
2017-07-13 19:29:08 +08:00
|
|
|
check_qp_movement_and_print(priv, priv->qp, IB_QPS_ERR);
|
2017-04-10 16:22:27 +08:00
|
|
|
|
|
|
|
/* Wait for all sends and receives to complete */
|
|
|
|
begin = jiffies;
|
|
|
|
|
|
|
|
while (priv->tx_head != priv->tx_tail || recvs_pending(dev)) {
|
|
|
|
if (time_after(jiffies, begin + 5 * HZ)) {
|
|
|
|
ipoib_warn(priv,
|
|
|
|
"timing out; %d sends %d receives not completed\n",
|
|
|
|
priv->tx_head - priv->tx_tail,
|
|
|
|
recvs_pending(dev));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* assume the HW is wedged and just free up
|
|
|
|
* all our pending work requests.
|
|
|
|
*/
|
|
|
|
while ((int)priv->tx_tail - (int)priv->tx_head < 0) {
|
|
|
|
tx_req = &priv->tx_ring[priv->tx_tail &
|
|
|
|
(ipoib_sendq_size - 1)];
|
|
|
|
ipoib_dma_unmap_tx(priv, tx_req);
|
|
|
|
dev_kfree_skb_any(tx_req->skb);
|
|
|
|
++priv->tx_tail;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ipoib_recvq_size; ++i) {
|
|
|
|
struct ipoib_rx_buf *rx_req;
|
|
|
|
|
|
|
|
rx_req = &priv->rx_ring[i];
|
|
|
|
if (!rx_req->skb)
|
|
|
|
continue;
|
|
|
|
ipoib_ud_dma_unmap_rx(priv,
|
|
|
|
priv->rx_ring[i].mapping);
|
|
|
|
dev_kfree_skb_any(rx_req->skb);
|
|
|
|
rx_req->skb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipoib_drain_cq(dev);
|
|
|
|
|
2017-05-23 16:29:42 +08:00
|
|
|
usleep_range(1000, 2000);
|
2007-05-19 23:51:54 +08:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:22:27 +08:00
|
|
|
ipoib_dbg(priv, "All sends and receives done.\n");
|
|
|
|
|
|
|
|
timeout:
|
|
|
|
qp_attr.qp_state = IB_QPS_RESET;
|
|
|
|
if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE))
|
|
|
|
ipoib_warn(priv, "Failed to modify QP to RESET state\n");
|
|
|
|
|
|
|
|
ib_req_notify_cq(priv->recv_cq, IB_CQ_NEXT_COMP);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ipoib_ib_dev_stop(struct net_device *dev)
|
|
|
|
{
|
2017-04-10 16:22:30 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
|
|
|
|
|
|
|
priv->rn_ops->ndo_stop(dev);
|
2017-04-10 16:22:27 +08:00
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
clear_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
|
2017-04-10 16:22:27 +08:00
|
|
|
ipoib_flush_ah(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ipoib_ib_dev_open_default(struct net_device *dev)
|
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2017-04-10 16:22:27 +08:00
|
|
|
int ret;
|
|
|
|
|
2005-10-12 02:08:24 +08:00
|
|
|
ret = ipoib_init_qp(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ret) {
|
2005-10-12 02:08:24 +08:00
|
|
|
ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret);
|
2005-04-17 06:20:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ipoib_ib_post_receives(dev);
|
|
|
|
if (ret) {
|
|
|
|
ipoib_warn(priv, "ipoib_ib_post_receives returned %d\n", ret);
|
2017-04-10 16:22:30 +08:00
|
|
|
goto out;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-06 04:12:23 +08:00
|
|
|
ret = ipoib_cm_dev_open(dev);
|
|
|
|
if (ret) {
|
2007-05-18 21:12:54 +08:00
|
|
|
ipoib_warn(priv, "ipoib_cm_dev_open returned %d\n", ret);
|
2017-04-10 16:22:30 +08:00
|
|
|
goto out;
|
2007-02-06 04:12:23 +08:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
|
2017-10-19 12:56:43 +08:00
|
|
|
ipoib_napi_enable(dev);
|
2006-03-24 01:52:51 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
2017-04-10 16:22:30 +08:00
|
|
|
out:
|
2013-10-16 22:37:47 +08:00
|
|
|
return -1;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:22:27 +08:00
|
|
|
int ipoib_ib_dev_open(struct net_device *dev)
|
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2017-04-10 16:22:27 +08:00
|
|
|
|
|
|
|
ipoib_pkey_dev_check_presence(dev);
|
|
|
|
|
|
|
|
if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
|
|
|
|
ipoib_warn(priv, "P_Key 0x%04x is %s\n", priv->pkey,
|
|
|
|
(!(priv->pkey & 0x7fff) ? "Invalid" : "not found"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_bit(IPOIB_STOP_REAPER, &priv->flags);
|
|
|
|
queue_delayed_work(priv->wq, &priv->ah_reap_task,
|
|
|
|
round_jiffies_relative(HZ));
|
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
if (priv->rn_ops->ndo_open(dev)) {
|
2017-04-10 16:22:27 +08:00
|
|
|
pr_warn("%s: Failed to open dev\n", dev->name);
|
2017-04-10 16:22:30 +08:00
|
|
|
goto dev_stop;
|
2017-04-10 16:22:27 +08:00
|
|
|
}
|
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
|
|
|
|
|
2017-04-10 16:22:27 +08:00
|
|
|
return 0;
|
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
dev_stop:
|
2017-04-10 16:22:27 +08:00
|
|
|
set_bit(IPOIB_STOP_REAPER, &priv->flags);
|
|
|
|
cancel_delayed_work(&priv->ah_reap_task);
|
2017-04-10 16:22:30 +08:00
|
|
|
set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
|
|
|
|
ipoib_ib_dev_stop(dev);
|
2017-04-10 16:22:27 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-07-08 17:45:11 +08:00
|
|
|
void ipoib_pkey_dev_check_presence(struct net_device *dev)
|
2006-03-24 01:52:51 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2017-06-15 03:18:48 +08:00
|
|
|
struct rdma_netdev *rn = netdev_priv(dev);
|
2006-03-24 01:52:51 +08:00
|
|
|
|
2014-08-07 02:40:32 +08:00
|
|
|
if (!(priv->pkey & 0x7fff) ||
|
|
|
|
ib_find_pkey(priv->ca, priv->port, priv->pkey,
|
2017-06-15 03:18:48 +08:00
|
|
|
&priv->pkey_index)) {
|
2006-03-24 01:52:51 +08:00
|
|
|
clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
|
2017-06-15 03:18:48 +08:00
|
|
|
} else {
|
|
|
|
if (rn->set_id)
|
|
|
|
rn->set_id(dev, priv->pkey_index);
|
2006-03-24 01:52:51 +08:00
|
|
|
set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
|
2017-06-15 03:18:48 +08:00
|
|
|
}
|
2006-03-24 01:52:51 +08:00
|
|
|
}
|
|
|
|
|
2017-01-19 12:16:06 +08:00
|
|
|
void ipoib_ib_dev_up(struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-24 01:52:51 +08:00
|
|
|
ipoib_pkey_dev_check_presence(dev);
|
|
|
|
|
|
|
|
if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags)) {
|
|
|
|
ipoib_dbg(priv, "PKEY is not assigned.\n");
|
2017-01-19 12:16:06 +08:00
|
|
|
return;
|
2006-03-24 01:52:51 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
set_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
|
|
|
|
|
2017-01-19 12:16:06 +08:00
|
|
|
ipoib_mcast_start_thread(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2017-01-12 15:39:01 +08:00
|
|
|
void ipoib_ib_dev_down(struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ipoib_dbg(priv, "downing ib_dev\n");
|
|
|
|
|
|
|
|
clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
|
|
|
|
netif_carrier_off(dev);
|
|
|
|
|
2015-02-22 08:27:04 +08:00
|
|
|
ipoib_mcast_stop_thread(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
ipoib_mcast_dev_flush(dev);
|
|
|
|
|
|
|
|
ipoib_flush_paths(dev);
|
|
|
|
}
|
|
|
|
|
2007-05-24 23:32:46 +08:00
|
|
|
void ipoib_drain_cq(struct net_device *dev)
|
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2007-05-24 23:32:46 +08:00
|
|
|
int i, n;
|
2008-10-01 01:36:21 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We call completion handling routines that expect to be
|
|
|
|
* called from the BH-disabled NAPI poll context, so disable
|
|
|
|
* BHs here too.
|
|
|
|
*/
|
|
|
|
local_bh_disable();
|
|
|
|
|
2007-05-24 23:32:46 +08:00
|
|
|
do {
|
2008-04-30 04:46:53 +08:00
|
|
|
n = ib_poll_cq(priv->recv_cq, IPOIB_NUM_WC, priv->ibwc);
|
2007-05-24 23:32:46 +08:00
|
|
|
for (i = 0; i < n; ++i) {
|
2007-10-10 10:59:04 +08:00
|
|
|
/*
|
|
|
|
* Convert any successful completions to flush
|
|
|
|
* errors to avoid passing packets up the
|
|
|
|
* stack after bringing the device down.
|
|
|
|
*/
|
|
|
|
if (priv->ibwc[i].status == IB_WC_SUCCESS)
|
|
|
|
priv->ibwc[i].status = IB_WC_WR_FLUSH_ERR;
|
|
|
|
|
2007-08-16 20:36:16 +08:00
|
|
|
if (priv->ibwc[i].wr_id & IPOIB_OP_RECV) {
|
|
|
|
if (priv->ibwc[i].wr_id & IPOIB_OP_CM)
|
|
|
|
ipoib_cm_handle_rx_wc(dev, priv->ibwc + i);
|
|
|
|
else
|
|
|
|
ipoib_ib_handle_rx_wc(dev, priv->ibwc + i);
|
2017-10-19 12:56:43 +08:00
|
|
|
} else {
|
|
|
|
pr_warn("%s: Got unexpected wqe id\n", __func__);
|
|
|
|
}
|
2007-05-24 23:32:46 +08:00
|
|
|
}
|
|
|
|
} while (n == IPOIB_NUM_WC);
|
2008-04-30 04:46:53 +08:00
|
|
|
|
|
|
|
while (poll_tx(priv))
|
|
|
|
; /* nothing */
|
2008-10-01 01:36:21 +08:00
|
|
|
|
|
|
|
local_bh_enable();
|
2007-05-24 23:32:46 +08:00
|
|
|
}
|
|
|
|
|
IPoIB: Fix pkey change flow for virtualization environments
IPoIB's required behaviour w.r.t to the pkey used by the device is the following:
- For "parent" interfaces (e.g ib0, ib1, etc) who are created
automatically as a result of hot-plug events from the IB core, the
driver needs to take whatever pkey vlaue it finds in index 0, and
stick to that index.
- For child interfaces (e.g ib0.8001, etc) created by admin directive,
the driver needs to use and stick to the value provided during its
creation.
In SR-IOV environment its possible for the VF probe to take place
before the cloud management software provisions the suitable pkey for
the VF in the paravirtualed PKEY table index 0. When this is the case,
the VF IB stack will find in index 0 an invalide pkey, which is all
zeros.
Moreover, the cloud managment can assign the pkey value at index 0 at
any time of the guest life cycle.
The correct behavior for IPoIB to address these requirements for
parent interfaces is to use PKEY_CHANGE event as trigger to optionally
re-init the device pkey value and re-create all the relevant resources
accordingly, if the value of the pkey in index 0 has changed (from
invalid to valid or from valid value X to invalid value Y).
This patch enhances the heavy flushing code which is triggered by pkey
change event, to behave correctly for parent devices. For child
devices, the code remains the same, namely chases pkey value and not
index.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2013-07-18 19:02:32 +08:00
|
|
|
/*
|
|
|
|
* Takes whatever value which is in pkey index 0 and updates priv->pkey
|
|
|
|
* returns 0 if the pkey value was changed.
|
|
|
|
*/
|
|
|
|
static inline int update_parent_pkey(struct ipoib_dev_priv *priv)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
u16 prev_pkey;
|
|
|
|
|
|
|
|
prev_pkey = priv->pkey;
|
|
|
|
result = ib_query_pkey(priv->ca, priv->port, 0, &priv->pkey);
|
|
|
|
if (result) {
|
|
|
|
ipoib_warn(priv, "ib_query_pkey port %d failed (ret = %d)\n",
|
|
|
|
priv->port, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->pkey |= 0x8000;
|
|
|
|
|
|
|
|
if (prev_pkey != priv->pkey) {
|
|
|
|
ipoib_dbg(priv, "pkey changed from 0x%x to 0x%x\n",
|
|
|
|
prev_pkey, priv->pkey);
|
|
|
|
/*
|
|
|
|
* Update the pkey in the broadcast address, while making sure to set
|
|
|
|
* the full membership bit, so that we join the right broadcast group.
|
|
|
|
*/
|
|
|
|
priv->dev->broadcast[8] = priv->pkey >> 8;
|
|
|
|
priv->dev->broadcast[9] = priv->pkey & 0xff;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2014-08-07 02:40:32 +08:00
|
|
|
/*
|
|
|
|
* returns 0 if pkey value was found in a different slot.
|
|
|
|
*/
|
|
|
|
static inline int update_child_pkey(struct ipoib_dev_priv *priv)
|
|
|
|
{
|
|
|
|
u16 old_index = priv->pkey_index;
|
|
|
|
|
|
|
|
priv->pkey_index = 0;
|
|
|
|
ipoib_pkey_dev_check_presence(priv->dev);
|
|
|
|
|
|
|
|
if (test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags) &&
|
|
|
|
(old_index == priv->pkey_index))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
IPoIB: Fix pkey change flow for virtualization environments
IPoIB's required behaviour w.r.t to the pkey used by the device is the following:
- For "parent" interfaces (e.g ib0, ib1, etc) who are created
automatically as a result of hot-plug events from the IB core, the
driver needs to take whatever pkey vlaue it finds in index 0, and
stick to that index.
- For child interfaces (e.g ib0.8001, etc) created by admin directive,
the driver needs to use and stick to the value provided during its
creation.
In SR-IOV environment its possible for the VF probe to take place
before the cloud management software provisions the suitable pkey for
the VF in the paravirtualed PKEY table index 0. When this is the case,
the VF IB stack will find in index 0 an invalide pkey, which is all
zeros.
Moreover, the cloud managment can assign the pkey value at index 0 at
any time of the guest life cycle.
The correct behavior for IPoIB to address these requirements for
parent interfaces is to use PKEY_CHANGE event as trigger to optionally
re-init the device pkey value and re-create all the relevant resources
accordingly, if the value of the pkey in index 0 has changed (from
invalid to valid or from valid value X to invalid value Y).
This patch enhances the heavy flushing code which is triggered by pkey
change event, to behave correctly for parent devices. For child
devices, the code remains the same, namely chases pkey value and not
index.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2013-07-18 19:02:32 +08:00
|
|
|
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
/*
|
|
|
|
* returns true if the device address of the ipoib interface has changed and the
|
|
|
|
* new address is a valid one (i.e in the gid table), return false otherwise.
|
|
|
|
*/
|
|
|
|
static bool ipoib_dev_addr_changed_valid(struct ipoib_dev_priv *priv)
|
|
|
|
{
|
|
|
|
union ib_gid search_gid;
|
|
|
|
union ib_gid gid0;
|
|
|
|
union ib_gid *netdev_gid;
|
|
|
|
int err;
|
|
|
|
u16 index;
|
|
|
|
u8 port;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
netdev_gid = (union ib_gid *)(priv->dev->dev_addr + 4);
|
2018-06-05 13:40:22 +08:00
|
|
|
if (rdma_query_gid(priv->ca, priv->port, 0, &gid0))
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
return false;
|
|
|
|
|
2016-06-04 20:15:22 +08:00
|
|
|
netif_addr_lock_bh(priv->dev);
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
|
|
|
|
/* The subnet prefix may have changed, update it now so we won't have
|
|
|
|
* to do it later
|
|
|
|
*/
|
|
|
|
priv->local_gid.global.subnet_prefix = gid0.global.subnet_prefix;
|
|
|
|
netdev_gid->global.subnet_prefix = gid0.global.subnet_prefix;
|
|
|
|
search_gid.global.subnet_prefix = gid0.global.subnet_prefix;
|
|
|
|
|
|
|
|
search_gid.global.interface_id = priv->local_gid.global.interface_id;
|
|
|
|
|
2016-06-04 20:15:22 +08:00
|
|
|
netif_addr_unlock_bh(priv->dev);
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
|
2018-03-13 22:06:12 +08:00
|
|
|
err = ib_find_gid(priv->ca, &search_gid, &port, &index);
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
|
2016-06-04 20:15:22 +08:00
|
|
|
netif_addr_lock_bh(priv->dev);
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
|
|
|
|
if (search_gid.global.interface_id !=
|
|
|
|
priv->local_gid.global.interface_id)
|
|
|
|
/* There was a change while we were looking up the gid, bail
|
|
|
|
* here and let the next work sort this out
|
|
|
|
*/
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* The next section of code needs some background:
|
|
|
|
* Per IB spec the port GUID can't change if the HCA is powered on.
|
|
|
|
* port GUID is the basis for GID at index 0 which is the basis for
|
|
|
|
* the default device address of a ipoib interface.
|
|
|
|
*
|
|
|
|
* so it seems the flow should be:
|
|
|
|
* if user_changed_dev_addr && gid in gid tbl
|
|
|
|
* set bit dev_addr_set
|
|
|
|
* return true
|
|
|
|
* else
|
|
|
|
* return false
|
|
|
|
*
|
|
|
|
* The issue is that there are devices that don't follow the spec,
|
|
|
|
* they change the port GUID when the HCA is powered, so in order
|
|
|
|
* not to break userspace applications, We need to check if the
|
|
|
|
* user wanted to control the device address and we assume that
|
|
|
|
* if he sets the device address back to be based on GID index 0,
|
|
|
|
* he no longer wishs to control it.
|
|
|
|
*
|
|
|
|
* If the user doesn't control the the device address,
|
|
|
|
* IPOIB_FLAG_DEV_ADDR_SET is set and ib_find_gid failed it means
|
|
|
|
* the port GUID has changed and GID at index 0 has changed
|
|
|
|
* so we need to change priv->local_gid and priv->dev->dev_addr
|
|
|
|
* to reflect the new GID.
|
|
|
|
*/
|
|
|
|
if (!test_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags)) {
|
|
|
|
if (!err && port == priv->port) {
|
|
|
|
set_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags);
|
|
|
|
if (index == 0)
|
|
|
|
clear_bit(IPOIB_FLAG_DEV_ADDR_CTRL,
|
|
|
|
&priv->flags);
|
|
|
|
else
|
|
|
|
set_bit(IPOIB_FLAG_DEV_ADDR_CTRL, &priv->flags);
|
|
|
|
ret = true;
|
|
|
|
} else {
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!err && port == priv->port) {
|
|
|
|
ret = true;
|
|
|
|
} else {
|
|
|
|
if (!test_bit(IPOIB_FLAG_DEV_ADDR_CTRL, &priv->flags)) {
|
|
|
|
memcpy(&priv->local_gid, &gid0,
|
|
|
|
sizeof(priv->local_gid));
|
|
|
|
memcpy(priv->dev->dev_addr + 4, &gid0,
|
|
|
|
sizeof(priv->local_gid));
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2016-06-04 20:15:22 +08:00
|
|
|
netif_addr_unlock_bh(priv->dev);
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-07-15 14:48:49 +08:00
|
|
|
static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
|
2015-07-07 22:45:13 +08:00
|
|
|
enum ipoib_flush_level level,
|
|
|
|
int nesting)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-05-19 23:51:54 +08:00
|
|
|
struct ipoib_dev_priv *cpriv;
|
2006-11-22 22:57:56 +08:00
|
|
|
struct net_device *dev = priv->dev;
|
IPoIB: Fix pkey change flow for virtualization environments
IPoIB's required behaviour w.r.t to the pkey used by the device is the following:
- For "parent" interfaces (e.g ib0, ib1, etc) who are created
automatically as a result of hot-plug events from the IB core, the
driver needs to take whatever pkey vlaue it finds in index 0, and
stick to that index.
- For child interfaces (e.g ib0.8001, etc) created by admin directive,
the driver needs to use and stick to the value provided during its
creation.
In SR-IOV environment its possible for the VF probe to take place
before the cloud management software provisions the suitable pkey for
the VF in the paravirtualed PKEY table index 0. When this is the case,
the VF IB stack will find in index 0 an invalide pkey, which is all
zeros.
Moreover, the cloud managment can assign the pkey value at index 0 at
any time of the guest life cycle.
The correct behavior for IPoIB to address these requirements for
parent interfaces is to use PKEY_CHANGE event as trigger to optionally
re-init the device pkey value and re-create all the relevant resources
accordingly, if the value of the pkey in index 0 has changed (from
invalid to valid or from valid value X to invalid value Y).
This patch enhances the heavy flushing code which is triggered by pkey
change event, to behave correctly for parent devices. For child
devices, the code remains the same, namely chases pkey value and not
index.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2013-07-18 19:02:32 +08:00
|
|
|
int result;
|
2007-05-19 23:51:54 +08:00
|
|
|
|
2015-07-07 22:45:13 +08:00
|
|
|
down_read_nested(&priv->vlan_rwsem, nesting);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-19 23:51:54 +08:00
|
|
|
/*
|
|
|
|
* Flush any child interfaces too -- they might be up even if
|
|
|
|
* the parent is down.
|
|
|
|
*/
|
|
|
|
list_for_each_entry(cpriv, &priv->child_intfs, list)
|
2015-07-07 22:45:13 +08:00
|
|
|
__ipoib_ib_dev_flush(cpriv, level, nesting + 1);
|
2007-05-19 23:51:54 +08:00
|
|
|
|
2013-10-16 22:37:49 +08:00
|
|
|
up_read(&priv->vlan_rwsem);
|
2007-05-19 23:51:54 +08:00
|
|
|
|
2014-08-07 02:40:32 +08:00
|
|
|
if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) &&
|
|
|
|
level != IPOIB_FLUSH_HEAVY) {
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
/* Make sure the dev_addr is set even if not flushing */
|
|
|
|
if (level == IPOIB_FLUSH_LIGHT)
|
|
|
|
ipoib_dev_addr_changed_valid(priv);
|
2006-03-24 01:52:51 +08:00
|
|
|
ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
|
2014-08-07 02:40:32 +08:00
|
|
|
/* interface is down. update pkey and leave. */
|
|
|
|
if (level == IPOIB_FLUSH_HEAVY) {
|
|
|
|
if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags))
|
|
|
|
update_parent_pkey(priv);
|
|
|
|
else
|
|
|
|
update_child_pkey(priv);
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
} else if (level == IPOIB_FLUSH_LIGHT)
|
|
|
|
ipoib_dev_addr_changed_valid(priv);
|
2006-03-24 01:52:51 +08:00
|
|
|
ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_ADMIN_UP not set.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
2006-03-24 01:52:51 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-15 14:48:49 +08:00
|
|
|
if (level == IPOIB_FLUSH_HEAVY) {
|
IPoIB: Fix pkey change flow for virtualization environments
IPoIB's required behaviour w.r.t to the pkey used by the device is the following:
- For "parent" interfaces (e.g ib0, ib1, etc) who are created
automatically as a result of hot-plug events from the IB core, the
driver needs to take whatever pkey vlaue it finds in index 0, and
stick to that index.
- For child interfaces (e.g ib0.8001, etc) created by admin directive,
the driver needs to use and stick to the value provided during its
creation.
In SR-IOV environment its possible for the VF probe to take place
before the cloud management software provisions the suitable pkey for
the VF in the paravirtualed PKEY table index 0. When this is the case,
the VF IB stack will find in index 0 an invalide pkey, which is all
zeros.
Moreover, the cloud managment can assign the pkey value at index 0 at
any time of the guest life cycle.
The correct behavior for IPoIB to address these requirements for
parent interfaces is to use PKEY_CHANGE event as trigger to optionally
re-init the device pkey value and re-create all the relevant resources
accordingly, if the value of the pkey in index 0 has changed (from
invalid to valid or from valid value X to invalid value Y).
This patch enhances the heavy flushing code which is triggered by pkey
change event, to behave correctly for parent devices. For child
devices, the code remains the same, namely chases pkey value and not
index.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2013-07-18 19:02:32 +08:00
|
|
|
/* child devices chase their origin pkey value, while non-child
|
|
|
|
* (parent) devices should always takes what present in pkey index 0
|
|
|
|
*/
|
|
|
|
if (test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
|
2014-08-07 02:40:32 +08:00
|
|
|
result = update_child_pkey(priv);
|
|
|
|
if (result) {
|
|
|
|
/* restart QP only if P_Key index is changed */
|
IPoIB: Fix pkey change flow for virtualization environments
IPoIB's required behaviour w.r.t to the pkey used by the device is the following:
- For "parent" interfaces (e.g ib0, ib1, etc) who are created
automatically as a result of hot-plug events from the IB core, the
driver needs to take whatever pkey vlaue it finds in index 0, and
stick to that index.
- For child interfaces (e.g ib0.8001, etc) created by admin directive,
the driver needs to use and stick to the value provided during its
creation.
In SR-IOV environment its possible for the VF probe to take place
before the cloud management software provisions the suitable pkey for
the VF in the paravirtualed PKEY table index 0. When this is the case,
the VF IB stack will find in index 0 an invalide pkey, which is all
zeros.
Moreover, the cloud managment can assign the pkey value at index 0 at
any time of the guest life cycle.
The correct behavior for IPoIB to address these requirements for
parent interfaces is to use PKEY_CHANGE event as trigger to optionally
re-init the device pkey value and re-create all the relevant resources
accordingly, if the value of the pkey in index 0 has changed (from
invalid to valid or from valid value X to invalid value Y).
This patch enhances the heavy flushing code which is triggered by pkey
change event, to behave correctly for parent devices. For child
devices, the code remains the same, namely chases pkey value and not
index.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2013-07-18 19:02:32 +08:00
|
|
|
ipoib_dbg(priv, "Not flushing - P_Key index not changed.\n");
|
2008-04-17 12:09:35 +08:00
|
|
|
return;
|
IPoIB: Fix pkey change flow for virtualization environments
IPoIB's required behaviour w.r.t to the pkey used by the device is the following:
- For "parent" interfaces (e.g ib0, ib1, etc) who are created
automatically as a result of hot-plug events from the IB core, the
driver needs to take whatever pkey vlaue it finds in index 0, and
stick to that index.
- For child interfaces (e.g ib0.8001, etc) created by admin directive,
the driver needs to use and stick to the value provided during its
creation.
In SR-IOV environment its possible for the VF probe to take place
before the cloud management software provisions the suitable pkey for
the VF in the paravirtualed PKEY table index 0. When this is the case,
the VF IB stack will find in index 0 an invalide pkey, which is all
zeros.
Moreover, the cloud managment can assign the pkey value at index 0 at
any time of the guest life cycle.
The correct behavior for IPoIB to address these requirements for
parent interfaces is to use PKEY_CHANGE event as trigger to optionally
re-init the device pkey value and re-create all the relevant resources
accordingly, if the value of the pkey in index 0 has changed (from
invalid to valid or from valid value X to invalid value Y).
This patch enhances the heavy flushing code which is triggered by pkey
change event, to behave correctly for parent devices. For child
devices, the code remains the same, namely chases pkey value and not
index.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2013-07-18 19:02:32 +08:00
|
|
|
}
|
2014-08-07 02:40:32 +08:00
|
|
|
|
IPoIB: Fix pkey change flow for virtualization environments
IPoIB's required behaviour w.r.t to the pkey used by the device is the following:
- For "parent" interfaces (e.g ib0, ib1, etc) who are created
automatically as a result of hot-plug events from the IB core, the
driver needs to take whatever pkey vlaue it finds in index 0, and
stick to that index.
- For child interfaces (e.g ib0.8001, etc) created by admin directive,
the driver needs to use and stick to the value provided during its
creation.
In SR-IOV environment its possible for the VF probe to take place
before the cloud management software provisions the suitable pkey for
the VF in the paravirtualed PKEY table index 0. When this is the case,
the VF IB stack will find in index 0 an invalide pkey, which is all
zeros.
Moreover, the cloud managment can assign the pkey value at index 0 at
any time of the guest life cycle.
The correct behavior for IPoIB to address these requirements for
parent interfaces is to use PKEY_CHANGE event as trigger to optionally
re-init the device pkey value and re-create all the relevant resources
accordingly, if the value of the pkey in index 0 has changed (from
invalid to valid or from valid value X to invalid value Y).
This patch enhances the heavy flushing code which is triggered by pkey
change event, to behave correctly for parent devices. For child
devices, the code remains the same, namely chases pkey value and not
index.
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2013-07-18 19:02:32 +08:00
|
|
|
} else {
|
|
|
|
result = update_parent_pkey(priv);
|
|
|
|
/* restart QP only if P_Key value changed */
|
|
|
|
if (result) {
|
|
|
|
ipoib_dbg(priv, "Not flushing - P_Key value not changed.\n");
|
|
|
|
return;
|
|
|
|
}
|
2007-05-19 23:51:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-15 14:48:49 +08:00
|
|
|
if (level == IPOIB_FLUSH_LIGHT) {
|
2016-09-12 14:55:28 +08:00
|
|
|
int oper_up;
|
2008-07-15 14:48:49 +08:00
|
|
|
ipoib_mark_paths_invalid(dev);
|
2016-09-12 14:55:28 +08:00
|
|
|
/* Set IPoIB operation as down to prevent races between:
|
|
|
|
* the flush flow which leaves MCG and on the fly joins
|
|
|
|
* which can happen during that time. mcast restart task
|
|
|
|
* should deal with join requests we missed.
|
|
|
|
*/
|
|
|
|
oper_up = test_and_clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
|
2008-07-15 14:48:49 +08:00
|
|
|
ipoib_mcast_dev_flush(dev);
|
2016-09-12 14:55:28 +08:00
|
|
|
if (oper_up)
|
|
|
|
set_bit(IPOIB_FLAG_OPER_UP, &priv->flags);
|
2015-02-22 08:27:04 +08:00
|
|
|
ipoib_flush_ah(dev);
|
2008-07-15 14:48:49 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-15 14:48:49 +08:00
|
|
|
if (level >= IPOIB_FLUSH_NORMAL)
|
2015-02-22 08:27:04 +08:00
|
|
|
ipoib_ib_dev_down(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-15 14:48:49 +08:00
|
|
|
if (level == IPOIB_FLUSH_HEAVY) {
|
2014-08-07 02:40:32 +08:00
|
|
|
if (test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags))
|
2015-02-22 08:27:04 +08:00
|
|
|
ipoib_ib_dev_stop(dev);
|
2017-10-10 15:36:41 +08:00
|
|
|
|
2017-12-21 23:38:27 +08:00
|
|
|
if (ipoib_ib_dev_open(dev))
|
2014-08-07 02:40:32 +08:00
|
|
|
return;
|
2017-10-10 15:36:41 +08:00
|
|
|
|
2014-08-07 02:40:32 +08:00
|
|
|
if (netif_queue_stopped(dev))
|
|
|
|
netif_start_queue(dev);
|
2007-05-19 23:51:54 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* The device could have been brought down between the start and when
|
|
|
|
* we get here, don't bring it back up if it's not configured up
|
|
|
|
*/
|
2006-09-23 06:22:56 +08:00
|
|
|
if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
|
2008-07-15 14:48:49 +08:00
|
|
|
if (level >= IPOIB_FLUSH_NORMAL)
|
|
|
|
ipoib_ib_dev_up(dev);
|
IB/IPoIB: Allow setting the device address
In IB networks, and specifically in IPoIB/rdmacm traffic, the device
address of an IPoIB interface is used as a means to exchange information
between nodes needed for communication.
Currently an IPoIB interface will always be created with a device
address based on its node GUID without a way to change that.
This change adds the ability to set the device address of an IPoIB
interface by value. We use the set mac address ndo to do that.
The flow should be broken down to two:
1) The GID value is already in the GID table,
in this case the interface will be able to set carrier up.
2) The GID value is not yet in the GID table,
in this case the interface won't try to join the multicast group
and will wait (listen on GID_CHANGE event) until the GID is inserted.
In order to track those changes, we add a new flag:
* IPOIB_FLAG_DEV_ADDR_SET.
When set, it means the dev_addr is a based on a value in the gid
table. this bit will be cleared upon a dev_addr change triggered
by the user and set after validation.
Per IB spec the port GUID can't change if the module is loaded.
port GUID is the basis for GID at index 0 which is the basis for
the default device address of a ipoib interface.
The issue is that there are devices that don't follow the spec,
they change the port GUID while HCA is powered on, so in order
not to break userspace applications. We need to check if the
user wanted to control the device address and we assume that
if he sets the device address back to be based on GID index 0,
he no longer wishs to control it.
In order to track this, we add an additional flag:
* IPOIB_FLAG_DEV_ADDR_CTRL
When setting the device address, there is no validation of the upper
twelve bytes of the device address (flags, qpn, subnet prefix) as those
bytes are not under the control of the user.
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
2016-05-18 21:42:43 +08:00
|
|
|
if (ipoib_dev_addr_changed_valid(priv))
|
|
|
|
ipoib_mcast_restart_task(&priv->restart_task);
|
2006-09-23 06:22:56 +08:00
|
|
|
}
|
2007-05-19 23:51:54 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-15 14:48:49 +08:00
|
|
|
void ipoib_ib_dev_flush_light(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv =
|
|
|
|
container_of(work, struct ipoib_dev_priv, flush_light);
|
|
|
|
|
2015-07-07 22:45:13 +08:00
|
|
|
__ipoib_ib_dev_flush(priv, IPOIB_FLUSH_LIGHT, 0);
|
2008-07-15 14:48:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ipoib_ib_dev_flush_normal(struct work_struct *work)
|
2007-05-19 23:51:54 +08:00
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv =
|
2008-07-15 14:48:49 +08:00
|
|
|
container_of(work, struct ipoib_dev_priv, flush_normal);
|
2005-11-30 02:53:30 +08:00
|
|
|
|
2015-07-07 22:45:13 +08:00
|
|
|
__ipoib_ib_dev_flush(priv, IPOIB_FLUSH_NORMAL, 0);
|
2007-05-19 23:51:54 +08:00
|
|
|
}
|
2005-11-30 02:53:30 +08:00
|
|
|
|
2008-07-15 14:48:49 +08:00
|
|
|
void ipoib_ib_dev_flush_heavy(struct work_struct *work)
|
2007-05-19 23:51:54 +08:00
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv =
|
2008-07-15 14:48:49 +08:00
|
|
|
container_of(work, struct ipoib_dev_priv, flush_heavy);
|
2007-05-19 23:51:54 +08:00
|
|
|
|
2017-12-21 23:38:27 +08:00
|
|
|
rtnl_lock();
|
2015-07-07 22:45:13 +08:00
|
|
|
__ipoib_ib_dev_flush(priv, IPOIB_FLUSH_HEAVY, 0);
|
2017-12-21 23:38:27 +08:00
|
|
|
rtnl_unlock();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ipoib_ib_dev_cleanup(struct net_device *dev)
|
|
|
|
{
|
2017-04-10 16:22:29 +08:00
|
|
|
struct ipoib_dev_priv *priv = ipoib_priv(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ipoib_dbg(priv, "cleaning up ib_dev\n");
|
2013-10-16 22:37:52 +08:00
|
|
|
/*
|
|
|
|
* We must make sure there are no more (path) completions
|
|
|
|
* that may wish to touch priv fields that are no longer valid
|
|
|
|
*/
|
|
|
|
ipoib_flush_paths(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-02-22 08:27:04 +08:00
|
|
|
ipoib_mcast_stop_thread(dev);
|
2006-01-13 06:32:20 +08:00
|
|
|
ipoib_mcast_dev_flush(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-02-22 08:26:59 +08:00
|
|
|
/*
|
|
|
|
* All of our ah references aren't free until after
|
|
|
|
* ipoib_mcast_dev_flush(), ipoib_flush_paths, and
|
|
|
|
* the neighbor garbage collection is stopped and reaped.
|
|
|
|
* That should all be done now, so make a final ah flush.
|
|
|
|
*/
|
2015-02-22 08:27:04 +08:00
|
|
|
ipoib_stop_ah(dev);
|
2015-02-22 08:26:59 +08:00
|
|
|
|
2017-04-10 16:22:26 +08:00
|
|
|
clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
|
|
|
|
|
2017-04-10 16:22:30 +08:00
|
|
|
priv->rn_ops->ndo_uninit(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2017-04-10 16:22:26 +08:00
|
|
|
if (priv->pd) {
|
|
|
|
ib_dealloc_pd(priv->pd);
|
|
|
|
priv->pd = NULL;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|