/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */1/*2*3* This file is provided under a dual BSD/GPLv2 license. When using or4* redistributing this file, you may do so under either license.5*6* GPL LICENSE SUMMARY7*8* Copyright(c) 2015 - 2020 Intel Corporation.9*10* This program is free software; you can redistribute it and/or modify11* it under the terms of version 2 of the GNU General Public License as12* published by the Free Software Foundation.13*14* This program is distributed in the hope that it will be useful, but15* WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17* General Public License for more details.18*19* BSD LICENSE20*21* Copyright(c) 2015 Intel Corporation.22*23* Redistribution and use in source and binary forms, with or without24* modification, are permitted provided that the following conditions25* are met:26*27* - Redistributions of source code must retain the above copyright28* notice, this list of conditions and the following disclaimer.29* - Redistributions in binary form must reproduce the above copyright30* notice, this list of conditions and the following disclaimer in31* the documentation and/or other materials provided with the32* distribution.33* - Neither the name of Intel Corporation nor the names of its34* contributors may be used to endorse or promote products derived35* from this software without specific prior written permission.36*37* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS38* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT39* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR40* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT41* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,42* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT43* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,44* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY45* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT46* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE47* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.48*49*/5051/*52* This file contains defines, structures, etc. that are used53* to communicate between kernel and user code.54*/5556#ifndef _LINUX__HFI1_USER_H57#define _LINUX__HFI1_USER_H5859#include <linux/types.h>60#include <rdma/rdma_user_ioctl.h>6162/*63* This version number is given to the driver by the user code during64* initialization in the spu_userversion field of hfi1_user_info, so65* the driver can check for compatibility with user code.66*67* The major version changes when data structures change in an incompatible68* way. The driver must be the same for initialization to succeed.69*/70#define HFI1_USER_SWMAJOR 67172/*73* Minor version differences are always compatible74* a within a major version, however if user software is larger75* than driver software, some new features and/or structure fields76* may not be implemented; the user code must deal with this if it77* cares, or it must abort after initialization reports the difference.78*/79#define HFI1_USER_SWMINOR 38081/*82* We will encode the major/minor inside a single 32bit version number.83*/84#define HFI1_SWMAJOR_SHIFT 168586/*87* Set of HW and driver capability/feature bits.88* These bit values are used to configure enabled/disabled HW and89* driver features. The same set of bits are communicated to user90* space.91*/92#define HFI1_CAP_DMA_RTAIL (1UL << 0) /* Use DMA'ed RTail value */93#define HFI1_CAP_SDMA (1UL << 1) /* Enable SDMA support */94#define HFI1_CAP_SDMA_AHG (1UL << 2) /* Enable SDMA AHG support */95#define HFI1_CAP_EXTENDED_PSN (1UL << 3) /* Enable Extended PSN support */96#define HFI1_CAP_HDRSUPP (1UL << 4) /* Enable Header Suppression */97#define HFI1_CAP_TID_RDMA (1UL << 5) /* Enable TID RDMA operations */98#define HFI1_CAP_USE_SDMA_HEAD (1UL << 6) /* DMA Hdr Q tail vs. use CSR */99#define HFI1_CAP_MULTI_PKT_EGR (1UL << 7) /* Enable multi-packet Egr buffs*/100#define HFI1_CAP_NODROP_RHQ_FULL (1UL << 8) /* Don't drop on Hdr Q full */101#define HFI1_CAP_NODROP_EGR_FULL (1UL << 9) /* Don't drop on EGR buffs full */102#define HFI1_CAP_TID_UNMAP (1UL << 10) /* Disable Expected TID caching */103#define HFI1_CAP_PRINT_UNIMPL (1UL << 11) /* Show for unimplemented feats */104#define HFI1_CAP_ALLOW_PERM_JKEY (1UL << 12) /* Allow use of permissive JKEY */105#define HFI1_CAP_NO_INTEGRITY (1UL << 13) /* Enable ctxt integrity checks */106#define HFI1_CAP_PKEY_CHECK (1UL << 14) /* Enable ctxt PKey checking */107#define HFI1_CAP_STATIC_RATE_CTRL (1UL << 15) /* Allow PBC.StaticRateControl */108#define HFI1_CAP_OPFN (1UL << 16) /* Enable the OPFN protocol */109#define HFI1_CAP_SDMA_HEAD_CHECK (1UL << 17) /* SDMA head checking */110#define HFI1_CAP_EARLY_CREDIT_RETURN (1UL << 18) /* early credit return */111#define HFI1_CAP_AIP (1UL << 19) /* Enable accelerated IP */112113#define HFI1_RCVHDR_ENTSIZE_2 (1UL << 0)114#define HFI1_RCVHDR_ENTSIZE_16 (1UL << 1)115#define HFI1_RCVDHR_ENTSIZE_32 (1UL << 2)116117#define _HFI1_EVENT_FROZEN_BIT 0118#define _HFI1_EVENT_LINKDOWN_BIT 1119#define _HFI1_EVENT_LID_CHANGE_BIT 2120#define _HFI1_EVENT_LMC_CHANGE_BIT 3121#define _HFI1_EVENT_SL2VL_CHANGE_BIT 4122#define _HFI1_EVENT_TID_MMU_NOTIFY_BIT 5123#define _HFI1_MAX_EVENT_BIT _HFI1_EVENT_TID_MMU_NOTIFY_BIT124125#define HFI1_EVENT_FROZEN (1UL << _HFI1_EVENT_FROZEN_BIT)126#define HFI1_EVENT_LINKDOWN (1UL << _HFI1_EVENT_LINKDOWN_BIT)127#define HFI1_EVENT_LID_CHANGE (1UL << _HFI1_EVENT_LID_CHANGE_BIT)128#define HFI1_EVENT_LMC_CHANGE (1UL << _HFI1_EVENT_LMC_CHANGE_BIT)129#define HFI1_EVENT_SL2VL_CHANGE (1UL << _HFI1_EVENT_SL2VL_CHANGE_BIT)130#define HFI1_EVENT_TID_MMU_NOTIFY (1UL << _HFI1_EVENT_TID_MMU_NOTIFY_BIT)131132/*133* These are the status bits readable (in ASCII form, 64bit value)134* from the "status" sysfs file. For binary compatibility, values135* must remain as is; removed states can be reused for different136* purposes.137*/138#define HFI1_STATUS_INITTED 0x1 /* basic initialization done */139/* Chip has been found and initialized */140#define HFI1_STATUS_CHIP_PRESENT 0x20141/* IB link is at ACTIVE, usable for data traffic */142#define HFI1_STATUS_IB_READY 0x40143/* link is configured, LID, MTU, etc. have been set */144#define HFI1_STATUS_IB_CONF 0x80145/* A Fatal hardware error has occurred. */146#define HFI1_STATUS_HWERROR 0x200147148/*149* Number of supported shared contexts.150* This is the maximum number of software contexts that can share151* a hardware send/receive context.152*/153#define HFI1_MAX_SHARED_CTXTS 8154155/*156* Poll types157*/158#define HFI1_POLL_TYPE_ANYRCV 0x0159#define HFI1_POLL_TYPE_URGENT 0x1160161enum hfi1_sdma_comp_state {162FREE = 0,163QUEUED,164COMPLETE,165ERROR166};167168/*169* SDMA completion ring entry170*/171struct hfi1_sdma_comp_entry {172__u32 status;173__u32 errcode;174};175176/*177* Device status and notifications from driver to user-space.178*/179struct hfi1_status {180__aligned_u64 dev; /* device/hw status bits */181__aligned_u64 port; /* port state and status bits */182char freezemsg[];183};184185enum sdma_req_opcode {186EXPECTED = 0,187EAGER188};189190#define HFI1_SDMA_REQ_VERSION_MASK 0xF191#define HFI1_SDMA_REQ_VERSION_SHIFT 0x0192#define HFI1_SDMA_REQ_OPCODE_MASK 0xF193#define HFI1_SDMA_REQ_OPCODE_SHIFT 0x4194#define HFI1_SDMA_REQ_IOVCNT_MASK 0xFF195#define HFI1_SDMA_REQ_IOVCNT_SHIFT 0x8196197struct sdma_req_info {198/*199* bits 0-3 - version (currently unused)200* bits 4-7 - opcode (enum sdma_req_opcode)201* bits 8-15 - io vector count202*/203__u16 ctrl;204/*205* Number of fragments contained in this request.206* User-space has already computed how many207* fragment-sized packet the user buffer will be208* split into.209*/210__u16 npkts;211/*212* Size of each fragment the user buffer will be213* split into.214*/215__u16 fragsize;216/*217* Index of the slot in the SDMA completion ring218* this request should be using. User-space is219* in charge of managing its own ring.220*/221__u16 comp_idx;222} __attribute__((__packed__));223224/*225* SW KDETH header.226* swdata is SW defined portion.227*/228struct hfi1_kdeth_header {229__le32 ver_tid_offset;230__le16 jkey;231__le16 hcrc;232__le32 swdata[7];233} __attribute__((__packed__));234235/*236* Structure describing the headers that User space uses. The237* structure above is a subset of this one.238*/239struct hfi1_pkt_header {240__le16 pbc[4];241__be16 lrh[4];242__be32 bth[3];243struct hfi1_kdeth_header kdeth;244} __attribute__((__packed__));245246247/*248* The list of usermode accessible registers.249*/250enum hfi1_ureg {251/* (RO) DMA RcvHdr to be used next. */252ur_rcvhdrtail = 0,253/* (RW) RcvHdr entry to be processed next by host. */254ur_rcvhdrhead = 1,255/* (RO) Index of next Eager index to use. */256ur_rcvegrindextail = 2,257/* (RW) Eager TID to be processed next */258ur_rcvegrindexhead = 3,259/* (RO) Receive Eager Offset Tail */260ur_rcvegroffsettail = 4,261/* For internal use only; max register number. */262ur_maxreg,263/* (RW) Receive TID flow table */264ur_rcvtidflowtable = 256265};266267#endif /* _LINIUX__HFI1_USER_H */268269270