2007-05-09 08:00:38 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004 Topspin Communications. All rights reserved.
|
|
|
|
* Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
|
2008-07-26 00:32:52 +07:00
|
|
|
* Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
|
2007-05-09 08:00:38 +07:00
|
|
|
* Copyright (c) 2004 Voltaire, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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/gfp.h>
|
2011-05-28 03:14:23 +07:00
|
|
|
#include <linux/export.h>
|
2011-12-13 11:13:22 +07:00
|
|
|
|
2007-05-09 08:00:38 +07:00
|
|
|
#include <linux/mlx4/cmd.h>
|
|
|
|
#include <linux/mlx4/qp.h>
|
|
|
|
|
|
|
|
#include "mlx4.h"
|
|
|
|
#include "icm.h"
|
|
|
|
|
|
|
|
void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type)
|
|
|
|
{
|
|
|
|
struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
|
|
|
|
struct mlx4_qp *qp;
|
|
|
|
|
|
|
|
spin_lock(&qp_table->lock);
|
|
|
|
|
|
|
|
qp = __mlx4_qp_lookup(dev, qpn);
|
|
|
|
if (qp)
|
|
|
|
atomic_inc(&qp->refcount);
|
|
|
|
|
|
|
|
spin_unlock(&qp_table->lock);
|
|
|
|
|
|
|
|
if (!qp) {
|
2011-12-13 11:13:22 +07:00
|
|
|
mlx4_dbg(dev, "Async event for none existent QP %08x\n", qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qp->event(qp, event_type);
|
|
|
|
|
|
|
|
if (atomic_dec_and_test(&qp->refcount))
|
|
|
|
complete(&qp->free);
|
|
|
|
}
|
|
|
|
|
2012-08-03 15:40:53 +07:00
|
|
|
/* used for INIT/CLOSE port logic */
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
static int is_master_qp0(struct mlx4_dev *dev, struct mlx4_qp *qp, int *real_qp0, int *proxy_qp0)
|
2011-12-13 11:13:22 +07:00
|
|
|
{
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
/* this procedure is called after we already know we are on the master */
|
2012-08-03 15:40:53 +07:00
|
|
|
/* qp0 is either the proxy qp0, or the real qp0 */
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
u32 pf_proxy_offset = dev->phys_caps.base_proxy_sqpn + 8 * mlx4_master_func_num(dev);
|
|
|
|
*proxy_qp0 = qp->qpn >= pf_proxy_offset && qp->qpn <= pf_proxy_offset + 1;
|
2012-08-03 15:40:53 +07:00
|
|
|
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
*real_qp0 = qp->qpn >= dev->phys_caps.base_sqpn &&
|
|
|
|
qp->qpn <= dev->phys_caps.base_sqpn + 1;
|
2012-08-03 15:40:53 +07:00
|
|
|
|
|
|
|
return *real_qp0 || *proxy_qp0;
|
2011-12-13 11:13:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
|
|
|
enum mlx4_qp_state cur_state, enum mlx4_qp_state new_state,
|
|
|
|
struct mlx4_qp_context *context,
|
|
|
|
enum mlx4_qp_optpar optpar,
|
|
|
|
int sqd_event, struct mlx4_qp *qp, int native)
|
2007-05-09 08:00:38 +07:00
|
|
|
{
|
|
|
|
static const u16 op[MLX4_QP_NUM_STATE][MLX4_QP_NUM_STATE] = {
|
|
|
|
[MLX4_QP_STATE_RST] = {
|
|
|
|
[MLX4_QP_STATE_RST] = MLX4_CMD_2RST_QP,
|
|
|
|
[MLX4_QP_STATE_ERR] = MLX4_CMD_2ERR_QP,
|
|
|
|
[MLX4_QP_STATE_INIT] = MLX4_CMD_RST2INIT_QP,
|
|
|
|
},
|
|
|
|
[MLX4_QP_STATE_INIT] = {
|
|
|
|
[MLX4_QP_STATE_RST] = MLX4_CMD_2RST_QP,
|
|
|
|
[MLX4_QP_STATE_ERR] = MLX4_CMD_2ERR_QP,
|
|
|
|
[MLX4_QP_STATE_INIT] = MLX4_CMD_INIT2INIT_QP,
|
|
|
|
[MLX4_QP_STATE_RTR] = MLX4_CMD_INIT2RTR_QP,
|
|
|
|
},
|
|
|
|
[MLX4_QP_STATE_RTR] = {
|
|
|
|
[MLX4_QP_STATE_RST] = MLX4_CMD_2RST_QP,
|
|
|
|
[MLX4_QP_STATE_ERR] = MLX4_CMD_2ERR_QP,
|
|
|
|
[MLX4_QP_STATE_RTS] = MLX4_CMD_RTR2RTS_QP,
|
|
|
|
},
|
|
|
|
[MLX4_QP_STATE_RTS] = {
|
|
|
|
[MLX4_QP_STATE_RST] = MLX4_CMD_2RST_QP,
|
|
|
|
[MLX4_QP_STATE_ERR] = MLX4_CMD_2ERR_QP,
|
|
|
|
[MLX4_QP_STATE_RTS] = MLX4_CMD_RTS2RTS_QP,
|
|
|
|
[MLX4_QP_STATE_SQD] = MLX4_CMD_RTS2SQD_QP,
|
|
|
|
},
|
|
|
|
[MLX4_QP_STATE_SQD] = {
|
|
|
|
[MLX4_QP_STATE_RST] = MLX4_CMD_2RST_QP,
|
|
|
|
[MLX4_QP_STATE_ERR] = MLX4_CMD_2ERR_QP,
|
|
|
|
[MLX4_QP_STATE_RTS] = MLX4_CMD_SQD2RTS_QP,
|
|
|
|
[MLX4_QP_STATE_SQD] = MLX4_CMD_SQD2SQD_QP,
|
|
|
|
},
|
|
|
|
[MLX4_QP_STATE_SQER] = {
|
|
|
|
[MLX4_QP_STATE_RST] = MLX4_CMD_2RST_QP,
|
|
|
|
[MLX4_QP_STATE_ERR] = MLX4_CMD_2ERR_QP,
|
|
|
|
[MLX4_QP_STATE_RTS] = MLX4_CMD_SQERR2RTS_QP,
|
|
|
|
},
|
|
|
|
[MLX4_QP_STATE_ERR] = {
|
|
|
|
[MLX4_QP_STATE_RST] = MLX4_CMD_2RST_QP,
|
|
|
|
[MLX4_QP_STATE_ERR] = MLX4_CMD_2ERR_QP,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
2007-05-09 08:00:38 +07:00
|
|
|
struct mlx4_cmd_mailbox *mailbox;
|
|
|
|
int ret = 0;
|
2012-08-03 15:40:53 +07:00
|
|
|
int real_qp0 = 0;
|
|
|
|
int proxy_qp0 = 0;
|
2011-12-13 11:13:22 +07:00
|
|
|
u8 port;
|
2007-05-09 08:00:38 +07:00
|
|
|
|
2007-11-21 04:01:28 +07:00
|
|
|
if (cur_state >= MLX4_QP_NUM_STATE || new_state >= MLX4_QP_NUM_STATE ||
|
2007-05-09 08:00:38 +07:00
|
|
|
!op[cur_state][new_state])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
if (op[cur_state][new_state] == MLX4_CMD_2RST_QP) {
|
|
|
|
ret = mlx4_cmd(dev, 0, qp->qpn, 2,
|
|
|
|
MLX4_CMD_2RST_QP, MLX4_CMD_TIME_CLASS_A, native);
|
|
|
|
if (mlx4_is_master(dev) && cur_state != MLX4_QP_STATE_ERR &&
|
|
|
|
cur_state != MLX4_QP_STATE_RST &&
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
is_master_qp0(dev, qp, &real_qp0, &proxy_qp0)) {
|
2011-12-13 11:13:22 +07:00
|
|
|
port = (qp->qpn & 1) + 1;
|
2012-08-03 15:40:53 +07:00
|
|
|
if (proxy_qp0)
|
|
|
|
priv->mfunc.master.qp0_state[port].proxy_qp0_active = 0;
|
|
|
|
else
|
|
|
|
priv->mfunc.master.qp0_state[port].qp0_active = 0;
|
2011-12-13 11:13:22 +07:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2007-05-09 08:00:38 +07:00
|
|
|
|
|
|
|
mailbox = mlx4_alloc_cmd_mailbox(dev);
|
|
|
|
if (IS_ERR(mailbox))
|
|
|
|
return PTR_ERR(mailbox);
|
|
|
|
|
|
|
|
if (cur_state == MLX4_QP_STATE_RST && new_state == MLX4_QP_STATE_INIT) {
|
|
|
|
u64 mtt_addr = mlx4_mtt_addr(dev, mtt);
|
|
|
|
context->mtt_base_addr_h = mtt_addr >> 32;
|
|
|
|
context->mtt_base_addr_l = cpu_to_be32(mtt_addr & 0xffffffff);
|
|
|
|
context->log_page_size = mtt->page_shift - MLX4_ICM_PAGE_SHIFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
*(__be32 *) mailbox->buf = cpu_to_be32(optpar);
|
|
|
|
memcpy(mailbox->buf + 8, context, sizeof *context);
|
|
|
|
|
|
|
|
((struct mlx4_qp_context *) (mailbox->buf + 8))->local_qpn =
|
|
|
|
cpu_to_be32(qp->qpn);
|
|
|
|
|
2012-01-19 16:45:19 +07:00
|
|
|
ret = mlx4_cmd(dev, mailbox->dma,
|
2011-12-13 11:13:22 +07:00
|
|
|
qp->qpn | (!!sqd_event << 31),
|
2007-05-09 08:00:38 +07:00
|
|
|
new_state == MLX4_QP_STATE_RST ? 2 : 0,
|
2011-12-13 11:13:22 +07:00
|
|
|
op[cur_state][new_state], MLX4_CMD_TIME_CLASS_C, native);
|
2007-05-09 08:00:38 +07:00
|
|
|
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
if (mlx4_is_master(dev) && is_master_qp0(dev, qp, &real_qp0, &proxy_qp0)) {
|
2012-08-03 15:40:53 +07:00
|
|
|
port = (qp->qpn & 1) + 1;
|
|
|
|
if (cur_state != MLX4_QP_STATE_ERR &&
|
|
|
|
cur_state != MLX4_QP_STATE_RST &&
|
|
|
|
new_state == MLX4_QP_STATE_ERR) {
|
|
|
|
if (proxy_qp0)
|
|
|
|
priv->mfunc.master.qp0_state[port].proxy_qp0_active = 0;
|
|
|
|
else
|
|
|
|
priv->mfunc.master.qp0_state[port].qp0_active = 0;
|
|
|
|
} else if (new_state == MLX4_QP_STATE_RTR) {
|
|
|
|
if (proxy_qp0)
|
|
|
|
priv->mfunc.master.qp0_state[port].proxy_qp0_active = 1;
|
|
|
|
else
|
|
|
|
priv->mfunc.master.qp0_state[port].qp0_active = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-09 08:00:38 +07:00
|
|
|
mlx4_free_cmd_mailbox(dev, mailbox);
|
|
|
|
return ret;
|
|
|
|
}
|
2011-12-13 11:13:22 +07:00
|
|
|
|
|
|
|
int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
|
|
|
enum mlx4_qp_state cur_state, enum mlx4_qp_state new_state,
|
|
|
|
struct mlx4_qp_context *context,
|
|
|
|
enum mlx4_qp_optpar optpar,
|
|
|
|
int sqd_event, struct mlx4_qp *qp)
|
|
|
|
{
|
|
|
|
return __mlx4_qp_modify(dev, mtt, cur_state, new_state, context,
|
|
|
|
optpar, sqd_event, qp, 0);
|
|
|
|
}
|
2007-05-09 08:00:38 +07:00
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_modify);
|
|
|
|
|
mlx4_core: resource tracking for HCA resources used by guests
The resource tracker is used to track usage of HCA resources by the different
guests.
Virtual functions (VFs) are attached to guest operating systems but
resources are allocated from the same pool and are assigned to VFs. It is
essential that hostile/buggy guests not be able to affect the operation of
other VFs, possibly attached to other guest OSs since ConnectX firmware is not
tolerant to misuse of resources.
The resource tracker module associates each resource with a VF and maintains
state information for the allocated object. It also defines allowed state
transitions and enforces them.
Relationships between resources are also referred to. For example, CQs are
pointed to by QPs, so it is forbidden to destroy a CQ if a QP refers to it.
ICM memory is always accessible through the primary function and hence it is
allocated by the owner of the primary function.
When a guest dies, an FLR is generated for all the VFs it owns and all the
resources it used are freed.
The tracked resource types are: QPs, CQs, SRQs, MPTs, MTTs, MACs, RES_EQs,
and XRCDNs.
Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-12-13 11:15:24 +07:00
|
|
|
int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
|
2011-12-13 11:13:22 +07:00
|
|
|
int *base)
|
2008-10-11 02:01:37 +07:00
|
|
|
{
|
|
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
|
|
|
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
*base = mlx4_bitmap_alloc_range(&qp_table->bitmap, cnt, align);
|
|
|
|
if (*base == -1)
|
2008-10-11 02:01:37 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-12-13 11:13:22 +07:00
|
|
|
|
|
|
|
int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, int *base)
|
|
|
|
{
|
2013-03-07 10:46:54 +07:00
|
|
|
u64 in_param = 0;
|
2011-12-13 11:13:22 +07:00
|
|
|
u64 out_param;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (mlx4_is_mfunc(dev)) {
|
|
|
|
set_param_l(&in_param, cnt);
|
|
|
|
set_param_h(&in_param, align);
|
|
|
|
err = mlx4_cmd_imm(dev, in_param, &out_param,
|
|
|
|
RES_QP, RES_OP_RESERVE,
|
|
|
|
MLX4_CMD_ALLOC_RES,
|
|
|
|
MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
*base = get_param_l(&out_param);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return __mlx4_qp_reserve_range(dev, cnt, align, base);
|
|
|
|
}
|
2008-10-11 02:01:37 +07:00
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_reserve_range);
|
|
|
|
|
mlx4_core: resource tracking for HCA resources used by guests
The resource tracker is used to track usage of HCA resources by the different
guests.
Virtual functions (VFs) are attached to guest operating systems but
resources are allocated from the same pool and are assigned to VFs. It is
essential that hostile/buggy guests not be able to affect the operation of
other VFs, possibly attached to other guest OSs since ConnectX firmware is not
tolerant to misuse of resources.
The resource tracker module associates each resource with a VF and maintains
state information for the allocated object. It also defines allowed state
transitions and enforces them.
Relationships between resources are also referred to. For example, CQs are
pointed to by QPs, so it is forbidden to destroy a CQ if a QP refers to it.
ICM memory is always accessible through the primary function and hence it is
allocated by the owner of the primary function.
When a guest dies, an FLR is generated for all the VFs it owns and all the
resources it used are freed.
The tracked resource types are: QPs, CQs, SRQs, MPTs, MTTs, MACs, RES_EQs,
and XRCDNs.
Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-12-13 11:15:24 +07:00
|
|
|
void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt)
|
2008-10-11 02:01:37 +07:00
|
|
|
{
|
|
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
|
|
|
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
if (mlx4_is_qp_reserved(dev, (u32) base_qpn))
|
|
|
|
return;
|
mlx4_core: Roll back round robin bitmap allocation commit for CQs, SRQs, and MPTs
Commit f4ec9e9 "mlx4_core: Change bitmap allocator to work in round-robin fashion"
introduced round-robin allocation (via bitmap) for all resources which allocate
via a bitmap.
Round robin allocation is desirable for mcgs, counters, pd's, UARs, and xrcds.
These are simply numbers, with no involvement of ICM memory mapping.
Round robin is required for QPs, since we had a problem with immediate
reuse of a 24-bit QP number (commit f4ec9e9).
However, for other resources which use the bitmap allocator and involve
mapping ICM memory -- MPTs, CQs, SRQs -- round-robin is not desirable.
What happens in these cases is the following:
ICM memory is allocated and mapped in chunks of 256K.
Since the resource allocation index goes up monotonically, the allocator
will eventually require mapping a new chunk. Now, chunks are also unmapped
when their reference count goes back to zero. Thus, if a single app is
running and starts/exits frequently we will have the following situation:
When the app starts, a new chunk must be allocated and mapped.
When the app exits, the chunk reference count goes back to zero, and the
chunk is unmapped and freed. Therefore, the app must pay the cost of allocation
and mapping of ICM memory each time it runs (although the price is paid only when
allocating the initial entry in the new chunk).
For apps which allocate MPTs/SRQs/CQs and which operate as described above,
this presented a performance problem.
We therefore roll back the round-robin allocator modification for MPTs, CQs, SRQs.
Reported-by: Matthew Finlay <matt@mellanox.com>
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>
2013-12-08 21:50:17 +07:00
|
|
|
mlx4_bitmap_free_range(&qp_table->bitmap, base_qpn, cnt, MLX4_USE_RR);
|
2008-10-11 02:01:37 +07:00
|
|
|
}
|
2011-12-13 11:13:22 +07:00
|
|
|
|
|
|
|
void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt)
|
|
|
|
{
|
2013-03-07 10:46:54 +07:00
|
|
|
u64 in_param = 0;
|
2011-12-13 11:13:22 +07:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (mlx4_is_mfunc(dev)) {
|
|
|
|
set_param_l(&in_param, base_qpn);
|
|
|
|
set_param_h(&in_param, cnt);
|
|
|
|
err = mlx4_cmd(dev, in_param, RES_QP, RES_OP_RESERVE,
|
|
|
|
MLX4_CMD_FREE_RES,
|
|
|
|
MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED);
|
|
|
|
if (err) {
|
|
|
|
mlx4_warn(dev, "Failed to release qp range"
|
|
|
|
" base:%d cnt:%d\n", base_qpn, cnt);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
__mlx4_qp_release_range(dev, base_qpn, cnt);
|
|
|
|
}
|
2008-10-11 02:01:37 +07:00
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_release_range);
|
|
|
|
|
mlx4_core: resource tracking for HCA resources used by guests
The resource tracker is used to track usage of HCA resources by the different
guests.
Virtual functions (VFs) are attached to guest operating systems but
resources are allocated from the same pool and are assigned to VFs. It is
essential that hostile/buggy guests not be able to affect the operation of
other VFs, possibly attached to other guest OSs since ConnectX firmware is not
tolerant to misuse of resources.
The resource tracker module associates each resource with a VF and maintains
state information for the allocated object. It also defines allowed state
transitions and enforces them.
Relationships between resources are also referred to. For example, CQs are
pointed to by QPs, so it is forbidden to destroy a CQ if a QP refers to it.
ICM memory is always accessible through the primary function and hence it is
allocated by the owner of the primary function.
When a guest dies, an FLR is generated for all the VFs it owns and all the
resources it used are freed.
The tracked resource types are: QPs, CQs, SRQs, MPTs, MTTs, MACs, RES_EQs,
and XRCDNs.
Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-12-13 11:15:24 +07:00
|
|
|
int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn)
|
2007-05-09 08:00:38 +07:00
|
|
|
{
|
|
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
|
|
|
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
|
|
|
int err;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
err = mlx4_table_get(dev, &qp_table->qp_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
err = mlx4_table_get(dev, &qp_table->auxc_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
if (err)
|
|
|
|
goto err_put_qp;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
err = mlx4_table_get(dev, &qp_table->altc_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
if (err)
|
|
|
|
goto err_put_auxc;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
err = mlx4_table_get(dev, &qp_table->rdmarc_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
if (err)
|
|
|
|
goto err_put_altc;
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
err = mlx4_table_get(dev, &qp_table->cmpt_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
if (err)
|
|
|
|
goto err_put_rdmarc;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_put_rdmarc:
|
2011-12-13 11:13:22 +07:00
|
|
|
mlx4_table_put(dev, &qp_table->rdmarc_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
|
|
|
|
err_put_altc:
|
2011-12-13 11:13:22 +07:00
|
|
|
mlx4_table_put(dev, &qp_table->altc_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
|
|
|
|
err_put_auxc:
|
2011-12-13 11:13:22 +07:00
|
|
|
mlx4_table_put(dev, &qp_table->auxc_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
|
|
|
|
err_put_qp:
|
2011-12-13 11:13:22 +07:00
|
|
|
mlx4_table_put(dev, &qp_table->qp_table, qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
|
|
|
|
err_out:
|
|
|
|
return err;
|
|
|
|
}
|
2011-12-13 11:13:22 +07:00
|
|
|
|
|
|
|
static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn)
|
|
|
|
{
|
2013-03-07 10:46:54 +07:00
|
|
|
u64 param = 0;
|
2011-12-13 11:13:22 +07:00
|
|
|
|
|
|
|
if (mlx4_is_mfunc(dev)) {
|
|
|
|
set_param_l(¶m, qpn);
|
|
|
|
return mlx4_cmd_imm(dev, param, ¶m, RES_QP, RES_OP_MAP_ICM,
|
|
|
|
MLX4_CMD_ALLOC_RES, MLX4_CMD_TIME_CLASS_A,
|
|
|
|
MLX4_CMD_WRAPPED);
|
|
|
|
}
|
|
|
|
return __mlx4_qp_alloc_icm(dev, qpn);
|
|
|
|
}
|
|
|
|
|
mlx4_core: resource tracking for HCA resources used by guests
The resource tracker is used to track usage of HCA resources by the different
guests.
Virtual functions (VFs) are attached to guest operating systems but
resources are allocated from the same pool and are assigned to VFs. It is
essential that hostile/buggy guests not be able to affect the operation of
other VFs, possibly attached to other guest OSs since ConnectX firmware is not
tolerant to misuse of resources.
The resource tracker module associates each resource with a VF and maintains
state information for the allocated object. It also defines allowed state
transitions and enforces them.
Relationships between resources are also referred to. For example, CQs are
pointed to by QPs, so it is forbidden to destroy a CQ if a QP refers to it.
ICM memory is always accessible through the primary function and hence it is
allocated by the owner of the primary function.
When a guest dies, an FLR is generated for all the VFs it owns and all the
resources it used are freed.
The tracked resource types are: QPs, CQs, SRQs, MPTs, MTTs, MACs, RES_EQs,
and XRCDNs.
Signed-off-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-12-13 11:15:24 +07:00
|
|
|
void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
|
2011-12-13 11:13:22 +07:00
|
|
|
{
|
|
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
|
|
|
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
|
|
|
|
|
|
|
mlx4_table_put(dev, &qp_table->cmpt_table, qpn);
|
|
|
|
mlx4_table_put(dev, &qp_table->rdmarc_table, qpn);
|
|
|
|
mlx4_table_put(dev, &qp_table->altc_table, qpn);
|
|
|
|
mlx4_table_put(dev, &qp_table->auxc_table, qpn);
|
|
|
|
mlx4_table_put(dev, &qp_table->qp_table, qpn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
|
|
|
|
{
|
2013-03-07 10:46:54 +07:00
|
|
|
u64 in_param = 0;
|
2011-12-13 11:13:22 +07:00
|
|
|
|
|
|
|
if (mlx4_is_mfunc(dev)) {
|
|
|
|
set_param_l(&in_param, qpn);
|
|
|
|
if (mlx4_cmd(dev, in_param, RES_QP, RES_OP_MAP_ICM,
|
|
|
|
MLX4_CMD_FREE_RES, MLX4_CMD_TIME_CLASS_A,
|
|
|
|
MLX4_CMD_WRAPPED))
|
|
|
|
mlx4_warn(dev, "Failed to free icm of qp:%d\n", qpn);
|
|
|
|
} else
|
|
|
|
__mlx4_qp_free_icm(dev, qpn);
|
|
|
|
}
|
|
|
|
|
|
|
|
int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp)
|
|
|
|
{
|
|
|
|
struct mlx4_priv *priv = mlx4_priv(dev);
|
|
|
|
struct mlx4_qp_table *qp_table = &priv->qp_table;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!qpn)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
qp->qpn = qpn;
|
|
|
|
|
|
|
|
err = mlx4_qp_alloc_icm(dev, qpn);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
spin_lock_irq(&qp_table->lock);
|
|
|
|
err = radix_tree_insert(&dev->qp_table_tree, qp->qpn &
|
|
|
|
(dev->caps.num_qps - 1), qp);
|
|
|
|
spin_unlock_irq(&qp_table->lock);
|
|
|
|
if (err)
|
|
|
|
goto err_icm;
|
|
|
|
|
|
|
|
atomic_set(&qp->refcount, 1);
|
|
|
|
init_completion(&qp->free);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_icm:
|
|
|
|
mlx4_qp_free_icm(dev, qpn);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-05-09 08:00:38 +07:00
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_alloc);
|
|
|
|
|
2014-05-15 19:29:27 +07:00
|
|
|
#define MLX4_UPDATE_QP_SUPPORTED_ATTRS MLX4_UPDATE_QP_SMAC
|
|
|
|
int mlx4_update_qp(struct mlx4_dev *dev, struct mlx4_qp *qp,
|
|
|
|
enum mlx4_update_qp_attr attr,
|
|
|
|
struct mlx4_update_qp_params *params)
|
|
|
|
{
|
|
|
|
struct mlx4_cmd_mailbox *mailbox;
|
|
|
|
struct mlx4_update_qp_context *cmd;
|
|
|
|
u64 pri_addr_path_mask = 0;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
mailbox = mlx4_alloc_cmd_mailbox(dev);
|
|
|
|
if (IS_ERR(mailbox))
|
|
|
|
return PTR_ERR(mailbox);
|
|
|
|
|
|
|
|
cmd = (struct mlx4_update_qp_context *)mailbox->buf;
|
|
|
|
|
|
|
|
if (!attr || (attr & ~MLX4_UPDATE_QP_SUPPORTED_ATTRS))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (attr & MLX4_UPDATE_QP_SMAC) {
|
|
|
|
pri_addr_path_mask |= 1ULL << MLX4_UPD_QP_PATH_MASK_MAC_INDEX;
|
|
|
|
cmd->qp_context.pri_path.grh_mylmc = params->smac_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd->primary_addr_path_mask = cpu_to_be64(pri_addr_path_mask);
|
|
|
|
|
|
|
|
err = mlx4_cmd(dev, mailbox->dma, qp->qpn & 0xffffff, 0,
|
|
|
|
MLX4_CMD_UPDATE_QP, MLX4_CMD_TIME_CLASS_A,
|
|
|
|
MLX4_CMD_NATIVE);
|
|
|
|
|
|
|
|
mlx4_free_cmd_mailbox(dev, mailbox);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mlx4_update_qp);
|
|
|
|
|
2007-05-09 08:00:38 +07:00
|
|
|
void mlx4_qp_remove(struct mlx4_dev *dev, struct mlx4_qp *qp)
|
|
|
|
{
|
|
|
|
struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&qp_table->lock, flags);
|
|
|
|
radix_tree_delete(&dev->qp_table_tree, qp->qpn & (dev->caps.num_qps - 1));
|
|
|
|
spin_unlock_irqrestore(&qp_table->lock, flags);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_remove);
|
|
|
|
|
|
|
|
void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp)
|
|
|
|
{
|
|
|
|
if (atomic_dec_and_test(&qp->refcount))
|
|
|
|
complete(&qp->free);
|
|
|
|
wait_for_completion(&qp->free);
|
|
|
|
|
2011-12-13 11:13:22 +07:00
|
|
|
mlx4_qp_free_icm(dev, qp->qpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_free);
|
|
|
|
|
|
|
|
static int mlx4_CONF_SPECIAL_QP(struct mlx4_dev *dev, u32 base_qpn)
|
|
|
|
{
|
|
|
|
return mlx4_cmd(dev, 0, base_qpn, 0, MLX4_CMD_CONF_SPECIAL_QP,
|
2011-12-13 11:10:51 +07:00
|
|
|
MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
|
2007-05-09 08:00:38 +07:00
|
|
|
}
|
|
|
|
|
2007-10-11 05:43:54 +07:00
|
|
|
int mlx4_init_qp_table(struct mlx4_dev *dev)
|
2007-05-09 08:00:38 +07:00
|
|
|
{
|
|
|
|
struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
|
|
|
|
int err;
|
2008-10-23 00:25:29 +07:00
|
|
|
int reserved_from_top = 0;
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
int k;
|
2007-05-09 08:00:38 +07:00
|
|
|
|
|
|
|
spin_lock_init(&qp_table->lock);
|
|
|
|
INIT_RADIX_TREE(&dev->qp_table_tree, GFP_ATOMIC);
|
2011-12-13 11:13:22 +07:00
|
|
|
if (mlx4_is_slave(dev))
|
|
|
|
return 0;
|
2007-05-09 08:00:38 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We reserve 2 extra QPs per port for the special QPs. The
|
|
|
|
* block of special QPs must be aligned to a multiple of 8, so
|
|
|
|
* round up.
|
2011-06-03 01:32:15 +07:00
|
|
|
*
|
|
|
|
* We also reserve the MSB of the 24-bit QP number to indicate
|
|
|
|
* that a QP is an XRC QP.
|
2007-05-09 08:00:38 +07:00
|
|
|
*/
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
dev->phys_caps.base_sqpn =
|
2008-10-23 00:25:29 +07:00
|
|
|
ALIGN(dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW], 8);
|
|
|
|
|
|
|
|
{
|
|
|
|
int sort[MLX4_NUM_QP_REGION];
|
|
|
|
int i, j, tmp;
|
|
|
|
int last_base = dev->caps.num_qps;
|
|
|
|
|
|
|
|
for (i = 1; i < MLX4_NUM_QP_REGION; ++i)
|
|
|
|
sort[i] = i;
|
|
|
|
|
|
|
|
for (i = MLX4_NUM_QP_REGION; i > 0; --i) {
|
|
|
|
for (j = 2; j < i; ++j) {
|
|
|
|
if (dev->caps.reserved_qps_cnt[sort[j]] >
|
|
|
|
dev->caps.reserved_qps_cnt[sort[j - 1]]) {
|
|
|
|
tmp = sort[j];
|
|
|
|
sort[j] = sort[j - 1];
|
|
|
|
sort[j - 1] = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < MLX4_NUM_QP_REGION; ++i) {
|
|
|
|
last_base -= dev->caps.reserved_qps_cnt[sort[i]];
|
|
|
|
dev->caps.reserved_qps_base[sort[i]] = last_base;
|
|
|
|
reserved_from_top +=
|
|
|
|
dev->caps.reserved_qps_cnt[sort[i]];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-03 15:40:41 +07:00
|
|
|
/* Reserve 8 real SQPs in both native and SRIOV modes.
|
|
|
|
* In addition, in SRIOV mode, reserve 8 proxy SQPs per function
|
|
|
|
* (for all PFs and VFs), and 8 corresponding tunnel QPs.
|
|
|
|
* Each proxy SQP works opposite its own tunnel QP.
|
|
|
|
*
|
|
|
|
* The QPs are arranged as follows:
|
|
|
|
* a. 8 real SQPs
|
|
|
|
* b. All the proxy SQPs (8 per function)
|
|
|
|
* c. All the tunnel QPs (8 per function)
|
|
|
|
*/
|
|
|
|
|
2007-05-09 08:00:38 +07:00
|
|
|
err = mlx4_bitmap_init(&qp_table->bitmap, dev->caps.num_qps,
|
mlx4: Structures and init/teardown for VF resource quotas
This is step #1 for implementing SRIOV resource quotas for VFs.
Quotas are implemented per resource type for VFs and the PF, to prevent
any entity from simply grabbing all the resources for itself and leaving
the other entities unable to obtain such resources.
Resources which are allocated using quotas: QPs, CQs, SRQs, MPTs, MTTs, MAC,
VLAN, and Counters.
The quota system works as follows:
Each entity (VF or PF) is given a max number of a given resource (its quota),
and a guaranteed minimum number for each resource (starvation prevention).
For QPs, CQs, SRQs, MPTs and MTTs:
50% of the available quantity for the resource is divided equally among
the PF and all the active VFs (i.e., the number of VFs in the mlx4_core module
parameter "num_vfs"). This 50% represents the "guaranteed minimum" pool.
The other 50% is the "free pool", allocated on a first-come-first-serve basis.
For each VF/PF, resources are first allocated from its "guaranteed-minimum"
pool. When that pool is exhausted, the driver attempts to allocate from
the resource "free-pool".
The quota (i.e., max) for the VFs and the PF is:
The free-pool amount (50% of the real max) + the guaranteed minimum
For MACs:
Guarantee 2 MACs per VF/PF per port. As a result, since we have only
128 MACs per port, reduce the allowable number of VFs from 64 to 63.
Any remaining MACs are put into a free pool.
For VLANs:
For the PF, the per-port quota is 128 and guarantee is 64
(to allow the PF to register at least a VLAN per VF in VST mode).
For the VFs, the per-port quota is 64 and the guarantee is 0.
We assume that VGT VFs are trusted not to abuse the VLAN resource.
For Counters:
For all functions (PF and VFs), the quota is 128 and the guarantee is 0.
In this patch, we define the needed structures, which are added to the
resource-tracker struct. In addition, we do initialization
for the resource quota, and adjust the query_device response to use quotas
rather than resource maxima.
As part of the implementation, we introduce a new field in
mlx4_dev: quotas. This field holds the resource quotas used
to report maxima to the upper layers (ib_core, via query_device).
The HCA maxima of these values are passed to the VFs (via
QUERY_HCA) so that they may continue to use these in handling
QPs, CQs, SRQs and MPTs.
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>
2013-11-03 15:03:23 +07:00
|
|
|
(1 << 23) - 1, mlx4_num_reserved_sqps(dev),
|
2008-10-23 00:25:29 +07:00
|
|
|
reserved_from_top);
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
2012-08-03 15:40:41 +07:00
|
|
|
|
|
|
|
if (mlx4_is_mfunc(dev)) {
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
/* for PPF use */
|
|
|
|
dev->phys_caps.base_proxy_sqpn = dev->phys_caps.base_sqpn + 8;
|
|
|
|
dev->phys_caps.base_tunnel_sqpn = dev->phys_caps.base_sqpn + 8 + 8 * MLX4_MFUNC_MAX;
|
|
|
|
|
|
|
|
/* In mfunc, calculate proxy and tunnel qp offsets for the PF here,
|
|
|
|
* since the PF does not call mlx4_slave_caps */
|
|
|
|
dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
|
|
|
|
dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
|
|
|
|
dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
|
|
|
|
dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports, sizeof (u32), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!dev->caps.qp0_tunnel || !dev->caps.qp0_proxy ||
|
|
|
|
!dev->caps.qp1_tunnel || !dev->caps.qp1_proxy) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_mem;
|
|
|
|
}
|
2012-08-03 15:40:41 +07:00
|
|
|
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
for (k = 0; k < dev->caps.num_ports; k++) {
|
|
|
|
dev->caps.qp0_proxy[k] = dev->phys_caps.base_proxy_sqpn +
|
|
|
|
8 * mlx4_master_func_num(dev) + k;
|
|
|
|
dev->caps.qp0_tunnel[k] = dev->caps.qp0_proxy[k] + 8 * MLX4_MFUNC_MAX;
|
|
|
|
dev->caps.qp1_proxy[k] = dev->phys_caps.base_proxy_sqpn +
|
|
|
|
8 * mlx4_master_func_num(dev) + MLX4_MAX_PORTS + k;
|
|
|
|
dev->caps.qp1_tunnel[k] = dev->caps.qp1_proxy[k] + 8 * MLX4_MFUNC_MAX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = mlx4_CONF_SPECIAL_QP(dev, dev->phys_caps.base_sqpn);
|
2007-05-09 08:00:38 +07:00
|
|
|
if (err)
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
goto err_mem;
|
|
|
|
return 0;
|
2007-05-09 08:00:38 +07:00
|
|
|
|
mlx4: Modify proxy/tunnel QP mechanism so that guests do no calculations
Previously, the structure of a guest's proxy QPs followed the
structure of the PPF special qps (qp0 port 1, qp0 port 2, qp1 port 1,
qp1 port 2, ...). The guest then did offset calculations on the
sqp_base qp number that the PPF passed to it in QUERY_FUNC_CAP().
This is now changed so that the guest does no offset calculations
regarding proxy or tunnel QPs to use. This change frees the PPF from
needing to adhere to a specific order in allocating proxy and tunnel
QPs.
Now QUERY_FUNC_CAP provides each port individually with its proxy
qp0, proxy qp1, tunnel qp0, and tunnel qp1 QP numbers, and these are
used directly where required (with no offset calculations).
To accomplish this change, several fields were added to the phys_caps
structure for use by the PPF and by non-SR-IOV mode:
base_sqpn -- in non-sriov mode, this was formerly sqp_start.
base_proxy_sqpn -- the first physical proxy qp number -- used by PPF
base_tunnel_sqpn -- the first physical tunnel qp number -- used by PPF.
The current code in the PPF still adheres to the previous layout of
sqps, proxy-sqps and tunnel-sqps. However, the PPF can change this
layout without affecting VF or (paravirtualized) PF code.
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
2012-08-03 15:40:57 +07:00
|
|
|
err_mem:
|
|
|
|
kfree(dev->caps.qp0_tunnel);
|
|
|
|
kfree(dev->caps.qp0_proxy);
|
|
|
|
kfree(dev->caps.qp1_tunnel);
|
|
|
|
kfree(dev->caps.qp1_proxy);
|
|
|
|
dev->caps.qp0_tunnel = dev->caps.qp0_proxy =
|
|
|
|
dev->caps.qp1_tunnel = dev->caps.qp1_proxy = NULL;
|
|
|
|
return err;
|
2007-05-09 08:00:38 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void mlx4_cleanup_qp_table(struct mlx4_dev *dev)
|
|
|
|
{
|
2011-12-13 11:13:22 +07:00
|
|
|
if (mlx4_is_slave(dev))
|
|
|
|
return;
|
|
|
|
|
2007-05-09 08:00:38 +07:00
|
|
|
mlx4_CONF_SPECIAL_QP(dev, 0);
|
|
|
|
mlx4_bitmap_cleanup(&mlx4_priv(dev)->qp_table.bitmap);
|
|
|
|
}
|
2007-06-21 16:27:47 +07:00
|
|
|
|
|
|
|
int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
|
|
|
|
struct mlx4_qp_context *context)
|
|
|
|
{
|
|
|
|
struct mlx4_cmd_mailbox *mailbox;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
mailbox = mlx4_alloc_cmd_mailbox(dev);
|
|
|
|
if (IS_ERR(mailbox))
|
|
|
|
return PTR_ERR(mailbox);
|
|
|
|
|
|
|
|
err = mlx4_cmd_box(dev, 0, mailbox->dma, qp->qpn, 0,
|
2011-12-13 11:10:51 +07:00
|
|
|
MLX4_CMD_QUERY_QP, MLX4_CMD_TIME_CLASS_A,
|
|
|
|
MLX4_CMD_WRAPPED);
|
2007-06-21 16:27:47 +07:00
|
|
|
if (!err)
|
|
|
|
memcpy(context, mailbox->buf + 8, sizeof *context);
|
|
|
|
|
|
|
|
mlx4_free_cmd_mailbox(dev, mailbox);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_query);
|
|
|
|
|
2008-04-26 04:52:32 +07:00
|
|
|
int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
|
|
|
|
struct mlx4_qp_context *context,
|
|
|
|
struct mlx4_qp *qp, enum mlx4_qp_state *qp_state)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
int i;
|
|
|
|
enum mlx4_qp_state states[] = {
|
|
|
|
MLX4_QP_STATE_RST,
|
|
|
|
MLX4_QP_STATE_INIT,
|
|
|
|
MLX4_QP_STATE_RTR,
|
|
|
|
MLX4_QP_STATE_RTS
|
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(states) - 1; i++) {
|
|
|
|
context->flags &= cpu_to_be32(~(0xf << 28));
|
|
|
|
context->flags |= cpu_to_be32(states[i + 1] << 28);
|
|
|
|
err = mlx4_qp_modify(dev, mtt, states[i], states[i + 1],
|
|
|
|
context, 0, 0, qp);
|
|
|
|
if (err) {
|
|
|
|
mlx4_err(dev, "Failed to bring QP to state: "
|
|
|
|
"%d with error: %d\n",
|
|
|
|
states[i + 1], err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
*qp_state = states[i + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(mlx4_qp_to_ready);
|