[mlx4] move eq definitions to a common header file
authortzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 10 Jul 2008 08:07:28 +0000 (08:07 +0000)
committertzachid <tzachid@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 10 Jul 2008 08:07:28 +0000 (08:07 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1366 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/kernel/bus/inc/eq.h [new file with mode: 0644]
hw/mlx4/kernel/bus/net/eq.c
hw/mlx4/kernel/bus/net/mlx4.h

diff --git a/hw/mlx4/kernel/bus/inc/eq.h b/hw/mlx4/kernel/bus/inc/eq.h
new file mode 100644 (file)
index 0000000..cc0087d
--- /dev/null
@@ -0,0 +1,129 @@
+/*\r
+ * Copyright (c) 2008 Mellanox Technologies.  All rights reserved.\r
+ * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.\r
+ *\r
+ * This software is available to you under the OpenIB.org BSD license\r
+ * below:\r
+ *\r
+ *     Redistribution and use in source and binary forms, with or\r
+ *     without modification, are permitted provided that the following\r
+ *     conditions are met:\r
+ *\r
+ *      - Redistributions of source code must retain the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer.\r
+ *\r
+ *      - Redistributions in binary form must reproduce the above\r
+ *        copyright notice, this list of conditions and the following\r
+ *        disclaimer in the documentation and/or other materials\r
+ *        provided with the distribution.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ * $Id: ipoib_port.h 1310 2008-06-30 18:09:25Z ftillier $\r
+ */\r
+\r
+#ifndef MLX4_EQ_H\r
+#define MLX4_EQ_H\r
+\r
+enum {
+       MLX4_NUM_ASYNC_EQE      = 0x100,
+       MLX4_NUM_SPARE_EQE      = 0x80,
+       MLX4_EQ_ENTRY_SIZE      = 0x20
+};\r
+\r
+struct mlx4_eq {
+       struct mlx4_dev        *dev;
+       void __iomem           *doorbell;
+       int                     eqn;
+       u32                     cons_index;
+       u16                     irq;
+       u16                     have_irq;
+       int                     nent;
+       struct mlx4_buf_list   *page_list;
+       struct mlx4_mtt         mtt;
+       // Windows
+       KDPC            dpc;            /* DPC routine */
+       spinlock_t      lock;           /* spinlock for simult DPCs */
+       int                     eq_ix;          /* EQ index - 0..MLX4_NUM_EQ */
+       BOOLEAN (*isr)(void*);  /* isr */
+       void *          ctx;            /* isr ctx */
+       USHORT eq_no_progress;  /* used to look for stacked card */
+};
+\r
+\r
+\r
+#pragma pack(push,1)
+struct mlx4_eqe {
+       u8                      reserved1;
+       u8                      type;
+       u8                      reserved2;
+       u8                      subtype;
+       union {
+               u32             raw[6];
+               struct {
+                       __be32  cqn;
+               } __attribute__((packed)) comp;
+               struct {
+                       u16     reserved1;
+                       __be16  token;
+                       u32     reserved2;
+                       u8      reserved3[3];
+                       u8      status;
+                       __be64  out_param;
+               } __attribute__((packed)) cmd;
+               struct {
+                       __be32  qpn;
+               } __attribute__((packed)) qp;
+               struct {
+                       __be32  srqn;
+               } __attribute__((packed)) srq;
+               struct {
+                       __be32  cqn;
+                       u32     reserved1;
+                       u8      reserved2[3];
+                       u8      syndrome;
+               } __attribute__((packed)) cq_err;
+               struct {
+                       u32     reserved1[2];
+                       __be32  port;
+               } __attribute__((packed)) port_change;
+       }                       event;
+       u8                      reserved3[3];
+       u8                      owner;
+} __attribute__((packed));
+#pragma pack(pop)
+
+static void eq_set_ci(struct mlx4_eq *eq, int req_not)
+{
+       __raw_writel((__force u32) cpu_to_be32((eq->cons_index & 0xffffff) |
+                                              req_not << 31),
+                    eq->doorbell);
+       /* We still want ordering, just not swabbing, so add a barrier */
+       mb();
+}
+
+static struct mlx4_eqe *get_eqe(struct mlx4_eq *eq, u32 entry)
+{
+       unsigned long off = (entry & (eq->nent - 1)) * MLX4_EQ_ENTRY_SIZE;
+       return (struct mlx4_eqe *)(eq->page_list[off / PAGE_SIZE].buf + off % PAGE_SIZE);
+}
+
+static struct mlx4_eqe *next_eqe_sw(struct mlx4_eq *eq)
+{
+       struct mlx4_eqe *eqe = get_eqe(eq, eq->cons_index);
+       return !!(eqe->owner & 0x80) ^ !!(eq->cons_index & eq->nent) ? NULL : eqe;
+}
+\r
+\r
+\r
+#endif /* MLX4_EQ_H */\r
+\r
+\r
index c0fc783..5296160 100644 (file)
 #include "mlx4.h"
 #include "cmd.h"
 #include "fw.h"
-
-enum {
-       MLX4_NUM_ASYNC_EQE      = 0x100,
-       MLX4_NUM_SPARE_EQE      = 0x80,
-       MLX4_EQ_ENTRY_SIZE      = 0x20
-};
+#include "eq.h"
 
 /*
  * Must be packed because start is 64 bits but only aligned to 32 bits.
@@ -91,68 +86,6 @@ struct mlx4_eq_context {
                               (1ull << MLX4_EVENT_TYPE_SRQ_LIMIT)          | \
                               (1ull << MLX4_EVENT_TYPE_CMD))
 
-#pragma pack(push,1)
-struct mlx4_eqe {
-       u8                      reserved1;
-       u8                      type;
-       u8                      reserved2;
-       u8                      subtype;
-       union {
-               u32             raw[6];
-               struct {
-                       __be32  cqn;
-               } __attribute__((packed)) comp;
-               struct {
-                       u16     reserved1;
-                       __be16  token;
-                       u32     reserved2;
-                       u8      reserved3[3];
-                       u8      status;
-                       __be64  out_param;
-               } __attribute__((packed)) cmd;
-               struct {
-                       __be32  qpn;
-               } __attribute__((packed)) qp;
-               struct {
-                       __be32  srqn;
-               } __attribute__((packed)) srq;
-               struct {
-                       __be32  cqn;
-                       u32     reserved1;
-                       u8      reserved2[3];
-                       u8      syndrome;
-               } __attribute__((packed)) cq_err;
-               struct {
-                       u32     reserved1[2];
-                       __be32  port;
-               } __attribute__((packed)) port_change;
-       }                       event;
-       u8                      reserved3[3];
-       u8                      owner;
-} __attribute__((packed));
-#pragma pack(pop)
-
-static void eq_set_ci(struct mlx4_eq *eq, int req_not)
-{
-       __raw_writel((__force u32) cpu_to_be32((eq->cons_index & 0xffffff) |
-                                              req_not << 31),
-                    eq->doorbell);
-       /* We still want ordering, just not swabbing, so add a barrier */
-       mb();
-}
-
-static struct mlx4_eqe *get_eqe(struct mlx4_eq *eq, u32 entry)
-{
-       unsigned long off = (entry & (eq->nent - 1)) * MLX4_EQ_ENTRY_SIZE;
-       return (struct mlx4_eqe *)(eq->page_list[off / PAGE_SIZE].buf + off % PAGE_SIZE);
-}
-
-static struct mlx4_eqe *next_eqe_sw(struct mlx4_eq *eq)
-{
-       struct mlx4_eqe *eqe = get_eqe(eq, eq->cons_index);
-       return !!(eqe->owner & 0x80) ^ !!(eq->cons_index & eq->nent) ? NULL : eqe;
-}
-
 #pragma warning( disable : 4706)
 static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
 {
index 051379b..76af035 100644 (file)
@@ -42,6 +42,7 @@
 #include "device.h"
 #include "doorbell.h"
 #include "bus_intf.h"
+#include "eq.h"
 
 
 #define DRV_NAME       "mlx4_net"
@@ -163,25 +164,6 @@ struct mlx4_icm_table {
        struct mlx4_icm       **icm;
 };
 
-struct mlx4_eq {
-       struct mlx4_dev        *dev;
-       void __iomem           *doorbell;
-       int                     eqn;
-       u32                     cons_index;
-       u16                     irq;
-       u16                     have_irq;
-       int                     nent;
-       struct mlx4_buf_list   *page_list;
-       struct mlx4_mtt         mtt;
-       // Windows
-       KDPC            dpc;            /* DPC routine */
-       spinlock_t      lock;           /* spinlock for simult DPCs */
-       int                     eq_ix;          /* EQ index - 0..MLX4_NUM_EQ */
-       BOOLEAN (*isr)(void*);  /* isr */
-       void *          ctx;            /* isr ctx */
-       USHORT eq_no_progress;  /* used to look for stacked card */
-};
-
 struct mlx4_profile {
        int                     num_qp;
        int                     rdmarc_per_qp;