aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEli Cohen <eli@dev.mellanox.co.il>2008-04-17 00:01:10 -0400
committerRoland Dreier <rolandd@cisco.com>2008-04-17 00:01:10 -0400
commit8ff095ec4bce7be943beff3b330562e2f0e42167 (patch)
treed0643b575033a033a072c2c0687be7e57d183d99 /drivers
parent6046136c742e32d5e6431cdcd8957638d1816821 (diff)
IB/mlx4: Add IPoIB checksum offload support
ConnectX devices support checksum generation and verification of TCP and UDP packets for UD IPoIB messages. This patch checks if the HCA supports this and sets the IB_DEVICE_UD_IP_CSUM capability flag if it does. It implements support for handling the IB_SEND_IP_CSUM send flag and setting the csum_ok field in receive work completions. Signed-off-by: Eli Cohen <eli@mellanox.co.il> Signed-off-by: Ali Ayub <ali@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c16
-rw-r--r--drivers/infiniband/hw/mlx4/main.c2
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c3
-rw-r--r--drivers/net/mlx4/fw.c4
4 files changed, 25 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 7360bbafbe84..d2e32b03e2f7 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -297,6 +297,20 @@ static void mlx4_ib_handle_error_cqe(struct mlx4_err_cqe *cqe,
297 wc->vendor_err = cqe->vendor_err_syndrome; 297 wc->vendor_err = cqe->vendor_err_syndrome;
298} 298}
299 299
300static int mlx4_ib_ipoib_csum_ok(__be32 status, __be16 checksum)
301{
302 return ((status & cpu_to_be32(MLX4_CQE_IPOIB_STATUS_IPV4 |
303 MLX4_CQE_IPOIB_STATUS_IPV4F |
304 MLX4_CQE_IPOIB_STATUS_IPV4OPT |
305 MLX4_CQE_IPOIB_STATUS_IPV6 |
306 MLX4_CQE_IPOIB_STATUS_IPOK)) ==
307 cpu_to_be32(MLX4_CQE_IPOIB_STATUS_IPV4 |
308 MLX4_CQE_IPOIB_STATUS_IPOK)) &&
309 (status & cpu_to_be32(MLX4_CQE_IPOIB_STATUS_UDP |
310 MLX4_CQE_IPOIB_STATUS_TCP)) &&
311 checksum == cpu_to_be16(0xffff);
312}
313
300static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq, 314static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq,
301 struct mlx4_ib_qp **cur_qp, 315 struct mlx4_ib_qp **cur_qp,
302 struct ib_wc *wc) 316 struct ib_wc *wc)
@@ -434,6 +448,8 @@ static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq,
434 wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f; 448 wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f;
435 wc->wc_flags |= g_mlpath_rqpn & 0x80000000 ? IB_WC_GRH : 0; 449 wc->wc_flags |= g_mlpath_rqpn & 0x80000000 ? IB_WC_GRH : 0;
436 wc->pkey_index = be32_to_cpu(cqe->immed_rss_invalid) & 0x7f; 450 wc->pkey_index = be32_to_cpu(cqe->immed_rss_invalid) & 0x7f;
451 wc->csum_ok = mlx4_ib_ipoib_csum_ok(cqe->ipoib_status,
452 cqe->checksum);
437 } 453 }
438 454
439 return 0; 455 return 0;
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index d5512011999c..6ea4746c2e9b 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -99,6 +99,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
99 props->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG; 99 props->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG;
100 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UD_AV_PORT) 100 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UD_AV_PORT)
101 props->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE; 101 props->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE;
102 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
103 props->device_cap_flags |= IB_DEVICE_UD_IP_CSUM;
102 104
103 props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) & 105 props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
104 0xffffff; 106 0xffffff;
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index ac965ab28845..31b2b5b230bd 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1436,6 +1436,9 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1436 cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE) : 0) | 1436 cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE) : 0) |
1437 (wr->send_flags & IB_SEND_SOLICITED ? 1437 (wr->send_flags & IB_SEND_SOLICITED ?
1438 cpu_to_be32(MLX4_WQE_CTRL_SOLICITED) : 0) | 1438 cpu_to_be32(MLX4_WQE_CTRL_SOLICITED) : 0) |
1439 ((wr->send_flags & IB_SEND_IP_CSUM) ?
1440 cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
1441 MLX4_WQE_CTRL_TCP_UDP_CSUM) : 0) |
1439 qp->sq_signal_bits; 1442 qp->sq_signal_bits;
1440 1443
1441 if (wr->opcode == IB_WR_SEND_WITH_IMM || 1444 if (wr->opcode == IB_WR_SEND_WITH_IMM ||
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c
index 61dc4951d6b0..f494c3e8bce3 100644
--- a/drivers/net/mlx4/fw.c
+++ b/drivers/net/mlx4/fw.c
@@ -696,6 +696,10 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param)
696 /* Check port for UD address vector: */ 696 /* Check port for UD address vector: */
697 *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1); 697 *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1);
698 698
699 /* Enable IPoIB checksumming if we can: */
700 if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
701 *(inbox + INIT_HCA_FLAGS_OFFSET / 4) |= cpu_to_be32(1 << 3);
702
699 /* QPC/EEC/CQC/EQC/RDMARC attributes */ 703 /* QPC/EEC/CQC/EQC/RDMARC attributes */
700 704
701 MLX4_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET); 705 MLX4_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET);