Path: blob/master/drivers/infiniband/hw/qib/qib_common.h
15112 views
/*1* Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.2* All rights reserved.3* Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.4*5* This software is available to you under a choice of one of two6* licenses. You may choose to be licensed under the terms of the GNU7* General Public License (GPL) Version 2, available from the file8* COPYING in the main directory of this source tree, or the9* OpenIB.org BSD license below:10*11* Redistribution and use in source and binary forms, with or12* without modification, are permitted provided that the following13* conditions are met:14*15* - Redistributions of source code must retain the above16* copyright notice, this list of conditions and the following17* disclaimer.18*19* - Redistributions in binary form must reproduce the above20* copyright notice, this list of conditions and the following21* disclaimer in the documentation and/or other materials22* provided with the distribution.23*24* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,25* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF26* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND27* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS28* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN29* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN30* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE31* SOFTWARE.32*/3334#ifndef _QIB_COMMON_H35#define _QIB_COMMON_H3637/*38* This file contains defines, structures, etc. that are used39* to communicate between kernel and user code.40*/4142/* This is the IEEE-assigned OUI for QLogic Inc. QLogic_IB */43#define QIB_SRC_OUI_1 0x0044#define QIB_SRC_OUI_2 0x1145#define QIB_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* QIB_VERBOSE_TRACING define as 1 if you want additional tracing in57* fastpath code58* QIB_TRACE_REGWRITES define as 1 if you want register writes to be59* traced in faspath code60* _QIB_TRACING define as 0 if you want to remove all tracing in a61* compilation unit62*/6364/*65* The value in the BTH QP field that QLogic_IB uses to differentiate66* an qlogic_ib protocol IB packet vs standard IB transport67* This it needs to be even (0x656b78), because the LSB is sometimes68* used for the MSB of context. The change may cause a problem69* interoperating with older software.70*/71#define QIB_KD_QP 0x656b787273/*74* These are the status bits readable (in ascii form, 64bit value)75* from the "status" sysfs file. For binary compatibility, values76* must remain as is; removed states can be reused for different77* purposes.78*/79#define QIB_STATUS_INITTED 0x1 /* basic initialization done */80/* Chip has been found and initted */81#define QIB_STATUS_CHIP_PRESENT 0x2082/* IB link is at ACTIVE, usable for data traffic */83#define QIB_STATUS_IB_READY 0x4084/* link is configured, LID, MTU, etc. have been set */85#define QIB_STATUS_IB_CONF 0x8086/* A Fatal hardware error has occurred. */87#define QIB_STATUS_HWERROR 0x2008889/*90* The list of usermode accessible registers. Also see Reg_* later in file.91*/92enum qib_ureg {93/* (RO) DMA RcvHdr to be used next. */94ur_rcvhdrtail = 0,95/* (RW) RcvHdr entry to be processed next by host. */96ur_rcvhdrhead = 1,97/* (RO) Index of next Eager index to use. */98ur_rcvegrindextail = 2,99/* (RW) Eager TID to be processed next */100ur_rcvegrindexhead = 3,101/* For internal use only; max register number. */102_QIB_UregMax103};104105/* bit values for spi_runtime_flags */106#define QIB_RUNTIME_PCIE 0x0002107#define QIB_RUNTIME_FORCE_WC_ORDER 0x0004108#define QIB_RUNTIME_RCVHDR_COPY 0x0008109#define QIB_RUNTIME_MASTER 0x0010110#define QIB_RUNTIME_RCHK 0x0020111#define QIB_RUNTIME_NODMA_RTAIL 0x0080112#define QIB_RUNTIME_SPECIAL_TRIGGER 0x0100113#define QIB_RUNTIME_SDMA 0x0200114#define QIB_RUNTIME_FORCE_PIOAVAIL 0x0400115#define QIB_RUNTIME_PIO_REGSWAPPED 0x0800116#define QIB_RUNTIME_CTXT_MSB_IN_QP 0x1000117#define QIB_RUNTIME_CTXT_REDIRECT 0x2000118#define QIB_RUNTIME_HDRSUPP 0x4000119120/*121* This structure is returned by qib_userinit() immediately after122* open to get implementation-specific info, and info specific to this123* instance.124*125* This struct must have explict pad fields where type sizes126* may result in different alignments between 32 and 64 bit127* programs, since the 64 bit * bit kernel requires the user code128* to have matching offsets129*/130struct qib_base_info {131/* version of hardware, for feature checking. */132__u32 spi_hw_version;133/* version of software, for feature checking. */134__u32 spi_sw_version;135/* QLogic_IB context assigned, goes into sent packets */136__u16 spi_ctxt;137__u16 spi_subctxt;138/*139* IB MTU, packets IB data must be less than this.140* The MTU is in bytes, and will be a multiple of 4 bytes.141*/142__u32 spi_mtu;143/*144* Size of a PIO buffer. Any given packet's total size must be less145* than this (in words). Included is the starting control word, so146* if 513 is returned, then total pkt size is 512 words or less.147*/148__u32 spi_piosize;149/* size of the TID cache in qlogic_ib, in entries */150__u32 spi_tidcnt;151/* size of the TID Eager list in qlogic_ib, in entries */152__u32 spi_tidegrcnt;153/* size of a single receive header queue entry in words. */154__u32 spi_rcvhdrent_size;155/*156* Count of receive header queue entries allocated.157* This may be less than the spu_rcvhdrcnt passed in!.158*/159__u32 spi_rcvhdr_cnt;160161/* per-chip and other runtime features bitmap (QIB_RUNTIME_*) */162__u32 spi_runtime_flags;163164/* address where hardware receive header queue is mapped */165__u64 spi_rcvhdr_base;166167/* user program. */168169/* base address of eager TID receive buffers used by hardware. */170__u64 spi_rcv_egrbufs;171172/* Allocated by initialization code, not by protocol. */173174/*175* Size of each TID buffer in host memory, starting at176* spi_rcv_egrbufs. The buffers are virtually contiguous.177*/178__u32 spi_rcv_egrbufsize;179/*180* The special QP (queue pair) value that identifies an qlogic_ib181* protocol packet from standard IB packets. More, probably much182* more, to be added.183*/184__u32 spi_qpair;185186/*187* User register base for init code, not to be used directly by188* protocol or applications. Always points to chip registers,189* for normal or shared context.190*/191__u64 spi_uregbase;192/*193* Maximum buffer size in bytes that can be used in a single TID194* entry (assuming the buffer is aligned to this boundary). This is195* the minimum of what the hardware and software support Guaranteed196* to be a power of 2.197*/198__u32 spi_tid_maxsize;199/*200* alignment of each pio send buffer (byte count201* to add to spi_piobufbase to get to second buffer)202*/203__u32 spi_pioalign;204/*205* The index of the first pio buffer available to this process;206* needed to do lookup in spi_pioavailaddr; not added to207* spi_piobufbase.208*/209__u32 spi_pioindex;210/* number of buffers mapped for this process */211__u32 spi_piocnt;212213/*214* Base address of writeonly pio buffers for this process.215* Each buffer has spi_piosize words, and is aligned on spi_pioalign216* boundaries. spi_piocnt buffers are mapped from this address217*/218__u64 spi_piobufbase;219220/*221* Base address of readonly memory copy of the pioavail registers.222* There are 2 bits for each buffer.223*/224__u64 spi_pioavailaddr;225226/*227* Address where driver updates a copy of the interface and driver228* status (QIB_STATUS_*) as a 64 bit value. It's followed by a229* link status qword (formerly combined with driver status), then a230* string indicating hardware error, if there was one.231*/232__u64 spi_status;233234/* number of chip ctxts available to user processes */235__u32 spi_nctxts;236__u16 spi_unit; /* unit number of chip we are using */237__u16 spi_port; /* IB port number we are using */238/* num bufs in each contiguous set */239__u32 spi_rcv_egrperchunk;240/* size in bytes of each contiguous set */241__u32 spi_rcv_egrchunksize;242/* total size of mmap to cover full rcvegrbuffers */243__u32 spi_rcv_egrbuftotlen;244__u32 spi_rhf_offset; /* dword offset in hdrqent for rcvhdr flags */245/* address of readonly memory copy of the rcvhdrq tail register. */246__u64 spi_rcvhdr_tailaddr;247248/*249* shared memory pages for subctxts if ctxt is shared; these cover250* all the processes in the group sharing a single context.251* all have enough space for the num_subcontexts value on this job.252*/253__u64 spi_subctxt_uregbase;254__u64 spi_subctxt_rcvegrbuf;255__u64 spi_subctxt_rcvhdr_base;256257/* shared memory page for send buffer disarm status */258__u64 spi_sendbuf_status;259} __attribute__ ((aligned(8)));260261/*262* This version number is given to the driver by the user code during263* initialization in the spu_userversion field of qib_user_info, so264* the driver can check for compatibility with user code.265*266* The major version changes when data structures267* change in an incompatible way. The driver must be the same or higher268* for initialization to succeed. In some cases, a higher version269* driver will not interoperate with older software, and initialization270* will return an error.271*/272#define QIB_USER_SWMAJOR 1273274/*275* Minor version differences are always compatible276* a within a major version, however if user software is larger277* than driver software, some new features and/or structure fields278* may not be implemented; the user code must deal with this if it279* cares, or it must abort after initialization reports the difference.280*/281#define QIB_USER_SWMINOR 11282283#define QIB_USER_SWVERSION ((QIB_USER_SWMAJOR << 16) | QIB_USER_SWMINOR)284285#ifndef QIB_KERN_TYPE286#define QIB_KERN_TYPE 0287#define QIB_IDSTR "QLogic kernel.org driver"288#endif289290/*291* Similarly, this is the kernel version going back to the user. It's292* slightly different, in that we want to tell if the driver was built as293* part of a QLogic release, or from the driver from openfabrics.org,294* kernel.org, or a standard distribution, for support reasons.295* The high bit is 0 for non-QLogic and 1 for QLogic-built/supplied.296*297* It's returned by the driver to the user code during initialization in the298* spi_sw_version field of qib_base_info, so the user code can in turn299* check for compatibility with the kernel.300*/301#define QIB_KERN_SWVERSION ((QIB_KERN_TYPE << 31) | QIB_USER_SWVERSION)302303/*304* If the unit is specified via open, HCA choice is fixed. If port is305* specified, it's also fixed. Otherwise we try to spread contexts306* across ports and HCAs, using different algorithims. WITHIN is307* the old default, prior to this mechanism.308*/309#define QIB_PORT_ALG_ACROSS 0 /* round robin contexts across HCAs, then310* ports; this is the default */311#define QIB_PORT_ALG_WITHIN 1 /* use all contexts on an HCA (round robin312* active ports within), then next HCA */313#define QIB_PORT_ALG_COUNT 2 /* number of algorithm choices */314315/*316* This structure is passed to qib_userinit() to tell the driver where317* user code buffers are, sizes, etc. The offsets and sizes of the318* fields must remain unchanged, for binary compatibility. It can319* be extended, if userversion is changed so user code can tell, if needed320*/321struct qib_user_info {322/*323* version of user software, to detect compatibility issues.324* Should be set to QIB_USER_SWVERSION.325*/326__u32 spu_userversion;327328__u32 _spu_unused2;329330/* size of struct base_info to write to */331__u32 spu_base_info_size;332333__u32 spu_port_alg; /* which QIB_PORT_ALG_*; unused user minor < 11 */334335/*336* If two or more processes wish to share a context, each process337* must set the spu_subctxt_cnt and spu_subctxt_id to the same338* values. The only restriction on the spu_subctxt_id is that339* it be unique for a given node.340*/341__u16 spu_subctxt_cnt;342__u16 spu_subctxt_id;343344__u32 spu_port; /* IB port requested by user if > 0 */345346/*347* address of struct base_info to write to348*/349__u64 spu_base_info;350351} __attribute__ ((aligned(8)));352353/* User commands. */354355/* 16 available, was: old set up userspace (for old user code) */356#define QIB_CMD_CTXT_INFO 17 /* find out what resources we got */357#define QIB_CMD_RECV_CTRL 18 /* control receipt of packets */358#define QIB_CMD_TID_UPDATE 19 /* update expected TID entries */359#define QIB_CMD_TID_FREE 20 /* free expected TID entries */360#define QIB_CMD_SET_PART_KEY 21 /* add partition key */361/* 22 available, was: return info on slave processes (for old user code) */362#define QIB_CMD_ASSIGN_CTXT 23 /* allocate HCA and ctxt */363#define QIB_CMD_USER_INIT 24 /* set up userspace */364#define QIB_CMD_UNUSED_1 25365#define QIB_CMD_UNUSED_2 26366#define QIB_CMD_PIOAVAILUPD 27 /* force an update of PIOAvail reg */367#define QIB_CMD_POLL_TYPE 28 /* set the kind of polling we want */368#define QIB_CMD_ARMLAUNCH_CTRL 29 /* armlaunch detection control */369/* 30 is unused */370#define QIB_CMD_SDMA_INFLIGHT 31 /* sdma inflight counter request */371#define QIB_CMD_SDMA_COMPLETE 32 /* sdma completion counter request */372/* 33 available, was a testing feature */373#define QIB_CMD_DISARM_BUFS 34 /* disarm send buffers w/ errors */374#define QIB_CMD_ACK_EVENT 35 /* ack & clear bits */375#define QIB_CMD_CPUS_LIST 36 /* list of cpus allocated, for pinned376* processes: qib_cpus_list */377378/*379* QIB_CMD_ACK_EVENT obsoletes QIB_CMD_DISARM_BUFS, but we keep it for380* compatibility with libraries from previous release. The ACK_EVENT381* will take appropriate driver action (if any, just DISARM for now),382* then clear the bits passed in as part of the mask. These bits are383* in the first 64bit word at spi_sendbuf_status, and are passed to384* the driver in the event_mask union as well.385*/386#define _QIB_EVENT_DISARM_BUFS_BIT 0387#define _QIB_EVENT_LINKDOWN_BIT 1388#define _QIB_EVENT_LID_CHANGE_BIT 2389#define _QIB_EVENT_LMC_CHANGE_BIT 3390#define _QIB_EVENT_SL2VL_CHANGE_BIT 4391#define _QIB_MAX_EVENT_BIT _QIB_EVENT_SL2VL_CHANGE_BIT392393#define QIB_EVENT_DISARM_BUFS_BIT (1UL << _QIB_EVENT_DISARM_BUFS_BIT)394#define QIB_EVENT_LINKDOWN_BIT (1UL << _QIB_EVENT_LINKDOWN_BIT)395#define QIB_EVENT_LID_CHANGE_BIT (1UL << _QIB_EVENT_LID_CHANGE_BIT)396#define QIB_EVENT_LMC_CHANGE_BIT (1UL << _QIB_EVENT_LMC_CHANGE_BIT)397#define QIB_EVENT_SL2VL_CHANGE_BIT (1UL << _QIB_EVENT_SL2VL_CHANGE_BIT)398399400/*401* Poll types402*/403#define QIB_POLL_TYPE_ANYRCV 0x0404#define QIB_POLL_TYPE_URGENT 0x1405406struct qib_ctxt_info {407__u16 num_active; /* number of active units */408__u16 unit; /* unit (chip) assigned to caller */409__u16 port; /* IB port assigned to caller (1-based) */410__u16 ctxt; /* ctxt on unit assigned to caller */411__u16 subctxt; /* subctxt on unit assigned to caller */412__u16 num_ctxts; /* number of ctxts available on unit */413__u16 num_subctxts; /* number of subctxts opened on ctxt */414__u16 rec_cpu; /* cpu # for affinity (ffff if none) */415};416417struct qib_tid_info {418__u32 tidcnt;419/* make structure same size in 32 and 64 bit */420__u32 tid__unused;421/* virtual address of first page in transfer */422__u64 tidvaddr;423/* pointer (same size 32/64 bit) to __u16 tid array */424__u64 tidlist;425426/*427* pointer (same size 32/64 bit) to bitmap of TIDs used428* for this call; checked for being large enough at open429*/430__u64 tidmap;431};432433struct qib_cmd {434__u32 type; /* command type */435union {436struct qib_tid_info tid_info;437struct qib_user_info user_info;438439/*440* address in userspace where we should put the sdma441* inflight counter442*/443__u64 sdma_inflight;444/*445* address in userspace where we should put the sdma446* completion counter447*/448__u64 sdma_complete;449/* address in userspace of struct qib_ctxt_info to450write result to */451__u64 ctxt_info;452/* enable/disable receipt of packets */453__u32 recv_ctrl;454/* enable/disable armlaunch errors (non-zero to enable) */455__u32 armlaunch_ctrl;456/* partition key to set */457__u16 part_key;458/* user address of __u32 bitmask of active slaves */459__u64 slave_mask_addr;460/* type of polling we want */461__u16 poll_type;462/* back pressure enable bit for one particular context */463__u8 ctxt_bp;464/* qib_user_event_ack(), IPATH_EVENT_* bits */465__u64 event_mask;466} cmd;467};468469struct qib_iovec {470/* Pointer to data, but same size 32 and 64 bit */471__u64 iov_base;472473/*474* Length of data; don't need 64 bits, but want475* qib_sendpkt to remain same size as before 32 bit changes, so...476*/477__u64 iov_len;478};479480/*481* Describes a single packet for send. Each packet can have one or more482* buffers, but the total length (exclusive of IB headers) must be less483* than the MTU, and if using the PIO method, entire packet length,484* including IB headers, must be less than the qib_piosize value (words).485* Use of this necessitates including sys/uio.h486*/487struct __qib_sendpkt {488__u32 sps_flags; /* flags for packet (TBD) */489__u32 sps_cnt; /* number of entries to use in sps_iov */490/* array of iov's describing packet. TEMPORARY */491struct qib_iovec sps_iov[4];492};493494/*495* Diagnostics can send a packet by "writing" the following496* structs to the diag data special file.497* This allows a custom498* pbc (+ static rate) qword, so that special modes and deliberate499* changes to CRCs can be used. The elements were also re-ordered500* for better alignment and to avoid padding issues.501*/502#define _DIAG_XPKT_VERS 3503struct qib_diag_xpkt {504__u16 version;505__u16 unit;506__u16 port;507__u16 len;508__u64 data;509__u64 pbc_wd;510};511512/*513* Data layout in I2C flash (for GUID, etc.)514* All fields are little-endian binary unless otherwise stated515*/516#define QIB_FLASH_VERSION 2517struct qib_flash {518/* flash layout version (QIB_FLASH_VERSION) */519__u8 if_fversion;520/* checksum protecting if_length bytes */521__u8 if_csum;522/*523* valid length (in use, protected by if_csum), including524* if_fversion and if_csum themselves)525*/526__u8 if_length;527/* the GUID, in network order */528__u8 if_guid[8];529/* number of GUIDs to use, starting from if_guid */530__u8 if_numguid;531/* the (last 10 characters of) board serial number, in ASCII */532char if_serial[12];533/* board mfg date (YYYYMMDD ASCII) */534char if_mfgdate[8];535/* last board rework/test date (YYYYMMDD ASCII) */536char if_testdate[8];537/* logging of error counts, TBD */538__u8 if_errcntp[4];539/* powered on hours, updated at driver unload */540__u8 if_powerhour[2];541/* ASCII free-form comment field */542char if_comment[32];543/* Backwards compatible prefix for longer QLogic Serial Numbers */544char if_sprefix[4];545/* 82 bytes used, min flash size is 128 bytes */546__u8 if_future[46];547};548549/*550* These are the counters implemented in the chip, and are listed in order.551* The InterCaps naming is taken straight from the chip spec.552*/553struct qlogic_ib_counters {554__u64 LBIntCnt;555__u64 LBFlowStallCnt;556__u64 TxSDmaDescCnt; /* was Reserved1 */557__u64 TxUnsupVLErrCnt;558__u64 TxDataPktCnt;559__u64 TxFlowPktCnt;560__u64 TxDwordCnt;561__u64 TxLenErrCnt;562__u64 TxMaxMinLenErrCnt;563__u64 TxUnderrunCnt;564__u64 TxFlowStallCnt;565__u64 TxDroppedPktCnt;566__u64 RxDroppedPktCnt;567__u64 RxDataPktCnt;568__u64 RxFlowPktCnt;569__u64 RxDwordCnt;570__u64 RxLenErrCnt;571__u64 RxMaxMinLenErrCnt;572__u64 RxICRCErrCnt;573__u64 RxVCRCErrCnt;574__u64 RxFlowCtrlErrCnt;575__u64 RxBadFormatCnt;576__u64 RxLinkProblemCnt;577__u64 RxEBPCnt;578__u64 RxLPCRCErrCnt;579__u64 RxBufOvflCnt;580__u64 RxTIDFullErrCnt;581__u64 RxTIDValidErrCnt;582__u64 RxPKeyMismatchCnt;583__u64 RxP0HdrEgrOvflCnt;584__u64 RxP1HdrEgrOvflCnt;585__u64 RxP2HdrEgrOvflCnt;586__u64 RxP3HdrEgrOvflCnt;587__u64 RxP4HdrEgrOvflCnt;588__u64 RxP5HdrEgrOvflCnt;589__u64 RxP6HdrEgrOvflCnt;590__u64 RxP7HdrEgrOvflCnt;591__u64 RxP8HdrEgrOvflCnt;592__u64 RxP9HdrEgrOvflCnt;593__u64 RxP10HdrEgrOvflCnt;594__u64 RxP11HdrEgrOvflCnt;595__u64 RxP12HdrEgrOvflCnt;596__u64 RxP13HdrEgrOvflCnt;597__u64 RxP14HdrEgrOvflCnt;598__u64 RxP15HdrEgrOvflCnt;599__u64 RxP16HdrEgrOvflCnt;600__u64 IBStatusChangeCnt;601__u64 IBLinkErrRecoveryCnt;602__u64 IBLinkDownedCnt;603__u64 IBSymbolErrCnt;604__u64 RxVL15DroppedPktCnt;605__u64 RxOtherLocalPhyErrCnt;606__u64 PcieRetryBufDiagQwordCnt;607__u64 ExcessBufferOvflCnt;608__u64 LocalLinkIntegrityErrCnt;609__u64 RxVlErrCnt;610__u64 RxDlidFltrCnt;611};612613/*614* The next set of defines are for packet headers, and chip register615* and memory bits that are visible to and/or used by user-mode software.616*/617618/* RcvHdrFlags bits */619#define QLOGIC_IB_RHF_LENGTH_MASK 0x7FF620#define QLOGIC_IB_RHF_LENGTH_SHIFT 0621#define QLOGIC_IB_RHF_RCVTYPE_MASK 0x7622#define QLOGIC_IB_RHF_RCVTYPE_SHIFT 11623#define QLOGIC_IB_RHF_EGRINDEX_MASK 0xFFF624#define QLOGIC_IB_RHF_EGRINDEX_SHIFT 16625#define QLOGIC_IB_RHF_SEQ_MASK 0xF626#define QLOGIC_IB_RHF_SEQ_SHIFT 0627#define QLOGIC_IB_RHF_HDRQ_OFFSET_MASK 0x7FF628#define QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT 4629#define QLOGIC_IB_RHF_H_ICRCERR 0x80000000630#define QLOGIC_IB_RHF_H_VCRCERR 0x40000000631#define QLOGIC_IB_RHF_H_PARITYERR 0x20000000632#define QLOGIC_IB_RHF_H_LENERR 0x10000000633#define QLOGIC_IB_RHF_H_MTUERR 0x08000000634#define QLOGIC_IB_RHF_H_IHDRERR 0x04000000635#define QLOGIC_IB_RHF_H_TIDERR 0x02000000636#define QLOGIC_IB_RHF_H_MKERR 0x01000000637#define QLOGIC_IB_RHF_H_IBERR 0x00800000638#define QLOGIC_IB_RHF_H_ERR_MASK 0xFF800000639#define QLOGIC_IB_RHF_L_USE_EGR 0x80000000640#define QLOGIC_IB_RHF_L_SWA 0x00008000641#define QLOGIC_IB_RHF_L_SWB 0x00004000642643/* qlogic_ib header fields */644#define QLOGIC_IB_I_VERS_MASK 0xF645#define QLOGIC_IB_I_VERS_SHIFT 28646#define QLOGIC_IB_I_CTXT_MASK 0xF647#define QLOGIC_IB_I_CTXT_SHIFT 24648#define QLOGIC_IB_I_TID_MASK 0x7FF649#define QLOGIC_IB_I_TID_SHIFT 13650#define QLOGIC_IB_I_OFFSET_MASK 0x1FFF651#define QLOGIC_IB_I_OFFSET_SHIFT 0652653/* K_PktFlags bits */654#define QLOGIC_IB_KPF_INTR 0x1655#define QLOGIC_IB_KPF_SUBCTXT_MASK 0x3656#define QLOGIC_IB_KPF_SUBCTXT_SHIFT 1657658#define QLOGIC_IB_MAX_SUBCTXT 4659660/* SendPIO per-buffer control */661#define QLOGIC_IB_SP_TEST 0x40662#define QLOGIC_IB_SP_TESTEBP 0x20663#define QLOGIC_IB_SP_TRIGGER_SHIFT 15664665/* SendPIOAvail bits */666#define QLOGIC_IB_SENDPIOAVAIL_BUSY_SHIFT 1667#define QLOGIC_IB_SENDPIOAVAIL_CHECK_SHIFT 0668669/* qlogic_ib header format */670struct qib_header {671/*672* Version - 4 bits, Context - 4 bits, TID - 10 bits and Offset -673* 14 bits before ECO change ~28 Dec 03. After that, Vers 4,674* Context 4, TID 11, offset 13.675*/676__le32 ver_ctxt_tid_offset;677__le16 chksum;678__le16 pkt_flags;679};680681/*682* qlogic_ib user message header format.683* This structure contains the first 4 fields common to all protocols684* that employ qlogic_ib.685*/686struct qib_message_header {687__be16 lrh[4];688__be32 bth[3];689/* fields below this point are in host byte order */690struct qib_header iph;691__u8 sub_opcode;692};693694/* IB - LRH header consts */695#define QIB_LRH_GRH 0x0003 /* 1. word of IB LRH - next header: GRH */696#define QIB_LRH_BTH 0x0002 /* 1. word of IB LRH - next header: BTH */697698/* misc. */699#define SIZE_OF_CRC 1700701#define QIB_DEFAULT_P_KEY 0xFFFF702#define QIB_PERMISSIVE_LID 0xFFFF703#define QIB_AETH_CREDIT_SHIFT 24704#define QIB_AETH_CREDIT_MASK 0x1F705#define QIB_AETH_CREDIT_INVAL 0x1F706#define QIB_PSN_MASK 0xFFFFFF707#define QIB_MSN_MASK 0xFFFFFF708#define QIB_QPN_MASK 0xFFFFFF709#define QIB_MULTICAST_LID_BASE 0xC000710#define QIB_EAGER_TID_ID QLOGIC_IB_I_TID_MASK711#define QIB_MULTICAST_QPN 0xFFFFFF712713/* Receive Header Queue: receive type (from qlogic_ib) */714#define RCVHQ_RCV_TYPE_EXPECTED 0715#define RCVHQ_RCV_TYPE_EAGER 1716#define RCVHQ_RCV_TYPE_NON_KD 2717#define RCVHQ_RCV_TYPE_ERROR 3718719#define QIB_HEADER_QUEUE_WORDS 9720721/* functions for extracting fields from rcvhdrq entries for the driver.722*/723static inline __u32 qib_hdrget_err_flags(const __le32 *rbuf)724{725return __le32_to_cpu(rbuf[1]) & QLOGIC_IB_RHF_H_ERR_MASK;726}727728static inline __u32 qib_hdrget_rcv_type(const __le32 *rbuf)729{730return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_RCVTYPE_SHIFT) &731QLOGIC_IB_RHF_RCVTYPE_MASK;732}733734static inline __u32 qib_hdrget_length_in_bytes(const __le32 *rbuf)735{736return ((__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_LENGTH_SHIFT) &737QLOGIC_IB_RHF_LENGTH_MASK) << 2;738}739740static inline __u32 qib_hdrget_index(const __le32 *rbuf)741{742return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_EGRINDEX_SHIFT) &743QLOGIC_IB_RHF_EGRINDEX_MASK;744}745746static inline __u32 qib_hdrget_seq(const __le32 *rbuf)747{748return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_SEQ_SHIFT) &749QLOGIC_IB_RHF_SEQ_MASK;750}751752static inline __u32 qib_hdrget_offset(const __le32 *rbuf)753{754return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT) &755QLOGIC_IB_RHF_HDRQ_OFFSET_MASK;756}757758static inline __u32 qib_hdrget_use_egr_buf(const __le32 *rbuf)759{760return __le32_to_cpu(rbuf[0]) & QLOGIC_IB_RHF_L_USE_EGR;761}762763static inline __u32 qib_hdrget_qib_ver(__le32 hdrword)764{765return (__le32_to_cpu(hdrword) >> QLOGIC_IB_I_VERS_SHIFT) &766QLOGIC_IB_I_VERS_MASK;767}768769#endif /* _QIB_COMMON_H */770771772