Skip to content

Commit

Permalink
rest config interface support for configuring slice info
Browse files Browse the repository at this point in the history
  • Loading branch information
badhri85 authored and badhri85 committed Sep 29, 2021
1 parent 25587c7 commit d661009
Show file tree
Hide file tree
Showing 9 changed files with 277 additions and 13 deletions.
62 changes: 53 additions & 9 deletions pfcpiface/bess.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@ func (b *bess) sendEndMarkers(endMarkerList *[][]byte) error {
return nil
}

func (b *bess) addSliceInfo(sliceInfo *SliceInfo) error {
var sliceMeterConfig SliceMeterConfig
sliceMeterConfig.N6RateBps = sliceInfo.uplinkMbr
sliceMeterConfig.N3RateBps = sliceInfo.downlinkMbr
sliceMeterConfig.N6BurstBytes = sliceInfo.ulBurstBytes
sliceMeterConfig.N3BurstBytes = sliceInfo.dlBurstBytes

ctx, cancel := context.WithTimeout(context.Background(), Timeout)
defer cancel()

done := make(chan bool)

b.addSliceMeter(ctx, done, sliceMeterConfig)

rc := b.GRPCJoin(1, Timeout, done)

if !rc {
log.Errorln("Unable to make GRPC calls")
}

return nil
}

