Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
0003  * All rights reserved.
0004  * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
0033  */
0034 
0035 #ifndef _QIB_COMMON_H
0036 #define _QIB_COMMON_H
0037 
0038 /*
0039  * This file contains defines, structures, etc. that are used
0040  * to communicate between kernel and user code.
0041  */
0042 
0043 /* This is the IEEE-assigned OUI for QLogic Inc. QLogic_IB */
0044 #define QIB_SRC_OUI_1 0x00
0045 #define QIB_SRC_OUI_2 0x11
0046 #define QIB_SRC_OUI_3 0x75
0047 
0048 /* version of protocol header (known to chip also). In the long run,
0049  * we should be able to generate and accept a range of version numbers;
0050  * for now we only accept one, and it's compiled in.
0051  */
0052 #define IPS_PROTO_VERSION 2
0053 
0054 /*
0055  * These are compile time constants that you may want to enable or disable
0056  * if you are trying to debug problems with code or performance.
0057  * QIB_VERBOSE_TRACING define as 1 if you want additional tracing in
0058  * fastpath code
0059  * QIB_TRACE_REGWRITES define as 1 if you want register writes to be
0060  * traced in fastpath code
0061  * _QIB_TRACING define as 0 if you want to remove all tracing in a
0062  * compilation unit
0063  */
0064 
0065 /*
0066  * The value in the BTH QP field that QLogic_IB uses to differentiate
0067  * an qlogic_ib protocol IB packet vs standard IB transport
0068  * This it needs to be even (0x656b78), because the LSB is sometimes
0069  * used for the MSB of context. The change may cause a problem
0070  * interoperating with older software.
0071  */
0072 #define QIB_KD_QP 0x656b78
0073 
0074 /*
0075  * These are the status bits readable (in ascii form, 64bit value)
0076  * from the "status" sysfs file.  For binary compatibility, values
0077  * must remain as is; removed states can be reused for different
0078  * purposes.
0079  */
0080 #define QIB_STATUS_INITTED       0x1    /* basic initialization done */
0081 /* Chip has been found and initted */
0082 #define QIB_STATUS_CHIP_PRESENT 0x20
0083 /* IB link is at ACTIVE, usable for data traffic */
0084 #define QIB_STATUS_IB_READY     0x40
0085 /* link is configured, LID, MTU, etc. have been set */
0086 #define QIB_STATUS_IB_CONF      0x80
0087 /* A Fatal hardware error has occurred. */
0088 #define QIB_STATUS_HWERROR     0x200
0089 
0090 /*
0091  * The list of usermode accessible registers.  Also see Reg_* later in file.
0092  */
0093 enum qib_ureg {
0094     /* (RO)  DMA RcvHdr to be used next. */
0095     ur_rcvhdrtail = 0,
0096     /* (RW)  RcvHdr entry to be processed next by host. */
0097     ur_rcvhdrhead = 1,
0098     /* (RO)  Index of next Eager index to use. */
0099     ur_rcvegrindextail = 2,
0100     /* (RW)  Eager TID to be processed next */
0101     ur_rcvegrindexhead = 3,
0102     /* For internal use only; max register number. */
0103     _QIB_UregMax
0104 };
0105 
0106 /* bit values for spi_runtime_flags */
0107 #define QIB_RUNTIME_PCIE                0x0002
0108 #define QIB_RUNTIME_FORCE_WC_ORDER      0x0004
0109 #define QIB_RUNTIME_RCVHDR_COPY         0x0008
0110 #define QIB_RUNTIME_MASTER              0x0010
0111 #define QIB_RUNTIME_RCHK                0x0020
0112 #define QIB_RUNTIME_NODMA_RTAIL         0x0080
0113 #define QIB_RUNTIME_SPECIAL_TRIGGER     0x0100
0114 #define QIB_RUNTIME_SDMA                0x0200
0115 #define QIB_RUNTIME_FORCE_PIOAVAIL      0x0400
0116 #define QIB_RUNTIME_PIO_REGSWAPPED      0x0800
0117 #define QIB_RUNTIME_CTXT_MSB_IN_QP      0x1000
0118 #define QIB_RUNTIME_CTXT_REDIRECT       0x2000
0119 #define QIB_RUNTIME_HDRSUPP             0x4000
0120 
0121 /*
0122  * This structure is returned by qib_userinit() immediately after
0123  * open to get implementation-specific info, and info specific to this
0124  * instance.
0125  *
0126  * This struct must have explict pad fields where type sizes
0127  * may result in different alignments between 32 and 64 bit
0128  * programs, since the 64 bit * bit kernel requires the user code
0129  * to have matching offsets
0130  */
0131 struct qib_base_info {
0132     /* version of hardware, for feature checking. */
0133     __u32 spi_hw_version;
0134     /* version of software, for feature checking. */
0135     __u32 spi_sw_version;
0136     /* QLogic_IB context assigned, goes into sent packets */
0137     __u16 spi_ctxt;
0138     __u16 spi_subctxt;
0139     /*
0140      * IB MTU, packets IB data must be less than this.
0141      * The MTU is in bytes, and will be a multiple of 4 bytes.
0142      */
0143     __u32 spi_mtu;
0144     /*
0145      * Size of a PIO buffer.  Any given packet's total size must be less
0146      * than this (in words).  Included is the starting control word, so
0147      * if 513 is returned, then total pkt size is 512 words or less.
0148      */
0149     __u32 spi_piosize;
0150     /* size of the TID cache in qlogic_ib, in entries */
0151     __u32 spi_tidcnt;
0152     /* size of the TID Eager list in qlogic_ib, in entries */
0153     __u32 spi_tidegrcnt;
0154     /* size of a single receive header queue entry in words. */
0155     __u32 spi_rcvhdrent_size;
0156     /*
0157      * Count of receive header queue entries allocated.
0158      * This may be less than the spu_rcvhdrcnt passed in!.
0159      */
0160     __u32 spi_rcvhdr_cnt;
0161 
0162     /* per-chip and other runtime features bitmap (QIB_RUNTIME_*) */
0163     __u32 spi_runtime_flags;
0164 
0165     /* address where hardware receive header queue is mapped */
0166     __u64 spi_rcvhdr_base;
0167 
0168     /* user program. */
0169 
0170     /* base address of eager TID receive buffers used by hardware. */
0171     __u64 spi_rcv_egrbufs;
0172 
0173     /* Allocated by initialization code, not by protocol. */
0174 
0175     /*
0176      * Size of each TID buffer in host memory, starting at
0177      * spi_rcv_egrbufs.  The buffers are virtually contiguous.
0178      */
0179     __u32 spi_rcv_egrbufsize;
0180     /*
0181      * The special QP (queue pair) value that identifies an qlogic_ib
0182      * protocol packet from standard IB packets.  More, probably much
0183      * more, to be added.
0184      */
0185     __u32 spi_qpair;
0186 
0187     /*
0188      * User register base for init code, not to be used directly by
0189      * protocol or applications.  Always points to chip registers,
0190      * for normal or shared context.
0191      */
0192     __u64 spi_uregbase;
0193     /*
0194      * Maximum buffer size in bytes that can be used in a single TID
0195      * entry (assuming the buffer is aligned to this boundary).  This is
0196      * the minimum of what the hardware and software support Guaranteed
0197      * to be a power of 2.
0198      */
0199     __u32 spi_tid_maxsize;
0200     /*
0201      * alignment of each pio send buffer (byte count
0202      * to add to spi_piobufbase to get to second buffer)
0203      */
0204     __u32 spi_pioalign;
0205     /*
0206      * The index of the first pio buffer available to this process;
0207      * needed to do lookup in spi_pioavailaddr; not added to
0208      * spi_piobufbase.
0209      */
0210     __u32 spi_pioindex;
0211      /* number of buffers mapped for this process */
0212     __u32 spi_piocnt;
0213 
0214     /*
0215      * Base address of writeonly pio buffers for this process.
0216      * Each buffer has spi_piosize words, and is aligned on spi_pioalign
0217      * boundaries.  spi_piocnt buffers are mapped from this address
0218      */
0219     __u64 spi_piobufbase;
0220 
0221     /*
0222      * Base address of readonly memory copy of the pioavail registers.
0223      * There are 2 bits for each buffer.
0224      */
0225     __u64 spi_pioavailaddr;
0226 
0227     /*
0228      * Address where driver updates a copy of the interface and driver
0229      * status (QIB_STATUS_*) as a 64 bit value.  It's followed by a
0230      * link status qword (formerly combined with driver status), then a
0231      * string indicating hardware error, if there was one.
0232      */
0233     __u64 spi_status;
0234 
0235     /* number of chip ctxts available to user processes */
0236     __u32 spi_nctxts;
0237     __u16 spi_unit; /* unit number of chip we are using */
0238     __u16 spi_port; /* IB port number we are using */
0239     /* num bufs in each contiguous set */
0240     __u32 spi_rcv_egrperchunk;
0241     /* size in bytes of each contiguous set */
0242     __u32 spi_rcv_egrchunksize;
0243     /* total size of mmap to cover full rcvegrbuffers */
0244     __u32 spi_rcv_egrbuftotlen;
0245     __u32 spi_rhf_offset; /* dword offset in hdrqent for rcvhdr flags */
0246     /* address of readonly memory copy of the rcvhdrq tail register. */
0247     __u64 spi_rcvhdr_tailaddr;
0248 
0249     /*
0250      * shared memory pages for subctxts if ctxt is shared; these cover
0251      * all the processes in the group sharing a single context.
0252      * all have enough space for the num_subcontexts value on this job.
0253      */
0254     __u64 spi_subctxt_uregbase;
0255     __u64 spi_subctxt_rcvegrbuf;
0256     __u64 spi_subctxt_rcvhdr_base;
0257 
0258     /* shared memory page for send buffer disarm status */
0259     __u64 spi_sendbuf_status;
0260 } __aligned(8);
0261 
0262 /*
0263  * This version number is given to the driver by the user code during
0264  * initialization in the spu_userversion field of qib_user_info, so
0265  * the driver can check for compatibility with user code.
0266  *
0267  * The major version changes when data structures
0268  * change in an incompatible way.  The driver must be the same or higher
0269  * for initialization to succeed.  In some cases, a higher version
0270  * driver will not interoperate with older software, and initialization
0271  * will return an error.
0272  */
0273 #define QIB_USER_SWMAJOR 1
0274 
0275 /*
0276  * Minor version differences are always compatible
0277  * a within a major version, however if user software is larger
0278  * than driver software, some new features and/or structure fields
0279  * may not be implemented; the user code must deal with this if it
0280  * cares, or it must abort after initialization reports the difference.
0281  */
0282 #define QIB_USER_SWMINOR 13
0283 
0284 #define QIB_USER_SWVERSION ((QIB_USER_SWMAJOR << 16) | QIB_USER_SWMINOR)
0285 
0286 #ifndef QIB_KERN_TYPE
0287 #define QIB_KERN_TYPE 0
0288 #endif
0289 
0290 /*
0291  * Similarly, this is the kernel version going back to the user.  It's
0292  * slightly different, in that we want to tell if the driver was built as
0293  * part of a QLogic release, or from the driver from openfabrics.org,
0294  * kernel.org, or a standard distribution, for support reasons.
0295  * The high bit is 0 for non-QLogic and 1 for QLogic-built/supplied.
0296  *
0297  * It's returned by the driver to the user code during initialization in the
0298  * spi_sw_version field of qib_base_info, so the user code can in turn
0299  * check for compatibility with the kernel.
0300 */
0301 #define QIB_KERN_SWVERSION ((QIB_KERN_TYPE << 31) | QIB_USER_SWVERSION)
0302 
0303 /*
0304  * Define the driver version number.  This is something that refers only
0305  * to the driver itself, not the software interfaces it supports.
0306  */
0307 #define QIB_DRIVER_VERSION_BASE "1.11"
0308 
0309 /* create the final driver version string */
0310 #ifdef QIB_IDSTR
0311 #define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE " " QIB_IDSTR
0312 #else
0313 #define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE
0314 #endif
0315 
0316 /*
0317  * If the unit is specified via open, HCA choice is fixed.  If port is
0318  * specified, it's also fixed.  Otherwise we try to spread contexts
0319  * across ports and HCAs, using different algorithims.  WITHIN is
0320  * the old default, prior to this mechanism.
0321  */
0322 #define QIB_PORT_ALG_ACROSS 0 /* round robin contexts across HCAs, then
0323                    * ports; this is the default */
0324 #define QIB_PORT_ALG_WITHIN 1 /* use all contexts on an HCA (round robin
0325                    * active ports within), then next HCA */
0326 #define QIB_PORT_ALG_COUNT 2 /* number of algorithm choices */
0327 
0328 /*
0329  * This structure is passed to qib_userinit() to tell the driver where
0330  * user code buffers are, sizes, etc.   The offsets and sizes of the
0331  * fields must remain unchanged, for binary compatibility.  It can
0332  * be extended, if userversion is changed so user code can tell, if needed
0333  */
0334 struct qib_user_info {
0335     /*
0336      * version of user software, to detect compatibility issues.
0337      * Should be set to QIB_USER_SWVERSION.
0338      */
0339     __u32 spu_userversion;
0340 
0341     __u32 _spu_unused2;
0342 
0343     /* size of struct base_info to write to */
0344     __u32 spu_base_info_size;
0345 
0346     __u32 spu_port_alg; /* which QIB_PORT_ALG_*; unused user minor < 11 */
0347 
0348     /*
0349      * If two or more processes wish to share a context, each process
0350      * must set the spu_subctxt_cnt and spu_subctxt_id to the same
0351      * values.  The only restriction on the spu_subctxt_id is that
0352      * it be unique for a given node.
0353      */
0354     __u16 spu_subctxt_cnt;
0355     __u16 spu_subctxt_id;
0356 
0357     __u32 spu_port; /* IB port requested by user if > 0 */
0358 
0359     /*
0360      * address of struct base_info to write to
0361      */
0362     __u64 spu_base_info;
0363 
0364 } __aligned(8);
0365 
0366 /* User commands. */
0367 
0368 /* 16 available, was: old set up userspace (for old user code) */
0369 #define QIB_CMD_CTXT_INFO       17      /* find out what resources we got */
0370 #define QIB_CMD_RECV_CTRL       18      /* control receipt of packets */
0371 #define QIB_CMD_TID_UPDATE      19      /* update expected TID entries */
0372 #define QIB_CMD_TID_FREE        20      /* free expected TID entries */
0373 #define QIB_CMD_SET_PART_KEY    21      /* add partition key */
0374 /* 22 available, was: return info on slave processes (for old user code) */
0375 #define QIB_CMD_ASSIGN_CTXT     23      /* allocate HCA and ctxt */
0376 #define QIB_CMD_USER_INIT       24      /* set up userspace */
0377 #define QIB_CMD_UNUSED_1        25
0378 #define QIB_CMD_UNUSED_2        26
0379 #define QIB_CMD_PIOAVAILUPD     27      /* force an update of PIOAvail reg */
0380 #define QIB_CMD_POLL_TYPE       28      /* set the kind of polling we want */
0381 #define QIB_CMD_ARMLAUNCH_CTRL  29      /* armlaunch detection control */
0382 /* 30 is unused */
0383 #define QIB_CMD_SDMA_INFLIGHT   31      /* sdma inflight counter request */
0384 #define QIB_CMD_SDMA_COMPLETE   32      /* sdma completion counter request */
0385 /* 33 available, was a testing feature  */
0386 #define QIB_CMD_DISARM_BUFS     34      /* disarm send buffers w/ errors */
0387 #define QIB_CMD_ACK_EVENT       35      /* ack & clear bits */
0388 #define QIB_CMD_CPUS_LIST       36      /* list of cpus allocated, for pinned
0389                      * processes: qib_cpus_list */
0390 
0391 /*
0392  * QIB_CMD_ACK_EVENT obsoletes QIB_CMD_DISARM_BUFS, but we keep it for
0393  * compatibility with libraries from previous release.   The ACK_EVENT
0394  * will take appropriate driver action (if any, just DISARM for now),
0395  * then clear the bits passed in as part of the mask.  These bits are
0396  * in the first 64bit word at spi_sendbuf_status, and are passed to
0397  * the driver in the event_mask union as well.
0398  */
0399 #define _QIB_EVENT_DISARM_BUFS_BIT  0
0400 #define _QIB_EVENT_LINKDOWN_BIT     1
0401 #define _QIB_EVENT_LID_CHANGE_BIT   2
0402 #define _QIB_EVENT_LMC_CHANGE_BIT   3
0403 #define _QIB_EVENT_SL2VL_CHANGE_BIT 4
0404 #define _QIB_MAX_EVENT_BIT _QIB_EVENT_SL2VL_CHANGE_BIT
0405 
0406 #define QIB_EVENT_DISARM_BUFS_BIT   (1UL << _QIB_EVENT_DISARM_BUFS_BIT)
0407 #define QIB_EVENT_LINKDOWN_BIT      (1UL << _QIB_EVENT_LINKDOWN_BIT)
0408 #define QIB_EVENT_LID_CHANGE_BIT    (1UL << _QIB_EVENT_LID_CHANGE_BIT)
0409 #define QIB_EVENT_LMC_CHANGE_BIT    (1UL << _QIB_EVENT_LMC_CHANGE_BIT)
0410 #define QIB_EVENT_SL2VL_CHANGE_BIT  (1UL << _QIB_EVENT_SL2VL_CHANGE_BIT)
0411 
0412 
0413 /*
0414  * Poll types
0415  */
0416 #define QIB_POLL_TYPE_ANYRCV     0x0
0417 #define QIB_POLL_TYPE_URGENT     0x1
0418 
0419 struct qib_ctxt_info {
0420     __u16 num_active;       /* number of active units */
0421     __u16 unit;             /* unit (chip) assigned to caller */
0422     __u16 port;             /* IB port assigned to caller (1-based) */
0423     __u16 ctxt;             /* ctxt on unit assigned to caller */
0424     __u16 subctxt;          /* subctxt on unit assigned to caller */
0425     __u16 num_ctxts;        /* number of ctxts available on unit */
0426     __u16 num_subctxts;     /* number of subctxts opened on ctxt */
0427     __u16 rec_cpu;          /* cpu # for affinity (ffff if none) */
0428 };
0429 
0430 struct qib_tid_info {
0431     __u32 tidcnt;
0432     /* make structure same size in 32 and 64 bit */
0433     __u32 tid__unused;
0434     /* virtual address of first page in transfer */
0435     __u64 tidvaddr;
0436     /* pointer (same size 32/64 bit) to __u16 tid array */
0437     __u64 tidlist;
0438 
0439     /*
0440      * pointer (same size 32/64 bit) to bitmap of TIDs used
0441      * for this call; checked for being large enough at open
0442      */
0443     __u64 tidmap;
0444 };
0445 
0446 struct qib_cmd {
0447     __u32 type;                     /* command type */
0448     union {
0449         struct qib_tid_info tid_info;
0450         struct qib_user_info user_info;
0451 
0452         /*
0453          * address in userspace where we should put the sdma
0454          * inflight counter
0455          */
0456         __u64 sdma_inflight;
0457         /*
0458          * address in userspace where we should put the sdma
0459          * completion counter
0460          */
0461         __u64 sdma_complete;
0462         /* address in userspace of struct qib_ctxt_info to
0463            write result to */
0464         __u64 ctxt_info;
0465         /* enable/disable receipt of packets */
0466         __u32 recv_ctrl;
0467         /* enable/disable armlaunch errors (non-zero to enable) */
0468         __u32 armlaunch_ctrl;
0469         /* partition key to set */
0470         __u16 part_key;
0471         /* user address of __u32 bitmask of active slaves */
0472         __u64 slave_mask_addr;
0473         /* type of polling we want */
0474         __u16 poll_type;
0475         /* back pressure enable bit for one particular context */
0476         __u8 ctxt_bp;
0477         /* qib_user_event_ack(), IPATH_EVENT_* bits */
0478         __u64 event_mask;
0479     } cmd;
0480 };
0481 
0482 struct qib_iovec {
0483     /* Pointer to data, but same size 32 and 64 bit */
0484     __u64 iov_base;
0485 
0486     /*
0487      * Length of data; don't need 64 bits, but want
0488      * qib_sendpkt to remain same size as before 32 bit changes, so...
0489      */
0490     __u64 iov_len;
0491 };
0492 
0493 /*
0494  * Describes a single packet for send.  Each packet can have one or more
0495  * buffers, but the total length (exclusive of IB headers) must be less
0496  * than the MTU, and if using the PIO method, entire packet length,
0497  * including IB headers, must be less than the qib_piosize value (words).
0498  * Use of this necessitates including sys/uio.h
0499  */
0500 struct __qib_sendpkt {
0501     __u32 sps_flags;        /* flags for packet (TBD) */
0502     __u32 sps_cnt;          /* number of entries to use in sps_iov */
0503     /* array of iov's describing packet. TEMPORARY */
0504     struct qib_iovec sps_iov[4];
0505 };
0506 
0507 /*
0508  * Diagnostics can send a packet by "writing" the following
0509  * structs to the diag data special file.
0510  * This allows a custom
0511  * pbc (+ static rate) qword, so that special modes and deliberate
0512  * changes to CRCs can be used. The elements were also re-ordered
0513  * for better alignment and to avoid padding issues.
0514  */
0515 #define _DIAG_XPKT_VERS 3
0516 struct qib_diag_xpkt {
0517     __u16 version;
0518     __u16 unit;
0519     __u16 port;
0520     __u16 len;
0521     __u64 data;
0522     __u64 pbc_wd;
0523 };
0524 
0525 /*
0526  * Data layout in I2C flash (for GUID, etc.)
0527  * All fields are little-endian binary unless otherwise stated
0528  */
0529 #define QIB_FLASH_VERSION 2
0530 struct qib_flash {
0531     /* flash layout version (QIB_FLASH_VERSION) */
0532     __u8 if_fversion;
0533     /* checksum protecting if_length bytes */
0534     __u8 if_csum;
0535     /*
0536      * valid length (in use, protected by if_csum), including
0537      * if_fversion and if_csum themselves)
0538      */
0539     __u8 if_length;
0540     /* the GUID, in network order */
0541     __u8 if_guid[8];
0542     /* number of GUIDs to use, starting from if_guid */
0543     __u8 if_numguid;
0544     /* the (last 10 characters of) board serial number, in ASCII */
0545     char if_serial[12];
0546     /* board mfg date (YYYYMMDD ASCII) */
0547     char if_mfgdate[8];
0548     /* last board rework/test date (YYYYMMDD ASCII) */
0549     char if_testdate[8];
0550     /* logging of error counts, TBD */
0551     __u8 if_errcntp[4];
0552     /* powered on hours, updated at driver unload */
0553     __u8 if_powerhour[2];
0554     /* ASCII free-form comment field */
0555     char if_comment[32];
0556     /* Backwards compatible prefix for longer QLogic Serial Numbers */
0557     char if_sprefix[4];
0558     /* 82 bytes used, min flash size is 128 bytes */
0559     __u8 if_future[46];
0560 };
0561 
0562 /*
0563  * These are the counters implemented in the chip, and are listed in order.
0564  * The InterCaps naming is taken straight from the chip spec.
0565  */
0566 struct qlogic_ib_counters {
0567     __u64 LBIntCnt;
0568     __u64 LBFlowStallCnt;
0569     __u64 TxSDmaDescCnt;    /* was Reserved1 */
0570     __u64 TxUnsupVLErrCnt;
0571     __u64 TxDataPktCnt;
0572     __u64 TxFlowPktCnt;
0573     __u64 TxDwordCnt;
0574     __u64 TxLenErrCnt;
0575     __u64 TxMaxMinLenErrCnt;
0576     __u64 TxUnderrunCnt;
0577     __u64 TxFlowStallCnt;
0578     __u64 TxDroppedPktCnt;
0579     __u64 RxDroppedPktCnt;
0580     __u64 RxDataPktCnt;
0581     __u64 RxFlowPktCnt;
0582     __u64 RxDwordCnt;
0583     __u64 RxLenErrCnt;
0584     __u64 RxMaxMinLenErrCnt;
0585     __u64 RxICRCErrCnt;
0586     __u64 RxVCRCErrCnt;
0587     __u64 RxFlowCtrlErrCnt;
0588     __u64 RxBadFormatCnt;
0589     __u64 RxLinkProblemCnt;
0590     __u64 RxEBPCnt;
0591     __u64 RxLPCRCErrCnt;
0592     __u64 RxBufOvflCnt;
0593     __u64 RxTIDFullErrCnt;
0594     __u64 RxTIDValidErrCnt;
0595     __u64 RxPKeyMismatchCnt;
0596     __u64 RxP0HdrEgrOvflCnt;
0597     __u64 RxP1HdrEgrOvflCnt;
0598     __u64 RxP2HdrEgrOvflCnt;
0599     __u64 RxP3HdrEgrOvflCnt;
0600     __u64 RxP4HdrEgrOvflCnt;
0601     __u64 RxP5HdrEgrOvflCnt;
0602     __u64 RxP6HdrEgrOvflCnt;
0603     __u64 RxP7HdrEgrOvflCnt;
0604     __u64 RxP8HdrEgrOvflCnt;
0605     __u64 RxP9HdrEgrOvflCnt;
0606     __u64 RxP10HdrEgrOvflCnt;
0607     __u64 RxP11HdrEgrOvflCnt;
0608     __u64 RxP12HdrEgrOvflCnt;
0609     __u64 RxP13HdrEgrOvflCnt;
0610     __u64 RxP14HdrEgrOvflCnt;
0611     __u64 RxP15HdrEgrOvflCnt;
0612     __u64 RxP16HdrEgrOvflCnt;
0613     __u64 IBStatusChangeCnt;
0614     __u64 IBLinkErrRecoveryCnt;
0615     __u64 IBLinkDownedCnt;
0616     __u64 IBSymbolErrCnt;
0617     __u64 RxVL15DroppedPktCnt;
0618     __u64 RxOtherLocalPhyErrCnt;
0619     __u64 PcieRetryBufDiagQwordCnt;
0620     __u64 ExcessBufferOvflCnt;
0621     __u64 LocalLinkIntegrityErrCnt;
0622     __u64 RxVlErrCnt;
0623     __u64 RxDlidFltrCnt;
0624 };
0625 
0626 /*
0627  * The next set of defines are for packet headers, and chip register
0628  * and memory bits that are visible to and/or used by user-mode software.
0629  */
0630 
0631 /* RcvHdrFlags bits */
0632 #define QLOGIC_IB_RHF_LENGTH_MASK 0x7FF
0633 #define QLOGIC_IB_RHF_LENGTH_SHIFT 0
0634 #define QLOGIC_IB_RHF_RCVTYPE_MASK 0x7
0635 #define QLOGIC_IB_RHF_RCVTYPE_SHIFT 11
0636 #define QLOGIC_IB_RHF_EGRINDEX_MASK 0xFFF
0637 #define QLOGIC_IB_RHF_EGRINDEX_SHIFT 16
0638 #define QLOGIC_IB_RHF_SEQ_MASK 0xF
0639 #define QLOGIC_IB_RHF_SEQ_SHIFT 0
0640 #define QLOGIC_IB_RHF_HDRQ_OFFSET_MASK 0x7FF
0641 #define QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT 4
0642 #define QLOGIC_IB_RHF_H_ICRCERR   0x80000000
0643 #define QLOGIC_IB_RHF_H_VCRCERR   0x40000000
0644 #define QLOGIC_IB_RHF_H_PARITYERR 0x20000000
0645 #define QLOGIC_IB_RHF_H_LENERR    0x10000000
0646 #define QLOGIC_IB_RHF_H_MTUERR    0x08000000
0647 #define QLOGIC_IB_RHF_H_IHDRERR   0x04000000
0648 #define QLOGIC_IB_RHF_H_TIDERR    0x02000000
0649 #define QLOGIC_IB_RHF_H_MKERR     0x01000000
0650 #define QLOGIC_IB_RHF_H_IBERR     0x00800000
0651 #define QLOGIC_IB_RHF_H_ERR_MASK  0xFF800000
0652 #define QLOGIC_IB_RHF_L_USE_EGR   0x80000000
0653 #define QLOGIC_IB_RHF_L_SWA       0x00008000
0654 #define QLOGIC_IB_RHF_L_SWB       0x00004000
0655 
0656 /* qlogic_ib header fields */
0657 #define QLOGIC_IB_I_VERS_MASK 0xF
0658 #define QLOGIC_IB_I_VERS_SHIFT 28
0659 #define QLOGIC_IB_I_CTXT_MASK 0xF
0660 #define QLOGIC_IB_I_CTXT_SHIFT 24
0661 #define QLOGIC_IB_I_TID_MASK 0x7FF
0662 #define QLOGIC_IB_I_TID_SHIFT 13
0663 #define QLOGIC_IB_I_OFFSET_MASK 0x1FFF
0664 #define QLOGIC_IB_I_OFFSET_SHIFT 0
0665 
0666 /* K_PktFlags bits */
0667 #define QLOGIC_IB_KPF_INTR 0x1
0668 #define QLOGIC_IB_KPF_SUBCTXT_MASK 0x3
0669 #define QLOGIC_IB_KPF_SUBCTXT_SHIFT 1
0670 
0671 #define QLOGIC_IB_MAX_SUBCTXT   4
0672 
0673 /* SendPIO per-buffer control */
0674 #define QLOGIC_IB_SP_TEST    0x40
0675 #define QLOGIC_IB_SP_TESTEBP 0x20
0676 #define QLOGIC_IB_SP_TRIGGER_SHIFT  15
0677 
0678 /* SendPIOAvail bits */
0679 #define QLOGIC_IB_SENDPIOAVAIL_BUSY_SHIFT 1
0680 #define QLOGIC_IB_SENDPIOAVAIL_CHECK_SHIFT 0
0681 
0682 /* qlogic_ib header format */
0683 struct qib_header {
0684     /*
0685      * Version - 4 bits, Context - 4 bits, TID - 10 bits and Offset -
0686      * 14 bits before ECO change ~28 Dec 03.  After that, Vers 4,
0687      * Context 4, TID 11, offset 13.
0688      */
0689     __le32 ver_ctxt_tid_offset;
0690     __le16 chksum;
0691     __le16 pkt_flags;
0692 };
0693 
0694 /*
0695  * qlogic_ib user message header format.
0696  * This structure contains the first 4 fields common to all protocols
0697  * that employ qlogic_ib.
0698  */
0699 struct qib_message_header {
0700     __be16 lrh[4];
0701     __be32 bth[3];
0702     /* fields below this point are in host byte order */
0703     struct qib_header iph;
0704     /* fields below are simplified, but should match PSM */
0705     /* some are accessed by driver when packet spliting is needed */
0706     __u8 sub_opcode;
0707     __u8 flags;
0708     __u16 commidx;
0709     __u32 ack_seq_num;
0710     __u8 flowid;
0711     __u8 hdr_dlen;
0712     __u16 mqhdr;
0713     __u32 uwords[4];
0714 };
0715 
0716 /* sequence number bits for message */
0717 union qib_seqnum {
0718     struct {
0719         __u32 seq:11;
0720         __u32 gen:8;
0721         __u32 flow:5;
0722     };
0723     struct {
0724         __u32 pkt:16;
0725         __u32 msg:8;
0726     };
0727     __u32 val;
0728 };
0729 
0730 /* qib receiving-dma tid-session-member */
0731 struct qib_tid_session_member {
0732     __u16 tid;
0733     __u16 offset;
0734     __u16 length;
0735 };
0736 
0737 /* IB - LRH header consts */
0738 #define QIB_LRH_GRH 0x0003      /* 1. word of IB LRH - next header: GRH */
0739 #define QIB_LRH_BTH 0x0002      /* 1. word of IB LRH - next header: BTH */
0740 
0741 /* misc. */
0742 #define SIZE_OF_CRC 1
0743 
0744 #define QIB_DEFAULT_P_KEY 0xFFFF
0745 #define QIB_PSN_MASK 0xFFFFFF
0746 #define QIB_EAGER_TID_ID QLOGIC_IB_I_TID_MASK
0747 #define QIB_MULTICAST_QPN 0xFFFFFF
0748 
0749 /* Receive Header Queue: receive type (from qlogic_ib) */
0750 #define RCVHQ_RCV_TYPE_EXPECTED  0
0751 #define RCVHQ_RCV_TYPE_EAGER     1
0752 #define RCVHQ_RCV_TYPE_NON_KD    2
0753 #define RCVHQ_RCV_TYPE_ERROR     3
0754 
0755 #define QIB_HEADER_QUEUE_WORDS 9
0756 
0757 /* functions for extracting fields from rcvhdrq entries for the driver.
0758  */
0759 static inline __u32 qib_hdrget_err_flags(const __le32 *rbuf)
0760 {
0761     return __le32_to_cpu(rbuf[1]) & QLOGIC_IB_RHF_H_ERR_MASK;
0762 }
0763 
0764 static inline __u32 qib_hdrget_rcv_type(const __le32 *rbuf)
0765 {
0766     return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_RCVTYPE_SHIFT) &
0767         QLOGIC_IB_RHF_RCVTYPE_MASK;
0768 }
0769 
0770 static inline __u32 qib_hdrget_length_in_bytes(const __le32 *rbuf)
0771 {
0772     return ((__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_LENGTH_SHIFT) &
0773         QLOGIC_IB_RHF_LENGTH_MASK) << 2;
0774 }
0775 
0776 static inline __u32 qib_hdrget_index(const __le32 *rbuf)
0777 {
0778     return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_EGRINDEX_SHIFT) &
0779         QLOGIC_IB_RHF_EGRINDEX_MASK;
0780 }
0781 
0782 static inline __u32 qib_hdrget_seq(const __le32 *rbuf)
0783 {
0784     return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_SEQ_SHIFT) &
0785         QLOGIC_IB_RHF_SEQ_MASK;
0786 }
0787 
0788 static inline __u32 qib_hdrget_offset(const __le32 *rbuf)
0789 {
0790     return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT) &
0791         QLOGIC_IB_RHF_HDRQ_OFFSET_MASK;
0792 }
0793 
0794 static inline __u32 qib_hdrget_use_egr_buf(const __le32 *rbuf)
0795 {
0796     return __le32_to_cpu(rbuf[0]) & QLOGIC_IB_RHF_L_USE_EGR;
0797 }
0798 #endif                          /* _QIB_COMMON_H */