[ofa-general] [PATCH - 5] ipoib checksum offlad
Eli Cohen
eli at mellanox.co.il
Wed Aug 15 11:14:18 PDT 2007
Add checksum offload support to ipoib
Signed-off-by: Eli Cohen <eli at mellnaox.co.il>
Signed-off-by: Ali Ayub <ali at mellnaox.co.il>
---
Index: linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib.h
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/ulp/ipoib/ipoib.h 2007-08-15 20:50:14.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib.h 2007-08-15 20:50:31.000000000 +0300
@@ -86,6 +86,7 @@ enum {
IPOIB_MCAST_STARTED = 8,
IPOIB_FLAG_NETIF_STOPPED = 9,
IPOIB_FLAG_ADMIN_CM = 10,
+ IPOIB_FLAG_RX_CSUM = 11,
IPOIB_MAX_BACKOFF_SECONDS = 16,
Index: linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib_cm.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/ulp/ipoib/ipoib_cm.c 2007-08-15 20:50:14.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib_cm.c 2007-08-15 20:50:31.000000000 +0300
@@ -1252,6 +1252,8 @@ static ssize_t set_mode(struct device *d
/* flush paths if we switch modes so that connections are restarted */
if (IPOIB_CM_SUPPORTED(dev->dev_addr) && !strcmp(buf, "connected\n")) {
set_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
+ /* on CM mode, turn off tx_csum offloading */
+ dev->features &= ~NETIF_F_HW_CSUM;
ipoib_warn(priv, "enabling connected mode "
"will cause multicast packet drops\n");
ipoib_flush_paths(dev);
Index: linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/ulp/ipoib/ipoib_ib.c 2007-08-15 20:50:14.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib_ib.c 2007-08-15 20:50:31.000000000 +0300
@@ -37,6 +37,7 @@
#include <linux/delay.h>
#include <linux/dma-mapping.h>
+#include <linux/ip.h>
#include <rdma/ib_cache.h>
@@ -231,6 +232,14 @@ static void ipoib_ib_handle_rx_wc(struct
skb->dev = dev;
/* XXX get correct PACKET_ type here */
skb->pkt_type = PACKET_HOST;
+
+ /* check rx csum */
+ if (test_bit(IPOIB_FLAG_RX_CSUM, &priv->flags))
+ if (likely(wc->csum_ok)) {
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb->csum = wc->csum;
+ }
+
netif_receive_skb(skb);
repost:
@@ -394,6 +403,16 @@ void ipoib_send(struct net_device *dev,
}
tx_req->mapping = addr;
+ if (dev->features & NETIF_F_HW_CSUM) {
+ if (likely(skb->ip_summed == CHECKSUM_PARTIAL))
+ priv->tx_wr.send_flags |=
+ IB_SEND_UDP_TCP_CSUM | IB_SEND_IP_CSUM;
+ else
+ priv->tx_wr.send_flags &=
+ ~(IB_SEND_UDP_TCP_CSUM | IB_SEND_IP_CSUM);
+ }
+
+
if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1),
address->ah, qpn, addr, skb->len))) {
ipoib_warn(priv, "post_send failed\n");
Index: linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib_main.c
===================================================================
--- linux-2.6.23-rc1.orig/drivers/infiniband/ulp/ipoib/ipoib_main.c 2007-08-15 20:50:27.000000000 +0300
+++ linux-2.6.23-rc1/drivers/infiniband/ulp/ipoib/ipoib_main.c 2007-08-15 20:50:31.000000000 +0300
@@ -1067,6 +1067,29 @@ int ipoib_add_pkey_attr(struct net_devic
return device_create_file(&dev->dev, &dev_attr_pkey);
}
+static void set_tx_csum(struct net_device *dev)
+{
+ struct ipoib_dev_priv *priv = netdev_priv(dev);
+
+ if (test_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags))
+ return;
+
+ if (!(priv->ca->flags & IB_DEVICE_IP_CSUM))
+ return;
+
+ dev->features |= NETIF_F_HW_CSUM;
+}
+
+static void set_rx_csum(struct net_device *dev)
+{
+ struct ipoib_dev_priv *priv = netdev_priv(dev);
+
+ if (!(priv->ca->flags & IB_DEVICE_IP_CSUM))
+ return;
+
+ set_bit(IPOIB_FLAG_RX_CSUM, &priv->flags);
+}
+
static struct net_device *ipoib_add_port(const char *format,
struct ib_device *hca, u8 port)
{
@@ -1123,6 +1146,9 @@ static struct net_device *ipoib_add_port
goto event_failed;
}
+ set_tx_csum(priv->dev);
+ set_rx_csum(priv->dev);
+
result = register_netdev(priv->dev);
if (result) {
printk(KERN_WARNING "%s: couldn't register ipoib port %d; error %d\n",
More information about the general
mailing list