gopktgen

package module
v0.0.0-...-958e258 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiInfo

type ApiInfo struct {
	FuncName string // Function Name of the library.
	FuncPtr  any    // Function pointer.
}

type CfgOption

type CfgOption func(*System)

func WithConfig

func WithConfig(config string) CfgOption

type GoPktgen

type GoPktgen struct {
	GoPktgenApi
	// contains filtered or unexported fields
}

func New

func New(options ...GoPktgenOption) (*GoPktgen, error)

Create the GoPktgen instance and load the necessary libraries

func (*GoPktgen) AddMapping

func (g *GoPktgen) AddMapping(pMap ...*gpc.Mapping)

func (*GoPktgen) AddPorts

func (g *GoPktgen) AddPorts(pci ...string)

func (*GoPktgen) Core

func (g *GoPktgen) Core(coreID gpc.CoreID) *gpc.LogicalCore

func (*GoPktgen) CoreList

func (g *GoPktgen) CoreList() []gpc.LogicalCore

func (*GoPktgen) Destroy

func (g *GoPktgen) Destroy()

func (*GoPktgen) GetEtherStats

func (g *GoPktgen) GetEtherStats(pid gpc.PortID) *gpc.EtherStats

func (*GoPktgen) GetLinkState

func (g *GoPktgen) GetLinkState(pid gpc.PortID) gpc.LinkState

LinkState is the function to get link status of a port

func (*GoPktgen) GetMacAddress

func (g *GoPktgen) GetMacAddress(pid gpc.PortID) (gpc.MacAddress, error)

GetMacAddress is the function to get MAC address of a port

func (*GoPktgen) GetPortDeviceInfo

func (g *GoPktgen) GetPortDeviceInfo(pid gpc.PortID) (gpc.PortDeviceInfo, error)

func (*GoPktgen) GetPortInfo

func (g *GoPktgen) GetPortInfo(pid gpc.PortID) *PortStats

func (*GoPktgen) GetPortStats

func (g *GoPktgen) GetPortStats(pid uint16) *PortStats

func (*GoPktgen) GetRxPercentSlice

func (g *GoPktgen) GetRxPercentSlice() []float64

func (*GoPktgen) GetTxPercentSlice

func (g *GoPktgen) GetTxPercentSlice() []float64

func (*GoPktgen) L2pConfigSet

func (g *GoPktgen) L2pConfigSet() error

func (*GoPktgen) LaunchThreads

func (g *GoPktgen) LaunchThreads() error

func (*GoPktgen) LogicalPortEntry

func (g *GoPktgen) LogicalPortEntry(pid gpc.PortID) *gpc.LogicalPort

func (*GoPktgen) LogicalPortList

func (g *GoPktgen) LogicalPortList() []gpc.LogicalPort

func (*GoPktgen) Marshal

func (g *GoPktgen) Marshal() string

func (*GoPktgen) NewPortStats

func (g *GoPktgen) NewPortStats() *PortStats

func (*GoPktgen) NumQueues

func (g *GoPktgen) NumQueues(pid gpc.PortID) (uint16, uint16)

(L2p) NumQueues returns the number of Rx and Tx queues for a given port.

func (*GoPktgen) PortCount

func (g *GoPktgen) PortCount() uint16

func (*GoPktgen) PortList

func (g *GoPktgen) PortList() []gpc.PhysicalPort

func (*GoPktgen) ProcessMaps

func (g *GoPktgen) ProcessMaps() error

func (*GoPktgen) SetL2pConfig

func (g *GoPktgen) SetL2pConfig(cfg *gpc.L2pConfig) int

func (*GoPktgen) Start

func (g *GoPktgen) Start() error

Start initializes and starts the GoPktgen system. It performs the following steps:

  1. Calls the scrollScreen function to clear the terminal screen.
  2. Initializes the DPDK system using the provided log path.
  3. Attaches to the EAL message channel with the default channel name. If the attachment fails, it sleeps for half a second and tries again.
  4. Initializes the physical port information.
  5. Creates the threads using the attached message channel.
  6. Returns an error if any step fails.

func (*GoPktgen) Stop

func (g *GoPktgen) Stop()

Stop is the function to stop DPDK

