Path: blob/master/drivers/infiniband/hw/ipath/ipath_common.h
15112 views
/*1* Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.2* Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.3*4* This software is available to you under a choice of one of two5* licenses. You may choose to be licensed under the terms of the GNU6* General Public License (GPL) Version 2, available from the file7* COPYING in the main directory of this source tree, or the8* OpenIB.org BSD license below:9*10* Redistribution and use in source and binary forms, with or11* without modification, are permitted provided that the following12* conditions are met:13*14* - Redistributions of source code must retain the above15* copyright notice, this list of conditions and the following16* disclaimer.17*18* - Redistributions in binary form must reproduce the above19* copyright notice, this list of conditions and the following20* disclaimer in the documentation and/or other materials21* provided with the distribution.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30* SOFTWARE.31*/3233#ifndef _IPATH_COMMON_H34#define _IPATH_COMMON_H3536/*37* This file contains defines, structures, etc. that are used38* to communicate between kernel and user code.39*/404142/* This is the IEEE-assigned OUI for QLogic Inc. InfiniPath */43#define IPATH_SRC_OUI_1 0x0044#define IPATH_SRC_OUI_2 0x1145#define IPATH_SRC_OUI_3 0x754647/* version of protocol header (known to chip also). In the long run,48* we should be able to generate and accept a range of version numbers;49* for now we only accept one, and it's compiled in.50*/51#define IPS_PROTO_VERSION 25253/*54* These are compile time constants that you may want to enable or disable55* if you are trying to debug problems with code or performance.56* IPATH_VERBOSE_TRACING define as 1 if you want additional tracing in57* fastpath code58* IPATH_TRACE_REGWRITES define as 1 if you want register writes to be59* traced in faspath code60* _IPATH_TRACING define as 0 if you want to remove all tracing in a61* compilation unit62* _IPATH_DEBUGGING define as 0 if you want to remove debug prints63*/6465/*66* The value in the BTH QP field that InfiniPath uses to differentiate67* an infinipath protocol IB packet vs standard IB transport68*/69#define IPATH_KD_QP 0x656b797071/*72* valid states passed to ipath_set_linkstate() user call73*/74#define IPATH_IB_LINKDOWN 075#define IPATH_IB_LINKARM 176#define IPATH_IB_LINKACTIVE 277#define IPATH_IB_LINKDOWN_ONLY 378#define IPATH_IB_LINKDOWN_SLEEP 479#define IPATH_IB_LINKDOWN_DISABLE 580#define IPATH_IB_LINK_LOOPBACK 6 /* enable local loopback */81#define IPATH_IB_LINK_EXTERNAL 7 /* normal, disable local loopback */82#define IPATH_IB_LINK_NO_HRTBT 8 /* disable Heartbeat, e.g. for loopback */83#define IPATH_IB_LINK_HRTBT 9 /* enable heartbeat, normal, non-loopback */8485/*86* These 3 values (SDR and DDR may be ORed for auto-speed87* negotiation) are used for the 3rd argument to path_f_set_ib_cfg88* with cmd IPATH_IB_CFG_SPD_ENB, by direct calls or via sysfs. They89* are also the the possible values for ipath_link_speed_enabled and active90* The values were chosen to match values used within the IB spec.91*/92#define IPATH_IB_SDR 193#define IPATH_IB_DDR 29495/*96* stats maintained by the driver. For now, at least, this is global97* to all minor devices.98*/99struct infinipath_stats {100/* number of interrupts taken */101__u64 sps_ints;102/* number of interrupts for errors */103__u64 sps_errints;104/* number of errors from chip (not incl. packet errors or CRC) */105__u64 sps_errs;106/* number of packet errors from chip other than CRC */107__u64 sps_pkterrs;108/* number of packets with CRC errors (ICRC and VCRC) */109__u64 sps_crcerrs;110/* number of hardware errors reported (parity, etc.) */111__u64 sps_hwerrs;112/* number of times IB link changed state unexpectedly */113__u64 sps_iblink;114__u64 sps_unused; /* was fastrcvint, no longer implemented */115/* number of kernel (port0) packets received */116__u64 sps_port0pkts;117/* number of "ethernet" packets sent by driver */118__u64 sps_ether_spkts;119/* number of "ethernet" packets received by driver */120__u64 sps_ether_rpkts;121/* number of SMA packets sent by driver. Obsolete. */122__u64 sps_sma_spkts;123/* number of SMA packets received by driver. Obsolete. */124__u64 sps_sma_rpkts;125/* number of times all ports rcvhdrq was full and packet dropped */126__u64 sps_hdrqfull;127/* number of times all ports egrtid was full and packet dropped */128__u64 sps_etidfull;129/*130* number of times we tried to send from driver, but no pio buffers131* avail132*/133__u64 sps_nopiobufs;134/* number of ports currently open */135__u64 sps_ports;136/* list of pkeys (other than default) accepted (0 means not set) */137__u16 sps_pkeys[4];138__u16 sps_unused16[4]; /* available; maintaining compatible layout */139/* number of user ports per chip (not IB ports) */140__u32 sps_nports;141/* not our interrupt, or already handled */142__u32 sps_nullintr;143/* max number of packets handled per receive call */144__u32 sps_maxpkts_call;145/* avg number of packets handled per receive call */146__u32 sps_avgpkts_call;147/* total number of pages locked */148__u64 sps_pagelocks;149/* total number of pages unlocked */150__u64 sps_pageunlocks;151/*152* Number of packets dropped in kernel other than errors (ether153* packets if ipath not configured, etc.)154*/155__u64 sps_krdrops;156__u64 sps_txeparity; /* PIO buffer parity error, recovered */157/* pad for future growth */158__u64 __sps_pad[45];159};160161/*162* These are the status bits readable (in ascii form, 64bit value)163* from the "status" sysfs file.164*/165#define IPATH_STATUS_INITTED 0x1 /* basic initialization done */166#define IPATH_STATUS_DISABLED 0x2 /* hardware disabled */167/* Device has been disabled via admin request */168#define IPATH_STATUS_ADMIN_DISABLED 0x4169/* Chip has been found and initted */170#define IPATH_STATUS_CHIP_PRESENT 0x20171/* IB link is at ACTIVE, usable for data traffic */172#define IPATH_STATUS_IB_READY 0x40173/* link is configured, LID, MTU, etc. have been set */174#define IPATH_STATUS_IB_CONF 0x80175/* no link established, probably no cable */176#define IPATH_STATUS_IB_NOCABLE 0x100177/* A Fatal hardware error has occurred. */178#define IPATH_STATUS_HWERROR 0x200179180/*181* The list of usermode accessible registers. Also see Reg_* later in file.182*/183typedef enum _ipath_ureg {184/* (RO) DMA RcvHdr to be used next. */185ur_rcvhdrtail = 0,186/* (RW) RcvHdr entry to be processed next by host. */187ur_rcvhdrhead = 1,188/* (RO) Index of next Eager index to use. */189ur_rcvegrindextail = 2,190/* (RW) Eager TID to be processed next */191ur_rcvegrindexhead = 3,192/* For internal use only; max register number. */193_IPATH_UregMax194} ipath_ureg;195196/* bit values for spi_runtime_flags */197#define IPATH_RUNTIME_HT 0x1198#define IPATH_RUNTIME_PCIE 0x2199#define IPATH_RUNTIME_FORCE_WC_ORDER 0x4200#define IPATH_RUNTIME_RCVHDR_COPY 0x8201#define IPATH_RUNTIME_MASTER 0x10202#define IPATH_RUNTIME_NODMA_RTAIL 0x80203#define IPATH_RUNTIME_SDMA 0x200204#define IPATH_RUNTIME_FORCE_PIOAVAIL 0x400205#define IPATH_RUNTIME_PIO_REGSWAPPED 0x800206207/*208* This structure is returned by ipath_userinit() immediately after209* open to get implementation-specific info, and info specific to this210* instance.211*212* This struct must have explict pad fields where type sizes213* may result in different alignments between 32 and 64 bit214* programs, since the 64 bit * bit kernel requires the user code215* to have matching offsets216*/217struct ipath_base_info {218/* version of hardware, for feature checking. */219__u32 spi_hw_version;220/* version of software, for feature checking. */221__u32 spi_sw_version;222/* InfiniPath port assigned, goes into sent packets */223__u16 spi_port;224__u16 spi_subport;225/*226* IB MTU, packets IB data must be less than this.227* The MTU is in bytes, and will be a multiple of 4 bytes.228*/229__u32 spi_mtu;230/*231* Size of a PIO buffer. Any given packet's total size must be less232* than this (in words). Included is the starting control word, so233* if 513 is returned, then total pkt size is 512 words or less.234*/235__u32 spi_piosize;236/* size of the TID cache in infinipath, in entries */237__u32 spi_tidcnt;238/* size of the TID Eager list in infinipath, in entries */239__u32 spi_tidegrcnt;240/* size of a single receive header queue entry in words. */241__u32 spi_rcvhdrent_size;242/*243* Count of receive header queue entries allocated.244* This may be less than the spu_rcvhdrcnt passed in!.245*/246__u32 spi_rcvhdr_cnt;247248/* per-chip and other runtime features bitmap (IPATH_RUNTIME_*) */249__u32 spi_runtime_flags;250251/* address where receive buffer queue is mapped into */252__u64 spi_rcvhdr_base;253254/* user program. */255256/* base address of eager TID receive buffers. */257__u64 spi_rcv_egrbufs;258259/* Allocated by initialization code, not by protocol. */260261/*262* Size of each TID buffer in host memory, starting at263* spi_rcv_egrbufs. The buffers are virtually contiguous.264*/265__u32 spi_rcv_egrbufsize;266/*267* The special QP (queue pair) value that identifies an infinipath268* protocol packet from standard IB packets. More, probably much269* more, to be added.270*/271__u32 spi_qpair;272273/*274* User register base for init code, not to be used directly by275* protocol or applications.276*/277__u64 __spi_uregbase;278/*279* Maximum buffer size in bytes that can be used in a single TID280* entry (assuming the buffer is aligned to this boundary). This is281* the minimum of what the hardware and software support Guaranteed282* to be a power of 2.283*/284__u32 spi_tid_maxsize;285/*286* alignment of each pio send buffer (byte count287* to add to spi_piobufbase to get to second buffer)288*/289__u32 spi_pioalign;290/*291* The index of the first pio buffer available to this process;292* needed to do lookup in spi_pioavailaddr; not added to293* spi_piobufbase.294*/295__u32 spi_pioindex;296/* number of buffers mapped for this process */297__u32 spi_piocnt;298299/*300* Base address of writeonly pio buffers for this process.301* Each buffer has spi_piosize words, and is aligned on spi_pioalign302* boundaries. spi_piocnt buffers are mapped from this address303*/304__u64 spi_piobufbase;305306/*307* Base address of readonly memory copy of the pioavail registers.308* There are 2 bits for each buffer.309*/310__u64 spi_pioavailaddr;311312/*313* Address where driver updates a copy of the interface and driver314* status (IPATH_STATUS_*) as a 64 bit value. It's followed by a315* string indicating hardware error, if there was one.316*/317__u64 spi_status;318319/* number of chip ports available to user processes */320__u32 spi_nports;321/* unit number of chip we are using */322__u32 spi_unit;323/* num bufs in each contiguous set */324__u32 spi_rcv_egrperchunk;325/* size in bytes of each contiguous set */326__u32 spi_rcv_egrchunksize;327/* total size of mmap to cover full rcvegrbuffers */328__u32 spi_rcv_egrbuftotlen;329__u32 spi_filler_for_align;330/* address of readonly memory copy of the rcvhdrq tail register. */331__u64 spi_rcvhdr_tailaddr;332333/* shared memory pages for subports if port is shared */334__u64 spi_subport_uregbase;335__u64 spi_subport_rcvegrbuf;336__u64 spi_subport_rcvhdr_base;337338/* shared memory page for hardware port if it is shared */339__u64 spi_port_uregbase;340__u64 spi_port_rcvegrbuf;341__u64 spi_port_rcvhdr_base;342__u64 spi_port_rcvhdr_tailaddr;343344} __attribute__ ((aligned(8)));345346347/*348* This version number is given to the driver by the user code during349* initialization in the spu_userversion field of ipath_user_info, so350* the driver can check for compatibility with user code.351*352* The major version changes when data structures353* change in an incompatible way. The driver must be the same or higher354* for initialization to succeed. In some cases, a higher version355* driver will not interoperate with older software, and initialization356* will return an error.357*/358#define IPATH_USER_SWMAJOR 1359360/*361* Minor version differences are always compatible362* a within a major version, however if user software is larger363* than driver software, some new features and/or structure fields364* may not be implemented; the user code must deal with this if it365* cares, or it must abort after initialization reports the difference.366*/367#define IPATH_USER_SWMINOR 6368369#define IPATH_USER_SWVERSION ((IPATH_USER_SWMAJOR<<16) | IPATH_USER_SWMINOR)370371#define IPATH_KERN_TYPE 0372373/*374* Similarly, this is the kernel version going back to the user. It's375* slightly different, in that we want to tell if the driver was built as376* part of a QLogic release, or from the driver from openfabrics.org,377* kernel.org, or a standard distribution, for support reasons.378* The high bit is 0 for non-QLogic and 1 for QLogic-built/supplied.379*380* It's returned by the driver to the user code during initialization in the381* spi_sw_version field of ipath_base_info, so the user code can in turn382* check for compatibility with the kernel.383*/384#define IPATH_KERN_SWVERSION ((IPATH_KERN_TYPE<<31) | IPATH_USER_SWVERSION)385386/*387* This structure is passed to ipath_userinit() to tell the driver where388* user code buffers are, sizes, etc. The offsets and sizes of the389* fields must remain unchanged, for binary compatibility. It can390* be extended, if userversion is changed so user code can tell, if needed391*/392struct ipath_user_info {393/*394* version of user software, to detect compatibility issues.395* Should be set to IPATH_USER_SWVERSION.396*/397__u32 spu_userversion;398399/* desired number of receive header queue entries */400__u32 spu_rcvhdrcnt;401402/* size of struct base_info to write to */403__u32 spu_base_info_size;404405/*406* number of words in KD protocol header407* This tells InfiniPath how many words to copy to rcvhdrq. If 0,408* kernel uses a default. Once set, attempts to set any other value409* are an error (EAGAIN) until driver is reloaded.410*/411__u32 spu_rcvhdrsize;412413/*414* If two or more processes wish to share a port, each process415* must set the spu_subport_cnt and spu_subport_id to the same416* values. The only restriction on the spu_subport_id is that417* it be unique for a given node.418*/419__u16 spu_subport_cnt;420__u16 spu_subport_id;421422__u32 spu_unused; /* kept for compatible layout */423424/*425* address of struct base_info to write to426*/427__u64 spu_base_info;428429} __attribute__ ((aligned(8)));430431/* User commands. */432433#define IPATH_CMD_MIN 16434435#define __IPATH_CMD_USER_INIT 16 /* old set up userspace (for old user code) */436#define IPATH_CMD_PORT_INFO 17 /* find out what resources we got */437#define IPATH_CMD_RECV_CTRL 18 /* control receipt of packets */438#define IPATH_CMD_TID_UPDATE 19 /* update expected TID entries */439#define IPATH_CMD_TID_FREE 20 /* free expected TID entries */440#define IPATH_CMD_SET_PART_KEY 21 /* add partition key */441#define __IPATH_CMD_SLAVE_INFO 22 /* return info on slave processes (for old user code) */442#define IPATH_CMD_ASSIGN_PORT 23 /* allocate HCA and port */443#define IPATH_CMD_USER_INIT 24 /* set up userspace */444#define IPATH_CMD_UNUSED_1 25445#define IPATH_CMD_UNUSED_2 26446#define IPATH_CMD_PIOAVAILUPD 27 /* force an update of PIOAvail reg */447#define IPATH_CMD_POLL_TYPE 28 /* set the kind of polling we want */448#define IPATH_CMD_ARMLAUNCH_CTRL 29 /* armlaunch detection control */449/* 30 is unused */450#define IPATH_CMD_SDMA_INFLIGHT 31 /* sdma inflight counter request */451#define IPATH_CMD_SDMA_COMPLETE 32 /* sdma completion counter request */452453/*454* Poll types455*/456#define IPATH_POLL_TYPE_URGENT 0x01457#define IPATH_POLL_TYPE_OVERFLOW 0x02458459struct ipath_port_info {460__u32 num_active; /* number of active units */461__u32 unit; /* unit (chip) assigned to caller */462__u16 port; /* port on unit assigned to caller */463__u16 subport; /* subport on unit assigned to caller */464__u16 num_ports; /* number of ports available on unit */465__u16 num_subports; /* number of subports opened on port */466};467468struct ipath_tid_info {469__u32 tidcnt;470/* make structure same size in 32 and 64 bit */471__u32 tid__unused;472/* virtual address of first page in transfer */473__u64 tidvaddr;474/* pointer (same size 32/64 bit) to __u16 tid array */475__u64 tidlist;476477/*478* pointer (same size 32/64 bit) to bitmap of TIDs used479* for this call; checked for being large enough at open480*/481__u64 tidmap;482};483484struct ipath_cmd {485__u32 type; /* command type */486union {487struct ipath_tid_info tid_info;488struct ipath_user_info user_info;489490/*491* address in userspace where we should put the sdma492* inflight counter493*/494__u64 sdma_inflight;495/*496* address in userspace where we should put the sdma497* completion counter498*/499__u64 sdma_complete;500/* address in userspace of struct ipath_port_info to501write result to */502__u64 port_info;503/* enable/disable receipt of packets */504__u32 recv_ctrl;505/* enable/disable armlaunch errors (non-zero to enable) */506__u32 armlaunch_ctrl;507/* partition key to set */508__u16 part_key;509/* user address of __u32 bitmask of active slaves */510__u64 slave_mask_addr;511/* type of polling we want */512__u16 poll_type;513} cmd;514};515516struct ipath_iovec {517/* Pointer to data, but same size 32 and 64 bit */518__u64 iov_base;519520/*521* Length of data; don't need 64 bits, but want522* ipath_sendpkt to remain same size as before 32 bit changes, so...523*/524__u64 iov_len;525};526527/*528* Describes a single packet for send. Each packet can have one or more529* buffers, but the total length (exclusive of IB headers) must be less530* than the MTU, and if using the PIO method, entire packet length,531* including IB headers, must be less than the ipath_piosize value (words).532* Use of this necessitates including sys/uio.h533*/534struct __ipath_sendpkt {535__u32 sps_flags; /* flags for packet (TBD) */536__u32 sps_cnt; /* number of entries to use in sps_iov */537/* array of iov's describing packet. TEMPORARY */538struct ipath_iovec sps_iov[4];539};540541/*542* diagnostics can send a packet by "writing" one of the following543* two structs to diag data special file544* The first is the legacy version for backward compatibility545*/546struct ipath_diag_pkt {547__u32 unit;548__u64 data;549__u32 len;550};551552/* The second diag_pkt struct is the expanded version that allows553* more control over the packet, specifically, by allowing a custom554* pbc (+ static rate) qword, so that special modes and deliberate555* changes to CRCs can be used. The elements were also re-ordered556* for better alignment and to avoid padding issues.557*/558struct ipath_diag_xpkt {559__u64 data;560__u64 pbc_wd;561__u32 unit;562__u32 len;563};564565/*566* Data layout in I2C flash (for GUID, etc.)567* All fields are little-endian binary unless otherwise stated568*/569#define IPATH_FLASH_VERSION 2570struct ipath_flash {571/* flash layout version (IPATH_FLASH_VERSION) */572__u8 if_fversion;573/* checksum protecting if_length bytes */574__u8 if_csum;575/*576* valid length (in use, protected by if_csum), including577* if_fversion and if_csum themselves)578*/579__u8 if_length;580/* the GUID, in network order */581__u8 if_guid[8];582/* number of GUIDs to use, starting from if_guid */583__u8 if_numguid;584/* the (last 10 characters of) board serial number, in ASCII */585char if_serial[12];586/* board mfg date (YYYYMMDD ASCII) */587char if_mfgdate[8];588/* last board rework/test date (YYYYMMDD ASCII) */589char if_testdate[8];590/* logging of error counts, TBD */591__u8 if_errcntp[4];592/* powered on hours, updated at driver unload */593__u8 if_powerhour[2];594/* ASCII free-form comment field */595char if_comment[32];596/* Backwards compatible prefix for longer QLogic Serial Numbers */597char if_sprefix[4];598/* 82 bytes used, min flash size is 128 bytes */599__u8 if_future[46];600};601602/*603* These are the counters implemented in the chip, and are listed in order.604* The InterCaps naming is taken straight from the chip spec.605*/606struct infinipath_counters {607__u64 LBIntCnt;608__u64 LBFlowStallCnt;609__u64 TxSDmaDescCnt; /* was Reserved1 */610__u64 TxUnsupVLErrCnt;611__u64 TxDataPktCnt;612__u64 TxFlowPktCnt;613__u64 TxDwordCnt;614__u64 TxLenErrCnt;615__u64 TxMaxMinLenErrCnt;616__u64 TxUnderrunCnt;617__u64 TxFlowStallCnt;618__u64 TxDroppedPktCnt;619__u64 RxDroppedPktCnt;620__u64 RxDataPktCnt;621__u64 RxFlowPktCnt;622__u64 RxDwordCnt;623__u64 RxLenErrCnt;624__u64 RxMaxMinLenErrCnt;625__u64 RxICRCErrCnt;626__u64 RxVCRCErrCnt;627__u64 RxFlowCtrlErrCnt;628__u64 RxBadFormatCnt;629__u64 RxLinkProblemCnt;630__u64 RxEBPCnt;631__u64 RxLPCRCErrCnt;632__u64 RxBufOvflCnt;633__u64 RxTIDFullErrCnt;634__u64 RxTIDValidErrCnt;635__u64 RxPKeyMismatchCnt;636__u64 RxP0HdrEgrOvflCnt;637__u64 RxP1HdrEgrOvflCnt;638__u64 RxP2HdrEgrOvflCnt;639__u64 RxP3HdrEgrOvflCnt;640__u64 RxP4HdrEgrOvflCnt;641__u64 RxP5HdrEgrOvflCnt;642__u64 RxP6HdrEgrOvflCnt;643__u64 RxP7HdrEgrOvflCnt;644__u64 RxP8HdrEgrOvflCnt;645__u64 RxP9HdrEgrOvflCnt; /* was Reserved6 */646__u64 RxP10HdrEgrOvflCnt; /* was Reserved7 */647__u64 RxP11HdrEgrOvflCnt; /* new for IBA7220 */648__u64 RxP12HdrEgrOvflCnt; /* new for IBA7220 */649__u64 RxP13HdrEgrOvflCnt; /* new for IBA7220 */650__u64 RxP14HdrEgrOvflCnt; /* new for IBA7220 */651__u64 RxP15HdrEgrOvflCnt; /* new for IBA7220 */652__u64 RxP16HdrEgrOvflCnt; /* new for IBA7220 */653__u64 IBStatusChangeCnt;654__u64 IBLinkErrRecoveryCnt;655__u64 IBLinkDownedCnt;656__u64 IBSymbolErrCnt;657/* The following are new for IBA7220 */658__u64 RxVL15DroppedPktCnt;659__u64 RxOtherLocalPhyErrCnt;660__u64 PcieRetryBufDiagQwordCnt;661__u64 ExcessBufferOvflCnt;662__u64 LocalLinkIntegrityErrCnt;663__u64 RxVlErrCnt;664__u64 RxDlidFltrCnt;665};666667/*668* The next set of defines are for packet headers, and chip register669* and memory bits that are visible to and/or used by user-mode software670* The other bits that are used only by the driver or diags are in671* ipath_registers.h672*/673674/* RcvHdrFlags bits */675#define INFINIPATH_RHF_LENGTH_MASK 0x7FF676#define INFINIPATH_RHF_LENGTH_SHIFT 0677#define INFINIPATH_RHF_RCVTYPE_MASK 0x7678#define INFINIPATH_RHF_RCVTYPE_SHIFT 11679#define INFINIPATH_RHF_EGRINDEX_MASK 0xFFF680#define INFINIPATH_RHF_EGRINDEX_SHIFT 16681#define INFINIPATH_RHF_SEQ_MASK 0xF682#define INFINIPATH_RHF_SEQ_SHIFT 0683#define INFINIPATH_RHF_HDRQ_OFFSET_MASK 0x7FF684#define INFINIPATH_RHF_HDRQ_OFFSET_SHIFT 4685#define INFINIPATH_RHF_H_ICRCERR 0x80000000686#define INFINIPATH_RHF_H_VCRCERR 0x40000000687#define INFINIPATH_RHF_H_PARITYERR 0x20000000688#define INFINIPATH_RHF_H_LENERR 0x10000000689#define INFINIPATH_RHF_H_MTUERR 0x08000000690#define INFINIPATH_RHF_H_IHDRERR 0x04000000691#define INFINIPATH_RHF_H_TIDERR 0x02000000692#define INFINIPATH_RHF_H_MKERR 0x01000000693#define INFINIPATH_RHF_H_IBERR 0x00800000694#define INFINIPATH_RHF_H_ERR_MASK 0xFF800000695#define INFINIPATH_RHF_L_USE_EGR 0x80000000696#define INFINIPATH_RHF_L_SWA 0x00008000697#define INFINIPATH_RHF_L_SWB 0x00004000698699/* infinipath header fields */700#define INFINIPATH_I_VERS_MASK 0xF701#define INFINIPATH_I_VERS_SHIFT 28702#define INFINIPATH_I_PORT_MASK 0xF703#define INFINIPATH_I_PORT_SHIFT 24704#define INFINIPATH_I_TID_MASK 0x7FF705#define INFINIPATH_I_TID_SHIFT 13706#define INFINIPATH_I_OFFSET_MASK 0x1FFF707#define INFINIPATH_I_OFFSET_SHIFT 0708709/* K_PktFlags bits */710#define INFINIPATH_KPF_INTR 0x1711#define INFINIPATH_KPF_SUBPORT_MASK 0x3712#define INFINIPATH_KPF_SUBPORT_SHIFT 1713714#define INFINIPATH_MAX_SUBPORT 4715716/* SendPIO per-buffer control */717#define INFINIPATH_SP_TEST 0x40718#define INFINIPATH_SP_TESTEBP 0x20719#define INFINIPATH_SP_TRIGGER_SHIFT 15720721/* SendPIOAvail bits */722#define INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT 1723#define INFINIPATH_SENDPIOAVAIL_CHECK_SHIFT 0724725/* infinipath header format */726struct ipath_header {727/*728* Version - 4 bits, Port - 4 bits, TID - 10 bits and Offset -729* 14 bits before ECO change ~28 Dec 03. After that, Vers 4,730* Port 4, TID 11, offset 13.731*/732__le32 ver_port_tid_offset;733__le16 chksum;734__le16 pkt_flags;735};736737/* infinipath user message header format.738* This structure contains the first 4 fields common to all protocols739* that employ infinipath.740*/741struct ipath_message_header {742__be16 lrh[4];743__be32 bth[3];744/* fields below this point are in host byte order */745struct ipath_header iph;746__u8 sub_opcode;747};748749/* infinipath ethernet header format */750struct ether_header {751__be16 lrh[4];752__be32 bth[3];753struct ipath_header iph;754__u8 sub_opcode;755__u8 cmd;756__be16 lid;757__u16 mac[3];758__u8 frag_num;759__u8 seq_num;760__le32 len;761/* MUST be of word size due to PIO write requirements */762__le32 csum;763__le16 csum_offset;764__le16 flags;765__u16 first_2_bytes;766__u8 unused[2]; /* currently unused */767};768769770/* IB - LRH header consts */771#define IPATH_LRH_GRH 0x0003 /* 1. word of IB LRH - next header: GRH */772#define IPATH_LRH_BTH 0x0002 /* 1. word of IB LRH - next header: BTH */773774/* misc. */775#define SIZE_OF_CRC 1776777#define IPATH_DEFAULT_P_KEY 0xFFFF778#define IPATH_PERMISSIVE_LID 0xFFFF779#define IPATH_AETH_CREDIT_SHIFT 24780#define IPATH_AETH_CREDIT_MASK 0x1F781#define IPATH_AETH_CREDIT_INVAL 0x1F782#define IPATH_PSN_MASK 0xFFFFFF783#define IPATH_MSN_MASK 0xFFFFFF784#define IPATH_QPN_MASK 0xFFFFFF785#define IPATH_MULTICAST_LID_BASE 0xC000786#define IPATH_EAGER_TID_ID INFINIPATH_I_TID_MASK787#define IPATH_MULTICAST_QPN 0xFFFFFF788789/* Receive Header Queue: receive type (from infinipath) */790#define RCVHQ_RCV_TYPE_EXPECTED 0791#define RCVHQ_RCV_TYPE_EAGER 1792#define RCVHQ_RCV_TYPE_NON_KD 2793#define RCVHQ_RCV_TYPE_ERROR 3794795796/* sub OpCodes - ith4x */797#define IPATH_ITH4X_OPCODE_ENCAP 0x81798#define IPATH_ITH4X_OPCODE_LID_ARP 0x82799800#define IPATH_HEADER_QUEUE_WORDS 9801802/* functions for extracting fields from rcvhdrq entries for the driver.803*/804static inline __u32 ipath_hdrget_err_flags(const __le32 * rbuf)805{806return __le32_to_cpu(rbuf[1]) & INFINIPATH_RHF_H_ERR_MASK;807}808809static inline __u32 ipath_hdrget_rcv_type(const __le32 * rbuf)810{811return (__le32_to_cpu(rbuf[0]) >> INFINIPATH_RHF_RCVTYPE_SHIFT)812& INFINIPATH_RHF_RCVTYPE_MASK;813}814815static inline __u32 ipath_hdrget_length_in_bytes(const __le32 * rbuf)816{817return ((__le32_to_cpu(rbuf[0]) >> INFINIPATH_RHF_LENGTH_SHIFT)818& INFINIPATH_RHF_LENGTH_MASK) << 2;819}820821static inline __u32 ipath_hdrget_index(const __le32 * rbuf)822{823return (__le32_to_cpu(rbuf[0]) >> INFINIPATH_RHF_EGRINDEX_SHIFT)824& INFINIPATH_RHF_EGRINDEX_MASK;825}826827static inline __u32 ipath_hdrget_seq(const __le32 *rbuf)828{829return (__le32_to_cpu(rbuf[1]) >> INFINIPATH_RHF_SEQ_SHIFT)830& INFINIPATH_RHF_SEQ_MASK;831}832833static inline __u32 ipath_hdrget_offset(const __le32 *rbuf)834{835return (__le32_to_cpu(rbuf[1]) >> INFINIPATH_RHF_HDRQ_OFFSET_SHIFT)836& INFINIPATH_RHF_HDRQ_OFFSET_MASK;837}838839static inline __u32 ipath_hdrget_use_egr_buf(const __le32 *rbuf)840{841return __le32_to_cpu(rbuf[0]) & INFINIPATH_RHF_L_USE_EGR;842}843844static inline __u32 ipath_hdrget_ipath_ver(__le32 hdrword)845{846return (__le32_to_cpu(hdrword) >> INFINIPATH_I_VERS_SHIFT)847& INFINIPATH_I_VERS_MASK;848}849850#endif /* _IPATH_COMMON_H */851852853