125981136fb13bcacf5f475f3e0ec750341e1e671Christopher Ferris/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This file is provided under a dual BSD/GPLv2 license.  When using or
512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * redistributing this file, you may do so under either license.
612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * GPL LICENSE SUMMARY
812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Copyright(c) 2015 Intel Corporation.
1012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
1112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This program is free software; you can redistribute it and/or modify
1212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * it under the terms of version 2 of the GNU General Public License as
1312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * published by the Free Software Foundation.
1412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
1512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This program is distributed in the hope that it will be useful, but
1612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * WITHOUT ANY WARRANTY; without even the implied warranty of
1712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * General Public License for more details.
1912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
2012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * BSD LICENSE
2112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
2212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Copyright(c) 2015 Intel Corporation.
2312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
2412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Redistribution and use in source and binary forms, with or without
2512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * modification, are permitted provided that the following conditions
2612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * are met:
2712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
2812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *  - Redistributions of source code must retain the above copyright
2912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *    notice, this list of conditions and the following disclaimer.
3012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *  - Redistributions in binary form must reproduce the above copyright
3112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *    notice, this list of conditions and the following disclaimer in
3212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *    the documentation and/or other materials provided with the
3312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *    distribution.
3412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *  - Neither the name of Intel Corporation nor the names of its
3512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *    contributors may be used to endorse or promote products derived
3612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *    from this software without specific prior written permission.
3712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
3812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
5012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
5112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
5212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
5312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This file contains defines, structures, etc. that are used
5412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * to communicate between kernel and user code.
5512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
5612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
5712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#ifndef _LINUX__HFI1_USER_H
5812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define _LINUX__HFI1_USER_H
5912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
6012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#include <linux/types.h>
610543f743b6f5bc5c0652568c763e6dfb9ddce647Christopher Ferris#include <rdma/rdma_user_ioctl.h>
6212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
6312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
6412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This version number is given to the driver by the user code during
6512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * initialization in the spu_userversion field of hfi1_user_info, so
6612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * the driver can check for compatibility with user code.
6712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris *
6812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * The major version changes when data structures change in an incompatible
6912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * way. The driver must be the same for initialization to succeed.
7012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
71ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_USER_SWMAJOR 6
7212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
7312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
7412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Minor version differences are always compatible
7512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * a within a major version, however if user software is larger
7612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * than driver software, some new features and/or structure fields
7712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * may not be implemented; the user code must deal with this if it
7812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * cares, or it must abort after initialization reports the difference.
7912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
802fd4b3cf888b560db61afa9e50dd42039e07a8b2Christopher Ferris#define HFI1_USER_SWMINOR 3
81ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris
82ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris/*
83ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris * We will encode the major/minor inside a single 32bit version number.
84ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris */
85ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_SWMAJOR_SHIFT 16
8612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
8712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
8812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Set of HW and driver capability/feature bits.
8912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * These bit values are used to configure enabled/disabled HW and
9012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * driver features. The same set of bits are communicated to user
9112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * space.
9212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
9312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_DMA_RTAIL        (1UL <<  0) /* Use DMA'ed RTail value */
9412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_SDMA             (1UL <<  1) /* Enable SDMA support */
9512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_SDMA_AHG         (1UL <<  2) /* Enable SDMA AHG support */
9612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_EXTENDED_PSN     (1UL <<  3) /* Enable Extended PSN support */
9712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_HDRSUPP          (1UL <<  4) /* Enable Header Suppression */
9812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* 1UL << 5 unused */
9912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_USE_SDMA_HEAD    (1UL <<  6) /* DMA Hdr Q tail vs. use CSR */
10012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_MULTI_PKT_EGR    (1UL <<  7) /* Enable multi-packet Egr buffs*/
10112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_NODROP_RHQ_FULL  (1UL <<  8) /* Don't drop on Hdr Q full */
10212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_NODROP_EGR_FULL  (1UL <<  9) /* Don't drop on EGR buffs full */
103ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_CAP_TID_UNMAP        (1UL << 10) /* Disable Expected TID caching */
10412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_PRINT_UNIMPL     (1UL << 11) /* Show for unimplemented feats */
10512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_ALLOW_PERM_JKEY  (1UL << 12) /* Allow use of permissive JKEY */
10612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_NO_INTEGRITY     (1UL << 13) /* Enable ctxt integrity checks */
10712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_PKEY_CHECK       (1UL << 14) /* Enable ctxt PKey checking */
10812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_STATIC_RATE_CTRL (1UL << 15) /* Allow PBC.StaticRateControl */
10912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* 1UL << 16 unused */
11012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_SDMA_HEAD_CHECK  (1UL << 17) /* SDMA head checking */
11112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_CAP_EARLY_CREDIT_RETURN (1UL << 18) /* early credit return */
11212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
11312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_RCVHDR_ENTSIZE_2    (1UL << 0)
11412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_RCVHDR_ENTSIZE_16   (1UL << 1)
11512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_RCVDHR_ENTSIZE_32   (1UL << 2)
11612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
117ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define _HFI1_EVENT_FROZEN_BIT         0
118ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define _HFI1_EVENT_LINKDOWN_BIT       1
119ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define _HFI1_EVENT_LID_CHANGE_BIT     2
120ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define _HFI1_EVENT_LMC_CHANGE_BIT     3
121ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define _HFI1_EVENT_SL2VL_CHANGE_BIT   4
122ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define _HFI1_EVENT_TID_MMU_NOTIFY_BIT 5
123ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define _HFI1_MAX_EVENT_BIT _HFI1_EVENT_TID_MMU_NOTIFY_BIT
12412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
125ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_EVENT_FROZEN            (1UL << _HFI1_EVENT_FROZEN_BIT)
126ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_EVENT_LINKDOWN          (1UL << _HFI1_EVENT_LINKDOWN_BIT)
127ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_EVENT_LID_CHANGE        (1UL << _HFI1_EVENT_LID_CHANGE_BIT)
128ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_EVENT_LMC_CHANGE        (1UL << _HFI1_EVENT_LMC_CHANGE_BIT)
129ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_EVENT_SL2VL_CHANGE      (1UL << _HFI1_EVENT_SL2VL_CHANGE_BIT)
130ccfaccd726a369b7df72e251710755233d176e5aChristopher Ferris#define HFI1_EVENT_TID_MMU_NOTIFY    (1UL << _HFI1_EVENT_TID_MMU_NOTIFY_BIT)
13112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
13212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
13312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * These are the status bits readable (in ASCII form, 64bit value)
13412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * from the "status" sysfs file.  For binary compatibility, values
13512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * must remain as is; removed states can be reused for different
13612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * purposes.
13712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
13812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_STATUS_INITTED       0x1    /* basic initialization done */
13912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* Chip has been found and initialized */
14012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_STATUS_CHIP_PRESENT 0x20
14112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* IB link is at ACTIVE, usable for data traffic */
14212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_STATUS_IB_READY     0x40
14312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* link is configured, LID, MTU, etc. have been set */
14412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_STATUS_IB_CONF      0x80
14512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/* A Fatal hardware error has occurred. */
14612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_STATUS_HWERROR     0x200
14712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
14812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
14912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Number of supported shared contexts.
15012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * This is the maximum number of software contexts that can share
15112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * a hardware send/receive context.
15212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
15312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_MAX_SHARED_CTXTS 8
15412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
15512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
15612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Poll types
15712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
15812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_POLL_TYPE_ANYRCV     0x0
15912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_POLL_TYPE_URGENT     0x1
16012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
16112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisenum hfi1_sdma_comp_state {
16212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	FREE = 0,
16312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	QUEUED,
16412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	COMPLETE,
16512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ERROR
16612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
16712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
16812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
16912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * SDMA completion ring entry
17012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
17112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct hfi1_sdma_comp_entry {
17212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 status;
17312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u32 errcode;
17412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
17512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
17612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
17712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Device status and notifications from driver to user-space.
17812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
17912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct hfi1_status {
18012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u64 dev;      /* device/hw status bits */
18112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u64 port;     /* port state and status bits */
18212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	char freezemsg[0];
18312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
18412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
18512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisenum sdma_req_opcode {
18612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	EXPECTED = 0,
18712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	EAGER
18812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
18912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
19012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_SDMA_REQ_VERSION_MASK 0xF
19112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_SDMA_REQ_VERSION_SHIFT 0x0
19212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_SDMA_REQ_OPCODE_MASK 0xF
19312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_SDMA_REQ_OPCODE_SHIFT 0x4
19412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_SDMA_REQ_IOVCNT_MASK 0xFF
19512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#define HFI1_SDMA_REQ_IOVCNT_SHIFT 0x8
19612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
19712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct sdma_req_info {
19812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/*
19912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * bits 0-3 - version (currently unused)
20012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * bits 4-7 - opcode (enum sdma_req_opcode)
20112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * bits 8-15 - io vector count
20212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 */
20312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u16 ctrl;
20412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/*
20512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * Number of fragments contained in this request.
20612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * User-space has already computed how many
20712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * fragment-sized packet the user buffer will be
20812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * split into.
20912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 */
21012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u16 npkts;
21112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/*
21212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * Size of each fragment the user buffer will be
21312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * split into.
21412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 */
21512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u16 fragsize;
21612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/*
21712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * Index of the slot in the SDMA completion ring
21812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * this request should be using. User-space is
21912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 * in charge of managing its own ring.
22012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	 */
22112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__u16 comp_idx;
22212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris} __packed;
22312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
22412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
22512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * SW KDETH header.
22612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * swdata is SW defined portion.
22712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
22812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct hfi1_kdeth_header {
22912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__le32 ver_tid_offset;
23012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__le16 jkey;
23112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__le16 hcrc;
23212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__le32 swdata[7];
23312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris} __packed;
23412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
23512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
23612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * Structure describing the headers that User space uses. The
23712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * structure above is a subset of this one.
23812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
23912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisstruct hfi1_pkt_header {
24012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__le16 pbc[4];
24112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__be16 lrh[4];
24212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	__be32 bth[3];
24312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	struct hfi1_kdeth_header kdeth;
24412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris} __packed;
24512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
24612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
24712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris/*
24812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris * The list of usermode accessible registers.
24912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris */
25012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferrisenum hfi1_ureg {
25112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* (RO)  DMA RcvHdr to be used next. */
25212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ur_rcvhdrtail = 0,
25312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* (RW)  RcvHdr entry to be processed next by host. */
25412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ur_rcvhdrhead = 1,
25512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* (RO)  Index of next Eager index to use. */
25612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ur_rcvegrindextail = 2,
25712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* (RW)  Eager TID to be processed next */
25812e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ur_rcvegrindexhead = 3,
25912e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* (RO)  Receive Eager Offset Tail */
26012e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ur_rcvegroffsettail = 4,
26112e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* For internal use only; max register number. */
26212e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ur_maxreg,
26312e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	/* (RW)  Receive TID flow table */
26412e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris	ur_rcvtidflowtable = 256
26512e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris};
26612e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris
26712e1f28cce28271eb109a5bae818a804f0c3bb27Christopher Ferris#endif /* _LINIUX__HFI1_USER_H */
268