1f931551bSRalph Campbell #ifndef _QIB_KERNEL_H 2f931551bSRalph Campbell #define _QIB_KERNEL_H 3f931551bSRalph Campbell /* 4f931551bSRalph Campbell * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation. 5f931551bSRalph Campbell * All rights reserved. 6f931551bSRalph Campbell * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved. 7f931551bSRalph Campbell * 8f931551bSRalph Campbell * This software is available to you under a choice of one of two 9f931551bSRalph Campbell * licenses. You may choose to be licensed under the terms of the GNU 10f931551bSRalph Campbell * General Public License (GPL) Version 2, available from the file 11f931551bSRalph Campbell * COPYING in the main directory of this source tree, or the 12f931551bSRalph Campbell * OpenIB.org BSD license below: 13f931551bSRalph Campbell * 14f931551bSRalph Campbell * Redistribution and use in source and binary forms, with or 15f931551bSRalph Campbell * without modification, are permitted provided that the following 16f931551bSRalph Campbell * conditions are met: 17f931551bSRalph Campbell * 18f931551bSRalph Campbell * - Redistributions of source code must retain the above 19f931551bSRalph Campbell * copyright notice, this list of conditions and the following 20f931551bSRalph Campbell * disclaimer. 21f931551bSRalph Campbell * 22f931551bSRalph Campbell * - Redistributions in binary form must reproduce the above 23f931551bSRalph Campbell * copyright notice, this list of conditions and the following 24f931551bSRalph Campbell * disclaimer in the documentation and/or other materials 25f931551bSRalph Campbell * provided with the distribution. 26f931551bSRalph Campbell * 27f931551bSRalph Campbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28f931551bSRalph Campbell * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 29f931551bSRalph Campbell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 30f931551bSRalph Campbell * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 31f931551bSRalph Campbell * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 32f931551bSRalph Campbell * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 33f931551bSRalph Campbell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 34f931551bSRalph Campbell * SOFTWARE. 35f931551bSRalph Campbell */ 36f931551bSRalph Campbell 37f931551bSRalph Campbell /* 38f931551bSRalph Campbell * This header file is the base header file for qlogic_ib kernel code 39f931551bSRalph Campbell * qib_user.h serves a similar purpose for user code. 40f931551bSRalph Campbell */ 41f931551bSRalph Campbell 42f931551bSRalph Campbell #include <linux/interrupt.h> 43f931551bSRalph Campbell #include <linux/pci.h> 44f931551bSRalph Campbell #include <linux/dma-mapping.h> 45f931551bSRalph Campbell #include <linux/mutex.h> 46f931551bSRalph Campbell #include <linux/list.h> 47f931551bSRalph Campbell #include <linux/scatterlist.h> 48ba818afdSDavid Miller #include <linux/slab.h> 49f931551bSRalph Campbell #include <linux/io.h> 50f931551bSRalph Campbell #include <linux/fs.h> 51f931551bSRalph Campbell #include <linux/completion.h> 52f931551bSRalph Campbell #include <linux/kref.h> 53f931551bSRalph Campbell #include <linux/sched.h> 54f931551bSRalph Campbell 55f931551bSRalph Campbell #include "qib_common.h" 56f931551bSRalph Campbell #include "qib_verbs.h" 57f931551bSRalph Campbell 58f931551bSRalph Campbell /* only s/w major version of QLogic_IB we can handle */ 59f931551bSRalph Campbell #define QIB_CHIP_VERS_MAJ 2U 60f931551bSRalph Campbell 61f931551bSRalph Campbell /* don't care about this except printing */ 62f931551bSRalph Campbell #define QIB_CHIP_VERS_MIN 0U 63f931551bSRalph Campbell 64f931551bSRalph Campbell /* The Organization Unique Identifier (Mfg code), and its position in GUID */ 65f931551bSRalph Campbell #define QIB_OUI 0x001175 66f931551bSRalph Campbell #define QIB_OUI_LSB 40 67f931551bSRalph Campbell 68f931551bSRalph Campbell /* 69f931551bSRalph Campbell * per driver stats, either not device nor port-specific, or 70f931551bSRalph Campbell * summed over all of the devices and ports. 71f931551bSRalph Campbell * They are described by name via ipathfs filesystem, so layout 72f931551bSRalph Campbell * and number of elements can change without breaking compatibility. 73f931551bSRalph Campbell * If members are added or deleted qib_statnames[] in qib_fs.c must 74f931551bSRalph Campbell * change to match. 75f931551bSRalph Campbell */ 76f931551bSRalph Campbell struct qlogic_ib_stats { 77f931551bSRalph Campbell __u64 sps_ints; /* number of interrupts handled */ 78f931551bSRalph Campbell __u64 sps_errints; /* number of error interrupts */ 79f931551bSRalph Campbell __u64 sps_txerrs; /* tx-related packet errors */ 80f931551bSRalph Campbell __u64 sps_rcverrs; /* non-crc rcv packet errors */ 81f931551bSRalph Campbell __u64 sps_hwerrs; /* hardware errors reported (parity, etc.) */ 82f931551bSRalph Campbell __u64 sps_nopiobufs; /* no pio bufs avail from kernel */ 83f931551bSRalph Campbell __u64 sps_ctxts; /* number of contexts currently open */ 84f931551bSRalph Campbell __u64 sps_lenerrs; /* number of kernel packets where RHF != LRH len */ 85f931551bSRalph Campbell __u64 sps_buffull; 86f931551bSRalph Campbell __u64 sps_hdrfull; 87f931551bSRalph Campbell }; 88f931551bSRalph Campbell 89f931551bSRalph Campbell extern struct qlogic_ib_stats qib_stats; 90f931551bSRalph Campbell extern struct pci_error_handlers qib_pci_err_handler; 91f931551bSRalph Campbell extern struct pci_driver qib_driver; 92f931551bSRalph Campbell 93f931551bSRalph Campbell #define QIB_CHIP_SWVERSION QIB_CHIP_VERS_MAJ 94f931551bSRalph Campbell /* 95f931551bSRalph Campbell * First-cut critierion for "device is active" is 96f931551bSRalph Campbell * two thousand dwords combined Tx, Rx traffic per 97f931551bSRalph Campbell * 5-second interval. SMA packets are 64 dwords, 98f931551bSRalph Campbell * and occur "a few per second", presumably each way. 99f931551bSRalph Campbell */ 100f931551bSRalph Campbell #define QIB_TRAFFIC_ACTIVE_THRESHOLD (2000) 101f931551bSRalph Campbell 102f931551bSRalph Campbell /* 103f931551bSRalph Campbell * Struct used to indicate which errors are logged in each of the 104f931551bSRalph Campbell * error-counters that are logged to EEPROM. A counter is incremented 105f931551bSRalph Campbell * _once_ (saturating at 255) for each event with any bits set in 106f931551bSRalph Campbell * the error or hwerror register masks below. 107f931551bSRalph Campbell */ 108f931551bSRalph Campbell #define QIB_EEP_LOG_CNT (4) 109f931551bSRalph Campbell struct qib_eep_log_mask { 110f931551bSRalph Campbell u64 errs_to_log; 111f931551bSRalph Campbell u64 hwerrs_to_log; 112f931551bSRalph Campbell }; 113f931551bSRalph Campbell 114f931551bSRalph Campbell /* 115f931551bSRalph Campbell * Below contains all data related to a single context (formerly called port). 116f931551bSRalph Campbell */ 117f931551bSRalph Campbell struct qib_ctxtdata { 118f931551bSRalph Campbell void **rcvegrbuf; 119f931551bSRalph Campbell dma_addr_t *rcvegrbuf_phys; 120f931551bSRalph Campbell /* rcvhdrq base, needs mmap before useful */ 121f931551bSRalph Campbell void *rcvhdrq; 122f931551bSRalph Campbell /* kernel virtual address where hdrqtail is updated */ 123f931551bSRalph Campbell void *rcvhdrtail_kvaddr; 124f931551bSRalph Campbell /* 125f931551bSRalph Campbell * temp buffer for expected send setup, allocated at open, instead 126f931551bSRalph Campbell * of each setup call 127f931551bSRalph Campbell */ 128f931551bSRalph Campbell void *tid_pg_list; 129f931551bSRalph Campbell /* 130f931551bSRalph Campbell * Shared page for kernel to signal user processes that send buffers 131f931551bSRalph Campbell * need disarming. The process should call QIB_CMD_DISARM_BUFS 132f931551bSRalph Campbell * or QIB_CMD_ACK_EVENT with IPATH_EVENT_DISARM_BUFS set. 133f931551bSRalph Campbell */ 134f931551bSRalph Campbell unsigned long *user_event_mask; 135f931551bSRalph Campbell /* when waiting for rcv or pioavail */ 136f931551bSRalph Campbell wait_queue_head_t wait; 137f931551bSRalph Campbell /* 138f931551bSRalph Campbell * rcvegr bufs base, physical, must fit 139f931551bSRalph Campbell * in 44 bits so 32 bit programs mmap64 44 bit works) 140f931551bSRalph Campbell */ 141f931551bSRalph Campbell dma_addr_t rcvegr_phys; 142f931551bSRalph Campbell /* mmap of hdrq, must fit in 44 bits */ 143f931551bSRalph Campbell dma_addr_t rcvhdrq_phys; 144f931551bSRalph Campbell dma_addr_t rcvhdrqtailaddr_phys; 145f931551bSRalph Campbell 146f931551bSRalph Campbell /* 147f931551bSRalph Campbell * number of opens (including slave sub-contexts) on this instance 148f931551bSRalph Campbell * (ignoring forks, dup, etc. for now) 149f931551bSRalph Campbell */ 150f931551bSRalph Campbell int cnt; 151f931551bSRalph Campbell /* 152f931551bSRalph Campbell * how much space to leave at start of eager TID entries for 153f931551bSRalph Campbell * protocol use, on each TID 154f931551bSRalph Campbell */ 155f931551bSRalph Campbell /* instead of calculating it */ 156f931551bSRalph Campbell unsigned ctxt; 157f931551bSRalph Campbell /* non-zero if ctxt is being shared. */ 158f931551bSRalph Campbell u16 subctxt_cnt; 159f931551bSRalph Campbell /* non-zero if ctxt is being shared. */ 160f931551bSRalph Campbell u16 subctxt_id; 161f931551bSRalph Campbell /* number of eager TID entries. */ 162f931551bSRalph Campbell u16 rcvegrcnt; 163f931551bSRalph Campbell /* index of first eager TID entry. */ 164f931551bSRalph Campbell u16 rcvegr_tid_base; 165f931551bSRalph Campbell /* number of pio bufs for this ctxt (all procs, if shared) */ 166f931551bSRalph Campbell u32 piocnt; 167f931551bSRalph Campbell /* first pio buffer for this ctxt */ 168f931551bSRalph Campbell u32 pio_base; 169f931551bSRalph Campbell /* chip offset of PIO buffers for this ctxt */ 170f931551bSRalph Campbell u32 piobufs; 171f931551bSRalph Campbell /* how many alloc_pages() chunks in rcvegrbuf_pages */ 172f931551bSRalph Campbell u32 rcvegrbuf_chunks; 173f931551bSRalph Campbell /* how many egrbufs per chunk */ 174f931551bSRalph Campbell u32 rcvegrbufs_perchunk; 175f931551bSRalph Campbell /* order for rcvegrbuf_pages */ 176f931551bSRalph Campbell size_t rcvegrbuf_size; 177f931551bSRalph Campbell /* rcvhdrq size (for freeing) */ 178f931551bSRalph Campbell size_t rcvhdrq_size; 179f931551bSRalph Campbell /* per-context flags for fileops/intr communication */ 180f931551bSRalph Campbell unsigned long flag; 181f931551bSRalph Campbell /* next expected TID to check when looking for free */ 182f931551bSRalph Campbell u32 tidcursor; 183f931551bSRalph Campbell /* WAIT_RCV that timed out, no interrupt */ 184f931551bSRalph Campbell u32 rcvwait_to; 185f931551bSRalph Campbell /* WAIT_PIO that timed out, no interrupt */ 186f931551bSRalph Campbell u32 piowait_to; 187f931551bSRalph Campbell /* WAIT_RCV already happened, no wait */ 188f931551bSRalph Campbell u32 rcvnowait; 189f931551bSRalph Campbell /* WAIT_PIO already happened, no wait */ 190f931551bSRalph Campbell u32 pionowait; 191f931551bSRalph Campbell /* total number of polled urgent packets */ 192f931551bSRalph Campbell u32 urgent; 193f931551bSRalph Campbell /* saved total number of polled urgent packets for poll edge trigger */ 194f931551bSRalph Campbell u32 urgent_poll; 195f931551bSRalph Campbell /* pid of process using this ctxt */ 196f931551bSRalph Campbell pid_t pid; 197f931551bSRalph Campbell pid_t subpid[QLOGIC_IB_MAX_SUBCTXT]; 198f931551bSRalph Campbell /* same size as task_struct .comm[], command that opened context */ 199f931551bSRalph Campbell char comm[16]; 200f931551bSRalph Campbell /* pkeys set by this use of this ctxt */ 201f931551bSRalph Campbell u16 pkeys[4]; 202f931551bSRalph Campbell /* so file ops can get at unit */ 203f931551bSRalph Campbell struct qib_devdata *dd; 204f931551bSRalph Campbell /* so funcs that need physical port can get it easily */ 205f931551bSRalph Campbell struct qib_pportdata *ppd; 206f931551bSRalph Campbell /* A page of memory for rcvhdrhead, rcvegrhead, rcvegrtail * N */ 207f931551bSRalph Campbell void *subctxt_uregbase; 208f931551bSRalph Campbell /* An array of pages for the eager receive buffers * N */ 209f931551bSRalph Campbell void *subctxt_rcvegrbuf; 210f931551bSRalph Campbell /* An array of pages for the eager header queue entries * N */ 211f931551bSRalph Campbell void *subctxt_rcvhdr_base; 212f931551bSRalph Campbell /* The version of the library which opened this ctxt */ 213f931551bSRalph Campbell u32 userversion; 214f931551bSRalph Campbell /* Bitmask of active slaves */ 215f931551bSRalph Campbell u32 active_slaves; 216f931551bSRalph Campbell /* Type of packets or conditions we want to poll for */ 217f931551bSRalph Campbell u16 poll_type; 218f931551bSRalph Campbell /* receive packet sequence counter */ 219f931551bSRalph Campbell u8 seq_cnt; 220f931551bSRalph Campbell u8 redirect_seq_cnt; 221f931551bSRalph Campbell /* ctxt rcvhdrq head offset */ 222f931551bSRalph Campbell u32 head; 223f931551bSRalph Campbell u32 pkt_count; 224f931551bSRalph Campbell /* QPs waiting for context processing */ 225f931551bSRalph Campbell struct list_head qp_wait_list; 226f931551bSRalph Campbell }; 227f931551bSRalph Campbell 228f931551bSRalph Campbell struct qib_sge_state; 229f931551bSRalph Campbell 230f931551bSRalph Campbell struct qib_sdma_txreq { 231f931551bSRalph Campbell int flags; 232f931551bSRalph Campbell int sg_count; 233f931551bSRalph Campbell dma_addr_t addr; 234f931551bSRalph Campbell void (*callback)(struct qib_sdma_txreq *, int); 235f931551bSRalph Campbell u16 start_idx; /* sdma private */ 236f931551bSRalph Campbell u16 next_descq_idx; /* sdma private */ 237f931551bSRalph Campbell struct list_head list; /* sdma private */ 238f931551bSRalph Campbell }; 239f931551bSRalph Campbell 240f931551bSRalph Campbell struct qib_sdma_desc { 241f931551bSRalph Campbell __le64 qw[2]; 242f931551bSRalph Campbell }; 243f931551bSRalph Campbell 244f931551bSRalph Campbell struct qib_verbs_txreq { 245f931551bSRalph Campbell struct qib_sdma_txreq txreq; 246f931551bSRalph Campbell struct qib_qp *qp; 247f931551bSRalph Campbell struct qib_swqe *wqe; 248f931551bSRalph Campbell u32 dwords; 249f931551bSRalph Campbell u16 hdr_dwords; 250f931551bSRalph Campbell u16 hdr_inx; 251f931551bSRalph Campbell struct qib_pio_header *align_buf; 252f931551bSRalph Campbell struct qib_mregion *mr; 253f931551bSRalph Campbell struct qib_sge_state *ss; 254f931551bSRalph Campbell }; 255f931551bSRalph Campbell 256f931551bSRalph Campbell #define QIB_SDMA_TXREQ_F_USELARGEBUF 0x1 257f931551bSRalph Campbell #define QIB_SDMA_TXREQ_F_HEADTOHOST 0x2 258f931551bSRalph Campbell #define QIB_SDMA_TXREQ_F_INTREQ 0x4 259f931551bSRalph Campbell #define QIB_SDMA_TXREQ_F_FREEBUF 0x8 260f931551bSRalph Campbell #define QIB_SDMA_TXREQ_F_FREEDESC 0x10 261f931551bSRalph Campbell 262f931551bSRalph Campbell #define QIB_SDMA_TXREQ_S_OK 0 263f931551bSRalph Campbell #define QIB_SDMA_TXREQ_S_SENDERROR 1 264f931551bSRalph Campbell #define QIB_SDMA_TXREQ_S_ABORTED 2 265f931551bSRalph Campbell #define QIB_SDMA_TXREQ_S_SHUTDOWN 3 266f931551bSRalph Campbell 267f931551bSRalph Campbell /* 268f931551bSRalph Campbell * Get/Set IB link-level config parameters for f_get/set_ib_cfg() 269f931551bSRalph Campbell * Mostly for MADs that set or query link parameters, also ipath 270f931551bSRalph Campbell * config interfaces 271f931551bSRalph Campbell */ 272f931551bSRalph Campbell #define QIB_IB_CFG_LIDLMC 0 /* LID (LS16b) and Mask (MS16b) */ 273f931551bSRalph Campbell #define QIB_IB_CFG_LWID_ENB 2 /* allowed Link-width */ 274f931551bSRalph Campbell #define QIB_IB_CFG_LWID 3 /* currently active Link-width */ 275f931551bSRalph Campbell #define QIB_IB_CFG_SPD_ENB 4 /* allowed Link speeds */ 276f931551bSRalph Campbell #define QIB_IB_CFG_SPD 5 /* current Link spd */ 277f931551bSRalph Campbell #define QIB_IB_CFG_RXPOL_ENB 6 /* Auto-RX-polarity enable */ 278f931551bSRalph Campbell #define QIB_IB_CFG_LREV_ENB 7 /* Auto-Lane-reversal enable */ 279f931551bSRalph Campbell #define QIB_IB_CFG_LINKLATENCY 8 /* Link Latency (IB1.2 only) */ 280f931551bSRalph Campbell #define QIB_IB_CFG_HRTBT 9 /* IB heartbeat off/enable/auto; DDR/QDR only */ 281f931551bSRalph Campbell #define QIB_IB_CFG_OP_VLS 10 /* operational VLs */ 282f931551bSRalph Campbell #define QIB_IB_CFG_VL_HIGH_CAP 11 /* num of VL high priority weights */ 283f931551bSRalph Campbell #define QIB_IB_CFG_VL_LOW_CAP 12 /* num of VL low priority weights */ 284f931551bSRalph Campbell #define QIB_IB_CFG_OVERRUN_THRESH 13 /* IB overrun threshold */ 285f931551bSRalph Campbell #define QIB_IB_CFG_PHYERR_THRESH 14 /* IB PHY error threshold */ 286f931551bSRalph Campbell #define QIB_IB_CFG_LINKDEFAULT 15 /* IB link default (sleep/poll) */ 287f931551bSRalph Campbell #define QIB_IB_CFG_PKEYS 16 /* update partition keys */ 288f931551bSRalph Campbell #define QIB_IB_CFG_MTU 17 /* update MTU in IBC */ 289f931551bSRalph Campbell #define QIB_IB_CFG_LSTATE 18 /* update linkcmd and linkinitcmd in IBC */ 290f931551bSRalph Campbell #define QIB_IB_CFG_VL_HIGH_LIMIT 19 291f931551bSRalph Campbell #define QIB_IB_CFG_PMA_TICKS 20 /* PMA sample tick resolution */ 292f931551bSRalph Campbell #define QIB_IB_CFG_PORT 21 /* switch port we are connected to */ 293f931551bSRalph Campbell 294f931551bSRalph Campbell /* 295f931551bSRalph Campbell * for CFG_LSTATE: LINKCMD in upper 16 bits, LINKINITCMD in lower 16 296f931551bSRalph Campbell * IB_LINKINITCMD_POLL and SLEEP are also used as set/get values for 297f931551bSRalph Campbell * QIB_IB_CFG_LINKDEFAULT cmd 298f931551bSRalph Campbell */ 299f931551bSRalph Campbell #define IB_LINKCMD_DOWN (0 << 16) 300f931551bSRalph Campbell #define IB_LINKCMD_ARMED (1 << 16) 301f931551bSRalph Campbell #define IB_LINKCMD_ACTIVE (2 << 16) 302f931551bSRalph Campbell #define IB_LINKINITCMD_NOP 0 303f931551bSRalph Campbell #define IB_LINKINITCMD_POLL 1 304f931551bSRalph Campbell #define IB_LINKINITCMD_SLEEP 2 305f931551bSRalph Campbell #define IB_LINKINITCMD_DISABLE 3 306f931551bSRalph Campbell 307f931551bSRalph Campbell /* 308f931551bSRalph Campbell * valid states passed to qib_set_linkstate() user call 309f931551bSRalph Campbell */ 310f931551bSRalph Campbell #define QIB_IB_LINKDOWN 0 311f931551bSRalph Campbell #define QIB_IB_LINKARM 1 312f931551bSRalph Campbell #define QIB_IB_LINKACTIVE 2 313f931551bSRalph Campbell #define QIB_IB_LINKDOWN_ONLY 3 314f931551bSRalph Campbell #define QIB_IB_LINKDOWN_SLEEP 4 315f931551bSRalph Campbell #define QIB_IB_LINKDOWN_DISABLE 5 316f931551bSRalph Campbell 317f931551bSRalph Campbell /* 318f931551bSRalph Campbell * These 7 values (SDR, DDR, and QDR may be ORed for auto-speed 319f931551bSRalph Campbell * negotiation) are used for the 3rd argument to path_f_set_ib_cfg 320f931551bSRalph Campbell * with cmd QIB_IB_CFG_SPD_ENB, by direct calls or via sysfs. They 321f931551bSRalph Campbell * are also the the possible values for qib_link_speed_enabled and active 322f931551bSRalph Campbell * The values were chosen to match values used within the IB spec. 323f931551bSRalph Campbell */ 324f931551bSRalph Campbell #define QIB_IB_SDR 1 325f931551bSRalph Campbell #define QIB_IB_DDR 2 326f931551bSRalph Campbell #define QIB_IB_QDR 4 327f931551bSRalph Campbell 328f931551bSRalph Campbell #define QIB_DEFAULT_MTU 4096 329f931551bSRalph Campbell 330cc323b2aSRalph Campbell /* max number of IB ports supported per HCA */ 331cc323b2aSRalph Campbell #define QIB_MAX_IB_PORTS 2 332cc323b2aSRalph Campbell 333f931551bSRalph Campbell /* 334f931551bSRalph Campbell * Possible IB config parameters for f_get/set_ib_table() 335f931551bSRalph Campbell */ 336f931551bSRalph Campbell #define QIB_IB_TBL_VL_HIGH_ARB 1 /* Get/set VL high priority weights */ 337f931551bSRalph Campbell #define QIB_IB_TBL_VL_LOW_ARB 2 /* Get/set VL low priority weights */ 338f931551bSRalph Campbell 339f931551bSRalph Campbell /* 340f931551bSRalph Campbell * Possible "operations" for f_rcvctrl(ppd, op, ctxt) 341f931551bSRalph Campbell * these are bits so they can be combined, e.g. 342f931551bSRalph Campbell * QIB_RCVCTRL_INTRAVAIL_ENB | QIB_RCVCTRL_CTXT_ENB 343f931551bSRalph Campbell */ 344f931551bSRalph Campbell #define QIB_RCVCTRL_TAILUPD_ENB 0x01 345f931551bSRalph Campbell #define QIB_RCVCTRL_TAILUPD_DIS 0x02 346f931551bSRalph Campbell #define QIB_RCVCTRL_CTXT_ENB 0x04 347f931551bSRalph Campbell #define QIB_RCVCTRL_CTXT_DIS 0x08 348f931551bSRalph Campbell #define QIB_RCVCTRL_INTRAVAIL_ENB 0x10 349f931551bSRalph Campbell #define QIB_RCVCTRL_INTRAVAIL_DIS 0x20 350f931551bSRalph Campbell #define QIB_RCVCTRL_PKEY_ENB 0x40 /* Note, default is enabled */ 351f931551bSRalph Campbell #define QIB_RCVCTRL_PKEY_DIS 0x80 352f931551bSRalph Campbell #define QIB_RCVCTRL_BP_ENB 0x0100 353f931551bSRalph Campbell #define QIB_RCVCTRL_BP_DIS 0x0200 354f931551bSRalph Campbell #define QIB_RCVCTRL_TIDFLOW_ENB 0x0400 355f931551bSRalph Campbell #define QIB_RCVCTRL_TIDFLOW_DIS 0x0800 356f931551bSRalph Campbell 357f931551bSRalph Campbell /* 358f931551bSRalph Campbell * Possible "operations" for f_sendctrl(ppd, op, var) 359f931551bSRalph Campbell * these are bits so they can be combined, e.g. 360f931551bSRalph Campbell * QIB_SENDCTRL_BUFAVAIL_ENB | QIB_SENDCTRL_ENB 361f931551bSRalph Campbell * Some operations (e.g. DISARM, ABORT) are known to 362f931551bSRalph Campbell * be "one-shot", so do not modify shadow. 363f931551bSRalph Campbell */ 364f931551bSRalph Campbell #define QIB_SENDCTRL_DISARM (0x1000) 365f931551bSRalph Campbell #define QIB_SENDCTRL_DISARM_BUF(bufn) ((bufn) | QIB_SENDCTRL_DISARM) 366f931551bSRalph Campbell /* available (0x2000) */ 367f931551bSRalph Campbell #define QIB_SENDCTRL_AVAIL_DIS (0x4000) 368f931551bSRalph Campbell #define QIB_SENDCTRL_AVAIL_ENB (0x8000) 369f931551bSRalph Campbell #define QIB_SENDCTRL_AVAIL_BLIP (0x10000) 370f931551bSRalph Campbell #define QIB_SENDCTRL_SEND_DIS (0x20000) 371f931551bSRalph Campbell #define QIB_SENDCTRL_SEND_ENB (0x40000) 372f931551bSRalph Campbell #define QIB_SENDCTRL_FLUSH (0x80000) 373f931551bSRalph Campbell #define QIB_SENDCTRL_CLEAR (0x100000) 374f931551bSRalph Campbell #define QIB_SENDCTRL_DISARM_ALL (0x200000) 375f931551bSRalph Campbell 376f931551bSRalph Campbell /* 377f931551bSRalph Campbell * These are the generic indices for requesting per-port 378f931551bSRalph Campbell * counter values via the f_portcntr function. They 379f931551bSRalph Campbell * are always returned as 64 bit values, although most 380f931551bSRalph Campbell * are 32 bit counters. 381f931551bSRalph Campbell */ 382f931551bSRalph Campbell /* send-related counters */ 383f931551bSRalph Campbell #define QIBPORTCNTR_PKTSEND 0U 384f931551bSRalph Campbell #define QIBPORTCNTR_WORDSEND 1U 385f931551bSRalph Campbell #define QIBPORTCNTR_PSXMITDATA 2U 386f931551bSRalph Campbell #define QIBPORTCNTR_PSXMITPKTS 3U 387f931551bSRalph Campbell #define QIBPORTCNTR_PSXMITWAIT 4U 388f931551bSRalph Campbell #define QIBPORTCNTR_SENDSTALL 5U 389f931551bSRalph Campbell /* receive-related counters */ 390f931551bSRalph Campbell #define QIBPORTCNTR_PKTRCV 6U 391f931551bSRalph Campbell #define QIBPORTCNTR_PSRCVDATA 7U 392f931551bSRalph Campbell #define QIBPORTCNTR_PSRCVPKTS 8U 393f931551bSRalph Campbell #define QIBPORTCNTR_RCVEBP 9U 394f931551bSRalph Campbell #define QIBPORTCNTR_RCVOVFL 10U 395f931551bSRalph Campbell #define QIBPORTCNTR_WORDRCV 11U 396f931551bSRalph Campbell /* IB link related error counters */ 397f931551bSRalph Campbell #define QIBPORTCNTR_RXLOCALPHYERR 12U 398f931551bSRalph Campbell #define QIBPORTCNTR_RXVLERR 13U 399f931551bSRalph Campbell #define QIBPORTCNTR_ERRICRC 14U 400f931551bSRalph Campbell #define QIBPORTCNTR_ERRVCRC 15U 401f931551bSRalph Campbell #define QIBPORTCNTR_ERRLPCRC 16U 402f931551bSRalph Campbell #define QIBPORTCNTR_BADFORMAT 17U 403f931551bSRalph Campbell #define QIBPORTCNTR_ERR_RLEN 18U 404f931551bSRalph Campbell #define QIBPORTCNTR_IBSYMBOLERR 19U 405f931551bSRalph Campbell #define QIBPORTCNTR_INVALIDRLEN 20U 406f931551bSRalph Campbell #define QIBPORTCNTR_UNSUPVL 21U 407f931551bSRalph Campbell #define QIBPORTCNTR_EXCESSBUFOVFL 22U 408f931551bSRalph Campbell #define QIBPORTCNTR_ERRLINK 23U 409f931551bSRalph Campbell #define QIBPORTCNTR_IBLINKDOWN 24U 410f931551bSRalph Campbell #define QIBPORTCNTR_IBLINKERRRECOV 25U 411f931551bSRalph Campbell #define QIBPORTCNTR_LLI 26U 412f931551bSRalph Campbell /* other error counters */ 413f931551bSRalph Campbell #define QIBPORTCNTR_RXDROPPKT 27U 414f931551bSRalph Campbell #define QIBPORTCNTR_VL15PKTDROP 28U 415f931551bSRalph Campbell #define QIBPORTCNTR_ERRPKEY 29U 416f931551bSRalph Campbell #define QIBPORTCNTR_KHDROVFL 30U 417f931551bSRalph Campbell /* sampling counters (these are actually control registers) */ 418f931551bSRalph Campbell #define QIBPORTCNTR_PSINTERVAL 31U 419f931551bSRalph Campbell #define QIBPORTCNTR_PSSTART 32U 420f931551bSRalph Campbell #define QIBPORTCNTR_PSSTAT 33U 421f931551bSRalph Campbell 422f931551bSRalph Campbell /* how often we check for packet activity for "power on hours (in seconds) */ 423f931551bSRalph Campbell #define ACTIVITY_TIMER 5 424f931551bSRalph Campbell 425f931551bSRalph Campbell /* Below is an opaque struct. Each chip (device) can maintain 426f931551bSRalph Campbell * private data needed for its operation, but not germane to the 427f931551bSRalph Campbell * rest of the driver. For convenience, we define another that 428f931551bSRalph Campbell * is chip-specific, per-port 429f931551bSRalph Campbell */ 430f931551bSRalph Campbell struct qib_chip_specific; 431f931551bSRalph Campbell struct qib_chipport_specific; 432f931551bSRalph Campbell 433f931551bSRalph Campbell enum qib_sdma_states { 434f931551bSRalph Campbell qib_sdma_state_s00_hw_down, 435f931551bSRalph Campbell qib_sdma_state_s10_hw_start_up_wait, 436f931551bSRalph Campbell qib_sdma_state_s20_idle, 437f931551bSRalph Campbell qib_sdma_state_s30_sw_clean_up_wait, 438f931551bSRalph Campbell qib_sdma_state_s40_hw_clean_up_wait, 439f931551bSRalph Campbell qib_sdma_state_s50_hw_halt_wait, 440f931551bSRalph Campbell qib_sdma_state_s99_running, 441f931551bSRalph Campbell }; 442f931551bSRalph Campbell 443f931551bSRalph Campbell enum qib_sdma_events { 444f931551bSRalph Campbell qib_sdma_event_e00_go_hw_down, 445f931551bSRalph Campbell qib_sdma_event_e10_go_hw_start, 446f931551bSRalph Campbell qib_sdma_event_e20_hw_started, 447f931551bSRalph Campbell qib_sdma_event_e30_go_running, 448f931551bSRalph Campbell qib_sdma_event_e40_sw_cleaned, 449f931551bSRalph Campbell qib_sdma_event_e50_hw_cleaned, 450f931551bSRalph Campbell qib_sdma_event_e60_hw_halted, 451f931551bSRalph Campbell qib_sdma_event_e70_go_idle, 452f931551bSRalph Campbell qib_sdma_event_e7220_err_halted, 453f931551bSRalph Campbell qib_sdma_event_e7322_err_halted, 454f931551bSRalph Campbell qib_sdma_event_e90_timer_tick, 455f931551bSRalph Campbell }; 456f931551bSRalph Campbell 457f931551bSRalph Campbell extern char *qib_sdma_state_names[]; 458f931551bSRalph Campbell extern char *qib_sdma_event_names[]; 459f931551bSRalph Campbell 460f931551bSRalph Campbell struct sdma_set_state_action { 461f931551bSRalph Campbell unsigned op_enable:1; 462f931551bSRalph Campbell unsigned op_intenable:1; 463f931551bSRalph Campbell unsigned op_halt:1; 464f931551bSRalph Campbell unsigned op_drain:1; 465f931551bSRalph Campbell unsigned go_s99_running_tofalse:1; 466f931551bSRalph Campbell unsigned go_s99_running_totrue:1; 467f931551bSRalph Campbell }; 468f931551bSRalph Campbell 469f931551bSRalph Campbell struct qib_sdma_state { 470f931551bSRalph Campbell struct kref kref; 471f931551bSRalph Campbell struct completion comp; 472f931551bSRalph Campbell enum qib_sdma_states current_state; 473f931551bSRalph Campbell struct sdma_set_state_action *set_state_action; 474f931551bSRalph Campbell unsigned current_op; 475f931551bSRalph Campbell unsigned go_s99_running; 476f931551bSRalph Campbell unsigned first_sendbuf; 477f931551bSRalph Campbell unsigned last_sendbuf; /* really last +1 */ 478f931551bSRalph Campbell /* debugging/devel */ 479f931551bSRalph Campbell enum qib_sdma_states previous_state; 480f931551bSRalph Campbell unsigned previous_op; 481f931551bSRalph Campbell enum qib_sdma_events last_event; 482f931551bSRalph Campbell }; 483f931551bSRalph Campbell 484f931551bSRalph Campbell struct xmit_wait { 485f931551bSRalph Campbell struct timer_list timer; 486f931551bSRalph Campbell u64 counter; 487f931551bSRalph Campbell u8 flags; 488f931551bSRalph Campbell struct cache { 489f931551bSRalph Campbell u64 psxmitdata; 490f931551bSRalph Campbell u64 psrcvdata; 491f931551bSRalph Campbell u64 psxmitpkts; 492f931551bSRalph Campbell u64 psrcvpkts; 493f931551bSRalph Campbell u64 psxmitwait; 494f931551bSRalph Campbell } counter_cache; 495f931551bSRalph Campbell }; 496f931551bSRalph Campbell 497f931551bSRalph Campbell /* 498f931551bSRalph Campbell * The structure below encapsulates data relevant to a physical IB Port. 499f931551bSRalph Campbell * Current chips support only one such port, but the separation 500f931551bSRalph Campbell * clarifies things a bit. Note that to conform to IB conventions, 501f931551bSRalph Campbell * port-numbers are one-based. The first or only port is port1. 502f931551bSRalph Campbell */ 503f931551bSRalph Campbell struct qib_pportdata { 504f931551bSRalph Campbell struct qib_ibport ibport_data; 505f931551bSRalph Campbell 506f931551bSRalph Campbell struct qib_devdata *dd; 507f931551bSRalph Campbell struct qib_chippport_specific *cpspec; /* chip-specific per-port */ 508f931551bSRalph Campbell struct kobject pport_kobj; 509f931551bSRalph Campbell struct kobject sl2vl_kobj; 510f931551bSRalph Campbell struct kobject diagc_kobj; 511f931551bSRalph Campbell 512f931551bSRalph Campbell /* GUID for this interface, in network order */ 513f931551bSRalph Campbell __be64 guid; 514f931551bSRalph Campbell 515f931551bSRalph Campbell /* QIB_POLL, etc. link-state specific flags, per port */ 516f931551bSRalph Campbell u32 lflags; 517f931551bSRalph Campbell /* qib_lflags driver is waiting for */ 518f931551bSRalph Campbell u32 state_wanted; 519f931551bSRalph Campbell spinlock_t lflags_lock; 520f931551bSRalph Campbell /* number of (port-specific) interrupts for this port -- saturates... */ 521f931551bSRalph Campbell u32 int_counter; 522f931551bSRalph Campbell 523f931551bSRalph Campbell /* ref count for each pkey */ 524f931551bSRalph Campbell atomic_t pkeyrefs[4]; 525f931551bSRalph Campbell 526f931551bSRalph Campbell /* 527f931551bSRalph Campbell * this address is mapped readonly into user processes so they can 528f931551bSRalph Campbell * get status cheaply, whenever they want. One qword of status per port 529f931551bSRalph Campbell */ 530f931551bSRalph Campbell u64 *statusp; 531f931551bSRalph Campbell 532f931551bSRalph Campbell /* SendDMA related entries */ 533f931551bSRalph Campbell spinlock_t sdma_lock; 534f931551bSRalph Campbell struct qib_sdma_state sdma_state; 535f931551bSRalph Campbell unsigned long sdma_buf_jiffies; 536f931551bSRalph Campbell struct qib_sdma_desc *sdma_descq; 537f931551bSRalph Campbell u64 sdma_descq_added; 538f931551bSRalph Campbell u64 sdma_descq_removed; 539f931551bSRalph Campbell u16 sdma_descq_cnt; 540f931551bSRalph Campbell u16 sdma_descq_tail; 541f931551bSRalph Campbell u16 sdma_descq_head; 542f931551bSRalph Campbell u16 sdma_next_intr; 543f931551bSRalph Campbell u16 sdma_reset_wait; 544f931551bSRalph Campbell u8 sdma_generation; 545f931551bSRalph Campbell struct tasklet_struct sdma_sw_clean_up_task; 546f931551bSRalph Campbell struct list_head sdma_activelist; 547f931551bSRalph Campbell 548f931551bSRalph Campbell dma_addr_t sdma_descq_phys; 549f931551bSRalph Campbell volatile __le64 *sdma_head_dma; /* DMA'ed by chip */ 550f931551bSRalph Campbell dma_addr_t sdma_head_phys; 551f931551bSRalph Campbell 552f931551bSRalph Campbell wait_queue_head_t state_wait; /* for state_wanted */ 553f931551bSRalph Campbell 554f931551bSRalph Campbell /* HoL blocking for SMP replies */ 555f931551bSRalph Campbell unsigned hol_state; 556f931551bSRalph Campbell struct timer_list hol_timer; 557f931551bSRalph Campbell 558f931551bSRalph Campbell /* 559f931551bSRalph Campbell * Shadow copies of registers; size indicates read access size. 560f931551bSRalph Campbell * Most of them are readonly, but some are write-only register, 561f931551bSRalph Campbell * where we manipulate the bits in the shadow copy, and then write 562f931551bSRalph Campbell * the shadow copy to qlogic_ib. 563f931551bSRalph Campbell * 564f931551bSRalph Campbell * We deliberately make most of these 32 bits, since they have 565f931551bSRalph Campbell * restricted range. For any that we read, we won't to generate 32 566f931551bSRalph Campbell * bit accesses, since Opteron will generate 2 separate 32 bit HT 567f931551bSRalph Campbell * transactions for a 64 bit read, and we want to avoid unnecessary 568f931551bSRalph Campbell * bus transactions. 569f931551bSRalph Campbell */ 570f931551bSRalph Campbell 571f931551bSRalph Campbell /* This is the 64 bit group */ 572f931551bSRalph Campbell /* last ibcstatus. opaque outside chip-specific code */ 573f931551bSRalph Campbell u64 lastibcstat; 574f931551bSRalph Campbell 575f931551bSRalph Campbell /* these are the "32 bit" regs */ 576f931551bSRalph Campbell 577f931551bSRalph Campbell /* 578f931551bSRalph Campbell * the following two are 32-bit bitmasks, but {test,clear,set}_bit 579f931551bSRalph Campbell * all expect bit fields to be "unsigned long" 580f931551bSRalph Campbell */ 581f931551bSRalph Campbell unsigned long p_rcvctrl; /* shadow per-port rcvctrl */ 582f931551bSRalph Campbell unsigned long p_sendctrl; /* shadow per-port sendctrl */ 583f931551bSRalph Campbell 584f931551bSRalph Campbell u32 ibmtu; /* The MTU programmed for this unit */ 585f931551bSRalph Campbell /* 586f931551bSRalph Campbell * Current max size IB packet (in bytes) including IB headers, that 587f931551bSRalph Campbell * we can send. Changes when ibmtu changes. 588f931551bSRalph Campbell */ 589f931551bSRalph Campbell u32 ibmaxlen; 590f931551bSRalph Campbell /* 591f931551bSRalph Campbell * ibmaxlen at init time, limited by chip and by receive buffer 592f931551bSRalph Campbell * size. Not changed after init. 593f931551bSRalph Campbell */ 594f931551bSRalph Campbell u32 init_ibmaxlen; 595f931551bSRalph Campbell /* LID programmed for this instance */ 596f931551bSRalph Campbell u16 lid; 597f931551bSRalph Campbell /* list of pkeys programmed; 0 if not set */ 598f931551bSRalph Campbell u16 pkeys[4]; 599f931551bSRalph Campbell /* LID mask control */ 600f931551bSRalph Campbell u8 lmc; 601f931551bSRalph Campbell u8 link_width_supported; 602f931551bSRalph Campbell u8 link_speed_supported; 603f931551bSRalph Campbell u8 link_width_enabled; 604f931551bSRalph Campbell u8 link_speed_enabled; 605f931551bSRalph Campbell u8 link_width_active; 606f931551bSRalph Campbell u8 link_speed_active; 607f931551bSRalph Campbell u8 vls_supported; 608f931551bSRalph Campbell u8 vls_operational; 609f931551bSRalph Campbell /* Rx Polarity inversion (compensate for ~tx on partner) */ 610f931551bSRalph Campbell u8 rx_pol_inv; 611f931551bSRalph Campbell 612f931551bSRalph Campbell u8 hw_pidx; /* physical port index */ 613f931551bSRalph Campbell u8 port; /* IB port number and index into dd->pports - 1 */ 614f931551bSRalph Campbell 615f931551bSRalph Campbell u8 delay_mult; 616f931551bSRalph Campbell 617f931551bSRalph Campbell /* used to override LED behavior */ 618f931551bSRalph Campbell u8 led_override; /* Substituted for normal value, if non-zero */ 619f931551bSRalph Campbell u16 led_override_timeoff; /* delta to next timer event */ 620f931551bSRalph Campbell u8 led_override_vals[2]; /* Alternates per blink-frame */ 621f931551bSRalph Campbell u8 led_override_phase; /* Just counts, LSB picks from vals[] */ 622f931551bSRalph Campbell atomic_t led_override_timer_active; 623f931551bSRalph Campbell /* Used to flash LEDs in override mode */ 624f931551bSRalph Campbell struct timer_list led_override_timer; 625f931551bSRalph Campbell struct xmit_wait cong_stats; 626f931551bSRalph Campbell struct timer_list symerr_clear_timer; 627f931551bSRalph Campbell }; 628f931551bSRalph Campbell 629f931551bSRalph Campbell /* Observers. Not to be taken lightly, possibly not to ship. */ 630f931551bSRalph Campbell /* 631f931551bSRalph Campbell * If a diag read or write is to (bottom <= offset <= top), 632f931551bSRalph Campbell * the "hoook" is called, allowing, e.g. shadows to be 633f931551bSRalph Campbell * updated in sync with the driver. struct diag_observer 634f931551bSRalph Campbell * is the "visible" part. 635f931551bSRalph Campbell */ 636f931551bSRalph Campbell struct diag_observer; 637f931551bSRalph Campbell 638f931551bSRalph Campbell typedef int (*diag_hook) (struct qib_devdata *dd, 639f931551bSRalph Campbell const struct diag_observer *op, 640f931551bSRalph Campbell u32 offs, u64 *data, u64 mask, int only_32); 641f931551bSRalph Campbell 642f931551bSRalph Campbell struct diag_observer { 643f931551bSRalph Campbell diag_hook hook; 644f931551bSRalph Campbell u32 bottom; 645f931551bSRalph Campbell u32 top; 646f931551bSRalph Campbell }; 647f931551bSRalph Campbell 648f931551bSRalph Campbell extern int qib_register_observer(struct qib_devdata *dd, 649f931551bSRalph Campbell const struct diag_observer *op); 650f931551bSRalph Campbell 651f931551bSRalph Campbell /* Only declared here, not defined. Private to diags */ 652f931551bSRalph Campbell struct diag_observer_list_elt; 653f931551bSRalph Campbell 654f931551bSRalph Campbell /* device data struct now contains only "general per-device" info. 655f931551bSRalph Campbell * fields related to a physical IB port are in a qib_pportdata struct, 65625985edcSLucas De Marchi * described above) while fields only used by a particular chip-type are in 657f931551bSRalph Campbell * a qib_chipdata struct, whose contents are opaque to this file. 658f931551bSRalph Campbell */ 659f931551bSRalph Campbell struct qib_devdata { 660f931551bSRalph Campbell struct qib_ibdev verbs_dev; /* must be first */ 661f931551bSRalph Campbell struct list_head list; 662f931551bSRalph Campbell /* pointers to related structs for this device */ 663f931551bSRalph Campbell /* pci access data structure */ 664f931551bSRalph Campbell struct pci_dev *pcidev; 665f931551bSRalph Campbell struct cdev *user_cdev; 666f931551bSRalph Campbell struct cdev *diag_cdev; 667f931551bSRalph Campbell struct device *user_device; 668f931551bSRalph Campbell struct device *diag_device; 669f931551bSRalph Campbell 670f931551bSRalph Campbell /* mem-mapped pointer to base of chip regs */ 671f931551bSRalph Campbell u64 __iomem *kregbase; 672f931551bSRalph Campbell /* end of mem-mapped chip space excluding sendbuf and user regs */ 673f931551bSRalph Campbell u64 __iomem *kregend; 674f931551bSRalph Campbell /* physical address of chip for io_remap, etc. */ 675f931551bSRalph Campbell resource_size_t physaddr; 676f931551bSRalph Campbell /* qib_cfgctxts pointers */ 677f931551bSRalph Campbell struct qib_ctxtdata **rcd; /* Receive Context Data */ 678f931551bSRalph Campbell 679f931551bSRalph Campbell /* qib_pportdata, points to array of (physical) port-specific 680f931551bSRalph Campbell * data structs, indexed by pidx (0..n-1) 681f931551bSRalph Campbell */ 682f931551bSRalph Campbell struct qib_pportdata *pport; 683f931551bSRalph Campbell struct qib_chip_specific *cspec; /* chip-specific */ 684f931551bSRalph Campbell 685f931551bSRalph Campbell /* kvirt address of 1st 2k pio buffer */ 686f931551bSRalph Campbell void __iomem *pio2kbase; 687f931551bSRalph Campbell /* kvirt address of 1st 4k pio buffer */ 688f931551bSRalph Campbell void __iomem *pio4kbase; 689f931551bSRalph Campbell /* mem-mapped pointer to base of PIO buffers (if using WC PAT) */ 690f931551bSRalph Campbell void __iomem *piobase; 691f931551bSRalph Campbell /* mem-mapped pointer to base of user chip regs (if using WC PAT) */ 692f931551bSRalph Campbell u64 __iomem *userbase; 693fce24a9dSDave Olson void __iomem *piovl15base; /* base of VL15 buffers, if not WC */ 694f931551bSRalph Campbell /* 695f931551bSRalph Campbell * points to area where PIOavail registers will be DMA'ed. 696f931551bSRalph Campbell * Has to be on a page of it's own, because the page will be 697f931551bSRalph Campbell * mapped into user program space. This copy is *ONLY* ever 698f931551bSRalph Campbell * written by DMA, not by the driver! Need a copy per device 699f931551bSRalph Campbell * when we get to multiple devices 700f931551bSRalph Campbell */ 701f931551bSRalph Campbell volatile __le64 *pioavailregs_dma; /* DMA'ed by chip */ 702f931551bSRalph Campbell /* physical address where updates occur */ 703f931551bSRalph Campbell dma_addr_t pioavailregs_phys; 704f931551bSRalph Campbell 705f931551bSRalph Campbell /* device-specific implementations of functions needed by 706f931551bSRalph Campbell * common code. Contrary to previous consensus, we can't 707f931551bSRalph Campbell * really just point to a device-specific table, because we 708f931551bSRalph Campbell * may need to "bend", e.g. *_f_put_tid 709f931551bSRalph Campbell */ 710f931551bSRalph Campbell /* fallback to alternate interrupt type if possible */ 711f931551bSRalph Campbell int (*f_intr_fallback)(struct qib_devdata *); 712f931551bSRalph Campbell /* hard reset chip */ 713f931551bSRalph Campbell int (*f_reset)(struct qib_devdata *); 714f931551bSRalph Campbell void (*f_quiet_serdes)(struct qib_pportdata *); 715f931551bSRalph Campbell int (*f_bringup_serdes)(struct qib_pportdata *); 716f931551bSRalph Campbell int (*f_early_init)(struct qib_devdata *); 717f931551bSRalph Campbell void (*f_clear_tids)(struct qib_devdata *, struct qib_ctxtdata *); 718f931551bSRalph Campbell void (*f_put_tid)(struct qib_devdata *, u64 __iomem*, 719f931551bSRalph Campbell u32, unsigned long); 720f931551bSRalph Campbell void (*f_cleanup)(struct qib_devdata *); 721f931551bSRalph Campbell void (*f_setextled)(struct qib_pportdata *, u32); 722f931551bSRalph Campbell /* fill out chip-specific fields */ 723f931551bSRalph Campbell int (*f_get_base_info)(struct qib_ctxtdata *, struct qib_base_info *); 724f931551bSRalph Campbell /* free irq */ 725f931551bSRalph Campbell void (*f_free_irq)(struct qib_devdata *); 726f931551bSRalph Campbell struct qib_message_header *(*f_get_msgheader) 727f931551bSRalph Campbell (struct qib_devdata *, __le32 *); 728f931551bSRalph Campbell void (*f_config_ctxts)(struct qib_devdata *); 729f931551bSRalph Campbell int (*f_get_ib_cfg)(struct qib_pportdata *, int); 730f931551bSRalph Campbell int (*f_set_ib_cfg)(struct qib_pportdata *, int, u32); 731f931551bSRalph Campbell int (*f_set_ib_loopback)(struct qib_pportdata *, const char *); 732f931551bSRalph Campbell int (*f_get_ib_table)(struct qib_pportdata *, int, void *); 733f931551bSRalph Campbell int (*f_set_ib_table)(struct qib_pportdata *, int, void *); 734f931551bSRalph Campbell u32 (*f_iblink_state)(u64); 735f931551bSRalph Campbell u8 (*f_ibphys_portstate)(u64); 736f931551bSRalph Campbell void (*f_xgxs_reset)(struct qib_pportdata *); 737f931551bSRalph Campbell /* per chip actions needed for IB Link up/down changes */ 738f931551bSRalph Campbell int (*f_ib_updown)(struct qib_pportdata *, int, u64); 739f931551bSRalph Campbell u32 __iomem *(*f_getsendbuf)(struct qib_pportdata *, u64, u32 *); 740f931551bSRalph Campbell /* Read/modify/write of GPIO pins (potentially chip-specific */ 741f931551bSRalph Campbell int (*f_gpio_mod)(struct qib_devdata *dd, u32 out, u32 dir, 742f931551bSRalph Campbell u32 mask); 743f931551bSRalph Campbell /* Enable writes to config EEPROM (if supported) */ 744f931551bSRalph Campbell int (*f_eeprom_wen)(struct qib_devdata *dd, int wen); 745f931551bSRalph Campbell /* 746f931551bSRalph Campbell * modify rcvctrl shadow[s] and write to appropriate chip-regs. 747f931551bSRalph Campbell * see above QIB_RCVCTRL_xxx_ENB/DIS for operations. 748f931551bSRalph Campbell * (ctxt == -1) means "all contexts", only meaningful for 749f931551bSRalph Campbell * clearing. Could remove if chip_spec shutdown properly done. 750f931551bSRalph Campbell */ 751f931551bSRalph Campbell void (*f_rcvctrl)(struct qib_pportdata *, unsigned int op, 752f931551bSRalph Campbell int ctxt); 753f931551bSRalph Campbell /* Read/modify/write sendctrl appropriately for op and port. */ 754f931551bSRalph Campbell void (*f_sendctrl)(struct qib_pportdata *, u32 op); 755f931551bSRalph Campbell void (*f_set_intr_state)(struct qib_devdata *, u32); 756f931551bSRalph Campbell void (*f_set_armlaunch)(struct qib_devdata *, u32); 757f931551bSRalph Campbell void (*f_wantpiobuf_intr)(struct qib_devdata *, u32); 758f931551bSRalph Campbell int (*f_late_initreg)(struct qib_devdata *); 759f931551bSRalph Campbell int (*f_init_sdma_regs)(struct qib_pportdata *); 760f931551bSRalph Campbell u16 (*f_sdma_gethead)(struct qib_pportdata *); 761f931551bSRalph Campbell int (*f_sdma_busy)(struct qib_pportdata *); 762f931551bSRalph Campbell void (*f_sdma_update_tail)(struct qib_pportdata *, u16); 763f931551bSRalph Campbell void (*f_sdma_set_desc_cnt)(struct qib_pportdata *, unsigned); 764f931551bSRalph Campbell void (*f_sdma_sendctrl)(struct qib_pportdata *, unsigned); 765f931551bSRalph Campbell void (*f_sdma_hw_clean_up)(struct qib_pportdata *); 766f931551bSRalph Campbell void (*f_sdma_hw_start_up)(struct qib_pportdata *); 767f931551bSRalph Campbell void (*f_sdma_init_early)(struct qib_pportdata *); 768f931551bSRalph Campbell void (*f_set_cntr_sample)(struct qib_pportdata *, u32, u32); 76919ede2e4SMike Marciniszyn void (*f_update_usrhead)(struct qib_ctxtdata *, u64, u32, u32, u32); 770f931551bSRalph Campbell u32 (*f_hdrqempty)(struct qib_ctxtdata *); 771f931551bSRalph Campbell u64 (*f_portcntr)(struct qib_pportdata *, u32); 772f931551bSRalph Campbell u32 (*f_read_cntrs)(struct qib_devdata *, loff_t, char **, 773f931551bSRalph Campbell u64 **); 774f931551bSRalph Campbell u32 (*f_read_portcntrs)(struct qib_devdata *, loff_t, u32, 775f931551bSRalph Campbell char **, u64 **); 776f931551bSRalph Campbell u32 (*f_setpbc_control)(struct qib_pportdata *, u32, u8, u8); 777f931551bSRalph Campbell void (*f_initvl15_bufs)(struct qib_devdata *); 778f931551bSRalph Campbell void (*f_init_ctxt)(struct qib_ctxtdata *); 779f931551bSRalph Campbell void (*f_txchk_change)(struct qib_devdata *, u32, u32, u32, 780f931551bSRalph Campbell struct qib_ctxtdata *); 781f931551bSRalph Campbell void (*f_writescratch)(struct qib_devdata *, u32); 782f931551bSRalph Campbell int (*f_tempsense_rd)(struct qib_devdata *, int regnum); 783f931551bSRalph Campbell 784f931551bSRalph Campbell char *boardname; /* human readable board info */ 785f931551bSRalph Campbell 786f931551bSRalph Campbell /* template for writing TIDs */ 787f931551bSRalph Campbell u64 tidtemplate; 788f931551bSRalph Campbell /* value to write to free TIDs */ 789f931551bSRalph Campbell u64 tidinvalid; 790f931551bSRalph Campbell 791f931551bSRalph Campbell /* number of registers used for pioavail */ 792f931551bSRalph Campbell u32 pioavregs; 793f931551bSRalph Campbell /* device (not port) flags, basically device capabilities */ 794f931551bSRalph Campbell u32 flags; 795f931551bSRalph Campbell /* last buffer for user use */ 796f931551bSRalph Campbell u32 lastctxt_piobuf; 797f931551bSRalph Campbell 798f931551bSRalph Campbell /* saturating counter of (non-port-specific) device interrupts */ 799f931551bSRalph Campbell u32 int_counter; 800f931551bSRalph Campbell 801f931551bSRalph Campbell /* pio bufs allocated per ctxt */ 802f931551bSRalph Campbell u32 pbufsctxt; 803f931551bSRalph Campbell /* if remainder on bufs/ctxt, ctxts < extrabuf get 1 extra */ 804f931551bSRalph Campbell u32 ctxts_extrabuf; 805f931551bSRalph Campbell /* 806f931551bSRalph Campbell * number of ctxts configured as max; zero is set to number chip 807f931551bSRalph Campbell * supports, less gives more pio bufs/ctxt, etc. 808f931551bSRalph Campbell */ 809f931551bSRalph Campbell u32 cfgctxts; 810*53ab1c64SMike Marciniszyn /* 811*53ab1c64SMike Marciniszyn * number of ctxts available for PSM open 812*53ab1c64SMike Marciniszyn */ 813*53ab1c64SMike Marciniszyn u32 freectxts; 814f931551bSRalph Campbell 815f931551bSRalph Campbell /* 816f931551bSRalph Campbell * hint that we should update pioavailshadow before 817f931551bSRalph Campbell * looking for a PIO buffer 818f931551bSRalph Campbell */ 819f931551bSRalph Campbell u32 upd_pio_shadow; 820f931551bSRalph Campbell 821f931551bSRalph Campbell /* internal debugging stats */ 822f931551bSRalph Campbell u32 maxpkts_call; 823f931551bSRalph Campbell u32 avgpkts_call; 824f931551bSRalph Campbell u64 nopiobufs; 825f931551bSRalph Campbell 826f931551bSRalph Campbell /* PCI Vendor ID (here for NodeInfo) */ 827f931551bSRalph Campbell u16 vendorid; 828f931551bSRalph Campbell /* PCI Device ID (here for NodeInfo) */ 829f931551bSRalph Campbell u16 deviceid; 830f931551bSRalph Campbell /* for write combining settings */ 831f931551bSRalph Campbell unsigned long wc_cookie; 832f931551bSRalph Campbell unsigned long wc_base; 833f931551bSRalph Campbell unsigned long wc_len; 834f931551bSRalph Campbell 835f931551bSRalph Campbell /* shadow copy of struct page *'s for exp tid pages */ 836f931551bSRalph Campbell struct page **pageshadow; 837f931551bSRalph Campbell /* shadow copy of dma handles for exp tid pages */ 838f931551bSRalph Campbell dma_addr_t *physshadow; 839f931551bSRalph Campbell u64 __iomem *egrtidbase; 840f931551bSRalph Campbell spinlock_t sendctrl_lock; /* protect changes to sendctrl shadow */ 841f931551bSRalph Campbell /* around rcd and (user ctxts) ctxt_cnt use (intr vs free) */ 842f931551bSRalph Campbell spinlock_t uctxt_lock; /* rcd and user context changes */ 843f931551bSRalph Campbell /* 844f931551bSRalph Campbell * per unit status, see also portdata statusp 845f931551bSRalph Campbell * mapped readonly into user processes so they can get unit and 846f931551bSRalph Campbell * IB link status cheaply 847f931551bSRalph Campbell */ 848f931551bSRalph Campbell u64 *devstatusp; 849f931551bSRalph Campbell char *freezemsg; /* freeze msg if hw error put chip in freeze */ 850f931551bSRalph Campbell u32 freezelen; /* max length of freezemsg */ 851f931551bSRalph Campbell /* timer used to prevent stats overflow, error throttling, etc. */ 852f931551bSRalph Campbell struct timer_list stats_timer; 853f931551bSRalph Campbell 854f931551bSRalph Campbell /* timer to verify interrupts work, and fallback if possible */ 855f931551bSRalph Campbell struct timer_list intrchk_timer; 856f931551bSRalph Campbell unsigned long ureg_align; /* user register alignment */ 857f931551bSRalph Campbell 858f931551bSRalph Campbell /* 859f931551bSRalph Campbell * Protects pioavailshadow, pioavailkernel, pio_need_disarm, and 860f931551bSRalph Campbell * pio_writing. 861f931551bSRalph Campbell */ 862f931551bSRalph Campbell spinlock_t pioavail_lock; 863f931551bSRalph Campbell 864f931551bSRalph Campbell /* 865f931551bSRalph Campbell * Shadow copies of registers; size indicates read access size. 866f931551bSRalph Campbell * Most of them are readonly, but some are write-only register, 867f931551bSRalph Campbell * where we manipulate the bits in the shadow copy, and then write 868f931551bSRalph Campbell * the shadow copy to qlogic_ib. 869f931551bSRalph Campbell * 870f931551bSRalph Campbell * We deliberately make most of these 32 bits, since they have 871f931551bSRalph Campbell * restricted range. For any that we read, we won't to generate 32 872f931551bSRalph Campbell * bit accesses, since Opteron will generate 2 separate 32 bit HT 873f931551bSRalph Campbell * transactions for a 64 bit read, and we want to avoid unnecessary 874f931551bSRalph Campbell * bus transactions. 875f931551bSRalph Campbell */ 876f931551bSRalph Campbell 877f931551bSRalph Campbell /* This is the 64 bit group */ 878f931551bSRalph Campbell 879f931551bSRalph Campbell unsigned long pioavailshadow[6]; 880f931551bSRalph Campbell /* bitmap of send buffers available for the kernel to use with PIO. */ 881f931551bSRalph Campbell unsigned long pioavailkernel[6]; 882f931551bSRalph Campbell /* bitmap of send buffers which need to be disarmed. */ 883f931551bSRalph Campbell unsigned long pio_need_disarm[3]; 884f931551bSRalph Campbell /* bitmap of send buffers which are being written to. */ 885f931551bSRalph Campbell unsigned long pio_writing[3]; 886f931551bSRalph Campbell /* kr_revision shadow */ 887f931551bSRalph Campbell u64 revision; 888f931551bSRalph Campbell /* Base GUID for device (from eeprom, network order) */ 889f931551bSRalph Campbell __be64 base_guid; 890f931551bSRalph Campbell 891f931551bSRalph Campbell /* 892f931551bSRalph Campbell * kr_sendpiobufbase value (chip offset of pio buffers), and the 893f931551bSRalph Campbell * base of the 2KB buffer s(user processes only use 2K) 894f931551bSRalph Campbell */ 895f931551bSRalph Campbell u64 piobufbase; 896f931551bSRalph Campbell u32 pio2k_bufbase; 897f931551bSRalph Campbell 898f931551bSRalph Campbell /* these are the "32 bit" regs */ 899f931551bSRalph Campbell 900f931551bSRalph Campbell /* number of GUIDs in the flash for this interface */ 901f931551bSRalph Campbell u32 nguid; 902f931551bSRalph Campbell /* 903f931551bSRalph Campbell * the following two are 32-bit bitmasks, but {test,clear,set}_bit 904f931551bSRalph Campbell * all expect bit fields to be "unsigned long" 905f931551bSRalph Campbell */ 906f931551bSRalph Campbell unsigned long rcvctrl; /* shadow per device rcvctrl */ 907f931551bSRalph Campbell unsigned long sendctrl; /* shadow per device sendctrl */ 908f931551bSRalph Campbell 909f931551bSRalph Campbell /* value we put in kr_rcvhdrcnt */ 910f931551bSRalph Campbell u32 rcvhdrcnt; 911f931551bSRalph Campbell /* value we put in kr_rcvhdrsize */ 912f931551bSRalph Campbell u32 rcvhdrsize; 913f931551bSRalph Campbell /* value we put in kr_rcvhdrentsize */ 914f931551bSRalph Campbell u32 rcvhdrentsize; 915f931551bSRalph Campbell /* kr_ctxtcnt value */ 916f931551bSRalph Campbell u32 ctxtcnt; 917f931551bSRalph Campbell /* kr_pagealign value */ 918f931551bSRalph Campbell u32 palign; 919f931551bSRalph Campbell /* number of "2KB" PIO buffers */ 920f931551bSRalph Campbell u32 piobcnt2k; 921f931551bSRalph Campbell /* size in bytes of "2KB" PIO buffers */ 922f931551bSRalph Campbell u32 piosize2k; 923f931551bSRalph Campbell /* max usable size in dwords of a "2KB" PIO buffer before going "4KB" */ 924f931551bSRalph Campbell u32 piosize2kmax_dwords; 925f931551bSRalph Campbell /* number of "4KB" PIO buffers */ 926f931551bSRalph Campbell u32 piobcnt4k; 927f931551bSRalph Campbell /* size in bytes of "4KB" PIO buffers */ 928f931551bSRalph Campbell u32 piosize4k; 929f931551bSRalph Campbell /* kr_rcvegrbase value */ 930f931551bSRalph Campbell u32 rcvegrbase; 931f931551bSRalph Campbell /* kr_rcvtidbase value */ 932f931551bSRalph Campbell u32 rcvtidbase; 933f931551bSRalph Campbell /* kr_rcvtidcnt value */ 934f931551bSRalph Campbell u32 rcvtidcnt; 935f931551bSRalph Campbell /* kr_userregbase */ 936f931551bSRalph Campbell u32 uregbase; 937f931551bSRalph Campbell /* shadow the control register contents */ 938f931551bSRalph Campbell u32 control; 939f931551bSRalph Campbell 940f931551bSRalph Campbell /* chip address space used by 4k pio buffers */ 941f931551bSRalph Campbell u32 align4k; 942f931551bSRalph Campbell /* size of each rcvegrbuffer */ 943f931551bSRalph Campbell u32 rcvegrbufsize; 944f931551bSRalph Campbell /* localbus width (1, 2,4,8,16,32) from config space */ 945f931551bSRalph Campbell u32 lbus_width; 946f931551bSRalph Campbell /* localbus speed in MHz */ 947f931551bSRalph Campbell u32 lbus_speed; 948f931551bSRalph Campbell int unit; /* unit # of this chip */ 949f931551bSRalph Campbell 950f931551bSRalph Campbell /* start of CHIP_SPEC move to chipspec, but need code changes */ 951f931551bSRalph Campbell /* low and high portions of MSI capability/vector */ 952f931551bSRalph Campbell u32 msi_lo; 953f931551bSRalph Campbell /* saved after PCIe init for restore after reset */ 954f931551bSRalph Campbell u32 msi_hi; 955f931551bSRalph Campbell /* MSI data (vector) saved for restore */ 956f931551bSRalph Campbell u16 msi_data; 957f931551bSRalph Campbell /* so we can rewrite it after a chip reset */ 958f931551bSRalph Campbell u32 pcibar0; 959f931551bSRalph Campbell /* so we can rewrite it after a chip reset */ 960f931551bSRalph Campbell u32 pcibar1; 961f931551bSRalph Campbell u64 rhdrhead_intr_off; 962f931551bSRalph Campbell 963f931551bSRalph Campbell /* 964f931551bSRalph Campbell * ASCII serial number, from flash, large enough for original 965f931551bSRalph Campbell * all digit strings, and longer QLogic serial number format 966f931551bSRalph Campbell */ 967f931551bSRalph Campbell u8 serial[16]; 968f931551bSRalph Campbell /* human readable board version */ 969f931551bSRalph Campbell u8 boardversion[96]; 970f931551bSRalph Campbell u8 lbus_info[32]; /* human readable localbus info */ 971f931551bSRalph Campbell /* chip major rev, from qib_revision */ 972f931551bSRalph Campbell u8 majrev; 973f931551bSRalph Campbell /* chip minor rev, from qib_revision */ 974f931551bSRalph Campbell u8 minrev; 975f931551bSRalph Campbell 976f931551bSRalph Campbell /* Misc small ints */ 977f931551bSRalph Campbell /* Number of physical ports available */ 978f931551bSRalph Campbell u8 num_pports; 979f931551bSRalph Campbell /* Lowest context number which can be used by user processes */ 980f931551bSRalph Campbell u8 first_user_ctxt; 981f931551bSRalph Campbell u8 n_krcv_queues; 982f931551bSRalph Campbell u8 qpn_mask; 983f931551bSRalph Campbell u8 skip_kctxt_mask; 984f931551bSRalph Campbell 985f931551bSRalph Campbell u16 rhf_offset; /* offset of RHF within receive header entry */ 986f931551bSRalph Campbell 987f931551bSRalph Campbell /* 988f931551bSRalph Campbell * GPIO pins for twsi-connected devices, and device code for eeprom 989f931551bSRalph Campbell */ 990f931551bSRalph Campbell u8 gpio_sda_num; 991f931551bSRalph Campbell u8 gpio_scl_num; 992f931551bSRalph Campbell u8 twsi_eeprom_dev; 993f931551bSRalph Campbell u8 board_atten; 994f931551bSRalph Campbell 995f931551bSRalph Campbell /* Support (including locks) for EEPROM logging of errors and time */ 996f931551bSRalph Campbell /* control access to actual counters, timer */ 997f931551bSRalph Campbell spinlock_t eep_st_lock; 998f931551bSRalph Campbell /* control high-level access to EEPROM */ 999f931551bSRalph Campbell struct mutex eep_lock; 1000f931551bSRalph Campbell uint64_t traffic_wds; 1001f931551bSRalph Campbell /* active time is kept in seconds, but logged in hours */ 1002f931551bSRalph Campbell atomic_t active_time; 1003f931551bSRalph Campbell /* Below are nominal shadow of EEPROM, new since last EEPROM update */ 1004f931551bSRalph Campbell uint8_t eep_st_errs[QIB_EEP_LOG_CNT]; 1005f931551bSRalph Campbell uint8_t eep_st_new_errs[QIB_EEP_LOG_CNT]; 1006f931551bSRalph Campbell uint16_t eep_hrs; 1007f931551bSRalph Campbell /* 1008f931551bSRalph Campbell * masks for which bits of errs, hwerrs that cause 1009f931551bSRalph Campbell * each of the counters to increment. 1010f931551bSRalph Campbell */ 1011f931551bSRalph Campbell struct qib_eep_log_mask eep_st_masks[QIB_EEP_LOG_CNT]; 1012f931551bSRalph Campbell struct qib_diag_client *diag_client; 1013f931551bSRalph Campbell spinlock_t qib_diag_trans_lock; /* protect diag observer ops */ 1014f931551bSRalph Campbell struct diag_observer_list_elt *diag_observer_list; 1015f931551bSRalph Campbell 1016f931551bSRalph Campbell u8 psxmitwait_supported; 1017f931551bSRalph Campbell /* cycle length of PS* counters in HW (in picoseconds) */ 1018f931551bSRalph Campbell u16 psxmitwait_check_rate; 1019e67306a3SMike Marciniszyn /* high volume overflow errors defered to tasklet */ 1020e67306a3SMike Marciniszyn struct tasklet_struct error_tasklet; 1021f931551bSRalph Campbell }; 1022f931551bSRalph Campbell 1023f931551bSRalph Campbell /* hol_state values */ 1024f931551bSRalph Campbell #define QIB_HOL_UP 0 1025f931551bSRalph Campbell #define QIB_HOL_INIT 1 1026f931551bSRalph Campbell 1027f931551bSRalph Campbell #define QIB_SDMA_SENDCTRL_OP_ENABLE (1U << 0) 1028f931551bSRalph Campbell #define QIB_SDMA_SENDCTRL_OP_INTENABLE (1U << 1) 1029f931551bSRalph Campbell #define QIB_SDMA_SENDCTRL_OP_HALT (1U << 2) 1030f931551bSRalph Campbell #define QIB_SDMA_SENDCTRL_OP_CLEANUP (1U << 3) 1031f931551bSRalph Campbell #define QIB_SDMA_SENDCTRL_OP_DRAIN (1U << 4) 1032f931551bSRalph Campbell 1033f931551bSRalph Campbell /* operation types for f_txchk_change() */ 1034f931551bSRalph Campbell #define TXCHK_CHG_TYPE_DIS1 3 1035f931551bSRalph Campbell #define TXCHK_CHG_TYPE_ENAB1 2 1036f931551bSRalph Campbell #define TXCHK_CHG_TYPE_KERN 1 1037f931551bSRalph Campbell #define TXCHK_CHG_TYPE_USER 0 1038f931551bSRalph Campbell 1039f931551bSRalph Campbell #define QIB_CHASE_TIME msecs_to_jiffies(145) 1040f931551bSRalph Campbell #define QIB_CHASE_DIS_TIME msecs_to_jiffies(160) 1041f931551bSRalph Campbell 1042f931551bSRalph Campbell /* Private data for file operations */ 1043f931551bSRalph Campbell struct qib_filedata { 1044f931551bSRalph Campbell struct qib_ctxtdata *rcd; 1045f931551bSRalph Campbell unsigned subctxt; 1046f931551bSRalph Campbell unsigned tidcursor; 1047f931551bSRalph Campbell struct qib_user_sdma_queue *pq; 1048f931551bSRalph Campbell int rec_cpu_num; /* for cpu affinity; -1 if none */ 1049f931551bSRalph Campbell }; 1050f931551bSRalph Campbell 1051f931551bSRalph Campbell extern struct list_head qib_dev_list; 1052f931551bSRalph Campbell extern spinlock_t qib_devs_lock; 1053f931551bSRalph Campbell extern struct qib_devdata *qib_lookup(int unit); 1054f931551bSRalph Campbell extern u32 qib_cpulist_count; 1055f931551bSRalph Campbell extern unsigned long *qib_cpulist; 1056f931551bSRalph Campbell 1057f931551bSRalph Campbell extern unsigned qib_wc_pat; 1058f931551bSRalph Campbell int qib_init(struct qib_devdata *, int); 1059f931551bSRalph Campbell int init_chip_wc_pat(struct qib_devdata *dd, u32); 1060f931551bSRalph Campbell int qib_enable_wc(struct qib_devdata *dd); 1061f931551bSRalph Campbell void qib_disable_wc(struct qib_devdata *dd); 1062f931551bSRalph Campbell int qib_count_units(int *npresentp, int *nupp); 1063f931551bSRalph Campbell int qib_count_active_units(void); 1064f931551bSRalph Campbell 1065f931551bSRalph Campbell int qib_cdev_init(int minor, const char *name, 1066f931551bSRalph Campbell const struct file_operations *fops, 1067f931551bSRalph Campbell struct cdev **cdevp, struct device **devp); 1068f931551bSRalph Campbell void qib_cdev_cleanup(struct cdev **cdevp, struct device **devp); 1069f931551bSRalph Campbell int qib_dev_init(void); 1070f931551bSRalph Campbell void qib_dev_cleanup(void); 1071f931551bSRalph Campbell 1072f931551bSRalph Campbell int qib_diag_add(struct qib_devdata *); 1073f931551bSRalph Campbell void qib_diag_remove(struct qib_devdata *); 1074f931551bSRalph Campbell void qib_handle_e_ibstatuschanged(struct qib_pportdata *, u64); 1075f931551bSRalph Campbell void qib_sdma_update_tail(struct qib_pportdata *, u16); /* hold sdma_lock */ 1076f931551bSRalph Campbell 1077f931551bSRalph Campbell int qib_decode_err(struct qib_devdata *dd, char *buf, size_t blen, u64 err); 1078f931551bSRalph Campbell void qib_bad_intrstatus(struct qib_devdata *); 1079f931551bSRalph Campbell void qib_handle_urcv(struct qib_devdata *, u64); 1080f931551bSRalph Campbell 1081f931551bSRalph Campbell /* clean up any per-chip chip-specific stuff */ 1082f931551bSRalph Campbell void qib_chip_cleanup(struct qib_devdata *); 1083f931551bSRalph Campbell /* clean up any chip type-specific stuff */ 1084f931551bSRalph Campbell void qib_chip_done(void); 1085f931551bSRalph Campbell 1086f931551bSRalph Campbell /* check to see if we have to force ordering for write combining */ 1087f931551bSRalph Campbell int qib_unordered_wc(void); 1088f931551bSRalph Campbell void qib_pio_copy(void __iomem *to, const void *from, size_t count); 1089f931551bSRalph Campbell 1090f931551bSRalph Campbell void qib_disarm_piobufs(struct qib_devdata *, unsigned, unsigned); 1091f931551bSRalph Campbell int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *); 1092f931551bSRalph Campbell void qib_disarm_piobufs_set(struct qib_devdata *, unsigned long *, unsigned); 1093f931551bSRalph Campbell void qib_cancel_sends(struct qib_pportdata *); 1094f931551bSRalph Campbell 1095f931551bSRalph Campbell int qib_create_rcvhdrq(struct qib_devdata *, struct qib_ctxtdata *); 1096f931551bSRalph Campbell int qib_setup_eagerbufs(struct qib_ctxtdata *); 1097f931551bSRalph Campbell void qib_set_ctxtcnt(struct qib_devdata *); 1098f931551bSRalph Campbell int qib_create_ctxts(struct qib_devdata *dd); 1099f931551bSRalph Campbell struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *, u32); 1100f931551bSRalph Campbell void qib_init_pportdata(struct qib_pportdata *, struct qib_devdata *, u8, u8); 1101f931551bSRalph Campbell void qib_free_ctxtdata(struct qib_devdata *, struct qib_ctxtdata *); 1102f931551bSRalph Campbell 1103f931551bSRalph Campbell u32 qib_kreceive(struct qib_ctxtdata *, u32 *, u32 *); 1104f931551bSRalph Campbell int qib_reset_device(int); 1105f931551bSRalph Campbell int qib_wait_linkstate(struct qib_pportdata *, u32, int); 1106f931551bSRalph Campbell int qib_set_linkstate(struct qib_pportdata *, u8); 1107f931551bSRalph Campbell int qib_set_mtu(struct qib_pportdata *, u16); 1108f931551bSRalph Campbell int qib_set_lid(struct qib_pportdata *, u32, u8); 1109f931551bSRalph Campbell void qib_hol_down(struct qib_pportdata *); 1110f931551bSRalph Campbell void qib_hol_init(struct qib_pportdata *); 1111f931551bSRalph Campbell void qib_hol_up(struct qib_pportdata *); 1112f931551bSRalph Campbell void qib_hol_event(unsigned long); 1113f931551bSRalph Campbell void qib_disable_after_error(struct qib_devdata *); 1114f931551bSRalph Campbell int qib_set_uevent_bits(struct qib_pportdata *, const int); 1115f931551bSRalph Campbell 1116f931551bSRalph Campbell /* for use in system calls, where we want to know device type, etc. */ 1117f931551bSRalph Campbell #define ctxt_fp(fp) \ 1118f931551bSRalph Campbell (((struct qib_filedata *)(fp)->private_data)->rcd) 1119f931551bSRalph Campbell #define subctxt_fp(fp) \ 1120f931551bSRalph Campbell (((struct qib_filedata *)(fp)->private_data)->subctxt) 1121f931551bSRalph Campbell #define tidcursor_fp(fp) \ 1122f931551bSRalph Campbell (((struct qib_filedata *)(fp)->private_data)->tidcursor) 1123f931551bSRalph Campbell #define user_sdma_queue_fp(fp) \ 1124f931551bSRalph Campbell (((struct qib_filedata *)(fp)->private_data)->pq) 1125f931551bSRalph Campbell 1126f931551bSRalph Campbell static inline struct qib_devdata *dd_from_ppd(struct qib_pportdata *ppd) 1127f931551bSRalph Campbell { 1128f931551bSRalph Campbell return ppd->dd; 1129f931551bSRalph Campbell } 1130f931551bSRalph Campbell 1131f931551bSRalph Campbell static inline struct qib_devdata *dd_from_dev(struct qib_ibdev *dev) 1132f931551bSRalph Campbell { 1133f931551bSRalph Campbell return container_of(dev, struct qib_devdata, verbs_dev); 1134f931551bSRalph Campbell } 1135f931551bSRalph Campbell 1136f931551bSRalph Campbell static inline struct qib_devdata *dd_from_ibdev(struct ib_device *ibdev) 1137f931551bSRalph Campbell { 1138f931551bSRalph Campbell return dd_from_dev(to_idev(ibdev)); 1139f931551bSRalph Campbell } 1140f931551bSRalph Campbell 1141f931551bSRalph Campbell static inline struct qib_pportdata *ppd_from_ibp(struct qib_ibport *ibp) 1142f931551bSRalph Campbell { 1143f931551bSRalph Campbell return container_of(ibp, struct qib_pportdata, ibport_data); 1144f931551bSRalph Campbell } 1145f931551bSRalph Campbell 1146f931551bSRalph Campbell static inline struct qib_ibport *to_iport(struct ib_device *ibdev, u8 port) 1147f931551bSRalph Campbell { 1148f931551bSRalph Campbell struct qib_devdata *dd = dd_from_ibdev(ibdev); 1149f931551bSRalph Campbell unsigned pidx = port - 1; /* IB number port from 1, hdw from 0 */ 1150f931551bSRalph Campbell 1151f931551bSRalph Campbell WARN_ON(pidx >= dd->num_pports); 1152f931551bSRalph Campbell return &dd->pport[pidx].ibport_data; 1153f931551bSRalph Campbell } 1154f931551bSRalph Campbell 1155f931551bSRalph Campbell /* 1156f931551bSRalph Campbell * values for dd->flags (_device_ related flags) and 1157f931551bSRalph Campbell */ 1158f931551bSRalph Campbell #define QIB_HAS_LINK_LATENCY 0x1 /* supports link latency (IB 1.2) */ 1159f931551bSRalph Campbell #define QIB_INITTED 0x2 /* chip and driver up and initted */ 1160f931551bSRalph Campbell #define QIB_DOING_RESET 0x4 /* in the middle of doing chip reset */ 1161f931551bSRalph Campbell #define QIB_PRESENT 0x8 /* chip accesses can be done */ 1162f931551bSRalph Campbell #define QIB_PIO_FLUSH_WC 0x10 /* Needs Write combining flush for PIO */ 1163f931551bSRalph Campbell #define QIB_HAS_THRESH_UPDATE 0x40 1164f931551bSRalph Campbell #define QIB_HAS_SDMA_TIMEOUT 0x80 1165f931551bSRalph Campbell #define QIB_USE_SPCL_TRIG 0x100 /* SpecialTrigger launch enabled */ 1166f931551bSRalph Campbell #define QIB_NODMA_RTAIL 0x200 /* rcvhdrtail register DMA enabled */ 1167f931551bSRalph Campbell #define QIB_HAS_INTX 0x800 /* Supports INTx interrupts */ 1168f931551bSRalph Campbell #define QIB_HAS_SEND_DMA 0x1000 /* Supports Send DMA */ 1169f931551bSRalph Campbell #define QIB_HAS_VLSUPP 0x2000 /* Supports multiple VLs; PBC different */ 1170f931551bSRalph Campbell #define QIB_HAS_HDRSUPP 0x4000 /* Supports header suppression */ 1171f931551bSRalph Campbell #define QIB_BADINTR 0x8000 /* severe interrupt problems */ 1172f931551bSRalph Campbell #define QIB_DCA_ENABLED 0x10000 /* Direct Cache Access enabled */ 1173f931551bSRalph Campbell #define QIB_HAS_QSFP 0x20000 /* device (card instance) has QSFP */ 1174f931551bSRalph Campbell 1175f931551bSRalph Campbell /* 1176f931551bSRalph Campbell * values for ppd->lflags (_ib_port_ related flags) 1177f931551bSRalph Campbell */ 1178f931551bSRalph Campbell #define QIBL_LINKV 0x1 /* IB link state valid */ 1179f931551bSRalph Campbell #define QIBL_LINKDOWN 0x8 /* IB link is down */ 1180f931551bSRalph Campbell #define QIBL_LINKINIT 0x10 /* IB link level is up */ 1181f931551bSRalph Campbell #define QIBL_LINKARMED 0x20 /* IB link is ARMED */ 1182f931551bSRalph Campbell #define QIBL_LINKACTIVE 0x40 /* IB link is ACTIVE */ 1183f931551bSRalph Campbell /* leave a gap for more IB-link state */ 1184f931551bSRalph Campbell #define QIBL_IB_AUTONEG_INPROG 0x1000 /* non-IBTA DDR/QDR neg active */ 1185f931551bSRalph Campbell #define QIBL_IB_AUTONEG_FAILED 0x2000 /* non-IBTA DDR/QDR neg failed */ 1186f931551bSRalph Campbell #define QIBL_IB_LINK_DISABLED 0x4000 /* Linkdown-disable forced, 1187f931551bSRalph Campbell * Do not try to bring up */ 1188f931551bSRalph Campbell #define QIBL_IB_FORCE_NOTIFY 0x8000 /* force notify on next ib change */ 1189f931551bSRalph Campbell 1190f931551bSRalph Campbell /* IB dword length mask in PBC (lower 11 bits); same for all chips */ 1191f931551bSRalph Campbell #define QIB_PBC_LENGTH_MASK ((1 << 11) - 1) 1192f931551bSRalph Campbell 1193f931551bSRalph Campbell 1194f931551bSRalph Campbell /* ctxt_flag bit offsets */ 1195f931551bSRalph Campbell /* waiting for a packet to arrive */ 1196f931551bSRalph Campbell #define QIB_CTXT_WAITING_RCV 2 1197f931551bSRalph Campbell /* master has not finished initializing */ 1198f931551bSRalph Campbell #define QIB_CTXT_MASTER_UNINIT 4 1199f931551bSRalph Campbell /* waiting for an urgent packet to arrive */ 1200f931551bSRalph Campbell #define QIB_CTXT_WAITING_URG 5 1201f931551bSRalph Campbell 1202f931551bSRalph Campbell /* free up any allocated data at closes */ 1203f931551bSRalph Campbell void qib_free_data(struct qib_ctxtdata *dd); 1204f931551bSRalph Campbell void qib_chg_pioavailkernel(struct qib_devdata *, unsigned, unsigned, 1205f931551bSRalph Campbell u32, struct qib_ctxtdata *); 1206f931551bSRalph Campbell struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *, 1207f931551bSRalph Campbell const struct pci_device_id *); 1208f931551bSRalph Campbell struct qib_devdata *qib_init_iba7220_funcs(struct pci_dev *, 1209f931551bSRalph Campbell const struct pci_device_id *); 1210f931551bSRalph Campbell struct qib_devdata *qib_init_iba6120_funcs(struct pci_dev *, 1211f931551bSRalph Campbell const struct pci_device_id *); 1212f931551bSRalph Campbell void qib_free_devdata(struct qib_devdata *); 1213f931551bSRalph Campbell struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra); 1214f931551bSRalph Campbell 1215f931551bSRalph Campbell #define QIB_TWSI_NO_DEV 0xFF 1216f931551bSRalph Campbell /* Below qib_twsi_ functions must be called with eep_lock held */ 1217f931551bSRalph Campbell int qib_twsi_reset(struct qib_devdata *dd); 1218f931551bSRalph Campbell int qib_twsi_blk_rd(struct qib_devdata *dd, int dev, int addr, void *buffer, 1219f931551bSRalph Campbell int len); 1220f931551bSRalph Campbell int qib_twsi_blk_wr(struct qib_devdata *dd, int dev, int addr, 1221f931551bSRalph Campbell const void *buffer, int len); 1222f931551bSRalph Campbell void qib_get_eeprom_info(struct qib_devdata *); 1223f931551bSRalph Campbell int qib_update_eeprom_log(struct qib_devdata *dd); 1224f931551bSRalph Campbell void qib_inc_eeprom_err(struct qib_devdata *dd, u32 eidx, u32 incr); 1225f931551bSRalph Campbell void qib_dump_lookup_output_queue(struct qib_devdata *); 1226f931551bSRalph Campbell void qib_force_pio_avail_update(struct qib_devdata *); 1227f931551bSRalph Campbell void qib_clear_symerror_on_linkup(unsigned long opaque); 1228f931551bSRalph Campbell 1229f931551bSRalph Campbell /* 1230f931551bSRalph Campbell * Set LED override, only the two LSBs have "public" meaning, but 1231f931551bSRalph Campbell * any non-zero value substitutes them for the Link and LinkTrain 1232f931551bSRalph Campbell * LED states. 1233f931551bSRalph Campbell */ 1234f931551bSRalph Campbell #define QIB_LED_PHYS 1 /* Physical (linktraining) GREEN LED */ 1235f931551bSRalph Campbell #define QIB_LED_LOG 2 /* Logical (link) YELLOW LED */ 1236f931551bSRalph Campbell void qib_set_led_override(struct qib_pportdata *ppd, unsigned int val); 1237f931551bSRalph Campbell 1238f931551bSRalph Campbell /* send dma routines */ 1239f931551bSRalph Campbell int qib_setup_sdma(struct qib_pportdata *); 1240f931551bSRalph Campbell void qib_teardown_sdma(struct qib_pportdata *); 1241f931551bSRalph Campbell void __qib_sdma_intr(struct qib_pportdata *); 1242f931551bSRalph Campbell void qib_sdma_intr(struct qib_pportdata *); 1243f931551bSRalph Campbell int qib_sdma_verbs_send(struct qib_pportdata *, struct qib_sge_state *, 1244f931551bSRalph Campbell u32, struct qib_verbs_txreq *); 1245f931551bSRalph Campbell /* ppd->sdma_lock should be locked before calling this. */ 1246f931551bSRalph Campbell int qib_sdma_make_progress(struct qib_pportdata *dd); 1247f931551bSRalph Campbell 1248f931551bSRalph Campbell /* must be called under qib_sdma_lock */ 1249f931551bSRalph Campbell static inline u16 qib_sdma_descq_freecnt(const struct qib_pportdata *ppd) 1250f931551bSRalph Campbell { 1251f931551bSRalph Campbell return ppd->sdma_descq_cnt - 1252f931551bSRalph Campbell (ppd->sdma_descq_added - ppd->sdma_descq_removed) - 1; 1253f931551bSRalph Campbell } 1254f931551bSRalph Campbell 1255f931551bSRalph Campbell static inline int __qib_sdma_running(struct qib_pportdata *ppd) 1256f931551bSRalph Campbell { 1257f931551bSRalph Campbell return ppd->sdma_state.current_state == qib_sdma_state_s99_running; 1258f931551bSRalph Campbell } 1259f931551bSRalph Campbell int qib_sdma_running(struct qib_pportdata *); 1260f931551bSRalph Campbell 1261f931551bSRalph Campbell void __qib_sdma_process_event(struct qib_pportdata *, enum qib_sdma_events); 1262f931551bSRalph Campbell void qib_sdma_process_event(struct qib_pportdata *, enum qib_sdma_events); 1263f931551bSRalph Campbell 1264f931551bSRalph Campbell /* 1265f931551bSRalph Campbell * number of words used for protocol header if not set by qib_userinit(); 1266f931551bSRalph Campbell */ 1267f931551bSRalph Campbell #define QIB_DFLT_RCVHDRSIZE 9 1268f931551bSRalph Campbell 1269f931551bSRalph Campbell /* 1270f931551bSRalph Campbell * We need to be able to handle an IB header of at least 24 dwords. 1271f931551bSRalph Campbell * We need the rcvhdrq large enough to handle largest IB header, but 1272f931551bSRalph Campbell * still have room for a 2KB MTU standard IB packet. 1273f931551bSRalph Campbell * Additionally, some processor/memory controller combinations 1274f931551bSRalph Campbell * benefit quite strongly from having the DMA'ed data be cacheline 1275f931551bSRalph Campbell * aligned and a cacheline multiple, so we set the size to 32 dwords 1276f931551bSRalph Campbell * (2 64-byte primary cachelines for pretty much all processors of 1277f931551bSRalph Campbell * interest). The alignment hurts nothing, other than using somewhat 1278f931551bSRalph Campbell * more memory. 1279f931551bSRalph Campbell */ 1280f931551bSRalph Campbell #define QIB_RCVHDR_ENTSIZE 32 1281f931551bSRalph Campbell 1282f931551bSRalph Campbell int qib_get_user_pages(unsigned long, size_t, struct page **); 1283f931551bSRalph Campbell void qib_release_user_pages(struct page **, size_t); 1284f931551bSRalph Campbell int qib_eeprom_read(struct qib_devdata *, u8, void *, int); 1285f931551bSRalph Campbell int qib_eeprom_write(struct qib_devdata *, u8, const void *, int); 1286f931551bSRalph Campbell u32 __iomem *qib_getsendbuf_range(struct qib_devdata *, u32 *, u32, u32); 1287f931551bSRalph Campbell void qib_sendbuf_done(struct qib_devdata *, unsigned); 1288f931551bSRalph Campbell 1289f931551bSRalph Campbell static inline void qib_clear_rcvhdrtail(const struct qib_ctxtdata *rcd) 1290f931551bSRalph Campbell { 1291f931551bSRalph Campbell *((u64 *) rcd->rcvhdrtail_kvaddr) = 0ULL; 1292f931551bSRalph Campbell } 1293f931551bSRalph Campbell 1294f931551bSRalph Campbell static inline u32 qib_get_rcvhdrtail(const struct qib_ctxtdata *rcd) 1295f931551bSRalph Campbell { 1296f931551bSRalph Campbell /* 1297f931551bSRalph Campbell * volatile because it's a DMA target from the chip, routine is 1298f931551bSRalph Campbell * inlined, and don't want register caching or reordering. 1299f931551bSRalph Campbell */ 1300f931551bSRalph Campbell return (u32) le64_to_cpu( 1301f931551bSRalph Campbell *((volatile __le64 *)rcd->rcvhdrtail_kvaddr)); /* DMA'ed */ 1302f931551bSRalph Campbell } 1303f931551bSRalph Campbell 1304f931551bSRalph Campbell static inline u32 qib_get_hdrqtail(const struct qib_ctxtdata *rcd) 1305f931551bSRalph Campbell { 1306f931551bSRalph Campbell const struct qib_devdata *dd = rcd->dd; 1307f931551bSRalph Campbell u32 hdrqtail; 1308f931551bSRalph Campbell 1309f931551bSRalph Campbell if (dd->flags & QIB_NODMA_RTAIL) { 1310f931551bSRalph Campbell __le32 *rhf_addr; 1311f931551bSRalph Campbell u32 seq; 1312f931551bSRalph Campbell 1313f931551bSRalph Campbell rhf_addr = (__le32 *) rcd->rcvhdrq + 1314f931551bSRalph Campbell rcd->head + dd->rhf_offset; 1315f931551bSRalph Campbell seq = qib_hdrget_seq(rhf_addr); 1316f931551bSRalph Campbell hdrqtail = rcd->head; 1317f931551bSRalph Campbell if (seq == rcd->seq_cnt) 1318f931551bSRalph Campbell hdrqtail++; 1319f931551bSRalph Campbell } else 1320f931551bSRalph Campbell hdrqtail = qib_get_rcvhdrtail(rcd); 1321f931551bSRalph Campbell 1322f931551bSRalph Campbell return hdrqtail; 1323f931551bSRalph Campbell } 1324f931551bSRalph Campbell 1325f931551bSRalph Campbell /* 1326f931551bSRalph Campbell * sysfs interface. 1327f931551bSRalph Campbell */ 1328f931551bSRalph Campbell 1329f931551bSRalph Campbell extern const char ib_qib_version[]; 1330f931551bSRalph Campbell 1331f931551bSRalph Campbell int qib_device_create(struct qib_devdata *); 1332f931551bSRalph Campbell void qib_device_remove(struct qib_devdata *); 1333f931551bSRalph Campbell 1334f931551bSRalph Campbell int qib_create_port_files(struct ib_device *ibdev, u8 port_num, 1335f931551bSRalph Campbell struct kobject *kobj); 1336f931551bSRalph Campbell int qib_verbs_register_sysfs(struct qib_devdata *); 1337f931551bSRalph Campbell void qib_verbs_unregister_sysfs(struct qib_devdata *); 1338f931551bSRalph Campbell /* Hook for sysfs read of QSFP */ 1339f931551bSRalph Campbell extern int qib_qsfp_dump(struct qib_pportdata *ppd, char *buf, int len); 1340f931551bSRalph Campbell 1341f931551bSRalph Campbell int __init qib_init_qibfs(void); 1342f931551bSRalph Campbell int __exit qib_exit_qibfs(void); 1343f931551bSRalph Campbell 1344f931551bSRalph Campbell int qibfs_add(struct qib_devdata *); 1345f931551bSRalph Campbell int qibfs_remove(struct qib_devdata *); 1346f931551bSRalph Campbell 1347f931551bSRalph Campbell int qib_pcie_init(struct pci_dev *, const struct pci_device_id *); 1348f931551bSRalph Campbell int qib_pcie_ddinit(struct qib_devdata *, struct pci_dev *, 1349f931551bSRalph Campbell const struct pci_device_id *); 1350f931551bSRalph Campbell void qib_pcie_ddcleanup(struct qib_devdata *); 1351f931551bSRalph Campbell int qib_pcie_params(struct qib_devdata *, u32, u32 *, struct msix_entry *); 1352f931551bSRalph Campbell int qib_reinit_intr(struct qib_devdata *); 1353f931551bSRalph Campbell void qib_enable_intx(struct pci_dev *); 1354f931551bSRalph Campbell void qib_nomsi(struct qib_devdata *); 1355f931551bSRalph Campbell void qib_nomsix(struct qib_devdata *); 1356f931551bSRalph Campbell void qib_pcie_getcmd(struct qib_devdata *, u16 *, u8 *, u8 *); 1357f931551bSRalph Campbell void qib_pcie_reenable(struct qib_devdata *, u16, u8, u8); 1358f931551bSRalph Campbell 1359f931551bSRalph Campbell /* 1360f931551bSRalph Campbell * dma_addr wrappers - all 0's invalid for hw 1361f931551bSRalph Campbell */ 1362f931551bSRalph Campbell dma_addr_t qib_map_page(struct pci_dev *, struct page *, unsigned long, 1363f931551bSRalph Campbell size_t, int); 1364f931551bSRalph Campbell const char *qib_get_unit_name(int unit); 1365f931551bSRalph Campbell 1366f931551bSRalph Campbell /* 1367f931551bSRalph Campbell * Flush write combining store buffers (if present) and perform a write 1368f931551bSRalph Campbell * barrier. 1369f931551bSRalph Campbell */ 1370f931551bSRalph Campbell #if defined(CONFIG_X86_64) 1371f931551bSRalph Campbell #define qib_flush_wc() asm volatile("sfence" : : : "memory") 1372f931551bSRalph Campbell #else 1373f931551bSRalph Campbell #define qib_flush_wc() wmb() /* no reorder around wc flush */ 1374f931551bSRalph Campbell #endif 1375f931551bSRalph Campbell 1376f931551bSRalph Campbell /* global module parameter variables */ 1377f931551bSRalph Campbell extern unsigned qib_ibmtu; 1378f931551bSRalph Campbell extern ushort qib_cfgctxts; 1379f931551bSRalph Campbell extern ushort qib_num_cfg_vls; 1380f931551bSRalph Campbell extern ushort qib_mini_init; /* If set, do few (ideally 0) writes to chip */ 1381f931551bSRalph Campbell extern unsigned qib_n_krcv_queues; 1382f931551bSRalph Campbell extern unsigned qib_sdma_fetch_arb; 1383f931551bSRalph Campbell extern unsigned qib_compat_ddr_negotiate; 1384f931551bSRalph Campbell extern int qib_special_trigger; 1385f931551bSRalph Campbell 1386f931551bSRalph Campbell extern struct mutex qib_mutex; 1387f931551bSRalph Campbell 1388f931551bSRalph Campbell /* Number of seconds before our card status check... */ 1389f931551bSRalph Campbell #define STATUS_TIMEOUT 60 1390f931551bSRalph Campbell 1391f931551bSRalph Campbell #define QIB_DRV_NAME "ib_qib" 1392f931551bSRalph Campbell #define QIB_USER_MINOR_BASE 0 1393f931551bSRalph Campbell #define QIB_TRACE_MINOR 127 1394f931551bSRalph Campbell #define QIB_DIAGPKT_MINOR 128 1395f931551bSRalph Campbell #define QIB_DIAG_MINOR_BASE 129 1396f931551bSRalph Campbell #define QIB_NMINORS 255 1397f931551bSRalph Campbell 1398f931551bSRalph Campbell #define PCI_VENDOR_ID_PATHSCALE 0x1fc1 1399f931551bSRalph Campbell #define PCI_VENDOR_ID_QLOGIC 0x1077 1400f931551bSRalph Campbell #define PCI_DEVICE_ID_QLOGIC_IB_6120 0x10 1401f931551bSRalph Campbell #define PCI_DEVICE_ID_QLOGIC_IB_7220 0x7220 1402f931551bSRalph Campbell #define PCI_DEVICE_ID_QLOGIC_IB_7322 0x7322 1403f931551bSRalph Campbell 1404f931551bSRalph Campbell /* 1405f931551bSRalph Campbell * qib_early_err is used (only!) to print early errors before devdata is 1406f931551bSRalph Campbell * allocated, or when dd->pcidev may not be valid, and at the tail end of 1407f931551bSRalph Campbell * cleanup when devdata may have been freed, etc. qib_dev_porterr is 1408f931551bSRalph Campbell * the same as qib_dev_err, but is used when the message really needs 1409f931551bSRalph Campbell * the IB port# to be definitive as to what's happening.. 1410f931551bSRalph Campbell * All of these go to the trace log, and the trace log entry is done 1411f931551bSRalph Campbell * first to avoid possible serial port delays from printk. 1412f931551bSRalph Campbell */ 1413f931551bSRalph Campbell #define qib_early_err(dev, fmt, ...) \ 1414f931551bSRalph Campbell do { \ 141582fdb0abSJason Gunthorpe dev_err(dev, fmt, ##__VA_ARGS__); \ 1416f931551bSRalph Campbell } while (0) 1417f931551bSRalph Campbell 1418f931551bSRalph Campbell #define qib_dev_err(dd, fmt, ...) \ 1419f931551bSRalph Campbell do { \ 1420f931551bSRalph Campbell dev_err(&(dd)->pcidev->dev, "%s: " fmt, \ 1421f931551bSRalph Campbell qib_get_unit_name((dd)->unit), ##__VA_ARGS__); \ 1422f931551bSRalph Campbell } while (0) 1423f931551bSRalph Campbell 1424f931551bSRalph Campbell #define qib_dev_porterr(dd, port, fmt, ...) \ 1425f931551bSRalph Campbell do { \ 1426f931551bSRalph Campbell dev_err(&(dd)->pcidev->dev, "%s: IB%u:%u " fmt, \ 1427f931551bSRalph Campbell qib_get_unit_name((dd)->unit), (dd)->unit, (port), \ 1428f931551bSRalph Campbell ##__VA_ARGS__); \ 1429f931551bSRalph Campbell } while (0) 1430f931551bSRalph Campbell 1431f931551bSRalph Campbell #define qib_devinfo(pcidev, fmt, ...) \ 1432f931551bSRalph Campbell do { \ 1433f931551bSRalph Campbell dev_info(&(pcidev)->dev, fmt, ##__VA_ARGS__); \ 1434f931551bSRalph Campbell } while (0) 1435f931551bSRalph Campbell 1436f931551bSRalph Campbell /* 1437f931551bSRalph Campbell * this is used for formatting hw error messages... 1438f931551bSRalph Campbell */ 1439f931551bSRalph Campbell struct qib_hwerror_msgs { 1440f931551bSRalph Campbell u64 mask; 1441f931551bSRalph Campbell const char *msg; 1442e67306a3SMike Marciniszyn size_t sz; 1443f931551bSRalph Campbell }; 1444f931551bSRalph Campbell 1445f931551bSRalph Campbell #define QLOGIC_IB_HWE_MSG(a, b) { .mask = a, .msg = b } 1446f931551bSRalph Campbell 1447f931551bSRalph Campbell /* in qib_intr.c... */ 1448f931551bSRalph Campbell void qib_format_hwerrors(u64 hwerrs, 1449f931551bSRalph Campbell const struct qib_hwerror_msgs *hwerrmsgs, 1450f931551bSRalph Campbell size_t nhwerrmsgs, char *msg, size_t lmsg); 1451f931551bSRalph Campbell #endif /* _QIB_KERNEL_H */ 1452