162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation. 362306a36Sopenharmony_ci * All rights reserved. 462306a36Sopenharmony_ci * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This software is available to you under a choice of one of two 762306a36Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the 1062306a36Sopenharmony_ci * OpenIB.org BSD license below: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or 1362306a36Sopenharmony_ci * without modification, are permitted provided that the following 1462306a36Sopenharmony_ci * conditions are met: 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * - Redistributions of source code must retain the above 1762306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 1862306a36Sopenharmony_ci * disclaimer. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * - Redistributions in binary form must reproduce the above 2162306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 2262306a36Sopenharmony_ci * disclaimer in the documentation and/or other materials 2362306a36Sopenharmony_ci * provided with the distribution. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3262306a36Sopenharmony_ci * SOFTWARE. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#ifndef _QIB_COMMON_H 3662306a36Sopenharmony_ci#define _QIB_COMMON_H 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* 3962306a36Sopenharmony_ci * This file contains defines, structures, etc. that are used 4062306a36Sopenharmony_ci * to communicate between kernel and user code. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci/* This is the IEEE-assigned OUI for QLogic Inc. QLogic_IB */ 4462306a36Sopenharmony_ci#define QIB_SRC_OUI_1 0x00 4562306a36Sopenharmony_ci#define QIB_SRC_OUI_2 0x11 4662306a36Sopenharmony_ci#define QIB_SRC_OUI_3 0x75 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* version of protocol header (known to chip also). In the long run, 4962306a36Sopenharmony_ci * we should be able to generate and accept a range of version numbers; 5062306a36Sopenharmony_ci * for now we only accept one, and it's compiled in. 5162306a36Sopenharmony_ci */ 5262306a36Sopenharmony_ci#define IPS_PROTO_VERSION 2 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* 5562306a36Sopenharmony_ci * These are compile time constants that you may want to enable or disable 5662306a36Sopenharmony_ci * if you are trying to debug problems with code or performance. 5762306a36Sopenharmony_ci * QIB_VERBOSE_TRACING define as 1 if you want additional tracing in 5862306a36Sopenharmony_ci * fastpath code 5962306a36Sopenharmony_ci * QIB_TRACE_REGWRITES define as 1 if you want register writes to be 6062306a36Sopenharmony_ci * traced in fastpath code 6162306a36Sopenharmony_ci * _QIB_TRACING define as 0 if you want to remove all tracing in a 6262306a36Sopenharmony_ci * compilation unit 6362306a36Sopenharmony_ci */ 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* 6662306a36Sopenharmony_ci * The value in the BTH QP field that QLogic_IB uses to differentiate 6762306a36Sopenharmony_ci * an qlogic_ib protocol IB packet vs standard IB transport 6862306a36Sopenharmony_ci * This it needs to be even (0x656b78), because the LSB is sometimes 6962306a36Sopenharmony_ci * used for the MSB of context. The change may cause a problem 7062306a36Sopenharmony_ci * interoperating with older software. 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_ci#define QIB_KD_QP 0x656b78 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* 7562306a36Sopenharmony_ci * These are the status bits readable (in ascii form, 64bit value) 7662306a36Sopenharmony_ci * from the "status" sysfs file. For binary compatibility, values 7762306a36Sopenharmony_ci * must remain as is; removed states can be reused for different 7862306a36Sopenharmony_ci * purposes. 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci#define QIB_STATUS_INITTED 0x1 /* basic initialization done */ 8162306a36Sopenharmony_ci/* Chip has been found and initted */ 8262306a36Sopenharmony_ci#define QIB_STATUS_CHIP_PRESENT 0x20 8362306a36Sopenharmony_ci/* IB link is at ACTIVE, usable for data traffic */ 8462306a36Sopenharmony_ci#define QIB_STATUS_IB_READY 0x40 8562306a36Sopenharmony_ci/* link is configured, LID, MTU, etc. have been set */ 8662306a36Sopenharmony_ci#define QIB_STATUS_IB_CONF 0x80 8762306a36Sopenharmony_ci/* A Fatal hardware error has occurred. */ 8862306a36Sopenharmony_ci#define QIB_STATUS_HWERROR 0x200 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* 9162306a36Sopenharmony_ci * The list of usermode accessible registers. Also see Reg_* later in file. 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_cienum qib_ureg { 9462306a36Sopenharmony_ci /* (RO) DMA RcvHdr to be used next. */ 9562306a36Sopenharmony_ci ur_rcvhdrtail = 0, 9662306a36Sopenharmony_ci /* (RW) RcvHdr entry to be processed next by host. */ 9762306a36Sopenharmony_ci ur_rcvhdrhead = 1, 9862306a36Sopenharmony_ci /* (RO) Index of next Eager index to use. */ 9962306a36Sopenharmony_ci ur_rcvegrindextail = 2, 10062306a36Sopenharmony_ci /* (RW) Eager TID to be processed next */ 10162306a36Sopenharmony_ci ur_rcvegrindexhead = 3, 10262306a36Sopenharmony_ci /* For internal use only; max register number. */ 10362306a36Sopenharmony_ci _QIB_UregMax 10462306a36Sopenharmony_ci}; 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci/* bit values for spi_runtime_flags */ 10762306a36Sopenharmony_ci#define QIB_RUNTIME_PCIE 0x0002 10862306a36Sopenharmony_ci#define QIB_RUNTIME_FORCE_WC_ORDER 0x0004 10962306a36Sopenharmony_ci#define QIB_RUNTIME_RCVHDR_COPY 0x0008 11062306a36Sopenharmony_ci#define QIB_RUNTIME_MASTER 0x0010 11162306a36Sopenharmony_ci#define QIB_RUNTIME_RCHK 0x0020 11262306a36Sopenharmony_ci#define QIB_RUNTIME_NODMA_RTAIL 0x0080 11362306a36Sopenharmony_ci#define QIB_RUNTIME_SPECIAL_TRIGGER 0x0100 11462306a36Sopenharmony_ci#define QIB_RUNTIME_SDMA 0x0200 11562306a36Sopenharmony_ci#define QIB_RUNTIME_FORCE_PIOAVAIL 0x0400 11662306a36Sopenharmony_ci#define QIB_RUNTIME_PIO_REGSWAPPED 0x0800 11762306a36Sopenharmony_ci#define QIB_RUNTIME_CTXT_MSB_IN_QP 0x1000 11862306a36Sopenharmony_ci#define QIB_RUNTIME_CTXT_REDIRECT 0x2000 11962306a36Sopenharmony_ci#define QIB_RUNTIME_HDRSUPP 0x4000 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* 12262306a36Sopenharmony_ci * This structure is returned by qib_userinit() immediately after 12362306a36Sopenharmony_ci * open to get implementation-specific info, and info specific to this 12462306a36Sopenharmony_ci * instance. 12562306a36Sopenharmony_ci * 12662306a36Sopenharmony_ci * This struct must have explict pad fields where type sizes 12762306a36Sopenharmony_ci * may result in different alignments between 32 and 64 bit 12862306a36Sopenharmony_ci * programs, since the 64 bit * bit kernel requires the user code 12962306a36Sopenharmony_ci * to have matching offsets 13062306a36Sopenharmony_ci */ 13162306a36Sopenharmony_cistruct qib_base_info { 13262306a36Sopenharmony_ci /* version of hardware, for feature checking. */ 13362306a36Sopenharmony_ci __u32 spi_hw_version; 13462306a36Sopenharmony_ci /* version of software, for feature checking. */ 13562306a36Sopenharmony_ci __u32 spi_sw_version; 13662306a36Sopenharmony_ci /* QLogic_IB context assigned, goes into sent packets */ 13762306a36Sopenharmony_ci __u16 spi_ctxt; 13862306a36Sopenharmony_ci __u16 spi_subctxt; 13962306a36Sopenharmony_ci /* 14062306a36Sopenharmony_ci * IB MTU, packets IB data must be less than this. 14162306a36Sopenharmony_ci * The MTU is in bytes, and will be a multiple of 4 bytes. 14262306a36Sopenharmony_ci */ 14362306a36Sopenharmony_ci __u32 spi_mtu; 14462306a36Sopenharmony_ci /* 14562306a36Sopenharmony_ci * Size of a PIO buffer. Any given packet's total size must be less 14662306a36Sopenharmony_ci * than this (in words). Included is the starting control word, so 14762306a36Sopenharmony_ci * if 513 is returned, then total pkt size is 512 words or less. 14862306a36Sopenharmony_ci */ 14962306a36Sopenharmony_ci __u32 spi_piosize; 15062306a36Sopenharmony_ci /* size of the TID cache in qlogic_ib, in entries */ 15162306a36Sopenharmony_ci __u32 spi_tidcnt; 15262306a36Sopenharmony_ci /* size of the TID Eager list in qlogic_ib, in entries */ 15362306a36Sopenharmony_ci __u32 spi_tidegrcnt; 15462306a36Sopenharmony_ci /* size of a single receive header queue entry in words. */ 15562306a36Sopenharmony_ci __u32 spi_rcvhdrent_size; 15662306a36Sopenharmony_ci /* 15762306a36Sopenharmony_ci * Count of receive header queue entries allocated. 15862306a36Sopenharmony_ci * This may be less than the spu_rcvhdrcnt passed in!. 15962306a36Sopenharmony_ci */ 16062306a36Sopenharmony_ci __u32 spi_rcvhdr_cnt; 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ci /* per-chip and other runtime features bitmap (QIB_RUNTIME_*) */ 16362306a36Sopenharmony_ci __u32 spi_runtime_flags; 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci /* address where hardware receive header queue is mapped */ 16662306a36Sopenharmony_ci __u64 spi_rcvhdr_base; 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci /* user program. */ 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci /* base address of eager TID receive buffers used by hardware. */ 17162306a36Sopenharmony_ci __u64 spi_rcv_egrbufs; 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci /* Allocated by initialization code, not by protocol. */ 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci /* 17662306a36Sopenharmony_ci * Size of each TID buffer in host memory, starting at 17762306a36Sopenharmony_ci * spi_rcv_egrbufs. The buffers are virtually contiguous. 17862306a36Sopenharmony_ci */ 17962306a36Sopenharmony_ci __u32 spi_rcv_egrbufsize; 18062306a36Sopenharmony_ci /* 18162306a36Sopenharmony_ci * The special QP (queue pair) value that identifies an qlogic_ib 18262306a36Sopenharmony_ci * protocol packet from standard IB packets. More, probably much 18362306a36Sopenharmony_ci * more, to be added. 18462306a36Sopenharmony_ci */ 18562306a36Sopenharmony_ci __u32 spi_qpair; 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci /* 18862306a36Sopenharmony_ci * User register base for init code, not to be used directly by 18962306a36Sopenharmony_ci * protocol or applications. Always points to chip registers, 19062306a36Sopenharmony_ci * for normal or shared context. 19162306a36Sopenharmony_ci */ 19262306a36Sopenharmony_ci __u64 spi_uregbase; 19362306a36Sopenharmony_ci /* 19462306a36Sopenharmony_ci * Maximum buffer size in bytes that can be used in a single TID 19562306a36Sopenharmony_ci * entry (assuming the buffer is aligned to this boundary). This is 19662306a36Sopenharmony_ci * the minimum of what the hardware and software support Guaranteed 19762306a36Sopenharmony_ci * to be a power of 2. 19862306a36Sopenharmony_ci */ 19962306a36Sopenharmony_ci __u32 spi_tid_maxsize; 20062306a36Sopenharmony_ci /* 20162306a36Sopenharmony_ci * alignment of each pio send buffer (byte count 20262306a36Sopenharmony_ci * to add to spi_piobufbase to get to second buffer) 20362306a36Sopenharmony_ci */ 20462306a36Sopenharmony_ci __u32 spi_pioalign; 20562306a36Sopenharmony_ci /* 20662306a36Sopenharmony_ci * The index of the first pio buffer available to this process; 20762306a36Sopenharmony_ci * needed to do lookup in spi_pioavailaddr; not added to 20862306a36Sopenharmony_ci * spi_piobufbase. 20962306a36Sopenharmony_ci */ 21062306a36Sopenharmony_ci __u32 spi_pioindex; 21162306a36Sopenharmony_ci /* number of buffers mapped for this process */ 21262306a36Sopenharmony_ci __u32 spi_piocnt; 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci /* 21562306a36Sopenharmony_ci * Base address of writeonly pio buffers for this process. 21662306a36Sopenharmony_ci * Each buffer has spi_piosize words, and is aligned on spi_pioalign 21762306a36Sopenharmony_ci * boundaries. spi_piocnt buffers are mapped from this address 21862306a36Sopenharmony_ci */ 21962306a36Sopenharmony_ci __u64 spi_piobufbase; 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci /* 22262306a36Sopenharmony_ci * Base address of readonly memory copy of the pioavail registers. 22362306a36Sopenharmony_ci * There are 2 bits for each buffer. 22462306a36Sopenharmony_ci */ 22562306a36Sopenharmony_ci __u64 spi_pioavailaddr; 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci /* 22862306a36Sopenharmony_ci * Address where driver updates a copy of the interface and driver 22962306a36Sopenharmony_ci * status (QIB_STATUS_*) as a 64 bit value. It's followed by a 23062306a36Sopenharmony_ci * link status qword (formerly combined with driver status), then a 23162306a36Sopenharmony_ci * string indicating hardware error, if there was one. 23262306a36Sopenharmony_ci */ 23362306a36Sopenharmony_ci __u64 spi_status; 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci /* number of chip ctxts available to user processes */ 23662306a36Sopenharmony_ci __u32 spi_nctxts; 23762306a36Sopenharmony_ci __u16 spi_unit; /* unit number of chip we are using */ 23862306a36Sopenharmony_ci __u16 spi_port; /* IB port number we are using */ 23962306a36Sopenharmony_ci /* num bufs in each contiguous set */ 24062306a36Sopenharmony_ci __u32 spi_rcv_egrperchunk; 24162306a36Sopenharmony_ci /* size in bytes of each contiguous set */ 24262306a36Sopenharmony_ci __u32 spi_rcv_egrchunksize; 24362306a36Sopenharmony_ci /* total size of mmap to cover full rcvegrbuffers */ 24462306a36Sopenharmony_ci __u32 spi_rcv_egrbuftotlen; 24562306a36Sopenharmony_ci __u32 spi_rhf_offset; /* dword offset in hdrqent for rcvhdr flags */ 24662306a36Sopenharmony_ci /* address of readonly memory copy of the rcvhdrq tail register. */ 24762306a36Sopenharmony_ci __u64 spi_rcvhdr_tailaddr; 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci /* 25062306a36Sopenharmony_ci * shared memory pages for subctxts if ctxt is shared; these cover 25162306a36Sopenharmony_ci * all the processes in the group sharing a single context. 25262306a36Sopenharmony_ci * all have enough space for the num_subcontexts value on this job. 25362306a36Sopenharmony_ci */ 25462306a36Sopenharmony_ci __u64 spi_subctxt_uregbase; 25562306a36Sopenharmony_ci __u64 spi_subctxt_rcvegrbuf; 25662306a36Sopenharmony_ci __u64 spi_subctxt_rcvhdr_base; 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ci /* shared memory page for send buffer disarm status */ 25962306a36Sopenharmony_ci __u64 spi_sendbuf_status; 26062306a36Sopenharmony_ci} __aligned(8); 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ci/* 26362306a36Sopenharmony_ci * This version number is given to the driver by the user code during 26462306a36Sopenharmony_ci * initialization in the spu_userversion field of qib_user_info, so 26562306a36Sopenharmony_ci * the driver can check for compatibility with user code. 26662306a36Sopenharmony_ci * 26762306a36Sopenharmony_ci * The major version changes when data structures 26862306a36Sopenharmony_ci * change in an incompatible way. The driver must be the same or higher 26962306a36Sopenharmony_ci * for initialization to succeed. In some cases, a higher version 27062306a36Sopenharmony_ci * driver will not interoperate with older software, and initialization 27162306a36Sopenharmony_ci * will return an error. 27262306a36Sopenharmony_ci */ 27362306a36Sopenharmony_ci#define QIB_USER_SWMAJOR 1 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci/* 27662306a36Sopenharmony_ci * Minor version differences are always compatible 27762306a36Sopenharmony_ci * a within a major version, however if user software is larger 27862306a36Sopenharmony_ci * than driver software, some new features and/or structure fields 27962306a36Sopenharmony_ci * may not be implemented; the user code must deal with this if it 28062306a36Sopenharmony_ci * cares, or it must abort after initialization reports the difference. 28162306a36Sopenharmony_ci */ 28262306a36Sopenharmony_ci#define QIB_USER_SWMINOR 13 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci#define QIB_USER_SWVERSION ((QIB_USER_SWMAJOR << 16) | QIB_USER_SWMINOR) 28562306a36Sopenharmony_ci 28662306a36Sopenharmony_ci#ifndef QIB_KERN_TYPE 28762306a36Sopenharmony_ci#define QIB_KERN_TYPE 0 28862306a36Sopenharmony_ci#endif 28962306a36Sopenharmony_ci 29062306a36Sopenharmony_ci/* 29162306a36Sopenharmony_ci * Similarly, this is the kernel version going back to the user. It's 29262306a36Sopenharmony_ci * slightly different, in that we want to tell if the driver was built as 29362306a36Sopenharmony_ci * part of a QLogic release, or from the driver from openfabrics.org, 29462306a36Sopenharmony_ci * kernel.org, or a standard distribution, for support reasons. 29562306a36Sopenharmony_ci * The high bit is 0 for non-QLogic and 1 for QLogic-built/supplied. 29662306a36Sopenharmony_ci * 29762306a36Sopenharmony_ci * It's returned by the driver to the user code during initialization in the 29862306a36Sopenharmony_ci * spi_sw_version field of qib_base_info, so the user code can in turn 29962306a36Sopenharmony_ci * check for compatibility with the kernel. 30062306a36Sopenharmony_ci*/ 30162306a36Sopenharmony_ci#define QIB_KERN_SWVERSION ((QIB_KERN_TYPE << 31) | QIB_USER_SWVERSION) 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci/* 30462306a36Sopenharmony_ci * Define the driver version number. This is something that refers only 30562306a36Sopenharmony_ci * to the driver itself, not the software interfaces it supports. 30662306a36Sopenharmony_ci */ 30762306a36Sopenharmony_ci#define QIB_DRIVER_VERSION_BASE "1.11" 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci/* create the final driver version string */ 31062306a36Sopenharmony_ci#ifdef QIB_IDSTR 31162306a36Sopenharmony_ci#define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE " " QIB_IDSTR 31262306a36Sopenharmony_ci#else 31362306a36Sopenharmony_ci#define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE 31462306a36Sopenharmony_ci#endif 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci/* 31762306a36Sopenharmony_ci * If the unit is specified via open, HCA choice is fixed. If port is 31862306a36Sopenharmony_ci * specified, it's also fixed. Otherwise we try to spread contexts 31962306a36Sopenharmony_ci * across ports and HCAs, using different algorithims. WITHIN is 32062306a36Sopenharmony_ci * the old default, prior to this mechanism. 32162306a36Sopenharmony_ci */ 32262306a36Sopenharmony_ci#define QIB_PORT_ALG_ACROSS 0 /* round robin contexts across HCAs, then 32362306a36Sopenharmony_ci * ports; this is the default */ 32462306a36Sopenharmony_ci#define QIB_PORT_ALG_WITHIN 1 /* use all contexts on an HCA (round robin 32562306a36Sopenharmony_ci * active ports within), then next HCA */ 32662306a36Sopenharmony_ci#define QIB_PORT_ALG_COUNT 2 /* number of algorithm choices */ 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci/* 32962306a36Sopenharmony_ci * This structure is passed to qib_userinit() to tell the driver where 33062306a36Sopenharmony_ci * user code buffers are, sizes, etc. The offsets and sizes of the 33162306a36Sopenharmony_ci * fields must remain unchanged, for binary compatibility. It can 33262306a36Sopenharmony_ci * be extended, if userversion is changed so user code can tell, if needed 33362306a36Sopenharmony_ci */ 33462306a36Sopenharmony_cistruct qib_user_info { 33562306a36Sopenharmony_ci /* 33662306a36Sopenharmony_ci * version of user software, to detect compatibility issues. 33762306a36Sopenharmony_ci * Should be set to QIB_USER_SWVERSION. 33862306a36Sopenharmony_ci */ 33962306a36Sopenharmony_ci __u32 spu_userversion; 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci __u32 _spu_unused2; 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci /* size of struct base_info to write to */ 34462306a36Sopenharmony_ci __u32 spu_base_info_size; 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci __u32 spu_port_alg; /* which QIB_PORT_ALG_*; unused user minor < 11 */ 34762306a36Sopenharmony_ci 34862306a36Sopenharmony_ci /* 34962306a36Sopenharmony_ci * If two or more processes wish to share a context, each process 35062306a36Sopenharmony_ci * must set the spu_subctxt_cnt and spu_subctxt_id to the same 35162306a36Sopenharmony_ci * values. The only restriction on the spu_subctxt_id is that 35262306a36Sopenharmony_ci * it be unique for a given node. 35362306a36Sopenharmony_ci */ 35462306a36Sopenharmony_ci __u16 spu_subctxt_cnt; 35562306a36Sopenharmony_ci __u16 spu_subctxt_id; 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci __u32 spu_port; /* IB port requested by user if > 0 */ 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci /* 36062306a36Sopenharmony_ci * address of struct base_info to write to 36162306a36Sopenharmony_ci */ 36262306a36Sopenharmony_ci __u64 spu_base_info; 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci} __aligned(8); 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci/* User commands. */ 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ci/* 16 available, was: old set up userspace (for old user code) */ 36962306a36Sopenharmony_ci#define QIB_CMD_CTXT_INFO 17 /* find out what resources we got */ 37062306a36Sopenharmony_ci#define QIB_CMD_RECV_CTRL 18 /* control receipt of packets */ 37162306a36Sopenharmony_ci#define QIB_CMD_TID_UPDATE 19 /* update expected TID entries */ 37262306a36Sopenharmony_ci#define QIB_CMD_TID_FREE 20 /* free expected TID entries */ 37362306a36Sopenharmony_ci#define QIB_CMD_SET_PART_KEY 21 /* add partition key */ 37462306a36Sopenharmony_ci/* 22 available, was: return info on slave processes (for old user code) */ 37562306a36Sopenharmony_ci#define QIB_CMD_ASSIGN_CTXT 23 /* allocate HCA and ctxt */ 37662306a36Sopenharmony_ci#define QIB_CMD_USER_INIT 24 /* set up userspace */ 37762306a36Sopenharmony_ci#define QIB_CMD_UNUSED_1 25 37862306a36Sopenharmony_ci#define QIB_CMD_UNUSED_2 26 37962306a36Sopenharmony_ci#define QIB_CMD_PIOAVAILUPD 27 /* force an update of PIOAvail reg */ 38062306a36Sopenharmony_ci#define QIB_CMD_POLL_TYPE 28 /* set the kind of polling we want */ 38162306a36Sopenharmony_ci#define QIB_CMD_ARMLAUNCH_CTRL 29 /* armlaunch detection control */ 38262306a36Sopenharmony_ci/* 30 is unused */ 38362306a36Sopenharmony_ci#define QIB_CMD_SDMA_INFLIGHT 31 /* sdma inflight counter request */ 38462306a36Sopenharmony_ci#define QIB_CMD_SDMA_COMPLETE 32 /* sdma completion counter request */ 38562306a36Sopenharmony_ci/* 33 available, was a testing feature */ 38662306a36Sopenharmony_ci#define QIB_CMD_DISARM_BUFS 34 /* disarm send buffers w/ errors */ 38762306a36Sopenharmony_ci#define QIB_CMD_ACK_EVENT 35 /* ack & clear bits */ 38862306a36Sopenharmony_ci#define QIB_CMD_CPUS_LIST 36 /* list of cpus allocated, for pinned 38962306a36Sopenharmony_ci * processes: qib_cpus_list */ 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_ci/* 39262306a36Sopenharmony_ci * QIB_CMD_ACK_EVENT obsoletes QIB_CMD_DISARM_BUFS, but we keep it for 39362306a36Sopenharmony_ci * compatibility with libraries from previous release. The ACK_EVENT 39462306a36Sopenharmony_ci * will take appropriate driver action (if any, just DISARM for now), 39562306a36Sopenharmony_ci * then clear the bits passed in as part of the mask. These bits are 39662306a36Sopenharmony_ci * in the first 64bit word at spi_sendbuf_status, and are passed to 39762306a36Sopenharmony_ci * the driver in the event_mask union as well. 39862306a36Sopenharmony_ci */ 39962306a36Sopenharmony_ci#define _QIB_EVENT_DISARM_BUFS_BIT 0 40062306a36Sopenharmony_ci#define _QIB_EVENT_LINKDOWN_BIT 1 40162306a36Sopenharmony_ci#define _QIB_EVENT_LID_CHANGE_BIT 2 40262306a36Sopenharmony_ci#define _QIB_EVENT_LMC_CHANGE_BIT 3 40362306a36Sopenharmony_ci#define _QIB_EVENT_SL2VL_CHANGE_BIT 4 40462306a36Sopenharmony_ci#define _QIB_MAX_EVENT_BIT _QIB_EVENT_SL2VL_CHANGE_BIT 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci#define QIB_EVENT_DISARM_BUFS_BIT (1UL << _QIB_EVENT_DISARM_BUFS_BIT) 40762306a36Sopenharmony_ci#define QIB_EVENT_LINKDOWN_BIT (1UL << _QIB_EVENT_LINKDOWN_BIT) 40862306a36Sopenharmony_ci#define QIB_EVENT_LID_CHANGE_BIT (1UL << _QIB_EVENT_LID_CHANGE_BIT) 40962306a36Sopenharmony_ci#define QIB_EVENT_LMC_CHANGE_BIT (1UL << _QIB_EVENT_LMC_CHANGE_BIT) 41062306a36Sopenharmony_ci#define QIB_EVENT_SL2VL_CHANGE_BIT (1UL << _QIB_EVENT_SL2VL_CHANGE_BIT) 41162306a36Sopenharmony_ci 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ci/* 41462306a36Sopenharmony_ci * Poll types 41562306a36Sopenharmony_ci */ 41662306a36Sopenharmony_ci#define QIB_POLL_TYPE_ANYRCV 0x0 41762306a36Sopenharmony_ci#define QIB_POLL_TYPE_URGENT 0x1 41862306a36Sopenharmony_ci 41962306a36Sopenharmony_cistruct qib_ctxt_info { 42062306a36Sopenharmony_ci __u16 num_active; /* number of active units */ 42162306a36Sopenharmony_ci __u16 unit; /* unit (chip) assigned to caller */ 42262306a36Sopenharmony_ci __u16 port; /* IB port assigned to caller (1-based) */ 42362306a36Sopenharmony_ci __u16 ctxt; /* ctxt on unit assigned to caller */ 42462306a36Sopenharmony_ci __u16 subctxt; /* subctxt on unit assigned to caller */ 42562306a36Sopenharmony_ci __u16 num_ctxts; /* number of ctxts available on unit */ 42662306a36Sopenharmony_ci __u16 num_subctxts; /* number of subctxts opened on ctxt */ 42762306a36Sopenharmony_ci __u16 rec_cpu; /* cpu # for affinity (ffff if none) */ 42862306a36Sopenharmony_ci}; 42962306a36Sopenharmony_ci 43062306a36Sopenharmony_cistruct qib_tid_info { 43162306a36Sopenharmony_ci __u32 tidcnt; 43262306a36Sopenharmony_ci /* make structure same size in 32 and 64 bit */ 43362306a36Sopenharmony_ci __u32 tid__unused; 43462306a36Sopenharmony_ci /* virtual address of first page in transfer */ 43562306a36Sopenharmony_ci __u64 tidvaddr; 43662306a36Sopenharmony_ci /* pointer (same size 32/64 bit) to __u16 tid array */ 43762306a36Sopenharmony_ci __u64 tidlist; 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_ci /* 44062306a36Sopenharmony_ci * pointer (same size 32/64 bit) to bitmap of TIDs used 44162306a36Sopenharmony_ci * for this call; checked for being large enough at open 44262306a36Sopenharmony_ci */ 44362306a36Sopenharmony_ci __u64 tidmap; 44462306a36Sopenharmony_ci}; 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_cistruct qib_cmd { 44762306a36Sopenharmony_ci __u32 type; /* command type */ 44862306a36Sopenharmony_ci union { 44962306a36Sopenharmony_ci struct qib_tid_info tid_info; 45062306a36Sopenharmony_ci struct qib_user_info user_info; 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci /* 45362306a36Sopenharmony_ci * address in userspace where we should put the sdma 45462306a36Sopenharmony_ci * inflight counter 45562306a36Sopenharmony_ci */ 45662306a36Sopenharmony_ci __u64 sdma_inflight; 45762306a36Sopenharmony_ci /* 45862306a36Sopenharmony_ci * address in userspace where we should put the sdma 45962306a36Sopenharmony_ci * completion counter 46062306a36Sopenharmony_ci */ 46162306a36Sopenharmony_ci __u64 sdma_complete; 46262306a36Sopenharmony_ci /* address in userspace of struct qib_ctxt_info to 46362306a36Sopenharmony_ci write result to */ 46462306a36Sopenharmony_ci __u64 ctxt_info; 46562306a36Sopenharmony_ci /* enable/disable receipt of packets */ 46662306a36Sopenharmony_ci __u32 recv_ctrl; 46762306a36Sopenharmony_ci /* enable/disable armlaunch errors (non-zero to enable) */ 46862306a36Sopenharmony_ci __u32 armlaunch_ctrl; 46962306a36Sopenharmony_ci /* partition key to set */ 47062306a36Sopenharmony_ci __u16 part_key; 47162306a36Sopenharmony_ci /* user address of __u32 bitmask of active slaves */ 47262306a36Sopenharmony_ci __u64 slave_mask_addr; 47362306a36Sopenharmony_ci /* type of polling we want */ 47462306a36Sopenharmony_ci __u16 poll_type; 47562306a36Sopenharmony_ci /* back pressure enable bit for one particular context */ 47662306a36Sopenharmony_ci __u8 ctxt_bp; 47762306a36Sopenharmony_ci /* qib_user_event_ack(), IPATH_EVENT_* bits */ 47862306a36Sopenharmony_ci __u64 event_mask; 47962306a36Sopenharmony_ci } cmd; 48062306a36Sopenharmony_ci}; 48162306a36Sopenharmony_ci 48262306a36Sopenharmony_cistruct qib_iovec { 48362306a36Sopenharmony_ci /* Pointer to data, but same size 32 and 64 bit */ 48462306a36Sopenharmony_ci __u64 iov_base; 48562306a36Sopenharmony_ci 48662306a36Sopenharmony_ci /* 48762306a36Sopenharmony_ci * Length of data; don't need 64 bits, but want 48862306a36Sopenharmony_ci * qib_sendpkt to remain same size as before 32 bit changes, so... 48962306a36Sopenharmony_ci */ 49062306a36Sopenharmony_ci __u64 iov_len; 49162306a36Sopenharmony_ci}; 49262306a36Sopenharmony_ci 49362306a36Sopenharmony_ci/* 49462306a36Sopenharmony_ci * Describes a single packet for send. Each packet can have one or more 49562306a36Sopenharmony_ci * buffers, but the total length (exclusive of IB headers) must be less 49662306a36Sopenharmony_ci * than the MTU, and if using the PIO method, entire packet length, 49762306a36Sopenharmony_ci * including IB headers, must be less than the qib_piosize value (words). 49862306a36Sopenharmony_ci * Use of this necessitates including sys/uio.h 49962306a36Sopenharmony_ci */ 50062306a36Sopenharmony_cistruct __qib_sendpkt { 50162306a36Sopenharmony_ci __u32 sps_flags; /* flags for packet (TBD) */ 50262306a36Sopenharmony_ci __u32 sps_cnt; /* number of entries to use in sps_iov */ 50362306a36Sopenharmony_ci /* array of iov's describing packet. TEMPORARY */ 50462306a36Sopenharmony_ci struct qib_iovec sps_iov[4]; 50562306a36Sopenharmony_ci}; 50662306a36Sopenharmony_ci 50762306a36Sopenharmony_ci/* 50862306a36Sopenharmony_ci * Diagnostics can send a packet by "writing" the following 50962306a36Sopenharmony_ci * structs to the diag data special file. 51062306a36Sopenharmony_ci * This allows a custom 51162306a36Sopenharmony_ci * pbc (+ static rate) qword, so that special modes and deliberate 51262306a36Sopenharmony_ci * changes to CRCs can be used. The elements were also re-ordered 51362306a36Sopenharmony_ci * for better alignment and to avoid padding issues. 51462306a36Sopenharmony_ci */ 51562306a36Sopenharmony_ci#define _DIAG_XPKT_VERS 3 51662306a36Sopenharmony_cistruct qib_diag_xpkt { 51762306a36Sopenharmony_ci __u16 version; 51862306a36Sopenharmony_ci __u16 unit; 51962306a36Sopenharmony_ci __u16 port; 52062306a36Sopenharmony_ci __u16 len; 52162306a36Sopenharmony_ci __u64 data; 52262306a36Sopenharmony_ci __u64 pbc_wd; 52362306a36Sopenharmony_ci}; 52462306a36Sopenharmony_ci 52562306a36Sopenharmony_ci/* 52662306a36Sopenharmony_ci * Data layout in I2C flash (for GUID, etc.) 52762306a36Sopenharmony_ci * All fields are little-endian binary unless otherwise stated 52862306a36Sopenharmony_ci */ 52962306a36Sopenharmony_ci#define QIB_FLASH_VERSION 2 53062306a36Sopenharmony_cistruct qib_flash { 53162306a36Sopenharmony_ci /* flash layout version (QIB_FLASH_VERSION) */ 53262306a36Sopenharmony_ci __u8 if_fversion; 53362306a36Sopenharmony_ci /* checksum protecting if_length bytes */ 53462306a36Sopenharmony_ci __u8 if_csum; 53562306a36Sopenharmony_ci /* 53662306a36Sopenharmony_ci * valid length (in use, protected by if_csum), including 53762306a36Sopenharmony_ci * if_fversion and if_csum themselves) 53862306a36Sopenharmony_ci */ 53962306a36Sopenharmony_ci __u8 if_length; 54062306a36Sopenharmony_ci /* the GUID, in network order */ 54162306a36Sopenharmony_ci __u8 if_guid[8]; 54262306a36Sopenharmony_ci /* number of GUIDs to use, starting from if_guid */ 54362306a36Sopenharmony_ci __u8 if_numguid; 54462306a36Sopenharmony_ci /* the (last 10 characters of) board serial number, in ASCII */ 54562306a36Sopenharmony_ci char if_serial[12]; 54662306a36Sopenharmony_ci /* board mfg date (YYYYMMDD ASCII) */ 54762306a36Sopenharmony_ci char if_mfgdate[8]; 54862306a36Sopenharmony_ci /* last board rework/test date (YYYYMMDD ASCII) */ 54962306a36Sopenharmony_ci char if_testdate[8]; 55062306a36Sopenharmony_ci /* logging of error counts, TBD */ 55162306a36Sopenharmony_ci __u8 if_errcntp[4]; 55262306a36Sopenharmony_ci /* powered on hours, updated at driver unload */ 55362306a36Sopenharmony_ci __u8 if_powerhour[2]; 55462306a36Sopenharmony_ci /* ASCII free-form comment field */ 55562306a36Sopenharmony_ci char if_comment[32]; 55662306a36Sopenharmony_ci /* Backwards compatible prefix for longer QLogic Serial Numbers */ 55762306a36Sopenharmony_ci char if_sprefix[4]; 55862306a36Sopenharmony_ci /* 82 bytes used, min flash size is 128 bytes */ 55962306a36Sopenharmony_ci __u8 if_future[46]; 56062306a36Sopenharmony_ci}; 56162306a36Sopenharmony_ci 56262306a36Sopenharmony_ci/* 56362306a36Sopenharmony_ci * These are the counters implemented in the chip, and are listed in order. 56462306a36Sopenharmony_ci * The InterCaps naming is taken straight from the chip spec. 56562306a36Sopenharmony_ci */ 56662306a36Sopenharmony_cistruct qlogic_ib_counters { 56762306a36Sopenharmony_ci __u64 LBIntCnt; 56862306a36Sopenharmony_ci __u64 LBFlowStallCnt; 56962306a36Sopenharmony_ci __u64 TxSDmaDescCnt; /* was Reserved1 */ 57062306a36Sopenharmony_ci __u64 TxUnsupVLErrCnt; 57162306a36Sopenharmony_ci __u64 TxDataPktCnt; 57262306a36Sopenharmony_ci __u64 TxFlowPktCnt; 57362306a36Sopenharmony_ci __u64 TxDwordCnt; 57462306a36Sopenharmony_ci __u64 TxLenErrCnt; 57562306a36Sopenharmony_ci __u64 TxMaxMinLenErrCnt; 57662306a36Sopenharmony_ci __u64 TxUnderrunCnt; 57762306a36Sopenharmony_ci __u64 TxFlowStallCnt; 57862306a36Sopenharmony_ci __u64 TxDroppedPktCnt; 57962306a36Sopenharmony_ci __u64 RxDroppedPktCnt; 58062306a36Sopenharmony_ci __u64 RxDataPktCnt; 58162306a36Sopenharmony_ci __u64 RxFlowPktCnt; 58262306a36Sopenharmony_ci __u64 RxDwordCnt; 58362306a36Sopenharmony_ci __u64 RxLenErrCnt; 58462306a36Sopenharmony_ci __u64 RxMaxMinLenErrCnt; 58562306a36Sopenharmony_ci __u64 RxICRCErrCnt; 58662306a36Sopenharmony_ci __u64 RxVCRCErrCnt; 58762306a36Sopenharmony_ci __u64 RxFlowCtrlErrCnt; 58862306a36Sopenharmony_ci __u64 RxBadFormatCnt; 58962306a36Sopenharmony_ci __u64 RxLinkProblemCnt; 59062306a36Sopenharmony_ci __u64 RxEBPCnt; 59162306a36Sopenharmony_ci __u64 RxLPCRCErrCnt; 59262306a36Sopenharmony_ci __u64 RxBufOvflCnt; 59362306a36Sopenharmony_ci __u64 RxTIDFullErrCnt; 59462306a36Sopenharmony_ci __u64 RxTIDValidErrCnt; 59562306a36Sopenharmony_ci __u64 RxPKeyMismatchCnt; 59662306a36Sopenharmony_ci __u64 RxP0HdrEgrOvflCnt; 59762306a36Sopenharmony_ci __u64 RxP1HdrEgrOvflCnt; 59862306a36Sopenharmony_ci __u64 RxP2HdrEgrOvflCnt; 59962306a36Sopenharmony_ci __u64 RxP3HdrEgrOvflCnt; 60062306a36Sopenharmony_ci __u64 RxP4HdrEgrOvflCnt; 60162306a36Sopenharmony_ci __u64 RxP5HdrEgrOvflCnt; 60262306a36Sopenharmony_ci __u64 RxP6HdrEgrOvflCnt; 60362306a36Sopenharmony_ci __u64 RxP7HdrEgrOvflCnt; 60462306a36Sopenharmony_ci __u64 RxP8HdrEgrOvflCnt; 60562306a36Sopenharmony_ci __u64 RxP9HdrEgrOvflCnt; 60662306a36Sopenharmony_ci __u64 RxP10HdrEgrOvflCnt; 60762306a36Sopenharmony_ci __u64 RxP11HdrEgrOvflCnt; 60862306a36Sopenharmony_ci __u64 RxP12HdrEgrOvflCnt; 60962306a36Sopenharmony_ci __u64 RxP13HdrEgrOvflCnt; 61062306a36Sopenharmony_ci __u64 RxP14HdrEgrOvflCnt; 61162306a36Sopenharmony_ci __u64 RxP15HdrEgrOvflCnt; 61262306a36Sopenharmony_ci __u64 RxP16HdrEgrOvflCnt; 61362306a36Sopenharmony_ci __u64 IBStatusChangeCnt; 61462306a36Sopenharmony_ci __u64 IBLinkErrRecoveryCnt; 61562306a36Sopenharmony_ci __u64 IBLinkDownedCnt; 61662306a36Sopenharmony_ci __u64 IBSymbolErrCnt; 61762306a36Sopenharmony_ci __u64 RxVL15DroppedPktCnt; 61862306a36Sopenharmony_ci __u64 RxOtherLocalPhyErrCnt; 61962306a36Sopenharmony_ci __u64 PcieRetryBufDiagQwordCnt; 62062306a36Sopenharmony_ci __u64 ExcessBufferOvflCnt; 62162306a36Sopenharmony_ci __u64 LocalLinkIntegrityErrCnt; 62262306a36Sopenharmony_ci __u64 RxVlErrCnt; 62362306a36Sopenharmony_ci __u64 RxDlidFltrCnt; 62462306a36Sopenharmony_ci}; 62562306a36Sopenharmony_ci 62662306a36Sopenharmony_ci/* 62762306a36Sopenharmony_ci * The next set of defines are for packet headers, and chip register 62862306a36Sopenharmony_ci * and memory bits that are visible to and/or used by user-mode software. 62962306a36Sopenharmony_ci */ 63062306a36Sopenharmony_ci 63162306a36Sopenharmony_ci/* RcvHdrFlags bits */ 63262306a36Sopenharmony_ci#define QLOGIC_IB_RHF_LENGTH_MASK 0x7FF 63362306a36Sopenharmony_ci#define QLOGIC_IB_RHF_LENGTH_SHIFT 0 63462306a36Sopenharmony_ci#define QLOGIC_IB_RHF_RCVTYPE_MASK 0x7 63562306a36Sopenharmony_ci#define QLOGIC_IB_RHF_RCVTYPE_SHIFT 11 63662306a36Sopenharmony_ci#define QLOGIC_IB_RHF_EGRINDEX_MASK 0xFFF 63762306a36Sopenharmony_ci#define QLOGIC_IB_RHF_EGRINDEX_SHIFT 16 63862306a36Sopenharmony_ci#define QLOGIC_IB_RHF_SEQ_MASK 0xF 63962306a36Sopenharmony_ci#define QLOGIC_IB_RHF_SEQ_SHIFT 0 64062306a36Sopenharmony_ci#define QLOGIC_IB_RHF_HDRQ_OFFSET_MASK 0x7FF 64162306a36Sopenharmony_ci#define QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT 4 64262306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_ICRCERR 0x80000000 64362306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_VCRCERR 0x40000000 64462306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_PARITYERR 0x20000000 64562306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_LENERR 0x10000000 64662306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_MTUERR 0x08000000 64762306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_IHDRERR 0x04000000 64862306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_TIDERR 0x02000000 64962306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_MKERR 0x01000000 65062306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_IBERR 0x00800000 65162306a36Sopenharmony_ci#define QLOGIC_IB_RHF_H_ERR_MASK 0xFF800000 65262306a36Sopenharmony_ci#define QLOGIC_IB_RHF_L_USE_EGR 0x80000000 65362306a36Sopenharmony_ci#define QLOGIC_IB_RHF_L_SWA 0x00008000 65462306a36Sopenharmony_ci#define QLOGIC_IB_RHF_L_SWB 0x00004000 65562306a36Sopenharmony_ci 65662306a36Sopenharmony_ci/* qlogic_ib header fields */ 65762306a36Sopenharmony_ci#define QLOGIC_IB_I_VERS_MASK 0xF 65862306a36Sopenharmony_ci#define QLOGIC_IB_I_VERS_SHIFT 28 65962306a36Sopenharmony_ci#define QLOGIC_IB_I_CTXT_MASK 0xF 66062306a36Sopenharmony_ci#define QLOGIC_IB_I_CTXT_SHIFT 24 66162306a36Sopenharmony_ci#define QLOGIC_IB_I_TID_MASK 0x7FF 66262306a36Sopenharmony_ci#define QLOGIC_IB_I_TID_SHIFT 13 66362306a36Sopenharmony_ci#define QLOGIC_IB_I_OFFSET_MASK 0x1FFF 66462306a36Sopenharmony_ci#define QLOGIC_IB_I_OFFSET_SHIFT 0 66562306a36Sopenharmony_ci 66662306a36Sopenharmony_ci/* K_PktFlags bits */ 66762306a36Sopenharmony_ci#define QLOGIC_IB_KPF_INTR 0x1 66862306a36Sopenharmony_ci#define QLOGIC_IB_KPF_SUBCTXT_MASK 0x3 66962306a36Sopenharmony_ci#define QLOGIC_IB_KPF_SUBCTXT_SHIFT 1 67062306a36Sopenharmony_ci 67162306a36Sopenharmony_ci#define QLOGIC_IB_MAX_SUBCTXT 4 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_ci/* SendPIO per-buffer control */ 67462306a36Sopenharmony_ci#define QLOGIC_IB_SP_TEST 0x40 67562306a36Sopenharmony_ci#define QLOGIC_IB_SP_TESTEBP 0x20 67662306a36Sopenharmony_ci#define QLOGIC_IB_SP_TRIGGER_SHIFT 15 67762306a36Sopenharmony_ci 67862306a36Sopenharmony_ci/* SendPIOAvail bits */ 67962306a36Sopenharmony_ci#define QLOGIC_IB_SENDPIOAVAIL_BUSY_SHIFT 1 68062306a36Sopenharmony_ci#define QLOGIC_IB_SENDPIOAVAIL_CHECK_SHIFT 0 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_ci/* qlogic_ib header format */ 68362306a36Sopenharmony_cistruct qib_header { 68462306a36Sopenharmony_ci /* 68562306a36Sopenharmony_ci * Version - 4 bits, Context - 4 bits, TID - 10 bits and Offset - 68662306a36Sopenharmony_ci * 14 bits before ECO change ~28 Dec 03. After that, Vers 4, 68762306a36Sopenharmony_ci * Context 4, TID 11, offset 13. 68862306a36Sopenharmony_ci */ 68962306a36Sopenharmony_ci __le32 ver_ctxt_tid_offset; 69062306a36Sopenharmony_ci __le16 chksum; 69162306a36Sopenharmony_ci __le16 pkt_flags; 69262306a36Sopenharmony_ci}; 69362306a36Sopenharmony_ci 69462306a36Sopenharmony_ci/* 69562306a36Sopenharmony_ci * qlogic_ib user message header format. 69662306a36Sopenharmony_ci * This structure contains the first 4 fields common to all protocols 69762306a36Sopenharmony_ci * that employ qlogic_ib. 69862306a36Sopenharmony_ci */ 69962306a36Sopenharmony_cistruct qib_message_header { 70062306a36Sopenharmony_ci __be16 lrh[4]; 70162306a36Sopenharmony_ci __be32 bth[3]; 70262306a36Sopenharmony_ci /* fields below this point are in host byte order */ 70362306a36Sopenharmony_ci struct qib_header iph; 70462306a36Sopenharmony_ci /* fields below are simplified, but should match PSM */ 70562306a36Sopenharmony_ci /* some are accessed by driver when packet spliting is needed */ 70662306a36Sopenharmony_ci __u8 sub_opcode; 70762306a36Sopenharmony_ci __u8 flags; 70862306a36Sopenharmony_ci __u16 commidx; 70962306a36Sopenharmony_ci __u32 ack_seq_num; 71062306a36Sopenharmony_ci __u8 flowid; 71162306a36Sopenharmony_ci __u8 hdr_dlen; 71262306a36Sopenharmony_ci __u16 mqhdr; 71362306a36Sopenharmony_ci __u32 uwords[4]; 71462306a36Sopenharmony_ci}; 71562306a36Sopenharmony_ci 71662306a36Sopenharmony_ci/* sequence number bits for message */ 71762306a36Sopenharmony_ciunion qib_seqnum { 71862306a36Sopenharmony_ci struct { 71962306a36Sopenharmony_ci __u32 seq:11; 72062306a36Sopenharmony_ci __u32 gen:8; 72162306a36Sopenharmony_ci __u32 flow:5; 72262306a36Sopenharmony_ci }; 72362306a36Sopenharmony_ci struct { 72462306a36Sopenharmony_ci __u32 pkt:16; 72562306a36Sopenharmony_ci __u32 msg:8; 72662306a36Sopenharmony_ci }; 72762306a36Sopenharmony_ci __u32 val; 72862306a36Sopenharmony_ci}; 72962306a36Sopenharmony_ci 73062306a36Sopenharmony_ci/* qib receiving-dma tid-session-member */ 73162306a36Sopenharmony_cistruct qib_tid_session_member { 73262306a36Sopenharmony_ci __u16 tid; 73362306a36Sopenharmony_ci __u16 offset; 73462306a36Sopenharmony_ci __u16 length; 73562306a36Sopenharmony_ci}; 73662306a36Sopenharmony_ci 73762306a36Sopenharmony_ci/* IB - LRH header consts */ 73862306a36Sopenharmony_ci#define QIB_LRH_GRH 0x0003 /* 1. word of IB LRH - next header: GRH */ 73962306a36Sopenharmony_ci#define QIB_LRH_BTH 0x0002 /* 1. word of IB LRH - next header: BTH */ 74062306a36Sopenharmony_ci 74162306a36Sopenharmony_ci/* misc. */ 74262306a36Sopenharmony_ci#define SIZE_OF_CRC 1 74362306a36Sopenharmony_ci 74462306a36Sopenharmony_ci#define QIB_DEFAULT_P_KEY 0xFFFF 74562306a36Sopenharmony_ci#define QIB_PSN_MASK 0xFFFFFF 74662306a36Sopenharmony_ci#define QIB_EAGER_TID_ID QLOGIC_IB_I_TID_MASK 74762306a36Sopenharmony_ci#define QIB_MULTICAST_QPN 0xFFFFFF 74862306a36Sopenharmony_ci 74962306a36Sopenharmony_ci/* Receive Header Queue: receive type (from qlogic_ib) */ 75062306a36Sopenharmony_ci#define RCVHQ_RCV_TYPE_EXPECTED 0 75162306a36Sopenharmony_ci#define RCVHQ_RCV_TYPE_EAGER 1 75262306a36Sopenharmony_ci#define RCVHQ_RCV_TYPE_NON_KD 2 75362306a36Sopenharmony_ci#define RCVHQ_RCV_TYPE_ERROR 3 75462306a36Sopenharmony_ci 75562306a36Sopenharmony_ci#define QIB_HEADER_QUEUE_WORDS 9 75662306a36Sopenharmony_ci 75762306a36Sopenharmony_ci/* functions for extracting fields from rcvhdrq entries for the driver. 75862306a36Sopenharmony_ci */ 75962306a36Sopenharmony_cistatic inline __u32 qib_hdrget_err_flags(const __le32 *rbuf) 76062306a36Sopenharmony_ci{ 76162306a36Sopenharmony_ci return __le32_to_cpu(rbuf[1]) & QLOGIC_IB_RHF_H_ERR_MASK; 76262306a36Sopenharmony_ci} 76362306a36Sopenharmony_ci 76462306a36Sopenharmony_cistatic inline __u32 qib_hdrget_rcv_type(const __le32 *rbuf) 76562306a36Sopenharmony_ci{ 76662306a36Sopenharmony_ci return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_RCVTYPE_SHIFT) & 76762306a36Sopenharmony_ci QLOGIC_IB_RHF_RCVTYPE_MASK; 76862306a36Sopenharmony_ci} 76962306a36Sopenharmony_ci 77062306a36Sopenharmony_cistatic inline __u32 qib_hdrget_length_in_bytes(const __le32 *rbuf) 77162306a36Sopenharmony_ci{ 77262306a36Sopenharmony_ci return ((__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_LENGTH_SHIFT) & 77362306a36Sopenharmony_ci QLOGIC_IB_RHF_LENGTH_MASK) << 2; 77462306a36Sopenharmony_ci} 77562306a36Sopenharmony_ci 77662306a36Sopenharmony_cistatic inline __u32 qib_hdrget_index(const __le32 *rbuf) 77762306a36Sopenharmony_ci{ 77862306a36Sopenharmony_ci return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_EGRINDEX_SHIFT) & 77962306a36Sopenharmony_ci QLOGIC_IB_RHF_EGRINDEX_MASK; 78062306a36Sopenharmony_ci} 78162306a36Sopenharmony_ci 78262306a36Sopenharmony_cistatic inline __u32 qib_hdrget_seq(const __le32 *rbuf) 78362306a36Sopenharmony_ci{ 78462306a36Sopenharmony_ci return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_SEQ_SHIFT) & 78562306a36Sopenharmony_ci QLOGIC_IB_RHF_SEQ_MASK; 78662306a36Sopenharmony_ci} 78762306a36Sopenharmony_ci 78862306a36Sopenharmony_cistatic inline __u32 qib_hdrget_offset(const __le32 *rbuf) 78962306a36Sopenharmony_ci{ 79062306a36Sopenharmony_ci return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT) & 79162306a36Sopenharmony_ci QLOGIC_IB_RHF_HDRQ_OFFSET_MASK; 79262306a36Sopenharmony_ci} 79362306a36Sopenharmony_ci 79462306a36Sopenharmony_cistatic inline __u32 qib_hdrget_use_egr_buf(const __le32 *rbuf) 79562306a36Sopenharmony_ci{ 79662306a36Sopenharmony_ci return __le32_to_cpu(rbuf[0]) & QLOGIC_IB_RHF_L_USE_EGR; 79762306a36Sopenharmony_ci} 79862306a36Sopenharmony_ci#endif /* _QIB_COMMON_H */ 799