Skip to content

Commit 0b1e5b9

Browse files
yonatancodledford
authored andcommitted
IB/rxe: Add port protocol stats
Expose new counters using the get_hw_stats callback. We expose the following counters: +---------------------+----------------------------------------+ | Name | Description | |---------------------+----------------------------------------| |sent_pkts | number of sent pkts | |---------------------+----------------------------------------| |rcvd_pkts | number of received packets | |---------------------+----------------------------------------| |out_of_sequence | number of errors due to packet | | | transport sequence number | |---------------------+----------------------------------------| |duplicate_request | number of received duplicated packets. | | | A request that previously executed is | | | named duplicated. | |---------------------+----------------------------------------| |rcvd_rnr_err | number of received RNR by completer | |---------------------+----------------------------------------| |send_rnr_err | number of sent RNR by responder | |---------------------+----------------------------------------| |rcvd_seq_err | number of out of sequence packets | | | received | |---------------------+----------------------------------------| |ack_deffered | number of deferred handling of ack | | | packets. | |---------------------+----------------------------------------| |retry_exceeded_err | number of times retry exceeded | |---------------------+----------------------------------------| |completer_retry_err | number of times completer decided to | | | retry | |---------------------+----------------------------------------| |send_err | number of failed send packet | +---------------------+----------------------------------------+ Signed-off-by: Yonatan Cohen <yonatanc@mellanox.com> Reviewed-by: Moni Shoua <monis@mellanox.com> Reviewed-by: Andrew Boyer <andrew.boyer@dell.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 339e757 commit 0b1e5b9

File tree

9 files changed

+174
-2
lines changed

9 files changed

+174
-2
lines changed

drivers/infiniband/sw/rxe/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ rdma_rxe-y := \
2020
rxe_mcast.o \
2121
rxe_task.o \
2222
rxe_net.o \
23-
rxe_sysfs.o
23+
rxe_sysfs.o \
24+
rxe_hw_counters.o

drivers/infiniband/sw/rxe/rxe_comp.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ void rxe_comp_queue_pkt(struct rxe_dev *rxe, struct rxe_qp *qp,
154154
skb_queue_tail(&qp->resp_pkts, skb);
155155

156156
must_sched = skb_queue_len(&qp->resp_pkts) > 1;
157+
if (must_sched != 0)
158+
rxe_counter_inc(rxe, RXE_CNT_COMPLETER_SCHED);
157159
rxe_run_task(&qp->comp.task, must_sched);
158160
}
159161

