From patchwork Thu Apr 14 15:42:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Dalessandro X-Patchwork-Id: 8838941 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 737AE9F71A for ; Thu, 14 Apr 2016 15:42:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E79C2014A for ; Thu, 14 Apr 2016 15:42:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CAD720295 for ; Thu, 14 Apr 2016 15:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932862AbcDNPmX (ORCPT ); Thu, 14 Apr 2016 11:42:23 -0400 Received: from mga01.intel.com ([192.55.52.88]:41416 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932819AbcDNPmN (ORCPT ); Thu, 14 Apr 2016 11:42:13 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 14 Apr 2016 08:42:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,485,1455004800"; d="scan'208";a="686286446" Received: from scymds01.sc.intel.com ([10.82.194.37]) by FMSMGA003.fm.intel.com with ESMTP; 14 Apr 2016 08:42:12 -0700 Received: from scvm10.sc.intel.com (scvm10.sc.intel.com [10.82.195.27]) by scymds01.sc.intel.com with ESMTP id u3EFgB43017623; Thu, 14 Apr 2016 08:42:11 -0700 Received: from scvm10.sc.intel.com (localhost [127.0.0.1]) by scvm10.sc.intel.com with ESMTP id u3EFgBvS008386; Thu, 14 Apr 2016 08:42:11 -0700 Subject: [PATCH 6/7] IB/hfi1: Consolidate IOCTL defines To: dledford@redhat.com From: Dennis Dalessandro Cc: linux-rdma@vger.kernel.org, Mitko Haralanov , linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, torvalds@linux-foundation.org Date: Thu, 14 Apr 2016 08:42:11 -0700 Message-ID: <20160414154210.6387.63374.stgit@scvm10.sc.intel.com> In-Reply-To: <20160414153727.6387.96381.stgit@scvm10.sc.intel.com> References: <20160414153727.6387.96381.stgit@scvm10.sc.intel.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Consolidate all the IOCTL defines which are supported by the driver into a common location. This header file is made available to user space and will now allow user applications to determine IOCTL numbers directly. Reviewed-by: Mitko Haralanov Signed-off-by: Dennis Dalessandro --- drivers/staging/rdma/hfi1/common.h | 3 -- drivers/staging/rdma/hfi1/diag.c | 50 +------------------------------- include/uapi/rdma/hfi/hfi1_user.h | 56 +++++++++++++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 56 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/staging/rdma/hfi1/common.h b/drivers/staging/rdma/hfi1/common.h index 37ac229..b729445 100644 --- a/drivers/staging/rdma/hfi1/common.h +++ b/drivers/staging/rdma/hfi1/common.h @@ -350,9 +350,6 @@ struct hfi1_message_header { #define HFI1_BECN_MASK 1 #define HFI1_BECN_SMASK BIT(HFI1_BECN_SHIFT) -#define HFI1_PSM_IOC_BASE_SEQ 0x0 -#define HFI1_SNOOP_IOC_BASE_SEQ 0x80 /* leaves plenty of room for psm */ - static inline __u64 rhf_to_cpu(const __le32 *rbuf) { return __le64_to_cpu(*((__le64 *)rbuf)); diff --git a/drivers/staging/rdma/hfi1/diag.c b/drivers/staging/rdma/hfi1/diag.c index 4cf6e8d..776ccee 100644 --- a/drivers/staging/rdma/hfi1/diag.c +++ b/drivers/staging/rdma/hfi1/diag.c @@ -64,6 +64,7 @@ #include #include #include +#include #include "hfi.h" #include "device.h" #include "common.h" @@ -142,60 +143,11 @@ static const struct file_operations diagpkt_file_ops = { }; /* - * This is used for communication with user space for snoop extended IOCTLs - */ -struct hfi1_link_info { - __be64 node_guid; - u8 port_mode; - u8 port_state; - u16 link_speed_active; - u16 link_width_active; - u16 vl15_init; - u8 port_number; - /* - * Add padding to make this a full IB SMP payload. Note: changing the - * size of this structure will make the IOCTLs created with _IOWR - * change. - * Be sure to run tests on all IOCTLs when making changes to this - * structure. - */ - u8 res[47]; -}; - -/* * This starts our ioctl sequence numbers *way* off from the ones * defined in ib_core. */ #define SNOOP_CAPTURE_VERSION 0x1 -#define HFI1_SNOOP_IOC_MAGIC IB_IOCTL_MAGIC - -#define HFI1_SNOOP_IOCGETLINKSTATE \ - _IO(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ) -#define HFI1_SNOOP_IOCSETLINKSTATE \ - _IO(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 1) -#define HFI1_SNOOP_IOCCLEARQUEUE \ - _IO(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 2) -#define HFI1_SNOOP_IOCCLEARFILTER \ - _IO(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 3) -#define HFI1_SNOOP_IOCSETFILTER \ - _IO(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 4) -#define HFI1_SNOOP_IOCGETVERSION \ - _IO(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 5) -#define HFI1_SNOOP_IOCSET_OPTS \ - _IO(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 6) - -/* - * These offsets +6/+7 could change, but these are already known and used - * IOCTL numbers so don't change them without a good reason. - */ -#define HFI1_SNOOP_IOCGETLINKSTATE_EXTRA \ - _IOWR(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 6, \ - struct hfi1_link_info) -#define HFI1_SNOOP_IOCSETLINKSTATE_EXTRA \ - _IOWR(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 7, \ - struct hfi1_link_info) - static int hfi1_snoop_open(struct inode *in, struct file *fp); static ssize_t hfi1_snoop_read(struct file *fp, char __user *data, size_t pkt_len, loff_t *off); diff --git a/include/uapi/rdma/hfi/hfi1_user.h b/include/uapi/rdma/hfi/hfi1_user.h index 383d036..5503451 100644 --- a/include/uapi/rdma/hfi/hfi1_user.h +++ b/include/uapi/rdma/hfi/hfi1_user.h @@ -147,13 +147,11 @@ #define HFI1_CMD_EP_READ_RANGE 76 /* read EPROM range */ #define HFI1_CMD_EP_WRITE_RANGE 77 /* write EPROM range */ -/* - * User IOCTLs can not go above 128 if they do then see common.h and change the - * base for the snoop ioctl - */ #define IB_IOCTL_MAGIC 0x1b /* See Documentation/ioctl/ioctl-number.txt */ struct hfi1_cmd; +#define HFI1_PSM_IOC_BASE_SEQ 0x0 + #define HFI1_IOCTL_ASSIGN_CTXT \ _IOWR(IB_IOCTL_MAGIC, HFI1_CMD_ASSIGN_CTXT, struct hfi1_user_info) #define HFI1_IOCTL_CTXT_INFO \ @@ -189,6 +187,56 @@ struct hfi1_cmd; #define HFI1_IOCTL_EP_WRITE_RANGE \ _IOWR(IB_IOCTL_MAGIC, HFI1_CMD_EP_WRITE_RANGE, struct hfi1_cmd) +#define HFI1_SNOOP_IOC_BASE_SEQ 0x80 /* leaves plenty of room for psm */ +#define HFI1_SNOOP_IOC_MAGIC IB_IOCTL_MAGIC + +#define HFI1_SNOOP_IOCGETLINKSTATE \ + _IO(IB_IOCTL_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ) +#define HFI1_SNOOP_IOCSETLINKSTATE \ + _IO(IB_IOCTL_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 1) +#define HFI1_SNOOP_IOCCLEARQUEUE \ + _IO(IB_IOCTL_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 2) +#define HFI1_SNOOP_IOCCLEARFILTER \ + _IO(IB_IOCTL_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 3) +#define HFI1_SNOOP_IOCSETFILTER \ + _IO(IB_IOCTL_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 4) +#define HFI1_SNOOP_IOCGETVERSION \ + _IO(IB_IOCTL_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 5) +#define HFI1_SNOOP_IOCSET_OPTS \ + _IO(IB_IOCTL_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 6) + +/* + * This is used for communication with user space for snoop extended IOCTLs + */ +struct hfi1_link_info { + __be64 node_guid; + __u8 port_mode; + __u8 port_state; + __u16 link_speed_active; + __u16 link_width_active; + __u16 vl15_init; + __u8 port_number; + /* + * Add padding to make this a full IB SMP payload. Note: changing the + * size of this structure will make the IOCTLs created with _IOWR + * change. + * Be sure to run tests on all IOCTLs when making changes to this + * structure. + */ + __u8 res[47]; +}; + +/* + * These offsets +6/+7 could change, but these are already known and used + * IOCTL numbers so don't change them without a good reason. + */ +#define HFI1_SNOOP_IOCGETLINKSTATE_EXTRA \ + _IOWR(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 6, \ + struct hfi1_link_info) +#define HFI1_SNOOP_IOCSETLINKSTATE_EXTRA \ + _IOWR(HFI1_SNOOP_IOC_MAGIC, HFI1_SNOOP_IOC_BASE_SEQ + 7, \ + struct hfi1_link_info) + #define _HFI1_EVENT_FROZEN_BIT 0 #define _HFI1_EVENT_LINKDOWN_BIT 1 #define _HFI1_EVENT_LID_CHANGE_BIT 2