IB/ipath: Fix check for no interrupts to reliably fallback to INTx
[firefly-linux-kernel-4.4.55.git] / drivers / infiniband / hw / ipath / ipath_kernel.h
index b8b81cb745b91499aadf48aa82996311e034c1fc..56e51cd7d6b9df04c3b99353e5f66bc9db05c7b1 100644 (file)
@@ -175,6 +175,8 @@ struct ipath_portdata {
        u16 poll_type;
        /* port rcvhdrq head offset */
        u32 port_head;
+       /* receive packet sequence counter */
+       u32 port_seq_cnt;
 };
 
 struct sk_buff;
@@ -191,6 +193,9 @@ struct ipath_skbinfo {
        dma_addr_t phys;
 };
 
+/* max dwords in small buffer packet */
+#define IPATH_SMALLBUF_DWORDS (dd->ipath_piosize2k >> 2)
+
 /*
  * Possible IB config parameters for ipath_f_get/set_ib_cfg()
  */
@@ -221,11 +226,6 @@ struct ipath_devdata {
        unsigned long ipath_physaddr;
        /* base of memory alloced for ipath_kregbase, for free */
        u64 *ipath_kregalloc;
-       /*
-        * virtual address where port0 rcvhdrqtail updated for this unit.
-        * only written to by the chip, not the driver.
-        */
-       volatile __le64 *ipath_hdrqtailptr;
        /* ipath_cfgports pointers */
        struct ipath_portdata **ipath_pd;
        /* sk_buffs used by port 0 eager receive queue */
@@ -283,6 +283,7 @@ struct ipath_devdata {
        /* per chip actions needed for IB Link up/down changes */
        int (*ipath_f_ib_updown)(struct ipath_devdata *, int, u64);
 
+       unsigned ipath_lastegr_idx;
        struct ipath_ibdev *verbs_dev;
        struct timer_list verbs_timer;
        /* total dwords sent (summed from counter) */
@@ -348,6 +349,7 @@ struct ipath_devdata {
        u32 ipath_lastrpkts;
        /* pio bufs allocated per port */
        u32 ipath_pbufsport;
+       u32 ipath_pioupd_thresh; /* update threshold, some chips */
        /*
         * number of ports configured as max; zero is set to number chip
         * supports, less gives more pio bufs/port, etc.
@@ -366,6 +368,7 @@ struct ipath_devdata {
         * get to multiple devices
         */
        u32 ipath_lastpioindex;
+       u32 ipath_lastpioindexl;
        /* max length of freezemsg */
        u32 ipath_freezelen;
        /*
@@ -423,6 +426,8 @@ struct ipath_devdata {
        struct class_device *diag_class_dev;
        /* timer used to prevent stats overflow, error throttling, etc. */
        struct timer_list ipath_stats_timer;
+       /* timer to verify interrupts work, and fallback if possible */
+       struct timer_list ipath_intrchk_timer;
        void *ipath_dummy_hdrq; /* used after port close */
        dma_addr_t ipath_dummy_hdrq_phys;
 
@@ -453,6 +458,8 @@ struct ipath_devdata {
         * init time.
         */
        unsigned long ipath_pioavailshadow[8];
+       /* bitmap of send buffers available for the kernel to use with PIO. */
+       unsigned long ipath_pioavailkernel[8];
        /* shadow of kr_gpio_out, for rmw ops */
        u64 ipath_gpio_out;
        /* shadow the gpio mask register */
@@ -587,14 +594,6 @@ struct ipath_devdata {
        u8 ipath_minrev;
        /* board rev, from ipath_revision */
        u8 ipath_boardrev;
-
-       u8 ipath_r_portenable_shift;
-       u8 ipath_r_intravail_shift;
-       u8 ipath_r_tailupd_shift;
-       u8 ipath_r_portcfg_shift;
-
-       /* unit # of this chip, if present */
-       int ipath_unit;
        /* saved for restore after reset */
        u8 ipath_pci_cacheline;
        /* LID mask control */
@@ -610,6 +609,14 @@ struct ipath_devdata {
        /* Rx Polarity inversion (compensate for ~tx on partner) */
        u8 ipath_rx_pol_inv;
 
+       u8 ipath_r_portenable_shift;
+       u8 ipath_r_intravail_shift;
+       u8 ipath_r_tailupd_shift;
+       u8 ipath_r_portcfg_shift;
+
+       /* unit # of this chip, if present */
+       int ipath_unit;
+
        /* local link integrity counter */
        u32 ipath_lli_counter;
        /* local link integrity errors */
@@ -624,9 +631,6 @@ struct ipath_devdata {
        u32 ipath_overrun_thresh_errs;
        u32 ipath_lli_errs;
 
-       /* status check work */
-       struct delayed_work status_work;
-
        /*
         * Not all devices managed by a driver instance are the same
         * type, so these fields must be per-device.
@@ -639,8 +643,8 @@ struct ipath_devdata {
         * Below should be computable from number of ports,
         * since they are never modified.
         */
-       u32 ipath_i_rcvavail_mask;
-       u32 ipath_i_rcvurg_mask;
+       u64 ipath_i_rcvavail_mask;
+       u64 ipath_i_rcvurg_mask;
        u16 ipath_i_rcvurg_shift;
        u16 ipath_i_rcvavail_shift;
 
@@ -648,8 +652,9 @@ struct ipath_devdata {
         * Register bits for selecting i2c direction and values, used for
         * I2C serial flash.
         */
-       u16 ipath_gpio_sda_num;
-       u16 ipath_gpio_scl_num;
+       u8 ipath_gpio_sda_num;
+       u8 ipath_gpio_scl_num;
+       u8 ipath_i2c_chain_type;
        u64 ipath_gpio_sda;
        u64 ipath_gpio_scl;
 
@@ -804,7 +809,7 @@ void ipath_hol_event(unsigned long);
  */
                /* chip can report link latency (IB 1.2) */
 #define IPATH_HAS_LINK_LATENCY 0x1
-/* The chip is up and initted */
+               /* The chip is up and initted */
 #define IPATH_INITTED       0x2
                /* set if any user code has set kr_rcvhdrsize */
 #define IPATH_RCVHDRSZ_SET  0x4
@@ -828,6 +833,8 @@ void ipath_hol_event(unsigned long);
 #define IPATH_LINKUNK       0x400
                /* Write combining flush needed for PIO */
 #define IPATH_PIO_FLUSH_WC  0x1000
+               /* DMA Receive tail pointer */
+#define IPATH_NODMA_RTAIL   0x2000
                /* no IB cable, or no device on IB cable */
 #define IPATH_NOCABLE       0x4000
                /* Supports port zero per packet receive interrupts via
@@ -838,9 +845,9 @@ void ipath_hol_event(unsigned long);
                /* packet/word counters are 32 bit, else those 4 counters
                 * are 64bit */
 #define IPATH_32BITCOUNTERS 0x20000
-               /* can miss port0 rx interrupts */
                /* Interrupt register is 64 bits */
 #define IPATH_INTREG_64     0x40000
+               /* can miss port0 rx interrupts */
 #define IPATH_DISABLED      0x80000 /* administratively disabled */
                /* Use GPIO interrupts for new counters */
 #define IPATH_GPIO_ERRINTRS 0x100000
@@ -848,6 +855,8 @@ void ipath_hol_event(unsigned long);
                /* Suppress heartbeat, even if turning off loopback */
 #define IPATH_NO_HRTBT      0x1000000
 #define IPATH_HAS_MULT_IB_SPEED 0x8000000
+               /* Linkdown-disable intentionally, Do not attempt to bring up */
+#define IPATH_IB_LINK_DISABLED 0x40000000
 #define IPATH_IB_FORCE_NOTIFY 0x80000000 /* force notify on next ib change */
 
 /* Bits in GPIO for the added interrupts */
@@ -867,13 +876,16 @@ void ipath_hol_event(unsigned long);
 
 /* free up any allocated data at closes */
 void ipath_free_data(struct ipath_portdata *dd);
-u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32 *);
+u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32, u32 *);
+void ipath_chg_pioavailkernel(struct ipath_devdata *dd, unsigned start,
+                               unsigned len, int avail);
 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);
+void ipath_force_pio_avail_update(struct ipath_devdata *);
 void signal_ib_event(struct ipath_devdata *dd, enum ib_event_type ev);
 
 /*
@@ -895,6 +907,8 @@ 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);
 int ipath_eeprom_write(struct ipath_devdata *, u8, const void *, int);
+int ipath_tempsense_read(struct ipath_devdata *, u8 regnum);
+int ipath_tempsense_write(struct ipath_devdata *, u8 regnum, u8 data);
 
 /* these are used for the registers that vary with port */
 void ipath_write_kreg_port(const struct ipath_devdata *, ipath_kreg,
@@ -1021,6 +1035,27 @@ static inline u32 ipath_get_rcvhdrtail(const struct ipath_portdata *pd)
                                pd->port_rcvhdrtail_kvaddr));
 }
 
+static inline u32 ipath_get_hdrqtail(const struct ipath_portdata *pd)
+{
+       const struct ipath_devdata *dd = pd->port_dd;
+       u32 hdrqtail;
+
+       if (dd->ipath_flags & IPATH_NODMA_RTAIL) {
+               __le32 *rhf_addr;
+               u32 seq;
+
+               rhf_addr = (__le32 *) pd->port_rcvhdrq +
+                       pd->port_head + dd->ipath_rhf_offset;
+               seq = ipath_hdrget_seq(rhf_addr);
+               hdrqtail = pd->port_head;
+               if (seq == pd->port_seq_cnt)
+                       hdrqtail++;
+       } else
+               hdrqtail = ipath_get_rcvhdrtail(pd);
+
+       return hdrqtail;
+}
+
 static inline u64 ipath_read_ireg(const struct ipath_devdata *dd, ipath_kreg r)
 {
        return (dd->ipath_flags & IPATH_INTREG_64) ?
@@ -1133,7 +1168,7 @@ extern struct mutex ipath_mutex;
 
 # define __IPATH_DBG_WHICH(which,fmt,...) \
        do { \
-               if(unlikely(ipath_debug&(which))) \
+               if (unlikely(ipath_debug & (which))) \
                        printk(KERN_DEBUG IPATH_DRV_NAME ": %s: " fmt, \
                               __func__,##__VA_ARGS__); \
        } while(0)