2007-05-09 09:00:38 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
|
2008-07-26 01:32:52 +08:00
|
|
|
* Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
|
2007-05-09 09:00:38 +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/mlx4/cq.h>
|
|
|
|
#include <linux/mlx4/qp.h>
|
2013-04-10 22:26:48 +08:00
|
|
|
#include <linux/mlx4/srq.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>
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
#include "mlx4_ib.h"
|
|
|
|
#include "user.h"
|
|
|
|
|
|
|
|
static void mlx4_ib_cq_comp(struct mlx4_cq *cq)
|
|
|
|
{
|
|
|
|
struct ib_cq *ibcq = &to_mibcq(cq)->ibcq;
|
|
|
|
ibcq->comp_handler(ibcq, ibcq->cq_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mlx4_ib_cq_event(struct mlx4_cq *cq, enum mlx4_event type)
|
|
|
|
{
|
|
|
|
struct ib_event event;
|
|
|
|
struct ib_cq *ibcq;
|
|
|
|
|
|
|
|
if (type != MLX4_EVENT_TYPE_CQ_ERROR) {
|
2012-04-29 22:04:26 +08:00
|
|
|
pr_warn("Unexpected event type %d "
|
2007-05-09 09:00:38 +08:00
|
|
|
"on CQ %06x\n", type, cq->cqn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ibcq = &to_mibcq(cq)->ibcq;
|
|
|
|
if (ibcq->event_handler) {
|
|
|
|
event.device = ibcq->device;
|
|
|
|
event.event = IB_EVENT_CQ_ERR;
|
|
|
|
event.element.cq = ibcq;
|
|
|
|
ibcq->event_handler(&event, ibcq->cq_context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *get_cqe_from_buf(struct mlx4_ib_cq_buf *buf, int n)
|
|
|
|
{
|
2012-10-21 22:59:24 +08:00
|
|
|
return mlx4_buf_offset(&buf->buf, n * buf->entry_size);
|
2007-05-09 09:00:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *get_cqe(struct mlx4_ib_cq *cq, int n)
|
|
|
|
{
|
|
|
|
return get_cqe_from_buf(&cq->buf, n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *get_sw_cqe(struct mlx4_ib_cq *cq, int n)
|
|
|
|
{
|
|
|
|
struct mlx4_cqe *cqe = get_cqe(cq, n & cq->ibcq.cqe);
|
2012-10-21 22:59:24 +08:00
|
|
|
struct mlx4_cqe *tcqe = ((cq->buf.entry_size == 64) ? (cqe + 1) : cqe);
|
2007-05-09 09:00:38 +08:00
|
|
|
|
2012-10-21 22:59:24 +08:00
|
|
|
return (!!(tcqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
|
2007-05-09 09:00:38 +08:00
|
|
|
!!(n & (cq->ibcq.cqe + 1))) ? NULL : cqe;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct mlx4_cqe *next_cqe_sw(struct mlx4_ib_cq *cq)
|
|
|
|
{
|
|
|
|
return get_sw_cqe(cq, cq->mcq.cons_index);
|
|
|
|
}
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_cq *mcq = to_mcq(cq);
|
|
|
|
struct mlx4_ib_dev *dev = to_mdev(cq->device);
|
|
|
|
|
|
|
|
return mlx4_cq_modify(dev->dev, &mcq->mcq, cq_count, cq_period);
|
|
|
|
}
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
static int mlx4_ib_alloc_cq_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq_buf *buf, int nent)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2012-10-21 22:59:24 +08:00
|
|
|
err = mlx4_buf_alloc(dev->dev, nent * dev->dev->caps.cqe_size,
|
2014-05-11 20:15:12 +08:00
|
|
|
PAGE_SIZE * 2, &buf->buf, GFP_KERNEL);
|
2008-04-17 12:09:33 +08:00
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
2012-10-21 22:59:24 +08:00
|
|
|
buf->entry_size = dev->dev->caps.cqe_size;
|
2008-04-17 12:09:33 +08:00
|
|
|
err = mlx4_mtt_init(dev->dev, buf->buf.npages, buf->buf.page_shift,
|
|
|
|
&buf->mtt);
|
|
|
|
if (err)
|
|
|
|
goto err_buf;
|
|
|
|
|
2014-05-11 20:15:12 +08:00
|
|
|
err = mlx4_buf_write_mtt(dev->dev, &buf->mtt, &buf->buf, GFP_KERNEL);
|
2008-04-17 12:09:33 +08:00
|
|
|
if (err)
|
|
|
|
goto err_mtt;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_mtt:
|
|
|
|
mlx4_mtt_cleanup(dev->dev, &buf->mtt);
|
|
|
|
|
|
|
|
err_buf:
|
2012-10-21 22:59:24 +08:00
|
|
|
mlx4_buf_free(dev->dev, nent * buf->entry_size, &buf->buf);
|
2008-04-17 12:09:33 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mlx4_ib_free_cq_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq_buf *buf, int cqe)
|
|
|
|
{
|
2012-10-21 22:59:24 +08:00
|
|
|
mlx4_buf_free(dev->dev, (cqe + 1) * buf->entry_size, &buf->buf);
|
2008-04-17 12:09:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mlx4_ib_get_cq_umem(struct mlx4_ib_dev *dev, struct ib_ucontext *context,
|
|
|
|
struct mlx4_ib_cq_buf *buf, struct ib_umem **umem,
|
|
|
|
u64 buf_addr, int cqe)
|
|
|
|
{
|
|
|
|
int err;
|
2012-10-21 22:59:24 +08:00
|
|
|
int cqe_size = dev->dev->caps.cqe_size;
|
2008-04-17 12:09:33 +08:00
|
|
|
|
2012-10-21 22:59:24 +08:00
|
|
|
*umem = ib_umem_get(context, buf_addr, cqe * cqe_size,
|
2008-04-29 16:00:34 +08:00
|
|
|
IB_ACCESS_LOCAL_WRITE, 1);
|
2008-04-17 12:09:33 +08:00
|
|
|
if (IS_ERR(*umem))
|
|
|
|
return PTR_ERR(*umem);
|
|
|
|
|
|
|
|
err = mlx4_mtt_init(dev->dev, ib_umem_page_count(*umem),
|
|
|
|
ilog2((*umem)->page_size), &buf->mtt);
|
|
|
|
if (err)
|
|
|
|
goto err_buf;
|
|
|
|
|
|
|
|
err = mlx4_ib_umem_write_mtt(dev, &buf->mtt, *umem);
|
|
|
|
if (err)
|
|
|
|
goto err_mtt;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_mtt:
|
|
|
|
mlx4_mtt_cleanup(dev->dev, &buf->mtt);
|
|
|
|
|
|
|
|
err_buf:
|
|
|
|
ib_umem_release(*umem);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector,
|
|
|
|
struct ib_ucontext *context,
|
|
|
|
struct ib_udata *udata)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_dev *dev = to_mdev(ibdev);
|
|
|
|
struct mlx4_ib_cq *cq;
|
|
|
|
struct mlx4_uar *uar;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (entries < 1 || entries > dev->dev->caps.max_cqes)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
cq = kmalloc(sizeof *cq, GFP_KERNEL);
|
|
|
|
if (!cq)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
entries = roundup_pow_of_two(entries + 1);
|
|
|
|
cq->ibcq.cqe = entries - 1;
|
2008-04-17 12:09:33 +08:00
|
|
|
mutex_init(&cq->resize_mutex);
|
2007-05-09 09:00:38 +08:00
|
|
|
spin_lock_init(&cq->lock);
|
2008-04-17 12:09:33 +08:00
|
|
|
cq->resize_buf = NULL;
|
|
|
|
cq->resize_umem = NULL;
|
2015-02-08 17:49:34 +08:00
|
|
|
INIT_LIST_HEAD(&cq->send_qp_list);
|
|
|
|
INIT_LIST_HEAD(&cq->recv_qp_list);
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
if (context) {
|
|
|
|
struct mlx4_ib_create_cq ucmd;
|
|
|
|
|
|
|
|
if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
|
|
|
|
err = -EFAULT;
|
|
|
|
goto err_cq;
|
|
|
|
}
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
err = mlx4_ib_get_cq_umem(dev, context, &cq->buf, &cq->umem,
|
|
|
|
ucmd.buf_addr, entries);
|
2007-05-09 09:00:38 +08:00
|
|
|
if (err)
|
2008-04-17 12:09:33 +08:00
|
|
|
goto err_cq;
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
err = mlx4_ib_db_map_user(to_mucontext(context), ucmd.db_addr,
|
|
|
|
&cq->db);
|
|
|
|
if (err)
|
|
|
|
goto err_mtt;
|
|
|
|
|
|
|
|
uar = &to_mucontext(context)->uar;
|
|
|
|
} else {
|
2014-05-11 20:15:12 +08:00
|
|
|
err = mlx4_db_alloc(dev->dev, &cq->db, 1, GFP_KERNEL);
|
2007-05-09 09:00:38 +08:00
|
|
|
if (err)
|
|
|
|
goto err_cq;
|
|
|
|
|
|
|
|
cq->mcq.set_ci_db = cq->db.db;
|
|
|
|
cq->mcq.arm_db = cq->db.db + 1;
|
|
|
|
*cq->mcq.set_ci_db = 0;
|
|
|
|
*cq->mcq.arm_db = 0;
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
err = mlx4_ib_alloc_cq_buf(dev, &cq->buf, entries);
|
2007-05-09 09:00:38 +08:00
|
|
|
if (err)
|
2008-04-17 12:09:33 +08:00
|
|
|
goto err_db;
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
uar = &dev->priv_uar;
|
|
|
|
}
|
|
|
|
|
2012-04-29 22:04:27 +08:00
|
|
|
if (dev->eq_table)
|
|
|
|
vector = dev->eq_table[vector % ibdev->num_comp_vectors];
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
err = mlx4_cq_alloc(dev->dev, entries, &cq->buf.mtt, uar,
|
2013-04-23 14:06:49 +08:00
|
|
|
cq->db.dma, &cq->mcq, vector, 0, 0);
|
2007-05-09 09:00:38 +08:00
|
|
|
if (err)
|
|
|
|
goto err_dbmap;
|
|
|
|
|
net/mlx4_core: Use tasklet for user-space CQ completion events
Previously, we've fired all our completion callbacks straight from our ISR.
Some of those callbacks were lightweight (for example, mlx4_en's and
IPoIB napi callbacks), but some of them did more work (for example,
the user-space RDMA stack uverbs' completion handler). Besides that,
doing more than the minimal work in ISR is generally considered wrong,
it could even lead to a hard lockup of the system. Since when a lot
of completion events are generated by the hardware, the loop over those
events could be so long, that we'll get into a hard lockup by the system
watchdog.
In order to avoid that, add a new way of invoking completion events
callbacks. In the interrupt itself, we add the CQs which receive completion
event to a per-EQ list and schedule a tasklet. In the tasklet context
we loop over all the CQs in the list and invoke the user callback.
Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-12-11 16:57:53 +08:00
|
|
|
if (context)
|
|
|
|
cq->mcq.tasklet_ctx.comp = mlx4_ib_cq_comp;
|
|
|
|
else
|
|
|
|
cq->mcq.comp = mlx4_ib_cq_comp;
|
2007-05-09 09:00:38 +08:00
|
|
|
cq->mcq.event = mlx4_ib_cq_event;
|
|
|
|
|
|
|
|
if (context)
|
|
|
|
if (ib_copy_to_udata(udata, &cq->mcq.cqn, sizeof (__u32))) {
|
|
|
|
err = -EFAULT;
|
|
|
|
goto err_dbmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
return &cq->ibcq;
|
|
|
|
|
|
|
|
err_dbmap:
|
|
|
|
if (context)
|
|
|
|
mlx4_ib_db_unmap_user(to_mucontext(context), &cq->db);
|
|
|
|
|
|
|
|
err_mtt:
|
|
|
|
mlx4_mtt_cleanup(dev->dev, &cq->buf.mtt);
|
|
|
|
|
|
|
|
if (context)
|
|
|
|
ib_umem_release(cq->umem);
|
|
|
|
else
|
2008-05-01 10:52:55 +08:00
|
|
|
mlx4_ib_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
err_db:
|
|
|
|
if (!context)
|
2008-04-24 02:55:45 +08:00
|
|
|
mlx4_db_free(dev->dev, &cq->db);
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
err_cq:
|
|
|
|
kfree(cq);
|
|
|
|
|
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
static int mlx4_alloc_resize_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq *cq,
|
|
|
|
int entries)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (cq->resize_buf)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC);
|
|
|
|
if (!cq->resize_buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
err = mlx4_ib_alloc_cq_buf(dev, &cq->resize_buf->buf, entries);
|
|
|
|
if (err) {
|
|
|
|
kfree(cq->resize_buf);
|
|
|
|
cq->resize_buf = NULL;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
cq->resize_buf->cqe = entries - 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mlx4_alloc_resize_umem(struct mlx4_ib_dev *dev, struct mlx4_ib_cq *cq,
|
|
|
|
int entries, struct ib_udata *udata)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_resize_cq ucmd;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (cq->resize_umem)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC);
|
|
|
|
if (!cq->resize_buf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
err = mlx4_ib_get_cq_umem(dev, cq->umem->context, &cq->resize_buf->buf,
|
|
|
|
&cq->resize_umem, ucmd.buf_addr, entries);
|
|
|
|
if (err) {
|
|
|
|
kfree(cq->resize_buf);
|
|
|
|
cq->resize_buf = NULL;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
cq->resize_buf->cqe = entries - 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mlx4_ib_get_outstanding_cqes(struct mlx4_ib_cq *cq)
|
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
i = cq->mcq.cons_index;
|
2013-10-31 21:26:35 +08:00
|
|
|
while (get_sw_cqe(cq, i))
|
2008-04-17 12:09:33 +08:00
|
|
|
++i;
|
|
|
|
|
|
|
|
return i - cq->mcq.cons_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mlx4_ib_cq_resize_copy_cqes(struct mlx4_ib_cq *cq)
|
|
|
|
{
|
2008-12-25 12:32:42 +08:00
|
|
|
struct mlx4_cqe *cqe, *new_cqe;
|
2008-04-17 12:09:33 +08:00
|
|
|
int i;
|
2012-10-21 22:59:24 +08:00
|
|
|
int cqe_size = cq->buf.entry_size;
|
|
|
|
int cqe_inc = cqe_size == 64 ? 1 : 0;
|
2008-04-17 12:09:33 +08:00
|
|
|
|
|
|
|
i = cq->mcq.cons_index;
|
|
|
|
cqe = get_cqe(cq, i & cq->ibcq.cqe);
|
2012-10-21 22:59:24 +08:00
|
|
|
cqe += cqe_inc;
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
while ((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) != MLX4_CQE_OPCODE_RESIZE) {
|
2008-12-25 12:32:42 +08:00
|
|
|
new_cqe = get_cqe_from_buf(&cq->resize_buf->buf,
|
|
|
|
(i + 1) & cq->resize_buf->cqe);
|
2012-10-21 22:59:24 +08:00
|
|
|
memcpy(new_cqe, get_cqe(cq, i & cq->ibcq.cqe), cqe_size);
|
|
|
|
new_cqe += cqe_inc;
|
|
|
|
|
2008-12-25 12:32:42 +08:00
|
|
|
new_cqe->owner_sr_opcode = (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) |
|
|
|
|
(((i + 1) & (cq->resize_buf->cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0);
|
2008-04-17 12:09:33 +08:00
|
|
|
cqe = get_cqe(cq, ++i & cq->ibcq.cqe);
|
2012-10-21 22:59:24 +08:00
|
|
|
cqe += cqe_inc;
|
2008-04-17 12:09:33 +08:00
|
|
|
}
|
|
|
|
++cq->mcq.cons_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_dev *dev = to_mdev(ibcq->device);
|
|
|
|
struct mlx4_ib_cq *cq = to_mcq(ibcq);
|
2008-12-02 02:09:37 +08:00
|
|
|
struct mlx4_mtt mtt;
|
2008-04-17 12:09:33 +08:00
|
|
|
int outst_cqe;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&cq->resize_mutex);
|
2015-01-29 16:41:42 +08:00
|
|
|
if (entries < 1 || entries > dev->dev->caps.max_cqes) {
|
2008-04-17 12:09:33 +08:00
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
entries = roundup_pow_of_two(entries + 1);
|
|
|
|
if (entries == ibcq->cqe + 1) {
|
|
|
|
err = 0;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2015-01-29 16:41:42 +08:00
|
|
|
if (entries > dev->dev->caps.max_cqes + 1) {
|
2013-10-31 21:26:34 +08:00
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
if (ibcq->uobject) {
|
|
|
|
err = mlx4_alloc_resize_umem(dev, cq, entries, udata);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
} else {
|
2008-10-17 01:02:37 +08:00
|
|
|
/* Can't be smaller than the number of outstanding CQEs */
|
2008-04-17 12:09:33 +08:00
|
|
|
outst_cqe = mlx4_ib_get_outstanding_cqes(cq);
|
|
|
|
if (entries < outst_cqe + 1) {
|
2015-01-29 16:41:42 +08:00
|
|
|
err = -EINVAL;
|
2008-04-17 12:09:33 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = mlx4_alloc_resize_buf(dev, cq, entries);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2008-12-02 02:09:37 +08:00
|
|
|
mtt = cq->buf.mtt;
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
err = mlx4_cq_resize(dev->dev, &cq->mcq, entries, &cq->resize_buf->buf.mtt);
|
|
|
|
if (err)
|
|
|
|
goto err_buf;
|
|
|
|
|
2008-12-02 02:09:37 +08:00
|
|
|
mlx4_mtt_cleanup(dev->dev, &mtt);
|
2008-04-17 12:09:33 +08:00
|
|
|
if (ibcq->uobject) {
|
|
|
|
cq->buf = cq->resize_buf->buf;
|
|
|
|
cq->ibcq.cqe = cq->resize_buf->cqe;
|
|
|
|
ib_umem_release(cq->umem);
|
|
|
|
cq->umem = cq->resize_umem;
|
|
|
|
|
|
|
|
kfree(cq->resize_buf);
|
|
|
|
cq->resize_buf = NULL;
|
|
|
|
cq->resize_umem = NULL;
|
|
|
|
} else {
|
2011-01-11 09:42:06 +08:00
|
|
|
struct mlx4_ib_cq_buf tmp_buf;
|
|
|
|
int tmp_cqe = 0;
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
spin_lock_irq(&cq->lock);
|
|
|
|
if (cq->resize_buf) {
|
|
|
|
mlx4_ib_cq_resize_copy_cqes(cq);
|
2011-01-11 09:42:06 +08:00
|
|
|
tmp_buf = cq->buf;
|
|
|
|
tmp_cqe = cq->ibcq.cqe;
|
2008-04-17 12:09:33 +08:00
|
|
|
cq->buf = cq->resize_buf->buf;
|
|
|
|
cq->ibcq.cqe = cq->resize_buf->cqe;
|
|
|
|
|
|
|
|
kfree(cq->resize_buf);
|
|
|
|
cq->resize_buf = NULL;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&cq->lock);
|
2011-01-11 09:42:06 +08:00
|
|
|
|
|
|
|
if (tmp_cqe)
|
|
|
|
mlx4_ib_free_cq_buf(dev, &tmp_buf, tmp_cqe);
|
2008-04-17 12:09:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
err_buf:
|
2008-12-02 02:09:37 +08:00
|
|
|
mlx4_mtt_cleanup(dev->dev, &cq->resize_buf->buf.mtt);
|
2008-04-17 12:09:33 +08:00
|
|
|
if (!ibcq->uobject)
|
|
|
|
mlx4_ib_free_cq_buf(dev, &cq->resize_buf->buf,
|
|
|
|
cq->resize_buf->cqe);
|
|
|
|
|
|
|
|
kfree(cq->resize_buf);
|
|
|
|
cq->resize_buf = NULL;
|
|
|
|
|
|
|
|
if (cq->resize_umem) {
|
|
|
|
ib_umem_release(cq->resize_umem);
|
|
|
|
cq->resize_umem = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&cq->resize_mutex);
|
2012-10-21 22:59:24 +08:00
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
int mlx4_ib_destroy_cq(struct ib_cq *cq)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_dev *dev = to_mdev(cq->device);
|
|
|
|
struct mlx4_ib_cq *mcq = to_mcq(cq);
|
|
|
|
|
|
|
|
mlx4_cq_free(dev->dev, &mcq->mcq);
|
|
|
|
mlx4_mtt_cleanup(dev->dev, &mcq->buf.mtt);
|
|
|
|
|
|
|
|
if (cq->uobject) {
|
|
|
|
mlx4_ib_db_unmap_user(to_mucontext(cq->uobject->context), &mcq->db);
|
|
|
|
ib_umem_release(mcq->umem);
|
|
|
|
} else {
|
2008-05-01 10:52:55 +08:00
|
|
|
mlx4_ib_free_cq_buf(dev, &mcq->buf, cq->cqe);
|
2008-04-24 02:55:45 +08:00
|
|
|
mlx4_db_free(dev->dev, &mcq->db);
|
2007-05-09 09:00:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree(mcq);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_cqe(void *cqe)
|
|
|
|
{
|
|
|
|
__be32 *buf = cqe;
|
|
|
|
|
2012-04-29 22:04:26 +08:00
|
|
|
pr_debug("CQE contents %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
2007-05-09 09:00:38 +08:00
|
|
|
be32_to_cpu(buf[0]), be32_to_cpu(buf[1]), be32_to_cpu(buf[2]),
|
|
|
|
be32_to_cpu(buf[3]), be32_to_cpu(buf[4]), be32_to_cpu(buf[5]),
|
|
|
|
be32_to_cpu(buf[6]), be32_to_cpu(buf[7]));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mlx4_ib_handle_error_cqe(struct mlx4_err_cqe *cqe,
|
|
|
|
struct ib_wc *wc)
|
|
|
|
{
|
|
|
|
if (cqe->syndrome == MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR) {
|
2012-04-29 22:04:26 +08:00
|
|
|
pr_debug("local QP operation err "
|
2007-05-09 09:00:38 +08:00
|
|
|
"(QPN %06x, WQE index %x, vendor syndrome %02x, "
|
|
|
|
"opcode = %02x)\n",
|
|
|
|
be32_to_cpu(cqe->my_qpn), be16_to_cpu(cqe->wqe_index),
|
|
|
|
cqe->vendor_err_syndrome,
|
|
|
|
cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK);
|
|
|
|
dump_cqe(cqe);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cqe->syndrome) {
|
|
|
|
case MLX4_CQE_SYNDROME_LOCAL_LENGTH_ERR:
|
|
|
|
wc->status = IB_WC_LOC_LEN_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR:
|
|
|
|
wc->status = IB_WC_LOC_QP_OP_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_LOCAL_PROT_ERR:
|
|
|
|
wc->status = IB_WC_LOC_PROT_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_WR_FLUSH_ERR:
|
|
|
|
wc->status = IB_WC_WR_FLUSH_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_MW_BIND_ERR:
|
|
|
|
wc->status = IB_WC_MW_BIND_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_BAD_RESP_ERR:
|
|
|
|
wc->status = IB_WC_BAD_RESP_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_LOCAL_ACCESS_ERR:
|
|
|
|
wc->status = IB_WC_LOC_ACCESS_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR:
|
|
|
|
wc->status = IB_WC_REM_INV_REQ_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_REMOTE_ACCESS_ERR:
|
|
|
|
wc->status = IB_WC_REM_ACCESS_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_REMOTE_OP_ERR:
|
|
|
|
wc->status = IB_WC_REM_OP_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR:
|
|
|
|
wc->status = IB_WC_RETRY_EXC_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_RNR_RETRY_EXC_ERR:
|
|
|
|
wc->status = IB_WC_RNR_RETRY_EXC_ERR;
|
|
|
|
break;
|
|
|
|
case MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR:
|
|
|
|
wc->status = IB_WC_REM_ABORT_ERR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wc->status = IB_WC_GENERAL_ERR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wc->vendor_err = cqe->vendor_err_syndrome;
|
|
|
|
}
|
|
|
|
|
2008-08-07 11:14:06 +08:00
|
|
|
static int mlx4_ib_ipoib_csum_ok(__be16 status, __be16 checksum)
|
2008-04-17 12:01:10 +08:00
|
|
|
{
|
2008-08-07 11:14:06 +08:00
|
|
|
return ((status & cpu_to_be16(MLX4_CQE_STATUS_IPV4 |
|
|
|
|
MLX4_CQE_STATUS_IPV4F |
|
|
|
|
MLX4_CQE_STATUS_IPV4OPT |
|
|
|
|
MLX4_CQE_STATUS_IPV6 |
|
|
|
|
MLX4_CQE_STATUS_IPOK)) ==
|
|
|
|
cpu_to_be16(MLX4_CQE_STATUS_IPV4 |
|
|
|
|
MLX4_CQE_STATUS_IPOK)) &&
|
|
|
|
(status & cpu_to_be16(MLX4_CQE_STATUS_UDP |
|
|
|
|
MLX4_CQE_STATUS_TCP)) &&
|
2008-04-17 12:01:10 +08:00
|
|
|
checksum == cpu_to_be16(0xffff);
|
|
|
|
}
|
|
|
|
|
2012-08-03 16:40:40 +08:00
|
|
|
static int use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct ib_wc *wc,
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
unsigned tail, struct mlx4_cqe *cqe, int is_eth)
|
2012-08-03 16:40:40 +08:00
|
|
|
{
|
|
|
|
struct mlx4_ib_proxy_sqp_hdr *hdr;
|
|
|
|
|
|
|
|
ib_dma_sync_single_for_cpu(qp->ibqp.device,
|
|
|
|
qp->sqp_proxy_rcv[tail].map,
|
|
|
|
sizeof (struct mlx4_ib_proxy_sqp_hdr),
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
hdr = (struct mlx4_ib_proxy_sqp_hdr *) (qp->sqp_proxy_rcv[tail].addr);
|
|
|
|
wc->pkey_index = be16_to_cpu(hdr->tun.pkey_index);
|
|
|
|
wc->src_qp = be32_to_cpu(hdr->tun.flags_src_qp) & 0xFFFFFF;
|
|
|
|
wc->wc_flags |= (hdr->tun.g_ml_path & 0x80) ? (IB_WC_GRH) : 0;
|
|
|
|
wc->dlid_path_bits = 0;
|
|
|
|
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
if (is_eth) {
|
|
|
|
wc->vlan_id = be16_to_cpu(hdr->tun.sl_vid);
|
|
|
|
memcpy(&(wc->smac[0]), (char *)&hdr->tun.mac_31_0, 4);
|
|
|
|
memcpy(&(wc->smac[4]), (char *)&hdr->tun.slid_mac_47_32, 2);
|
|
|
|
wc->wc_flags |= (IB_WC_WITH_VLAN | IB_WC_WITH_SMAC);
|
|
|
|
} else {
|
|
|
|
wc->slid = be16_to_cpu(hdr->tun.slid_mac_47_32);
|
|
|
|
wc->sl = (u8) (be16_to_cpu(hdr->tun.sl_vid) >> 12);
|
|
|
|
}
|
|
|
|
|
2012-08-03 16:40:40 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-08 17:49:34 +08:00
|
|
|
static void mlx4_ib_qp_sw_comp(struct mlx4_ib_qp *qp, int num_entries,
|
|
|
|
struct ib_wc *wc, int *npolled, int is_send)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_wq *wq;
|
|
|
|
unsigned cur;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
wq = is_send ? &qp->sq : &qp->rq;
|
|
|
|
cur = wq->head - wq->tail;
|
|
|
|
|
|
|
|
if (cur == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < cur && *npolled < num_entries; i++) {
|
|
|
|
wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
|
|
|
|
wc->status = IB_WC_WR_FLUSH_ERR;
|
|
|
|
wc->vendor_err = MLX4_CQE_SYNDROME_WR_FLUSH_ERR;
|
|
|
|
wq->tail++;
|
|
|
|
(*npolled)++;
|
|
|
|
wc->qp = &qp->ibqp;
|
|
|
|
wc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mlx4_ib_poll_sw_comp(struct mlx4_ib_cq *cq, int num_entries,
|
|
|
|
struct ib_wc *wc, int *npolled)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_qp *qp;
|
|
|
|
|
|
|
|
*npolled = 0;
|
|
|
|
/* Find uncompleted WQEs belonging to that cq and retrun
|
|
|
|
* simulated FLUSH_ERR completions
|
|
|
|
*/
|
|
|
|
list_for_each_entry(qp, &cq->send_qp_list, cq_send_list) {
|
|
|
|
mlx4_ib_qp_sw_comp(qp, num_entries, wc, npolled, 1);
|
|
|
|
if (*npolled >= num_entries)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry(qp, &cq->recv_qp_list, cq_recv_list) {
|
|
|
|
mlx4_ib_qp_sw_comp(qp, num_entries, wc + *npolled, npolled, 0);
|
|
|
|
if (*npolled >= num_entries)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq,
|
|
|
|
struct mlx4_ib_qp **cur_qp,
|
|
|
|
struct ib_wc *wc)
|
|
|
|
{
|
|
|
|
struct mlx4_cqe *cqe;
|
|
|
|
struct mlx4_qp *mqp;
|
|
|
|
struct mlx4_ib_wq *wq;
|
|
|
|
struct mlx4_ib_srq *srq;
|
2013-04-10 22:26:48 +08:00
|
|
|
struct mlx4_srq *msrq = NULL;
|
2007-05-09 09:00:38 +08:00
|
|
|
int is_send;
|
|
|
|
int is_error;
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
int is_eth;
|
2008-01-26 06:15:34 +08:00
|
|
|
u32 g_mlpath_rqpn;
|
2007-05-09 09:00:38 +08:00
|
|
|
u16 wqe_ctr;
|
2012-08-03 16:40:40 +08:00
|
|
|
unsigned tail = 0;
|
2007-05-09 09:00:38 +08:00
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
repoll:
|
2007-05-09 09:00:38 +08:00
|
|
|
cqe = next_cqe_sw(cq);
|
|
|
|
if (!cqe)
|
|
|
|
return -EAGAIN;
|
|
|
|
|
2012-10-21 22:59:24 +08:00
|
|
|
if (cq->buf.entry_size == 64)
|
|
|
|
cqe++;
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
++cq->mcq.cons_index;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we read CQ entry contents after we've checked the
|
|
|
|
* ownership bit.
|
|
|
|
*/
|
|
|
|
rmb();
|
|
|
|
|
|
|
|
is_send = cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK;
|
|
|
|
is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
|
|
|
|
MLX4_CQE_OPCODE_ERROR;
|
|
|
|
|
IB/mlx4: Use multiple WQ blocks to post smaller send WQEs
ConnectX HCA supports shrinking WQEs, so that a single work request
can be made of multiple units of wqe_shift. This way, WRs can differ
in size, and do not have to be a power of 2 in size, saving memory and
speeding up send WR posting. Unfortunately, if we do this then the
wqe_index field in CQEs can't be used to look up the WR ID anymore, so
our implementation does this only if selective signaling is off.
Further, on 32-bit platforms, we can't use vmap() to make the QP
buffer virtually contigious. Thus we have to use constant-sized WRs to
make sure a WR is always fully within a single page-sized chunk.
Finally, we use WRs with the NOP opcode to avoid wrapping around the
queue buffer in the middle of posting a WR, and we set the
NoErrorCompletion bit to avoid getting completions with error for NOP
WRs. However, NEC is only supported starting with firmware 2.2.232,
so we use constant-sized WRs for older firmware. And, since MLX QPs
only support SEND, we use constant-sized WRs in this case.
When stamping during NOP posting, do stamping following setting of the
NOP WQE valid bit.
Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
2008-01-28 16:40:59 +08:00
|
|
|
if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_OPCODE_NOP &&
|
|
|
|
is_send)) {
|
2012-04-29 22:04:26 +08:00
|
|
|
pr_warn("Completion for NOP opcode detected!\n");
|
IB/mlx4: Use multiple WQ blocks to post smaller send WQEs
ConnectX HCA supports shrinking WQEs, so that a single work request
can be made of multiple units of wqe_shift. This way, WRs can differ
in size, and do not have to be a power of 2 in size, saving memory and
speeding up send WR posting. Unfortunately, if we do this then the
wqe_index field in CQEs can't be used to look up the WR ID anymore, so
our implementation does this only if selective signaling is off.
Further, on 32-bit platforms, we can't use vmap() to make the QP
buffer virtually contigious. Thus we have to use constant-sized WRs to
make sure a WR is always fully within a single page-sized chunk.
Finally, we use WRs with the NOP opcode to avoid wrapping around the
queue buffer in the middle of posting a WR, and we set the
NoErrorCompletion bit to avoid getting completions with error for NOP
WRs. However, NEC is only supported starting with firmware 2.2.232,
so we use constant-sized WRs for older firmware. And, since MLX QPs
only support SEND, we use constant-sized WRs in this case.
When stamping during NOP posting, do stamping following setting of the
NOP WQE valid bit.
Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
2008-01-28 16:40:59 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-04-17 12:09:33 +08:00
|
|
|
/* Resize CQ in progress */
|
|
|
|
if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_CQE_OPCODE_RESIZE)) {
|
|
|
|
if (cq->resize_buf) {
|
|
|
|
struct mlx4_ib_dev *dev = to_mdev(cq->ibcq.device);
|
|
|
|
|
|
|
|
mlx4_ib_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
|
|
|
|
cq->buf = cq->resize_buf->buf;
|
|
|
|
cq->ibcq.cqe = cq->resize_buf->cqe;
|
|
|
|
|
|
|
|
kfree(cq->resize_buf);
|
|
|
|
cq->resize_buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto repoll;
|
|
|
|
}
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
if (!*cur_qp ||
|
2008-08-07 11:14:06 +08:00
|
|
|
(be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK) != (*cur_qp)->mqp.qpn) {
|
2007-05-09 09:00:38 +08:00
|
|
|
/*
|
|
|
|
* We do not have to take the QP table lock here,
|
|
|
|
* because CQs will be locked while QPs are removed
|
|
|
|
* from the table.
|
|
|
|
*/
|
|
|
|
mqp = __mlx4_qp_lookup(to_mdev(cq->ibcq.device)->dev,
|
2008-08-07 11:14:06 +08:00
|
|
|
be32_to_cpu(cqe->vlan_my_qpn));
|
2007-05-09 09:00:38 +08:00
|
|
|
if (unlikely(!mqp)) {
|
2012-04-29 22:04:26 +08:00
|
|
|
pr_warn("CQ %06x with entry for unknown QPN %06x\n",
|
2008-08-07 11:14:06 +08:00
|
|
|
cq->mcq.cqn, be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK);
|
2007-05-09 09:00:38 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cur_qp = to_mibqp(mqp);
|
|
|
|
}
|
|
|
|
|
|
|
|
wc->qp = &(*cur_qp)->ibqp;
|
|
|
|
|
2013-04-10 22:26:48 +08:00
|
|
|
if (wc->qp->qp_type == IB_QPT_XRC_TGT) {
|
|
|
|
u32 srq_num;
|
|
|
|
g_mlpath_rqpn = be32_to_cpu(cqe->g_mlpath_rqpn);
|
|
|
|
srq_num = g_mlpath_rqpn & 0xffffff;
|
|
|
|
/* SRQ is also in the radix tree */
|
|
|
|
msrq = mlx4_srq_lookup(to_mdev(cq->ibcq.device)->dev,
|
|
|
|
srq_num);
|
|
|
|
if (unlikely(!msrq)) {
|
|
|
|
pr_warn("CQ %06x with entry for unknown SRQN %06x\n",
|
|
|
|
cq->mcq.cqn, srq_num);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
if (is_send) {
|
|
|
|
wq = &(*cur_qp)->sq;
|
IB/mlx4: Use multiple WQ blocks to post smaller send WQEs
ConnectX HCA supports shrinking WQEs, so that a single work request
can be made of multiple units of wqe_shift. This way, WRs can differ
in size, and do not have to be a power of 2 in size, saving memory and
speeding up send WR posting. Unfortunately, if we do this then the
wqe_index field in CQEs can't be used to look up the WR ID anymore, so
our implementation does this only if selective signaling is off.
Further, on 32-bit platforms, we can't use vmap() to make the QP
buffer virtually contigious. Thus we have to use constant-sized WRs to
make sure a WR is always fully within a single page-sized chunk.
Finally, we use WRs with the NOP opcode to avoid wrapping around the
queue buffer in the middle of posting a WR, and we set the
NoErrorCompletion bit to avoid getting completions with error for NOP
WRs. However, NEC is only supported starting with firmware 2.2.232,
so we use constant-sized WRs for older firmware. And, since MLX QPs
only support SEND, we use constant-sized WRs in this case.
When stamping during NOP posting, do stamping following setting of the
NOP WQE valid bit.
Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
2008-01-28 16:40:59 +08:00
|
|
|
if (!(*cur_qp)->sq_signal_bits) {
|
|
|
|
wqe_ctr = be16_to_cpu(cqe->wqe_index);
|
|
|
|
wq->tail += (u16) (wqe_ctr - (u16) wq->tail);
|
|
|
|
}
|
2007-06-18 23:13:48 +08:00
|
|
|
wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
|
2007-05-09 09:00:38 +08:00
|
|
|
++wq->tail;
|
|
|
|
} else if ((*cur_qp)->ibqp.srq) {
|
|
|
|
srq = to_msrq((*cur_qp)->ibqp.srq);
|
|
|
|
wqe_ctr = be16_to_cpu(cqe->wqe_index);
|
|
|
|
wc->wr_id = srq->wrid[wqe_ctr];
|
|
|
|
mlx4_ib_free_srq_wqe(srq, wqe_ctr);
|
2013-04-10 22:26:48 +08:00
|
|
|
} else if (msrq) {
|
|
|
|
srq = to_mibsrq(msrq);
|
|
|
|
wqe_ctr = be16_to_cpu(cqe->wqe_index);
|
|
|
|
wc->wr_id = srq->wrid[wqe_ctr];
|
|
|
|
mlx4_ib_free_srq_wqe(srq, wqe_ctr);
|
2007-05-09 09:00:38 +08:00
|
|
|
} else {
|
|
|
|
wq = &(*cur_qp)->rq;
|
2012-08-03 16:40:40 +08:00
|
|
|
tail = wq->tail & (wq->wqe_cnt - 1);
|
|
|
|
wc->wr_id = wq->wrid[tail];
|
2007-05-09 09:00:38 +08:00
|
|
|
++wq->tail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(is_error)) {
|
|
|
|
mlx4_ib_handle_error_cqe((struct mlx4_err_cqe *) cqe, wc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
wc->status = IB_WC_SUCCESS;
|
|
|
|
|
|
|
|
if (is_send) {
|
|
|
|
wc->wc_flags = 0;
|
|
|
|
switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
|
|
|
|
case MLX4_OPCODE_RDMA_WRITE_IMM:
|
|
|
|
wc->wc_flags |= IB_WC_WITH_IMM;
|
|
|
|
case MLX4_OPCODE_RDMA_WRITE:
|
|
|
|
wc->opcode = IB_WC_RDMA_WRITE;
|
|
|
|
break;
|
|
|
|
case MLX4_OPCODE_SEND_IMM:
|
|
|
|
wc->wc_flags |= IB_WC_WITH_IMM;
|
|
|
|
case MLX4_OPCODE_SEND:
|
2008-07-23 23:12:26 +08:00
|
|
|
case MLX4_OPCODE_SEND_INVAL:
|
2007-05-09 09:00:38 +08:00
|
|
|
wc->opcode = IB_WC_SEND;
|
|
|
|
break;
|
|
|
|
case MLX4_OPCODE_RDMA_READ:
|
2007-08-04 05:25:48 +08:00
|
|
|
wc->opcode = IB_WC_RDMA_READ;
|
2007-05-09 09:00:38 +08:00
|
|
|
wc->byte_len = be32_to_cpu(cqe->byte_cnt);
|
|
|
|
break;
|
|
|
|
case MLX4_OPCODE_ATOMIC_CS:
|
|
|
|
wc->opcode = IB_WC_COMP_SWAP;
|
|
|
|
wc->byte_len = 8;
|
|
|
|
break;
|
|
|
|
case MLX4_OPCODE_ATOMIC_FA:
|
|
|
|
wc->opcode = IB_WC_FETCH_ADD;
|
|
|
|
wc->byte_len = 8;
|
|
|
|
break;
|
2010-04-14 22:23:39 +08:00
|
|
|
case MLX4_OPCODE_MASKED_ATOMIC_CS:
|
|
|
|
wc->opcode = IB_WC_MASKED_COMP_SWAP;
|
|
|
|
wc->byte_len = 8;
|
|
|
|
break;
|
|
|
|
case MLX4_OPCODE_MASKED_ATOMIC_FA:
|
|
|
|
wc->opcode = IB_WC_MASKED_FETCH_ADD;
|
|
|
|
wc->byte_len = 8;
|
|
|
|
break;
|
2007-05-09 09:00:38 +08:00
|
|
|
case MLX4_OPCODE_BIND_MW:
|
|
|
|
wc->opcode = IB_WC_BIND_MW;
|
|
|
|
break;
|
2008-04-17 12:09:27 +08:00
|
|
|
case MLX4_OPCODE_LSO:
|
|
|
|
wc->opcode = IB_WC_LSO;
|
|
|
|
break;
|
2008-07-23 23:12:26 +08:00
|
|
|
case MLX4_OPCODE_FMR:
|
|
|
|
wc->opcode = IB_WC_FAST_REG_MR;
|
|
|
|
break;
|
|
|
|
case MLX4_OPCODE_LOCAL_INVAL:
|
|
|
|
wc->opcode = IB_WC_LOCAL_INV;
|
|
|
|
break;
|
2007-05-09 09:00:38 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
wc->byte_len = be32_to_cpu(cqe->byte_cnt);
|
|
|
|
|
|
|
|
switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
|
|
|
|
case MLX4_RECV_OPCODE_RDMA_WRITE_IMM:
|
2008-07-15 14:48:45 +08:00
|
|
|
wc->opcode = IB_WC_RECV_RDMA_WITH_IMM;
|
|
|
|
wc->wc_flags = IB_WC_WITH_IMM;
|
|
|
|
wc->ex.imm_data = cqe->immed_rss_invalid;
|
2007-05-09 09:00:38 +08:00
|
|
|
break;
|
2008-07-23 23:12:26 +08:00
|
|
|
case MLX4_RECV_OPCODE_SEND_INVAL:
|
|
|
|
wc->opcode = IB_WC_RECV;
|
|
|
|
wc->wc_flags = IB_WC_WITH_INVALIDATE;
|
|
|
|
wc->ex.invalidate_rkey = be32_to_cpu(cqe->immed_rss_invalid);
|
|
|
|
break;
|
2007-05-09 09:00:38 +08:00
|
|
|
case MLX4_RECV_OPCODE_SEND:
|
|
|
|
wc->opcode = IB_WC_RECV;
|
|
|
|
wc->wc_flags = 0;
|
|
|
|
break;
|
|
|
|
case MLX4_RECV_OPCODE_SEND_IMM:
|
2008-07-15 14:48:45 +08:00
|
|
|
wc->opcode = IB_WC_RECV;
|
|
|
|
wc->wc_flags = IB_WC_WITH_IMM;
|
|
|
|
wc->ex.imm_data = cqe->immed_rss_invalid;
|
2007-05-09 09:00:38 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
is_eth = (rdma_port_get_link_layer(wc->qp->device,
|
|
|
|
(*cur_qp)->port) ==
|
|
|
|
IB_LINK_LAYER_ETHERNET);
|
2012-08-03 16:40:40 +08:00
|
|
|
if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
|
|
|
|
if ((*cur_qp)->mlx4_ib_qp_type &
|
|
|
|
(MLX4_IB_QPT_PROXY_SMI_OWNER |
|
|
|
|
MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI))
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
return use_tunnel_data(*cur_qp, cq, wc, tail,
|
|
|
|
cqe, is_eth);
|
2012-08-03 16:40:40 +08:00
|
|
|
}
|
|
|
|
|
2007-05-09 09:00:38 +08:00
|
|
|
wc->slid = be16_to_cpu(cqe->rlid);
|
2008-01-26 06:15:34 +08:00
|
|
|
g_mlpath_rqpn = be32_to_cpu(cqe->g_mlpath_rqpn);
|
|
|
|
wc->src_qp = g_mlpath_rqpn & 0xffffff;
|
|
|
|
wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f;
|
|
|
|
wc->wc_flags |= g_mlpath_rqpn & 0x80000000 ? IB_WC_GRH : 0;
|
2008-01-07 15:01:25 +08:00
|
|
|
wc->pkey_index = be32_to_cpu(cqe->immed_rss_invalid) & 0x7f;
|
2012-01-12 01:03:51 +08:00
|
|
|
wc->wc_flags |= mlx4_ib_ipoib_csum_ok(cqe->status,
|
|
|
|
cqe->checksum) ? IB_WC_IP_CSUM_OK : 0;
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
if (is_eth) {
|
2011-12-11 22:40:05 +08:00
|
|
|
wc->sl = be16_to_cpu(cqe->sl_vid) >> 13;
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
if (be32_to_cpu(cqe->vlan_my_qpn) &
|
|
|
|
MLX4_CQE_VLAN_PRESENT_MASK) {
|
|
|
|
wc->vlan_id = be16_to_cpu(cqe->sl_vid) &
|
|
|
|
MLX4_CQE_VID_MASK;
|
|
|
|
} else {
|
|
|
|
wc->vlan_id = 0xffff;
|
|
|
|
}
|
|
|
|
memcpy(wc->smac, cqe->smac, ETH_ALEN);
|
|
|
|
wc->wc_flags |= (IB_WC_WITH_VLAN | IB_WC_WITH_SMAC);
|
2013-12-13 00:03:14 +08:00
|
|
|
} else {
|
mlx4: Implement IP based gids support for RoCE/SRIOV
Since there is no connection between the MAC/VLAN and the GID
when using IP-based addressing, the proxy QP1 (running on the
slave) must pass the source-mac, destination-mac, and vlan_id
information separately from the GID. Additionally, the Host
must pass the remote source-mac and vlan_id back to the slave,
This is achieved as follows:
Outgoing MADs:
1. Source MAC: obtained from the CQ completion structure
(struct ib_wc, smac field).
2. Destination MAC: obtained from the tunnel header
3. vlan_id: obtained from the tunnel header.
Incoming MADs
1. The source (i.e., remote) MAC and vlan_id are passed in
the tunnel header to the proxy QP1.
VST mode support:
For outgoing MADs, the vlan_id obtained from the header is
discarded, and the vlan_id specified by the Hypervisor is used
instead.
For incoming MADs, the incoming vlan_id (in the wc) is discarded, and the
"invalid" vlan (0xffff) is substituted when forwarding to the slave.
Signed-off-by: Moni Shoua <monis@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-12 18:00:41 +08:00
|
|
|
wc->sl = be16_to_cpu(cqe->sl_vid) >> 12;
|
2013-12-13 00:03:14 +08:00
|
|
|
wc->vlan_id = 0xffff;
|
|
|
|
}
|
2007-05-09 09:00:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
|
|
|
|
{
|
|
|
|
struct mlx4_ib_cq *cq = to_mcq(ibcq);
|
|
|
|
struct mlx4_ib_qp *cur_qp = NULL;
|
|
|
|
unsigned long flags;
|
|
|
|
int npolled;
|
|
|
|
int err = 0;
|
2015-02-08 17:49:34 +08:00
|
|
|
struct mlx4_ib_dev *mdev = to_mdev(cq->ibcq.device);
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
spin_lock_irqsave(&cq->lock, flags);
|
2015-02-08 17:49:34 +08:00
|
|
|
if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) {
|
|
|
|
mlx4_ib_poll_sw_comp(cq, num_entries, wc, &npolled);
|
|
|
|
goto out;
|
|
|
|
}
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
for (npolled = 0; npolled < num_entries; ++npolled) {
|
|
|
|
err = mlx4_ib_poll_one(cq, &cur_qp, wc + npolled);
|
|
|
|
if (err)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-06 21:50:51 +08:00
|
|
|
mlx4_cq_set_ci(&cq->mcq);
|
2007-05-09 09:00:38 +08:00
|
|
|
|
2015-02-08 17:49:34 +08:00
|
|
|
out:
|
2007-05-09 09:00:38 +08:00
|
|
|
spin_unlock_irqrestore(&cq->lock, flags);
|
|
|
|
|
|
|
|
if (err == 0 || err == -EAGAIN)
|
|
|
|
return npolled;
|
|
|
|
else
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mlx4_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
|
|
|
|
{
|
|
|
|
mlx4_cq_arm(&to_mcq(ibcq)->mcq,
|
|
|
|
(flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
|
|
|
|
MLX4_CQ_DB_REQ_NOT_SOL : MLX4_CQ_DB_REQ_NOT,
|
|
|
|
to_mdev(ibcq->device)->uar_map,
|
|
|
|
MLX4_GET_DOORBELL_LOCK(&to_mdev(ibcq->device)->uar_lock));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq)
|
|
|
|
{
|
|
|
|
u32 prod_index;
|
|
|
|
int nfreed = 0;
|
2007-06-18 23:13:59 +08:00
|
|
|
struct mlx4_cqe *cqe, *dest;
|
|
|
|
u8 owner_bit;
|
2012-10-21 22:59:24 +08:00
|
|
|
int cqe_inc = cq->buf.entry_size == 64 ? 1 : 0;
|
2007-05-09 09:00:38 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First we need to find the current producer index, so we
|
|
|
|
* know where to start cleaning from. It doesn't matter if HW
|
|
|
|
* adds new entries after this loop -- the QP we're worried
|
|
|
|
* about is already in RESET, so the new entries won't come
|
|
|
|
* from our QP and therefore don't need to be checked.
|
|
|
|
*/
|
|
|
|
for (prod_index = cq->mcq.cons_index; get_sw_cqe(cq, prod_index); ++prod_index)
|
|
|
|
if (prod_index == cq->mcq.cons_index + cq->ibcq.cqe)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now sweep backwards through the CQ, removing CQ entries
|
|
|
|
* that match our QP by copying older entries on top of them.
|
|
|
|
*/
|
|
|
|
while ((int) --prod_index - (int) cq->mcq.cons_index >= 0) {
|
|
|
|
cqe = get_cqe(cq, prod_index & cq->ibcq.cqe);
|
2012-10-21 22:59:24 +08:00
|
|
|
cqe += cqe_inc;
|
|
|
|
|
2008-08-07 11:14:06 +08:00
|
|
|
if ((be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK) == qpn) {
|
2007-05-09 09:00:38 +08:00
|
|
|
if (srq && !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK))
|
|
|
|
mlx4_ib_free_srq_wqe(srq, be16_to_cpu(cqe->wqe_index));
|
|
|
|
++nfreed;
|
2007-06-18 23:13:59 +08:00
|
|
|
} else if (nfreed) {
|
|
|
|
dest = get_cqe(cq, (prod_index + nfreed) & cq->ibcq.cqe);
|
2012-10-21 22:59:24 +08:00
|
|
|
dest += cqe_inc;
|
|
|
|
|
2007-06-18 23:13:59 +08:00
|
|
|
owner_bit = dest->owner_sr_opcode & MLX4_CQE_OWNER_MASK;
|
|
|
|
memcpy(dest, cqe, sizeof *cqe);
|
|
|
|
dest->owner_sr_opcode = owner_bit |
|
|
|
|
(dest->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK);
|
|
|
|
}
|
2007-05-09 09:00:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nfreed) {
|
|
|
|
cq->mcq.cons_index += nfreed;
|
|
|
|
/*
|
|
|
|
* Make sure update of buffer contents is done before
|
|
|
|
* updating consumer index.
|
|
|
|
*/
|
|
|
|
wmb();
|
|
|
|
mlx4_cq_set_ci(&cq->mcq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq)
|
|
|
|
{
|
|
|
|
spin_lock_irq(&cq->lock);
|
|
|
|
__mlx4_ib_cq_clean(cq, qpn, srq);
|
|
|
|
spin_unlock_irq(&cq->lock);
|
|
|
|
}
|