func (*GoPktgen) UpdateStats

func (g *GoPktgen) UpdateStats()

type GoPktgenApi

type GoPktgenApi struct {
	AddArgv        func(arg string) int                               // Add a argv value
	L2pConfig      func(cfg unsafe.Pointer) int                       // Add L2p configuration
	Startup        func(log_path string) int                          // Start function with log_path
	Shutdown       func() int                                         // Stop function
	PortSetInfo    func(portCfg *gpc.PortConfig) int                  // Set port information
	PortGetInfo    func(portID gpc.PortID) *gpc.PortConfig            // Get port information
	PortFreeInfo   func(cfg *gpc.PortConfig)                          // Free port information structure
	PortStats      func(portID gpc.PortID, stats unsafe.Pointer) int  // Get port statistics
	PortLinkStatus func(portID gpc.PortID) uint64                     // Get link status encoded as a uint64
	PortMacAddress func(portID gpc.PortID, mac unsafe.Pointer) int    // Get port MAC address
	PortDeviceInfo func(portID gpc.PortID, info unsafe.Pointer) int   // Get port device information
	ChannelCreate  func(name string, size uint32) uintptr             // MsgChan initialize
	ChannelAttach  func(name string) uintptr                          // MsgChan attach
	ChannelDestroy func(mc uintptr) int                               // MsgChan destroy
	ChannelRecv    func(mc uintptr, data unsafe.Pointer, len int) int // MsgChan receive data burst
	ChannelSend    func(mc uintptr, data unsafe.Pointer, len int) int // MsgChan send data burst
}

GoPktgen API functions

type GoPktgenOption

type GoPktgenOption func(*GoPktgen)

func WithBasePath

func WithBasePath(basePath string) GoPktgenOption

func WithLibNames

func WithLibNames(libNames []string) GoPktgenOption

func WithLogPath

func WithLogPath(ttyID int) GoPktgenOption

type LibInfo

type LibInfo struct {
	Name   string  // Name of the library.
	Handle uintptr // library handle from dlopen().
}

type PortStats

type PortStats struct {
	TimeStamp  time.Time          // Current time per port to calculate rates
	LinkStatus gpc.LinkState      // Link status of the port
	CurrStats  gpc.PortStatistics // Port statistics
	PrevStats  gpc.PortStatistics // Port statistics
	RateStats  gpc.PortStatistics // Port statistics

	RxPPS        uint64  // Rx packets per second
	TxPPS        uint64  // Tx packets per second
	RxMbitsPS    uint64  // Rx Mbits per second
	TxMbitsPS    uint64  // Tx Mbits per second
	MaxRxPPS     uint64  // Maximum Rx packets received per second
	MaxTxPPS     uint64  // Maximum Tx packets transmitted per second
	MaxRxMbitPS  uint64  // Maximum Rx Mbits per second per second
	MaxTxMbitPS  uint64  // Maximum Tx Mbits per second per second
	RxPacketRate float64 // Rx percent rate per second
	TxPacketRate float64 // Tx percent rate per second
}

type System

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

func NewConfig

func NewConfig(options ...CfgOption) (*System, error)

func (*System) CoreList

func (cs *System) CoreList() string

func (*System) FilePrefix

func (cs *System) FilePrefix() string

func (*System) GetArgsDPDK

func (cs *System) GetArgsDPDK() ([]string, error)

Return the command-line arguments for starting DPDK.

func (*System) InMemory

func (cs *System) InMemory() bool

func (*System) LogTTY

func (cs *System) LogTTY() int

func (*System) MappingCount

func (cs *System) MappingCount() int

func (*System) Mappings

func (cs *System) Mappings() []*gpc.Mapping

func (*System) MemorySize

func (cs *System) MemorySize() uint64

func (*System) NumChannels

func (cs *System) NumChannels() uint16

func (*System) NumRanks

func (cs *System) NumRanks() uint16

func (*System) PciList

func (cs *System) PciList() []string

func (*System) PortCount

func (cs *System) PortCount() int

func (*System) Promiscuous

func (cs *System) Promiscuous() bool

func (*System) SetLogTTY

func (cs *System) SetLogTTY(ptty int)

Jump to

Keyboard shortcuts

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