2 * Copyright (c) 2006 QLogic, Inc. All rights reserved.
3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 #include <rdma/ib_smi.h>
36 #include "ipath_kernel.h"
37 #include "ipath_verbs.h"
38 #include "ipath_common.h"
40 #define IB_SMP_UNSUP_VERSION __constant_htons(0x0004)
41 #define IB_SMP_UNSUP_METHOD __constant_htons(0x0008)
42 #define IB_SMP_UNSUP_METH_ATTR __constant_htons(0x000C)
43 #define IB_SMP_INVALID_FIELD __constant_htons(0x001C)
45 static int reply(struct ib_smp
*smp
)
48 * The verbs framework will handle the directed/LID route
51 smp
->method
= IB_MGMT_METHOD_GET_RESP
;
52 if (smp
->mgmt_class
== IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE
)
53 smp
->status
|= IB_SMP_DIRECTION
;
54 return IB_MAD_RESULT_SUCCESS
| IB_MAD_RESULT_REPLY
;
57 static int recv_subn_get_nodedescription(struct ib_smp
*smp
,
58 struct ib_device
*ibdev
)
61 smp
->status
|= IB_SMP_INVALID_FIELD
;
63 strncpy(smp
->data
, ibdev
->node_desc
, sizeof(smp
->data
));
81 } __attribute__ ((packed
));
83 static int recv_subn_get_nodeinfo(struct ib_smp
*smp
,
84 struct ib_device
*ibdev
, u8 port
)
86 struct nodeinfo
*nip
= (struct nodeinfo
*)&smp
->data
;
87 struct ipath_devdata
*dd
= to_idev(ibdev
)->dd
;
88 u32 vendor
, majrev
, minrev
;
91 smp
->status
|= IB_SMP_INVALID_FIELD
;
93 nip
->base_version
= 1;
94 nip
->class_version
= 1;
95 nip
->node_type
= 1; /* channel adapter */
97 * XXX The num_ports value will need a layer function to get
98 * the value if we ever have more than one IB port on a chip.
99 * We will also need to get the GUID for the port.
101 nip
->num_ports
= ibdev
->phys_port_cnt
;
102 /* This is already in network order */
103 nip
->sys_guid
= to_idev(ibdev
)->sys_image_guid
;
104 nip
->node_guid
= ipath_layer_get_guid(dd
);
105 nip
->port_guid
= nip
->sys_guid
;
106 nip
->partition_cap
= cpu_to_be16(ipath_layer_get_npkeys(dd
));
107 nip
->device_id
= cpu_to_be16(ipath_layer_get_deviceid(dd
));
108 majrev
= ipath_layer_get_majrev(dd
);
109 minrev
= ipath_layer_get_minrev(dd
);
110 nip
->revision
= cpu_to_be32((majrev
<< 16) | minrev
);
111 nip
->local_port_num
= port
;
112 vendor
= ipath_layer_get_vendorid(dd
);
113 nip
->vendor_id
[0] = 0;
114 nip
->vendor_id
[1] = vendor
>> 8;
115 nip
->vendor_id
[2] = vendor
;
120 static int recv_subn_get_guidinfo(struct ib_smp
*smp
,
121 struct ib_device
*ibdev
)
123 u32 startgx
= 8 * be32_to_cpu(smp
->attr_mod
);
124 __be64
*p
= (__be64
*) smp
->data
;
126 /* 32 blocks of 8 64-bit GUIDs per block */
128 memset(smp
->data
, 0, sizeof(smp
->data
));
131 * We only support one GUID for now. If this changes, the
132 * portinfo.guid_cap field needs to be updated too.
135 /* The first is a copy of the read-only HW GUID. */
136 *p
= ipath_layer_get_guid(to_idev(ibdev
)->dd
);
138 smp
->status
|= IB_SMP_INVALID_FIELD
;
143 static int recv_subn_get_portinfo(struct ib_smp
*smp
,
144 struct ib_device
*ibdev
, u8 port
)
146 struct ipath_ibdev
*dev
;
147 struct ib_port_info
*pip
= (struct ib_port_info
*)smp
->data
;
153 if (be32_to_cpu(smp
->attr_mod
) > ibdev
->phys_port_cnt
) {
154 smp
->status
|= IB_SMP_INVALID_FIELD
;
159 dev
= to_idev(ibdev
);
161 /* Clear all fields. Only set the non-zero fields. */
162 memset(smp
->data
, 0, sizeof(smp
->data
));
164 /* Only return the mkey if the protection field allows it. */
165 if (smp
->method
== IB_MGMT_METHOD_SET
|| dev
->mkey
== smp
->mkey
||
166 (dev
->mkeyprot_resv_lmc
>> 6) == 0)
167 pip
->mkey
= dev
->mkey
;
168 pip
->gid_prefix
= dev
->gid_prefix
;
169 lid
= ipath_layer_get_lid(dev
->dd
);
170 pip
->lid
= lid
? cpu_to_be16(lid
) : IB_LID_PERMISSIVE
;
171 pip
->sm_lid
= cpu_to_be16(dev
->sm_lid
);
172 pip
->cap_mask
= cpu_to_be32(dev
->port_cap_flags
);
173 /* pip->diag_code; */
174 pip
->mkey_lease_period
= cpu_to_be16(dev
->mkey_lease_period
);
175 pip
->local_port_num
= port
;
176 pip
->link_width_enabled
= dev
->link_width_enabled
;
177 pip
->link_width_supported
= 3; /* 1x or 4x */
178 pip
->link_width_active
= 2; /* 4x */
179 pip
->linkspeed_portstate
= 0x10; /* 2.5Gbps */
180 ibcstat
= ipath_layer_get_lastibcstat(dev
->dd
);
181 pip
->linkspeed_portstate
|= ((ibcstat
>> 4) & 0x3) + 1;
182 pip
->portphysstate_linkdown
=
183 (ipath_cvt_physportstate
[ibcstat
& 0xf] << 4) |
184 (ipath_layer_get_linkdowndefaultstate(dev
->dd
) ? 1 : 2);
185 pip
->mkeyprot_resv_lmc
= dev
->mkeyprot_resv_lmc
;
186 pip
->linkspeedactive_enabled
= 0x11; /* 2.5Gbps, 2.5Gbps */
187 switch (ipath_layer_get_ibmtu(dev
->dd
)) {
203 default: /* oops, something is wrong */
207 pip
->neighbormtu_mastersmsl
= (mtu
<< 4) | dev
->sm_sl
;
208 pip
->vlcap_inittype
= 0x10; /* VLCap = VL0, InitType = 0 */
209 pip
->vl_high_limit
= dev
->vl_high_limit
;
210 /* pip->vl_arb_high_cap; // only one VL */
211 /* pip->vl_arb_low_cap; // only one VL */
212 /* InitTypeReply = 0 */
213 pip
->inittypereply_mtucap
= IB_MTU_4096
;
214 // HCAs ignore VLStallCount and HOQLife
215 /* pip->vlstallcnt_hoqlife; */
216 pip
->operationalvl_pei_peo_fpi_fpo
= 0x10; /* OVLs = 1 */
217 pip
->mkey_violations
= cpu_to_be16(dev
->mkey_violations
);
218 /* P_KeyViolations are counted by hardware. */
219 pip
->pkey_violations
=
220 cpu_to_be16((ipath_layer_get_cr_errpkey(dev
->dd
) -
221 dev
->z_pkey_violations
) & 0xFFFF);
222 pip
->qkey_violations
= cpu_to_be16(dev
->qkey_violations
);
223 /* Only the hardware GUID is supported for now */
225 pip
->clientrereg_resv_subnetto
= dev
->subnet_timeout
;
226 /* 32.768 usec. response time (guessing) */
227 pip
->resv_resptimevalue
= 3;
228 pip
->localphyerrors_overrunerrors
=
229 (ipath_layer_get_phyerrthreshold(dev
->dd
) << 4) |
230 ipath_layer_get_overrunthreshold(dev
->dd
);
231 /* pip->max_credit_hint; */
232 /* pip->link_roundtrip_latency[3]; */
240 static int recv_subn_get_pkeytable(struct ib_smp
*smp
,
241 struct ib_device
*ibdev
)
243 u32 startpx
= 32 * (be32_to_cpu(smp
->attr_mod
) & 0xffff);
244 u16
*p
= (u16
*) smp
->data
;
245 __be16
*q
= (__be16
*) smp
->data
;
247 /* 64 blocks of 32 16-bit P_Key entries */
249 memset(smp
->data
, 0, sizeof(smp
->data
));
251 struct ipath_ibdev
*dev
= to_idev(ibdev
);
252 unsigned i
, n
= ipath_layer_get_npkeys(dev
->dd
);
254 ipath_layer_get_pkeys(dev
->dd
, p
);
256 for (i
= 0; i
< n
; i
++)
257 q
[i
] = cpu_to_be16(p
[i
]);
259 smp
->status
|= IB_SMP_INVALID_FIELD
;
264 static int recv_subn_set_guidinfo(struct ib_smp
*smp
,
265 struct ib_device
*ibdev
)
267 /* The only GUID we support is the first read-only entry. */
268 return recv_subn_get_guidinfo(smp
, ibdev
);
272 * recv_subn_set_portinfo - set port information
273 * @smp: the incoming SM packet
274 * @ibdev: the infiniband device
275 * @port: the port on the device
277 * Set Portinfo (see ch. 14.2.5.6).
279 static int recv_subn_set_portinfo(struct ib_smp
*smp
,
280 struct ib_device
*ibdev
, u8 port
)
282 struct ib_port_info
*pip
= (struct ib_port_info
*)smp
->data
;
283 struct ib_event event
;
284 struct ipath_ibdev
*dev
;
286 char clientrereg
= 0;
295 if (be32_to_cpu(smp
->attr_mod
) > ibdev
->phys_port_cnt
)
298 dev
= to_idev(ibdev
);
299 event
.device
= ibdev
;
300 event
.element
.port_num
= port
;
302 dev
->mkey
= pip
->mkey
;
303 dev
->gid_prefix
= pip
->gid_prefix
;
304 dev
->mkey_lease_period
= be16_to_cpu(pip
->mkey_lease_period
);
306 lid
= be16_to_cpu(pip
->lid
);
307 if (lid
!= ipath_layer_get_lid(dev
->dd
)) {
308 /* Must be a valid unicast LID address. */
309 if (lid
== 0 || lid
>= IPATH_MULTICAST_LID_BASE
)
311 ipath_set_lid(dev
->dd
, lid
, pip
->mkeyprot_resv_lmc
& 7);
312 event
.event
= IB_EVENT_LID_CHANGE
;
313 ib_dispatch_event(&event
);
316 smlid
= be16_to_cpu(pip
->sm_lid
);
317 if (smlid
!= dev
->sm_lid
) {
318 /* Must be a valid unicast LID address. */
319 if (smlid
== 0 || smlid
>= IPATH_MULTICAST_LID_BASE
)
322 event
.event
= IB_EVENT_SM_CHANGE
;
323 ib_dispatch_event(&event
);
326 /* Only 4x supported but allow 1x or 4x to be set (see 14.2.6.6). */
327 lwe
= pip
->link_width_enabled
;
328 if ((lwe
>= 4 && lwe
<= 8) || (lwe
>= 0xC && lwe
<= 0xFE))
331 dev
->link_width_enabled
= 3; /* 1x or 4x */
333 dev
->link_width_enabled
= lwe
;
335 /* Only 2.5 Gbs supported. */
336 lse
= pip
->linkspeedactive_enabled
& 0xF;
337 if (lse
>= 2 && lse
<= 0xE)
340 /* Set link down default state. */
341 switch (pip
->portphysstate_linkdown
& 0xF) {
345 if (ipath_layer_set_linkdowndefaultstate(dev
->dd
, 1))
349 if (ipath_layer_set_linkdowndefaultstate(dev
->dd
, 0))
356 dev
->mkeyprot_resv_lmc
= pip
->mkeyprot_resv_lmc
;
357 dev
->vl_high_limit
= pip
->vl_high_limit
;
359 switch ((pip
->neighbormtu_mastersmsl
>> 4) & 0xF) {
376 /* XXX We have already partially updated our state! */
379 ipath_layer_set_mtu(dev
->dd
, mtu
);
381 dev
->sm_sl
= pip
->neighbormtu_mastersmsl
& 0xF;
383 /* We only support VL0 */
384 if (((pip
->operationalvl_pei_peo_fpi_fpo
>> 4) & 0xF) > 1)
387 if (pip
->mkey_violations
== 0)
388 dev
->mkey_violations
= 0;
391 * Hardware counter can't be reset so snapshot and subtract
394 if (pip
->pkey_violations
== 0)
395 dev
->z_pkey_violations
=
396 ipath_layer_get_cr_errpkey(dev
->dd
);
398 if (pip
->qkey_violations
== 0)
399 dev
->qkey_violations
= 0;
401 if (ipath_layer_set_phyerrthreshold(
403 (pip
->localphyerrors_overrunerrors
>> 4) & 0xF))
406 if (ipath_layer_set_overrunthreshold(
408 (pip
->localphyerrors_overrunerrors
& 0xF)))
411 dev
->subnet_timeout
= pip
->clientrereg_resv_subnetto
& 0x1F;
413 if (pip
->clientrereg_resv_subnetto
& 0x80) {
415 event
.event
= IB_EVENT_CLIENT_REREGISTER
;
416 ib_dispatch_event(&event
);
420 * Do the port state change now that the other link parameters
422 * Changing the port physical state only makes sense if the link
423 * is down or is being set to down.
425 state
= pip
->linkspeed_portstate
& 0xF;
426 flags
= ipath_layer_get_flags(dev
->dd
);
427 lstate
= (pip
->portphysstate_linkdown
>> 4) & 0xF;
428 if (lstate
&& !(state
== IB_PORT_DOWN
|| state
== IB_PORT_NOP
))
432 * Only state changes of DOWN, ARM, and ACTIVE are valid
433 * and must be in the correct state to take effect (see 7.2.6).
442 if (ipath_layer_get_linkdowndefaultstate(dev
->dd
))
443 lstate
= IPATH_IB_LINKDOWN_SLEEP
;
445 lstate
= IPATH_IB_LINKDOWN
;
446 else if (lstate
== 1)
447 lstate
= IPATH_IB_LINKDOWN_SLEEP
;
448 else if (lstate
== 2)
449 lstate
= IPATH_IB_LINKDOWN
;
450 else if (lstate
== 3)
451 lstate
= IPATH_IB_LINKDOWN_DISABLE
;
454 ipath_layer_set_linkstate(dev
->dd
, lstate
);
455 if (flags
& IPATH_LINKACTIVE
) {
456 event
.event
= IB_EVENT_PORT_ERR
;
457 ib_dispatch_event(&event
);
461 if (!(flags
& (IPATH_LINKINIT
| IPATH_LINKACTIVE
)))
463 ipath_layer_set_linkstate(dev
->dd
, IPATH_IB_LINKARM
);
464 if (flags
& IPATH_LINKACTIVE
) {
465 event
.event
= IB_EVENT_PORT_ERR
;
466 ib_dispatch_event(&event
);
470 if (!(flags
& IPATH_LINKARMED
))
472 ipath_layer_set_linkstate(dev
->dd
, IPATH_IB_LINKACTIVE
);
473 event
.event
= IB_EVENT_PORT_ACTIVE
;
474 ib_dispatch_event(&event
);
477 /* XXX We have already partially updated our state! */
481 ret
= recv_subn_get_portinfo(smp
, ibdev
, port
);
484 pip
->clientrereg_resv_subnetto
|= 0x80;
489 smp
->status
|= IB_SMP_INVALID_FIELD
;
490 ret
= recv_subn_get_portinfo(smp
, ibdev
, port
);
496 static int recv_subn_set_pkeytable(struct ib_smp
*smp
,
497 struct ib_device
*ibdev
)
499 u32 startpx
= 32 * (be32_to_cpu(smp
->attr_mod
) & 0xffff);
500 __be16
*p
= (__be16
*) smp
->data
;
501 u16
*q
= (u16
*) smp
->data
;
502 struct ipath_ibdev
*dev
= to_idev(ibdev
);
503 unsigned i
, n
= ipath_layer_get_npkeys(dev
->dd
);
505 for (i
= 0; i
< n
; i
++)
506 q
[i
] = be16_to_cpu(p
[i
]);
509 ipath_layer_set_pkeys(dev
->dd
, q
) != 0)
510 smp
->status
|= IB_SMP_INVALID_FIELD
;
512 return recv_subn_get_pkeytable(smp
, ibdev
);
515 #define IB_PMA_CLASS_PORT_INFO __constant_htons(0x0001)
516 #define IB_PMA_PORT_SAMPLES_CONTROL __constant_htons(0x0010)
517 #define IB_PMA_PORT_SAMPLES_RESULT __constant_htons(0x0011)
518 #define IB_PMA_PORT_COUNTERS __constant_htons(0x0012)
519 #define IB_PMA_PORT_COUNTERS_EXT __constant_htons(0x001D)
520 #define IB_PMA_PORT_SAMPLES_RESULT_EXT __constant_htons(0x001E)
535 } __attribute__ ((packed
));
537 struct ib_pma_classportinfo
{
542 u8 resp_time_value
; /* only lower 5 bits */
543 union ib_gid redirect_gid
;
544 __be32 redirect_tc_sl_fl
; /* 8, 4, 20 bits respectively */
546 __be16 redirect_pkey
;
547 __be32 redirect_qp
; /* only lower 24 bits */
548 __be32 redirect_qkey
;
549 union ib_gid trap_gid
;
550 __be32 trap_tc_sl_fl
; /* 8, 4, 20 bits respectively */
553 __be32 trap_hl_qp
; /* 8, 24 bits respectively */
555 } __attribute__ ((packed
));
557 struct ib_pma_portsamplescontrol
{
561 u8 counter_width
; /* only lower 3 bits */
562 __be32 counter_mask0_9
; /* 2, 10 * 3, bits */
563 __be16 counter_mask10_14
; /* 1, 5 * 3, bits */
564 u8 sample_mechanisms
;
565 u8 sample_status
; /* only lower 2 bits */
569 __be32 sample_interval
;
571 __be16 counter_select
[15];
572 } __attribute__ ((packed
));
574 struct ib_pma_portsamplesresult
{
576 __be16 sample_status
; /* only lower 2 bits */
578 } __attribute__ ((packed
));
580 struct ib_pma_portsamplesresult_ext
{
582 __be16 sample_status
; /* only lower 2 bits */
583 __be32 extended_width
; /* only upper 2 bits */
585 } __attribute__ ((packed
));
587 struct ib_pma_portcounters
{
590 __be16 counter_select
;
591 __be16 symbol_error_counter
;
592 u8 link_error_recovery_counter
;
593 u8 link_downed_counter
;
594 __be16 port_rcv_errors
;
595 __be16 port_rcv_remphys_errors
;
596 __be16 port_rcv_switch_relay_errors
;
597 __be16 port_xmit_discards
;
598 u8 port_xmit_constraint_errors
;
599 u8 port_rcv_constraint_errors
;
601 u8 lli_ebor_errors
; /* 4, 4, bits */
604 __be32 port_xmit_data
;
605 __be32 port_rcv_data
;
606 __be32 port_xmit_packets
;
607 __be32 port_rcv_packets
;
608 } __attribute__ ((packed
));
610 #define IB_PMA_SEL_SYMBOL_ERROR __constant_htons(0x0001)
611 #define IB_PMA_SEL_LINK_ERROR_RECOVERY __constant_htons(0x0002)
612 #define IB_PMA_SEL_LINK_DOWNED __constant_htons(0x0004)
613 #define IB_PMA_SEL_PORT_RCV_ERRORS __constant_htons(0x0008)
614 #define IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS __constant_htons(0x0010)
615 #define IB_PMA_SEL_PORT_XMIT_DISCARDS __constant_htons(0x0040)
616 #define IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS __constant_htons(0x0200)
617 #define IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS __constant_htons(0x0400)
618 #define IB_PMA_SEL_PORT_VL15_DROPPED __constant_htons(0x0800)
619 #define IB_PMA_SEL_PORT_XMIT_DATA __constant_htons(0x1000)
620 #define IB_PMA_SEL_PORT_RCV_DATA __constant_htons(0x2000)
621 #define IB_PMA_SEL_PORT_XMIT_PACKETS __constant_htons(0x4000)
622 #define IB_PMA_SEL_PORT_RCV_PACKETS __constant_htons(0x8000)
624 struct ib_pma_portcounters_ext
{
627 __be16 counter_select
;
629 __be64 port_xmit_data
;
630 __be64 port_rcv_data
;
631 __be64 port_xmit_packets
;
632 __be64 port_rcv_packets
;
633 __be64 port_unicast_xmit_packets
;
634 __be64 port_unicast_rcv_packets
;
635 __be64 port_multicast_xmit_packets
;
636 __be64 port_multicast_rcv_packets
;
637 } __attribute__ ((packed
));
639 #define IB_PMA_SELX_PORT_XMIT_DATA __constant_htons(0x0001)
640 #define IB_PMA_SELX_PORT_RCV_DATA __constant_htons(0x0002)
641 #define IB_PMA_SELX_PORT_XMIT_PACKETS __constant_htons(0x0004)
642 #define IB_PMA_SELX_PORT_RCV_PACKETS __constant_htons(0x0008)
643 #define IB_PMA_SELX_PORT_UNI_XMIT_PACKETS __constant_htons(0x0010)
644 #define IB_PMA_SELX_PORT_UNI_RCV_PACKETS __constant_htons(0x0020)
645 #define IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS __constant_htons(0x0040)
646 #define IB_PMA_SELX_PORT_MULTI_RCV_PACKETS __constant_htons(0x0080)
648 static int recv_pma_get_classportinfo(struct ib_perf
*pmp
)
650 struct ib_pma_classportinfo
*p
=
651 (struct ib_pma_classportinfo
*)pmp
->data
;
653 memset(pmp
->data
, 0, sizeof(pmp
->data
));
655 if (pmp
->attr_mod
!= 0)
656 pmp
->status
|= IB_SMP_INVALID_FIELD
;
658 /* Indicate AllPortSelect is valid (only one port anyway) */
659 p
->cap_mask
= __constant_cpu_to_be16(1 << 8);
661 p
->class_version
= 1;
663 * Expected response time is 4.096 usec. * 2^18 == 1.073741824
666 p
->resp_time_value
= 18;
668 return reply((struct ib_smp
*) pmp
);
672 * The PortSamplesControl.CounterMasks field is an array of 3 bit fields
673 * which specify the N'th counter's capabilities. See ch. 16.1.3.2.
674 * We support 5 counters which only count the mandatory quantities.
676 #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
677 #define COUNTER_MASK0_9 \
678 __constant_cpu_to_be32(COUNTER_MASK(1, 0) | \
679 COUNTER_MASK(1, 1) | \
680 COUNTER_MASK(1, 2) | \
681 COUNTER_MASK(1, 3) | \
684 static int recv_pma_get_portsamplescontrol(struct ib_perf
*pmp
,
685 struct ib_device
*ibdev
, u8 port
)
687 struct ib_pma_portsamplescontrol
*p
=
688 (struct ib_pma_portsamplescontrol
*)pmp
->data
;
689 struct ipath_ibdev
*dev
= to_idev(ibdev
);
691 u8 port_select
= p
->port_select
;
693 memset(pmp
->data
, 0, sizeof(pmp
->data
));
695 p
->port_select
= port_select
;
696 if (pmp
->attr_mod
!= 0 ||
697 (port_select
!= port
&& port_select
!= 0xFF))
698 pmp
->status
|= IB_SMP_INVALID_FIELD
;
700 * Ticks are 10x the link transfer period which for 2.5Gbs is 4
701 * nsec. 0 == 4 nsec., 1 == 8 nsec., ..., 255 == 1020 nsec. Sample
702 * intervals are counted in ticks. Since we use Linux timers, that
703 * count in jiffies, we can't sample for less than 1000 ticks if HZ
704 * == 1000 (4000 ticks if HZ is 250).
706 /* XXX This is WRONG. */
707 p
->tick
= 250; /* 1 usec. */
708 p
->counter_width
= 4; /* 32 bit counters */
709 p
->counter_mask0_9
= COUNTER_MASK0_9
;
710 spin_lock_irqsave(&dev
->pending_lock
, flags
);
711 p
->sample_status
= dev
->pma_sample_status
;
712 p
->sample_start
= cpu_to_be32(dev
->pma_sample_start
);
713 p
->sample_interval
= cpu_to_be32(dev
->pma_sample_interval
);
714 p
->tag
= cpu_to_be16(dev
->pma_tag
);
715 p
->counter_select
[0] = dev
->pma_counter_select
[0];
716 p
->counter_select
[1] = dev
->pma_counter_select
[1];
717 p
->counter_select
[2] = dev
->pma_counter_select
[2];
718 p
->counter_select
[3] = dev
->pma_counter_select
[3];
719 p
->counter_select
[4] = dev
->pma_counter_select
[4];
720 spin_unlock_irqrestore(&dev
->pending_lock
, flags
);
722 return reply((struct ib_smp
*) pmp
);
725 static int recv_pma_set_portsamplescontrol(struct ib_perf
*pmp
,
726 struct ib_device
*ibdev
, u8 port
)
728 struct ib_pma_portsamplescontrol
*p
=
729 (struct ib_pma_portsamplescontrol
*)pmp
->data
;
730 struct ipath_ibdev
*dev
= to_idev(ibdev
);
735 if (pmp
->attr_mod
!= 0 ||
736 (p
->port_select
!= port
&& p
->port_select
!= 0xFF)) {
737 pmp
->status
|= IB_SMP_INVALID_FIELD
;
738 ret
= reply((struct ib_smp
*) pmp
);
742 start
= be32_to_cpu(p
->sample_start
);
744 spin_lock_irqsave(&dev
->pending_lock
, flags
);
745 if (dev
->pma_sample_status
== IB_PMA_SAMPLE_STATUS_DONE
) {
746 dev
->pma_sample_status
=
747 IB_PMA_SAMPLE_STATUS_STARTED
;
748 dev
->pma_sample_start
= start
;
749 dev
->pma_sample_interval
=
750 be32_to_cpu(p
->sample_interval
);
751 dev
->pma_tag
= be16_to_cpu(p
->tag
);
752 if (p
->counter_select
[0])
753 dev
->pma_counter_select
[0] =
754 p
->counter_select
[0];
755 if (p
->counter_select
[1])
756 dev
->pma_counter_select
[1] =
757 p
->counter_select
[1];
758 if (p
->counter_select
[2])
759 dev
->pma_counter_select
[2] =
760 p
->counter_select
[2];
761 if (p
->counter_select
[3])
762 dev
->pma_counter_select
[3] =
763 p
->counter_select
[3];
764 if (p
->counter_select
[4])
765 dev
->pma_counter_select
[4] =
766 p
->counter_select
[4];
768 spin_unlock_irqrestore(&dev
->pending_lock
, flags
);
770 ret
= recv_pma_get_portsamplescontrol(pmp
, ibdev
, port
);
776 static u64
get_counter(struct ipath_ibdev
*dev
, __be16 sel
)
781 case IB_PMA_PORT_XMIT_DATA
:
782 ret
= dev
->ipath_sword
;
784 case IB_PMA_PORT_RCV_DATA
:
785 ret
= dev
->ipath_rword
;
787 case IB_PMA_PORT_XMIT_PKTS
:
788 ret
= dev
->ipath_spkts
;
790 case IB_PMA_PORT_RCV_PKTS
:
791 ret
= dev
->ipath_rpkts
;
793 case IB_PMA_PORT_XMIT_WAIT
:
794 ret
= dev
->ipath_xmit_wait
;
803 static int recv_pma_get_portsamplesresult(struct ib_perf
*pmp
,
804 struct ib_device
*ibdev
)
806 struct ib_pma_portsamplesresult
*p
=
807 (struct ib_pma_portsamplesresult
*)pmp
->data
;
808 struct ipath_ibdev
*dev
= to_idev(ibdev
);
811 memset(pmp
->data
, 0, sizeof(pmp
->data
));
812 p
->tag
= cpu_to_be16(dev
->pma_tag
);
813 p
->sample_status
= cpu_to_be16(dev
->pma_sample_status
);
814 for (i
= 0; i
< ARRAY_SIZE(dev
->pma_counter_select
); i
++)
815 p
->counter
[i
] = cpu_to_be32(
816 get_counter(dev
, dev
->pma_counter_select
[i
]));
818 return reply((struct ib_smp
*) pmp
);
821 static int recv_pma_get_portsamplesresult_ext(struct ib_perf
*pmp
,
822 struct ib_device
*ibdev
)
824 struct ib_pma_portsamplesresult_ext
*p
=
825 (struct ib_pma_portsamplesresult_ext
*)pmp
->data
;
826 struct ipath_ibdev
*dev
= to_idev(ibdev
);
829 memset(pmp
->data
, 0, sizeof(pmp
->data
));
830 p
->tag
= cpu_to_be16(dev
->pma_tag
);
831 p
->sample_status
= cpu_to_be16(dev
->pma_sample_status
);
833 p
->extended_width
= __constant_cpu_to_be32(0x80000000);
834 for (i
= 0; i
< ARRAY_SIZE(dev
->pma_counter_select
); i
++)
835 p
->counter
[i
] = cpu_to_be64(
836 get_counter(dev
, dev
->pma_counter_select
[i
]));
838 return reply((struct ib_smp
*) pmp
);
841 static int recv_pma_get_portcounters(struct ib_perf
*pmp
,
842 struct ib_device
*ibdev
, u8 port
)
844 struct ib_pma_portcounters
*p
= (struct ib_pma_portcounters
*)
846 struct ipath_ibdev
*dev
= to_idev(ibdev
);
847 struct ipath_layer_counters cntrs
;
848 u8 port_select
= p
->port_select
;
850 ipath_layer_get_counters(dev
->dd
, &cntrs
);
852 /* Adjust counters for any resets done. */
853 cntrs
.symbol_error_counter
-= dev
->z_symbol_error_counter
;
854 cntrs
.link_error_recovery_counter
-=
855 dev
->z_link_error_recovery_counter
;
856 cntrs
.link_downed_counter
-= dev
->z_link_downed_counter
;
857 cntrs
.port_rcv_errors
+= dev
->rcv_errors
;
858 cntrs
.port_rcv_errors
-= dev
->z_port_rcv_errors
;
859 cntrs
.port_rcv_remphys_errors
-= dev
->z_port_rcv_remphys_errors
;
860 cntrs
.port_xmit_discards
-= dev
->z_port_xmit_discards
;
861 cntrs
.port_xmit_data
-= dev
->z_port_xmit_data
;
862 cntrs
.port_rcv_data
-= dev
->z_port_rcv_data
;
863 cntrs
.port_xmit_packets
-= dev
->z_port_xmit_packets
;
864 cntrs
.port_rcv_packets
-= dev
->z_port_rcv_packets
;
865 cntrs
.local_link_integrity_errors
-=
866 dev
->z_local_link_integrity_errors
;
867 cntrs
.excessive_buffer_overrun_errors
-=
868 dev
->z_excessive_buffer_overrun_errors
;
870 memset(pmp
->data
, 0, sizeof(pmp
->data
));
872 p
->port_select
= port_select
;
873 if (pmp
->attr_mod
!= 0 ||
874 (port_select
!= port
&& port_select
!= 0xFF))
875 pmp
->status
|= IB_SMP_INVALID_FIELD
;
877 if (cntrs
.symbol_error_counter
> 0xFFFFUL
)
878 p
->symbol_error_counter
= __constant_cpu_to_be16(0xFFFF);
880 p
->symbol_error_counter
=
881 cpu_to_be16((u16
)cntrs
.symbol_error_counter
);
882 if (cntrs
.link_error_recovery_counter
> 0xFFUL
)
883 p
->link_error_recovery_counter
= 0xFF;
885 p
->link_error_recovery_counter
=
886 (u8
)cntrs
.link_error_recovery_counter
;
887 if (cntrs
.link_downed_counter
> 0xFFUL
)
888 p
->link_downed_counter
= 0xFF;
890 p
->link_downed_counter
= (u8
)cntrs
.link_downed_counter
;
891 if (cntrs
.port_rcv_errors
> 0xFFFFUL
)
892 p
->port_rcv_errors
= __constant_cpu_to_be16(0xFFFF);
895 cpu_to_be16((u16
) cntrs
.port_rcv_errors
);
896 if (cntrs
.port_rcv_remphys_errors
> 0xFFFFUL
)
897 p
->port_rcv_remphys_errors
= __constant_cpu_to_be16(0xFFFF);
899 p
->port_rcv_remphys_errors
=
900 cpu_to_be16((u16
)cntrs
.port_rcv_remphys_errors
);
901 if (cntrs
.port_xmit_discards
> 0xFFFFUL
)
902 p
->port_xmit_discards
= __constant_cpu_to_be16(0xFFFF);
904 p
->port_xmit_discards
=
905 cpu_to_be16((u16
)cntrs
.port_xmit_discards
);
906 if (cntrs
.local_link_integrity_errors
> 0xFUL
)
907 cntrs
.local_link_integrity_errors
= 0xFUL
;
908 if (cntrs
.excessive_buffer_overrun_errors
> 0xFUL
)
909 cntrs
.excessive_buffer_overrun_errors
= 0xFUL
;
910 p
->lli_ebor_errors
= (cntrs
.local_link_integrity_errors
<< 4) |
911 cntrs
.excessive_buffer_overrun_errors
;
912 if (dev
->n_vl15_dropped
> 0xFFFFUL
)
913 p
->vl15_dropped
= __constant_cpu_to_be16(0xFFFF);
915 p
->vl15_dropped
= cpu_to_be16((u16
)dev
->n_vl15_dropped
);
916 if (cntrs
.port_xmit_data
> 0xFFFFFFFFUL
)
917 p
->port_xmit_data
= __constant_cpu_to_be32(0xFFFFFFFF);
919 p
->port_xmit_data
= cpu_to_be32((u32
)cntrs
.port_xmit_data
);
920 if (cntrs
.port_rcv_data
> 0xFFFFFFFFUL
)
921 p
->port_rcv_data
= __constant_cpu_to_be32(0xFFFFFFFF);
923 p
->port_rcv_data
= cpu_to_be32((u32
)cntrs
.port_rcv_data
);
924 if (cntrs
.port_xmit_packets
> 0xFFFFFFFFUL
)
925 p
->port_xmit_packets
= __constant_cpu_to_be32(0xFFFFFFFF);
927 p
->port_xmit_packets
=
928 cpu_to_be32((u32
)cntrs
.port_xmit_packets
);
929 if (cntrs
.port_rcv_packets
> 0xFFFFFFFFUL
)
930 p
->port_rcv_packets
= __constant_cpu_to_be32(0xFFFFFFFF);
932 p
->port_rcv_packets
=
933 cpu_to_be32((u32
) cntrs
.port_rcv_packets
);
935 return reply((struct ib_smp
*) pmp
);
938 static int recv_pma_get_portcounters_ext(struct ib_perf
*pmp
,
939 struct ib_device
*ibdev
, u8 port
)
941 struct ib_pma_portcounters_ext
*p
=
942 (struct ib_pma_portcounters_ext
*)pmp
->data
;
943 struct ipath_ibdev
*dev
= to_idev(ibdev
);
944 u64 swords
, rwords
, spkts
, rpkts
, xwait
;
945 u8 port_select
= p
->port_select
;
947 ipath_layer_snapshot_counters(dev
->dd
, &swords
, &rwords
, &spkts
,
950 /* Adjust counters for any resets done. */
951 swords
-= dev
->z_port_xmit_data
;
952 rwords
-= dev
->z_port_rcv_data
;
953 spkts
-= dev
->z_port_xmit_packets
;
954 rpkts
-= dev
->z_port_rcv_packets
;
956 memset(pmp
->data
, 0, sizeof(pmp
->data
));
958 p
->port_select
= port_select
;
959 if (pmp
->attr_mod
!= 0 ||
960 (port_select
!= port
&& port_select
!= 0xFF))
961 pmp
->status
|= IB_SMP_INVALID_FIELD
;
963 p
->port_xmit_data
= cpu_to_be64(swords
);
964 p
->port_rcv_data
= cpu_to_be64(rwords
);
965 p
->port_xmit_packets
= cpu_to_be64(spkts
);
966 p
->port_rcv_packets
= cpu_to_be64(rpkts
);
967 p
->port_unicast_xmit_packets
= cpu_to_be64(dev
->n_unicast_xmit
);
968 p
->port_unicast_rcv_packets
= cpu_to_be64(dev
->n_unicast_rcv
);
969 p
->port_multicast_xmit_packets
= cpu_to_be64(dev
->n_multicast_xmit
);
970 p
->port_multicast_rcv_packets
= cpu_to_be64(dev
->n_multicast_rcv
);
972 return reply((struct ib_smp
*) pmp
);
975 static int recv_pma_set_portcounters(struct ib_perf
*pmp
,
976 struct ib_device
*ibdev
, u8 port
)
978 struct ib_pma_portcounters
*p
= (struct ib_pma_portcounters
*)
980 struct ipath_ibdev
*dev
= to_idev(ibdev
);
981 struct ipath_layer_counters cntrs
;
984 * Since the HW doesn't support clearing counters, we save the
985 * current count and subtract it from future responses.
987 ipath_layer_get_counters(dev
->dd
, &cntrs
);
989 if (p
->counter_select
& IB_PMA_SEL_SYMBOL_ERROR
)
990 dev
->z_symbol_error_counter
= cntrs
.symbol_error_counter
;
992 if (p
->counter_select
& IB_PMA_SEL_LINK_ERROR_RECOVERY
)
993 dev
->z_link_error_recovery_counter
=
994 cntrs
.link_error_recovery_counter
;
996 if (p
->counter_select
& IB_PMA_SEL_LINK_DOWNED
)
997 dev
->z_link_downed_counter
= cntrs
.link_downed_counter
;
999 if (p
->counter_select
& IB_PMA_SEL_PORT_RCV_ERRORS
)
1000 dev
->z_port_rcv_errors
=
1001 cntrs
.port_rcv_errors
+ dev
->rcv_errors
;
1003 if (p
->counter_select
& IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS
)
1004 dev
->z_port_rcv_remphys_errors
=
1005 cntrs
.port_rcv_remphys_errors
;
1007 if (p
->counter_select
& IB_PMA_SEL_PORT_XMIT_DISCARDS
)
1008 dev
->z_port_xmit_discards
= cntrs
.port_xmit_discards
;
1010 if (p
->counter_select
& IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS
)
1011 dev
->z_local_link_integrity_errors
=
1012 cntrs
.local_link_integrity_errors
;
1014 if (p
->counter_select
& IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS
)
1015 dev
->z_excessive_buffer_overrun_errors
=
1016 cntrs
.excessive_buffer_overrun_errors
;
1018 if (p
->counter_select
& IB_PMA_SEL_PORT_VL15_DROPPED
)
1019 dev
->n_vl15_dropped
= 0;
1021 if (p
->counter_select
& IB_PMA_SEL_PORT_XMIT_DATA
)
1022 dev
->z_port_xmit_data
= cntrs
.port_xmit_data
;
1024 if (p
->counter_select
& IB_PMA_SEL_PORT_RCV_DATA
)
1025 dev
->z_port_rcv_data
= cntrs
.port_rcv_data
;
1027 if (p
->counter_select
& IB_PMA_SEL_PORT_XMIT_PACKETS
)
1028 dev
->z_port_xmit_packets
= cntrs
.port_xmit_packets
;
1030 if (p
->counter_select
& IB_PMA_SEL_PORT_RCV_PACKETS
)
1031 dev
->z_port_rcv_packets
= cntrs
.port_rcv_packets
;
1033 return recv_pma_get_portcounters(pmp
, ibdev
, port
);
1036 static int recv_pma_set_portcounters_ext(struct ib_perf
*pmp
,
1037 struct ib_device
*ibdev
, u8 port
)
1039 struct ib_pma_portcounters
*p
= (struct ib_pma_portcounters
*)
1041 struct ipath_ibdev
*dev
= to_idev(ibdev
);
1042 u64 swords
, rwords
, spkts
, rpkts
, xwait
;
1044 ipath_layer_snapshot_counters(dev
->dd
, &swords
, &rwords
, &spkts
,
1047 if (p
->counter_select
& IB_PMA_SELX_PORT_XMIT_DATA
)
1048 dev
->z_port_xmit_data
= swords
;
1050 if (p
->counter_select
& IB_PMA_SELX_PORT_RCV_DATA
)
1051 dev
->z_port_rcv_data
= rwords
;
1053 if (p
->counter_select
& IB_PMA_SELX_PORT_XMIT_PACKETS
)
1054 dev
->z_port_xmit_packets
= spkts
;
1056 if (p
->counter_select
& IB_PMA_SELX_PORT_RCV_PACKETS
)
1057 dev
->z_port_rcv_packets
= rpkts
;
1059 if (p
->counter_select
& IB_PMA_SELX_PORT_UNI_XMIT_PACKETS
)
1060 dev
->n_unicast_xmit
= 0;
1062 if (p
->counter_select
& IB_PMA_SELX_PORT_UNI_RCV_PACKETS
)
1063 dev
->n_unicast_rcv
= 0;
1065 if (p
->counter_select
& IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS
)
1066 dev
->n_multicast_xmit
= 0;
1068 if (p
->counter_select
& IB_PMA_SELX_PORT_MULTI_RCV_PACKETS
)
1069 dev
->n_multicast_rcv
= 0;
1071 return recv_pma_get_portcounters_ext(pmp
, ibdev
, port
);
1074 static int process_subn(struct ib_device
*ibdev
, int mad_flags
,
1075 u8 port_num
, struct ib_mad
*in_mad
,
1076 struct ib_mad
*out_mad
)
1078 struct ib_smp
*smp
= (struct ib_smp
*)out_mad
;
1079 struct ipath_ibdev
*dev
= to_idev(ibdev
);
1083 if (smp
->class_version
!= 1) {
1084 smp
->status
|= IB_SMP_UNSUP_VERSION
;
1089 /* Is the mkey in the process of expiring? */
1090 if (dev
->mkey_lease_timeout
&& jiffies
>= dev
->mkey_lease_timeout
) {
1091 /* Clear timeout and mkey protection field. */
1092 dev
->mkey_lease_timeout
= 0;
1093 dev
->mkeyprot_resv_lmc
&= 0x3F;
1097 * M_Key checking depends on
1098 * Portinfo:M_Key_protect_bits
1100 if ((mad_flags
& IB_MAD_IGNORE_MKEY
) == 0 && dev
->mkey
!= 0 &&
1101 dev
->mkey
!= smp
->mkey
&&
1102 (smp
->method
== IB_MGMT_METHOD_SET
||
1103 (smp
->method
== IB_MGMT_METHOD_GET
&&
1104 (dev
->mkeyprot_resv_lmc
>> 7) != 0))) {
1105 if (dev
->mkey_violations
!= 0xFFFF)
1106 ++dev
->mkey_violations
;
1107 if (dev
->mkey_lease_timeout
||
1108 dev
->mkey_lease_period
== 0) {
1109 ret
= IB_MAD_RESULT_SUCCESS
|
1110 IB_MAD_RESULT_CONSUMED
;
1113 dev
->mkey_lease_timeout
= jiffies
+
1114 dev
->mkey_lease_period
* HZ
;
1115 /* Future: Generate a trap notice. */
1116 ret
= IB_MAD_RESULT_SUCCESS
| IB_MAD_RESULT_CONSUMED
;
1118 } else if (dev
->mkey_lease_timeout
)
1119 dev
->mkey_lease_timeout
= 0;
1121 switch (smp
->method
) {
1122 case IB_MGMT_METHOD_GET
:
1123 switch (smp
->attr_id
) {
1124 case IB_SMP_ATTR_NODE_DESC
:
1125 ret
= recv_subn_get_nodedescription(smp
, ibdev
);
1127 case IB_SMP_ATTR_NODE_INFO
:
1128 ret
= recv_subn_get_nodeinfo(smp
, ibdev
, port_num
);
1130 case IB_SMP_ATTR_GUID_INFO
:
1131 ret
= recv_subn_get_guidinfo(smp
, ibdev
);
1133 case IB_SMP_ATTR_PORT_INFO
:
1134 ret
= recv_subn_get_portinfo(smp
, ibdev
, port_num
);
1136 case IB_SMP_ATTR_PKEY_TABLE
:
1137 ret
= recv_subn_get_pkeytable(smp
, ibdev
);
1139 case IB_SMP_ATTR_SM_INFO
:
1140 if (dev
->port_cap_flags
& IB_PORT_SM_DISABLED
) {
1141 ret
= IB_MAD_RESULT_SUCCESS
|
1142 IB_MAD_RESULT_CONSUMED
;
1145 if (dev
->port_cap_flags
& IB_PORT_SM
) {
1146 ret
= IB_MAD_RESULT_SUCCESS
;
1151 smp
->status
|= IB_SMP_UNSUP_METH_ATTR
;
1156 case IB_MGMT_METHOD_SET
:
1157 switch (smp
->attr_id
) {
1158 case IB_SMP_ATTR_GUID_INFO
:
1159 ret
= recv_subn_set_guidinfo(smp
, ibdev
);
1161 case IB_SMP_ATTR_PORT_INFO
:
1162 ret
= recv_subn_set_portinfo(smp
, ibdev
, port_num
);
1164 case IB_SMP_ATTR_PKEY_TABLE
:
1165 ret
= recv_subn_set_pkeytable(smp
, ibdev
);
1167 case IB_SMP_ATTR_SM_INFO
:
1168 if (dev
->port_cap_flags
& IB_PORT_SM_DISABLED
) {
1169 ret
= IB_MAD_RESULT_SUCCESS
|
1170 IB_MAD_RESULT_CONSUMED
;
1173 if (dev
->port_cap_flags
& IB_PORT_SM
) {
1174 ret
= IB_MAD_RESULT_SUCCESS
;
1179 smp
->status
|= IB_SMP_UNSUP_METH_ATTR
;
1184 case IB_MGMT_METHOD_GET_RESP
:
1186 * The ib_mad module will call us to process responses
1187 * before checking for other consumers.
1188 * Just tell the caller to process it normally.
1190 ret
= IB_MAD_RESULT_FAILURE
;
1193 smp
->status
|= IB_SMP_UNSUP_METHOD
;
1201 static int process_perf(struct ib_device
*ibdev
, u8 port_num
,
1202 struct ib_mad
*in_mad
,
1203 struct ib_mad
*out_mad
)
1205 struct ib_perf
*pmp
= (struct ib_perf
*)out_mad
;
1209 if (pmp
->class_version
!= 1) {
1210 pmp
->status
|= IB_SMP_UNSUP_VERSION
;
1211 ret
= reply((struct ib_smp
*) pmp
);
1215 switch (pmp
->method
) {
1216 case IB_MGMT_METHOD_GET
:
1217 switch (pmp
->attr_id
) {
1218 case IB_PMA_CLASS_PORT_INFO
:
1219 ret
= recv_pma_get_classportinfo(pmp
);
1221 case IB_PMA_PORT_SAMPLES_CONTROL
:
1222 ret
= recv_pma_get_portsamplescontrol(pmp
, ibdev
,
1225 case IB_PMA_PORT_SAMPLES_RESULT
:
1226 ret
= recv_pma_get_portsamplesresult(pmp
, ibdev
);
1228 case IB_PMA_PORT_SAMPLES_RESULT_EXT
:
1229 ret
= recv_pma_get_portsamplesresult_ext(pmp
,
1232 case IB_PMA_PORT_COUNTERS
:
1233 ret
= recv_pma_get_portcounters(pmp
, ibdev
,
1236 case IB_PMA_PORT_COUNTERS_EXT
:
1237 ret
= recv_pma_get_portcounters_ext(pmp
, ibdev
,
1241 pmp
->status
|= IB_SMP_UNSUP_METH_ATTR
;
1242 ret
= reply((struct ib_smp
*) pmp
);
1246 case IB_MGMT_METHOD_SET
:
1247 switch (pmp
->attr_id
) {
1248 case IB_PMA_PORT_SAMPLES_CONTROL
:
1249 ret
= recv_pma_set_portsamplescontrol(pmp
, ibdev
,
1252 case IB_PMA_PORT_COUNTERS
:
1253 ret
= recv_pma_set_portcounters(pmp
, ibdev
,
1256 case IB_PMA_PORT_COUNTERS_EXT
:
1257 ret
= recv_pma_set_portcounters_ext(pmp
, ibdev
,
1261 pmp
->status
|= IB_SMP_UNSUP_METH_ATTR
;
1262 ret
= reply((struct ib_smp
*) pmp
);
1266 case IB_MGMT_METHOD_GET_RESP
:
1268 * The ib_mad module will call us to process responses
1269 * before checking for other consumers.
1270 * Just tell the caller to process it normally.
1272 ret
= IB_MAD_RESULT_FAILURE
;
1275 pmp
->status
|= IB_SMP_UNSUP_METHOD
;
1276 ret
= reply((struct ib_smp
*) pmp
);
1284 * ipath_process_mad - process an incoming MAD packet
1285 * @ibdev: the infiniband device this packet came in on
1286 * @mad_flags: MAD flags
1287 * @port_num: the port number this packet came in on
1288 * @in_wc: the work completion entry for this packet
1289 * @in_grh: the global route header for this packet
1290 * @in_mad: the incoming MAD
1291 * @out_mad: any outgoing MAD reply
1293 * Returns IB_MAD_RESULT_SUCCESS if this is a MAD that we are not
1294 * interested in processing.
1296 * Note that the verbs framework has already done the MAD sanity checks,
1297 * and hop count/pointer updating for IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE
1300 * This is called by the ib_mad module.
1302 int ipath_process_mad(struct ib_device
*ibdev
, int mad_flags
, u8 port_num
,
1303 struct ib_wc
*in_wc
, struct ib_grh
*in_grh
,
1304 struct ib_mad
*in_mad
, struct ib_mad
*out_mad
)
1308 switch (in_mad
->mad_hdr
.mgmt_class
) {
1309 case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE
:
1310 case IB_MGMT_CLASS_SUBN_LID_ROUTED
:
1311 ret
= process_subn(ibdev
, mad_flags
, port_num
,
1314 case IB_MGMT_CLASS_PERF_MGMT
:
1315 ret
= process_perf(ibdev
, port_num
, in_mad
, out_mad
);
1318 ret
= IB_MAD_RESULT_SUCCESS
;