Commit 3ad404b7 authored by Roland Dreier's avatar Roland Dreier Committed by Linus Torvalds

[PATCH] InfiniBand/mthca: pass full process_mad info to firmware

From: "Michael S. Tsirkin" <mst@mellanox.co.il>

Pass full extended MAD information to firmware when a work completion is
supplied to the MAD_IFC command.  This allows B_Key checking/trap generation.
Signed-off-by: default avatarMichael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: default avatarRoland Dreier <roland@topspin.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 187d53a7
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/io.h> #include <asm/io.h>
#include <ib_mad.h>
#include "mthca_dev.h" #include "mthca_dev.h"
#include "mthca_config_reg.h" #include "mthca_config_reg.h"
...@@ -1626,13 +1627,24 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn, ...@@ -1626,13 +1627,24 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
CMD_TIME_CLASS_B, status); CMD_TIME_CLASS_B, status);
} }
int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int port, int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
void *in_mad, void *response_mad, u8 *status) { int port, struct ib_wc* in_wc, struct ib_grh* in_grh,
void *in_mad, void *response_mad, u8 *status)
{
void *box; void *box;
dma_addr_t dma; dma_addr_t dma;
int err; int err;
u32 in_modifier = port;
#define MAD_IFC_BOX_SIZE 512 u8 op_modifier = 0;
#define MAD_IFC_BOX_SIZE 0x400
#define MAD_IFC_MY_QPN_OFFSET 0x100
#define MAD_IFC_RQPN_OFFSET 0x104
#define MAD_IFC_SL_OFFSET 0x108
#define MAD_IFC_G_PATH_OFFSET 0x109
#define MAD_IFC_RLID_OFFSET 0x10a
#define MAD_IFC_PKEY_OFFSET 0x10e
#define MAD_IFC_GRH_OFFSET 0x140
box = pci_alloc_consistent(dev->pdev, MAD_IFC_BOX_SIZE, &dma); box = pci_alloc_consistent(dev->pdev, MAD_IFC_BOX_SIZE, &dma);
if (!box) if (!box)
...@@ -1640,11 +1652,46 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int port, ...@@ -1640,11 +1652,46 @@ int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int port,
memcpy(box, in_mad, 256); memcpy(box, in_mad, 256);
err = mthca_cmd_box(dev, dma, dma + 256, port, !!ignore_mkey, /*
* Key check traps can't be generated unless we have in_wc to
* tell us where to send the trap.
*/
if (ignore_mkey || !in_wc)
op_modifier |= 0x1;
if (ignore_bkey || !in_wc)
op_modifier |= 0x2;
if (in_wc) {
u8 val;
memset(box + 256, 0, 256);
MTHCA_PUT(box, in_wc->qp_num, MAD_IFC_MY_QPN_OFFSET);
MTHCA_PUT(box, in_wc->src_qp, MAD_IFC_RQPN_OFFSET);
val = in_wc->sl << 4;
MTHCA_PUT(box, val, MAD_IFC_SL_OFFSET);
val = in_wc->dlid_path_bits |
(in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
MTHCA_PUT(box, val, MAD_IFC_GRH_OFFSET);
MTHCA_PUT(box, in_wc->slid, MAD_IFC_RLID_OFFSET);
MTHCA_PUT(box, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
if (in_grh)
memcpy((u8 *) box + MAD_IFC_GRH_OFFSET, in_grh, 40);
op_modifier |= 0x10;
in_modifier |= in_wc->slid << 16;
}
err = mthca_cmd_box(dev, dma, dma + 512, in_modifier, op_modifier,
CMD_MAD_IFC, CMD_TIME_CLASS_C, status); CMD_MAD_IFC, CMD_TIME_CLASS_C, status);
if (!err && !*status) if (!err && !*status)
memcpy(response_mad, box + 256, 256); memcpy(response_mad, box + 512, 256);
pci_free_consistent(dev->pdev, MAD_IFC_BOX_SIZE, box, dma); pci_free_consistent(dev->pdev, MAD_IFC_BOX_SIZE, box, dma);
return err; return err;
......
...@@ -280,7 +280,8 @@ int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee, ...@@ -280,7 +280,8 @@ int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
void *qp_context, u8 *status); void *qp_context, u8 *status);
int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn, int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
u8 *status); u8 *status);
int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int port, int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
int port, struct ib_wc* in_wc, struct ib_grh* in_grh,
void *in_mad, void *response_mad, u8 *status); void *in_mad, void *response_mad, u8 *status);
int mthca_READ_MGM(struct mthca_dev *dev, int index, void *mgm, int mthca_READ_MGM(struct mthca_dev *dev, int index, void *mgm,
u8 *status); u8 *status);
......
...@@ -232,8 +232,9 @@ int mthca_process_mad(struct ib_device *ibdev, ...@@ -232,8 +232,9 @@ int mthca_process_mad(struct ib_device *ibdev,
return IB_MAD_RESULT_SUCCESS; return IB_MAD_RESULT_SUCCESS;
err = mthca_MAD_IFC(to_mdev(ibdev), err = mthca_MAD_IFC(to_mdev(ibdev),
!!(mad_flags & IB_MAD_IGNORE_MKEY), mad_flags & IB_MAD_IGNORE_MKEY,
port_num, in_mad, out_mad, mad_flags & IB_MAD_IGNORE_BKEY,
port_num, in_wc, in_grh, in_mad, out_mad,
&status); &status);
if (err) { if (err) {
mthca_err(to_mdev(ibdev), "MAD_IFC failed\n"); mthca_err(to_mdev(ibdev), "MAD_IFC failed\n");
......
...@@ -59,8 +59,8 @@ static int mthca_query_device(struct ib_device *ibdev, ...@@ -59,8 +59,8 @@ static int mthca_query_device(struct ib_device *ibdev,
in_mad->method = IB_MGMT_METHOD_GET; in_mad->method = IB_MGMT_METHOD_GET;
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
err = mthca_MAD_IFC(to_mdev(ibdev), 1, err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
1, in_mad, out_mad, 1, NULL, NULL, in_mad, out_mad,
&status); &status);
if (err) if (err)
goto out; goto out;
...@@ -104,8 +104,8 @@ static int mthca_query_port(struct ib_device *ibdev, ...@@ -104,8 +104,8 @@ static int mthca_query_port(struct ib_device *ibdev,
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->attr_mod = cpu_to_be32(port); in_mad->attr_mod = cpu_to_be32(port);
err = mthca_MAD_IFC(to_mdev(ibdev), 1, err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
port, in_mad, out_mad, port, NULL, NULL, in_mad, out_mad,
&status); &status);
if (err) if (err)
goto out; goto out;
...@@ -189,8 +189,8 @@ static int mthca_query_pkey(struct ib_device *ibdev, ...@@ -189,8 +189,8 @@ static int mthca_query_pkey(struct ib_device *ibdev,
in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE; in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
in_mad->attr_mod = cpu_to_be32(index / 32); in_mad->attr_mod = cpu_to_be32(index / 32);
err = mthca_MAD_IFC(to_mdev(ibdev), 1, err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
port, in_mad, out_mad, port, NULL, NULL, in_mad, out_mad,
&status); &status);
if (err) if (err)
goto out; goto out;
...@@ -228,8 +228,8 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port, ...@@ -228,8 +228,8 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO; in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
in_mad->attr_mod = cpu_to_be32(port); in_mad->attr_mod = cpu_to_be32(port);
err = mthca_MAD_IFC(to_mdev(ibdev), 1, err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
port, in_mad, out_mad, port, NULL, NULL, in_mad, out_mad,
&status); &status);
if (err) if (err)
goto out; goto out;
...@@ -248,8 +248,8 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port, ...@@ -248,8 +248,8 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port,
in_mad->attr_id = IB_SMP_ATTR_GUID_INFO; in_mad->attr_id = IB_SMP_ATTR_GUID_INFO;
in_mad->attr_mod = cpu_to_be32(index / 8); in_mad->attr_mod = cpu_to_be32(index / 8);
err = mthca_MAD_IFC(to_mdev(ibdev), 1, err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
port, in_mad, out_mad, port, NULL, NULL, in_mad, out_mad,
&status); &status);
if (err) if (err)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment