Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make p4info and device_config paths configurable #485

Merged
merged 4 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion conf/upf.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@
"p4rtciface": {
"access_ip": "172.17.0.1/32",
"p4rtc_server": "onos",
"p4rtc_port": "51001"
"p4rtc_port": "51001",
"" : "p4info: /bin/p4info.txt",
"" : "device_config: /bin/bmv2.json"
}
}
32 changes: 29 additions & 3 deletions pfcpiface/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ import (
"os"
)

const (
// Default values
maxReqRetriesDefault = 5
respTimeoutDefault = 2 * time.Second
hbIntervalDefault = 5 * time.Second
readTimeoutDefault = 15 * time.Second
p4InfoPathDefault = "/bin/p4info.txt"
deviceConfigPathDefault = "/bin/bmv2.json"
)

// Conf : Json conf struct.
type Conf struct {
Mode string `json:"mode"`
Expand Down Expand Up @@ -86,9 +96,11 @@ type IfaceType struct {

// P4rtcInfo : P4 runtime interface settings.
type P4rtcInfo struct {
AccessIP string `json:"access_ip"`
P4rtcServer string `json:"p4rtc_server"`
P4rtcPort string `json:"p4rtc_port"`
P4Info string `json:"p4info"`
DeviceConfig string `json:"device_config"`
AccessIP string `json:"access_ip"`
P4rtcServer string `json:"p4rtc_server"`
P4rtcPort string `json:"p4rtc_port"`
}

// validateConf checks that the given config reaches a baseline of correctness.
Expand Down Expand Up @@ -190,6 +202,20 @@ func LoadConfigFile(filepath string) (Conf, error) {
conf.MaxReqRetries = maxReqRetriesDefault
}

if conf.EnableHBTimer {
if conf.HeartBeatInterval == "" {
conf.HeartBeatInterval = hbIntervalDefault.String()
}
}

if conf.P4rtcIface.P4Info == "" {
conf.P4rtcIface.P4Info = p4InfoPathDefault
}

if conf.P4rtcIface.DeviceConfig == "" {
conf.P4rtcIface.DeviceConfig = deviceConfigPathDefault
}

// Perform basic validation.
err = validateConf(conf)
if err != nil {
Expand Down
57 changes: 26 additions & 31 deletions pfcpiface/up4.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,29 @@ import (
"github.com/wmnsk/go-pfcp/ie"
)

const (
// FIXME: this is hardcoded currently, but should be passed as configuration/cmd line arg
p4InfoPath = "/bin/p4info.txt"
deviceConfigPath = "/bin/bmv2.json"

// DefaultQFI is set if no QER is sent by a control plane in PFCP messages.
// QFI=9 is used as a default value, because many Aether configurations uses it as default.
// TODO: we might want to make it configurable in future.
DefaultQFI = 9
)

var (
p4RtcServerIP = flag.String("p4RtcServerIP", "", "P4 Server ip")
p4RtcServerPort = flag.String("p4RtcServerPort", "", "P4 Server port")
)

const (
preQosCounterID = iota
postQosCounterID

// 253 base stations + 1 dbuf (fixed in UP4) + 1 reserved (fixed in P4 pipeline)
maxGTPTunnelPeerIDs = 253
maxApplicationIDs = 254
)

const (
applicationMeter = "PreQosPipe.app_meter"
sessionMeter = "PreQosPipe.session_meter"

meterTypeApplication uint8 = 1
meterTypeSession uint8 = 2

// DefaultQFI is set if no QER is sent by a control plane in PFCP messages.
// QFI=9 is used as a default value, because many Aether configurations uses it as default.
// TODO: we might want to make it configurable in future.
DefaultQFI = 9
)

var (
p4RtcServerIP = flag.String("p4RtcServerIP", "", "P4 Server ip")
p4RtcServerPort = flag.String("p4RtcServerPort", "", "P4 Server port")
)

type application struct {
Expand Down Expand Up @@ -82,13 +74,13 @@ type meter struct {
}

type UP4 struct {
conf P4rtcInfo

host string
deviceID uint64
timeout uint32
accessIP *net.IPNet
ueIPPool *net.IPNet
p4rtcServer string
p4rtcPort string
enableEndMarker bool

p4client *P4rtClient
Expand Down Expand Up @@ -209,7 +201,7 @@ func (up4 *UP4) setupChannel() error {

err = up4.p4client.GetForwardingPipelineConfig()
if err != nil {
err = up4.p4client.SetForwardingPipelineConfig(p4InfoPath, deviceConfigPath)
err = up4.p4client.SetForwardingPipelineConfig(up4.conf.P4Info, up4.conf.DeviceConfig)
if err != nil {
log.Errorf("set forwarding pipeling config failed: %v", err)
return err
Expand Down Expand Up @@ -325,35 +317,38 @@ func (up4 *UP4) isConnected(accessIP *net.IP) bool {
func (up4 *UP4) setUpfInfo(u *upf, conf *Conf) {
log.Println("setUpfInfo UP4")

up4.conf = conf.P4rtcIface

up4.accessIP = MustParseStrIP(conf.P4rtcIface.AccessIP)
u.accessIP = up4.accessIP.IP

log.Println("AccessIP: ", up4.accessIP)
log.Infof("AccessIP: %v", up4.accessIP)

up4.ueIPPool = MustParseStrIP(conf.CPIface.UEIPPool)

log.Infof("UE IP pool: %v", up4.ueIPPool)

up4.p4rtcServer = conf.P4rtcIface.P4rtcServer
log.Println("UP4 server ip/name", up4.p4rtcServer)
up4.p4rtcPort = conf.P4rtcIface.P4rtcPort
p4rtcServer := conf.P4rtcIface.P4rtcServer

p4rtcPort := conf.P4rtcIface.P4rtcPort
up4.reportNotifyChan = u.reportNotifyChan

if *p4RtcServerIP != "" {
up4.p4rtcServer = *p4RtcServerIP
p4rtcServer = *p4RtcServerIP
}

if *p4RtcServerPort != "" {
up4.p4rtcPort = *p4RtcServerPort
p4rtcPort = *p4RtcServerPort
}

u.coreIP = net.ParseIP(net.IPv4zero.String())

log.Println("onos server ip ", up4.p4rtcServer)
log.Println("onos server port ", up4.p4rtcPort)
up4.host = p4rtcServer + ":" + p4rtcPort

log.WithFields(log.Fields{
"UP4 endpoint": up4.host,
}).Info("UP4 endpoint configured")

up4.host = up4.p4rtcServer + ":" + up4.p4rtcPort
log.Println("server name: ", up4.host)
up4.deviceID = 1
up4.timeout = 30
up4.enableEndMarker = conf.EnableEndMarker
Expand Down
11 changes: 0 additions & 11 deletions pfcpiface/upf.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ const (
n3 = 0x0
n6 = 0x1
n9 = 0x2

// Default values for outgoing requests
maxReqRetriesDefault = 5
respTimeoutDefault = 2 * time.Second

// Default value for Heart Beat Interval
hbIntervalDefault = 5 * time.Second

readTimeoutDefault = 15 * time.Second
)

func (u *upf) isConnected() bool {
Expand Down Expand Up @@ -134,9 +125,7 @@ func NewUPF(conf *Conf, fp fastPath) *upf {
peers: conf.CPIface.Peers,
reportNotifyChan: make(chan uint64, 1024),
maxReqRetries: conf.MaxReqRetries,
respTimeout: respTimeoutDefault,
enableHBTimer: conf.EnableHBTimer,
hbInterval: hbIntervalDefault,
readTimeout: time.Second * time.Duration(conf.ReadTimeout),
}

Expand Down