Index: /branches/rel_apv_10_4_0_112_gail/usr/click/lib/libparser/commands.pm
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/click/lib/libparser/commands.pm	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/click/lib/libparser/commands.pm	(working copy)
@@ -53507,27 +53507,6 @@
         },
         {
                 obj_type => "ITEM",
-                name => "dequeuerepeat",
-                menu => "root_show_qos",
-                help_string => "show mbuf dequeue iterate count",
-                cmd_attribute => "CMD_ARRAYOS|CMD_NORMAL|CMD_GLOBAL|CMD_KERN_API",
-		user_level => "CLI_LEVEL_ENGINEER",
-                function_name => "get_dequeue_repeat",
-                function_args => [],
-        },
-        {
-                obj_type => "ITEM",
-                name => "getmaxpendmbuf",
-                menu => "root_show_qos",
-                help_string => "show max pend mbuf",
-                cmd_attribute => "CMD_ARRAYOS|CMD_NORMAL|CMD_GLOBAL|CMD_KERN_API",
-		user_level => "CLI_LEVEL_ENGINEER",
-                function_name => "get_max_pend_mbuf",
-                function_args => [],
-        },
-
-        {
-                obj_type => "ITEM",
                 name => "session",
                 menu => "root_no_qos",
                 cmd_attribute => "CMD_ARRAYOS|CMD_NORMAL|CMD_GLOBAL|CMD_KERN_API",
@@ -53660,39 +53639,6 @@
 			},
 		],
         },
-        {
-                obj_type => "ITEM",
-                name => "dequeuerepeat",
-                menu => "root_qos",
-                help_string => "set mbuf dequeue iterate count",
-                cmd_attribute => "CMD_ARRAYOS|CMD_NORMAL|CMD_GLOBAL|CMD_KERN_API|CMD_KAPI_LOCK",
-		user_level => "CLI_LEVEL_ENGINEER",
-                function_name => "set_dequeue_repeat",
-                function_args => [
-			{
-					type => "U32",
-					help_string => "set count (1 to 1024)",
-					optional => "NO",
-			},
-		],
-        },
-        {
-                obj_type => "ITEM",
-                name => "maxpendmbuf",
-                menu => "root_qos",
-                help_string => "set max pend mbuf",
-                cmd_attribute => "CMD_ARRAYOS|CMD_NORMAL|CMD_GLOBAL|CMD_KERN_API|CMD_KAPI_LOCK",
-		user_level => "CLI_LEVEL_ENGINEER",
-                function_name => "set_max_pend_mbuf",
-                function_args => [
-			{
-					type => "U32",
-					help_string => "set count (1 to 1024)",
-					optional => "NO",
-			},
-		],
-        },
-
 	{
 		obj_type => "ITEM",
 		name => "sub",
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_cbq.c
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_cbq.c	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_cbq.c	(working copy)
@@ -68,7 +68,6 @@
 #include <click/app/fastlog/fastlog.h>
 #include <click/app/qos/qos_dynamic.h>
 
-extern int max_pend_mbuf;
 
 #ifndef MORELOG
 #define MORELOG
@@ -590,14 +589,7 @@
             return NULL;
         }
 
-	if (max_pend_mbuf) {
-	    if (cbqp->cbq_qlen >= max_pend_mbuf)
-		m = rmc_dequeue_next(&cbqp->ifnp, op, 1);
-	    else
-		m = rmc_dequeue_next(&cbqp->ifnp, op, 0);
-	} else {
-		m = rmc_dequeue_next(&cbqp->ifnp, op, 0);
-	}
+	m = rmc_dequeue_next(&cbqp->ifnp, op);
             
 
 	if (m && op == ALTDQ_REMOVE) {
@@ -606,9 +598,6 @@
 
 		/* Update the class. */
 		rmc_update_class_util(&cbqp->ifnp);
-#ifdef MORELOG
-                fastlog_syslog(LOG_DEBUG, "cbq_dequeue : no of outstanding packets to be dequeued : %d\n", cbqp->cbq_qlen);
-#endif
 	}
 
 #ifdef MORELOG
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_rmclass.h
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_rmclass.h	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_rmclass.h	(working copy)
@@ -294,7 +294,7 @@
 			 void (*)(struct ifaltq *),
 			 int, int, u_int, int, u_int, int);
 extern int	rmc_queue_packet(struct rm_class *, mbuf_t *);
-extern mbuf_t	*rmc_dequeue_next(struct rm_ifdat *, int, int);
+extern mbuf_t	*rmc_dequeue_next(struct rm_ifdat *, int);
 extern void	rmc_update_class_util(struct rm_ifdat *);
 extern void	rmc_delay_action(struct rm_class *, struct rm_class *);
 extern void	rmc_dropall(struct rm_class *);
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_rmclass.c
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_rmclass.c	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/altq_rmclass.c	(working copy)
@@ -101,7 +101,7 @@
 static void	rmc_depth_compute(struct rm_class *);
 static void	rmc_depth_recompute(rm_class_t *);
 
