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