From patchwork Mon Dec 17 19:15:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 10734169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23ED91399 for ; Mon, 17 Dec 2018 19:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C2A2A419 for ; Mon, 17 Dec 2018 19:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A5102A420; Mon, 17 Dec 2018 19:15:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6E5A2A419 for ; Mon, 17 Dec 2018 19:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388999AbeLQTP5 (ORCPT ); Mon, 17 Dec 2018 14:15:57 -0500 Received: from mga12.intel.com ([192.55.52.136]:45850 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388938AbeLQTP5 (ORCPT ); Mon, 17 Dec 2018 14:15:57 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2018 11:15:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,366,1539673200"; d="scan'208";a="304561732" Received: from phlsvsds.ph.intel.com ([10.228.164.149]) by fmsmga005.fm.intel.com with ESMTP; 17 Dec 2018 11:15:54 -0800 Received: from phlsvsds.ph.intel.com (localhost.localdomain [127.0.0.1]) by phlsvsds.ph.intel.com (8.13.8/8.13.8) with ESMTP id wBHJFkWB018263; Mon, 17 Dec 2018 14:15:46 -0500 Received: (from iweiny@localhost) by phlsvsds.ph.intel.com (8.13.8/8.13.8/Submit) id wBHJFjUB018260; Mon, 17 Dec 2018 14:15:45 -0500 X-Authentication-Warning: phlsvsds.ph.intel.com: iweiny set sender to ira.weiny@intel.com using -f From: ira.weiny@intel.com To: linux-rdma@vger.kernel.org Cc: Doug Ledford , Jason Gunthorpe , Alexei Starovoitov , Daniel Borkmann , Hal Rosenstock , Ira Weiny Subject: [RDMA for-next 4/6] IB/UMAD: Add umad trace points Date: Mon, 17 Dec 2018 14:15:22 -0500 Message-Id: <1545074124-18185-5-git-send-email-ira.weiny@intel.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1545074124-18185-1-git-send-email-ira.weiny@intel.com> References: <1545074124-18185-1-git-send-email-ira.weiny@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ira Weiny Trace MADs going to/from user space. Signed-off-by: Ira Weiny --- Changes from v1: remove extra dead traces from trace/events/ib_umad.h fix copyright Clean up FIXMEs Changes from v2: fix checkpatch errors Update copyright date Add ib_umad_read trace drivers/infiniband/core/user_mad.c | 7 ++ include/trace/events/ib_umad.h | 140 +++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 include/trace/events/ib_umad.h diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index f55f48f6b272..1d2c6fb10951 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c @@ -130,6 +130,9 @@ struct ib_umad_packet { struct ib_user_mad mad; }; +#define CREATE_TRACE_POINTS +#include + static struct class *umad_class; static const dev_t base_umad_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE); @@ -388,6 +391,8 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf, else ret = copy_send_mad(file, buf, packet, count); + trace_ib_umad_read(file, (struct ib_user_mad *)buf); + if (ret < 0) { /* Requeue packet */ mutex_lock(&file->mutex); @@ -505,6 +510,8 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf, mutex_lock(&file->mutex); + trace_ib_umad_write(file, &packet->mad); + agent = __get_agent(file, packet->mad.hdr.id); if (!agent) { ret = -EINVAL; diff --git a/include/trace/events/ib_umad.h b/include/trace/events/ib_umad.h new file mode 100644 index 000000000000..247802268d39 --- /dev/null +++ b/include/trace/events/ib_umad.h @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2018 Intel Corporation. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM ib_umad + +#if !defined(_TRACE_IB_UMAD_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_IB_UMAD_H + +#include + +DECLARE_EVENT_CLASS(ib_umad_template, + TP_PROTO(struct ib_umad_file *file, struct ib_user_mad *mad), + TP_ARGS(file, mad), + + TP_STRUCT__entry( + __array(char, dev_name, IB_DEVICE_NAME_MAX) + __field(u8, port_num) + + __field(u32, id) + __field(u32, status) + __field(u32, timeout_ms) + __field(u32, retires) + __field(u32, length) + __field(u32, qpn) + __field(u32, qkey) + __field(u16, lid) + __field(u8, sl) + __field(u8, path_bits) + __field(u8, grh_present) + __field(u8, gid_index) + __field(u8, hop_limit) + __field(u8, traffic_class) + __array(u8, gid, 16) + __field(u32, flow_label) + __field(u16, pkey_index) + + __field(u8, base_version) + __field(u8, mgmt_class) + __field(u8, class_version) + __field(u8, method) + __field(u16, mad_status) + __field(u16, class_specific) + __field(u64, tid) + __field(u16, attr_id) + __field(u32, attr_mod) + ), + + TP_fast_assign( + memcpy(__entry->dev_name, file->port->ib_dev->name, IB_DEVICE_NAME_MAX); + __entry->port_num = file->port->port_num; + + __entry->id = mad->hdr.id; + __entry->status = mad->hdr.status; + __entry->timeout_ms = mad->hdr.timeout_ms; + __entry->retires = mad->hdr.retries; + __entry->length = mad->hdr.length; + __entry->qpn = mad->hdr.qpn; + __entry->qkey = mad->hdr.qkey; + __entry->lid = mad->hdr.lid; + __entry->sl = mad->hdr.sl; + __entry->path_bits = mad->hdr.path_bits; + __entry->grh_present = mad->hdr.grh_present; + __entry->gid_index = mad->hdr.gid_index; + __entry->hop_limit = mad->hdr.hop_limit; + __entry->traffic_class = mad->hdr.traffic_class; + memcpy(__entry->gid, mad->hdr.gid, sizeof(mad->hdr.gid)); + __entry->flow_label = mad->hdr.flow_label; + __entry->pkey_index = mad->hdr.pkey_index; + + __entry->base_version = ((struct ib_mad_hdr *)mad->data)->base_version; + __entry->mgmt_class = ((struct ib_mad_hdr *)mad->data)->mgmt_class; + __entry->class_version = ((struct ib_mad_hdr *)mad->data)->class_version; + __entry->method = ((struct ib_mad_hdr *)mad->data)->method; + __entry->mad_status = ((struct ib_mad_hdr *)mad->data)->status; + __entry->class_specific = ((struct ib_mad_hdr *)mad->data)->class_specific; + __entry->tid = ((struct ib_mad_hdr *)mad->data)->tid; + __entry->attr_id = ((struct ib_mad_hdr *)mad->data)->attr_id; + __entry->attr_mod = ((struct ib_mad_hdr *)mad->data)->attr_mod; + ), + + TP_printk("%s:%d umad_hdr: id 0x%08x status 0x%08x ms %u ret %u len %u QP%u " \ + "qkey 0x%08x lid 0x%04x sl %u path_bits 0x%x grh 0x%x gidi %u " \ + "hop_lim %u traf_cl %u gid %pI6c flow 0x%08x pkeyi %u " \ + "MAD: base_ver 0x%x class 0x%x class_ver 0x%x method 0x%x " \ + "status 0x%04x class_specific 0x%04x tid 0x%016llx attr_id 0x%04x attr_mod 0x%08x ", + __entry->dev_name, __entry->port_num, + __entry->id, __entry->status, __entry->timeout_ms, + __entry->retires, __entry->length, be32_to_cpu(__entry->qpn), + be32_to_cpu(__entry->qkey), be16_to_cpu(__entry->lid), __entry->sl, + __entry->path_bits, __entry->grh_present, __entry->gid_index, + __entry->hop_limit, __entry->traffic_class, &__entry->gid, + be32_to_cpu(__entry->flow_label), __entry->pkey_index, + __entry->base_version, __entry->mgmt_class, __entry->class_version, + __entry->method, be16_to_cpu(__entry->mad_status), be16_to_cpu(__entry->class_specific), + be64_to_cpu(__entry->tid), be16_to_cpu(__entry->attr_id), be32_to_cpu(__entry->attr_mod) + ) +); + +DEFINE_EVENT(ib_umad_template, ib_umad_write, + TP_PROTO(struct ib_umad_file *file, struct ib_user_mad *mad), + TP_ARGS(file, mad)); + +DEFINE_EVENT(ib_umad_template, ib_umad_read, + TP_PROTO(struct ib_umad_file *file, struct ib_user_mad *mad), + TP_ARGS(file, mad)); + +#endif /* _TRACE_IB_UMAD_H */ + +#include