2006-03-29 23:23:37 +00:00
|
|
|
/*
|
2008-04-17 04:09:32 +00:00
|
|
|
* Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.
|
2006-03-29 23:23:37 +00:00
|
|
|
* Copyright (c) 2005, 2006 PathScale, 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 <rdma/ib_smi.h>
|
2011-07-05 15:46:29 +00:00
|
|
|
#include <rdma/ib_pma.h>
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
#include "ipath_kernel.h"
|
|
|
|
#include "ipath_verbs.h"
|
2006-07-01 11:36:17 +00:00
|
|
|
#include "ipath_common.h"
|
2006-03-29 23:23:37 +00:00
|
|
|
|
2009-01-18 01:11:57 +00:00
|
|
|
#define IB_SMP_UNSUP_VERSION cpu_to_be16(0x0004)
|
|
|
|
#define IB_SMP_UNSUP_METHOD cpu_to_be16(0x0008)
|
|
|
|
#define IB_SMP_UNSUP_METH_ATTR cpu_to_be16(0x000C)
|
|
|
|
#define IB_SMP_INVALID_FIELD cpu_to_be16(0x001C)
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
static int reply(struct ib_smp *smp)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The verbs framework will handle the directed/LID route
|
|
|
|
* packet changes.
|
|
|
|
*/
|
|
|
|
smp->method = IB_MGMT_METHOD_GET_RESP;
|
|
|
|
if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
|
|
|
|
smp->status |= IB_SMP_DIRECTION;
|
|
|
|
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int recv_subn_get_nodedescription(struct ib_smp *smp,
|
|
|
|
struct ib_device *ibdev)
|
|
|
|
{
|
|
|
|
if (smp->attr_mod)
|
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
|
2009-09-06 03:23:21 +00:00
|
|
|
memcpy(smp->data, ibdev->node_desc, sizeof(smp->data));
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
return reply(smp);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct nodeinfo {
|
|
|
|
u8 base_version;
|
|
|
|
u8 class_version;
|
|
|
|
u8 node_type;
|
|
|
|
u8 num_ports;
|
|
|
|
__be64 sys_guid;
|
|
|
|
__be64 node_guid;
|
|
|
|
__be64 port_guid;
|
|
|
|
__be16 partition_cap;
|
|
|
|
__be16 device_id;
|
|
|
|
__be32 revision;
|
|
|
|
u8 local_port_num;
|
|
|
|
u8 vendor_id[3];
|
|
|
|
} __attribute__ ((packed));
|
|
|
|
|
|
|
|
static int recv_subn_get_nodeinfo(struct ib_smp *smp,
|
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct nodeinfo *nip = (struct nodeinfo *)&smp->data;
|
|
|
|
struct ipath_devdata *dd = to_idev(ibdev)->dd;
|
2006-07-01 11:35:57 +00:00
|
|
|
u32 vendor, majrev, minrev;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
2006-09-28 16:00:02 +00:00
|
|
|
/* GUID 0 is illegal */
|
|
|
|
if (smp->attr_mod || (dd->ipath_guid == 0))
|
2006-03-29 23:23:37 +00:00
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
|
|
|
|
nip->base_version = 1;
|
|
|
|
nip->class_version = 1;
|
|
|
|
nip->node_type = 1; /* channel adapter */
|
|
|
|
/*
|
|
|
|
* XXX The num_ports value will need a layer function to get
|
|
|
|
* the value if we ever have more than one IB port on a chip.
|
|
|
|
* We will also need to get the GUID for the port.
|
|
|
|
*/
|
|
|
|
nip->num_ports = ibdev->phys_port_cnt;
|
|
|
|
/* This is already in network order */
|
|
|
|
nip->sys_guid = to_idev(ibdev)->sys_image_guid;
|
2006-08-25 18:24:32 +00:00
|
|
|
nip->node_guid = dd->ipath_guid;
|
2007-06-29 02:16:20 +00:00
|
|
|
nip->port_guid = dd->ipath_guid;
|
2006-08-25 18:24:32 +00:00
|
|
|
nip->partition_cap = cpu_to_be16(ipath_get_npkeys(dd));
|
|
|
|
nip->device_id = cpu_to_be16(dd->ipath_deviceid);
|
|
|
|
majrev = dd->ipath_majrev;
|
|
|
|
minrev = dd->ipath_minrev;
|
2006-03-29 23:23:37 +00:00
|
|
|
nip->revision = cpu_to_be32((majrev << 16) | minrev);
|
|
|
|
nip->local_port_num = port;
|
2006-08-25 18:24:32 +00:00
|
|
|
vendor = dd->ipath_vendorid;
|
2008-07-15 06:48:52 +00:00
|
|
|
nip->vendor_id[0] = IPATH_SRC_OUI_1;
|
|
|
|
nip->vendor_id[1] = IPATH_SRC_OUI_2;
|
|
|
|
nip->vendor_id[2] = IPATH_SRC_OUI_3;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
return reply(smp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int recv_subn_get_guidinfo(struct ib_smp *smp,
|
|
|
|
struct ib_device *ibdev)
|
|
|
|
{
|
|
|
|
u32 startgx = 8 * be32_to_cpu(smp->attr_mod);
|
|
|
|
__be64 *p = (__be64 *) smp->data;
|
|
|
|
|
|
|
|
/* 32 blocks of 8 64-bit GUIDs per block */
|
|
|
|
|
|
|
|
memset(smp->data, 0, sizeof(smp->data));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We only support one GUID for now. If this changes, the
|
|
|
|
* portinfo.guid_cap field needs to be updated too.
|
|
|
|
*/
|
2006-09-28 16:00:02 +00:00
|
|
|
if (startgx == 0) {
|
|
|
|
__be64 g = to_idev(ibdev)->dd->ipath_guid;
|
|
|
|
if (g == 0)
|
|
|
|
/* GUID 0 is illegal */
|
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
else
|
|
|
|
/* The first is a copy of the read-only HW GUID. */
|
|
|
|
*p = g;
|
|
|
|
} else
|
2006-03-29 23:23:37 +00:00
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
|
|
|
|
return reply(smp);
|
|
|
|
}
|
|
|
|
|
2008-04-17 04:09:24 +00:00
|
|
|
static void set_link_width_enabled(struct ipath_devdata *dd, u32 w)
|
|
|
|
{
|
|
|
|
(void) dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_LWID_ENB, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_link_speed_enabled(struct ipath_devdata *dd, u32 s)
|
|
|
|
{
|
|
|
|
(void) dd->ipath_f_set_ib_cfg(dd, IPATH_IB_CFG_SPD_ENB, s);
|
|
|
|
}
|
2006-08-25 18:24:32 +00:00
|
|
|
|
|
|
|
static int get_overrunthreshold(struct ipath_devdata *dd)
|
|
|
|
{
|
|
|
|
return (dd->ipath_ibcctrl >>
|
|
|
|
INFINIPATH_IBCC_OVERRUNTHRESHOLD_SHIFT) &
|
|
|
|
INFINIPATH_IBCC_OVERRUNTHRESHOLD_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set_overrunthreshold - set the overrun threshold
|
|
|
|
* @dd: the infinipath device
|
|
|
|
* @n: the new threshold
|
|
|
|
*
|
|
|
|
* Note that this will only take effect when the link state changes.
|
|
|
|
*/
|
|
|
|
static int set_overrunthreshold(struct ipath_devdata *dd, unsigned n)
|
|
|
|
{
|
|
|
|
unsigned v;
|
|
|
|
|
|
|
|
v = (dd->ipath_ibcctrl >> INFINIPATH_IBCC_OVERRUNTHRESHOLD_SHIFT) &
|
|
|
|
INFINIPATH_IBCC_OVERRUNTHRESHOLD_MASK;
|
|
|
|
if (v != n) {
|
|
|
|
dd->ipath_ibcctrl &=
|
|
|
|
~(INFINIPATH_IBCC_OVERRUNTHRESHOLD_MASK <<
|
|
|
|
INFINIPATH_IBCC_OVERRUNTHRESHOLD_SHIFT);
|
|
|
|
dd->ipath_ibcctrl |=
|
|
|
|
(u64) n << INFINIPATH_IBCC_OVERRUNTHRESHOLD_SHIFT;
|
|
|
|
ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl,
|
|
|
|
dd->ipath_ibcctrl);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int get_phyerrthreshold(struct ipath_devdata *dd)
|
|
|
|
{
|
|
|
|
return (dd->ipath_ibcctrl >>
|
|
|
|
INFINIPATH_IBCC_PHYERRTHRESHOLD_SHIFT) &
|
|
|
|
INFINIPATH_IBCC_PHYERRTHRESHOLD_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set_phyerrthreshold - set the physical error threshold
|
|
|
|
* @dd: the infinipath device
|
|
|
|
* @n: the new threshold
|
|
|
|
*
|
|
|
|
* Note that this will only take effect when the link state changes.
|
|
|
|
*/
|
|
|
|
static int set_phyerrthreshold(struct ipath_devdata *dd, unsigned n)
|
|
|
|
{
|
|
|
|
unsigned v;
|
|
|
|
|
|
|
|
v = (dd->ipath_ibcctrl >> INFINIPATH_IBCC_PHYERRTHRESHOLD_SHIFT) &
|
|
|
|
INFINIPATH_IBCC_PHYERRTHRESHOLD_MASK;
|
|
|
|
if (v != n) {
|
|
|
|
dd->ipath_ibcctrl &=
|
|
|
|
~(INFINIPATH_IBCC_PHYERRTHRESHOLD_MASK <<
|
|
|
|
INFINIPATH_IBCC_PHYERRTHRESHOLD_SHIFT);
|
|
|
|
dd->ipath_ibcctrl |=
|
|
|
|
(u64) n << INFINIPATH_IBCC_PHYERRTHRESHOLD_SHIFT;
|
|
|
|
ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl,
|
|
|
|
dd->ipath_ibcctrl);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get_linkdowndefaultstate - get the default linkdown state
|
|
|
|
* @dd: the infinipath device
|
|
|
|
*
|
|
|
|
* Returns zero if the default is POLL, 1 if the default is SLEEP.
|
|
|
|
*/
|
|
|
|
static int get_linkdowndefaultstate(struct ipath_devdata *dd)
|
|
|
|
{
|
|
|
|
return !!(dd->ipath_ibcctrl & INFINIPATH_IBCC_LINKDOWNDEFAULTSTATE);
|
|
|
|
}
|
|
|
|
|
2006-03-29 23:23:37 +00:00
|
|
|
static int recv_subn_get_portinfo(struct ib_smp *smp,
|
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct ipath_ibdev *dev;
|
2008-04-17 04:09:24 +00:00
|
|
|
struct ipath_devdata *dd;
|
2006-06-18 03:37:36 +00:00
|
|
|
struct ib_port_info *pip = (struct ib_port_info *)smp->data;
|
2006-03-29 23:23:37 +00:00
|
|
|
u16 lid;
|
|
|
|
u8 ibcstat;
|
|
|
|
u8 mtu;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (be32_to_cpu(smp->attr_mod) > ibdev->phys_port_cnt) {
|
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
ret = reply(smp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev = to_idev(ibdev);
|
2008-04-17 04:09:24 +00:00
|
|
|
dd = dev->dd;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
/* Clear all fields. Only set the non-zero fields. */
|
|
|
|
memset(smp->data, 0, sizeof(smp->data));
|
|
|
|
|
|
|
|
/* Only return the mkey if the protection field allows it. */
|
|
|
|
if (smp->method == IB_MGMT_METHOD_SET || dev->mkey == smp->mkey ||
|
2007-09-13 18:42:52 +00:00
|
|
|
dev->mkeyprot == 0)
|
2006-03-29 23:23:37 +00:00
|
|
|
pip->mkey = dev->mkey;
|
|
|
|
pip->gid_prefix = dev->gid_prefix;
|
2008-04-17 04:09:24 +00:00
|
|
|
lid = dd->ipath_lid;
|
2006-03-29 23:23:37 +00:00
|
|
|
pip->lid = lid ? cpu_to_be16(lid) : IB_LID_PERMISSIVE;
|
|
|
|
pip->sm_lid = cpu_to_be16(dev->sm_lid);
|
|
|
|
pip->cap_mask = cpu_to_be32(dev->port_cap_flags);
|
|
|
|
/* pip->diag_code; */
|
|
|
|
pip->mkey_lease_period = cpu_to_be16(dev->mkey_lease_period);
|
|
|
|
pip->local_port_num = port;
|
2008-04-17 04:09:24 +00:00
|
|
|
pip->link_width_enabled = dd->ipath_link_width_enabled;
|
|
|
|
pip->link_width_supported = dd->ipath_link_width_supported;
|
|
|
|
pip->link_width_active = dd->ipath_link_width_active;
|
|
|
|
pip->linkspeed_portstate = dd->ipath_link_speed_supported << 4;
|
|
|
|
ibcstat = dd->ipath_lastibcstat;
|
|
|
|
/* map LinkState to IB portinfo values. */
|
|
|
|
pip->linkspeed_portstate |= ipath_ib_linkstate(dd, ibcstat) + 1;
|
|
|
|
|
2006-03-29 23:23:37 +00:00
|
|
|
pip->portphysstate_linkdown =
|
2008-04-17 04:09:24 +00:00
|
|
|
(ipath_cvt_physportstate[ibcstat & dd->ibcs_lts_mask] << 4) |
|
|
|
|
(get_linkdowndefaultstate(dd) ? 1 : 2);
|
|
|
|
pip->mkeyprot_resv_lmc = (dev->mkeyprot << 6) | dd->ipath_lmc;
|
|
|
|
pip->linkspeedactive_enabled = (dd->ipath_link_speed_active << 4) |
|
|
|
|
dd->ipath_link_speed_enabled;
|
|
|
|
switch (dd->ipath_ibmtu) {
|
2006-03-29 23:23:37 +00:00
|
|
|
case 4096:
|
|
|
|
mtu = IB_MTU_4096;
|
|
|
|
break;
|
|
|
|
case 2048:
|
|
|
|
mtu = IB_MTU_2048;
|
|
|
|
break;
|
|
|
|
case 1024:
|
|
|
|
mtu = IB_MTU_1024;
|
|
|
|
break;
|
|
|
|
case 512:
|
|
|
|
mtu = IB_MTU_512;
|
|
|
|
break;
|
|
|
|
case 256:
|
|
|
|
mtu = IB_MTU_256;
|
|
|
|
break;
|
|
|
|
default: /* oops, something is wrong */
|
|
|
|
mtu = IB_MTU_2048;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pip->neighbormtu_mastersmsl = (mtu << 4) | dev->sm_sl;
|
|
|
|
pip->vlcap_inittype = 0x10; /* VLCap = VL0, InitType = 0 */
|
|
|
|
pip->vl_high_limit = dev->vl_high_limit;
|
|
|
|
/* pip->vl_arb_high_cap; // only one VL */
|
|
|
|
/* pip->vl_arb_low_cap; // only one VL */
|
|
|
|
/* InitTypeReply = 0 */
|
2008-04-17 04:01:12 +00:00
|
|
|
/* our mtu cap depends on whether 4K MTU enabled or not */
|
|
|
|
pip->inittypereply_mtucap = ipath_mtu4096 ? IB_MTU_4096 : IB_MTU_2048;
|
|
|
|
/* HCAs ignore VLStallCount and HOQLife */
|
2006-03-29 23:23:37 +00:00
|
|
|
/* pip->vlstallcnt_hoqlife; */
|
|
|
|
pip->operationalvl_pei_peo_fpi_fpo = 0x10; /* OVLs = 1 */
|
|
|
|
pip->mkey_violations = cpu_to_be16(dev->mkey_violations);
|
|
|
|
/* P_KeyViolations are counted by hardware. */
|
|
|
|
pip->pkey_violations =
|
2008-04-17 04:09:24 +00:00
|
|
|
cpu_to_be16((ipath_get_cr_errpkey(dd) -
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_pkey_violations) & 0xFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
pip->qkey_violations = cpu_to_be16(dev->qkey_violations);
|
|
|
|
/* Only the hardware GUID is supported for now */
|
|
|
|
pip->guid_cap = 1;
|
|
|
|
pip->clientrereg_resv_subnetto = dev->subnet_timeout;
|
|
|
|
/* 32.768 usec. response time (guessing) */
|
|
|
|
pip->resv_resptimevalue = 3;
|
|
|
|
pip->localphyerrors_overrunerrors =
|
2008-04-17 04:09:24 +00:00
|
|
|
(get_phyerrthreshold(dd) << 4) |
|
|
|
|
get_overrunthreshold(dd);
|
2006-03-29 23:23:37 +00:00
|
|
|
/* pip->max_credit_hint; */
|
2008-04-17 04:09:24 +00:00
|
|
|
if (dev->port_cap_flags & IB_PORT_LINK_LATENCY_SUP) {
|
|
|
|
u32 v;
|
|
|
|
|
|
|
|
v = dd->ipath_f_get_ib_cfg(dd, IPATH_IB_CFG_LINKLATENCY);
|
|
|
|
pip->link_roundtrip_latency[0] = v >> 16;
|
|
|
|
pip->link_roundtrip_latency[1] = v >> 8;
|
|
|
|
pip->link_roundtrip_latency[2] = v;
|
|
|
|
}
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
ret = reply(smp);
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
/**
|
|
|
|
* get_pkeys - return the PKEY table for port 0
|
|
|
|
* @dd: the infinipath device
|
|
|
|
* @pkeys: the pkey table is placed here
|
|
|
|
*/
|
|
|
|
static int get_pkeys(struct ipath_devdata *dd, u16 * pkeys)
|
|
|
|
{
|
2008-12-05 19:14:38 +00:00
|
|
|
/* always a kernel port, no locking needed */
|
2006-08-25 18:24:32 +00:00
|
|
|
struct ipath_portdata *pd = dd->ipath_pd[0];
|
|
|
|
|
|
|
|
memcpy(pkeys, pd->port_pkeys, sizeof(pd->port_pkeys));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-29 23:23:37 +00:00
|
|
|
static int recv_subn_get_pkeytable(struct ib_smp *smp,
|
|
|
|
struct ib_device *ibdev)
|
|
|
|
{
|
|
|
|
u32 startpx = 32 * (be32_to_cpu(smp->attr_mod) & 0xffff);
|
|
|
|
u16 *p = (u16 *) smp->data;
|
|
|
|
__be16 *q = (__be16 *) smp->data;
|
|
|
|
|
|
|
|
/* 64 blocks of 32 16-bit P_Key entries */
|
|
|
|
|
|
|
|
memset(smp->data, 0, sizeof(smp->data));
|
|
|
|
if (startpx == 0) {
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2006-08-25 18:24:32 +00:00
|
|
|
unsigned i, n = ipath_get_npkeys(dev->dd);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
get_pkeys(dev->dd, p);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
q[i] = cpu_to_be16(p[i]);
|
|
|
|
} else
|
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
|
|
|
|
return reply(smp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int recv_subn_set_guidinfo(struct ib_smp *smp,
|
|
|
|
struct ib_device *ibdev)
|
|
|
|
{
|
|
|
|
/* The only GUID we support is the first read-only entry. */
|
|
|
|
return recv_subn_get_guidinfo(smp, ibdev);
|
|
|
|
}
|
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
/**
|
|
|
|
* set_linkdowndefaultstate - set the default linkdown state
|
|
|
|
* @dd: the infinipath device
|
|
|
|
* @sleep: the new state
|
|
|
|
*
|
|
|
|
* Note that this will only take effect when the link state changes.
|
|
|
|
*/
|
|
|
|
static int set_linkdowndefaultstate(struct ipath_devdata *dd, int sleep)
|
|
|
|
{
|
|
|
|
if (sleep)
|
|
|
|
dd->ipath_ibcctrl |= INFINIPATH_IBCC_LINKDOWNDEFAULTSTATE;
|
|
|
|
else
|
|
|
|
dd->ipath_ibcctrl &= ~INFINIPATH_IBCC_LINKDOWNDEFAULTSTATE;
|
|
|
|
ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl,
|
|
|
|
dd->ipath_ibcctrl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-29 23:23:37 +00:00
|
|
|
/**
|
|
|
|
* recv_subn_set_portinfo - set port information
|
|
|
|
* @smp: the incoming SM packet
|
|
|
|
* @ibdev: the infiniband device
|
|
|
|
* @port: the port on the device
|
|
|
|
*
|
|
|
|
* Set Portinfo (see ch. 14.2.5.6).
|
|
|
|
*/
|
|
|
|
static int recv_subn_set_portinfo(struct ib_smp *smp,
|
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
2006-06-18 03:37:36 +00:00
|
|
|
struct ib_port_info *pip = (struct ib_port_info *)smp->data;
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_event event;
|
|
|
|
struct ipath_ibdev *dev;
|
2007-09-13 18:42:52 +00:00
|
|
|
struct ipath_devdata *dd;
|
2006-03-29 23:23:37 +00:00
|
|
|
char clientrereg = 0;
|
|
|
|
u16 lid, smlid;
|
|
|
|
u8 lwe;
|
|
|
|
u8 lse;
|
|
|
|
u8 state;
|
|
|
|
u16 lstate;
|
|
|
|
u32 mtu;
|
2006-08-25 18:24:32 +00:00
|
|
|
int ret, ore;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (be32_to_cpu(smp->attr_mod) > ibdev->phys_port_cnt)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
dev = to_idev(ibdev);
|
2007-09-13 18:42:52 +00:00
|
|
|
dd = dev->dd;
|
2006-03-29 23:23:37 +00:00
|
|
|
event.device = ibdev;
|
|
|
|
event.element.port_num = port;
|
|
|
|
|
|
|
|
dev->mkey = pip->mkey;
|
|
|
|
dev->gid_prefix = pip->gid_prefix;
|
|
|
|
dev->mkey_lease_period = be16_to_cpu(pip->mkey_lease_period);
|
|
|
|
|
|
|
|
lid = be16_to_cpu(pip->lid);
|
2007-09-13 18:42:52 +00:00
|
|
|
if (dd->ipath_lid != lid ||
|
|
|
|
dd->ipath_lmc != (pip->mkeyprot_resv_lmc & 7)) {
|
2006-03-29 23:23:37 +00:00
|
|
|
/* Must be a valid unicast LID address. */
|
2006-07-01 11:36:17 +00:00
|
|
|
if (lid == 0 || lid >= IPATH_MULTICAST_LID_BASE)
|
2006-03-29 23:23:37 +00:00
|
|
|
goto err;
|
2007-09-13 18:42:52 +00:00
|
|
|
ipath_set_lid(dd, lid, pip->mkeyprot_resv_lmc & 7);
|
2006-03-29 23:23:37 +00:00
|
|
|
event.event = IB_EVENT_LID_CHANGE;
|
|
|
|
ib_dispatch_event(&event);
|
|
|
|
}
|
|
|
|
|
|
|
|
smlid = be16_to_cpu(pip->sm_lid);
|
|
|
|
if (smlid != dev->sm_lid) {
|
|
|
|
/* Must be a valid unicast LID address. */
|
2006-07-01 11:36:17 +00:00
|
|
|
if (smlid == 0 || smlid >= IPATH_MULTICAST_LID_BASE)
|
2006-03-29 23:23:37 +00:00
|
|
|
goto err;
|
|
|
|
dev->sm_lid = smlid;
|
|
|
|
event.event = IB_EVENT_SM_CHANGE;
|
|
|
|
ib_dispatch_event(&event);
|
|
|
|
}
|
|
|
|
|
2008-04-17 04:09:24 +00:00
|
|
|
/* Allow 1x or 4x to be set (see 14.2.6.6). */
|
2006-03-29 23:23:37 +00:00
|
|
|
lwe = pip->link_width_enabled;
|
2008-04-17 04:09:24 +00:00
|
|
|
if (lwe) {
|
|
|
|
if (lwe == 0xFF)
|
|
|
|
lwe = dd->ipath_link_width_supported;
|
|
|
|
else if (lwe >= 16 || (lwe & ~dd->ipath_link_width_supported))
|
|
|
|
goto err;
|
|
|
|
set_link_width_enabled(dd, lwe);
|
|
|
|
}
|
2006-03-29 23:23:37 +00:00
|
|
|
|
2008-04-17 04:09:24 +00:00
|
|
|
/* Allow 2.5 or 5.0 Gbs. */
|
2006-03-29 23:23:37 +00:00
|
|
|
lse = pip->linkspeedactive_enabled & 0xF;
|
2008-04-17 04:09:24 +00:00
|
|
|
if (lse) {
|
|
|
|
if (lse == 15)
|
|
|
|
lse = dd->ipath_link_speed_supported;
|
|
|
|
else if (lse >= 8 || (lse & ~dd->ipath_link_speed_supported))
|
|
|
|
goto err;
|
|
|
|
set_link_speed_enabled(dd, lse);
|
|
|
|
}
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
/* Set link down default state. */
|
|
|
|
switch (pip->portphysstate_linkdown & 0xF) {
|
|
|
|
case 0: /* NOP */
|
|
|
|
break;
|
|
|
|
case 1: /* SLEEP */
|
2007-09-13 18:42:52 +00:00
|
|
|
if (set_linkdowndefaultstate(dd, 1))
|
2006-03-29 23:23:37 +00:00
|
|
|
goto err;
|
|
|
|
break;
|
|
|
|
case 2: /* POLL */
|
2007-09-13 18:42:52 +00:00
|
|
|
if (set_linkdowndefaultstate(dd, 0))
|
2006-03-29 23:23:37 +00:00
|
|
|
goto err;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2007-09-13 18:42:52 +00:00
|
|
|
dev->mkeyprot = pip->mkeyprot_resv_lmc >> 6;
|
2006-03-29 23:23:37 +00:00
|
|
|
dev->vl_high_limit = pip->vl_high_limit;
|
|
|
|
|
|
|
|
switch ((pip->neighbormtu_mastersmsl >> 4) & 0xF) {
|
|
|
|
case IB_MTU_256:
|
|
|
|
mtu = 256;
|
|
|
|
break;
|
|
|
|
case IB_MTU_512:
|
|
|
|
mtu = 512;
|
|
|
|
break;
|
|
|
|
case IB_MTU_1024:
|
|
|
|
mtu = 1024;
|
|
|
|
break;
|
|
|
|
case IB_MTU_2048:
|
|
|
|
mtu = 2048;
|
|
|
|
break;
|
|
|
|
case IB_MTU_4096:
|
2008-04-17 04:01:12 +00:00
|
|
|
if (!ipath_mtu4096)
|
|
|
|
goto err;
|
2006-03-29 23:23:37 +00:00
|
|
|
mtu = 4096;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* XXX We have already partially updated our state! */
|
|
|
|
goto err;
|
|
|
|
}
|
2007-09-13 18:42:52 +00:00
|
|
|
ipath_set_mtu(dd, mtu);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
dev->sm_sl = pip->neighbormtu_mastersmsl & 0xF;
|
|
|
|
|
|
|
|
/* We only support VL0 */
|
|
|
|
if (((pip->operationalvl_pei_peo_fpi_fpo >> 4) & 0xF) > 1)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (pip->mkey_violations == 0)
|
|
|
|
dev->mkey_violations = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hardware counter can't be reset so snapshot and subtract
|
|
|
|
* later.
|
|
|
|
*/
|
|
|
|
if (pip->pkey_violations == 0)
|
2007-09-13 18:42:52 +00:00
|
|
|
dev->z_pkey_violations = ipath_get_cr_errpkey(dd);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (pip->qkey_violations == 0)
|
|
|
|
dev->qkey_violations = 0;
|
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
ore = pip->localphyerrors_overrunerrors;
|
2007-09-13 18:42:52 +00:00
|
|
|
if (set_phyerrthreshold(dd, (ore >> 4) & 0xF))
|
2006-03-29 23:23:37 +00:00
|
|
|
goto err;
|
|
|
|
|
2007-09-13 18:42:52 +00:00
|
|
|
if (set_overrunthreshold(dd, (ore & 0xF)))
|
2006-03-29 23:23:37 +00:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
dev->subnet_timeout = pip->clientrereg_resv_subnetto & 0x1F;
|
|
|
|
|
|
|
|
if (pip->clientrereg_resv_subnetto & 0x80) {
|
|
|
|
clientrereg = 1;
|
2006-06-18 03:37:37 +00:00
|
|
|
event.event = IB_EVENT_CLIENT_REREGISTER;
|
2006-03-29 23:23:37 +00:00
|
|
|
ib_dispatch_event(&event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do the port state change now that the other link parameters
|
|
|
|
* have been set.
|
|
|
|
* Changing the port physical state only makes sense if the link
|
|
|
|
* is down or is being set to down.
|
|
|
|
*/
|
|
|
|
state = pip->linkspeed_portstate & 0xF;
|
|
|
|
lstate = (pip->portphysstate_linkdown >> 4) & 0xF;
|
|
|
|
if (lstate && !(state == IB_PORT_DOWN || state == IB_PORT_NOP))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only state changes of DOWN, ARM, and ACTIVE are valid
|
|
|
|
* and must be in the correct state to take effect (see 7.2.6).
|
|
|
|
*/
|
|
|
|
switch (state) {
|
|
|
|
case IB_PORT_NOP:
|
|
|
|
if (lstate == 0)
|
|
|
|
break;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case IB_PORT_DOWN:
|
|
|
|
if (lstate == 0)
|
2007-12-14 09:53:56 +00:00
|
|
|
lstate = IPATH_IB_LINKDOWN_ONLY;
|
2006-03-29 23:23:37 +00:00
|
|
|
else if (lstate == 1)
|
|
|
|
lstate = IPATH_IB_LINKDOWN_SLEEP;
|
|
|
|
else if (lstate == 2)
|
|
|
|
lstate = IPATH_IB_LINKDOWN;
|
|
|
|
else if (lstate == 3)
|
|
|
|
lstate = IPATH_IB_LINKDOWN_DISABLE;
|
|
|
|
else
|
|
|
|
goto err;
|
2007-09-13 18:42:52 +00:00
|
|
|
ipath_set_linkstate(dd, lstate);
|
2008-04-17 04:09:26 +00:00
|
|
|
if (lstate == IPATH_IB_LINKDOWN_DISABLE) {
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
|
|
|
|
goto done;
|
|
|
|
}
|
2007-12-14 09:53:56 +00:00
|
|
|
ipath_wait_linkstate(dd, IPATH_LINKINIT | IPATH_LINKARMED |
|
|
|
|
IPATH_LINKACTIVE, 1000);
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
case IB_PORT_ARMED:
|
2007-09-13 18:42:52 +00:00
|
|
|
ipath_set_linkstate(dd, IPATH_IB_LINKARM);
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
case IB_PORT_ACTIVE:
|
2007-09-13 18:42:52 +00:00
|
|
|
ipath_set_linkstate(dd, IPATH_IB_LINKACTIVE);
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* XXX We have already partially updated our state! */
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = recv_subn_get_portinfo(smp, ibdev, port);
|
|
|
|
|
|
|
|
if (clientrereg)
|
|
|
|
pip->clientrereg_resv_subnetto |= 0x80;
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
err:
|
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
ret = recv_subn_get_portinfo(smp, ibdev, port);
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
/**
|
|
|
|
* rm_pkey - decrecment the reference count for the given PKEY
|
|
|
|
* @dd: the infinipath device
|
|
|
|
* @key: the PKEY index
|
|
|
|
*
|
|
|
|
* Return true if this was the last reference and the hardware table entry
|
|
|
|
* needs to be changed.
|
|
|
|
*/
|
|
|
|
static int rm_pkey(struct ipath_devdata *dd, u16 key)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dd->ipath_pkeys); i++) {
|
|
|
|
if (dd->ipath_pkeys[i] != key)
|
|
|
|
continue;
|
|
|
|
if (atomic_dec_and_test(&dd->ipath_pkeyrefs[i])) {
|
|
|
|
dd->ipath_pkeys[i] = 0;
|
|
|
|
ret = 1;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* add_pkey - add the given PKEY to the hardware table
|
|
|
|
* @dd: the infinipath device
|
|
|
|
* @key: the PKEY
|
|
|
|
*
|
|
|
|
* Return an error code if unable to add the entry, zero if no change,
|
|
|
|
* or 1 if the hardware PKEY register needs to be updated.
|
|
|
|
*/
|
|
|
|
static int add_pkey(struct ipath_devdata *dd, u16 key)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u16 lkey = key & 0x7FFF;
|
|
|
|
int any = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (lkey == 0x7FFF) {
|
|
|
|
ret = 0;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for an empty slot or a matching PKEY. */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dd->ipath_pkeys); i++) {
|
|
|
|
if (!dd->ipath_pkeys[i]) {
|
|
|
|
any++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* If it matches exactly, try to increment the ref count */
|
|
|
|
if (dd->ipath_pkeys[i] == key) {
|
|
|
|
if (atomic_inc_return(&dd->ipath_pkeyrefs[i]) > 1) {
|
|
|
|
ret = 0;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
/* Lost the race. Look for an empty slot below. */
|
|
|
|
atomic_dec(&dd->ipath_pkeyrefs[i]);
|
|
|
|
any++;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* It makes no sense to have both the limited and unlimited
|
|
|
|
* PKEY set at the same time since the unlimited one will
|
|
|
|
* disable the limited one.
|
|
|
|
*/
|
|
|
|
if ((dd->ipath_pkeys[i] & 0x7FFF) == lkey) {
|
|
|
|
ret = -EEXIST;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!any) {
|
|
|
|
ret = -EBUSY;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dd->ipath_pkeys); i++) {
|
|
|
|
if (!dd->ipath_pkeys[i] &&
|
|
|
|
atomic_inc_return(&dd->ipath_pkeyrefs[i]) == 1) {
|
|
|
|
/* for ipathstats, etc. */
|
|
|
|
ipath_stats.sps_pkeys[i] = lkey;
|
|
|
|
dd->ipath_pkeys[i] = key;
|
|
|
|
ret = 1;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = -EBUSY;
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set_pkeys - set the PKEY table for port 0
|
|
|
|
* @dd: the infinipath device
|
|
|
|
* @pkeys: the PKEY table
|
|
|
|
*/
|
2014-07-08 09:45:10 +00:00
|
|
|
static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys, u8 port)
|
2006-08-25 18:24:32 +00:00
|
|
|
{
|
|
|
|
struct ipath_portdata *pd;
|
|
|
|
int i;
|
|
|
|
int changed = 0;
|
|
|
|
|
2008-12-05 19:14:38 +00:00
|
|
|
/* always a kernel port, no locking needed */
|
2006-08-25 18:24:32 +00:00
|
|
|
pd = dd->ipath_pd[0];
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(pd->port_pkeys); i++) {
|
|
|
|
u16 key = pkeys[i];
|
|
|
|
u16 okey = pd->port_pkeys[i];
|
|
|
|
|
|
|
|
if (key == okey)
|
|
|
|
continue;
|
|
|
|
/*
|
|
|
|
* The value of this PKEY table entry is changing.
|
|
|
|
* Remove the old entry in the hardware's array of PKEYs.
|
|
|
|
*/
|
|
|
|
if (okey & 0x7FFF)
|
|
|
|
changed |= rm_pkey(dd, okey);
|
|
|
|
if (key & 0x7FFF) {
|
|
|
|
int ret = add_pkey(dd, key);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
key = 0;
|
|
|
|
else
|
|
|
|
changed |= ret;
|
|
|
|
}
|
|
|
|
pd->port_pkeys[i] = key;
|
|
|
|
}
|
|
|
|
if (changed) {
|
|
|
|
u64 pkey;
|
2014-07-08 09:45:10 +00:00
|
|
|
struct ib_event event;
|
2006-08-25 18:24:32 +00:00
|
|
|
|
|
|
|
pkey = (u64) dd->ipath_pkeys[0] |
|
|
|
|
((u64) dd->ipath_pkeys[1] << 16) |
|
|
|
|
((u64) dd->ipath_pkeys[2] << 32) |
|
|
|
|
((u64) dd->ipath_pkeys[3] << 48);
|
|
|
|
ipath_cdbg(VERBOSE, "p0 new pkey reg %llx\n",
|
|
|
|
(unsigned long long) pkey);
|
|
|
|
ipath_write_kreg(dd, dd->ipath_kregs->kr_partitionkey,
|
|
|
|
pkey);
|
2014-07-08 09:45:10 +00:00
|
|
|
|
|
|
|
event.event = IB_EVENT_PKEY_CHANGE;
|
|
|
|
event.device = &dd->verbs_dev->ibdev;
|
|
|
|
event.element.port_num = port;
|
|
|
|
ib_dispatch_event(&event);
|
2006-08-25 18:24:32 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-29 23:23:37 +00:00
|
|
|
static int recv_subn_set_pkeytable(struct ib_smp *smp,
|
2014-07-08 09:45:10 +00:00
|
|
|
struct ib_device *ibdev, u8 port)
|
2006-03-29 23:23:37 +00:00
|
|
|
{
|
|
|
|
u32 startpx = 32 * (be32_to_cpu(smp->attr_mod) & 0xffff);
|
|
|
|
__be16 *p = (__be16 *) smp->data;
|
|
|
|
u16 *q = (u16 *) smp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2006-08-25 18:24:32 +00:00
|
|
|
unsigned i, n = ipath_get_npkeys(dev->dd);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
q[i] = be16_to_cpu(p[i]);
|
|
|
|
|
2014-07-08 09:45:10 +00:00
|
|
|
if (startpx != 0 || set_pkeys(dev->dd, q, port) != 0)
|
2006-03-29 23:23:37 +00:00
|
|
|
smp->status |= IB_SMP_INVALID_FIELD;
|
|
|
|
|
|
|
|
return recv_subn_get_pkeytable(smp, ibdev);
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_get_classportinfo(struct ib_pma_mad *pmp)
|
2006-03-29 23:23:37 +00:00
|
|
|
{
|
2011-07-05 15:46:29 +00:00
|
|
|
struct ib_class_port_info *p =
|
|
|
|
(struct ib_class_port_info *)pmp->data;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
memset(pmp->data, 0, sizeof(pmp->data));
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
if (pmp->mad_hdr.attr_mod != 0)
|
|
|
|
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
/* Indicate AllPortSelect is valid (only one port anyway) */
|
2011-07-05 15:46:29 +00:00
|
|
|
p->capability_mask = cpu_to_be16(1 << 8);
|
2006-03-29 23:23:37 +00:00
|
|
|
p->base_version = 1;
|
|
|
|
p->class_version = 1;
|
|
|
|
/*
|
|
|
|
* Expected response time is 4.096 usec. * 2^18 == 1.073741824
|
|
|
|
* sec.
|
|
|
|
*/
|
|
|
|
p->resp_time_value = 18;
|
|
|
|
|
|
|
|
return reply((struct ib_smp *) pmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The PortSamplesControl.CounterMasks field is an array of 3 bit fields
|
|
|
|
* which specify the N'th counter's capabilities. See ch. 16.1.3.2.
|
|
|
|
* We support 5 counters which only count the mandatory quantities.
|
|
|
|
*/
|
|
|
|
#define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
|
2009-01-18 01:11:57 +00:00
|
|
|
#define COUNTER_MASK0_9 cpu_to_be32(COUNTER_MASK(1, 0) | \
|
|
|
|
COUNTER_MASK(1, 1) | \
|
|
|
|
COUNTER_MASK(1, 2) | \
|
|
|
|
COUNTER_MASK(1, 3) | \
|
|
|
|
COUNTER_MASK(1, 4))
|
2006-03-29 23:23:37 +00:00
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_get_portsamplescontrol(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct ib_pma_portsamplescontrol *p =
|
|
|
|
(struct ib_pma_portsamplescontrol *)pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2008-01-07 05:02:33 +00:00
|
|
|
struct ipath_cregs const *crp = dev->dd->ipath_cregs;
|
2006-03-29 23:23:37 +00:00
|
|
|
unsigned long flags;
|
|
|
|
u8 port_select = p->port_select;
|
|
|
|
|
|
|
|
memset(pmp->data, 0, sizeof(pmp->data));
|
|
|
|
|
|
|
|
p->port_select = port_select;
|
2011-07-05 15:46:29 +00:00
|
|
|
if (pmp->mad_hdr.attr_mod != 0 ||
|
2006-03-29 23:23:37 +00:00
|
|
|
(port_select != port && port_select != 0xFF))
|
2011-07-05 15:46:29 +00:00
|
|
|
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
|
2006-03-29 23:23:37 +00:00
|
|
|
/*
|
|
|
|
* Ticks are 10x the link transfer period which for 2.5Gbs is 4
|
|
|
|
* nsec. 0 == 4 nsec., 1 == 8 nsec., ..., 255 == 1020 nsec. Sample
|
|
|
|
* intervals are counted in ticks. Since we use Linux timers, that
|
|
|
|
* count in jiffies, we can't sample for less than 1000 ticks if HZ
|
2008-04-17 04:09:24 +00:00
|
|
|
* == 1000 (4000 ticks if HZ is 250). link_speed_active returns 2 for
|
|
|
|
* DDR, 1 for SDR, set the tick to 1 for DDR, 0 for SDR on chips that
|
|
|
|
* have hardware support for delaying packets.
|
2006-03-29 23:23:37 +00:00
|
|
|
*/
|
2008-04-17 04:09:24 +00:00
|
|
|
if (crp->cr_psstat)
|
|
|
|
p->tick = dev->dd->ipath_link_speed_active - 1;
|
|
|
|
else
|
|
|
|
p->tick = 250; /* 1 usec. */
|
2006-03-29 23:23:37 +00:00
|
|
|
p->counter_width = 4; /* 32 bit counters */
|
|
|
|
p->counter_mask0_9 = COUNTER_MASK0_9;
|
|
|
|
spin_lock_irqsave(&dev->pending_lock, flags);
|
2008-01-07 05:02:33 +00:00
|
|
|
if (crp->cr_psstat)
|
|
|
|
p->sample_status = ipath_read_creg32(dev->dd, crp->cr_psstat);
|
|
|
|
else
|
|
|
|
p->sample_status = dev->pma_sample_status;
|
2006-03-29 23:23:37 +00:00
|
|
|
p->sample_start = cpu_to_be32(dev->pma_sample_start);
|
|
|
|
p->sample_interval = cpu_to_be32(dev->pma_sample_interval);
|
|
|
|
p->tag = cpu_to_be16(dev->pma_tag);
|
|
|
|
p->counter_select[0] = dev->pma_counter_select[0];
|
|
|
|
p->counter_select[1] = dev->pma_counter_select[1];
|
|
|
|
p->counter_select[2] = dev->pma_counter_select[2];
|
|
|
|
p->counter_select[3] = dev->pma_counter_select[3];
|
|
|
|
p->counter_select[4] = dev->pma_counter_select[4];
|
|
|
|
spin_unlock_irqrestore(&dev->pending_lock, flags);
|
|
|
|
|
|
|
|
return reply((struct ib_smp *) pmp);
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_set_portsamplescontrol(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct ib_pma_portsamplescontrol *p =
|
|
|
|
(struct ib_pma_portsamplescontrol *)pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2008-01-07 05:02:33 +00:00
|
|
|
struct ipath_cregs const *crp = dev->dd->ipath_cregs;
|
2006-03-29 23:23:37 +00:00
|
|
|
unsigned long flags;
|
2008-01-07 05:02:33 +00:00
|
|
|
u8 status;
|
2006-03-29 23:23:37 +00:00
|
|
|
int ret;
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
if (pmp->mad_hdr.attr_mod != 0 ||
|
2006-03-29 23:23:37 +00:00
|
|
|
(p->port_select != port && p->port_select != 0xFF)) {
|
2011-07-05 15:46:29 +00:00
|
|
|
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
|
2006-03-29 23:23:37 +00:00
|
|
|
ret = reply((struct ib_smp *) pmp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2008-01-07 05:02:33 +00:00
|
|
|
spin_lock_irqsave(&dev->pending_lock, flags);
|
|
|
|
if (crp->cr_psstat)
|
|
|
|
status = ipath_read_creg32(dev->dd, crp->cr_psstat);
|
|
|
|
else
|
|
|
|
status = dev->pma_sample_status;
|
|
|
|
if (status == IB_PMA_SAMPLE_STATUS_DONE) {
|
|
|
|
dev->pma_sample_start = be32_to_cpu(p->sample_start);
|
|
|
|
dev->pma_sample_interval = be32_to_cpu(p->sample_interval);
|
|
|
|
dev->pma_tag = be16_to_cpu(p->tag);
|
|
|
|
dev->pma_counter_select[0] = p->counter_select[0];
|
|
|
|
dev->pma_counter_select[1] = p->counter_select[1];
|
|
|
|
dev->pma_counter_select[2] = p->counter_select[2];
|
|
|
|
dev->pma_counter_select[3] = p->counter_select[3];
|
|
|
|
dev->pma_counter_select[4] = p->counter_select[4];
|
|
|
|
if (crp->cr_psstat) {
|
|
|
|
ipath_write_creg(dev->dd, crp->cr_psinterval,
|
|
|
|
dev->pma_sample_interval);
|
|
|
|
ipath_write_creg(dev->dd, crp->cr_psstart,
|
|
|
|
dev->pma_sample_start);
|
|
|
|
} else
|
|
|
|
dev->pma_sample_status = IB_PMA_SAMPLE_STATUS_STARTED;
|
2006-03-29 23:23:37 +00:00
|
|
|
}
|
2008-01-07 05:02:33 +00:00
|
|
|
spin_unlock_irqrestore(&dev->pending_lock, flags);
|
|
|
|
|
2006-03-29 23:23:37 +00:00
|
|
|
ret = recv_pma_get_portsamplescontrol(pmp, ibdev, port);
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-01-07 05:02:33 +00:00
|
|
|
static u64 get_counter(struct ipath_ibdev *dev,
|
|
|
|
struct ipath_cregs const *crp,
|
|
|
|
__be16 sel)
|
2006-03-29 23:23:37 +00:00
|
|
|
{
|
|
|
|
u64 ret;
|
|
|
|
|
|
|
|
switch (sel) {
|
|
|
|
case IB_PMA_PORT_XMIT_DATA:
|
2008-01-07 05:02:33 +00:00
|
|
|
ret = (crp->cr_psxmitdatacount) ?
|
|
|
|
ipath_read_creg32(dev->dd, crp->cr_psxmitdatacount) :
|
|
|
|
dev->ipath_sword;
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
case IB_PMA_PORT_RCV_DATA:
|
2008-01-07 05:02:33 +00:00
|
|
|
ret = (crp->cr_psrcvdatacount) ?
|
|
|
|
ipath_read_creg32(dev->dd, crp->cr_psrcvdatacount) :
|
|
|
|
dev->ipath_rword;
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
case IB_PMA_PORT_XMIT_PKTS:
|
2008-01-07 05:02:33 +00:00
|
|
|
ret = (crp->cr_psxmitpktscount) ?
|
|
|
|
ipath_read_creg32(dev->dd, crp->cr_psxmitpktscount) :
|
|
|
|
dev->ipath_spkts;
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
case IB_PMA_PORT_RCV_PKTS:
|
2008-01-07 05:02:33 +00:00
|
|
|
ret = (crp->cr_psrcvpktscount) ?
|
|
|
|
ipath_read_creg32(dev->dd, crp->cr_psrcvpktscount) :
|
|
|
|
dev->ipath_rpkts;
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
case IB_PMA_PORT_XMIT_WAIT:
|
2008-01-07 05:02:33 +00:00
|
|
|
ret = (crp->cr_psxmitwaitcount) ?
|
|
|
|
ipath_read_creg32(dev->dd, crp->cr_psxmitwaitcount) :
|
|
|
|
dev->ipath_xmit_wait;
|
2006-03-29 23:23:37 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_get_portsamplesresult(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev)
|
|
|
|
{
|
|
|
|
struct ib_pma_portsamplesresult *p =
|
|
|
|
(struct ib_pma_portsamplesresult *)pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2008-01-07 05:02:33 +00:00
|
|
|
struct ipath_cregs const *crp = dev->dd->ipath_cregs;
|
|
|
|
u8 status;
|
2006-03-29 23:23:37 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
memset(pmp->data, 0, sizeof(pmp->data));
|
|
|
|
p->tag = cpu_to_be16(dev->pma_tag);
|
2008-01-07 05:02:33 +00:00
|
|
|
if (crp->cr_psstat)
|
|
|
|
status = ipath_read_creg32(dev->dd, crp->cr_psstat);
|
|
|
|
else
|
|
|
|
status = dev->pma_sample_status;
|
|
|
|
p->sample_status = cpu_to_be16(status);
|
2006-03-29 23:23:37 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dev->pma_counter_select); i++)
|
2008-01-07 05:02:33 +00:00
|
|
|
p->counter[i] = (status != IB_PMA_SAMPLE_STATUS_DONE) ? 0 :
|
|
|
|
cpu_to_be32(
|
|
|
|
get_counter(dev, crp, dev->pma_counter_select[i]));
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
return reply((struct ib_smp *) pmp);
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_get_portsamplesresult_ext(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev)
|
|
|
|
{
|
|
|
|
struct ib_pma_portsamplesresult_ext *p =
|
|
|
|
(struct ib_pma_portsamplesresult_ext *)pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2008-01-07 05:02:33 +00:00
|
|
|
struct ipath_cregs const *crp = dev->dd->ipath_cregs;
|
|
|
|
u8 status;
|
2006-03-29 23:23:37 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
memset(pmp->data, 0, sizeof(pmp->data));
|
|
|
|
p->tag = cpu_to_be16(dev->pma_tag);
|
2008-01-07 05:02:33 +00:00
|
|
|
if (crp->cr_psstat)
|
|
|
|
status = ipath_read_creg32(dev->dd, crp->cr_psstat);
|
|
|
|
else
|
|
|
|
status = dev->pma_sample_status;
|
|
|
|
p->sample_status = cpu_to_be16(status);
|
2006-03-29 23:23:37 +00:00
|
|
|
/* 64 bits */
|
2009-01-18 01:11:57 +00:00
|
|
|
p->extended_width = cpu_to_be32(0x80000000);
|
2006-03-29 23:23:37 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dev->pma_counter_select); i++)
|
2008-01-07 05:02:33 +00:00
|
|
|
p->counter[i] = (status != IB_PMA_SAMPLE_STATUS_DONE) ? 0 :
|
|
|
|
cpu_to_be64(
|
|
|
|
get_counter(dev, crp, dev->pma_counter_select[i]));
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
return reply((struct ib_smp *) pmp);
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_get_portcounters(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct ib_pma_portcounters *p = (struct ib_pma_portcounters *)
|
|
|
|
pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2006-08-25 18:24:32 +00:00
|
|
|
struct ipath_verbs_counters cntrs;
|
2006-03-29 23:23:37 +00:00
|
|
|
u8 port_select = p->port_select;
|
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
ipath_get_counters(dev->dd, &cntrs);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
/* Adjust counters for any resets done. */
|
2006-07-01 11:35:48 +00:00
|
|
|
cntrs.symbol_error_counter -= dev->z_symbol_error_counter;
|
2006-03-29 23:23:37 +00:00
|
|
|
cntrs.link_error_recovery_counter -=
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_link_error_recovery_counter;
|
|
|
|
cntrs.link_downed_counter -= dev->z_link_downed_counter;
|
2006-03-29 23:23:37 +00:00
|
|
|
cntrs.port_rcv_errors += dev->rcv_errors;
|
2006-07-01 11:35:48 +00:00
|
|
|
cntrs.port_rcv_errors -= dev->z_port_rcv_errors;
|
|
|
|
cntrs.port_rcv_remphys_errors -= dev->z_port_rcv_remphys_errors;
|
|
|
|
cntrs.port_xmit_discards -= dev->z_port_xmit_discards;
|
|
|
|
cntrs.port_xmit_data -= dev->z_port_xmit_data;
|
|
|
|
cntrs.port_rcv_data -= dev->z_port_rcv_data;
|
|
|
|
cntrs.port_xmit_packets -= dev->z_port_xmit_packets;
|
|
|
|
cntrs.port_rcv_packets -= dev->z_port_rcv_packets;
|
2006-07-01 11:36:09 +00:00
|
|
|
cntrs.local_link_integrity_errors -=
|
|
|
|
dev->z_local_link_integrity_errors;
|
|
|
|
cntrs.excessive_buffer_overrun_errors -=
|
|
|
|
dev->z_excessive_buffer_overrun_errors;
|
2008-01-07 05:02:33 +00:00
|
|
|
cntrs.vl15_dropped -= dev->z_vl15_dropped;
|
|
|
|
cntrs.vl15_dropped += dev->n_vl15_dropped;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
memset(pmp->data, 0, sizeof(pmp->data));
|
|
|
|
|
|
|
|
p->port_select = port_select;
|
2011-07-05 15:46:29 +00:00
|
|
|
if (pmp->mad_hdr.attr_mod != 0 ||
|
2006-03-29 23:23:37 +00:00
|
|
|
(port_select != port && port_select != 0xFF))
|
2011-07-05 15:46:29 +00:00
|
|
|
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (cntrs.symbol_error_counter > 0xFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->symbol_error_counter = cpu_to_be16(0xFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->symbol_error_counter =
|
|
|
|
cpu_to_be16((u16)cntrs.symbol_error_counter);
|
|
|
|
if (cntrs.link_error_recovery_counter > 0xFFUL)
|
|
|
|
p->link_error_recovery_counter = 0xFF;
|
|
|
|
else
|
|
|
|
p->link_error_recovery_counter =
|
|
|
|
(u8)cntrs.link_error_recovery_counter;
|
|
|
|
if (cntrs.link_downed_counter > 0xFFUL)
|
|
|
|
p->link_downed_counter = 0xFF;
|
|
|
|
else
|
|
|
|
p->link_downed_counter = (u8)cntrs.link_downed_counter;
|
|
|
|
if (cntrs.port_rcv_errors > 0xFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->port_rcv_errors = cpu_to_be16(0xFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->port_rcv_errors =
|
|
|
|
cpu_to_be16((u16) cntrs.port_rcv_errors);
|
|
|
|
if (cntrs.port_rcv_remphys_errors > 0xFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->port_rcv_remphys_errors = cpu_to_be16(0xFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->port_rcv_remphys_errors =
|
|
|
|
cpu_to_be16((u16)cntrs.port_rcv_remphys_errors);
|
|
|
|
if (cntrs.port_xmit_discards > 0xFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->port_xmit_discards = cpu_to_be16(0xFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->port_xmit_discards =
|
|
|
|
cpu_to_be16((u16)cntrs.port_xmit_discards);
|
2006-07-01 11:36:09 +00:00
|
|
|
if (cntrs.local_link_integrity_errors > 0xFUL)
|
|
|
|
cntrs.local_link_integrity_errors = 0xFUL;
|
|
|
|
if (cntrs.excessive_buffer_overrun_errors > 0xFUL)
|
|
|
|
cntrs.excessive_buffer_overrun_errors = 0xFUL;
|
2011-07-05 15:46:29 +00:00
|
|
|
p->link_overrun_errors = (cntrs.local_link_integrity_errors << 4) |
|
2006-07-01 11:36:09 +00:00
|
|
|
cntrs.excessive_buffer_overrun_errors;
|
2008-01-07 05:02:33 +00:00
|
|
|
if (cntrs.vl15_dropped > 0xFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->vl15_dropped = cpu_to_be16(0xFFFF);
|
2006-07-01 11:36:09 +00:00
|
|
|
else
|
2008-01-07 05:02:33 +00:00
|
|
|
p->vl15_dropped = cpu_to_be16((u16)cntrs.vl15_dropped);
|
2006-03-29 23:23:37 +00:00
|
|
|
if (cntrs.port_xmit_data > 0xFFFFFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->port_xmit_data = cpu_to_be32(0xFFFFFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->port_xmit_data = cpu_to_be32((u32)cntrs.port_xmit_data);
|
|
|
|
if (cntrs.port_rcv_data > 0xFFFFFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->port_rcv_data = cpu_to_be32(0xFFFFFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->port_rcv_data = cpu_to_be32((u32)cntrs.port_rcv_data);
|
|
|
|
if (cntrs.port_xmit_packets > 0xFFFFFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->port_xmit_packets = cpu_to_be32(0xFFFFFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->port_xmit_packets =
|
|
|
|
cpu_to_be32((u32)cntrs.port_xmit_packets);
|
|
|
|
if (cntrs.port_rcv_packets > 0xFFFFFFFFUL)
|
2009-01-18 01:11:57 +00:00
|
|
|
p->port_rcv_packets = cpu_to_be32(0xFFFFFFFF);
|
2006-03-29 23:23:37 +00:00
|
|
|
else
|
|
|
|
p->port_rcv_packets =
|
|
|
|
cpu_to_be32((u32) cntrs.port_rcv_packets);
|
|
|
|
|
|
|
|
return reply((struct ib_smp *) pmp);
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_get_portcounters_ext(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct ib_pma_portcounters_ext *p =
|
|
|
|
(struct ib_pma_portcounters_ext *)pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
|
|
|
u64 swords, rwords, spkts, rpkts, xwait;
|
|
|
|
u8 port_select = p->port_select;
|
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
ipath_snapshot_counters(dev->dd, &swords, &rwords, &spkts,
|
|
|
|
&rpkts, &xwait);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
/* Adjust counters for any resets done. */
|
2006-07-01 11:35:48 +00:00
|
|
|
swords -= dev->z_port_xmit_data;
|
|
|
|
rwords -= dev->z_port_rcv_data;
|
|
|
|
spkts -= dev->z_port_xmit_packets;
|
|
|
|
rpkts -= dev->z_port_rcv_packets;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
memset(pmp->data, 0, sizeof(pmp->data));
|
|
|
|
|
|
|
|
p->port_select = port_select;
|
2011-07-05 15:46:29 +00:00
|
|
|
if (pmp->mad_hdr.attr_mod != 0 ||
|
2006-03-29 23:23:37 +00:00
|
|
|
(port_select != port && port_select != 0xFF))
|
2011-07-05 15:46:29 +00:00
|
|
|
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
p->port_xmit_data = cpu_to_be64(swords);
|
|
|
|
p->port_rcv_data = cpu_to_be64(rwords);
|
|
|
|
p->port_xmit_packets = cpu_to_be64(spkts);
|
|
|
|
p->port_rcv_packets = cpu_to_be64(rpkts);
|
|
|
|
p->port_unicast_xmit_packets = cpu_to_be64(dev->n_unicast_xmit);
|
|
|
|
p->port_unicast_rcv_packets = cpu_to_be64(dev->n_unicast_rcv);
|
|
|
|
p->port_multicast_xmit_packets = cpu_to_be64(dev->n_multicast_xmit);
|
|
|
|
p->port_multicast_rcv_packets = cpu_to_be64(dev->n_multicast_rcv);
|
|
|
|
|
|
|
|
return reply((struct ib_smp *) pmp);
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_set_portcounters(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct ib_pma_portcounters *p = (struct ib_pma_portcounters *)
|
|
|
|
pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
2006-08-25 18:24:32 +00:00
|
|
|
struct ipath_verbs_counters cntrs;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Since the HW doesn't support clearing counters, we save the
|
|
|
|
* current count and subtract it from future responses.
|
|
|
|
*/
|
2006-08-25 18:24:32 +00:00
|
|
|
ipath_get_counters(dev->dd, &cntrs);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_SYMBOL_ERROR)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_symbol_error_counter = cntrs.symbol_error_counter;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_LINK_ERROR_RECOVERY)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_link_error_recovery_counter =
|
2006-03-29 23:23:37 +00:00
|
|
|
cntrs.link_error_recovery_counter;
|
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_LINK_DOWNED)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_link_downed_counter = cntrs.link_downed_counter;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_RCV_ERRORS)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_rcv_errors =
|
2006-03-29 23:23:37 +00:00
|
|
|
cntrs.port_rcv_errors + dev->rcv_errors;
|
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_rcv_remphys_errors =
|
2006-03-29 23:23:37 +00:00
|
|
|
cntrs.port_rcv_remphys_errors;
|
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_XMIT_DISCARDS)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_xmit_discards = cntrs.port_xmit_discards;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
2006-07-01 11:36:09 +00:00
|
|
|
if (p->counter_select & IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS)
|
|
|
|
dev->z_local_link_integrity_errors =
|
|
|
|
cntrs.local_link_integrity_errors;
|
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS)
|
|
|
|
dev->z_excessive_buffer_overrun_errors =
|
|
|
|
cntrs.excessive_buffer_overrun_errors;
|
|
|
|
|
2008-01-07 05:02:33 +00:00
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_VL15_DROPPED) {
|
2006-07-01 11:36:09 +00:00
|
|
|
dev->n_vl15_dropped = 0;
|
2008-01-07 05:02:33 +00:00
|
|
|
dev->z_vl15_dropped = cntrs.vl15_dropped;
|
|
|
|
}
|
2006-07-01 11:36:09 +00:00
|
|
|
|
2006-03-29 23:23:37 +00:00
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_XMIT_DATA)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_xmit_data = cntrs.port_xmit_data;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_RCV_DATA)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_rcv_data = cntrs.port_rcv_data;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_XMIT_PACKETS)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_xmit_packets = cntrs.port_xmit_packets;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SEL_PORT_RCV_PACKETS)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_rcv_packets = cntrs.port_rcv_packets;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
return recv_pma_get_portcounters(pmp, ibdev, port);
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
static int recv_pma_set_portcounters_ext(struct ib_pma_mad *pmp,
|
2006-03-29 23:23:37 +00:00
|
|
|
struct ib_device *ibdev, u8 port)
|
|
|
|
{
|
|
|
|
struct ib_pma_portcounters *p = (struct ib_pma_portcounters *)
|
|
|
|
pmp->data;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
|
|
|
u64 swords, rwords, spkts, rpkts, xwait;
|
|
|
|
|
2006-08-25 18:24:32 +00:00
|
|
|
ipath_snapshot_counters(dev->dd, &swords, &rwords, &spkts,
|
|
|
|
&rpkts, &xwait);
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_XMIT_DATA)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_xmit_data = swords;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_RCV_DATA)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_rcv_data = rwords;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_XMIT_PACKETS)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_xmit_packets = spkts;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_RCV_PACKETS)
|
2006-07-01 11:35:48 +00:00
|
|
|
dev->z_port_rcv_packets = rpkts;
|
2006-03-29 23:23:37 +00:00
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_UNI_XMIT_PACKETS)
|
|
|
|
dev->n_unicast_xmit = 0;
|
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_UNI_RCV_PACKETS)
|
|
|
|
dev->n_unicast_rcv = 0;
|
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS)
|
|
|
|
dev->n_multicast_xmit = 0;
|
|
|
|
|
|
|
|
if (p->counter_select & IB_PMA_SELX_PORT_MULTI_RCV_PACKETS)
|
|
|
|
dev->n_multicast_rcv = 0;
|
|
|
|
|
|
|
|
return recv_pma_get_portcounters_ext(pmp, ibdev, port);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int process_subn(struct ib_device *ibdev, int mad_flags,
|
|
|
|
u8 port_num, struct ib_mad *in_mad,
|
|
|
|
struct ib_mad *out_mad)
|
|
|
|
{
|
|
|
|
struct ib_smp *smp = (struct ib_smp *)out_mad;
|
|
|
|
struct ipath_ibdev *dev = to_idev(ibdev);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
*out_mad = *in_mad;
|
|
|
|
if (smp->class_version != 1) {
|
|
|
|
smp->status |= IB_SMP_UNSUP_VERSION;
|
|
|
|
ret = reply(smp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is the mkey in the process of expiring? */
|
2008-04-17 04:09:28 +00:00
|
|
|
if (dev->mkey_lease_timeout &&
|
|
|
|
time_after_eq(jiffies, dev->mkey_lease_timeout)) {
|
2006-03-29 23:23:37 +00:00
|
|
|
/* Clear timeout and mkey protection field. */
|
|
|
|
dev->mkey_lease_timeout = 0;
|
2007-09-13 18:42:52 +00:00
|
|
|
dev->mkeyprot = 0;
|
2006-03-29 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* M_Key checking depends on
|
|
|
|
* Portinfo:M_Key_protect_bits
|
|
|
|
*/
|
|
|
|
if ((mad_flags & IB_MAD_IGNORE_MKEY) == 0 && dev->mkey != 0 &&
|
|
|
|
dev->mkey != smp->mkey &&
|
|
|
|
(smp->method == IB_MGMT_METHOD_SET ||
|
|
|
|
(smp->method == IB_MGMT_METHOD_GET &&
|
2007-09-13 18:42:52 +00:00
|
|
|
dev->mkeyprot >= 2))) {
|
2006-03-29 23:23:37 +00:00
|
|
|
if (dev->mkey_violations != 0xFFFF)
|
|
|
|
++dev->mkey_violations;
|
|
|
|
if (dev->mkey_lease_timeout ||
|
|
|
|
dev->mkey_lease_period == 0) {
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS |
|
|
|
|
IB_MAD_RESULT_CONSUMED;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
dev->mkey_lease_timeout = jiffies +
|
|
|
|
dev->mkey_lease_period * HZ;
|
|
|
|
/* Future: Generate a trap notice. */
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
|
|
|
|
goto bail;
|
|
|
|
} else if (dev->mkey_lease_timeout)
|
|
|
|
dev->mkey_lease_timeout = 0;
|
|
|
|
|
|
|
|
switch (smp->method) {
|
|
|
|
case IB_MGMT_METHOD_GET:
|
|
|
|
switch (smp->attr_id) {
|
|
|
|
case IB_SMP_ATTR_NODE_DESC:
|
|
|
|
ret = recv_subn_get_nodedescription(smp, ibdev);
|
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_NODE_INFO:
|
|
|
|
ret = recv_subn_get_nodeinfo(smp, ibdev, port_num);
|
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_GUID_INFO:
|
|
|
|
ret = recv_subn_get_guidinfo(smp, ibdev);
|
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_PORT_INFO:
|
|
|
|
ret = recv_subn_get_portinfo(smp, ibdev, port_num);
|
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_PKEY_TABLE:
|
|
|
|
ret = recv_subn_get_pkeytable(smp, ibdev);
|
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_SM_INFO:
|
|
|
|
if (dev->port_cap_flags & IB_PORT_SM_DISABLED) {
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS |
|
|
|
|
IB_MAD_RESULT_CONSUMED;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (dev->port_cap_flags & IB_PORT_SM) {
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
|
|
|
smp->status |= IB_SMP_UNSUP_METH_ATTR;
|
|
|
|
ret = reply(smp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IB_MGMT_METHOD_SET:
|
|
|
|
switch (smp->attr_id) {
|
|
|
|
case IB_SMP_ATTR_GUID_INFO:
|
|
|
|
ret = recv_subn_set_guidinfo(smp, ibdev);
|
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_PORT_INFO:
|
|
|
|
ret = recv_subn_set_portinfo(smp, ibdev, port_num);
|
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_PKEY_TABLE:
|
2014-07-08 09:45:10 +00:00
|
|
|
ret = recv_subn_set_pkeytable(smp, ibdev, port_num);
|
2006-03-29 23:23:37 +00:00
|
|
|
goto bail;
|
|
|
|
case IB_SMP_ATTR_SM_INFO:
|
|
|
|
if (dev->port_cap_flags & IB_PORT_SM_DISABLED) {
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS |
|
|
|
|
IB_MAD_RESULT_CONSUMED;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (dev->port_cap_flags & IB_PORT_SM) {
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
|
|
|
smp->status |= IB_SMP_UNSUP_METH_ATTR;
|
|
|
|
ret = reply(smp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2008-06-06 18:23:29 +00:00
|
|
|
case IB_MGMT_METHOD_TRAP:
|
|
|
|
case IB_MGMT_METHOD_REPORT:
|
|
|
|
case IB_MGMT_METHOD_REPORT_RESP:
|
|
|
|
case IB_MGMT_METHOD_TRAP_REPRESS:
|
2006-03-29 23:23:37 +00:00
|
|
|
case IB_MGMT_METHOD_GET_RESP:
|
|
|
|
/*
|
|
|
|
* The ib_mad module will call us to process responses
|
|
|
|
* before checking for other consumers.
|
|
|
|
* Just tell the caller to process it normally.
|
|
|
|
*/
|
2007-10-23 22:07:41 +00:00
|
|
|
ret = IB_MAD_RESULT_SUCCESS;
|
2006-03-29 23:23:37 +00:00
|
|
|
goto bail;
|
|
|
|
default:
|
|
|
|
smp->status |= IB_SMP_UNSUP_METHOD;
|
|
|
|
ret = reply(smp);
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int process_perf(struct ib_device *ibdev, u8 port_num,
|
|
|
|
struct ib_mad *in_mad,
|
|
|
|
struct ib_mad *out_mad)
|
|
|
|
{
|
2011-07-05 15:46:29 +00:00
|
|
|
struct ib_pma_mad *pmp = (struct ib_pma_mad *)out_mad;
|
2006-03-29 23:23:37 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
*out_mad = *in_mad;
|
2011-07-05 15:46:29 +00:00
|
|
|
if (pmp->mad_hdr.class_version != 1) {
|
|
|
|
pmp->mad_hdr.status |= IB_SMP_UNSUP_VERSION;
|
2006-03-29 23:23:37 +00:00
|
|
|
ret = reply((struct ib_smp *) pmp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2011-07-05 15:46:29 +00:00
|
|
|
switch (pmp->mad_hdr.method) {
|
2006-03-29 23:23:37 +00:00
|
|
|
case IB_MGMT_METHOD_GET:
|
2011-07-05 15:46:29 +00:00
|
|
|
switch (pmp->mad_hdr.attr_id) {
|
2006-03-29 23:23:37 +00:00
|
|
|
case IB_PMA_CLASS_PORT_INFO:
|
|
|
|
ret = recv_pma_get_classportinfo(pmp);
|
|
|
|
goto bail;
|
|
|
|
case IB_PMA_PORT_SAMPLES_CONTROL:
|
|
|
|
ret = recv_pma_get_portsamplescontrol(pmp, ibdev,
|
|
|
|
port_num);
|
|
|
|
goto bail;
|
|
|
|
case IB_PMA_PORT_SAMPLES_RESULT:
|
|
|
|
ret = recv_pma_get_portsamplesresult(pmp, ibdev);
|
|
|
|
goto bail;
|
|
|
|
case IB_PMA_PORT_SAMPLES_RESULT_EXT:
|
|
|
|
ret = recv_pma_get_portsamplesresult_ext(pmp,
|
|
|
|
ibdev);
|
|
|
|
goto bail;
|
|
|
|
case IB_PMA_PORT_COUNTERS:
|
|
|
|
ret = recv_pma_get_portcounters(pmp, ibdev,
|
|
|
|
port_num);
|
|
|
|
goto bail;
|
|
|
|
case IB_PMA_PORT_COUNTERS_EXT:
|
|
|
|
ret = recv_pma_get_portcounters_ext(pmp, ibdev,
|
|
|
|
port_num);
|
|
|
|
goto bail;
|
|
|
|
default:
|
2011-07-05 15:46:29 +00:00
|
|
|
pmp->mad_hdr.status |= IB_SMP_UNSUP_METH_ATTR;
|
2006-03-29 23:23:37 +00:00
|
|
|
ret = reply((struct ib_smp *) pmp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IB_MGMT_METHOD_SET:
|
2011-07-05 15:46:29 +00:00
|
|
|
switch (pmp->mad_hdr.attr_id) {
|
2006-03-29 23:23:37 +00:00
|
|
|
case IB_PMA_PORT_SAMPLES_CONTROL:
|
|
|
|
ret = recv_pma_set_portsamplescontrol(pmp, ibdev,
|
|
|
|
port_num);
|
|
|
|
goto bail;
|
|
|
|
case IB_PMA_PORT_COUNTERS:
|
|
|
|
ret = recv_pma_set_portcounters(pmp, ibdev,
|
|
|
|
port_num);
|
|
|
|
goto bail;
|
|
|
|
case IB_PMA_PORT_COUNTERS_EXT:
|
|
|
|
ret = recv_pma_set_portcounters_ext(pmp, ibdev,
|
|
|
|
port_num);
|
|
|
|
goto bail;
|
|
|
|
default:
|
2011-07-05 15:46:29 +00:00
|
|
|
pmp->mad_hdr.status |= IB_SMP_UNSUP_METH_ATTR;
|
2006-03-29 23:23:37 +00:00
|
|
|
ret = reply((struct ib_smp *) pmp);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
case IB_MGMT_METHOD_GET_RESP:
|
|
|
|
/*
|
|
|
|
* The ib_mad module will call us to process responses
|
|
|
|
* before checking for other consumers.
|
|
|
|
* Just tell the caller to process it normally.
|
|
|
|
*/
|
2007-10-23 22:07:41 +00:00
|
|
|
ret = IB_MAD_RESULT_SUCCESS;
|
2006-03-29 23:23:37 +00:00
|
|
|
goto bail;
|
|
|
|
default:
|
2011-07-05 15:46:29 +00:00
|
|
|
pmp->mad_hdr.status |= IB_SMP_UNSUP_METHOD;
|
2006-03-29 23:23:37 +00:00
|
|
|
ret = reply((struct ib_smp *) pmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ipath_process_mad - process an incoming MAD packet
|
|
|
|
* @ibdev: the infiniband device this packet came in on
|
|
|
|
* @mad_flags: MAD flags
|
|
|
|
* @port_num: the port number this packet came in on
|
|
|
|
* @in_wc: the work completion entry for this packet
|
|
|
|
* @in_grh: the global route header for this packet
|
|
|
|
* @in_mad: the incoming MAD
|
|
|
|
* @out_mad: any outgoing MAD reply
|
|
|
|
*
|
|
|
|
* Returns IB_MAD_RESULT_SUCCESS if this is a MAD that we are not
|
|
|
|
* interested in processing.
|
|
|
|
*
|
|
|
|
* Note that the verbs framework has already done the MAD sanity checks,
|
|
|
|
* and hop count/pointer updating for IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE
|
|
|
|
* MADs.
|
|
|
|
*
|
|
|
|
* This is called by the ib_mad module.
|
|
|
|
*/
|
|
|
|
int ipath_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
|
|
|
|
struct ib_wc *in_wc, struct ib_grh *in_grh,
|
|
|
|
struct ib_mad *in_mad, struct ib_mad *out_mad)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
switch (in_mad->mad_hdr.mgmt_class) {
|
|
|
|
case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
|
|
|
|
case IB_MGMT_CLASS_SUBN_LID_ROUTED:
|
|
|
|
ret = process_subn(ibdev, mad_flags, port_num,
|
|
|
|
in_mad, out_mad);
|
|
|
|
goto bail;
|
|
|
|
case IB_MGMT_CLASS_PERF_MGMT:
|
|
|
|
ret = process_perf(ibdev, port_num, in_mad, out_mad);
|
|
|
|
goto bail;
|
|
|
|
default:
|
|
|
|
ret = IB_MAD_RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return ret;
|
|
|
|
}
|