[ofa-general] [PATCH 7/10] nes: process mss option

Glenn Grundstrom NetEffect glenn at lists.openfabrics.org
Thu Dec 20 12:33:18 PST 2007


Process a packet with mss option set or use default
value.

Signed-off-by: Glenn Grundstrom <ggrundstrom at neteffect.com>

---

diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 79889a4..1777769 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1220,11 +1220,12 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
 /**
  * process_options
  */
-static void process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 optionsize)
+static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 optionsize, u32 syn_packet)
 {
 	u32 tmp;
 	u32 offset = 0;
 	union all_known_options *all_options;
+	char got_mss_option = 0;
 
 	while (offset < optionsize) {
 		all_options = (union all_known_options *)(optionsloc + offset);
@@ -1236,9 +1237,17 @@ static void process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 opt
 				offset += 1;
 				continue;
 			case OPTION_NUMBER_MSS:
-				tmp = htons(all_options->as_mss.mss);
-				if (tmp < cm_node->tcp_cntxt.mss)
-					cm_node->tcp_cntxt.mss = tmp;
+				nes_debug(NES_DBG_CM, "%s: MSS Length: %d Offset: %d Size: %d\n",
+						__FUNCTION__,
+						all_options->as_mss.length, offset, optionsize);
+				got_mss_option = 1;
+				if (all_options->as_mss.length != 4) {
+					return 1;
+				} else {
+					tmp = htons(all_options->as_mss.mss);
+					if (tmp > 0 && tmp < cm_node->tcp_cntxt.mss)
+						cm_node->tcp_cntxt.mss = tmp;
+				}
 				break;
 			case OPTION_NUMBER_WINDOW_SCALE:
 				cm_node->tcp_cntxt.snd_wscale = all_options->as_windowscale.shiftcount;
@@ -1253,6 +1262,9 @@ static void process_options(struct nes_cm_node *cm_node, u8 *optionsloc, u32 opt
 		}
 		offset += all_options->as_base.length;
 	}
+	if ((!got_mss_option) && (syn_packet))
+		cm_node->tcp_cntxt.mss = NES_CM_DEFAULT_MSS;
+	return 0;
 }
 
 
@@ -1343,6 +1355,8 @@ int process_packet(struct nes_cm_node *cm_node, struct sk_buff *skb,
 		u8 *optionsloc = (u8 *)&tcph[1];
 		process_options(cm_node, optionsloc, optionsize);
 	}
+	else if (tcph->syn)
+		cm_node->tcp_cntxt.mss = NES_CM_DEFAULT_MSS;
 
 	cm_node->tcp_cntxt.snd_wnd = htons(tcph->window) <<
 			cm_node->tcp_cntxt.snd_wscale;
diff --git a/drivers/infiniband/hw/nes/nes_cm.h b/drivers/infiniband/hw/nes/nes_cm.h
index cd8e003..c511242 100644
--- a/drivers/infiniband/hw/nes/nes_cm.h
+++ b/drivers/infiniband/hw/nes/nes_cm.h
@@ -152,6 +152,8 @@ struct nes_timer_entry {
 #define NES_CM_DEFAULT_FREE_PKTS      0x000A
 #define NES_CM_FREE_PKT_LO_WATERMARK  2
 
+#define NES_CM_DEFAULT_MSS   536
+
 #define NES_CM_DEF_SEQ       0x159bf75f
 #define NES_CM_DEF_LOCAL_ID  0x3b47
 



More information about the general mailing list