18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
38c2ecf20Sopenharmony_ci * All rights reserved.
48c2ecf20Sopenharmony_ci * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
78c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
138c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
148c2ecf20Sopenharmony_ci *     conditions are met:
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
178c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
188c2ecf20Sopenharmony_ci *        disclaimer.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
218c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
228c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
238c2ecf20Sopenharmony_ci *        provided with the distribution.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
328c2ecf20Sopenharmony_ci * SOFTWARE.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifndef _QIB_COMMON_H
368c2ecf20Sopenharmony_ci#define _QIB_COMMON_H
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/*
398c2ecf20Sopenharmony_ci * This file contains defines, structures, etc. that are used
408c2ecf20Sopenharmony_ci * to communicate between kernel and user code.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* This is the IEEE-assigned OUI for QLogic Inc. QLogic_IB */
448c2ecf20Sopenharmony_ci#define QIB_SRC_OUI_1 0x00
458c2ecf20Sopenharmony_ci#define QIB_SRC_OUI_2 0x11
468c2ecf20Sopenharmony_ci#define QIB_SRC_OUI_3 0x75
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* version of protocol header (known to chip also). In the long run,
498c2ecf20Sopenharmony_ci * we should be able to generate and accept a range of version numbers;
508c2ecf20Sopenharmony_ci * for now we only accept one, and it's compiled in.
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci#define IPS_PROTO_VERSION 2
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/*
558c2ecf20Sopenharmony_ci * These are compile time constants that you may want to enable or disable
568c2ecf20Sopenharmony_ci * if you are trying to debug problems with code or performance.
578c2ecf20Sopenharmony_ci * QIB_VERBOSE_TRACING define as 1 if you want additional tracing in
588c2ecf20Sopenharmony_ci * fastpath code
598c2ecf20Sopenharmony_ci * QIB_TRACE_REGWRITES define as 1 if you want register writes to be
608c2ecf20Sopenharmony_ci * traced in fastpath code
618c2ecf20Sopenharmony_ci * _QIB_TRACING define as 0 if you want to remove all tracing in a
628c2ecf20Sopenharmony_ci * compilation unit
638c2ecf20Sopenharmony_ci */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/*
668c2ecf20Sopenharmony_ci * The value in the BTH QP field that QLogic_IB uses to differentiate
678c2ecf20Sopenharmony_ci * an qlogic_ib protocol IB packet vs standard IB transport
688c2ecf20Sopenharmony_ci * This it needs to be even (0x656b78), because the LSB is sometimes
698c2ecf20Sopenharmony_ci * used for the MSB of context. The change may cause a problem
708c2ecf20Sopenharmony_ci * interoperating with older software.
718c2ecf20Sopenharmony_ci */
728c2ecf20Sopenharmony_ci#define QIB_KD_QP 0x656b78
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/*
758c2ecf20Sopenharmony_ci * These are the status bits readable (in ascii form, 64bit value)
768c2ecf20Sopenharmony_ci * from the "status" sysfs file.  For binary compatibility, values
778c2ecf20Sopenharmony_ci * must remain as is; removed states can be reused for different
788c2ecf20Sopenharmony_ci * purposes.
798c2ecf20Sopenharmony_ci */
808c2ecf20Sopenharmony_ci#define QIB_STATUS_INITTED       0x1    /* basic initialization done */
818c2ecf20Sopenharmony_ci/* Chip has been found and initted */
828c2ecf20Sopenharmony_ci#define QIB_STATUS_CHIP_PRESENT 0x20
838c2ecf20Sopenharmony_ci/* IB link is at ACTIVE, usable for data traffic */
848c2ecf20Sopenharmony_ci#define QIB_STATUS_IB_READY     0x40
858c2ecf20Sopenharmony_ci/* link is configured, LID, MTU, etc. have been set */
868c2ecf20Sopenharmony_ci#define QIB_STATUS_IB_CONF      0x80
878c2ecf20Sopenharmony_ci/* A Fatal hardware error has occurred. */
888c2ecf20Sopenharmony_ci#define QIB_STATUS_HWERROR     0x200
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/*
918c2ecf20Sopenharmony_ci * The list of usermode accessible registers.  Also see Reg_* later in file.
928c2ecf20Sopenharmony_ci */
938c2ecf20Sopenharmony_cienum qib_ureg {
948c2ecf20Sopenharmony_ci	/* (RO)  DMA RcvHdr to be used next. */
958c2ecf20Sopenharmony_ci	ur_rcvhdrtail = 0,
968c2ecf20Sopenharmony_ci	/* (RW)  RcvHdr entry to be processed next by host. */
978c2ecf20Sopenharmony_ci	ur_rcvhdrhead = 1,
988c2ecf20Sopenharmony_ci	/* (RO)  Index of next Eager index to use. */
998c2ecf20Sopenharmony_ci	ur_rcvegrindextail = 2,
1008c2ecf20Sopenharmony_ci	/* (RW)  Eager TID to be processed next */
1018c2ecf20Sopenharmony_ci	ur_rcvegrindexhead = 3,
1028c2ecf20Sopenharmony_ci	/* For internal use only; max register number. */
1038c2ecf20Sopenharmony_ci	_QIB_UregMax
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* bit values for spi_runtime_flags */
1078c2ecf20Sopenharmony_ci#define QIB_RUNTIME_PCIE                0x0002
1088c2ecf20Sopenharmony_ci#define QIB_RUNTIME_FORCE_WC_ORDER      0x0004
1098c2ecf20Sopenharmony_ci#define QIB_RUNTIME_RCVHDR_COPY         0x0008
1108c2ecf20Sopenharmony_ci#define QIB_RUNTIME_MASTER              0x0010
1118c2ecf20Sopenharmony_ci#define QIB_RUNTIME_RCHK                0x0020
1128c2ecf20Sopenharmony_ci#define QIB_RUNTIME_NODMA_RTAIL         0x0080
1138c2ecf20Sopenharmony_ci#define QIB_RUNTIME_SPECIAL_TRIGGER     0x0100
1148c2ecf20Sopenharmony_ci#define QIB_RUNTIME_SDMA                0x0200
1158c2ecf20Sopenharmony_ci#define QIB_RUNTIME_FORCE_PIOAVAIL      0x0400
1168c2ecf20Sopenharmony_ci#define QIB_RUNTIME_PIO_REGSWAPPED      0x0800
1178c2ecf20Sopenharmony_ci#define QIB_RUNTIME_CTXT_MSB_IN_QP      0x1000
1188c2ecf20Sopenharmony_ci#define QIB_RUNTIME_CTXT_REDIRECT       0x2000
1198c2ecf20Sopenharmony_ci#define QIB_RUNTIME_HDRSUPP             0x4000
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/*
1228c2ecf20Sopenharmony_ci * This structure is returned by qib_userinit() immediately after
1238c2ecf20Sopenharmony_ci * open to get implementation-specific info, and info specific to this
1248c2ecf20Sopenharmony_ci * instance.
1258c2ecf20Sopenharmony_ci *
1268c2ecf20Sopenharmony_ci * This struct must have explict pad fields where type sizes
1278c2ecf20Sopenharmony_ci * may result in different alignments between 32 and 64 bit
1288c2ecf20Sopenharmony_ci * programs, since the 64 bit * bit kernel requires the user code
1298c2ecf20Sopenharmony_ci * to have matching offsets
1308c2ecf20Sopenharmony_ci */
1318c2ecf20Sopenharmony_cistruct qib_base_info {
1328c2ecf20Sopenharmony_ci	/* version of hardware, for feature checking. */
1338c2ecf20Sopenharmony_ci	__u32 spi_hw_version;
1348c2ecf20Sopenharmony_ci	/* version of software, for feature checking. */
1358c2ecf20Sopenharmony_ci	__u32 spi_sw_version;
1368c2ecf20Sopenharmony_ci	/* QLogic_IB context assigned, goes into sent packets */
1378c2ecf20Sopenharmony_ci	__u16 spi_ctxt;
1388c2ecf20Sopenharmony_ci	__u16 spi_subctxt;
1398c2ecf20Sopenharmony_ci	/*
1408c2ecf20Sopenharmony_ci	 * IB MTU, packets IB data must be less than this.
1418c2ecf20Sopenharmony_ci	 * The MTU is in bytes, and will be a multiple of 4 bytes.
1428c2ecf20Sopenharmony_ci	 */
1438c2ecf20Sopenharmony_ci	__u32 spi_mtu;
1448c2ecf20Sopenharmony_ci	/*
1458c2ecf20Sopenharmony_ci	 * Size of a PIO buffer.  Any given packet's total size must be less
1468c2ecf20Sopenharmony_ci	 * than this (in words).  Included is the starting control word, so
1478c2ecf20Sopenharmony_ci	 * if 513 is returned, then total pkt size is 512 words or less.
1488c2ecf20Sopenharmony_ci	 */
1498c2ecf20Sopenharmony_ci	__u32 spi_piosize;
1508c2ecf20Sopenharmony_ci	/* size of the TID cache in qlogic_ib, in entries */
1518c2ecf20Sopenharmony_ci	__u32 spi_tidcnt;
1528c2ecf20Sopenharmony_ci	/* size of the TID Eager list in qlogic_ib, in entries */
1538c2ecf20Sopenharmony_ci	__u32 spi_tidegrcnt;
1548c2ecf20Sopenharmony_ci	/* size of a single receive header queue entry in words. */
1558c2ecf20Sopenharmony_ci	__u32 spi_rcvhdrent_size;
1568c2ecf20Sopenharmony_ci	/*
1578c2ecf20Sopenharmony_ci	 * Count of receive header queue entries allocated.
1588c2ecf20Sopenharmony_ci	 * This may be less than the spu_rcvhdrcnt passed in!.
1598c2ecf20Sopenharmony_ci	 */
1608c2ecf20Sopenharmony_ci	__u32 spi_rcvhdr_cnt;
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	/* per-chip and other runtime features bitmap (QIB_RUNTIME_*) */
1638c2ecf20Sopenharmony_ci	__u32 spi_runtime_flags;
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci	/* address where hardware receive header queue is mapped */
1668c2ecf20Sopenharmony_ci	__u64 spi_rcvhdr_base;
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci	/* user program. */
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	/* base address of eager TID receive buffers used by hardware. */
1718c2ecf20Sopenharmony_ci	__u64 spi_rcv_egrbufs;
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	/* Allocated by initialization code, not by protocol. */
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci	/*
1768c2ecf20Sopenharmony_ci	 * Size of each TID buffer in host memory, starting at
1778c2ecf20Sopenharmony_ci	 * spi_rcv_egrbufs.  The buffers are virtually contiguous.
1788c2ecf20Sopenharmony_ci	 */
1798c2ecf20Sopenharmony_ci	__u32 spi_rcv_egrbufsize;
1808c2ecf20Sopenharmony_ci	/*
1818c2ecf20Sopenharmony_ci	 * The special QP (queue pair) value that identifies an qlogic_ib
1828c2ecf20Sopenharmony_ci	 * protocol packet from standard IB packets.  More, probably much
1838c2ecf20Sopenharmony_ci	 * more, to be added.
1848c2ecf20Sopenharmony_ci	 */
1858c2ecf20Sopenharmony_ci	__u32 spi_qpair;
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	/*
1888c2ecf20Sopenharmony_ci	 * User register base for init code, not to be used directly by
1898c2ecf20Sopenharmony_ci	 * protocol or applications.  Always points to chip registers,
1908c2ecf20Sopenharmony_ci	 * for normal or shared context.
1918c2ecf20Sopenharmony_ci	 */
1928c2ecf20Sopenharmony_ci	__u64 spi_uregbase;
1938c2ecf20Sopenharmony_ci	/*
1948c2ecf20Sopenharmony_ci	 * Maximum buffer size in bytes that can be used in a single TID
1958c2ecf20Sopenharmony_ci	 * entry (assuming the buffer is aligned to this boundary).  This is
1968c2ecf20Sopenharmony_ci	 * the minimum of what the hardware and software support Guaranteed
1978c2ecf20Sopenharmony_ci	 * to be a power of 2.
1988c2ecf20Sopenharmony_ci	 */
1998c2ecf20Sopenharmony_ci	__u32 spi_tid_maxsize;
2008c2ecf20Sopenharmony_ci	/*
2018c2ecf20Sopenharmony_ci	 * alignment of each pio send buffer (byte count
2028c2ecf20Sopenharmony_ci	 * to add to spi_piobufbase to get to second buffer)
2038c2ecf20Sopenharmony_ci	 */
2048c2ecf20Sopenharmony_ci	__u32 spi_pioalign;
2058c2ecf20Sopenharmony_ci	/*
2068c2ecf20Sopenharmony_ci	 * The index of the first pio buffer available to this process;
2078c2ecf20Sopenharmony_ci	 * needed to do lookup in spi_pioavailaddr; not added to
2088c2ecf20Sopenharmony_ci	 * spi_piobufbase.
2098c2ecf20Sopenharmony_ci	 */
2108c2ecf20Sopenharmony_ci	__u32 spi_pioindex;
2118c2ecf20Sopenharmony_ci	 /* number of buffers mapped for this process */
2128c2ecf20Sopenharmony_ci	__u32 spi_piocnt;
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	/*
2158c2ecf20Sopenharmony_ci	 * Base address of writeonly pio buffers for this process.
2168c2ecf20Sopenharmony_ci	 * Each buffer has spi_piosize words, and is aligned on spi_pioalign
2178c2ecf20Sopenharmony_ci	 * boundaries.  spi_piocnt buffers are mapped from this address
2188c2ecf20Sopenharmony_ci	 */
2198c2ecf20Sopenharmony_ci	__u64 spi_piobufbase;
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	/*
2228c2ecf20Sopenharmony_ci	 * Base address of readonly memory copy of the pioavail registers.
2238c2ecf20Sopenharmony_ci	 * There are 2 bits for each buffer.
2248c2ecf20Sopenharmony_ci	 */
2258c2ecf20Sopenharmony_ci	__u64 spi_pioavailaddr;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	/*
2288c2ecf20Sopenharmony_ci	 * Address where driver updates a copy of the interface and driver
2298c2ecf20Sopenharmony_ci	 * status (QIB_STATUS_*) as a 64 bit value.  It's followed by a
2308c2ecf20Sopenharmony_ci	 * link status qword (formerly combined with driver status), then a
2318c2ecf20Sopenharmony_ci	 * string indicating hardware error, if there was one.
2328c2ecf20Sopenharmony_ci	 */
2338c2ecf20Sopenharmony_ci	__u64 spi_status;
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci	/* number of chip ctxts available to user processes */
2368c2ecf20Sopenharmony_ci	__u32 spi_nctxts;
2378c2ecf20Sopenharmony_ci	__u16 spi_unit; /* unit number of chip we are using */
2388c2ecf20Sopenharmony_ci	__u16 spi_port; /* IB port number we are using */
2398c2ecf20Sopenharmony_ci	/* num bufs in each contiguous set */
2408c2ecf20Sopenharmony_ci	__u32 spi_rcv_egrperchunk;
2418c2ecf20Sopenharmony_ci	/* size in bytes of each contiguous set */
2428c2ecf20Sopenharmony_ci	__u32 spi_rcv_egrchunksize;
2438c2ecf20Sopenharmony_ci	/* total size of mmap to cover full rcvegrbuffers */
2448c2ecf20Sopenharmony_ci	__u32 spi_rcv_egrbuftotlen;
2458c2ecf20Sopenharmony_ci	__u32 spi_rhf_offset; /* dword offset in hdrqent for rcvhdr flags */
2468c2ecf20Sopenharmony_ci	/* address of readonly memory copy of the rcvhdrq tail register. */
2478c2ecf20Sopenharmony_ci	__u64 spi_rcvhdr_tailaddr;
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci	/*
2508c2ecf20Sopenharmony_ci	 * shared memory pages for subctxts if ctxt is shared; these cover
2518c2ecf20Sopenharmony_ci	 * all the processes in the group sharing a single context.
2528c2ecf20Sopenharmony_ci	 * all have enough space for the num_subcontexts value on this job.
2538c2ecf20Sopenharmony_ci	 */
2548c2ecf20Sopenharmony_ci	__u64 spi_subctxt_uregbase;
2558c2ecf20Sopenharmony_ci	__u64 spi_subctxt_rcvegrbuf;
2568c2ecf20Sopenharmony_ci	__u64 spi_subctxt_rcvhdr_base;
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci	/* shared memory page for send buffer disarm status */
2598c2ecf20Sopenharmony_ci	__u64 spi_sendbuf_status;
2608c2ecf20Sopenharmony_ci} __aligned(8);
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci/*
2638c2ecf20Sopenharmony_ci * This version number is given to the driver by the user code during
2648c2ecf20Sopenharmony_ci * initialization in the spu_userversion field of qib_user_info, so
2658c2ecf20Sopenharmony_ci * the driver can check for compatibility with user code.
2668c2ecf20Sopenharmony_ci *
2678c2ecf20Sopenharmony_ci * The major version changes when data structures
2688c2ecf20Sopenharmony_ci * change in an incompatible way.  The driver must be the same or higher
2698c2ecf20Sopenharmony_ci * for initialization to succeed.  In some cases, a higher version
2708c2ecf20Sopenharmony_ci * driver will not interoperate with older software, and initialization
2718c2ecf20Sopenharmony_ci * will return an error.
2728c2ecf20Sopenharmony_ci */
2738c2ecf20Sopenharmony_ci#define QIB_USER_SWMAJOR 1
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci/*
2768c2ecf20Sopenharmony_ci * Minor version differences are always compatible
2778c2ecf20Sopenharmony_ci * a within a major version, however if user software is larger
2788c2ecf20Sopenharmony_ci * than driver software, some new features and/or structure fields
2798c2ecf20Sopenharmony_ci * may not be implemented; the user code must deal with this if it
2808c2ecf20Sopenharmony_ci * cares, or it must abort after initialization reports the difference.
2818c2ecf20Sopenharmony_ci */
2828c2ecf20Sopenharmony_ci#define QIB_USER_SWMINOR 13
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci#define QIB_USER_SWVERSION ((QIB_USER_SWMAJOR << 16) | QIB_USER_SWMINOR)
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci#ifndef QIB_KERN_TYPE
2878c2ecf20Sopenharmony_ci#define QIB_KERN_TYPE 0
2888c2ecf20Sopenharmony_ci#endif
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci/*
2918c2ecf20Sopenharmony_ci * Similarly, this is the kernel version going back to the user.  It's
2928c2ecf20Sopenharmony_ci * slightly different, in that we want to tell if the driver was built as
2938c2ecf20Sopenharmony_ci * part of a QLogic release, or from the driver from openfabrics.org,
2948c2ecf20Sopenharmony_ci * kernel.org, or a standard distribution, for support reasons.
2958c2ecf20Sopenharmony_ci * The high bit is 0 for non-QLogic and 1 for QLogic-built/supplied.
2968c2ecf20Sopenharmony_ci *
2978c2ecf20Sopenharmony_ci * It's returned by the driver to the user code during initialization in the
2988c2ecf20Sopenharmony_ci * spi_sw_version field of qib_base_info, so the user code can in turn
2998c2ecf20Sopenharmony_ci * check for compatibility with the kernel.
3008c2ecf20Sopenharmony_ci*/
3018c2ecf20Sopenharmony_ci#define QIB_KERN_SWVERSION ((QIB_KERN_TYPE << 31) | QIB_USER_SWVERSION)
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci/*
3048c2ecf20Sopenharmony_ci * Define the driver version number.  This is something that refers only
3058c2ecf20Sopenharmony_ci * to the driver itself, not the software interfaces it supports.
3068c2ecf20Sopenharmony_ci */
3078c2ecf20Sopenharmony_ci#define QIB_DRIVER_VERSION_BASE "1.11"
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci/* create the final driver version string */
3108c2ecf20Sopenharmony_ci#ifdef QIB_IDSTR
3118c2ecf20Sopenharmony_ci#define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE " " QIB_IDSTR
3128c2ecf20Sopenharmony_ci#else
3138c2ecf20Sopenharmony_ci#define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE
3148c2ecf20Sopenharmony_ci#endif
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci/*
3178c2ecf20Sopenharmony_ci * If the unit is specified via open, HCA choice is fixed.  If port is
3188c2ecf20Sopenharmony_ci * specified, it's also fixed.  Otherwise we try to spread contexts
3198c2ecf20Sopenharmony_ci * across ports and HCAs, using different algorithims.  WITHIN is
3208c2ecf20Sopenharmony_ci * the old default, prior to this mechanism.
3218c2ecf20Sopenharmony_ci */
3228c2ecf20Sopenharmony_ci#define QIB_PORT_ALG_ACROSS 0 /* round robin contexts across HCAs, then
3238c2ecf20Sopenharmony_ci			       * ports; this is the default */
3248c2ecf20Sopenharmony_ci#define QIB_PORT_ALG_WITHIN 1 /* use all contexts on an HCA (round robin
3258c2ecf20Sopenharmony_ci			       * active ports within), then next HCA */
3268c2ecf20Sopenharmony_ci#define QIB_PORT_ALG_COUNT 2 /* number of algorithm choices */
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci/*
3298c2ecf20Sopenharmony_ci * This structure is passed to qib_userinit() to tell the driver where
3308c2ecf20Sopenharmony_ci * user code buffers are, sizes, etc.   The offsets and sizes of the
3318c2ecf20Sopenharmony_ci * fields must remain unchanged, for binary compatibility.  It can
3328c2ecf20Sopenharmony_ci * be extended, if userversion is changed so user code can tell, if needed
3338c2ecf20Sopenharmony_ci */
3348c2ecf20Sopenharmony_cistruct qib_user_info {
3358c2ecf20Sopenharmony_ci	/*
3368c2ecf20Sopenharmony_ci	 * version of user software, to detect compatibility issues.
3378c2ecf20Sopenharmony_ci	 * Should be set to QIB_USER_SWVERSION.
3388c2ecf20Sopenharmony_ci	 */
3398c2ecf20Sopenharmony_ci	__u32 spu_userversion;
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci	__u32 _spu_unused2;
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	/* size of struct base_info to write to */
3448c2ecf20Sopenharmony_ci	__u32 spu_base_info_size;
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ci	__u32 spu_port_alg; /* which QIB_PORT_ALG_*; unused user minor < 11 */
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci	/*
3498c2ecf20Sopenharmony_ci	 * If two or more processes wish to share a context, each process
3508c2ecf20Sopenharmony_ci	 * must set the spu_subctxt_cnt and spu_subctxt_id to the same
3518c2ecf20Sopenharmony_ci	 * values.  The only restriction on the spu_subctxt_id is that
3528c2ecf20Sopenharmony_ci	 * it be unique for a given node.
3538c2ecf20Sopenharmony_ci	 */
3548c2ecf20Sopenharmony_ci	__u16 spu_subctxt_cnt;
3558c2ecf20Sopenharmony_ci	__u16 spu_subctxt_id;
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci	__u32 spu_port; /* IB port requested by user if > 0 */
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci	/*
3608c2ecf20Sopenharmony_ci	 * address of struct base_info to write to
3618c2ecf20Sopenharmony_ci	 */
3628c2ecf20Sopenharmony_ci	__u64 spu_base_info;
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci} __aligned(8);
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ci/* User commands. */
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci/* 16 available, was: old set up userspace (for old user code) */
3698c2ecf20Sopenharmony_ci#define QIB_CMD_CTXT_INFO       17      /* find out what resources we got */
3708c2ecf20Sopenharmony_ci#define QIB_CMD_RECV_CTRL       18      /* control receipt of packets */
3718c2ecf20Sopenharmony_ci#define QIB_CMD_TID_UPDATE      19      /* update expected TID entries */
3728c2ecf20Sopenharmony_ci#define QIB_CMD_TID_FREE        20      /* free expected TID entries */
3738c2ecf20Sopenharmony_ci#define QIB_CMD_SET_PART_KEY    21      /* add partition key */
3748c2ecf20Sopenharmony_ci/* 22 available, was: return info on slave processes (for old user code) */
3758c2ecf20Sopenharmony_ci#define QIB_CMD_ASSIGN_CTXT     23      /* allocate HCA and ctxt */
3768c2ecf20Sopenharmony_ci#define QIB_CMD_USER_INIT       24      /* set up userspace */
3778c2ecf20Sopenharmony_ci#define QIB_CMD_UNUSED_1        25
3788c2ecf20Sopenharmony_ci#define QIB_CMD_UNUSED_2        26
3798c2ecf20Sopenharmony_ci#define QIB_CMD_PIOAVAILUPD     27      /* force an update of PIOAvail reg */
3808c2ecf20Sopenharmony_ci#define QIB_CMD_POLL_TYPE       28      /* set the kind of polling we want */
3818c2ecf20Sopenharmony_ci#define QIB_CMD_ARMLAUNCH_CTRL  29      /* armlaunch detection control */
3828c2ecf20Sopenharmony_ci/* 30 is unused */
3838c2ecf20Sopenharmony_ci#define QIB_CMD_SDMA_INFLIGHT   31      /* sdma inflight counter request */
3848c2ecf20Sopenharmony_ci#define QIB_CMD_SDMA_COMPLETE   32      /* sdma completion counter request */
3858c2ecf20Sopenharmony_ci/* 33 available, was a testing feature  */
3868c2ecf20Sopenharmony_ci#define QIB_CMD_DISARM_BUFS     34      /* disarm send buffers w/ errors */
3878c2ecf20Sopenharmony_ci#define QIB_CMD_ACK_EVENT       35      /* ack & clear bits */
3888c2ecf20Sopenharmony_ci#define QIB_CMD_CPUS_LIST       36      /* list of cpus allocated, for pinned
3898c2ecf20Sopenharmony_ci					 * processes: qib_cpus_list */
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci/*
3928c2ecf20Sopenharmony_ci * QIB_CMD_ACK_EVENT obsoletes QIB_CMD_DISARM_BUFS, but we keep it for
3938c2ecf20Sopenharmony_ci * compatibility with libraries from previous release.   The ACK_EVENT
3948c2ecf20Sopenharmony_ci * will take appropriate driver action (if any, just DISARM for now),
3958c2ecf20Sopenharmony_ci * then clear the bits passed in as part of the mask.  These bits are
3968c2ecf20Sopenharmony_ci * in the first 64bit word at spi_sendbuf_status, and are passed to
3978c2ecf20Sopenharmony_ci * the driver in the event_mask union as well.
3988c2ecf20Sopenharmony_ci */
3998c2ecf20Sopenharmony_ci#define _QIB_EVENT_DISARM_BUFS_BIT	0
4008c2ecf20Sopenharmony_ci#define _QIB_EVENT_LINKDOWN_BIT		1
4018c2ecf20Sopenharmony_ci#define _QIB_EVENT_LID_CHANGE_BIT	2
4028c2ecf20Sopenharmony_ci#define _QIB_EVENT_LMC_CHANGE_BIT	3
4038c2ecf20Sopenharmony_ci#define _QIB_EVENT_SL2VL_CHANGE_BIT	4
4048c2ecf20Sopenharmony_ci#define _QIB_MAX_EVENT_BIT _QIB_EVENT_SL2VL_CHANGE_BIT
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci#define QIB_EVENT_DISARM_BUFS_BIT	(1UL << _QIB_EVENT_DISARM_BUFS_BIT)
4078c2ecf20Sopenharmony_ci#define QIB_EVENT_LINKDOWN_BIT		(1UL << _QIB_EVENT_LINKDOWN_BIT)
4088c2ecf20Sopenharmony_ci#define QIB_EVENT_LID_CHANGE_BIT	(1UL << _QIB_EVENT_LID_CHANGE_BIT)
4098c2ecf20Sopenharmony_ci#define QIB_EVENT_LMC_CHANGE_BIT	(1UL << _QIB_EVENT_LMC_CHANGE_BIT)
4108c2ecf20Sopenharmony_ci#define QIB_EVENT_SL2VL_CHANGE_BIT	(1UL << _QIB_EVENT_SL2VL_CHANGE_BIT)
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci/*
4148c2ecf20Sopenharmony_ci * Poll types
4158c2ecf20Sopenharmony_ci */
4168c2ecf20Sopenharmony_ci#define QIB_POLL_TYPE_ANYRCV     0x0
4178c2ecf20Sopenharmony_ci#define QIB_POLL_TYPE_URGENT     0x1
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_cistruct qib_ctxt_info {
4208c2ecf20Sopenharmony_ci	__u16 num_active;       /* number of active units */
4218c2ecf20Sopenharmony_ci	__u16 unit;             /* unit (chip) assigned to caller */
4228c2ecf20Sopenharmony_ci	__u16 port;             /* IB port assigned to caller (1-based) */
4238c2ecf20Sopenharmony_ci	__u16 ctxt;             /* ctxt on unit assigned to caller */
4248c2ecf20Sopenharmony_ci	__u16 subctxt;          /* subctxt on unit assigned to caller */
4258c2ecf20Sopenharmony_ci	__u16 num_ctxts;        /* number of ctxts available on unit */
4268c2ecf20Sopenharmony_ci	__u16 num_subctxts;     /* number of subctxts opened on ctxt */
4278c2ecf20Sopenharmony_ci	__u16 rec_cpu;          /* cpu # for affinity (ffff if none) */
4288c2ecf20Sopenharmony_ci};
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_cistruct qib_tid_info {
4318c2ecf20Sopenharmony_ci	__u32 tidcnt;
4328c2ecf20Sopenharmony_ci	/* make structure same size in 32 and 64 bit */
4338c2ecf20Sopenharmony_ci	__u32 tid__unused;
4348c2ecf20Sopenharmony_ci	/* virtual address of first page in transfer */
4358c2ecf20Sopenharmony_ci	__u64 tidvaddr;
4368c2ecf20Sopenharmony_ci	/* pointer (same size 32/64 bit) to __u16 tid array */
4378c2ecf20Sopenharmony_ci	__u64 tidlist;
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ci	/*
4408c2ecf20Sopenharmony_ci	 * pointer (same size 32/64 bit) to bitmap of TIDs used
4418c2ecf20Sopenharmony_ci	 * for this call; checked for being large enough at open
4428c2ecf20Sopenharmony_ci	 */
4438c2ecf20Sopenharmony_ci	__u64 tidmap;
4448c2ecf20Sopenharmony_ci};
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_cistruct qib_cmd {
4478c2ecf20Sopenharmony_ci	__u32 type;                     /* command type */
4488c2ecf20Sopenharmony_ci	union {
4498c2ecf20Sopenharmony_ci		struct qib_tid_info tid_info;
4508c2ecf20Sopenharmony_ci		struct qib_user_info user_info;
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci		/*
4538c2ecf20Sopenharmony_ci		 * address in userspace where we should put the sdma
4548c2ecf20Sopenharmony_ci		 * inflight counter
4558c2ecf20Sopenharmony_ci		 */
4568c2ecf20Sopenharmony_ci		__u64 sdma_inflight;
4578c2ecf20Sopenharmony_ci		/*
4588c2ecf20Sopenharmony_ci		 * address in userspace where we should put the sdma
4598c2ecf20Sopenharmony_ci		 * completion counter
4608c2ecf20Sopenharmony_ci		 */
4618c2ecf20Sopenharmony_ci		__u64 sdma_complete;
4628c2ecf20Sopenharmony_ci		/* address in userspace of struct qib_ctxt_info to
4638c2ecf20Sopenharmony_ci		   write result to */
4648c2ecf20Sopenharmony_ci		__u64 ctxt_info;
4658c2ecf20Sopenharmony_ci		/* enable/disable receipt of packets */
4668c2ecf20Sopenharmony_ci		__u32 recv_ctrl;
4678c2ecf20Sopenharmony_ci		/* enable/disable armlaunch errors (non-zero to enable) */
4688c2ecf20Sopenharmony_ci		__u32 armlaunch_ctrl;
4698c2ecf20Sopenharmony_ci		/* partition key to set */
4708c2ecf20Sopenharmony_ci		__u16 part_key;
4718c2ecf20Sopenharmony_ci		/* user address of __u32 bitmask of active slaves */
4728c2ecf20Sopenharmony_ci		__u64 slave_mask_addr;
4738c2ecf20Sopenharmony_ci		/* type of polling we want */
4748c2ecf20Sopenharmony_ci		__u16 poll_type;
4758c2ecf20Sopenharmony_ci		/* back pressure enable bit for one particular context */
4768c2ecf20Sopenharmony_ci		__u8 ctxt_bp;
4778c2ecf20Sopenharmony_ci		/* qib_user_event_ack(), IPATH_EVENT_* bits */
4788c2ecf20Sopenharmony_ci		__u64 event_mask;
4798c2ecf20Sopenharmony_ci	} cmd;
4808c2ecf20Sopenharmony_ci};
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_cistruct qib_iovec {
4838c2ecf20Sopenharmony_ci	/* Pointer to data, but same size 32 and 64 bit */
4848c2ecf20Sopenharmony_ci	__u64 iov_base;
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci	/*
4878c2ecf20Sopenharmony_ci	 * Length of data; don't need 64 bits, but want
4888c2ecf20Sopenharmony_ci	 * qib_sendpkt to remain same size as before 32 bit changes, so...
4898c2ecf20Sopenharmony_ci	 */
4908c2ecf20Sopenharmony_ci	__u64 iov_len;
4918c2ecf20Sopenharmony_ci};
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci/*
4948c2ecf20Sopenharmony_ci * Describes a single packet for send.  Each packet can have one or more
4958c2ecf20Sopenharmony_ci * buffers, but the total length (exclusive of IB headers) must be less
4968c2ecf20Sopenharmony_ci * than the MTU, and if using the PIO method, entire packet length,
4978c2ecf20Sopenharmony_ci * including IB headers, must be less than the qib_piosize value (words).
4988c2ecf20Sopenharmony_ci * Use of this necessitates including sys/uio.h
4998c2ecf20Sopenharmony_ci */
5008c2ecf20Sopenharmony_cistruct __qib_sendpkt {
5018c2ecf20Sopenharmony_ci	__u32 sps_flags;        /* flags for packet (TBD) */
5028c2ecf20Sopenharmony_ci	__u32 sps_cnt;          /* number of entries to use in sps_iov */
5038c2ecf20Sopenharmony_ci	/* array of iov's describing packet. TEMPORARY */
5048c2ecf20Sopenharmony_ci	struct qib_iovec sps_iov[4];
5058c2ecf20Sopenharmony_ci};
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci/*
5088c2ecf20Sopenharmony_ci * Diagnostics can send a packet by "writing" the following
5098c2ecf20Sopenharmony_ci * structs to the diag data special file.
5108c2ecf20Sopenharmony_ci * This allows a custom
5118c2ecf20Sopenharmony_ci * pbc (+ static rate) qword, so that special modes and deliberate
5128c2ecf20Sopenharmony_ci * changes to CRCs can be used. The elements were also re-ordered
5138c2ecf20Sopenharmony_ci * for better alignment and to avoid padding issues.
5148c2ecf20Sopenharmony_ci */
5158c2ecf20Sopenharmony_ci#define _DIAG_XPKT_VERS 3
5168c2ecf20Sopenharmony_cistruct qib_diag_xpkt {
5178c2ecf20Sopenharmony_ci	__u16 version;
5188c2ecf20Sopenharmony_ci	__u16 unit;
5198c2ecf20Sopenharmony_ci	__u16 port;
5208c2ecf20Sopenharmony_ci	__u16 len;
5218c2ecf20Sopenharmony_ci	__u64 data;
5228c2ecf20Sopenharmony_ci	__u64 pbc_wd;
5238c2ecf20Sopenharmony_ci};
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci/*
5268c2ecf20Sopenharmony_ci * Data layout in I2C flash (for GUID, etc.)
5278c2ecf20Sopenharmony_ci * All fields are little-endian binary unless otherwise stated
5288c2ecf20Sopenharmony_ci */
5298c2ecf20Sopenharmony_ci#define QIB_FLASH_VERSION 2
5308c2ecf20Sopenharmony_cistruct qib_flash {
5318c2ecf20Sopenharmony_ci	/* flash layout version (QIB_FLASH_VERSION) */
5328c2ecf20Sopenharmony_ci	__u8 if_fversion;
5338c2ecf20Sopenharmony_ci	/* checksum protecting if_length bytes */
5348c2ecf20Sopenharmony_ci	__u8 if_csum;
5358c2ecf20Sopenharmony_ci	/*
5368c2ecf20Sopenharmony_ci	 * valid length (in use, protected by if_csum), including
5378c2ecf20Sopenharmony_ci	 * if_fversion and if_csum themselves)
5388c2ecf20Sopenharmony_ci	 */
5398c2ecf20Sopenharmony_ci	__u8 if_length;
5408c2ecf20Sopenharmony_ci	/* the GUID, in network order */
5418c2ecf20Sopenharmony_ci	__u8 if_guid[8];
5428c2ecf20Sopenharmony_ci	/* number of GUIDs to use, starting from if_guid */
5438c2ecf20Sopenharmony_ci	__u8 if_numguid;
5448c2ecf20Sopenharmony_ci	/* the (last 10 characters of) board serial number, in ASCII */
5458c2ecf20Sopenharmony_ci	char if_serial[12];
5468c2ecf20Sopenharmony_ci	/* board mfg date (YYYYMMDD ASCII) */
5478c2ecf20Sopenharmony_ci	char if_mfgdate[8];
5488c2ecf20Sopenharmony_ci	/* last board rework/test date (YYYYMMDD ASCII) */
5498c2ecf20Sopenharmony_ci	char if_testdate[8];
5508c2ecf20Sopenharmony_ci	/* logging of error counts, TBD */
5518c2ecf20Sopenharmony_ci	__u8 if_errcntp[4];
5528c2ecf20Sopenharmony_ci	/* powered on hours, updated at driver unload */
5538c2ecf20Sopenharmony_ci	__u8 if_powerhour[2];
5548c2ecf20Sopenharmony_ci	/* ASCII free-form comment field */
5558c2ecf20Sopenharmony_ci	char if_comment[32];
5568c2ecf20Sopenharmony_ci	/* Backwards compatible prefix for longer QLogic Serial Numbers */
5578c2ecf20Sopenharmony_ci	char if_sprefix[4];
5588c2ecf20Sopenharmony_ci	/* 82 bytes used, min flash size is 128 bytes */
5598c2ecf20Sopenharmony_ci	__u8 if_future[46];
5608c2ecf20Sopenharmony_ci};
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci/*
5638c2ecf20Sopenharmony_ci * These are the counters implemented in the chip, and are listed in order.
5648c2ecf20Sopenharmony_ci * The InterCaps naming is taken straight from the chip spec.
5658c2ecf20Sopenharmony_ci */
5668c2ecf20Sopenharmony_cistruct qlogic_ib_counters {
5678c2ecf20Sopenharmony_ci	__u64 LBIntCnt;
5688c2ecf20Sopenharmony_ci	__u64 LBFlowStallCnt;
5698c2ecf20Sopenharmony_ci	__u64 TxSDmaDescCnt;    /* was Reserved1 */
5708c2ecf20Sopenharmony_ci	__u64 TxUnsupVLErrCnt;
5718c2ecf20Sopenharmony_ci	__u64 TxDataPktCnt;
5728c2ecf20Sopenharmony_ci	__u64 TxFlowPktCnt;
5738c2ecf20Sopenharmony_ci	__u64 TxDwordCnt;
5748c2ecf20Sopenharmony_ci	__u64 TxLenErrCnt;
5758c2ecf20Sopenharmony_ci	__u64 TxMaxMinLenErrCnt;
5768c2ecf20Sopenharmony_ci	__u64 TxUnderrunCnt;
5778c2ecf20Sopenharmony_ci	__u64 TxFlowStallCnt;
5788c2ecf20Sopenharmony_ci	__u64 TxDroppedPktCnt;
5798c2ecf20Sopenharmony_ci	__u64 RxDroppedPktCnt;
5808c2ecf20Sopenharmony_ci	__u64 RxDataPktCnt;
5818c2ecf20Sopenharmony_ci	__u64 RxFlowPktCnt;
5828c2ecf20Sopenharmony_ci	__u64 RxDwordCnt;
5838c2ecf20Sopenharmony_ci	__u64 RxLenErrCnt;
5848c2ecf20Sopenharmony_ci	__u64 RxMaxMinLenErrCnt;
5858c2ecf20Sopenharmony_ci	__u64 RxICRCErrCnt;
5868c2ecf20Sopenharmony_ci	__u64 RxVCRCErrCnt;
5878c2ecf20Sopenharmony_ci	__u64 RxFlowCtrlErrCnt;
5888c2ecf20Sopenharmony_ci	__u64 RxBadFormatCnt;
5898c2ecf20Sopenharmony_ci	__u64 RxLinkProblemCnt;
5908c2ecf20Sopenharmony_ci	__u64 RxEBPCnt;
5918c2ecf20Sopenharmony_ci	__u64 RxLPCRCErrCnt;
5928c2ecf20Sopenharmony_ci	__u64 RxBufOvflCnt;
5938c2ecf20Sopenharmony_ci	__u64 RxTIDFullErrCnt;
5948c2ecf20Sopenharmony_ci	__u64 RxTIDValidErrCnt;
5958c2ecf20Sopenharmony_ci	__u64 RxPKeyMismatchCnt;
5968c2ecf20Sopenharmony_ci	__u64 RxP0HdrEgrOvflCnt;
5978c2ecf20Sopenharmony_ci	__u64 RxP1HdrEgrOvflCnt;
5988c2ecf20Sopenharmony_ci	__u64 RxP2HdrEgrOvflCnt;
5998c2ecf20Sopenharmony_ci	__u64 RxP3HdrEgrOvflCnt;
6008c2ecf20Sopenharmony_ci	__u64 RxP4HdrEgrOvflCnt;
6018c2ecf20Sopenharmony_ci	__u64 RxP5HdrEgrOvflCnt;
6028c2ecf20Sopenharmony_ci	__u64 RxP6HdrEgrOvflCnt;
6038c2ecf20Sopenharmony_ci	__u64 RxP7HdrEgrOvflCnt;
6048c2ecf20Sopenharmony_ci	__u64 RxP8HdrEgrOvflCnt;
6058c2ecf20Sopenharmony_ci	__u64 RxP9HdrEgrOvflCnt;
6068c2ecf20Sopenharmony_ci	__u64 RxP10HdrEgrOvflCnt;
6078c2ecf20Sopenharmony_ci	__u64 RxP11HdrEgrOvflCnt;
6088c2ecf20Sopenharmony_ci	__u64 RxP12HdrEgrOvflCnt;
6098c2ecf20Sopenharmony_ci	__u64 RxP13HdrEgrOvflCnt;
6108c2ecf20Sopenharmony_ci	__u64 RxP14HdrEgrOvflCnt;
6118c2ecf20Sopenharmony_ci	__u64 RxP15HdrEgrOvflCnt;
6128c2ecf20Sopenharmony_ci	__u64 RxP16HdrEgrOvflCnt;
6138c2ecf20Sopenharmony_ci	__u64 IBStatusChangeCnt;
6148c2ecf20Sopenharmony_ci	__u64 IBLinkErrRecoveryCnt;
6158c2ecf20Sopenharmony_ci	__u64 IBLinkDownedCnt;
6168c2ecf20Sopenharmony_ci	__u64 IBSymbolErrCnt;
6178c2ecf20Sopenharmony_ci	__u64 RxVL15DroppedPktCnt;
6188c2ecf20Sopenharmony_ci	__u64 RxOtherLocalPhyErrCnt;
6198c2ecf20Sopenharmony_ci	__u64 PcieRetryBufDiagQwordCnt;
6208c2ecf20Sopenharmony_ci	__u64 ExcessBufferOvflCnt;
6218c2ecf20Sopenharmony_ci	__u64 LocalLinkIntegrityErrCnt;
6228c2ecf20Sopenharmony_ci	__u64 RxVlErrCnt;
6238c2ecf20Sopenharmony_ci	__u64 RxDlidFltrCnt;
6248c2ecf20Sopenharmony_ci};
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci/*
6278c2ecf20Sopenharmony_ci * The next set of defines are for packet headers, and chip register
6288c2ecf20Sopenharmony_ci * and memory bits that are visible to and/or used by user-mode software.
6298c2ecf20Sopenharmony_ci */
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci/* RcvHdrFlags bits */
6328c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_LENGTH_MASK 0x7FF
6338c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_LENGTH_SHIFT 0
6348c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_RCVTYPE_MASK 0x7
6358c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_RCVTYPE_SHIFT 11
6368c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_EGRINDEX_MASK 0xFFF
6378c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_EGRINDEX_SHIFT 16
6388c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_SEQ_MASK 0xF
6398c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_SEQ_SHIFT 0
6408c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_HDRQ_OFFSET_MASK 0x7FF
6418c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT 4
6428c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_ICRCERR   0x80000000
6438c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_VCRCERR   0x40000000
6448c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_PARITYERR 0x20000000
6458c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_LENERR    0x10000000
6468c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_MTUERR    0x08000000
6478c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_IHDRERR   0x04000000
6488c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_TIDERR    0x02000000
6498c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_MKERR     0x01000000
6508c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_IBERR     0x00800000
6518c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_H_ERR_MASK  0xFF800000
6528c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_L_USE_EGR   0x80000000
6538c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_L_SWA       0x00008000
6548c2ecf20Sopenharmony_ci#define QLOGIC_IB_RHF_L_SWB       0x00004000
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci/* qlogic_ib header fields */
6578c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_VERS_MASK 0xF
6588c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_VERS_SHIFT 28
6598c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_CTXT_MASK 0xF
6608c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_CTXT_SHIFT 24
6618c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_TID_MASK 0x7FF
6628c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_TID_SHIFT 13
6638c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_OFFSET_MASK 0x1FFF
6648c2ecf20Sopenharmony_ci#define QLOGIC_IB_I_OFFSET_SHIFT 0
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_ci/* K_PktFlags bits */
6678c2ecf20Sopenharmony_ci#define QLOGIC_IB_KPF_INTR 0x1
6688c2ecf20Sopenharmony_ci#define QLOGIC_IB_KPF_SUBCTXT_MASK 0x3
6698c2ecf20Sopenharmony_ci#define QLOGIC_IB_KPF_SUBCTXT_SHIFT 1
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_ci#define QLOGIC_IB_MAX_SUBCTXT   4
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_ci/* SendPIO per-buffer control */
6748c2ecf20Sopenharmony_ci#define QLOGIC_IB_SP_TEST    0x40
6758c2ecf20Sopenharmony_ci#define QLOGIC_IB_SP_TESTEBP 0x20
6768c2ecf20Sopenharmony_ci#define QLOGIC_IB_SP_TRIGGER_SHIFT  15
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_ci/* SendPIOAvail bits */
6798c2ecf20Sopenharmony_ci#define QLOGIC_IB_SENDPIOAVAIL_BUSY_SHIFT 1
6808c2ecf20Sopenharmony_ci#define QLOGIC_IB_SENDPIOAVAIL_CHECK_SHIFT 0
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_ci/* qlogic_ib header format */
6838c2ecf20Sopenharmony_cistruct qib_header {
6848c2ecf20Sopenharmony_ci	/*
6858c2ecf20Sopenharmony_ci	 * Version - 4 bits, Context - 4 bits, TID - 10 bits and Offset -
6868c2ecf20Sopenharmony_ci	 * 14 bits before ECO change ~28 Dec 03.  After that, Vers 4,
6878c2ecf20Sopenharmony_ci	 * Context 4, TID 11, offset 13.
6888c2ecf20Sopenharmony_ci	 */
6898c2ecf20Sopenharmony_ci	__le32 ver_ctxt_tid_offset;
6908c2ecf20Sopenharmony_ci	__le16 chksum;
6918c2ecf20Sopenharmony_ci	__le16 pkt_flags;
6928c2ecf20Sopenharmony_ci};
6938c2ecf20Sopenharmony_ci
6948c2ecf20Sopenharmony_ci/*
6958c2ecf20Sopenharmony_ci * qlogic_ib user message header format.
6968c2ecf20Sopenharmony_ci * This structure contains the first 4 fields common to all protocols
6978c2ecf20Sopenharmony_ci * that employ qlogic_ib.
6988c2ecf20Sopenharmony_ci */
6998c2ecf20Sopenharmony_cistruct qib_message_header {
7008c2ecf20Sopenharmony_ci	__be16 lrh[4];
7018c2ecf20Sopenharmony_ci	__be32 bth[3];
7028c2ecf20Sopenharmony_ci	/* fields below this point are in host byte order */
7038c2ecf20Sopenharmony_ci	struct qib_header iph;
7048c2ecf20Sopenharmony_ci	/* fields below are simplified, but should match PSM */
7058c2ecf20Sopenharmony_ci	/* some are accessed by driver when packet spliting is needed */
7068c2ecf20Sopenharmony_ci	__u8 sub_opcode;
7078c2ecf20Sopenharmony_ci	__u8 flags;
7088c2ecf20Sopenharmony_ci	__u16 commidx;
7098c2ecf20Sopenharmony_ci	__u32 ack_seq_num;
7108c2ecf20Sopenharmony_ci	__u8 flowid;
7118c2ecf20Sopenharmony_ci	__u8 hdr_dlen;
7128c2ecf20Sopenharmony_ci	__u16 mqhdr;
7138c2ecf20Sopenharmony_ci	__u32 uwords[4];
7148c2ecf20Sopenharmony_ci};
7158c2ecf20Sopenharmony_ci
7168c2ecf20Sopenharmony_ci/* sequence number bits for message */
7178c2ecf20Sopenharmony_ciunion qib_seqnum {
7188c2ecf20Sopenharmony_ci	struct {
7198c2ecf20Sopenharmony_ci		__u32 seq:11;
7208c2ecf20Sopenharmony_ci		__u32 gen:8;
7218c2ecf20Sopenharmony_ci		__u32 flow:5;
7228c2ecf20Sopenharmony_ci	};
7238c2ecf20Sopenharmony_ci	struct {
7248c2ecf20Sopenharmony_ci		__u32 pkt:16;
7258c2ecf20Sopenharmony_ci		__u32 msg:8;
7268c2ecf20Sopenharmony_ci	};
7278c2ecf20Sopenharmony_ci	__u32 val;
7288c2ecf20Sopenharmony_ci};
7298c2ecf20Sopenharmony_ci
7308c2ecf20Sopenharmony_ci/* qib receiving-dma tid-session-member */
7318c2ecf20Sopenharmony_cistruct qib_tid_session_member {
7328c2ecf20Sopenharmony_ci	__u16 tid;
7338c2ecf20Sopenharmony_ci	__u16 offset;
7348c2ecf20Sopenharmony_ci	__u16 length;
7358c2ecf20Sopenharmony_ci};
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ci/* IB - LRH header consts */
7388c2ecf20Sopenharmony_ci#define QIB_LRH_GRH 0x0003      /* 1. word of IB LRH - next header: GRH */
7398c2ecf20Sopenharmony_ci#define QIB_LRH_BTH 0x0002      /* 1. word of IB LRH - next header: BTH */
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci/* misc. */
7428c2ecf20Sopenharmony_ci#define SIZE_OF_CRC 1
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_ci#define QIB_DEFAULT_P_KEY 0xFFFF
7458c2ecf20Sopenharmony_ci#define QIB_PSN_MASK 0xFFFFFF
7468c2ecf20Sopenharmony_ci#define QIB_EAGER_TID_ID QLOGIC_IB_I_TID_MASK
7478c2ecf20Sopenharmony_ci#define QIB_MULTICAST_QPN 0xFFFFFF
7488c2ecf20Sopenharmony_ci
7498c2ecf20Sopenharmony_ci/* Receive Header Queue: receive type (from qlogic_ib) */
7508c2ecf20Sopenharmony_ci#define RCVHQ_RCV_TYPE_EXPECTED  0
7518c2ecf20Sopenharmony_ci#define RCVHQ_RCV_TYPE_EAGER     1
7528c2ecf20Sopenharmony_ci#define RCVHQ_RCV_TYPE_NON_KD    2
7538c2ecf20Sopenharmony_ci#define RCVHQ_RCV_TYPE_ERROR     3
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_ci#define QIB_HEADER_QUEUE_WORDS 9
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_ci/* functions for extracting fields from rcvhdrq entries for the driver.
7588c2ecf20Sopenharmony_ci */
7598c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_err_flags(const __le32 *rbuf)
7608c2ecf20Sopenharmony_ci{
7618c2ecf20Sopenharmony_ci	return __le32_to_cpu(rbuf[1]) & QLOGIC_IB_RHF_H_ERR_MASK;
7628c2ecf20Sopenharmony_ci}
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_rcv_type(const __le32 *rbuf)
7658c2ecf20Sopenharmony_ci{
7668c2ecf20Sopenharmony_ci	return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_RCVTYPE_SHIFT) &
7678c2ecf20Sopenharmony_ci		QLOGIC_IB_RHF_RCVTYPE_MASK;
7688c2ecf20Sopenharmony_ci}
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_length_in_bytes(const __le32 *rbuf)
7718c2ecf20Sopenharmony_ci{
7728c2ecf20Sopenharmony_ci	return ((__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_LENGTH_SHIFT) &
7738c2ecf20Sopenharmony_ci		QLOGIC_IB_RHF_LENGTH_MASK) << 2;
7748c2ecf20Sopenharmony_ci}
7758c2ecf20Sopenharmony_ci
7768c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_index(const __le32 *rbuf)
7778c2ecf20Sopenharmony_ci{
7788c2ecf20Sopenharmony_ci	return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_EGRINDEX_SHIFT) &
7798c2ecf20Sopenharmony_ci		QLOGIC_IB_RHF_EGRINDEX_MASK;
7808c2ecf20Sopenharmony_ci}
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_seq(const __le32 *rbuf)
7838c2ecf20Sopenharmony_ci{
7848c2ecf20Sopenharmony_ci	return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_SEQ_SHIFT) &
7858c2ecf20Sopenharmony_ci		QLOGIC_IB_RHF_SEQ_MASK;
7868c2ecf20Sopenharmony_ci}
7878c2ecf20Sopenharmony_ci
7888c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_offset(const __le32 *rbuf)
7898c2ecf20Sopenharmony_ci{
7908c2ecf20Sopenharmony_ci	return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT) &
7918c2ecf20Sopenharmony_ci		QLOGIC_IB_RHF_HDRQ_OFFSET_MASK;
7928c2ecf20Sopenharmony_ci}
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_use_egr_buf(const __le32 *rbuf)
7958c2ecf20Sopenharmony_ci{
7968c2ecf20Sopenharmony_ci	return __le32_to_cpu(rbuf[0]) & QLOGIC_IB_RHF_L_USE_EGR;
7978c2ecf20Sopenharmony_ci}
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_cistatic inline __u32 qib_hdrget_qib_ver(__le32 hdrword)
8008c2ecf20Sopenharmony_ci{
8018c2ecf20Sopenharmony_ci	return (__le32_to_cpu(hdrword) >> QLOGIC_IB_I_VERS_SHIFT) &
8028c2ecf20Sopenharmony_ci		QLOGIC_IB_I_VERS_MASK;
8038c2ecf20Sopenharmony_ci}
8048c2ecf20Sopenharmony_ci
8058c2ecf20Sopenharmony_ci#endif                          /* _QIB_COMMON_H */
806