@@ -236,6 +238,7 @@ static inline enum comp_state check_ack(struct rxe_qp *qp,
236238
{
237239
unsigned int mask = pkt->mask;
238240
u8 syn;
241+
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
239242

240243
/* Check the sequence only */
241244
switch (qp->comp.opcode) {
@@ -298,6 +301,7 @@ static inline enum comp_state check_ack(struct rxe_qp *qp,
298301
return COMPST_WRITE_SEND;
299302

300303
case AETH_RNR_NAK:
304+
rxe_counter_inc(rxe, RXE_CNT_RCV_RNR);
301305
return COMPST_RNR_RETRY;
302306

303307
case AETH_NAK:
@@ -307,6 +311,8 @@ static inline enum comp_state check_ack(struct rxe_qp *qp,
307311
* before
308312
*/
309313
if (psn_compare(pkt->psn, qp->comp.psn) > 0) {
314+
rxe_counter_inc(rxe,
315+
RXE_CNT_RCV_SEQ_ERR);
310316
qp->comp.psn = pkt->psn;
311317
if (qp->req.wait_psn) {
312318
qp->req.wait_psn = 0;
@@ -534,6 +540,7 @@ static void rxe_drain_resp_pkts(struct rxe_qp *qp, bool notify)
534540
int rxe_completer(void *arg)
535541
{
536542
struct rxe_qp *qp = (struct rxe_qp *)arg;
543+
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
537544
struct rxe_send_wqe *wqe = wqe;
538545
struct sk_buff *skb = NULL;
539546
struct rxe_pkt_info *pkt = NULL;
@@ -683,8 +690,10 @@ int rxe_completer(void *arg)
683690
if (psn_compare(qp->req.psn,
684691
qp->comp.psn) > 0) {
685692
/* tell the requester to retry the
686-
* send send queue next time around
693+
* send queue next time around
687694
*/
695+
rxe_counter_inc(rxe,
696+
RXE_CNT_COMP_RETRY);
688697
qp->req.need_retry = 1;
689698
rxe_run_task(&qp->req.task, 1);
690699
}
@@ -699,6 +708,7 @@ int rxe_completer(void *arg)
699708
goto exit;
700709

701710
} else {
711+
rxe_counter_inc(rxe, RXE_CNT_RETRY_EXCEEDED);
702712
wqe->status = IB_WC_RETRY_EXC_ERR;
703713
state = COMPST_ERROR;
704714
}
@@ -720,6 +730,8 @@ int rxe_completer(void *arg)
720730
skb = NULL;
721731
goto exit;
722732
} else {
733+
rxe_counter_inc(rxe,
734+
RXE_CNT_RNR_RETRY_EXCEEDED);
723735
wqe->status = IB_WC_RNR_RETRY_EXC_ERR;
724736
state = COMPST_ERROR;
725737
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved.
3+
*
4+
* This software is available to you under a choice of one of two
5+
* licenses. You may choose to be licensed under the terms of the GNU
6+
* General Public License (GPL) Version 2, available from the file
7+
* COPYING in the main directory of this source tree, or the
8+
* OpenIB.org BSD license below:
9+
*
10+
* Redistribution and use in source and binary forms, with or
11+
* without modification, are permitted provided that the following
12+
* conditions are met:
13+
*
14+
* - Redistributions of source code must retain the above
15+
* copyright notice, this list of conditions and the following
16+
* disclaimer.
17+
*
18+
* - Redistributions in binary form must reproduce the above
19+
* copyright notice, this list of conditions and the following
20+
* disclaimer in the documentation and/or other materials
21+
* provided with the distribution.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
* SOFTWARE.
31+
*/
32+
33+
#include "rxe.h"
34+
#include "rxe_hw_counters.h"
35+
36+
const char * const rxe_counter_name[] = {
37+
[RXE_CNT_SENT_PKTS] = "sent_pkts",
38+
[RXE_CNT_RCVD_PKTS] = "rcvd_pkts",
39+
[RXE_CNT_DUP_REQ] = "duplicate_request",
40+
[RXE_CNT_OUT_OF_SEQ_REQ] = "out_of_sequence",
41+
[RXE_CNT_RCV_RNR] = "rcvd_rnr_err",
42+
[RXE_CNT_SND_RNR] = "send_rnr_err",
43+
[RXE_CNT_RCV_SEQ_ERR] = "rcvd_seq_err",
44+
[RXE_CNT_COMPLETER_SCHED] = "ack_deffered",
45+
[RXE_CNT_RETRY_EXCEEDED] = "retry_exceeded_err",
46+
[RXE_CNT_RNR_RETRY_EXCEEDED] = "retry_rnr_exceeded_err",
47+
[RXE_CNT_COMP_RETRY] = "completer_retry_err",
48+
[RXE_CNT_SEND_ERR] = "send_err",
49+
};
50+
51+
int rxe_ib_get_hw_stats(struct ib_device *ibdev,
52+
struct rdma_hw_stats *stats,
53+
u8 port, int index)
54+
{
55+
struct rxe_dev *dev = to_rdev(ibdev);
56+
unsigned int cnt;
57+
58+
if (!port || !stats)
59+
return -EINVAL;
60+
61+
for (cnt = 0; cnt < ARRAY_SIZE(rxe_counter_name); cnt++)
62+
stats->value[cnt] = dev->stats_counters[cnt];
63+
64+
return ARRAY_SIZE(rxe_counter_name);
65+
}
66+
67+
struct rdma_hw_stats *rxe_ib_alloc_hw_stats(struct ib_device *ibdev,
68+
u8 port_num)
69+
{
70+
BUILD_BUG_ON(ARRAY_SIZE(rxe_counter_name) != RXE_NUM_OF_COUNTERS);
71+
/* We support only per port stats */
72+
if (!port_num)
73+
return NULL;
74+
75+
return rdma_alloc_hw_stats_struct(rxe_counter_name,
76+
ARRAY_SIZE(rxe_counter_name),
77+
RDMA_HW_STATS_DEFAULT_LIFESPAN);
78+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved.
3+
*
4+
* This software is available to you under a choice of one of two
5+
* licenses. You may choose to be licensed under the terms of the GNU
6+
* General Public License (GPL) Version 2, available from the file
7+
* COPYING in the main directory of this source tree, or the
8+
* OpenIB.org BSD license below:
9+
*
10+
* Redistribution and use in source and binary forms, with or
11+
* without modification, are permitted provided that the following
12+
* conditions are met:
13+
*
14+
* - Redistributions of source code must retain the above
15+
* copyright notice, this list of conditions and the following
16+
* disclaimer.
17+
*
18+
* - Redistributions in binary form must reproduce the above
19+
* copyright notice, this list of conditions and the following
20+
* disclaimer in the documentation and/or other materials
21+
* provided with the distribution.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
* SOFTWARE.
31+
*/
32+
33+
#ifndef RXE_HW_COUNTERS_H
34+
#define RXE_HW_COUNTERS_H
35+
36+
/*
37+
* when adding counters to enum also add
38+
* them to rxe_counter_name[] vector.
39+
*/
40+
enum rxe_counters {
41+
RXE_CNT_SENT_PKTS,
42+
RXE_CNT_RCVD_PKTS,
43+
RXE_CNT_DUP_REQ,
44+
RXE_CNT_OUT_OF_SEQ_REQ,
45+
RXE_CNT_RCV_RNR,
46+
RXE_CNT_SND_RNR,
47+
RXE_CNT_RCV_SEQ_ERR,
48+
RXE_CNT_COMPLETER_SCHED,
49+
RXE_CNT_RETRY_EXCEEDED,
50+
RXE_CNT_RNR_RETRY_EXCEEDED,
51+
RXE_CNT_COMP_RETRY,
52+
RXE_CNT_SEND_ERR,
53+
RXE_NUM_OF_COUNTERS
54+
};
55+
56+
struct rdma_hw_stats *rxe_ib_alloc_hw_stats(struct ib_device *ibdev,
57+
u8 port_num);
58+
int rxe_ib_get_hw_stats(struct ib_device *ibdev,
59+
struct rdma_hw_stats *stats,
60+
u8 port, int index);
61+
#endif /* RXE_HW_COUNTERS_H */

drivers/infiniband/sw/rxe/rxe_loc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ static inline int rxe_xmit_packet(struct rxe_dev *rxe, struct rxe_qp *qp,
278278

279279
if (err) {
280280
rxe->xmit_errors++;
281+
rxe_counter_inc(rxe, RXE_CNT_SEND_ERR);
281282
return err;
282283
}
283284

@@ -287,6 +288,7 @@ static inline int rxe_xmit_packet(struct rxe_dev *rxe, struct rxe_qp *qp,
287288
rxe_run_task(&qp->comp.task, 1);
288289
}
289290

291+
rxe_counter_inc(rxe, RXE_CNT_SENT_PKTS);
290292
goto done;
291293

292294
drop:

drivers/infiniband/sw/rxe/rxe_recv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ int rxe_rcv(struct sk_buff *skb)
403403
goto drop;
404404
}
405405

406+
rxe_counter_inc(rxe, RXE_CNT_RCVD_PKTS);
407+
406408
if (unlikely(bth_qpn(pkt) == IB_MULTICAST_QPN))
407409
rxe_rcv_mcast_pkt(rxe, skb);
408410
else

drivers/infiniband/sw/rxe/rxe_resp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ static enum resp_states check_psn(struct rxe_qp *qp,
149149
struct rxe_pkt_info *pkt)
150150
{
151151
int diff = psn_compare(pkt->psn, qp->resp.psn);
152+
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
152153

153154
switch (qp_type(qp)) {
154155
case IB_QPT_RC:
@@ -157,9 +158,11 @@ static enum resp_states check_psn(struct rxe_qp *qp,
157158
return RESPST_CLEANUP;
158159

159160
qp->resp.sent_psn_nak = 1;
161+
rxe_counter_inc(rxe, RXE_CNT_OUT_OF_SEQ_REQ);
160162
return RESPST_ERR_PSN_OUT_OF_SEQ;
161163

162164
} else if (diff < 0) {
165+
rxe_counter_inc(rxe, RXE_CNT_DUP_REQ);
163166
return RESPST_DUPLICATE_REQUEST;
164167
}
165168

@@ -1223,6 +1226,7 @@ void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify)
12231226
int rxe_responder(void *arg)
12241227
{
12251228
struct rxe_qp *qp = (struct rxe_qp *)arg;
1229+
struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
12261230
enum resp_states state;
12271231
struct rxe_pkt_info *pkt = NULL;
12281232
int ret = 0;
@@ -1311,6 +1315,7 @@ int rxe_responder(void *arg)
13111315
break;
13121316
case RESPST_ERR_RNR:
13131317
if (qp_type(qp) == IB_QPT_RC) {
1318+
rxe_counter_inc(rxe, RXE_CNT_SND_RNR);
13141319
/* RC - class B */
13151320
send_ack(qp, pkt, AETH_RNR_NAK |
13161321
(~AETH_TYPE_MASK &

drivers/infiniband/sw/rxe/rxe_verbs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "rxe.h"
3636
#include "rxe_loc.h"
3737
#include "rxe_queue.h"
38+
#include "rxe_hw_counters.h"
3839

3940
static int rxe_query_device(struct ib_device *dev,
4041
struct ib_device_attr *attr,
@@ -1318,6 +1319,8 @@ int rxe_register_device(struct rxe_dev *rxe)
13181319
dev->map_mr_sg = rxe_map_mr_sg;
13191320
dev->attach_mcast = rxe_attach_mcast;
13201321
dev->detach_mcast = rxe_detach_mcast;
1322+
dev->get_hw_stats = rxe_ib_get_hw_stats;
1323+
dev->alloc_hw_stats = rxe_ib_alloc_hw_stats;
13211324

13221325
err = ib_register_device(dev, NULL);
13231326
if (err) {

drivers/infiniband/sw/rxe/rxe_verbs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <rdma/rdma_user_rxe.h>
3939
#include "rxe_pool.h"
4040
#include "rxe_task.h"
41+
#include "rxe_hw_counters.h"
4142

4243
static inline int pkey_match(u16 key1, u16 key2)
4344
{
@@ -401,10 +402,17 @@ struct rxe_dev {
401402
spinlock_t mmap_offset_lock; /* guard mmap_offset */
402403
int mmap_offset;
403404

405+
u64 stats_counters[RXE_NUM_OF_COUNTERS];
406+
404407
struct rxe_port port;
405408
struct list_head list;
406409
};
407410

411+
static inline void rxe_counter_inc(struct rxe_dev *rxe, enum rxe_counters cnt)
412+
{
413+
rxe->stats_counters[cnt]++;
414+
}
415+
408416
static inline struct rxe_dev *to_rdev(struct ib_device *dev)
409417
{
410418
return dev ? container_of(dev, struct rxe_dev, ib_dev) : NULL;

0 commit comments

Comments
 (0)