Tests for L2 load balancing feature.

Change-Id: Ic8fcd217c6ae383fa7097bc1288c0db9b2190e63
diff --git a/accton/accton_util.py b/accton/accton_util.py
index ef13c43..78d183e 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -160,6 +160,9 @@
 def encode_l2_unfiltered_group_id(id):
     return id + (11 << OFDPA_GROUP_TYPE_SHIFT)
 
+def encode_l2_loadbal_group_id(id):
+    return id + (12 << OFDPA_GROUP_TYPE_SHIFT)
+
 def encode_l2_overlay_group_id(tunnel_id, subtype, index):
     tunnel_id=tunnel_id&0xffff #16 bits
     subtype = subtype&3        #2 bits
@@ -306,6 +309,20 @@
     ctrl.message_send(request)
     return request
 
+def add_l2_flood_group_with_gids(ctrl, gids, vlanid, id):
+    buckets=[]
+    for gid in gids:
+        action=[ofp.action.group(gid)]
+        buckets.append(ofp.bucket(actions=action))
+
+    group_id =encode_l2_flood_group_id(vlanid, id)
+    request = ofp.message.group_add(group_type=ofp.OFPGT_ALL,
+                                    group_id=group_id,
+                                    buckets=buckets
+                                   )
+    ctrl.message_send(request)
+    return request
+
 def mod_l2_flood_group(ctrl, ports, vlanid, id):
     buckets=[]
     for of_port in ports:
@@ -396,6 +413,37 @@
     ctrl.message_send(request)
     return request
 
+
+def add_l2_loadbal_group(ctrl, id, l2_unfil_intf_groups, send_barrier=False):
+    buckets=[]
+    for group in l2_unfil_intf_groups:
+        buckets.append(ofp.bucket(actions=[ofp.action.group(group)]))
+
+    group_id=encode_l2_loadbal_group_id(id)
+    request = ofp.message.group_add(group_type=ofp.OFPGT_SELECT,
+                                   group_id=group_id,
+                                   buckets=buckets
+                                   )
+    ctrl.message_send(request)
+    if send_barrier:
+        do_barrier(ctrl)
+
+    return group_id, request
+
+def mod_l2_loadbal_group(ctrl, id, l2_unfil_intf_groups, send_barrier=False):
+    buckets=[]
+    for group in l2_unfil_intf_groups:
+        buckets.append(ofp.bucket(actions=[ofp.action.group(group)]))
+
+    group_id =encode_l2_loadbal_group_id(id)
+    request = ofp.message.group_modify(group_type=ofp.OFPGT_SELECT,
+                                    group_id=group_id,
+                                    buckets=buckets
+                                   )
+    ctrl.message_send(request)
+    return request
+
+
 def add_l3_ecmp_group(ctrl, id, l3_ucast_groups, send_barrier=False):
     buckets=[]
     for group in l3_ucast_groups:
@@ -2147,3 +2195,4 @@
         print "hard_timeout", obj.hard_timeout
         #obj.actions
         print "packet count: %lx"%obj.packet_count
+