Skip to content

Commit

Permalink
Simplify swxruntime thread implementation
Browse files Browse the repository at this point in the history
And add block handling for later IPSec implementation.
Adapted from DPDK Pipeline example!

Signed-off-by: stolsma <github@tolsma.net>
  • Loading branch information
stolsma committed Feb 13, 2023
1 parent 01ee10d commit 8fa78e2
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 451 deletions.
44 changes: 22 additions & 22 deletions pkg/dpdkswx/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ func init() {
})
}

const (
MaxPortsIn = 256
MaxPortsOut = 256
)

type PortParamsType interface {
PortName() string
PortType() string
Expand All @@ -89,17 +94,16 @@ type swxPorts map[int]PortParamsType

// Pipeline represents a DPDK Pipeline record in a Pipeline store
type Pipeline struct {
Ctl // Pipeline Control Struct inclusion
name string // Name of the pipeline
p *C.struct_rte_swx_pipeline // Struct definition, only for swx internal use!
timerPeriodms uint //
build bool // The pipeline is build
enabled bool // The pipeline is enabled
threadID uint // ID of the Lcore thread this pipeline is running on
portsIn swxPorts // All added input ports
portsOut swxPorts // All added output ports
actions ActionStore // All the defined actions in this pipeline when build
tables TableStore // All the defined tables in this pipeline when build
Ctl // Pipeline Control Struct inclusion
name string // Name of the pipeline
p *C.struct_rte_swx_pipeline // Struct definition, only for swx internal use!
build bool // The pipeline is build
enabled bool // The pipeline is enabled
threadID uint // ID of the Lcore thread this pipeline is running on
portsIn swxPorts // All added input ports
portsOut swxPorts // All added output ports
actions ActionStore // All the defined actions in this pipeline when build
tables TableStore // All the defined tables in this pipeline when build
// TODO mirror slots
// TODO mirror sessions
// TODO selectors SelectorStore // All the defined selector tables in this pipeline when build
Expand Down Expand Up @@ -131,11 +135,10 @@ func (pl *Pipeline) Init(name string, numaNode int, clean func()) error {
// Node fill in
pl.name = name
pl.p = p
pl.timerPeriodms = 100
pl.build = false
pl.enabled = false
pl.portsIn = make(swxPorts, 265)
pl.portsOut = make(swxPorts, 265)
pl.portsIn = make(swxPorts, MaxPortsIn)
pl.portsOut = make(swxPorts, MaxPortsOut)
pl.clean = clean

return nil
Expand All @@ -149,11 +152,11 @@ func (pl *Pipeline) Free() (err error) {

err = dpdkswx.Runtime.ExecOnMain(func(*swxruntime.MainCtx) error {
if pl.enabled {
err = swxruntime.DisablePipeline(pl.GetPipeline(), pl.threadID)
swxruntime.DisablePipeline(pl.GetPipeline())
}
pl.Ctl.Free()
C.rte_swx_pipeline_free(pl.p)
return err
return nil
})

pl.build = false
Expand All @@ -180,10 +183,6 @@ func (pl *Pipeline) GetPipeline() unsafe.Pointer {
return unsafe.Pointer(pl.p)
}

func (pl *Pipeline) GetTimerPeriodms() uint {
return pl.timerPeriodms
}

func (pl *Pipeline) IsBuild() bool {
return pl.build
}
Expand Down Expand Up @@ -274,7 +273,7 @@ func (pl *Pipeline) SetEnabled(threadID uint) error {
}

err := dpdkswx.Runtime.ExecOnMain(func(*swxruntime.MainCtx) error {
return swxruntime.EnablePipeline(pl.GetPipeline(), threadID, pl.timerPeriodms)
return swxruntime.EnablePipeline(pl.GetPipeline(), threadID)
})
if err != nil {
return err
Expand All @@ -293,7 +292,8 @@ func (pl *Pipeline) SetDisabled() error {
}

err := dpdkswx.Runtime.ExecOnMain(func(*swxruntime.MainCtx) error {
return swxruntime.DisablePipeline(pl.GetPipeline(), pl.threadID)
swxruntime.DisablePipeline(pl.GetPipeline())
return nil
})
if err != nil {
return err
Expand Down
7 changes: 3 additions & 4 deletions pkg/dpdkswx/swxruntime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,14 @@ func (rt *Runtime) mainCoreJobListener() int {
return 0
}

// launch thread_main pipeline runners on all worker lcores, should be run at Start only!!!
// launch thread_main dataplane runners on all dpdk worker lcores, should be run at Start only!!!
func (rt *Runtime) launchWorkers() error {
// init per-lcore client contexts
// init per-lcore dataplane contexts
if err := ThreadsInit(); err != nil {
return err
}

// launch every EAL thread lcore function
// it should be success since we've just called rte_eal_init()
// launch every EAL worker lcore with dataplane runners
return ThreadsStart()
}

Expand Down
Loading

0 comments on commit 8fa78e2

Please sign in to comment.