162306a36Sopenharmony_ci/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
562306a36Sopenharmony_ci * redistributing this file, you may do so under either license.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * GPL LICENSE SUMMARY
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Copyright(c) 2015 Intel Corporation.
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
1262306a36Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as
1362306a36Sopenharmony_ci * published by the Free Software Foundation.
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful, but
1662306a36Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
1762306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1862306a36Sopenharmony_ci * General Public License for more details.
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * BSD LICENSE
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci * Copyright(c) 2015 Intel Corporation.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
2562306a36Sopenharmony_ci * modification, are permitted provided that the following conditions
2662306a36Sopenharmony_ci * are met:
2762306a36Sopenharmony_ci *
2862306a36Sopenharmony_ci *  - Redistributions of source code must retain the above copyright
2962306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
3062306a36Sopenharmony_ci *  - Redistributions in binary form must reproduce the above copyright
3162306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
3262306a36Sopenharmony_ci *    the documentation and/or other materials provided with the
3362306a36Sopenharmony_ci *    distribution.
3462306a36Sopenharmony_ci *  - Neither the name of Intel Corporation nor the names of its
3562306a36Sopenharmony_ci *    contributors may be used to endorse or promote products derived
3662306a36Sopenharmony_ci *    from this software without specific prior written permission.
3762306a36Sopenharmony_ci *
3862306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3962306a36Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
4062306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
4162306a36Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4262306a36Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4362306a36Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
4462306a36Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
4562306a36Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
4662306a36Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
4762306a36Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4862306a36Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4962306a36Sopenharmony_ci *
5062306a36Sopenharmony_ci */
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#ifndef _LINUX__HFI1_IOCTL_H
5362306a36Sopenharmony_ci#define _LINUX__HFI1_IOCTL_H
5462306a36Sopenharmony_ci#include <linux/types.h>
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/*
5762306a36Sopenharmony_ci * This structure is passed to the driver to tell it where
5862306a36Sopenharmony_ci * user code buffers are, sizes, etc.   The offsets and sizes of the
5962306a36Sopenharmony_ci * fields must remain unchanged, for binary compatibility.  It can
6062306a36Sopenharmony_ci * be extended, if userversion is changed so user code can tell, if needed
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_cistruct hfi1_user_info {
6362306a36Sopenharmony_ci	/*
6462306a36Sopenharmony_ci	 * version of user software, to detect compatibility issues.
6562306a36Sopenharmony_ci	 * Should be set to HFI1_USER_SWVERSION.
6662306a36Sopenharmony_ci	 */
6762306a36Sopenharmony_ci	__u32 userversion;
6862306a36Sopenharmony_ci	__u32 pad;
6962306a36Sopenharmony_ci	/*
7062306a36Sopenharmony_ci	 * If two or more processes wish to share a context, each process
7162306a36Sopenharmony_ci	 * must set the subcontext_cnt and subcontext_id to the same
7262306a36Sopenharmony_ci	 * values.  The only restriction on the subcontext_id is that
7362306a36Sopenharmony_ci	 * it be unique for a given node.
7462306a36Sopenharmony_ci	 */
7562306a36Sopenharmony_ci	__u16 subctxt_cnt;
7662306a36Sopenharmony_ci	__u16 subctxt_id;
7762306a36Sopenharmony_ci	/* 128bit UUID passed in by PSM. */
7862306a36Sopenharmony_ci	__u8 uuid[16];
7962306a36Sopenharmony_ci};
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_cistruct hfi1_ctxt_info {
8262306a36Sopenharmony_ci	__aligned_u64 runtime_flags;    /* chip/drv runtime flags (HFI1_CAP_*) */
8362306a36Sopenharmony_ci	__u32 rcvegr_size;      /* size of each eager buffer */
8462306a36Sopenharmony_ci	__u16 num_active;       /* number of active units */
8562306a36Sopenharmony_ci	__u16 unit;             /* unit (chip) assigned to caller */
8662306a36Sopenharmony_ci	__u16 ctxt;             /* ctxt on unit assigned to caller */
8762306a36Sopenharmony_ci	__u16 subctxt;          /* subctxt on unit assigned to caller */
8862306a36Sopenharmony_ci	__u16 rcvtids;          /* number of Rcv TIDs for this context */
8962306a36Sopenharmony_ci	__u16 credits;          /* number of PIO credits for this context */
9062306a36Sopenharmony_ci	__u16 numa_node;        /* NUMA node of the assigned device */
9162306a36Sopenharmony_ci	__u16 rec_cpu;          /* cpu # for affinity (0xffff if none) */
9262306a36Sopenharmony_ci	__u16 send_ctxt;        /* send context in use by this user context */
9362306a36Sopenharmony_ci	__u16 egrtids;          /* number of RcvArray entries for Eager Rcvs */
9462306a36Sopenharmony_ci	__u16 rcvhdrq_cnt;      /* number of RcvHdrQ entries */
9562306a36Sopenharmony_ci	__u16 rcvhdrq_entsize;  /* size (in bytes) for each RcvHdrQ entry */
9662306a36Sopenharmony_ci	__u16 sdma_ring_size;   /* number of entries in SDMA request ring */
9762306a36Sopenharmony_ci};
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_cistruct hfi1_tid_info {
10062306a36Sopenharmony_ci	/* virtual address of first page in transfer */
10162306a36Sopenharmony_ci	__aligned_u64 vaddr;
10262306a36Sopenharmony_ci	/* pointer to tid array. this array is big enough */
10362306a36Sopenharmony_ci	__aligned_u64 tidlist;
10462306a36Sopenharmony_ci	/* number of tids programmed by this request */
10562306a36Sopenharmony_ci	__u32 tidcnt;
10662306a36Sopenharmony_ci	/* length of transfer buffer programmed by this request */
10762306a36Sopenharmony_ci	__u32 length;
10862306a36Sopenharmony_ci};
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci/*
11162306a36Sopenharmony_ci * This structure is returned by the driver immediately after
11262306a36Sopenharmony_ci * open to get implementation-specific info, and info specific to this
11362306a36Sopenharmony_ci * instance.
11462306a36Sopenharmony_ci *
11562306a36Sopenharmony_ci * This struct must have explicit pad fields where type sizes
11662306a36Sopenharmony_ci * may result in different alignments between 32 and 64 bit
11762306a36Sopenharmony_ci * programs, since the 64 bit * bit kernel requires the user code
11862306a36Sopenharmony_ci * to have matching offsets
11962306a36Sopenharmony_ci */
12062306a36Sopenharmony_cistruct hfi1_base_info {
12162306a36Sopenharmony_ci	/* version of hardware, for feature checking. */
12262306a36Sopenharmony_ci	__u32 hw_version;
12362306a36Sopenharmony_ci	/* version of software, for feature checking. */
12462306a36Sopenharmony_ci	__u32 sw_version;
12562306a36Sopenharmony_ci	/* Job key */
12662306a36Sopenharmony_ci	__u16 jkey;
12762306a36Sopenharmony_ci	__u16 padding1;
12862306a36Sopenharmony_ci	/*
12962306a36Sopenharmony_ci	 * The special QP (queue pair) value that identifies PSM
13062306a36Sopenharmony_ci	 * protocol packet from standard IB packets.
13162306a36Sopenharmony_ci	 */
13262306a36Sopenharmony_ci	__u32 bthqp;
13362306a36Sopenharmony_ci	/* PIO credit return address, */
13462306a36Sopenharmony_ci	__aligned_u64 sc_credits_addr;
13562306a36Sopenharmony_ci	/*
13662306a36Sopenharmony_ci	 * Base address of write-only pio buffers for this process.
13762306a36Sopenharmony_ci	 * Each buffer has sendpio_credits*64 bytes.
13862306a36Sopenharmony_ci	 */
13962306a36Sopenharmony_ci	__aligned_u64 pio_bufbase_sop;
14062306a36Sopenharmony_ci	/*
14162306a36Sopenharmony_ci	 * Base address of write-only pio buffers for this process.
14262306a36Sopenharmony_ci	 * Each buffer has sendpio_credits*64 bytes.
14362306a36Sopenharmony_ci	 */
14462306a36Sopenharmony_ci	__aligned_u64 pio_bufbase;
14562306a36Sopenharmony_ci	/* address where receive buffer queue is mapped into */
14662306a36Sopenharmony_ci	__aligned_u64 rcvhdr_bufbase;
14762306a36Sopenharmony_ci	/* base address of Eager receive buffers. */
14862306a36Sopenharmony_ci	__aligned_u64 rcvegr_bufbase;
14962306a36Sopenharmony_ci	/* base address of SDMA completion ring */
15062306a36Sopenharmony_ci	__aligned_u64 sdma_comp_bufbase;
15162306a36Sopenharmony_ci	/*
15262306a36Sopenharmony_ci	 * User register base for init code, not to be used directly by
15362306a36Sopenharmony_ci	 * protocol or applications.  Always maps real chip register space.
15462306a36Sopenharmony_ci	 * the register addresses are:
15562306a36Sopenharmony_ci	 * ur_rcvhdrhead, ur_rcvhdrtail, ur_rcvegrhead, ur_rcvegrtail,
15662306a36Sopenharmony_ci	 * ur_rcvtidflow
15762306a36Sopenharmony_ci	 */
15862306a36Sopenharmony_ci	__aligned_u64 user_regbase;
15962306a36Sopenharmony_ci	/* notification events */
16062306a36Sopenharmony_ci	__aligned_u64 events_bufbase;
16162306a36Sopenharmony_ci	/* status page */
16262306a36Sopenharmony_ci	__aligned_u64 status_bufbase;
16362306a36Sopenharmony_ci	/* rcvhdrtail update */
16462306a36Sopenharmony_ci	__aligned_u64 rcvhdrtail_base;
16562306a36Sopenharmony_ci	/*
16662306a36Sopenharmony_ci	 * shared memory pages for subctxts if ctxt is shared; these cover
16762306a36Sopenharmony_ci	 * all the processes in the group sharing a single context.
16862306a36Sopenharmony_ci	 * all have enough space for the num_subcontexts value on this job.
16962306a36Sopenharmony_ci	 */
17062306a36Sopenharmony_ci	__aligned_u64 subctxt_uregbase;
17162306a36Sopenharmony_ci	__aligned_u64 subctxt_rcvegrbuf;
17262306a36Sopenharmony_ci	__aligned_u64 subctxt_rcvhdrbuf;
17362306a36Sopenharmony_ci};
17462306a36Sopenharmony_ci#endif /* _LINIUX__HFI1_IOCTL_H */
175