1. FTTB fixes
2. Delete subscriber with payload
3. Correct ServiceName field in programmed-subscribers response

Change-Id: I54fd24ff08e5c10efdbd0c43623bf699d890bdd8
diff --git a/internal/pkg/application/service.go b/internal/pkg/application/service.go
index e6e81c3..a2e1d54 100644
--- a/internal/pkg/application/service.go
+++ b/internal/pkg/application/service.go
@@ -600,6 +600,9 @@
 		| Byte8    | Byte7    | Byte6 | Byte5  | Byte4  | Byte3   | Byte2  | Byte1 |
 		| reserved | reserved | TpID  | TpID   | uinID  | uniID   | uniID  | uniID | */
 		metadata := uint64(vs.CVlan)<<48 + uint64(vs.TechProfileID)<<32 + uint64(outport)
+		if vs.ServiceType == FttbSubscriberTraffic {
+			metadata = uint64(of.VlanAny)<<48 + uint64(vs.TechProfileID)<<32 + uint64(outport)
+		}
 		subflow1.SetWriteMetadata(metadata)
 
 		/* TableMetaData 8 Byte(uint64) Voltha usage:  (Considering MSB bit as 63rd bit and LSB bit as 0th bit)
@@ -613,8 +616,10 @@
 		| 0000     |    00     |    0     |  0  | 00000000 | 00000000 |  0000   0000     |  00000000 | 00000000 | 00000000 | 00000000|
 		| reserved | svlanTpID |  Buff us |  AT | schedID  | schedID  | onteth  vlanCtrl |   ctag    |  ctag    |  ctag    | ctag    |  */
 
-		metadata = uint64(l2ProtoValue)<<58 | uint64(allowTransparent)<<56 | uint64(vs.SchedID)<<40 | uint64(vs.ONTEtherTypeClassification)<<36 | uint64(vs.VlanControl)<<32 | uint64(vs.CVlan)
-		subflow1.SetTableMetadata(metadata)
+		if vs.ServiceType != FttbSubscriberTraffic {
+			metadata = uint64(l2ProtoValue)<<58 | uint64(allowTransparent)<<56 | uint64(vs.SchedID)<<40 | uint64(vs.ONTEtherTypeClassification)<<36 | uint64(vs.VlanControl)<<32 | uint64(vs.CVlan)
+			subflow1.SetTableMetadata(metadata)
+		}
 		// TODO - We are using cookie as key and must come up with better cookie
 		// allocation algorithm
 		/**
@@ -669,6 +674,9 @@
 
 		// refer Table-0 flow generation for byte information
 		metadata := uint64(vs.CVlan)<<48 + uint64(vs.TechProfileID)<<32 + uint64(outport)
+		if vs.ServiceType == FttbSubscriberTraffic {
+			metadata = uint64(of.VlanAny)<<48 + uint64(vs.TechProfileID)<<32 + uint64(outport)
+		}
 		subflow2.SetWriteMetadata(metadata)
 
 		// Table-1 and inport is NNI: It is a DS flow for ONU, add uniport in metadata to make it unique
@@ -744,6 +752,9 @@
 		| reserved | reserved | TpID  | TpID   | uinID  | uniID   | uniID  | uniID | */
 		//metadata := uint64(vs.CVlan)<<48 + uint64(vs.TechProfileID)<<32 + uint64(outport)
 		metadata := uint64(vs.TechProfileID)<<32 + uint64(outport)
