Commit a51a2513 authored by Ralph Campbell's avatar Ralph Campbell Committed by Roland Dreier

IB/ipath: Add code to support multiple link speeds and widths

This patch adds code to get/set portinfo to support multiple link speeds
and widths.
Signed-off-by: default avatarRalph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 58411d1c
...@@ -801,6 +801,8 @@ void ipath_hol_event(unsigned long); ...@@ -801,6 +801,8 @@ void ipath_hol_event(unsigned long);
/* /*
* values for ipath_flags * values for ipath_flags
*/ */
/* chip can report link latency (IB 1.2) */
#define IPATH_HAS_LINK_LATENCY 0x1
/* The chip is up and initted */ /* The chip is up and initted */
#define IPATH_INITTED 0x2 #define IPATH_INITTED 0x2
/* set if any user code has set kr_rcvhdrsize */ /* set if any user code has set kr_rcvhdrsize */
......
...@@ -146,6 +146,15 @@ static int recv_subn_get_guidinfo(struct ib_smp *smp, ...@@ -146,6 +146,15 @@ static int recv_subn_get_guidinfo(struct ib_smp *smp,
return reply(smp); return reply(smp);
} }
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);
}
static int get_overrunthreshold(struct ipath_devdata *dd) static int get_overrunthreshold(struct ipath_devdata *dd)
{ {
...@@ -226,6 +235,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp, ...@@ -226,6 +235,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp,
struct ib_device *ibdev, u8 port) struct ib_device *ibdev, u8 port)
{ {
struct ipath_ibdev *dev; struct ipath_ibdev *dev;
struct ipath_devdata *dd;
struct ib_port_info *pip = (struct ib_port_info *)smp->data; struct ib_port_info *pip = (struct ib_port_info *)smp->data;
u16 lid; u16 lid;
u8 ibcstat; u8 ibcstat;
...@@ -239,6 +249,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp, ...@@ -239,6 +249,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp,
} }
dev = to_idev(ibdev); dev = to_idev(ibdev);
dd = dev->dd;
/* Clear all fields. Only set the non-zero fields. */ /* Clear all fields. Only set the non-zero fields. */
memset(smp->data, 0, sizeof(smp->data)); memset(smp->data, 0, sizeof(smp->data));
...@@ -248,25 +259,28 @@ static int recv_subn_get_portinfo(struct ib_smp *smp, ...@@ -248,25 +259,28 @@ static int recv_subn_get_portinfo(struct ib_smp *smp,
dev->mkeyprot == 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 = dd->ipath_lid;
pip->lid = lid ? cpu_to_be16(lid) : IB_LID_PERMISSIVE; pip->lid = lid ? cpu_to_be16(lid) : IB_LID_PERMISSIVE;
pip->sm_lid = cpu_to_be16(dev->sm_lid); pip->sm_lid = cpu_to_be16(dev->sm_lid);
pip->cap_mask = cpu_to_be32(dev->port_cap_flags); pip->cap_mask = cpu_to_be32(dev->port_cap_flags);
/* pip->diag_code; */ /* pip->diag_code; */
pip->mkey_lease_period = cpu_to_be16(dev->mkey_lease_period); pip->mkey_lease_period = cpu_to_be16(dev->mkey_lease_period);
pip->local_port_num = port; pip->local_port_num = port;
pip->link_width_enabled = dev->link_width_enabled; pip->link_width_enabled = dd->ipath_link_width_enabled;
pip->link_width_supported = 3; /* 1x or 4x */ pip->link_width_supported = dd->ipath_link_width_supported;
pip->link_width_active = 2; /* 4x */ pip->link_width_active = dd->ipath_link_width_active;
pip->linkspeed_portstate = 0x10; /* 2.5Gbps */ pip->linkspeed_portstate = dd->ipath_link_speed_supported << 4;
ibcstat = dev->dd->ipath_lastibcstat; ibcstat = dd->ipath_lastibcstat;
pip->linkspeed_portstate |= ((ibcstat >> 4) & 0x3) + 1; /* map LinkState to IB portinfo values. */
pip->linkspeed_portstate |= ipath_ib_linkstate(dd, ibcstat) + 1;
pip->portphysstate_linkdown = pip->portphysstate_linkdown =
(ipath_cvt_physportstate[ibcstat & 0xf] << 4) | (ipath_cvt_physportstate[ibcstat & dd->ibcs_lts_mask] << 4) |
(get_linkdowndefaultstate(dev->dd) ? 1 : 2); (get_linkdowndefaultstate(dd) ? 1 : 2);
pip->mkeyprot_resv_lmc = (dev->mkeyprot << 6) | dev->dd->ipath_lmc; pip->mkeyprot_resv_lmc = (dev->mkeyprot << 6) | dd->ipath_lmc;
pip->linkspeedactive_enabled = 0x11; /* 2.5Gbps, 2.5Gbps */ pip->linkspeedactive_enabled = (dd->ipath_link_speed_active << 4) |
switch (dev->dd->ipath_ibmtu) { dd->ipath_link_speed_enabled;
switch (dd->ipath_ibmtu) {
case 4096: case 4096:
mtu = IB_MTU_4096; mtu = IB_MTU_4096;
break; break;
...@@ -300,7 +314,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp, ...@@ -300,7 +314,7 @@ static int recv_subn_get_portinfo(struct ib_smp *smp,
pip->mkey_violations = cpu_to_be16(dev->mkey_violations); pip->mkey_violations = cpu_to_be16(dev->mkey_violations);
/* P_KeyViolations are counted by hardware. */ /* P_KeyViolations are counted by hardware. */
pip->pkey_violations = pip->pkey_violations =
cpu_to_be16((ipath_get_cr_errpkey(dev->dd) - cpu_to_be16((ipath_get_cr_errpkey(dd) -
dev->z_pkey_violations) & 0xFFFF); dev->z_pkey_violations) & 0xFFFF);
pip->qkey_violations = cpu_to_be16(dev->qkey_violations); pip->qkey_violations = cpu_to_be16(dev->qkey_violations);
/* Only the hardware GUID is supported for now */ /* Only the hardware GUID is supported for now */
...@@ -309,10 +323,17 @@ static int recv_subn_get_portinfo(struct ib_smp *smp, ...@@ -309,10 +323,17 @@ static int recv_subn_get_portinfo(struct ib_smp *smp,
/* 32.768 usec. response time (guessing) */ /* 32.768 usec. response time (guessing) */
pip->resv_resptimevalue = 3; pip->resv_resptimevalue = 3;
pip->localphyerrors_overrunerrors = pip->localphyerrors_overrunerrors =
(get_phyerrthreshold(dev->dd) << 4) | (get_phyerrthreshold(dd) << 4) |
get_overrunthreshold(dev->dd); get_overrunthreshold(dd);
/* pip->max_credit_hint; */ /* pip->max_credit_hint; */
/* pip->link_roundtrip_latency[3]; */ 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;
}
ret = reply(smp); ret = reply(smp);
...@@ -440,19 +461,25 @@ static int recv_subn_set_portinfo(struct ib_smp *smp, ...@@ -440,19 +461,25 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
ib_dispatch_event(&event); ib_dispatch_event(&event);
} }
/* Only 4x supported but allow 1x or 4x to be set (see 14.2.6.6). */ /* Allow 1x or 4x to be set (see 14.2.6.6). */
lwe = pip->link_width_enabled; lwe = pip->link_width_enabled;
if ((lwe >= 4 && lwe <= 8) || (lwe >= 0xC && lwe <= 0xFE)) if (lwe) {
goto err; if (lwe == 0xFF)
if (lwe == 0xFF) lwe = dd->ipath_link_width_supported;
dev->link_width_enabled = 3; /* 1x or 4x */ else if (lwe >= 16 || (lwe & ~dd->ipath_link_width_supported))
else if (lwe) goto err;
dev->link_width_enabled = lwe; set_link_width_enabled(dd, lwe);
}
/* Only 2.5 Gbs supported. */ /* Allow 2.5 or 5.0 Gbs. */
lse = pip->linkspeedactive_enabled & 0xF; lse = pip->linkspeedactive_enabled & 0xF;
if (lse >= 2 && lse <= 0xE) if (lse) {
goto err; 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);
}
/* Set link down default state. */ /* Set link down default state. */
switch (pip->portphysstate_linkdown & 0xF) { switch (pip->portphysstate_linkdown & 0xF) {
...@@ -946,10 +973,14 @@ static int recv_pma_get_portsamplescontrol(struct ib_perf *pmp, ...@@ -946,10 +973,14 @@ static int recv_pma_get_portsamplescontrol(struct ib_perf *pmp,
* nsec. 0 == 4 nsec., 1 == 8 nsec., ..., 255 == 1020 nsec. Sample * nsec. 0 == 4 nsec., 1 == 8 nsec., ..., 255 == 1020 nsec. Sample
* intervals are counted in ticks. Since we use Linux timers, that * 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 * count in jiffies, we can't sample for less than 1000 ticks if HZ
* == 1000 (4000 ticks if HZ is 250). * == 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.
*/ */
/* XXX This is WRONG. */ if (crp->cr_psstat)
p->tick = 250; /* 1 usec. */ p->tick = dev->dd->ipath_link_speed_active - 1;
else
p->tick = 250; /* 1 usec. */
p->counter_width = 4; /* 32 bit counters */ p->counter_width = 4; /* 32 bit counters */
p->counter_mask0_9 = COUNTER_MASK0_9; p->counter_mask0_9 = COUNTER_MASK0_9;
spin_lock_irqsave(&dev->pending_lock, flags); spin_lock_irqsave(&dev->pending_lock, flags);
......
...@@ -1183,7 +1183,9 @@ static int ipath_query_port(struct ib_device *ibdev, ...@@ -1183,7 +1183,9 @@ static int ipath_query_port(struct ib_device *ibdev,
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;
props->state = ((ibcstat >> 4) & 0x3) + 1; /* map LinkState to IB portinfo values. */
props->state = ipath_ib_linkstate(dd, ibcstat) + 1;
/* See phys_state_show() */ /* See phys_state_show() */
props->phys_state = /* MEA: assumes shift == 0 */ props->phys_state = /* MEA: assumes shift == 0 */
ipath_cvt_physportstate[dd->ipath_lastibcstat & ipath_cvt_physportstate[dd->ipath_lastibcstat &
...@@ -1195,9 +1197,9 @@ static int ipath_query_port(struct ib_device *ibdev, ...@@ -1195,9 +1197,9 @@ static int ipath_query_port(struct ib_device *ibdev,
props->bad_pkey_cntr = ipath_get_cr_errpkey(dd) - props->bad_pkey_cntr = ipath_get_cr_errpkey(dd) -
dev->z_pkey_violations; dev->z_pkey_violations;
props->qkey_viol_cntr = dev->qkey_violations; props->qkey_viol_cntr = dev->qkey_violations;
props->active_width = IB_WIDTH_4X; props->active_width = dd->ipath_link_width_active;
/* See rate_show() */ /* See rate_show() */
props->active_speed = 1; /* Regular 10Mbs speed. */ props->active_speed = dd->ipath_link_speed_active;
props->max_vl_num = 1; /* VLCap = VL0 */ props->max_vl_num = 1; /* VLCap = VL0 */
props->init_type_reply = 0; props->init_type_reply = 0;
...@@ -1629,12 +1631,13 @@ int ipath_register_ib_device(struct ipath_devdata *dd) ...@@ -1629,12 +1631,13 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
idev->pending_index = 0; idev->pending_index = 0;
idev->port_cap_flags = idev->port_cap_flags =
IB_PORT_SYS_IMAGE_GUID_SUP | IB_PORT_CLIENT_REG_SUP; IB_PORT_SYS_IMAGE_GUID_SUP | IB_PORT_CLIENT_REG_SUP;
if (dd->ipath_flags & IPATH_HAS_LINK_LATENCY)
idev->port_cap_flags |= IB_PORT_LINK_LATENCY_SUP;
idev->pma_counter_select[0] = IB_PMA_PORT_XMIT_DATA; idev->pma_counter_select[0] = IB_PMA_PORT_XMIT_DATA;
idev->pma_counter_select[1] = IB_PMA_PORT_RCV_DATA; idev->pma_counter_select[1] = IB_PMA_PORT_RCV_DATA;
idev->pma_counter_select[2] = IB_PMA_PORT_XMIT_PKTS; idev->pma_counter_select[2] = IB_PMA_PORT_XMIT_PKTS;
idev->pma_counter_select[3] = IB_PMA_PORT_RCV_PKTS; idev->pma_counter_select[3] = IB_PMA_PORT_RCV_PKTS;
idev->pma_counter_select[4] = IB_PMA_PORT_XMIT_WAIT; idev->pma_counter_select[4] = IB_PMA_PORT_XMIT_WAIT;
idev->link_width_enabled = 3; /* 1x or 4x */
/* Snapshot current HW counters to "clear" them. */ /* Snapshot current HW counters to "clear" them. */
ipath_get_counters(dd, &cntrs); ipath_get_counters(dd, &cntrs);
......
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