control

package
v0.0.0-...-c26978f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Control

type Control interface {
	ControlTable
	PerformArbitration()
	IsMaster() bool
	SetMastershipStatus(bool)
	Run()
	InstallProgram(string, string) error
}

Control represents a controller's control over a switch.

func NewControl

func NewControl(addr string, deviceID uint64, electionID p4V1.Uint128) (Control, error)

NewControl will create a new Control instance

type ControlTable

type ControlTable interface {
	Table(string) TableControl
	Digest(string) DigestControl
	Counter(string) CounterControl
}

type CounterControl

type CounterControl struct {
	// contains filtered or unexported fields
}

CounterControl will contain all the information required to do stuff with a P4 counter

func (*CounterControl) ReadValueAtIndex

func (cc *CounterControl) ReadValueAtIndex(index int64) (*CounterData, error)

ReadValueAtIndex will return the value of the target counter at the target index. Duh.

func (*CounterControl) ReadValues

func (cc *CounterControl) ReadValues() ([]*CounterData, error)

ReadValues will return a list of counter values at all indices

func (*CounterControl) StreamValues

func (cc *CounterControl) StreamValues() (chan *CounterData, error)

StreamValues is like ReadValues, except it will return a channel on which all the counter values will be sent. Use this when you want to get all values asynchronously

type CounterData

type CounterData struct {
	ByteCount   int64
	PacketCount int64
	Index       int64
}

CounterData represents a counter's value at a given index

type DigestControl

type DigestControl struct {
	// contains filtered or unexported fields
}

DigestControl contains all the information needed to handle DigestEntries in the controller

func (DigestControl) Acknowledge

func (dc DigestControl) Acknowledge(digestList *p4V1.DigestList)

Acknowledge will acknowledge that the control plane did receive a DigestList of a given ID

func (DigestControl) Delete

func (dc DigestControl) Delete() error

Delete will delete the selected DigestEntry from the switch i.e. no digest messages corresponding to that DigestEntry will be received.

func (DigestControl) Insert

func (dc DigestControl) Insert(maxListSize int32, maxTimeoutNs, ackTimeoutNs int64) error

Insert will insert a DigestEntry in the switch

func (DigestControl) Modify

func (dc DigestControl) Modify(maxListSize int32, maxTimeoutNs, ackTimeoutNs int64) error

Modify will modify an existing DigestEntry on the switch

type DirectCounterData

type DirectCounterData struct {
	TableEntry  *TableEntry
	ByteCount   int64
	PacketCount int64
}

type SimpleControl

type SimpleControl struct {
	Client             core.P4RClient
	DigestChannel      chan *p4V1.StreamMessageResponse_Digest
	ArbitrationChannel chan *p4V1.StreamMessageResponse_Arbitration
	// contains filtered or unexported fields
}

SimpleControl implements the Control interface. I could not think of a better name

func (*SimpleControl) Counter

func (sc *SimpleControl) Counter(counterName string) CounterControl

Counter will return a CounterControl struct

func (*SimpleControl) Digest

func (sc *SimpleControl) Digest(digestName string) DigestControl

Digest will return a DigestControl struct

func (*SimpleControl) InstallProgram

func (sc *SimpleControl) InstallProgram(binPath, p4InfoPath string) error

InstallProgram will install a p4 compiled binary on a given target

func (*SimpleControl) IsMaster

func (sc *SimpleControl) IsMaster() bool

IsMaster will return true if the control has mastership

func (*SimpleControl) PerformArbitration

func (sc *SimpleControl) PerformArbitration()

PerformArbitration will send an Arbitration Request down the Stream Channel to participate in arbitration

func (*SimpleControl) Run

func (sc *SimpleControl) Run()

Run will do all the work required to actually get the control instance up and running

func (*SimpleControl) SetMastershipStatus

func (sc *SimpleControl) SetMastershipStatus(status bool)

SetMastershipStatus will call a method of the same name on P4RClient. We need to keep track of mastership to reason about which control can be used for what.

func (*SimpleControl) StartArbitrationUpdateListener

func (sc *SimpleControl) StartArbitrationUpdateListener()

StartArbitrationUpdateListener will start a goroutine to listen on the ArbitrationChannel to check for any updates in arbitration

func (*SimpleControl) StartMessageRouter

func (sc *SimpleControl) StartMessageRouter()

StartMessageRouter will start a goroutine that takes incoming messages from the stream and then sends them to corresponding channels based on message types

func (*SimpleControl) Table

func (sc *SimpleControl) Table(tableName string) TableControl

Table will return a TableControl struct

type TableControl

type TableControl struct {
	// contains filtered or unexported fields
}

TableControl will contain all the information required to do stuff with a P4 table

func (TableControl) InsertEntry

func (tc TableControl) InsertEntry(action string, data map[string]interface{}) error

InsertEntry is a less ugly version of InsertEntryRaw, since it supports pretty input (which can be serialized from incoming json, yay!). This method will call the table's Transformer function to convert the data into raw match fields and params, and will then call InsertEntryRaw with these values.

func (TableControl) InsertEntryRaw

func (tc TableControl) InsertEntryRaw(action string, mf []entities.Match, params [][]byte) error

InsertEntryRaw is used to insert an entry into a table using raw values of match fields and params

func (TableControl) ReadDirectCounterValueOnEntry

func (tc TableControl) ReadDirectCounterValueOnEntry(matches []entities.Match) (*DirectCounterData, error)

ReadDirectCounterValueOnEntry will read the value of the DirectCounter against an entry in the table

func (TableControl) ReadDirectCounterValuesSync

func (tc TableControl) ReadDirectCounterValuesSync() ([]*DirectCounterData, error)

ReadDirectCounterValuesSync will return a list of DirectCounter values against all the entries of the table.

func (TableControl) RegisterTransformer

func (tc TableControl) RegisterTransformer(transformer entities.TableEntryTransformer)

RegisterTransformer will register a transformer function for the table managed by this TableControl instance

func (TableControl) StreamDirectCounterValues

func (tc TableControl) StreamDirectCounterValues() (chan *DirectCounterData, error)

StreamDirectCounterValues does what ReadDirectCounterValuesSync does, except that instead of returning a list of values, it returns a channel on which these values can be asynchronously sent.

type TableEntry

type TableEntry p4V1.TableEntry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL