]> err.no Git - linux-2.6/commitdiff
RDMA/nes: Fix CRC endianness for RDMA connection establishment on big-endian
authorFaisal Latif <flatif@neteffect.com>
Thu, 21 Feb 2008 14:31:22 +0000 (08:31 -0600)
committerRoland Dreier <rolandd@cisco.com>
Wed, 27 Feb 2008 00:24:29 +0000 (16:24 -0800)
With commit ef19454b ("[LIB] crc32c: Keep intermediate crc state in
cpu order"), the behavior of crc32c changes on big-endian platforms.

Our algorithm expects the previous behavior; otherwise we have RDMA
connection establishment failure on big-endian platforms like powerpc.
Apply cpu_to_le32() to value returned by crc32c() to get the previous
behavior.

Signed-off-by: Faisal Latif <flatif@neteffect.com>
Signed-off-by: Glenn Streiff <gstreiff@neteffect.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/nes/nes.h
drivers/infiniband/hw/nes/nes_cm.c

index fd57e8a1582f210383044ab7748eabbccdcf662d..a48b288618ece5d569644915455e51251e4d5e97 100644 (file)
@@ -285,6 +285,21 @@ struct nes_device {
 };
 
 
+static inline __le32 get_crc_value(struct nes_v4_quad *nes_quad)
+{
+       u32 crc_value;
+       crc_value = crc32c(~0, (void *)nes_quad, sizeof (struct nes_v4_quad));
+
+       /*
+        * With commit ef19454b ("[LIB] crc32c: Keep intermediate crc
+        * state in cpu order"), behavior of crc32c changes on
+        * big-endian platforms.  Our algorithm expects the previous
+        * behavior; otherwise we have RDMA connection establishment
+        * issue on big-endian.
+        */
+       return cpu_to_le32(crc_value);
+}
+
 static inline void
 set_wqe_64bit_value(__le32 *wqe_words, u32 index, u64 value)
 {
index 6c298aa9ab05a06e7c8945f54bbef2f03d42a8c3..39adb267fb1553fb45d96104b361eb6442ba8658 100644 (file)
@@ -2320,6 +2320,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
        struct iw_cm_event cm_event;
        struct nes_hw_qp_wqe *wqe;
        struct nes_v4_quad nes_quad;
+       u32 crc_value;
        int ret;
 
        ibqp = nes_get_qp(cm_id->device, conn_param->qpn);
@@ -2436,8 +2437,8 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
        nes_quad.TcpPorts[1]   = cm_id->local_addr.sin_port;
 
        /* Produce hash key */
-       nesqp->hte_index = cpu_to_be32(
-                       crc32c(~0, (void *)&nes_quad, sizeof(nes_quad)) ^ 0xffffffff);
+       crc_value = get_crc_value(&nes_quad);
+       nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff);
        nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, CRC = 0x%08X\n",
                        nesqp->hte_index, nesqp->hte_index & adapter->hte_index_mask);
 
@@ -2751,6 +2752,7 @@ void cm_event_connected(struct nes_cm_event *event)
        struct iw_cm_event cm_event;
        struct nes_hw_qp_wqe *wqe;
        struct nes_v4_quad nes_quad;
+       u32 crc_value;
        int ret;
 
        /* get all our handles */
@@ -2828,8 +2830,8 @@ void cm_event_connected(struct nes_cm_event *event)
        nes_quad.TcpPorts[1] = cm_id->local_addr.sin_port;
 
        /* Produce hash key */
-       nesqp->hte_index = cpu_to_be32(
-                       crc32c(~0, (void *)&nes_quad, sizeof(nes_quad)) ^ 0xffffffff);
+       crc_value = get_crc_value(&nes_quad);
+       nesqp->hte_index = cpu_to_be32(crc_value ^ 0xffffffff);
        nes_debug(NES_DBG_CM, "HTE Index = 0x%08X, After CRC = 0x%08X\n",
                        nesqp->hte_index, nesqp->hte_index & nesadapter->hte_index_mask);