-static mbuf_t	*_rmc_wrr_dequeue_next(struct rm_ifdat *, int, int);
+static mbuf_t	*_rmc_wrr_dequeue_next(struct rm_ifdat *, int);
 static mbuf_t	*_rmc_prr_dequeue_next(struct rm_ifdat *, int);
 
 static int	_rmc_addq(rm_class_t *, mbuf_t *);
@@ -1153,7 +1153,7 @@
 
 
 static mbuf_t *
-_rmc_wrr_dequeue_next(struct rm_ifdat *ifd, int op, int send)
+_rmc_wrr_dequeue_next(struct rm_ifdat *ifd, int op)
 {
 	struct rm_class	*cl = NULL, *first = NULL;
 	u_int		 deficit;
@@ -1209,15 +1209,9 @@
                     fastlog_syslog(LOG_DEBUG, "_rmc_wrr_dequeue_next : no active mbuf to process\n");
                     return NULL;
                 }
-#ifdef MORELOG
-                fastlog_syslog(LOG_DEBUG, "_rmc_wrr_dequeue_next : 1st class to process: %x\n", cl);
-#endif
 		ALTQ_ASSERT(cl != NULL);
 		do {
                         ++loop_ct;
-#ifdef MORELOG
-                        fastlog_syslog(LOG_DEBUG, "loop cl addr : %x ==> current loop count : %u ==> deficit : %u\n", cl, loop_ct, deficit);
-#endif
 			if ((deficit < 2) && (cl->bytes_alloc_ <= 0)) {
 				cl->bytes_alloc_ += cl->w_allotment_;
 			}
@@ -1231,8 +1225,8 @@
 				} else if (first == NULL && cl->borrow_ != NULL) {
                                         fastlog_syslog(LOG_DEBUG, "borrowing candidate : %x\n", cl);
 					first = cl; /* borrowing candidate */
-                                } else if ( (qlen(cl->q_) >= q_len_wait) || send) {
-                                        fastlog_syslog(LOG_DEBUG, "queue len for class : %x is %d and send : %d..sending it out\n", cl, qlen(cl->q_), send);
+                                } else if ( qlen(cl->q_) >= q_len_wait) {
+                                        fastlog_syslog(LOG_DEBUG, "current pending mbufs for class : %x is %d.....sending out\n", cl, qlen(cl->q_));
 					ifd->borrowed_[ifd->qi_] = NULL;
                                         goto _wrr_out;
                                 } else if (first == NULL && cl->borrow_ != NULL)
@@ -1463,14 +1457,14 @@
  */
 
 mbuf_t *
-rmc_dequeue_next(struct rm_ifdat *ifd, int mode, int send)
+rmc_dequeue_next(struct rm_ifdat *ifd, int mode)
 {
 	if (ifd->queued_ >= ifd->maxqueued_) {
                 fastlog_syslog(LOG_DEBUG, "classes are ovelimit not dequeuing. current size : %d.  max : %d\n", ifd->queued_, ifd->maxqueued_);
 		return (NULL);
         }
 	else if (ifd->wrr_) {
-		return (_rmc_wrr_dequeue_next(ifd, mode, send));
+		return (_rmc_wrr_dequeue_next(ifd, mode));
         }
 	else {
 		return (_rmc_prr_dequeue_next(ifd, mode));
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_classifier.c
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_classifier.c	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_classifier.c	(working copy)
@@ -273,6 +273,8 @@
 	fastlog_syslog(LOG_DEBUG, "filter creation failed : %s\n", f_name);
         return;
     }
+    ++current_dyn_q_count;
+
 }
 
 
@@ -1134,19 +1136,17 @@
 	bcopy(qos_filter, pfltr, sizeof(qos_filter_t));
 
 
-	pfltr->used = 1;
-	++n_filters;
-	mtx_unlock (&qos_filter_lock);
-
 	ret = qos_filter_add_table(qs, pfltr);
 	if(QOS_FAILURE == ret) {
 	    bzero(pfltr, sizeof(qos_filter_t));
 	    qos_filter_share.fltr_g_stats.count_add_table_fail++;
-	    pfltr->used = 0;
-	    --n_filters;
+	    mtx_unlock (&qos_filter_lock);
 	    fastlog_syslog(LOG_DEBUG, "ERROR: failed to add the filter to the table\n");
 	    goto ADD_FLTR_ERROR;
 	}
+	pfltr->used = 1;
+	++n_filters;
+	mtx_unlock (&qos_filter_lock);
 
 	return QOS_SUCCESS;
 
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_dynamic.h
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_dynamic.h	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_dynamic.h	(working copy)
@@ -25,14 +25,12 @@
 
 extern struct dyn_session_qos_conf_head dyn_session_qos_conf_head;
 extern int qos_session_status;
