[VOL-3419] Supporting new flow format.
Releasing version 1.3.0

Change-Id: Ie35c06c62797cc5966305a0a82492600a0dec871
diff --git a/internal/bbsim/devices/onu.go b/internal/bbsim/devices/onu.go
index 650dcfe..42c48bb 100644
--- a/internal/bbsim/devices/onu.go
+++ b/internal/bbsim/devices/onu.go
@@ -34,8 +34,8 @@
 	"github.com/opencord/bbsim/internal/common"
 	omcilib "github.com/opencord/bbsim/internal/common/omci"
 	omcisim "github.com/opencord/omci-sim"
-	"github.com/opencord/voltha-protos/v3/go/openolt"
-	"github.com/opencord/voltha-protos/v3/go/tech_profile"
+	"github.com/opencord/voltha-protos/v4/go/openolt"
+	"github.com/opencord/voltha-protos/v4/go/tech_profile"
 	log "github.com/sirupsen/logrus"
 )
 
@@ -44,7 +44,7 @@
 })
 
 type FlowKey struct {
-	ID        uint32
+	ID        uint64
 	Direction string
 }
 
@@ -67,7 +67,7 @@
 	// deprecated (gemPort is on a Service basis)
 	GemPortAdded bool
 	Flows        []FlowKey
-	FlowIds      []uint32 // keep track of the flows we currently have in the ONU
+	FlowIds      []uint64 // keep track of the flows we currently have in the ONU
 
 	OperState    *fsm.FSM
 	SerialNumber *openolt.SerialNumber
@@ -622,6 +622,8 @@
 		"ClassifierOPbits":  msg.Flow.Classifier.OPbits,
 		"ClassifierIVid":    msg.Flow.Classifier.IVid,
 		"ClassifierOVid":    msg.Flow.Classifier.OVid,
+		"ReplicateFlow":     msg.Flow.ReplicateFlow,
+		"PbitToGemport":     msg.Flow.PbitToGemport,
 	}).Debug("OLT receives FlowAdd for ONU")
 
 	if msg.Flow.UniId != 0 {
@@ -635,7 +637,18 @@
 	}
 
 	o.FlowIds = append(o.FlowIds, msg.Flow.FlowId)
-	o.addGemPortToService(uint32(msg.Flow.GemportId), msg.Flow.Classifier.EthType, msg.Flow.Classifier.OVid, msg.Flow.Classifier.IVid)
+
+	var gemPortId uint32
+	if msg.Flow.ReplicateFlow {
+		// This means that the OLT should replicate the flow for each PBIT, for BBSim it's enough to use the
+		// first available gemport (we only need to send one packet)
+		// NOTE different TP may create different mapping between PBits and GemPorts, this may require some changes
+		gemPortId = msg.Flow.PbitToGemport[0]
+	} else {
+		// if replicateFlows is false, then the flow is carrying the correct GemPortId
+		gemPortId = uint32(msg.Flow.GemportId)
+	}
+	o.addGemPortToService(gemPortId, msg.Flow.Classifier.EthType, msg.Flow.Classifier.OVid, msg.Flow.Classifier.IVid)
 
 	if msg.Flow.Classifier.EthType == uint32(layers.EthernetTypeEAPOL) && msg.Flow.Classifier.OVid == 4091 {
 		// NOTE storing the PortNO, it's needed when sending PacketIndications
@@ -822,7 +835,7 @@
 		AccessIntfId:  int32(o.PonPortID),
 		OnuId:         int32(o.ID),
 		UniId:         int32(0), // NOTE do not hardcode this, we need to support multiple UNIs
-		FlowId:        uint32(o.ID),
+		FlowId:        uint64(o.ID),
 		FlowType:      "downstream",
 		AllocId:       int32(0),
 		NetworkIntfId: int32(0),
@@ -870,7 +883,7 @@
 		AccessIntfId:  int32(o.PonPortID),
 		OnuId:         int32(o.ID),
 		UniId:         int32(0), // FIXME do not hardcode this
-		FlowId:        uint32(o.ID),
+		FlowId:        uint64(o.ID),
 		FlowType:      "downstream",
 		AllocId:       int32(0),
 		NetworkIntfId: int32(0),