[ofw] patch: move eq defenitions to a common header file
Tzachi Dar
tzachid at mellanox.co.il
Thu Jul 10 01:08:20 PDT 2008
Applied at 1362.
________________________________
From: ofw-bounces at lists.openfabrics.org
[mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Tzachi Dar
Sent: Wednesday, July 09, 2008 12:39 PM
To: ofw at lists.openfabrics.org; Uri Habusha
Subject: [ofw] patch: move eq defenitions to a common header
file
This patch is in order to allow other users of the eqs to use
the code that reads data from the eq.
(no new code is introduced, only moving code from .c file to .h
file)
Thanks
Tzachi
Index: inc/eq.h
===================================================================
--- inc/eq.h (revision 0)
+++ inc/eq.h (revision 0)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2008 Mellanox Technologies. All rights
reserved.
+ * Portions Copyright (c) 2008 Microsoft Corporation. All
rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD
license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with
or
+ * without modification, are permitted provided that the
following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the
above
+ * copyright notice, this list of conditions and the
following
+ * disclaimer in the documentation and/or other
materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE
+ * SOFTWARE.
+ *
+ * $Id: ipoib_port.h 1310 2008-06-30 18:09:25Z ftillier $
+ */
+
+#ifndef MLX4_EQ_H
+#define MLX4_EQ_H
+
+enum {
+ MLX4_NUM_ASYNC_EQE = 0x100,
+ MLX4_NUM_SPARE_EQE = 0x80,
+ MLX4_EQ_ENTRY_SIZE = 0x20
+};
+
+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 */
+};
+
+
+
+#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;
+}
+
+
+
+#endif /* MLX4_EQ_H */
+
+
Index: net/eq.c
===================================================================
--- net/eq.c (revision 1353)
+++ net/eq.c (working copy)
@@ -34,13 +34,8 @@
#include "mlx4.h"
#include "cmd.h"
#include "fw.h"
+#include "eq.h"
-enum {
- MLX4_NUM_ASYNC_EQE = 0x100,
- MLX4_NUM_SPARE_EQE = 0x80,
- MLX4_EQ_ENTRY_SIZE = 0x20
-};
-
/*
* Must be packed because start is 64 bits but only aligned to
32 bits.
*/
@@ -91,68 +86,6 @@
(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: net/mlx4.h
===================================================================
--- net/mlx4.h (revision 1353)
+++ net/mlx4.h (working copy)
@@ -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 **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;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080710/08cd888c/attachment.html>
More information about the ofw
mailing list