ib/port_attr: report active width as part of port attributes
[mirror/winof/.git] / hw / mlx4 / kernel_patches / mlx4_0030_checksum_offload.patch
1 From cb0f57646824cc986000cc2b8e36cf306f4cda18 Mon Sep 17 00:00:00 2001
2 From: Eli Cohen <eli@mellanox.co.il>
3 Date: Tue, 15 Jan 2008 14:47:39 +0200
4 Subject: [PATCH] Add checksum offload support to mlx4
5
6 Signed-off-by: Eli Cohen <eli@mellnaox.co.il>
7 Signed-off-by: Ali Ayub <ali@mellnaox.co.il>
8 ---
9  drivers/infiniband/hw/mlx4/cq.c   |    2 ++
10  drivers/infiniband/hw/mlx4/main.c |    5 +++++
11  drivers/infiniband/hw/mlx4/qp.c   |    3 +++
12  drivers/net/mlx4/fw.c             |    3 +++
13  include/linux/mlx4/cq.h           |    4 ++--
14  include/linux/mlx4/qp.h           |    2 ++
15  6 files changed, 17 insertions(+), 2 deletions(-)
16
17 Index: ofed_kernel/drivers/infiniband/hw/mlx4/cq.c
18 ===================================================================
19 --- ofed_kernel.orig/drivers/infiniband/hw/mlx4/cq.c    2008-01-24 12:01:00.000000000 +0200
20 +++ ofed_kernel/drivers/infiniband/hw/mlx4/cq.c 2008-01-24 12:09:24.000000000 +0200
21 @@ -314,6 +314,11 @@ static int mlx4_ib_poll_one(struct mlx4_
22         int is_send;
23         int is_error;
24         u16 wqe_ctr;
25 +       __be32 status;
26 +
27 +#define CSUM_MASK_BITS cpu_to_be32(0x13c00000)
28 +#define CSUM_VAL_BITS  cpu_to_be32(0x10400000)
29 +#define CSUM_MASK2_BITS cpu_to_be32(0x0c000000)
30  
31         cqe = next_cqe_sw(cq);
32         if (!cqe)
33 @@ -431,6 +436,10 @@ static int mlx4_ib_poll_one(struct mlx4_
34                 wc->wc_flags      |= be32_to_cpu(cqe->g_mlpath_rqpn) & 0x80000000 ?
35                         IB_WC_GRH : 0;
36                 wc->pkey_index     = be32_to_cpu(cqe->immed_rss_invalid) & 0x7f;
37 +               status = cqe->ipoib_status;
38 +               wc->csum_ok = (status & CSUM_MASK_BITS) == CSUM_VAL_BITS &&
39 +                             (status & CSUM_MASK2_BITS) &&
40 +                             cqe->checksum == 0xffff;
41         }
42  
43         return 0;
44 Index: ofed_kernel/drivers/infiniband/hw/mlx4/main.c
45 ===================================================================
46 --- ofed_kernel.orig/drivers/infiniband/hw/mlx4/main.c  2008-01-24 12:01:17.000000000 +0200
47 +++ ofed_kernel/drivers/infiniband/hw/mlx4/main.c       2008-01-24 12:03:18.000000000 +0200
48 @@ -100,6 +100,8 @@ static int mlx4_ib_query_device(struct i
49                 props->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG;
50         if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UD_AV_PORT)
51                 props->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE;
52 +       if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
53 +               props->device_cap_flags |= IB_DEVICE_IP_CSUM;
54  
55         props->vendor_id           = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
56                 0xffffff;
57 @@ -613,6 +615,9 @@ static void *mlx4_ib_add(struct mlx4_dev
58         ibdev->ib_dev.unmap_fmr         = mlx4_ib_unmap_fmr;
59         ibdev->ib_dev.dealloc_fmr       = mlx4_ib_fmr_dealloc;
60  
61 +       if (ibdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
62 +               ibdev->ib_dev.flags |= IB_DEVICE_IP_CSUM;
63 +
64         if (init_node_data(ibdev))
65                 goto err_map;
66  
67 Index: ofed_kernel/drivers/infiniband/hw/mlx4/qp.c
68 ===================================================================
69 --- ofed_kernel.orig/drivers/infiniband/hw/mlx4/qp.c    2008-01-24 12:01:00.000000000 +0200
70 +++ ofed_kernel/drivers/infiniband/hw/mlx4/qp.c 2008-01-24 12:03:18.000000000 +0200
71 @@ -1307,6 +1307,9 @@ int mlx4_ib_post_send(struct ib_qp *ibqp
72                          cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE) : 0) |
73                         (wr->send_flags & IB_SEND_SOLICITED ?
74                          cpu_to_be32(MLX4_WQE_CTRL_SOLICITED) : 0) |
75 +                       ((wr->send_flags & IB_SEND_IP_CSUM) ?
76 +                        cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
77 +                                    MLX4_WQE_CTRL_TCP_UDP_CSUM) : 0) |
78                         qp->sq_signal_bits;
79  
80                 if (wr->opcode == IB_WR_SEND_WITH_IMM ||
81 Index: ofed_kernel/drivers/net/mlx4/fw.c
82 ===================================================================
83 --- ofed_kernel.orig/drivers/net/mlx4/fw.c      2008-01-24 12:01:17.000000000 +0200
84 +++ ofed_kernel/drivers/net/mlx4/fw.c   2008-01-24 12:03:18.000000000 +0200
85 @@ -741,6 +741,9 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, 
86         MLX4_PUT(inbox, (u8) (PAGE_SHIFT - 12), INIT_HCA_UAR_PAGE_SZ_OFFSET);
87         MLX4_PUT(inbox, param->log_uar_sz,      INIT_HCA_LOG_UAR_SZ_OFFSET);
88  
89 +       if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
90 +               *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 3);
91 +
92         err = mlx4_cmd(dev, mailbox->dma, 0, 0, MLX4_CMD_INIT_HCA, 10000);
93  
94         if (err)
95 Index: ofed_kernel/include/linux/mlx4/cq.h
96 ===================================================================
97 --- ofed_kernel.orig/include/linux/mlx4/cq.h    2008-01-24 12:01:00.000000000 +0200
98 +++ ofed_kernel/include/linux/mlx4/cq.h 2008-01-24 12:03:18.000000000 +0200
99 @@ -45,11 +45,11 @@ struct mlx4_cqe {
100         u8                      sl;
101         u8                      reserved1;
102         __be16                  rlid;
103 -       u32                     reserved2;
104 +       __be32                  ipoib_status;
105         __be32                  byte_cnt;
106         __be16                  wqe_index;
107         __be16                  checksum;
108 -       u8                      reserved3[3];
109 +       u8                      reserved2[3];
110         u8                      owner_sr_opcode;
111  };
112  
113 Index: ofed_kernel/include/linux/mlx4/qp.h
114 ===================================================================
115 --- ofed_kernel.orig/include/linux/mlx4/qp.h    2008-01-24 12:01:00.000000000 +0200
116 +++ ofed_kernel/include/linux/mlx4/qp.h 2008-01-24 12:03:18.000000000 +0200
117 @@ -158,6 +158,8 @@ enum {
118         MLX4_WQE_CTRL_FENCE     = 1 << 6,
119         MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2,
120         MLX4_WQE_CTRL_SOLICITED = 1 << 1,
121 +       MLX4_WQE_CTRL_IP_CSUM           = 1 << 4,
122 +       MLX4_WQE_CTRL_TCP_UDP_CSUM      = 1 << 5,
123  };
124  
125  struct mlx4_wqe_ctrl_seg {