func (b *bess) sendMsgToUPF(method upfMsgType, pdrs []pdr, fars []far, qers []qer) uint8 {
// create context
var cause uint8 = ie.CauseRequestAccepted
Expand Down Expand Up @@ -409,10 +432,14 @@ func (b *bess) setUpfInfo(u *upf, conf *Conf) {
}

if conf.SliceMeterConfig.N6RateBps > 0 || conf.SliceMeterConfig.N3RateBps > 0 {

ctx, cancel := context.WithTimeout(context.Background(), Timeout)
defer cancel()

done := make(chan bool)

b.addSliceMeter(ctx, done, conf.SliceMeterConfig)

rc := b.GRPCJoin(1, Timeout, done)
if !rc {
log.Errorln("Unable to make GRPC calls")
Expand Down Expand Up @@ -562,20 +589,20 @@ func (b *bess) sim(u *upf, method string) {
qerID: n6,
fseID: uint64(n3TEID + i),
qfi: 9,
ulGbr: 50000,
ulMbr: 90000,
dlGbr: 60000,
dlMbr: 80000,
ulGbr: 1,
ulMbr: 100000,
dlGbr: 1,
dlMbr: 400000,
}

qerN9 := qer{
qerID: n9,
fseID: uint64(n3TEID + i),
qfi: 8,
ulGbr: 50000,
ulMbr: 60000,
dlGbr: 70000,
dlMbr: 90000,
qfi: 9,
ulGbr: 1,
ulMbr: 100000,
dlGbr: 1,
dlMbr: 400000,
}

qers := []qer{qerN6, qerN9}
Expand Down Expand Up @@ -757,6 +784,11 @@ func (b *bess) addQER(ctx context.Context, done chan<- bool, qer qer) {
gate = qerGateUnmeter
}

log.Println("qerid ", qer.qerID)
log.Println("srcIface ", srcIface)
log.Println("fseid ", qer.fseID)
log.Println("cir ", cir)
log.Println("pir ", pir)
q := &pb.QosCommandAddArg{
Gate: gate,
Cir: cir, /* committed info rate */
Expand Down Expand Up @@ -797,6 +829,11 @@ func (b *bess) addQER(ctx context.Context, done chan<- bool, qer qer) {
gate = qerGateUnmeter
}

log.Println("qerid ", qer.qerID)
log.Println("srcIface ", srcIface)
log.Println("fseid ", qer.fseID)
log.Println("cir ", cir)
log.Println("pir ", pir)
q = &pb.QosCommandAddArg{
Gate: gate,
Cir: cir, /* committed info rate */
Expand Down Expand Up @@ -1064,6 +1101,7 @@ func (b *bess) addSliceMeter(ctx context.Context, done chan<- bool, meterConfig
} else {
gate = sliceMeterGateUnmeter
}

if meterConfig.N6BurstBytes != 0 {
cbs = 1 // Mark all traffic as yellow
pbs = meterConfig.N6BurstBytes
Expand All @@ -1073,6 +1111,7 @@ func (b *bess) addSliceMeter(ctx context.Context, done chan<- bool, meterConfig
pbs = DefaultBurstSize
ebs = 0 // Unused
}

q := &pb.QosCommandAddArg{
Gate: gate,
Cir: cir, /* committed info rate */
Expand All @@ -1086,11 +1125,13 @@ func (b *bess) addSliceMeter(ctx context.Context, done chan<- bool, meterConfig
intEnc(uint64(0)), /* tunnel_out_type */
},
}

any, err = anypb.New(q)
if err != nil {
log.Errorln("Error marshalling the rule", q, err)
return
}

b.processSliceMeter(ctx, any, upfMsgTypeAdd)

// Downlink N3 slice meter config
Expand All @@ -1101,6 +1142,7 @@ func (b *bess) addSliceMeter(ctx context.Context, done chan<- bool, meterConfig
} else {
gate = sliceMeterGateUnmeter
}

if meterConfig.N3BurstBytes != 0 {
cbs = 1 // Mark all traffic as yellow
pbs = meterConfig.N3BurstBytes
Expand All @@ -1124,11 +1166,13 @@ func (b *bess) addSliceMeter(ctx context.Context, done chan<- bool, meterConfig
intEnc(uint64(1)), /* tunnel_out_type */
},
}

any, err = anypb.New(q)
if err != nil {
log.Errorln("Error marshalling the rule", q, err)
return
}

b.processSliceMeter(ctx, any, upfMsgTypeAdd)
done <- true
}()
Expand Down
2 changes: 2 additions & 0 deletions pfcpiface/fastpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type fastPath interface {
setUpfInfo(u *upf, conf *Conf)
/* set udp and pfcp conn parameters in interface */
setInfo(udpConn *net.UDPConn, udpAddr net.Addr, pconn *PFCPConn)
/* set up slice info */
addSliceInfo(sliceInfo *SliceInfo) error
/* simulator mode setup */
sim(u *upf, method string)
/* write endMarker to fastpath */
Expand Down
5 changes: 5 additions & 0 deletions pfcpiface/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
Expand All @@ -90,8 +91,10 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
Expand Down Expand Up @@ -149,6 +152,7 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -256,6 +260,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
9 changes: 9 additions & 0 deletions pfcpiface/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type Conf struct {
SimInfo SimModeInfo `json:"sim"`
ConnTimeout uint32 `json:"conn_timeout"`
ReadTimeout uint32 `json:"read_timeout"`
ConfigPort string `json:"config_port"`
EnableConfigPort bool `json:"enable_config_port"`
EnableNotifyBess bool `json:"enable_notify_bess"`
EnableEndMarker bool `json:"enable_end_marker"`
NotifySockAddr string `json:"notify_sockaddr"`
Expand Down Expand Up @@ -233,6 +235,13 @@ func main() {
conf.CPIface.DestIP,
)

/*if conf.EnableConfigPort {
log.Infoln("start config server")
go ConfigServerStart(conf, upf)
}*/

setupConfigHandler(upf)
setupProm(upf)
log.Fatal(http.ListenAndServe(*httpAddr, nil))
upf.exit()
Expand Down
5 changes: 5 additions & 0 deletions pfcpiface/p4rt.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ type p4rtc struct {
endMarkerChan chan []byte
}

func (p *p4rtc) addSliceInfo(sliceInfo *SliceInfo) error {
log.Errorln("Slice Info not supported in P4")
return nil
}

func (p *p4rtc) summaryLatencyJitter(uc *upfCollector, ch chan<- prometheus.Metric) {
}

Expand Down
6 changes: 3 additions & 3 deletions pfcpiface/p4rtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1138,18 +1138,18 @@ func LoadDeviceConfig(deviceConfigPath string) (P4DeviceConfig, error) {

deviceConfig, err := os.Open(deviceConfigPath)
if err != nil {
return nil, fmt.Errorf("open %s: %v", deviceConfigPath, err)
return nil, fmt.Errorf("open %s: %w", deviceConfigPath, err)
}
defer deviceConfig.Close()

bmv2Info, err := deviceConfig.Stat()
if err != nil {
return nil, fmt.Errorf("stat %s: %v", deviceConfigPath, err)
return nil, fmt.Errorf("stat %s: %w", deviceConfigPath, err)
}

bin := make([]byte, int(bmv2Info.Size()))
if b, err := deviceConfig.Read(bin); err != nil {
return nil, fmt.Errorf("read %s: %v", deviceConfigPath, err)
return nil, fmt.Errorf("read %s: %w", deviceConfigPath, err)
} else if b != int(bmv2Info.Size()) {
return nil, errors.New("bmv2 bin copy failed")
}
Expand Down
3 changes: 2 additions & 1 deletion pfcpiface/parse-pdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package main

import (
"errors"
"fmt"
"net"
"strings"
Expand Down Expand Up @@ -282,7 +283,7 @@ func (p *pdr) parsePDR(ie1 *ie.IE, seid uint64, appPFDs map[string]appPFD, upf *
}

err = p.parsePDI(pdi, appPFDs, upf)
if err != nil && err != errBadFilterDesc {
if err != nil && !errors.Is(err, errBadFilterDesc) {
return err
}

Expand Down
65 changes: 65 additions & 0 deletions pfcpiface/upf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package main

import (
"errors"
"net"
"time"

Expand All @@ -18,6 +19,39 @@ type QosConfigVal struct {
schedulePriority uint32
}

type SliceInfo struct {
name string
uplinkMbr uint64
downlinkMbr uint64
ulBurstBytes uint64
dlBurstBytes uint64
ueResList []UeResource
}

func (s *SliceInfo) CopySlice(sliceInfo *SliceInfo) {
s.name = sliceInfo.name
s.uplinkMbr = sliceInfo.uplinkMbr
s.ulBurstBytes = sliceInfo.ulBurstBytes
s.downlinkMbr = sliceInfo.downlinkMbr
s.dlBurstBytes = sliceInfo.dlBurstBytes
s.ueResList = nil

for _, ueRes := range sliceInfo.ueResList {
s.ueResList = make([]UeResource, 0)

var ueResource UeResource

ueResource.dnn = ueRes.dnn
ueResource.name = ueRes.name
s.ueResList = append(s.ueResList, ueResource)
}
}

type UeResource struct {
name string
dnn string
}

type upf struct {
enableUeIPAlloc bool
enableEndMarker bool
Expand All @@ -38,6 +72,7 @@ type upf struct {
recoveryTime time.Time
dnn string
reportNotifyChan chan uint64
sliceInfoList []SliceInfo
}

// to be replaced with go-pfcp structs
Expand Down Expand Up @@ -76,6 +111,36 @@ func (u *upf) exit() {
u.intf.exit()
}

func (u *upf) addSliceInfo(sliceInfo *SliceInfo) error {
if sliceInfo == nil {
return errors.New("invalid slice")
}

found := false

log.Infoln("add sliceInfo for slice ", sliceInfo.name)

for idx, slice := range u.sliceInfoList {
if slice.name == sliceInfo.name {
u.sliceInfoList[idx].CopySlice(sliceInfo)

found = true

break
}
}

if !found {

var slice SliceInfo
slice.CopySlice(sliceInfo)

u.sliceInfoList = append(u.sliceInfoList, slice)
}

return u.intf.addSliceInfo(sliceInfo)
}

func (u *upf) sim(method string) {
u.intf.sim(u, method)
}
Expand Down

0 comments on commit d661009

Please sign in to comment.