+		if vs.ServiceType == FttbSubscriberTraffic {
+			metadata = uint64(of.VlanAny)<<48 + uint64(vs.TechProfileID)<<32 + uint64(outport)
+		}
 		subflow1.SetWriteMetadata(metadata)
 
 		if vs.VlanControl == OLTCVlanOLTSVlan {
@@ -783,6 +794,9 @@
 
 		// refer Table-0 flow generation for byte information
 		metadata := uint64(vs.TechProfileID)<<32 + uint64(outport)
+		if vs.ServiceType == FttbSubscriberTraffic {
+			metadata = uint64(of.VlanAny)<<48 + uint64(vs.TechProfileID)<<32 + uint64(outport)
+		}
 		subflow2.SetWriteMetadata(metadata)
 
 		if vs.VlanControl == OLTCVlanOLTSVlan {
diff --git a/internal/pkg/application/vnets.go b/internal/pkg/application/vnets.go
index 1817b5d..c8e51d4 100644
--- a/internal/pkg/application/vnets.go
+++ b/internal/pkg/application/vnets.go
@@ -945,7 +945,7 @@
 	matchpbitsFunc := func(key, value interface{}) bool {
 		svc := value.(*VoltService)
 		for _, pbit := range svc.Pbits {
-			if uint8(pbit) == priority {
+			if uint8(pbit) == priority || uint8(pbit) == uint8(of.PbitMatchAll) {
 				logger.Infow(ctx, "Pbit match found with service",
 					log.Fields{"Pbit": priority, "serviceName": svc.Name})
 				pbitFound = true
@@ -1683,7 +1683,7 @@
 		vs := value.(*VoltService)
 		var writemetadata uint64
 		if vpv.VnetType == DpuMgmtTraffic {
-			writemetadata = uint64(vs.SVlan)<<48 + uint64(vs.TechProfileID)<<32
+			writemetadata = uint64(vs.TechProfileID)<<32 + uint64(vs.UsMeterID)
 		} else {
 			writemetadata = uint64(vs.TechProfileID) << 32
 		}
diff --git a/voltha-go-controller/nbi/subscriber.go b/voltha-go-controller/nbi/subscriber.go
index fcae52d..882bc61 100644
--- a/voltha-go-controller/nbi/subscriber.go
+++ b/voltha-go-controller/nbi/subscriber.go
@@ -244,6 +244,33 @@
 	// HTTP response with 202 accepted for service delete request
 	w.WriteHeader(http.StatusAccepted)
 
+	d := new(bytes.Buffer)
+	if _, err := d.ReadFrom(r.Body); err != nil {
+		logger.Warnw(ctx, "Error reading buffer", log.Fields{"Reason": err.Error()})
+		return
+	}
+
+	// Unmarshal the request into service configuration structure
+	req := &SubscriberDeviceInfo{}
+	if err := json.Unmarshal(d.Bytes(), req); err != nil {
+		logger.Warnw(ctx, "Unmarshal Failed", log.Fields{"Reason": err.Error()})
+		http.Error(w, err.Error(), http.StatusConflict)
+		return
+	}
+
+	for _, uniTagInfo := range req.UniTagList {
+		svcname := req.ID + "_"
+		svcname = svcname + req.NasPortID + "-"
+		svcname = svcname + strconv.Itoa(uniTagInfo.UniTagMatch) + "-"
+		svcname = svcname + strconv.Itoa(uniTagInfo.PonSTag) + "-"
+		svcname = svcname + strconv.Itoa(uniTagInfo.PonCTag) + "-"
+		svcname = svcname + strconv.Itoa(uniTagInfo.TechnologyProfileID)
+
+		if uniTagInfo.ServiceName == app.FttbSubscriberTraffic {
+			id = svcname
+		}
+	}
+
 	logger.Warnw(ctx, "northbound-del-service-req", log.Fields{"ServiceName": id})
 	app.GetApplication().DelServiceWithPrefix(cntx, id)
 }
diff --git a/voltha-go-controller/onos_nbi/models.go b/voltha-go-controller/onos_nbi/models.go
index dcfe220..cc4bed0 100644
--- a/voltha-go-controller/onos_nbi/models.go
+++ b/voltha-go-controller/onos_nbi/models.go
@@ -678,7 +678,7 @@
 				DownstreamBandwidthProfile:    vs.DsMeterProfile,
 				UpstreamOltBandwidthProfile:   vs.UsMeterProfile,
 				DownstreamOltBandwidthProfile: vs.DsMeterProfile,
-				ServiceName:                   vs.Name,
+				ServiceName:                   vs.ServiceType,
 				EnableMacLearning:             vs.MacLearning == app.Learn,
 				ConfiguredMacAddress:          vs.MacAddr.String(),
 				IsDhcpRequired:                vs.MacLearning == app.Learn,