[ofa-general] [PATCH 1/1] sdp: Limit skb frag size to 64K-1

Amir Vadai amirv at mellanox.co.il
Sun Oct 26 03:27:23 PDT 2008


When 64K pages are in use, the skb_frag size can become larger
than the skb_frag can address. An skb_frag's max size is 64K-1.
This patch defines SDP_MAX_PAYLOAD as 64K - SDP_HEADER_SIZE.
The patch changes sdp_post_recv() and sdp_sendmsg() to use the smaller of
PAGE_SIZE or SDP_MAX_PAYLOAD as it segment size.

This fix the bug here:
https://bugs.openfabrics.org/show_bug.cgi?id=1300

Signed-off-by: David Wilder <dwilder at us.ibm.com>
Signed-off-by: Amir Vadai <amirv at mellanox.co.il>
---
 drivers/infiniband/ulp/sdp/sdp.h       |    1 +
 drivers/infiniband/ulp/sdp/sdp_bcopy.c |    8 ++++----
 drivers/infiniband/ulp/sdp/sdp_main.c  |    4 ++++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/ulp/sdp/sdp.h b/drivers/infiniband/ulp/sdp/sdp.h
index 13cc42d..8638422 100644
--- a/drivers/infiniband/ulp/sdp/sdp.h
+++ b/drivers/infiniband/ulp/sdp/sdp.h
@@ -82,6 +82,7 @@ extern int sdp_data_debug_level;
 #define SDP_MAX_SEND_SKB_FRAGS (PAGE_SIZE > 0x8000 ? 1 : 0x8000 / PAGE_SIZE)
 #define SDP_HEAD_SIZE (PAGE_SIZE / 2 + sizeof(struct sdp_bsdh))
 #define SDP_NUM_WC 4
+#define SDP_MAX_PAYLOAD ((1 << 16) - SDP_HEAD_SIZE)
 
 #define SDP_MIN_ZCOPY_THRESH    1024
 #define SDP_MAX_ZCOPY_THRESH 1048576
diff --git a/drivers/infiniband/ulp/sdp/sdp_bcopy.c b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
index 20f6a33..4677df0 100644
--- a/drivers/infiniband/ulp/sdp/sdp_bcopy.c
+++ b/drivers/infiniband/ulp/sdp/sdp_bcopy.c
@@ -322,11 +322,11 @@ static void sdp_post_recv(struct sdp_sock *ssk)
 		frag = &skb_shinfo(skb)->frags[i];
 		frag->page                = page;
 		frag->page_offset         = 0;
-		frag->size                = PAGE_SIZE;
+		frag->size                =  min(PAGE_SIZE, SDP_MAX_PAYLOAD);
 		++skb_shinfo(skb)->nr_frags;
-		skb->len += PAGE_SIZE;
-		skb->data_len += PAGE_SIZE;
-		skb->truesize += PAGE_SIZE;
+		skb->len += frag->size;
+		skb->data_len += frag->size;
+		skb->truesize += frag->size;
 	}
 
         rx_req = ssk->rx_ring + (id & (SDP_RX_SIZE - 1));
diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c
index dfbe724..32833cd 100644
--- a/drivers/infiniband/ulp/sdp/sdp_main.c
+++ b/drivers/infiniband/ulp/sdp/sdp_main.c
@@ -1637,6 +1637,10 @@ int sdp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 
 		iov++;
 
+		/* Limmiting the size_goal is reqired when using 64K pages*/
+		if (size_goal > SDP_MAX_PAYLOAD)
+			size_goal = SDP_MAX_PAYLOAD;
+
 		bz = sdp_bz_setup(ssk, from, seglen, size_goal);
 
 		while (seglen > 0) {
-- 
1.5.5.GIT




More information about the general mailing list