2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
|
2005-08-11 13:03:10 +07:00
|
|
|
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
|
2005-04-17 05:20:36 +07: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 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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "ipoib.h"
|
|
|
|
|
2008-07-15 13:48:50 +07:00
|
|
|
int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid, int set_qkey)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
2008-07-15 13:48:50 +07:00
|
|
|
struct ib_qp_attr *qp_attr = NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
int ret;
|
|
|
|
u16 pkey_index;
|
|
|
|
|
2007-05-19 22:51:54 +07:00
|
|
|
if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
|
|
|
|
ret = -ENXIO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
|
|
|
|
|
2008-07-15 13:48:50 +07:00
|
|
|
if (set_qkey) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
|
|
|
|
if (!qp_attr)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* set correct QKey for QP */
|
|
|
|
qp_attr->qkey = priv->qkey;
|
|
|
|
ret = ib_modify_qp(priv->qp, qp_attr, IB_QP_QKEY);
|
|
|
|
if (ret) {
|
|
|
|
ipoib_warn(priv, "failed to modify QP, ret = %d\n", ret);
|
|
|
|
goto out;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* attach QP to multicast group */
|
|
|
|
ret = ib_attach_mcast(priv->qp, mgid, mlid);
|
|
|
|
if (ret)
|
|
|
|
ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret);
|
|
|
|
|
|
|
|
out:
|
|
|
|
kfree(qp_attr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-10-12 01:08:24 +07:00
|
|
|
int ipoib_init_qp(struct net_device *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
|
|
|
int ret;
|
|
|
|
struct ib_qp_attr qp_attr;
|
|
|
|
int attr_mask;
|
|
|
|
|
2007-05-19 22:51:54 +07:00
|
|
|
if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags))
|
|
|
|
return -1;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
qp_attr.qp_state = IB_QPS_INIT;
|
|
|
|
qp_attr.qkey = 0;
|
|
|
|
qp_attr.port_num = priv->port;
|
2007-05-19 22:51:54 +07:00
|
|
|
qp_attr.pkey_index = priv->pkey_index;
|
2005-04-17 05:20:36 +07:00
|
|
|
attr_mask =
|
|
|
|
IB_QP_QKEY |
|
|
|
|
IB_QP_PORT |
|
|
|
|
IB_QP_PKEY_INDEX |
|
|
|
|
IB_QP_STATE;
|
|
|
|
ret = ib_modify_qp(priv->qp, &qp_attr, attr_mask);
|
|
|
|
if (ret) {
|
|
|
|
ipoib_warn(priv, "failed to modify QP to init, ret = %d\n", ret);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp_attr.qp_state = IB_QPS_RTR;
|
|
|
|
/* Can't set this in a INIT->RTR transition */
|
|
|
|
attr_mask &= ~IB_QP_PORT;
|
|
|
|
ret = ib_modify_qp(priv->qp, &qp_attr, attr_mask);
|
|
|
|
if (ret) {
|
|
|
|
ipoib_warn(priv, "failed to modify QP to RTR, ret = %d\n", ret);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp_attr.qp_state = IB_QPS_RTS;
|
|
|
|
qp_attr.sq_psn = 0;
|
|
|
|
attr_mask |= IB_QP_SQ_PSN;
|
|
|
|
attr_mask &= ~IB_QP_PKEY_INDEX;
|
|
|
|
ret = ib_modify_qp(priv->qp, &qp_attr, attr_mask);
|
|
|
|
if (ret) {
|
|
|
|
ipoib_warn(priv, "failed to modify QP to RTS, ret = %d\n", ret);
|
|
|
|
goto out_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_fail:
|
2005-10-12 01:08:24 +07:00
|
|
|
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");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-10-12 01:08:24 +07:00
|
|
|
return ret;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
|
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
|
|
|
struct ib_qp_init_attr init_attr = {
|
|
|
|
.cap = {
|
2006-04-10 23:43:58 +07:00
|
|
|
.max_send_wr = ipoib_sendq_size,
|
|
|
|
.max_recv_wr = ipoib_recvq_size,
|
2016-07-20 15:30:06 +07:00
|
|
|
.max_send_sge = min_t(u32, priv->ca->attrs.max_sge,
|
|
|
|
MAX_SKB_FRAGS + 1),
|
2008-04-24 01:55:45 +07:00
|
|
|
.max_recv_sge = IPOIB_UD_RX_SG
|
2005-04-17 05:20:36 +07:00
|
|
|
},
|
|
|
|
.sq_sig_type = IB_SIGNAL_ALL_WR,
|
|
|
|
.qp_type = IB_QPT_UD
|
|
|
|
};
|
2015-06-11 20:35:21 +07:00
|
|
|
struct ib_cq_init_attr cq_attr = {};
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-02-06 03:12:23 +07:00
|
|
|
int ret, size;
|
2008-01-30 23:30:53 +07:00
|
|
|
int i;
|
2007-02-06 03:12:23 +07:00
|
|
|
|
2016-09-05 17:56:17 +07:00
|
|
|
priv->pd = ib_alloc_pd(priv->ca, 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (IS_ERR(priv->pd)) {
|
|
|
|
printk(KERN_WARNING "%s: failed to allocate PD\n", ca->name);
|
2015-01-31 06:38:55 +07:00
|
|
|
return -ENODEV;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
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 07:27:03 +07:00
|
|
|
/*
|
|
|
|
* the various IPoIB tasks assume they will never race against
|
|
|
|
* themselves, so always use a single thread workqueue
|
|
|
|
*/
|
2016-08-16 01:14:47 +07:00
|
|
|
priv->wq = alloc_ordered_workqueue("ipoib_wq", WQ_MEM_RECLAIM);
|
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 07:27:03 +07:00
|
|
|
if (!priv->wq) {
|
|
|
|
printk(KERN_WARNING "ipoib: failed to allocate device WQ\n");
|
2015-07-31 06:22:17 +07:00
|
|
|
goto out_free_pd;
|
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 07:27:03 +07:00
|
|
|
}
|
|
|
|
|
2008-04-30 03:46:53 +07:00
|
|
|
size = ipoib_recvq_size + 1;
|
2007-02-06 03:12:23 +07:00
|
|
|
ret = ipoib_cm_dev_init(dev);
|
2008-01-26 05:15:24 +07:00
|
|
|
if (!ret) {
|
2008-04-30 03:46:53 +07:00
|
|
|
size += ipoib_sendq_size;
|
2008-01-26 05:15:24 +07:00
|
|
|
if (ipoib_cm_has_srq(dev))
|
|
|
|
size += ipoib_recvq_size + 1; /* 1 extra for rx_drain_qp */
|
|
|
|
else
|
|
|
|
size += ipoib_recvq_size * ipoib_max_conn_qp;
|
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 07:27:03 +07:00
|
|
|
} else
|
2015-07-23 03:30:03 +07:00
|
|
|
if (ret != -ENOSYS)
|
|
|
|
goto out_free_wq;
|
2007-02-06 03:12:23 +07:00
|
|
|
|
2015-06-11 20:35:21 +07:00
|
|
|
cq_attr.cqe = size;
|
|
|
|
priv->recv_cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL,
|
|
|
|
dev, &cq_attr);
|
2008-04-30 03:46:53 +07:00
|
|
|
if (IS_ERR(priv->recv_cq)) {
|
|
|
|
printk(KERN_WARNING "%s: failed to create receive CQ\n", ca->name);
|
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 07:27:03 +07:00
|
|
|
goto out_cm_dev_cleanup;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2015-06-11 20:35:21 +07:00
|
|
|
cq_attr.cqe = ipoib_sendq_size;
|
2008-05-01 10:02:45 +07:00
|
|
|
priv->send_cq = ib_create_cq(priv->ca, ipoib_send_comp_handler, NULL,
|
2015-06-11 20:35:21 +07:00
|
|
|
dev, &cq_attr);
|
2008-04-30 03:46:53 +07:00
|
|
|
if (IS_ERR(priv->send_cq)) {
|
|
|
|
printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name);
|
|
|
|
goto out_free_recv_cq;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ib_req_notify_cq(priv->recv_cq, IB_CQ_NEXT_COMP))
|
|
|
|
goto out_free_send_cq;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-04-30 03:46:53 +07:00
|
|
|
init_attr.send_cq = priv->send_cq;
|
|
|
|
init_attr.recv_cq = priv->recv_cq;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-04-17 11:09:27 +07:00
|
|
|
if (priv->hca_caps & IB_DEVICE_UD_TSO)
|
2008-07-15 13:48:48 +07:00
|
|
|
init_attr.create_flags |= IB_QP_CREATE_IPOIB_UD_LSO;
|
|
|
|
|
|
|
|
if (priv->hca_caps & IB_DEVICE_BLOCK_MULTICAST_LOOPBACK)
|
|
|
|
init_attr.create_flags |= IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK;
|
2008-04-17 11:09:27 +07:00
|
|
|
|
2013-11-07 20:25:12 +07:00
|
|
|
if (priv->hca_caps & IB_DEVICE_MANAGED_FLOW_STEERING)
|
|
|
|
init_attr.create_flags |= IB_QP_CREATE_NETIF_QP;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
priv->qp = ib_create_qp(priv->pd, &init_attr);
|
|
|
|
if (IS_ERR(priv->qp)) {
|
|
|
|
printk(KERN_WARNING "%s: failed to create QP\n", ca->name);
|
2008-04-30 03:46:53 +07:00
|
|
|
goto out_free_send_cq;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
priv->dev->dev_addr[1] = (priv->qp->qp_num >> 16) & 0xff;
|
|
|
|
priv->dev->dev_addr[2] = (priv->qp->qp_num >> 8) & 0xff;
|
|
|
|
priv->dev->dev_addr[3] = (priv->qp->qp_num ) & 0xff;
|
|
|
|
|
2008-01-30 23:30:53 +07:00
|
|
|
for (i = 0; i < MAX_SKB_FRAGS + 1; ++i)
|
2015-07-31 06:22:17 +07:00
|
|
|
priv->tx_sge[i].lkey = priv->pd->local_dma_lkey;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-10-08 15:16:33 +07:00
|
|
|
priv->tx_wr.wr.opcode = IB_WR_SEND;
|
|
|
|
priv->tx_wr.wr.sg_list = priv->tx_sge;
|
|
|
|
priv->tx_wr.wr.send_flags = IB_SEND_SIGNALED;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-07-31 06:22:17 +07:00
|
|
|
priv->rx_sge[0].lkey = priv->pd->local_dma_lkey;
|
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 17:39:00 +07:00
|
|
|
|
|
|
|
priv->rx_sge[0].length = IPOIB_UD_BUF_SIZE(priv->max_ib_mtu);
|
|
|
|
priv->rx_wr.num_sge = 1;
|
|
|
|
|
2008-04-24 01:55:45 +07:00
|
|
|
priv->rx_wr.next = NULL;
|
|
|
|
priv->rx_wr.sg_list = priv->rx_sge;
|
|
|
|
|
2016-07-20 15:30:06 +07:00
|
|
|
if (init_attr.cap.max_send_sge > 1)
|
|
|
|
dev->features |= NETIF_F_SG;
|
|
|
|
|
2016-03-02 19:44:28 +07:00
|
|
|
priv->max_send_sge = init_attr.cap.max_send_sge;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
|
2008-04-30 03:46:53 +07:00
|
|
|
out_free_send_cq:
|
|
|
|
ib_destroy_cq(priv->send_cq);
|
|
|
|
|
|
|
|
out_free_recv_cq:
|
|
|
|
ib_destroy_cq(priv->recv_cq);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
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 07:27:03 +07:00
|
|
|
out_cm_dev_cleanup:
|
|
|
|
ipoib_cm_dev_cleanup(dev);
|
|
|
|
|
|
|
|
out_free_wq:
|
|
|
|
destroy_workqueue(priv->wq);
|
|
|
|
priv->wq = NULL;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
out_free_pd:
|
|
|
|
ib_dealloc_pd(priv->pd);
|
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 07:27:03 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ipoib_transport_dev_cleanup(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (priv->qp) {
|
|
|
|
if (ib_destroy_qp(priv->qp))
|
|
|
|
ipoib_warn(priv, "ib_qp_destroy failed\n");
|
|
|
|
|
|
|
|
priv->qp = NULL;
|
|
|
|
clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
|
|
|
|
}
|
|
|
|
|
2008-04-30 03:46:53 +07:00
|
|
|
if (ib_destroy_cq(priv->send_cq))
|
|
|
|
ipoib_warn(priv, "ib_cq_destroy (send) failed\n");
|
|
|
|
|
|
|
|
if (ib_destroy_cq(priv->recv_cq))
|
|
|
|
ipoib_warn(priv, "ib_cq_destroy (recv) failed\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-02-06 03:12:23 +07:00
|
|
|
ipoib_cm_dev_cleanup(dev);
|
|
|
|
|
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 07:27:03 +07:00
|
|
|
if (priv->wq) {
|
|
|
|
flush_workqueue(priv->wq);
|
|
|
|
destroy_workqueue(priv->wq);
|
|
|
|
priv->wq = NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-06 03:34:31 +07:00
|
|
|
ib_dealloc_pd(priv->pd);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void ipoib_event(struct ib_event_handler *handler,
|
|
|
|
struct ib_event *record)
|
|
|
|
{
|
|
|
|
struct ipoib_dev_priv *priv =
|
|
|
|
container_of(handler, struct ipoib_dev_priv, event_handler);
|
|
|
|
|
2007-05-19 22:51:54 +07:00
|
|
|
if (record->element.port_num != priv->port)
|
|
|
|
return;
|
|
|
|
|
2008-07-15 13:48:49 +07:00
|
|
|
ipoib_dbg(priv, "Event %d on device %s port %d\n", record->event,
|
|
|
|
record->device->name, record->element.port_num);
|
|
|
|
|
|
|
|
if (record->event == IB_EVENT_SM_CHANGE ||
|
2007-05-19 22:51:54 +07:00
|
|
|
record->event == IB_EVENT_CLIENT_REREGISTER) {
|
2008-07-15 13:48:49 +07:00
|
|
|
queue_work(ipoib_workqueue, &priv->flush_light);
|
|
|
|
} else if (record->event == IB_EVENT_PORT_ERR ||
|
|
|
|
record->event == IB_EVENT_PORT_ACTIVE ||
|
|
|
|
record->event == IB_EVENT_LID_CHANGE) {
|
|
|
|
queue_work(ipoib_workqueue, &priv->flush_normal);
|
2007-05-19 22:51:54 +07:00
|
|
|
} else if (record->event == IB_EVENT_PKEY_CHANGE) {
|
2008-07-15 13:48:49 +07:00
|
|
|
queue_work(ipoib_workqueue, &priv->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 20:42:43 +07:00
|
|
|
} else if (record->event == IB_EVENT_GID_CHANGE &&
|
|
|
|
!test_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags)) {
|
|
|
|
queue_work(ipoib_workqueue, &priv->flush_light);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|