Commit 542869a1 authored by Ralph Campbell's avatar Ralph Campbell Committed by Roland Dreier

IB/ipath: Remove duplicate copy of LMC

The LMC value was being saved by the SMA in two places. This patch
cleans it up so only one copy is kept.
Signed-off-by: default avatarRalph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 15cba26f
...@@ -245,7 +245,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp, ...@@ -245,7 +245,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp,
/* Only return the mkey if the protection field allows it. */ /* Only return the mkey if the protection field allows it. */
if (smp->method == IB_MGMT_METHOD_SET || dev->mkey == smp->mkey || if (smp->method == IB_MGMT_METHOD_SET || dev->mkey == smp->mkey ||
(dev->mkeyprot_resv_lmc >> 6) == 0) dev->mkeyprot == 0)
pip->mkey = dev->mkey; pip->mkey = dev->mkey;
pip->gid_prefix = dev->gid_prefix; pip->gid_prefix = dev->gid_prefix;
lid = dev->dd->ipath_lid; lid = dev->dd->ipath_lid;
...@@ -264,7 +264,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp, ...@@ -264,7 +264,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp,
pip->portphysstate_linkdown = pip->portphysstate_linkdown =
(ipath_cvt_physportstate[ibcstat & 0xf] << 4) | (ipath_cvt_physportstate[ibcstat & 0xf] << 4) |
(get_linkdowndefaultstate(dev->dd) ? 1 : 2); (get_linkdowndefaultstate(dev->dd) ? 1 : 2);
pip->mkeyprot_resv_lmc = dev->mkeyprot_resv_lmc; pip->mkeyprot_resv_lmc = (dev->mkeyprot << 6) | dev->dd->ipath_lmc;
pip->linkspeedactive_enabled = 0x11; /* 2.5Gbps, 2.5Gbps */ pip->linkspeedactive_enabled = 0x11; /* 2.5Gbps, 2.5Gbps */
switch (dev->dd->ipath_ibmtu) { switch (dev->dd->ipath_ibmtu) {
case 4096: case 4096:
...@@ -401,6 +401,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -401,6 +401,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
struct ib_port_info *pip = (struct ib_port_info *)smp->data; struct ib_port_info *pip = (struct ib_port_info *)smp->data;
struct ib_event event; struct ib_event event;
struct ipath_ibdev *dev; struct ipath_ibdev *dev;
struct ipath_devdata *dd;
u32 flags; u32 flags;
char clientrereg = 0; char clientrereg = 0;
u16 lid, smlid; u16 lid, smlid;
...@@ -415,6 +416,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -415,6 +416,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
goto err; goto err;
dev = to_idev(ibdev); dev = to_idev(ibdev);
dd = dev->dd;
event.device = ibdev; event.device = ibdev;
event.element.port_num = port; event.element.port_num = port;
...@@ -423,11 +425,12 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -423,11 +425,12 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
dev->mkey_lease_period = be16_to_cpu(pip->mkey_lease_period); dev->mkey_lease_period = be16_to_cpu(pip->mkey_lease_period);
lid = be16_to_cpu(pip->lid); lid = be16_to_cpu(pip->lid);
if (lid != dev->dd->ipath_lid) { if (dd->ipath_lid != lid ||
dd->ipath_lmc != (pip->mkeyprot_resv_lmc & 7)) {
/* Must be a valid unicast LID address. */ /* Must be a valid unicast LID address. */
if (lid == 0 || lid >= IPATH_MULTICAST_LID_BASE) if (lid == 0 || lid >= IPATH_MULTICAST_LID_BASE)
goto err; goto err;
ipath_set_lid(dev->dd, lid, pip->mkeyprot_resv_lmc & 7); ipath_set_lid(dd, lid, pip->mkeyprot_resv_lmc & 7);
event.event = IB_EVENT_LID_CHANGE; event.event = IB_EVENT_LID_CHANGE;
ib_dispatch_event(&event); ib_dispatch_event(&event);
} }
...@@ -461,18 +464,18 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -461,18 +464,18 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
case 0: /* NOP */ case 0: /* NOP */
break; break;
case 1: /* SLEEP */ case 1: /* SLEEP */
if (set_linkdowndefaultstate(dev->dd, 1)) if (set_linkdowndefaultstate(dd, 1))
goto err; goto err;
break; break;
case 2: /* POLL */ case 2: /* POLL */
if (set_linkdowndefaultstate(dev->dd, 0)) if (set_linkdowndefaultstate(dd, 0))
goto err; goto err;
break; break;
default: default:
goto err; goto err;
} }
dev->mkeyprot_resv_lmc = pip->mkeyprot_resv_lmc; dev->mkeyprot = pip->mkeyprot_resv_lmc >> 6;
dev->vl_high_limit = pip->vl_high_limit; dev->vl_high_limit = pip->vl_high_limit;
switch ((pip->neighbormtu_mastersmsl >> 4) & 0xF) { switch ((pip->neighbormtu_mastersmsl >> 4) & 0xF) {
...@@ -495,7 +498,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -495,7 +498,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
/* XXX We have already partially updated our state! */ /* XXX We have already partially updated our state! */
goto err; goto err;
} }
ipath_set_mtu(dev->dd, mtu); ipath_set_mtu(dd, mtu);
dev->sm_sl = pip->neighbormtu_mastersmsl & 0xF; dev->sm_sl = pip->neighbormtu_mastersmsl & 0xF;
...@@ -511,16 +514,16 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -511,16 +514,16 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
* later. * later.
*/ */
if (pip->pkey_violations == 0) if (pip->pkey_violations == 0)
dev->z_pkey_violations = ipath_get_cr_errpkey(dev->dd); dev->z_pkey_violations = ipath_get_cr_errpkey(dd);
if (pip->qkey_violations == 0) if (pip->qkey_violations == 0)
dev->qkey_violations = 0; dev->qkey_violations = 0;
ore = pip->localphyerrors_overrunerrors; ore = pip->localphyerrors_overrunerrors;
if (set_phyerrthreshold(dev->dd, (ore >> 4) & 0xF)) if (set_phyerrthreshold(dd, (ore >> 4) & 0xF))
goto err; goto err;
if (set_overrunthreshold(dev->dd, (ore & 0xF))) if (set_overrunthreshold(dd, (ore & 0xF)))
goto err; goto err;
dev->subnet_timeout = pip->clientrereg_resv_subnetto & 0x1F; dev->subnet_timeout = pip->clientrereg_resv_subnetto & 0x1F;
...@@ -538,7 +541,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -538,7 +541,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
* is down or is being set to down. * is down or is being set to down.
*/ */
state = pip->linkspeed_portstate & 0xF; state = pip->linkspeed_portstate & 0xF;
flags = dev->dd->ipath_flags; flags = dd->ipath_flags;
lstate = (pip->portphysstate_linkdown >> 4) & 0xF; lstate = (pip->portphysstate_linkdown >> 4) & 0xF;
if (lstate && !(state == IB_PORT_DOWN || state == IB_PORT_NOP)) if (lstate && !(state == IB_PORT_DOWN || state == IB_PORT_NOP))
goto err; goto err;
...@@ -554,7 +557,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -554,7 +557,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
/* FALLTHROUGH */ /* FALLTHROUGH */
case IB_PORT_DOWN: case IB_PORT_DOWN:
if (lstate == 0) if (lstate == 0)
if (get_linkdowndefaultstate(dev->dd)) if (get_linkdowndefaultstate(dd))
lstate = IPATH_IB_LINKDOWN_SLEEP; lstate = IPATH_IB_LINKDOWN_SLEEP;
else else
lstate = IPATH_IB_LINKDOWN; lstate = IPATH_IB_LINKDOWN;
...@@ -566,7 +569,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -566,7 +569,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
lstate = IPATH_IB_LINKDOWN_DISABLE; lstate = IPATH_IB_LINKDOWN_DISABLE;
else else
goto err; goto err;
ipath_set_linkstate(dev->dd, lstate); ipath_set_linkstate(dd, lstate);
if (flags & IPATH_LINKACTIVE) { if (flags & IPATH_LINKACTIVE) {
event.event = IB_EVENT_PORT_ERR; event.event = IB_EVENT_PORT_ERR;
ib_dispatch_event(&event); ib_dispatch_event(&event);
...@@ -575,7 +578,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -575,7 +578,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
case IB_PORT_ARMED: case IB_PORT_ARMED:
if (!(flags & (IPATH_LINKINIT | IPATH_LINKACTIVE))) if (!(flags & (IPATH_LINKINIT | IPATH_LINKACTIVE)))
break; break;
ipath_set_linkstate(dev->dd, IPATH_IB_LINKARM); ipath_set_linkstate(dd, IPATH_IB_LINKARM);
if (flags & IPATH_LINKACTIVE) { if (flags & IPATH_LINKACTIVE) {
event.event = IB_EVENT_PORT_ERR; event.event = IB_EVENT_PORT_ERR;
ib_dispatch_event(&event); ib_dispatch_event(&event);
...@@ -584,7 +587,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -584,7 +587,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
case IB_PORT_ACTIVE: case IB_PORT_ACTIVE:
if (!(flags & IPATH_LINKARMED)) if (!(flags & IPATH_LINKARMED))
break; break;
ipath_set_linkstate(dev->dd, IPATH_IB_LINKACTIVE); ipath_set_linkstate(dd, IPATH_IB_LINKACTIVE);
event.event = IB_EVENT_PORT_ACTIVE; event.event = IB_EVENT_PORT_ACTIVE;
ib_dispatch_event(&event); ib_dispatch_event(&event);
break; break;
...@@ -1350,7 +1353,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags, ...@@ -1350,7 +1353,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags,
if (dev->mkey_lease_timeout && jiffies >= dev->mkey_lease_timeout) { if (dev->mkey_lease_timeout && jiffies >= dev->mkey_lease_timeout) {
/* Clear timeout and mkey protection field. */ /* Clear timeout and mkey protection field. */
dev->mkey_lease_timeout = 0; dev->mkey_lease_timeout = 0;
dev->mkeyprot_resv_lmc &= 0x3F; dev->mkeyprot = 0;
} }
/* /*
...@@ -1361,7 +1364,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags, ...@@ -1361,7 +1364,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags,
dev->mkey != smp->mkey && dev->mkey != smp->mkey &&
(smp->method == IB_MGMT_METHOD_SET || (smp->method == IB_MGMT_METHOD_SET ||
(smp->method == IB_MGMT_METHOD_GET && (smp->method == IB_MGMT_METHOD_GET &&
(dev->mkeyprot_resv_lmc >> 7) != 0))) { dev->mkeyprot >= 2))) {
if (dev->mkey_violations != 0xFFFF) if (dev->mkey_violations != 0xFFFF)
++dev->mkey_violations; ++dev->mkey_violations;
if (dev->mkey_lease_timeout || if (dev->mkey_lease_timeout ||
......
...@@ -236,10 +236,10 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe) ...@@ -236,10 +236,10 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
wc.pkey_index = 0; wc.pkey_index = 0;
wc.slid = dev->dd->ipath_lid | wc.slid = dev->dd->ipath_lid |
(ah_attr->src_path_bits & (ah_attr->src_path_bits &
((1 << (dev->mkeyprot_resv_lmc & 7)) - 1)); ((1 << dev->dd->ipath_lmc) - 1));
wc.sl = ah_attr->sl; wc.sl = ah_attr->sl;
wc.dlid_path_bits = wc.dlid_path_bits =
ah_attr->dlid & ((1 << (dev->mkeyprot_resv_lmc & 7)) - 1); ah_attr->dlid & ((1 << dev->dd->ipath_lmc) - 1);
wc.port_num = 1; wc.port_num = 1;
/* Signal completion event if the solicited bit is set. */ /* Signal completion event if the solicited bit is set. */
ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
...@@ -289,7 +289,7 @@ int ipath_make_ud_req(struct ipath_qp *qp) ...@@ -289,7 +289,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
} else { } else {
dev->n_unicast_xmit++; dev->n_unicast_xmit++;
lid = ah_attr->dlid & lid = ah_attr->dlid &
~((1 << (dev->mkeyprot_resv_lmc & 7)) - 1); ~((1 << dev->dd->ipath_lmc) - 1);
if (unlikely(lid == dev->dd->ipath_lid)) { if (unlikely(lid == dev->dd->ipath_lid)) {
ipath_ud_loopback(qp, wqe); ipath_ud_loopback(qp, wqe);
goto done; goto done;
...@@ -341,7 +341,7 @@ int ipath_make_ud_req(struct ipath_qp *qp) ...@@ -341,7 +341,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
lid = dev->dd->ipath_lid; lid = dev->dd->ipath_lid;
if (lid) { if (lid) {
lid |= ah_attr->src_path_bits & lid |= ah_attr->src_path_bits &
((1 << (dev->mkeyprot_resv_lmc & 7)) - 1); ((1 << dev->dd->ipath_lmc) - 1);
qp->s_hdr.lrh[3] = cpu_to_be16(lid); qp->s_hdr.lrh[3] = cpu_to_be16(lid);
} else } else
qp->s_hdr.lrh[3] = IB_LID_PERMISSIVE; qp->s_hdr.lrh[3] = IB_LID_PERMISSIVE;
...@@ -551,7 +551,7 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, ...@@ -551,7 +551,7 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
* Save the LMC lower bits if the destination LID is a unicast LID. * Save the LMC lower bits if the destination LID is a unicast LID.
*/ */
wc.dlid_path_bits = dlid >= IPATH_MULTICAST_LID_BASE ? 0 : wc.dlid_path_bits = dlid >= IPATH_MULTICAST_LID_BASE ? 0 :
dlid & ((1 << (dev->mkeyprot_resv_lmc & 7)) - 1); dlid & ((1 << dev->dd->ipath_lmc) - 1);
wc.port_num = 1; wc.port_num = 1;
/* Signal completion event if the solicited bit is set. */ /* Signal completion event if the solicited bit is set. */
ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
......
...@@ -513,7 +513,7 @@ void ipath_ib_rcv(struct ipath_ibdev *dev, void *rhdr, void *data, ...@@ -513,7 +513,7 @@ void ipath_ib_rcv(struct ipath_ibdev *dev, void *rhdr, void *data,
/* Check for a valid destination LID (see ch. 7.11.1). */ /* Check for a valid destination LID (see ch. 7.11.1). */
lid = be16_to_cpu(hdr->lrh[1]); lid = be16_to_cpu(hdr->lrh[1]);
if (lid < IPATH_MULTICAST_LID_BASE) { if (lid < IPATH_MULTICAST_LID_BASE) {
lid &= ~((1 << (dev->mkeyprot_resv_lmc & 7)) - 1); lid &= ~((1 << dev->dd->ipath_lmc) - 1);
if (unlikely(lid != dev->dd->ipath_lid)) { if (unlikely(lid != dev->dd->ipath_lid)) {
dev->rcv_errors++; dev->rcv_errors++;
goto bail; goto bail;
...@@ -1152,7 +1152,7 @@ static int ipath_query_port(struct ib_device *ibdev, ...@@ -1152,7 +1152,7 @@ static int ipath_query_port(struct ib_device *ibdev,
memset(props, 0, sizeof(*props)); memset(props, 0, sizeof(*props));
props->lid = lid ? lid : __constant_be16_to_cpu(IB_LID_PERMISSIVE); props->lid = lid ? lid : __constant_be16_to_cpu(IB_LID_PERMISSIVE);
props->lmc = dev->mkeyprot_resv_lmc & 7; props->lmc = dd->ipath_lmc;
props->sm_lid = dev->sm_lid; props->sm_lid = dev->sm_lid;
props->sm_sl = dev->sm_sl; props->sm_sl = dev->sm_sl;
ibcstat = dd->ipath_lastibcstat; ibcstat = dd->ipath_lastibcstat;
......
...@@ -501,7 +501,7 @@ struct ipath_ibdev { ...@@ -501,7 +501,7 @@ struct ipath_ibdev {
int ib_unit; /* This is the device number */ int ib_unit; /* This is the device number */
u16 sm_lid; /* in host order */ u16 sm_lid; /* in host order */
u8 sm_sl; u8 sm_sl;
u8 mkeyprot_resv_lmc; u8 mkeyprot;
/* non-zero when timer is set */ /* non-zero when timer is set */
unsigned long mkey_lease_timeout; unsigned long mkey_lease_timeout;
......
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