IB/ipath: Remove ipath_get_user_pages_nocopy()
[safe/jmp/linux-2.6] / drivers / infiniband / hw / ipath / ipath_kernel.h
index 159d0ae..ace63ef 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _IPATH_KERNEL_H
 #define _IPATH_KERNEL_H
 /*
+ * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.
  * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -38,6 +39,8 @@
  */
 
 #include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <asm/io.h>
 
 #include "ipath_common.h"
 extern struct infinipath_stats ipath_stats;
 
 #define IPATH_CHIP_SWVERSION IPATH_CHIP_VERS_MAJ
+/*
+ * First-cut critierion for "device is active" is
+ * two thousand dwords combined Tx, Rx traffic per
+ * 5-second interval. SMA packets are 64 dwords,
+ * and occur "a few per second", presumably each way.
+ */
+#define IPATH_TRAFFIC_ACTIVE_THRESHOLD (2000)
+/*
+ * Struct used to indicate which errors are logged in each of the
+ * error-counters that are logged to EEPROM. A counter is incremented
+ * _once_ (saturating at 255) for each event with any bits set in
+ * the error or hwerror register masks below.
+ */
+#define IPATH_EEP_LOG_CNT (4)
+struct ipath_eep_log_mask {
+       u64 errs_to_log;
+       u64 hwerrs_to_log;
+};
 
 struct ipath_portdata {
        void **port_rcvegrbuf;
@@ -61,9 +82,7 @@ struct ipath_portdata {
        /* rcvhdrq base, needs mmap before useful */
        void *port_rcvhdrq;
        /* kernel virtual address where hdrqtail is updated */
-       u64 *port_rcvhdrtail_kvaddr;
-       /* page * used for uaddr */
-       struct page *port_rcvhdrtail_pagep;
+       void *port_rcvhdrtail_kvaddr;
        /*
         * temp buffer for expected send setup, allocated at open, instead
         * of each setup call
@@ -78,14 +97,10 @@ struct ipath_portdata {
        dma_addr_t port_rcvegr_phys;
        /* mmap of hdrq, must fit in 44 bits */
        dma_addr_t port_rcvhdrq_phys;
+       dma_addr_t port_rcvhdrqtailaddr_phys;
        /*
-        * the actual user address that we ipath_mlock'ed, so we can
-        * ipath_munlock it at close
-        */
-       unsigned long port_rcvhdrtail_uaddr;
-       /*
-        * number of opens on this instance (0 or 1; ignoring forks, dup,
-        * etc. for now)
+        * number of opens (including slave subports) on this instance
+        * (ignoring forks, dup, etc. for now)
         */
        int port_cnt;
        /*
@@ -94,6 +109,10 @@ struct ipath_portdata {
         */
        /* instead of calculating it */
        unsigned port_port;
+       /* non-zero if port is being shared. */
+       u16 port_subport_cnt;
+       /* non-zero if port is being shared. */
+       u16 port_subport_id;
        /* chip offset of PIO buffers for this port */
        u32 port_piobufs;
        /* how many alloc_pages() chunks in port_rcvegrbuf_pages */
@@ -108,6 +127,8 @@ struct ipath_portdata {
        u32 port_tidcursor;
        /* next expected TID to check */
        unsigned long port_flag;
+       /* what happened */
+       unsigned long int_flag;
        /* WAIT_RCV that timed out, no interrupt */
        u32 port_rcvwait_to;
        /* WAIT_PIO that timed out, no interrupt */
@@ -126,6 +147,18 @@ struct ipath_portdata {
        u16 port_pkeys[4];
        /* so file ops can get at unit */
        struct ipath_devdata *port_dd;
+       /* A page of memory for rcvhdrhead, rcvegrhead, rcvegrtail * N */
+       void *subport_uregbase;
+       /* An array of pages for the eager receive buffers * N */
+       void *subport_rcvegrbuf;
+       /* An array of pages for the eager header queue entries * N */
+       void *subport_rcvhdr_base;
+       /* The version of the library which opened this port */
+       u32 userversion;
+       /* Bitmask of active slaves */
+       u32 active_slaves;
+       /* Type of packets or conditions we want to poll for */
+       u16 poll_type;
 };
 
 struct sk_buff;
@@ -137,10 +170,9 @@ struct _ipath_layer {
        void *l_arg;
 };
 
-/* Verbs layer interface */
-struct _verbs_layer {
-       void *l_arg;
-       struct timer_list l_timer;
+struct ipath_skbinfo {
+       struct sk_buff *skb;
+       dma_addr_t phys;
 };
 
 struct ipath_devdata {
@@ -158,20 +190,14 @@ struct ipath_devdata {
        /* base of memory alloced for ipath_kregbase, for free */
        u64 *ipath_kregalloc;
        /*
-        * version of kregbase that doesn't have high bits set (for 32 bit
-        * programs, so mmap64 44 bit works)
-        */
-       u64 __iomem *ipath_kregvirt;
-       /*
         * virtual address where port0 rcvhdrqtail updated for this unit.
         * only written to by the chip, not the driver.
         */
        volatile __le64 *ipath_hdrqtailptr;
-       dma_addr_t ipath_dma_addr;
        /* ipath_cfgports pointers */
        struct ipath_portdata **ipath_pd;
        /* sk_buffs used by port 0 eager receive queue */
-       struct sk_buff **ipath_port0_skbs;
+       struct ipath_skbinfo *ipath_port0_skbinfo;
        /* kvirt address of 1st 2k pio buffer */
        void __iomem *ipath_pio2kbase;
        /* kvirt address of 1st 4k pio buffer */
@@ -209,7 +235,10 @@ struct ipath_devdata {
        void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64);
        /* fill out chip-specific fields */
        int (*ipath_f_get_base_info)(struct ipath_portdata *, void *);
-       struct _verbs_layer verbs_layer;
+       /* free irq */
+       void (*ipath_f_free_irq)(struct ipath_devdata *);
+       struct ipath_ibdev *verbs_dev;
+       struct timer_list verbs_timer;
        /* total dwords sent (summed from counter) */
        u64 ipath_sword;
        /* total dwords rcvd (summed from counter) */
@@ -252,7 +281,7 @@ struct ipath_devdata {
        u64 ipath_tidtemplate;
        /* value to write to free TIDs */
        u64 ipath_tidinvalid;
-       /* PE-800 rcv interrupt setup */
+       /* IBA6120 rcv interrupt setup */
        u64 ipath_rhdrhead_intr_off;
 
        /* size of memory at ipath_kregbase */
@@ -261,13 +290,15 @@ struct ipath_devdata {
        u32 ipath_pioavregs;
        /* IPATH_POLL, etc. */
        u32 ipath_flags;
-       /* ipath_flags sma is waiting for */
-       u32 ipath_sma_state_wanted;
+       /* ipath_flags driver is waiting for */
+       u32 ipath_state_wanted;
        /* last buffer for user use, first buf for kernel use is this
         * index. */
        u32 ipath_lastport_piobuf;
        /* is a stats timer active */
        u32 ipath_stats_timer_active;
+       /* number of interrupts for this device -- saturates... */
+       u32 ipath_int_counter;
        /* dwords sent read from counter */
        u32 ipath_lastsword;
        /* dwords received read from counter */
@@ -322,11 +353,9 @@ struct ipath_devdata {
        u32 ipath_pcibar0;
        /* so we can rewrite it after a chip reset */
        u32 ipath_pcibar1;
-       /* sequential tries for SMA send and no bufs */
-       u32 ipath_nosma_bufs;
-       /* duration (seconds) ipath_nosma_bufs set */
-       u32 ipath_nosma_secs;
 
+       /* interrupt number */
+       int ipath_irq;
        /* HT/PCI Vendor ID (here for NodeInfo) */
        u16 ipath_vendorid;
        /* HT/PCI Device ID (here for NodeInfo) */
@@ -335,12 +364,16 @@ struct ipath_devdata {
        u8 ipath_ht_slave_off;
        /* for write combining settings */
        unsigned long ipath_wc_cookie;
+       unsigned long ipath_wc_base;
+       unsigned long ipath_wc_len;
        /* ref count for each pkey */
        atomic_t ipath_pkeyrefs[4];
        /* shadow copy of all exptids physaddr; used only by funcsim */
        u64 *ipath_tidsimshadow;
        /* shadow copy of struct page *'s for exp tid pages */
        struct page **ipath_pageshadow;
+       /* shadow copy of dma handles for exp tid pages */
+       dma_addr_t *ipath_physshadow;
        /* lock to workaround chip bug 9437 */
        spinlock_t ipath_tid_lock;
 
@@ -354,13 +387,14 @@ struct ipath_devdata {
        char *ipath_freezemsg;
        /* pci access data structure */
        struct pci_dev *pcidev;
-       struct cdev *cdev;
-       struct class_device *class_dev;
+       struct cdev *user_cdev;
+       struct cdev *diag_cdev;
+       struct class_device *user_class_dev;
+       struct class_device *diag_class_dev;
        /* timer used to prevent stats overflow, error throttling, etc. */
        struct timer_list ipath_stats_timer;
-       /* check for stale messages in rcv queue */
-       /* only allow one intr at a time. */
-       unsigned long ipath_rcv_pending;
+       void *ipath_dummy_hdrq; /* used after port close */
+       dma_addr_t ipath_dummy_hdrq_phys;
 
        /*
         * Shadow copies of registers; size indicates read access size.
@@ -384,6 +418,10 @@ struct ipath_devdata {
        unsigned long ipath_pioavailshadow[8];
        /* shadow of kr_gpio_out, for rmw ops */
        u64 ipath_gpio_out;
+       /* shadow the gpio mask register */
+       u64 ipath_gpio_mask;
+       /* shadow the gpio output enable, etc... */
+       u64 ipath_extctrl;
        /* kr_revision shadow */
        u64 ipath_revision;
        /*
@@ -418,6 +456,9 @@ struct ipath_devdata {
        unsigned long ipath_rcvctrl;
        /* shadow kr_sendctrl */
        unsigned long ipath_sendctrl;
+       /* ports waiting for PIOavail intr */
+       unsigned long ipath_portpiowait;
+       unsigned long ipath_lastcancel; /* to not count armlaunch after cancel */
 
        /* value we put in kr_rcvhdrcnt */
        u32 ipath_rcvhdrcnt;
@@ -455,8 +496,6 @@ struct ipath_devdata {
        u32 ipath_cregbase;
        /* shadow the control register contents */
        u32 ipath_control;
-       /* shadow the gpio output contents */
-       u32 ipath_extctrl;
        /* PCI revision register (HTC rev on FPGA) */
        u32 ipath_pcirev;
 
@@ -481,8 +520,6 @@ struct ipath_devdata {
        u32 ipath_htwidth;
        /* HT speed (200,400,800,1000) from HT config */
        u32 ipath_htspeed;
-       /* ports waiting for PIOavail intr */
-       unsigned long ipath_portpiowait;
        /*
         * number of sequential ibcstatus change for polling active/quiet
         * (i.e., link not coming up).
@@ -500,8 +537,11 @@ struct ipath_devdata {
        u16 ipath_lid;
        /* list of pkeys programmed; 0 if not set */
        u16 ipath_pkeys[4];
-       /* ASCII serial number, from flash */
-       u8 ipath_serial[12];
+       /*
+        * ASCII serial number, from flash, large enough for original
+        * all digit strings, and longer QLogic serial number format
+        */
+       u8 ipath_serial[16];
        /* human readable board version */
        u8 ipath_boardversion[80];
        /* chip major rev, from ipath_revision */
@@ -516,57 +556,119 @@ struct ipath_devdata {
        u8 ipath_pci_cacheline;
        /* LID mask control */
        u8 ipath_lmc;
-};
+       /* Rx Polarity inversion (compensate for ~tx on partner) */
+       u8 ipath_rx_pol_inv;
+
+       /* local link integrity counter */
+       u32 ipath_lli_counter;
+       /* local link integrity errors */
+       u32 ipath_lli_errors;
+       /*
+        * Above counts only cases where _successive_ LocalLinkIntegrity
+        * errors were seen in the receive headers of kern-packets.
+        * Below are the three (monotonically increasing) counters
+        * maintained via GPIO interrupts on iba6120-rev2.
+        */
+       u32 ipath_rxfc_unsupvl_errs;
+       u32 ipath_overrun_thresh_errs;
+       u32 ipath_lli_errs;
+
+       /* status check work */
+       struct delayed_work status_work;
 
-extern volatile __le64 *ipath_port0_rcvhdrtail;
-extern dma_addr_t ipath_port0_rcvhdrtail_dma;
+       /*
+        * Not all devices managed by a driver instance are the same
+        * type, so these fields must be per-device.
+        */
+       u64 ipath_i_bitsextant;
+       ipath_err_t ipath_e_bitsextant;
+       ipath_err_t ipath_hwe_bitsextant;
 
-#define IPATH_PORT0_RCVHDRTAIL_SIZE PAGE_SIZE
+       /*
+        * Below should be computable from number of ports,
+        * since they are never modified.
+        */
+       u32 ipath_i_rcvavail_mask;
+       u32 ipath_i_rcvurg_mask;
 
+       /*
+        * Register bits for selecting i2c direction and values, used for
+        * I2C serial flash.
+        */
+       u16 ipath_gpio_sda_num;
+       u16 ipath_gpio_scl_num;
+       u64 ipath_gpio_sda;
+       u64 ipath_gpio_scl;
+
+       /* lock for doing RMW of shadows/regs for ExtCtrl and GPIO */
+       spinlock_t ipath_gpio_lock;
+
+       /* used to override LED behavior */
+       u8 ipath_led_override;  /* Substituted for normal value, if non-zero */
+       u16 ipath_led_override_timeoff; /* delta to next timer event */
+       u8 ipath_led_override_vals[2]; /* Alternates per blink-frame */
+       u8 ipath_led_override_phase; /* Just counts, LSB picks from vals[] */
+       atomic_t ipath_led_override_timer_active;
+       /* Used to flash LEDs in override mode */
+       struct timer_list ipath_led_override_timer;
+
+       /* Support (including locks) for EEPROM logging of errors and time */
+       /* control access to actual counters, timer */
+       spinlock_t ipath_eep_st_lock;
+       /* control high-level access to EEPROM */
+       struct semaphore ipath_eep_sem;
+       /* Below inc'd by ipath_snap_cntrs(), locked by ipath_eep_st_lock */
+       uint64_t ipath_traffic_wds;
+       /* active time is kept in seconds, but logged in hours */
+       atomic_t ipath_active_time;
+       /* Below are nominal shadow of EEPROM, new since last EEPROM update */
+       uint8_t ipath_eep_st_errs[IPATH_EEP_LOG_CNT];
+       uint8_t ipath_eep_st_new_errs[IPATH_EEP_LOG_CNT];
+       uint16_t ipath_eep_hrs;
+       /*
+        * masks for which bits of errs, hwerrs that cause
+        * each of the counters to increment.
+        */
+       struct ipath_eep_log_mask ipath_eep_st_masks[IPATH_EEP_LOG_CNT];
+};
+
+/* Private data for file operations */
+struct ipath_filedata {
+       struct ipath_portdata *pd;
+       unsigned subport;
+       unsigned tidcursor;
+};
 extern struct list_head ipath_dev_list;
 extern spinlock_t ipath_devs_lock;
 extern struct ipath_devdata *ipath_lookup(int unit);
 
-extern u16 ipath_layer_rcv_opcode;
-extern int ipath_verbs_registered;
-extern int __ipath_layer_intr(struct ipath_devdata *, u32);
-extern int ipath_layer_intr(struct ipath_devdata *, u32);
-extern int __ipath_layer_rcv(struct ipath_devdata *, void *,
-                            struct sk_buff *);
-extern int __ipath_layer_rcv_lid(struct ipath_devdata *, void *);
-extern int __ipath_verbs_piobufavail(struct ipath_devdata *);
-extern int __ipath_verbs_rcv(struct ipath_devdata *, void *, void *, u32);
-
-void ipath_layer_add(struct ipath_devdata *);
-void ipath_layer_del(struct ipath_devdata *);
-
 int ipath_init_chip(struct ipath_devdata *, int);
 int ipath_enable_wc(struct ipath_devdata *dd);
 void ipath_disable_wc(struct ipath_devdata *dd);
 int ipath_count_units(int *npresentp, int *nupp, u32 *maxportsp);
 void ipath_shutdown_device(struct ipath_devdata *);
+void ipath_clear_freeze(struct ipath_devdata *);
 
 struct file_operations;
-int ipath_cdev_init(int minor, char *name, struct file_operations *fops,
+int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
                    struct cdev **cdevp, struct class_device **class_devp);
 void ipath_cdev_cleanup(struct cdev **cdevp,
                        struct class_device **class_devp);
 
-int ipath_diag_init(void);
-void ipath_diag_cleanup(void);
-void ipath_diag_bringup_link(struct ipath_devdata *);
+int ipath_diag_add(struct ipath_devdata *);
+void ipath_diag_remove(struct ipath_devdata *);
 
-extern wait_queue_head_t ipath_sma_state_wait;
+extern wait_queue_head_t ipath_state_wait;
 
 int ipath_user_add(struct ipath_devdata *dd);
-void ipath_user_del(struct ipath_devdata *dd);
+void ipath_user_remove(struct ipath_devdata *dd);
 
 struct sk_buff *ipath_alloc_skb(struct ipath_devdata *dd, gfp_t);
 
 extern int ipath_diag_inuse;
 
-irqreturn_t ipath_intr(int irq, void *devid, struct pt_regs *regs);
-void ipath_decode_err(char *buf, size_t blen, ipath_err_t err);
+irqreturn_t ipath_intr(int irq, void *devid);
+int ipath_decode_err(char *buf, size_t blen, ipath_err_t err);
 #if __IPATH_INFO || __IPATH_DBG
 extern const char *ipath_ibcstatus_str[];
 #endif
@@ -581,21 +683,28 @@ int ipath_unordered_wc(void);
 
 void ipath_disarm_piobufs(struct ipath_devdata *, unsigned first,
                          unsigned cnt);
+void ipath_cancel_sends(struct ipath_devdata *);
 
 int ipath_create_rcvhdrq(struct ipath_devdata *, struct ipath_portdata *);
-void ipath_free_pddata(struct ipath_devdata *, u32, int);
+void ipath_free_pddata(struct ipath_devdata *, struct ipath_portdata *);
 
 int ipath_parse_ushort(const char *str, unsigned short *valp);
 
-int ipath_wait_linkstate(struct ipath_devdata *, u32, int);
-void ipath_set_ib_lstate(struct ipath_devdata *, int);
 void ipath_kreceive(struct ipath_devdata *);
 int ipath_setrcvhdrsize(struct ipath_devdata *, unsigned);
 int ipath_reset_device(int);
 void ipath_get_faststats(unsigned long);
+int ipath_set_linkstate(struct ipath_devdata *, u8);
+int ipath_set_mtu(struct ipath_devdata *, u16);
+int ipath_set_lid(struct ipath_devdata *, u32, u8);
+int ipath_set_rx_pol_inv(struct ipath_devdata *dd, u8 new_pol_inv);
 
 /* for use in system calls, where we want to know device type, etc. */
-#define port_fp(fp) ((struct ipath_portdata *) (fp)->private_data)
+#define port_fp(fp) ((struct ipath_filedata *)(fp)->private_data)->pd
+#define subport_fp(fp) \
+       ((struct ipath_filedata *)(fp)->private_data)->subport
+#define tidcursor_fp(fp) \
+       ((struct ipath_filedata *)(fp)->private_data)->tidcursor
 
 /*
  * values for ipath_flags
@@ -633,28 +742,51 @@ void ipath_get_faststats(unsigned long);
                 * are 64bit */
 #define IPATH_32BITCOUNTERS 0x20000
                /* can miss port0 rx interrupts */
-#define IPATH_POLL_RX_INTR  0x40000
 #define IPATH_DISABLED      0x80000 /* administratively disabled */
+               /* Use GPIO interrupts for new counters */
+#define IPATH_GPIO_ERRINTRS 0x100000
+
+/* Bits in GPIO for the added interrupts */
+#define IPATH_GPIO_PORT0_BIT 2
+#define IPATH_GPIO_RXUVL_BIT 3
+#define IPATH_GPIO_OVRUN_BIT 4
+#define IPATH_GPIO_LLI_BIT 5
+#define IPATH_GPIO_ERRINTR_MASK 0x38
 
 /* portdata flag bit offsets */
                /* waiting for a packet to arrive */
 #define IPATH_PORT_WAITING_RCV   2
                /* waiting for a PIO buffer to be available */
 #define IPATH_PORT_WAITING_PIO   3
+               /* master has not finished initializing */
+#define IPATH_PORT_MASTER_UNINIT 4
+               /* waiting for an urgent packet to arrive */
+#define IPATH_PORT_WAITING_URG 5
+               /* waiting for a header overflow */
+#define IPATH_PORT_WAITING_OVERFLOW 6
 
 /* free up any allocated data at closes */
 void ipath_free_data(struct ipath_portdata *dd);
 int ipath_waitfor_mdio_cmdready(struct ipath_devdata *);
 int ipath_waitfor_complete(struct ipath_devdata *, ipath_kreg, u64, u64 *);
 u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32 *);
-/* init PE-800-specific func */
-void ipath_init_pe800_funcs(struct ipath_devdata *);
-/* init HT-400-specific func */
-void ipath_init_ht400_funcs(struct ipath_devdata *);
-void ipath_get_guid(struct ipath_devdata *);
+void ipath_init_iba6120_funcs(struct ipath_devdata *);
+void ipath_init_iba6110_funcs(struct ipath_devdata *);
+void ipath_get_eeprom_info(struct ipath_devdata *);
+int ipath_update_eeprom_log(struct ipath_devdata *dd);
+void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr);
 u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg);
 
 /*
+ * Set LED override, only the two LSBs have "public" meaning, but
+ * any non-zero value substitutes them for the Link and LinkTrain
+ * LED states.
+ */
+#define IPATH_LED_PHYS 1 /* Physical (linktraining) GREEN LED */
+#define IPATH_LED_LOG 2  /* Logical (link) YELLOW LED */
+void ipath_set_led_override(struct ipath_devdata *dd, unsigned int val);
+
+/*
  * number of words used for protocol header if not set by ipath_userinit();
  */
 #define IPATH_DFLT_RCVHDRSIZE 9
@@ -687,7 +819,6 @@ static inline u64 ipath_mdio_req(int cmd, int dev, int reg, int data)
 #define IPATH_MDIO_CTRL_8355_REG_10 0x1D
 
 int ipath_get_user_pages(unsigned long, size_t, struct page **);
-int ipath_get_user_pages_nocopy(unsigned long, struct page **);
 void ipath_release_user_pages(struct page **, size_t);
 void ipath_release_user_pages_on_close(struct page **, size_t);
 int ipath_eeprom_read(struct ipath_devdata *, u8, void *, int);
@@ -696,8 +827,6 @@ int ipath_eeprom_write(struct ipath_devdata *, u8, const void *, int);
 /* these are used for the registers that vary with port */
 void ipath_write_kreg_port(const struct ipath_devdata *, ipath_kreg,
                           unsigned, u64);
-u64 ipath_read_kreg64_port(const struct ipath_devdata *, ipath_kreg,
-                          unsigned);
 
 /*
  * We could have a single register get/put routine, that takes a group type,
@@ -721,18 +850,13 @@ u64 ipath_read_kreg64_port(const struct ipath_devdata *, ipath_kreg,
  * @port: port number
  *
  * Return the contents of a register that is virtualized to be per port.
- * Prints a debug message and returns -1 on errors (not distinguishable from
- * valid contents at runtime; we may add a separate error variable at some
- * point).
- *
- * This is normally not used by the kernel, but may be for debugging, and
- * has a different implementation than user mode, which is why it's not in
- * _common.h.
+ * Returns -1 on errors (not distinguishable from valid contents at
+ * runtime; we may add a separate error variable at some point).
  */
 static inline u32 ipath_read_ureg32(const struct ipath_devdata *dd,
                                    ipath_ureg regno, int port)
 {
-       if (!dd->ipath_kregbase)
+       if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
                return 0;
 
        return readl(regno + (u64 __iomem *)
@@ -763,7 +887,7 @@ static inline void ipath_write_ureg(const struct ipath_devdata *dd,
 static inline u32 ipath_read_kreg32(const struct ipath_devdata *dd,
                                    ipath_kreg regno)
 {
-       if (!dd->ipath_kregbase)
+       if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
                return -1;
        return readl((u32 __iomem *) & dd->ipath_kregbase[regno]);
 }
@@ -771,7 +895,7 @@ static inline u32 ipath_read_kreg32(const struct ipath_devdata *dd,
 static inline u64 ipath_read_kreg64(const struct ipath_devdata *dd,
                                    ipath_kreg regno)
 {
-       if (!dd->ipath_kregbase)
+       if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
                return -1;
 
        return readq(&dd->ipath_kregbase[regno]);
@@ -787,7 +911,7 @@ static inline void ipath_write_kreg(const struct ipath_devdata *dd,
 static inline u64 ipath_read_creg(const struct ipath_devdata *dd,
                                  ipath_sreg regno)
 {
-       if (!dd->ipath_kregbase)
+       if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
                return 0;
 
        return readq(regno + (u64 __iomem *)
@@ -798,7 +922,7 @@ static inline u64 ipath_read_creg(const struct ipath_devdata *dd,
 static inline u32 ipath_read_creg32(const struct ipath_devdata *dd,
                                         ipath_sreg regno)
 {
-       if (!dd->ipath_kregbase)
+       if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
                return 0;
        return readl(regno + (u64 __iomem *)
                     (dd->ipath_cregbase +
@@ -811,7 +935,7 @@ static inline u32 ipath_read_creg32(const struct ipath_devdata *dd,
 
 struct device_driver;
 
-extern const char ipath_core_version[];
+extern const char ib_ipath_version[];
 
 int ipath_driver_create_group(struct device_driver *);
 void ipath_driver_remove_group(struct device_driver *);
@@ -826,6 +950,13 @@ int ipathfs_add_device(struct ipath_devdata *);
 int ipathfs_remove_device(struct ipath_devdata *);
 
 /*
+ * dma_addr wrappers - all 0's invalid for hw
+ */
+dma_addr_t ipath_map_page(struct pci_dev *, struct page *, unsigned long,
+                         size_t, int);
+dma_addr_t ipath_map_single(struct pci_dev *, void *, size_t, int);
+
+/*
  * Flush write combining store buffers (if present) and perform a write
  * barrier.
  */
@@ -837,15 +968,18 @@ int ipathfs_remove_device(struct ipath_devdata *);
 
 extern unsigned ipath_debug; /* debugging bit mask */
 
+#define IPATH_MAX_PARITY_ATTEMPTS 10000 /* max times to try recovery */
+
 const char *ipath_get_unit_name(int unit);
 
 extern struct mutex ipath_mutex;
 
-#define IPATH_DRV_NAME         "ipath_core"
+#define IPATH_DRV_NAME         "ib_ipath"
 #define IPATH_MAJOR            233
-#define IPATH_SMA_MINOR                128
-#define IPATH_DIAG_MINOR       129
-#define IPATH_NMINORS          130
+#define IPATH_USER_MINOR_BASE  0
+#define IPATH_DIAGPKT_MINOR    127
+#define IPATH_DIAG_MINOR_BASE  129
+#define IPATH_NMINORS          255
 
 #define ipath_dev_err(dd,fmt,...) \
        do { \
@@ -881,4 +1015,20 @@ extern struct mutex ipath_mutex;
 
 #endif /* _IPATH_DEBUGGING */
 
+/*
+ * this is used for formatting hw error messages...
+ */
+struct ipath_hwerror_msgs {
+       u64 mask;
+       const char *msg;
+};
+
+#define INFINIPATH_HWE_MSG(a, b) { .mask = INFINIPATH_HWE_##a, .msg = b }
+
+/* in ipath_intr.c... */
+void ipath_format_hwerrors(u64 hwerrs,
+                          const struct ipath_hwerror_msgs *hwerrmsgs,
+                          size_t nhwerrmsgs,
+                          char *msg, size_t lmsg);
+
 #endif                         /* _IPATH_KERNEL_H */