-extern int dequeue_repeat;
 extern uint32_t repeat_segment_num;
 extern uint32_t q_del_step_size;
 extern struct mtx qos_session_lock;
 extern struct mtx qos_filter_lock;
 
 extern uint32_t max_dyn_queue;
-extern int max_pend_mbuf;
 
 //CBQ
 extern int class_insert_pos;
@@ -73,18 +71,9 @@
 int qos_session_init (void);
 int set_qos_max_session_count (void *pcb, uint32_t count);
 int get_qos_max_session_count (void *pcb);
-
 int set_loop_class_count (void *pcb, uint32_t count);
 int get_loop_class_count (void *pcb);
-
 int set_class_insert_pos (void *pcb, uint32_t count);
 int get_class_insert_pos (void *pcb);
-
 int set_q_len_wait (void *pcb, uint32_t count);
 int get_q_len_wait (void *pcb);
-
-int set_dequeue_repeat (void *pcb, uint32_t count);
-int get_dequeue_repeat (void *pcb);
-
-int set_max_pend_mbuf (void *pcb, uint32_t count);
-int get_max_pend_mbuf (void *pcb);
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_dynamic.c
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_dynamic.c	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_dynamic.c	(working copy)
@@ -36,9 +36,7 @@
 struct mtx qos_filter_lock;
 
 int qos_session_status = SESSION_DISABLE;
-int dequeue_repeat = 2;
 
-int max_pend_mbuf = 0;
 
 uint32_t repeat_segment_num = 50;
 uint32_t q_del_step_size = 1;
@@ -46,7 +44,7 @@
 
 int class_insert_pos = 205;
 int loop_class_count = 200;
-int q_len_wait = 512;
+int q_len_wait = 1024;
 
 struct dyn_session_qos_conf_head dyn_session_qos_conf_head = STAILQ_HEAD_INITIALIZER(dyn_session_qos_conf_head);
 
@@ -493,23 +491,3 @@
     app_printf(pcb, "q_len_wait : %u\n", q_len_wait);
     return QOS_SUCCESS;
 }
-
-int set_dequeue_repeat (void *pcb, uint32_t count) {
-    dequeue_repeat = count;
-    return QOS_SUCCESS;
-}
-
-int get_dequeue_repeat (void *pcb) {
-    app_printf(pcb, "count : %u\n", dequeue_repeat);
-    return QOS_SUCCESS;
-}
-
-int set_max_pend_mbuf (void *pcb, uint32_t count) {
-    max_pend_mbuf = count;
-    return QOS_SUCCESS;
-}
-
-int get_max_pend_mbuf (void *pcb) {
-    app_printf(pcb, "count : %d\n", max_pend_mbuf);
-    return QOS_SUCCESS;
-}
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_scheduler.c
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_scheduler.c	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_scheduler.c	(working copy)
@@ -66,7 +66,6 @@
 extern int qos_session_cleanup;
 extern struct mtx qos_session_lock;
 extern unsigned int current_dyn_q_count;
-extern int dequeue_repeat;
 
 /* QoS qid generator */
 static uint32_t qos_index = 0;
@@ -256,34 +255,25 @@
 
 void qos_start(struct ifnet *ifp)
 {
-	struct mbuf *m_head;
-        char temp;
-        int i;
-
-	while (!IFQ_IS_EMPTY(&ifp->if_rcv)) {
-		if (ifp->if_rcv.ifq_head != NULL) {
-			IF_DEQUEUE(&ifp->if_rcv, m_head);
-		        if (m_head == NULL) { break; }
-		            (*ifp->if_input)(ifp, m_head);
-		} else {
-		        IF_LOCK(&ifp->if_rcv);
-                        for (i = 1; i <= dequeue_repeat; i++) {
-			    m_head = tbr_dequeue_ptr(&ifp->if_rcv, ALTDQ_REMOVE);
-		            if (m_head == NULL) { 
-                                break; 
-                            } else {
-		                (*ifp->if_input)(ifp, m_head);
-                            }
-                        }
-			IF_UNLOCK(&ifp->if_rcv);
-                        if (m_head == NULL)
-                            break;
-		}
-	}
+        struct mbuf *m_head;
+
+        while (!IFQ_IS_EMPTY(&ifp->if_rcv)) {
+                if (ifp->if_rcv.ifq_head != NULL) {
+                        IF_DEQUEUE(&ifp->if_rcv, m_head);
+                } else {
+                        IF_LOCK(&ifp->if_rcv);
+                        m_head = tbr_dequeue_ptr(&ifp->if_rcv, ALTDQ_REMOVE);
+                        IF_UNLOCK(&ifp->if_rcv);
+                }
+                if (m_head == NULL) { break; }
 
-	return;
+                (*ifp->if_input)(ifp, m_head);
+        }
+
+        return;
 }
 
