]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/hw/ipath/ipath_kernel.h
IB/ipath: Add ipath_read_ireg() abstraction
[linux-2.6-omap-h63xx.git] / drivers / infiniband / hw / ipath / ipath_kernel.h
index 8786dd7922e4e3916170af24d8cb8752793ea7ba..c472904224578bca556d99b83358b9dcfd79adcd 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 #include <rdma/ib_verbs.h>
 
@@ -140,6 +141,11 @@ struct ipath_portdata {
        u32 port_pionowait;
        /* total number of rcvhdrqfull errors */
        u32 port_hdrqfull;
+       /*
+        * Used to suppress multiple instances of same
+        * port staying stuck at same point.
+        */
+       u32 port_lastrcvhdrqtail;
        /* saved total number of rcvhdrqfull errors for poll edge trigger */
        u32 port_hdrqfull_poll;
        /* total number of polled urgent packets */
@@ -148,6 +154,7 @@ struct ipath_portdata {
        u32 port_urgent_poll;
        /* pid of process using this port */
        pid_t port_pid;
+       pid_t port_subpid[INFINIPATH_MAX_SUBPORT];
        /* same size as task_struct .comm[] */
        char port_comm[16];
        /* pkeys set by this use of this port */
@@ -166,6 +173,8 @@ struct ipath_portdata {
        u32 active_slaves;
        /* Type of packets or conditions we want to poll for */
        u16 poll_type;
+       /* port rcvhdrq head offset */
+       u32 port_head;
 };
 
 struct sk_buff;
@@ -244,6 +253,9 @@ struct ipath_devdata {
        int (*ipath_f_get_base_info)(struct ipath_portdata *, void *);
        /* free irq */
        void (*ipath_f_free_irq)(struct ipath_devdata *);
+       void (*ipath_f_config_ports)(struct ipath_devdata *, ushort);
+       void (*ipath_f_read_counters)(struct ipath_devdata *,
+                                     struct infinipath_counters *);
        struct ipath_ibdev *verbs_dev;
        struct timer_list verbs_timer;
        /* total dwords sent (summed from counter) */
@@ -313,21 +325,11 @@ struct ipath_devdata {
         * supports, less gives more pio bufs/port, etc.
         */
        u32 ipath_cfgports;
-       /* port0 rcvhdrq head offset */
-       u32 ipath_port0head;
        /* count of port 0 hdrqfull errors */
        u32 ipath_p0_hdrqfull;
+       /* port 0 number of receive eager buffers */
+       u32 ipath_p0_rcvegrcnt;
 
-       /*
-        * (*cfgports) used to suppress multiple instances of same
-        * port staying stuck at same point
-        */
-       u32 *ipath_lastrcvhdrqtails;
-       /*
-        * (*cfgports) used to suppress multiple instances of same
-        * port staying stuck at same point
-        */
-       u32 *ipath_lastegrheads;
        /*
         * index of last piobuffer we used.  Speeds up searching, by
         * starting at this point.  Doesn't matter if multiple cpu's use and
@@ -375,6 +377,7 @@ struct ipath_devdata {
        dma_addr_t *ipath_physshadow;
        /* lock to workaround chip bug 9437 */
        spinlock_t ipath_tid_lock;
+       spinlock_t ipath_sendctrl_lock;
 
        /*
         * IPATH_STATUS_*,
@@ -395,6 +398,8 @@ struct ipath_devdata {
        void *ipath_dummy_hdrq; /* used after port close */
        dma_addr_t ipath_dummy_hdrq_phys;
 
+       unsigned long ipath_ureg_align; /* user register alignment */
+
        /*
         * Shadow copies of registers; size indicates read access size.
         * Most of them are readonly, but some are write-only register,
@@ -456,8 +461,6 @@ 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 */
@@ -550,6 +553,12 @@ 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 */
@@ -616,7 +625,7 @@ struct ipath_devdata {
        /* control access to actual counters, timer */
        spinlock_t ipath_eep_st_lock;
        /* control high-level access to EEPROM */
-       struct semaphore ipath_eep_sem;
+       struct mutex ipath_eep_lock;
        /* 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 */
@@ -690,7 +699,7 @@ void ipath_free_pddata(struct ipath_devdata *, struct ipath_portdata *);
 
 int ipath_parse_ushort(const char *str, unsigned short *valp);
 
-void ipath_kreceive(struct ipath_devdata *);
+void ipath_kreceive(struct ipath_portdata *);
 int ipath_setrcvhdrsize(struct ipath_devdata *, unsigned);
 int ipath_reset_device(int);
 void ipath_get_faststats(unsigned long);
@@ -744,9 +753,12 @@ int ipath_set_rx_pol_inv(struct ipath_devdata *dd, u8 new_pol_inv);
                 * are 64bit */
 #define IPATH_32BITCOUNTERS 0x20000
                /* can miss port0 rx interrupts */
+               /* Interrupt register is 64 bits */
+#define IPATH_INTREG_64     0x40000
 #define IPATH_DISABLED      0x80000 /* administratively disabled */
                /* Use GPIO interrupts for new counters */
 #define IPATH_GPIO_ERRINTRS 0x100000
+#define IPATH_SWAP_PIOBUFS  0x200000
 
 /* Bits in GPIO for the added interrupts */
 #define IPATH_GPIO_PORT0_BIT 2
@@ -758,8 +770,6 @@ int ipath_set_rx_pol_inv(struct ipath_devdata *dd, u8 new_pol_inv);
 /* 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 */
@@ -863,7 +873,7 @@ static inline u32 ipath_read_ureg32(const struct ipath_devdata *dd,
        return readl(regno + (u64 __iomem *)
                     (dd->ipath_uregbase +
                      (char __iomem *)dd->ipath_kregbase +
-                     dd->ipath_palign * port));
+                     dd->ipath_ureg_align * port));
 }
 
 /**
@@ -880,7 +890,7 @@ static inline void ipath_write_ureg(const struct ipath_devdata *dd,
 {
        u64 __iomem *ubase = (u64 __iomem *)
                (dd->ipath_uregbase + (char __iomem *) dd->ipath_kregbase +
-                dd->ipath_palign * port);
+                dd->ipath_ureg_align * port);
        if (dd->ipath_kregbase)
                writeq(value, &ubase[regno]);
 }
@@ -930,6 +940,32 @@ static inline u32 ipath_read_creg32(const struct ipath_devdata *dd,
                      (char __iomem *)dd->ipath_kregbase));
 }
 
+static inline void ipath_write_creg(const struct ipath_devdata *dd,
+                                   ipath_creg regno, u64 value)
+{
+       if (dd->ipath_kregbase)
+               writeq(value, regno + (u64 __iomem *)
+                      (dd->ipath_cregbase +
+                       (char __iomem *)dd->ipath_kregbase));
+}
+
+static inline void ipath_clear_rcvhdrtail(const struct ipath_portdata *pd)
+{
+       *((u64 *) pd->port_rcvhdrtail_kvaddr) = 0ULL;
+}
+
+static inline u32 ipath_get_rcvhdrtail(const struct ipath_portdata *pd)
+{
+       return (u32) le64_to_cpu(*((volatile __le64 *)
+                               pd->port_rcvhdrtail_kvaddr));
+}
+
+static inline u64 ipath_read_ireg(const struct ipath_devdata *dd, ipath_kreg r)
+{
+       return (dd->ipath_flags & IPATH_INTREG_64) ?
+               ipath_read_kreg64(dd, r) : ipath_read_kreg32(dd, r);
+}
+
 /*
  * sysfs interface.
  */
@@ -938,8 +974,7 @@ struct device_driver;
 
 extern const char ib_ipath_version[];
 
-int ipath_driver_create_group(struct device_driver *);
-void ipath_driver_remove_group(struct device_driver *);
+extern struct attribute_group *ipath_driver_attr_groups[];
 
 int ipath_device_create_group(struct device *, struct ipath_devdata *);
 void ipath_device_remove_group(struct device *, struct ipath_devdata *);