Skip to content

Commit 959f2d1

Browse files
alexestrdledford
authored andcommitted
IB/hfi1: Complete check for locally terminated smp
For lid routed packets 'hop_cnt' is zero, therefore current test is incomplete. Fix it by using local mad check for both lid routed and direct routed MADs. Reviewed-by: Mike Mariciniszyn <[email protected]> Signed-off-by: Alex Estrin <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 48e0a65 commit 959f2d1

File tree

1 file changed

+20
-16
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+20
-16
lines changed

drivers/infiniband/hw/hfi1/mad.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ static int port_states_transition_allowed(struct hfi1_pportdata *ppd,
12381238
}
12391239

12401240
static int set_port_states(struct hfi1_pportdata *ppd, struct opa_smp *smp,
1241-
u32 logical_state, u32 phys_state)
1241+
u32 logical_state, u32 phys_state, int local_mad)
12421242
{
12431243
struct hfi1_devdata *dd = ppd->dd;
12441244
u32 link_state;
@@ -1314,7 +1314,7 @@ static int set_port_states(struct hfi1_pportdata *ppd, struct opa_smp *smp,
13141314
* Don't send a reply if the response would be sent
13151315
* through the disabled port.
13161316
*/
1317-
if (link_state == HLS_DN_DISABLE && smp->hop_cnt)
1317+
if (link_state == HLS_DN_DISABLE && !local_mad)
13181318
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
13191319
break;
13201320
case IB_PORT_ARMED:
@@ -1350,7 +1350,7 @@ static int set_port_states(struct hfi1_pportdata *ppd, struct opa_smp *smp,
13501350
*/
13511351
static int __subn_set_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data,
13521352
struct ib_device *ibdev, u8 port,
1353-
u32 *resp_len, u32 max_len)
1353+
u32 *resp_len, u32 max_len, int local_mad)
13541354
{
13551355
struct opa_port_info *pi = (struct opa_port_info *)data;
13561356
struct ib_event event;
@@ -1634,7 +1634,7 @@ static int __subn_set_opa_portinfo(struct opa_smp *smp, u32 am, u8 *data,
16341634
*/
16351635

16361636
if (!invalid) {
1637-
ret = set_port_states(ppd, smp, ls_new, ps_new);
1637+
ret = set_port_states(ppd, smp, ls_new, ps_new, local_mad);
16381638
if (ret)
16391639
return ret;
16401640
}
@@ -2085,7 +2085,7 @@ static int __subn_get_opa_psi(struct opa_smp *smp, u32 am, u8 *data,
20852085

20862086
static int __subn_set_opa_psi(struct opa_smp *smp, u32 am, u8 *data,
20872087
struct ib_device *ibdev, u8 port,
2088-
u32 *resp_len, u32 max_len)
2088+
u32 *resp_len, u32 max_len, int local_mad)
20892089
{
20902090
u32 nports = OPA_AM_NPORT(am);
20912091
u32 start_of_sm_config = OPA_AM_START_SM_CFG(am);
@@ -2122,7 +2122,7 @@ static int __subn_set_opa_psi(struct opa_smp *smp, u32 am, u8 *data,
21222122
}
21232123

21242124
if (!invalid) {
2125-
ret = set_port_states(ppd, smp, ls_new, ps_new);
2125+
ret = set_port_states(ppd, smp, ls_new, ps_new, local_mad);
21262126
if (ret)
21272127
return ret;
21282128
}
@@ -4190,15 +4190,15 @@ static int subn_get_opa_sma(__be16 attr_id, struct opa_smp *smp, u32 am,
41904190

41914191
static int subn_set_opa_sma(__be16 attr_id, struct opa_smp *smp, u32 am,
41924192
u8 *data, struct ib_device *ibdev, u8 port,
4193-
u32 *resp_len, u32 max_len)
4193+
u32 *resp_len, u32 max_len, int local_mad)
41944194
{
41954195
int ret;
41964196
struct hfi1_ibport *ibp = to_iport(ibdev, port);
41974197

41984198
switch (attr_id) {
41994199
case IB_SMP_ATTR_PORT_INFO:
42004200
ret = __subn_set_opa_portinfo(smp, am, data, ibdev, port,
4201-
resp_len, max_len);
4201+
resp_len, max_len, local_mad);
42024202
break;
42034203
case IB_SMP_ATTR_PKEY_TABLE:
42044204
ret = __subn_set_opa_pkeytable(smp, am, data, ibdev, port,
@@ -4222,7 +4222,7 @@ static int subn_set_opa_sma(__be16 attr_id, struct opa_smp *smp, u32 am,
42224222
break;
42234223
case OPA_ATTRIB_ID_PORT_STATE_INFO:
42244224
ret = __subn_set_opa_psi(smp, am, data, ibdev, port,
4225-
resp_len, max_len);
4225+
resp_len, max_len, local_mad);
42264226
break;
42274227
case OPA_ATTRIB_ID_BUFFER_CONTROL_TABLE:
42284228
ret = __subn_set_opa_bct(smp, am, data, ibdev, port,
@@ -4314,7 +4314,7 @@ static int subn_get_opa_aggregate(struct opa_smp *smp,
43144314

43154315
static int subn_set_opa_aggregate(struct opa_smp *smp,
43164316
struct ib_device *ibdev, u8 port,
4317-
u32 *resp_len)
4317+
u32 *resp_len, int local_mad)
43184318
{
43194319
int i;
43204320
u32 num_attr = be32_to_cpu(smp->attr_mod) & 0x000000ff;
@@ -4344,7 +4344,9 @@ static int subn_set_opa_aggregate(struct opa_smp *smp,
43444344
}
43454345

43464346
(void)subn_set_opa_sma(agg->attr_id, smp, am, agg->data,
4347-
ibdev, port, NULL, (u32)agg_data_len);
4347+
ibdev, port, NULL, (u32)agg_data_len,
4348+
local_mad);
4349+
43484350
if (smp->status & IB_SMP_INVALID_FIELD)
43494351
break;
43504352
if (smp->status & ~IB_SMP_DIRECTION) {
@@ -4519,7 +4521,7 @@ static int hfi1_pkey_validation_pma(struct hfi1_ibport *ibp,
45194521
static int process_subn_opa(struct ib_device *ibdev, int mad_flags,
45204522
u8 port, const struct opa_mad *in_mad,
45214523
struct opa_mad *out_mad,
4522-
u32 *resp_len)
4524+
u32 *resp_len, int local_mad)
45234525
{
45244526
struct opa_smp *smp = (struct opa_smp *)out_mad;
45254527
struct hfi1_ibport *ibp = to_iport(ibdev, port);
@@ -4588,11 +4590,11 @@ static int process_subn_opa(struct ib_device *ibdev, int mad_flags,
45884590
default:
45894591
ret = subn_set_opa_sma(attr_id, smp, am, data,
45904592
ibdev, port, resp_len,
4591-
data_size);
4593+
data_size, local_mad);
45924594
break;
45934595
case OPA_ATTRIB_ID_AGGREGATE:
45944596
ret = subn_set_opa_aggregate(smp, ibdev, port,
4595-
resp_len);
4597+
resp_len, local_mad);
45964598
break;
45974599
}
45984600
break;
@@ -4832,6 +4834,7 @@ static int hfi1_process_opa_mad(struct ib_device *ibdev, int mad_flags,
48324834
{
48334835
int ret;
48344836
int pkey_idx;
4837+
int local_mad = 0;
48354838
u32 resp_len = 0;
48364839
struct hfi1_ibport *ibp = to_iport(ibdev, port);
48374840

@@ -4846,13 +4849,14 @@ static int hfi1_process_opa_mad(struct ib_device *ibdev, int mad_flags,
48464849
switch (in_mad->mad_hdr.mgmt_class) {
48474850
case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
48484851
case IB_MGMT_CLASS_SUBN_LID_ROUTED:
4849-
if (is_local_mad(ibp, in_mad, in_wc)) {
4852+
local_mad = is_local_mad(ibp, in_mad, in_wc);
4853+
if (local_mad) {
48504854
ret = opa_local_smp_check(ibp, in_wc);
48514855
if (ret)
48524856
return IB_MAD_RESULT_FAILURE;
48534857
}
48544858
ret = process_subn_opa(ibdev, mad_flags, port, in_mad,
4855-
out_mad, &resp_len);
4859+
out_mad, &resp_len, local_mad);
48564860
goto bail;
48574861
case IB_MGMT_CLASS_PERF_MGMT:
48584862
ret = hfi1_pkey_validation_pma(ibp, in_mad, in_wc);

0 commit comments

Comments
 (0)