+
 /*************************************************************************
  * QoS CLI kernelapi implementation
  *************************************************************************/
@@ -860,9 +850,6 @@
 
         mtx_lock (&qos_session_lock);
     	STAILQ_INSERT_HEAD(&qos_queue_root_head, pQoSQRootSave, list_entry);
-        if (qos_session_status) {
-	    ++current_dyn_q_count;
-        }
         mtx_unlock (&qos_session_lock);
 	splx(s);
 	return(QOS_SUCCESS);
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_subr.c
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_subr.c	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/app/qos/qos_subr.c	(working copy)
@@ -645,7 +645,8 @@
 	qs = &qos_filter_share;
 
 	isfound = 0;
-	STAILQ_FOREACH(pQoSIfConf, &qos_interface_conf_head, list_entry) {
+	if (!current_dyn_q_count) {
+	    STAILQ_FOREACH(pQoSIfConf, &qos_interface_conf_head, list_entry) {
 		/*
 		 * QoS interface
 		 */
@@ -731,12 +732,9 @@
 				}
 			}
 		}
+	    }
 	}
         
-	if(!isfound) {
-		return QOS_USERLAND_FAILURE;
-	}
-
 	/*
 	 * Keep stat.
 	 * 1. qs->fltr_g_stats.count_interface_with_filter
@@ -921,13 +919,19 @@
     /* QoS session command format */
     char qos_session_conf_cmd[] = "qos session xxxxxx xxx.xxx.xxx.xxx xxxxx xxx.xxx.xxx.xxx xxxxx xxxxxxx xxx";
     char qos_session_status_cmd[] = "qos sessionxxx";
-    char qos_session_tuple_count_cmd[] = "qos sessionpacketcount xxxx";
+    char qos_session_tuple_count_cmd[] = "qos sespacketcnt xxxx";
     char qos_session_q_del_step_count_cmd[] = "qos sessionqdelstepcount xxxx";
+    char qos_session_q_len_wait_cmd[] = "qos qlenwait xxxx";
+    char qos_session_q_class_count_cmd[] = "qos qosclasscnt xxxx";
+    char qos_session_q_class_insert_pos_cmd[] = "qos qosclspos xxxx";
 
     len = (sizeof (qos_session_conf_cmd) + QOS_SNAME_MAX + 1) * MAX_QOS_SESSION_CONFIG;
     len += sizeof (qos_session_status_cmd) + 1;
     len += sizeof (qos_session_tuple_count_cmd) + 1;
     len += sizeof (qos_session_q_del_step_count_cmd) + 1;
+    len += sizeof (qos_session_q_len_wait_cmd) + 1;
+    len += sizeof (qos_session_q_class_count_cmd) + 1;
+    len += sizeof (qos_session_q_class_insert_pos_cmd) + 1;
 
     MALLOC(buffer, char *, len, M_TEMP, M_NOWAIT);
 
@@ -944,8 +948,11 @@
     else
         cur += sprintf (cur, "qos sessionoff\n");
 
-    cur += sprintf (cur, "qos sessionpacketcount %u\n", repeat_segment_num);
+    cur += sprintf (cur, "qos sespacketcnt %u\n", repeat_segment_num);
     cur += sprintf (cur, "qos sessionqdelstepcount %u\n", q_del_step_size);
+    cur += sprintf (cur, "qos qlenwait %d\n", q_len_wait);
+    cur += sprintf (cur, "qos qosclasscnt %d\n", loop_class_count);
+    cur += sprintf (cur, "qos qosclspos %d\n", class_insert_pos);
 
     STAILQ_FOREACH(dyn_qos_conf_run, &dyn_session_qos_conf_head, list_entry) {
         cur += sprintf (cur, "qos session \"%s\" %s %u.%u.%u.%u %u %u.%u.%u.%u %u %s %s\n",
Index: /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/netinet/click_rule.c
===================================================================
--- /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/netinet/click_rule.c	(revision 38295)
+++ /branches/rel_apv_10_4_0_112_gail/usr/src/sys/click/netinet/click_rule.c	(working copy)
@@ -203,7 +203,12 @@
 rule_init(void)
 {
 	clickrule_node_zone = uma_zcreate("Click rule node", sizeof(struct clickrule_node), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
+#if 0
 	uma_zone_set_max(clickrule_node_zone, (ptoa(physmem)/4)/sizeof(struct clickrule_node));
+#endif
+#if 1
+	uma_zone_set_max(clickrule_node_zone, (ptoa(physmem)/2)/sizeof(struct clickrule_node));
+#endif
 	return clickrule_node_notfound();
 }
 
