p4rt_client

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

* Copyright (c) 2022 Cisco Systems, Inc. and its affiliates * All rights reserved. * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *

* Copyright (c) 2022 Cisco Systems, Inc. and its affiliates * All rights reserved. * * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *

Index

Constants

View Source
const (
	P4RT_MAX_ARBITRATION_QUEUE_SIZE = 100
	P4RT_MAX_PACKET_QUEUE_SIZE      = 100
	P4RT_STREAM_TERM_CHAN_SIZE      = 100
)

Variables

This section is empty.

Functions

func P4RTParameterToString

func P4RTParameterToString(params *P4RTParameters) string

func P4RTWriteErrParse

func P4RTWriteErrParse(err error) (int, int, []*p4_v1.Error)

Helper function to parse the Write Errors

Types

type P4RTArbCounters

type P4RTArbCounters struct {
	RxArbCntr       uint64
	RxArbCntrDrop   uint64
	RxArbCntrQueued uint64
}

type P4RTArbInfo

type P4RTArbInfo struct {
	SeqNum uint64
	Arb    *p4_v1.MasterArbitrationUpdate
}

type P4RTClient

type P4RTClient struct {
	Params        P4RTClientParameters //Make a copy
	StreamTermErr chan *P4RTStreamTermErr
	// contains filtered or unexported fields
}

We want the Client to be more or less stateless so that we can do negative testing This would require the test driver to explicitly set every attribute in every message

func NewP4RTClient

func NewP4RTClient(params *P4RTClientParameters) *P4RTClient

Creates and Initializes a P4RT client

func (*P4RTClient) Capabilities

func (*P4RTClient) P4rtClientSet

func (p *P4RTClient) P4rtClientSet(client p4_v1.P4RuntimeClient) error

func (*P4RTClient) Read

func (*P4RTClient) ServerConnect

func (p *P4RTClient) ServerConnect() error

func (*P4RTClient) ServerConnectWithOptions added in v0.1.2

func (p *P4RTClient) ServerConnectWithOptions(insec bool, skipVerify bool, username string, password string) error

func (*P4RTClient) ServerDisconnect

func (p *P4RTClient) ServerDisconnect()

func (*P4RTClient) SetForwardingPipelineConfig

func (p *P4RTClient) SetForwardingPipelineConfig(msg *p4_v1.SetForwardingPipelineConfigRequest) error

func (*P4RTClient) StreamChannelCreate

func (p *P4RTClient) StreamChannelCreate(params *P4RTStreamParameters) error

func (*P4RTClient) StreamChannelDestroy

func (p *P4RTClient) StreamChannelDestroy(streamName *string) error

func (*P4RTClient) StreamChannelGet

func (p *P4RTClient) StreamChannelGet(streamName *string) *P4RTClientStream

func (*P4RTClient) StreamChannelGetArbitrationResp

func (p *P4RTClient) StreamChannelGetArbitrationResp(streamName *string,
	minSeqNum uint64) (uint64, *P4RTArbInfo, error)

Block until AT LEAST minSeqNum is observed Returns the max arbitration sequence number observed and the "next" Arbitration from the FIFO queue (could be nil)

func (*P4RTClient) StreamChannelGetPacket

func (p *P4RTClient) StreamChannelGetPacket(streamName *string,
	minSeqNum uint64) (uint64, *P4RTPacketInfo, error)

func (*P4RTClient) StreamChannelGetPackets added in v0.1.1

func (p *P4RTClient) StreamChannelGetPackets(streamName *string,
	minSeqNum uint64, timeout time.Duration) (uint64, []*P4RTPacketInfo, error)

func (*P4RTClient) StreamChannelSendMsg

func (p *P4RTClient) StreamChannelSendMsg(streamName *string, msg *p4_v1.StreamMessageRequest) error

func (*P4RTClient) StreamGetParams

func (p *P4RTClient) StreamGetParams(streamName *string) (uint64, *p4_v1.Uint128, error)

func (*P4RTClient) String

func (p *P4RTClient) String() string

func (*P4RTClient) Write

func (p *P4RTClient) Write(msg *p4_v1.WriteRequest) error

type P4RTClientMap

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

func NewP4RTClientMap

func NewP4RTClientMap() *P4RTClientMap

func (*P4RTClientMap) ClientAdd

func (p *P4RTClientMap) ClientAdd(params *P4RTClientParameters) (*P4RTClient, error)

func (*P4RTClientMap) ClientGet

func (p *P4RTClientMap) ClientGet(clientName *string) (*P4RTClient, error)

func (*P4RTClientMap) InitfromJson

func (p *P4RTClientMap) InitfromJson(jsonFile *string, serverIP *string, serverPort int, username string, password string) (*P4RTParameters, error)

Helper function to bootstrap things from a JSON file

type P4RTClientParameters

type P4RTClientParameters struct {
	Name       string
	ServerIP   string
	ServerPort int
	P4InfoFile string
	Streams    []P4RTStreamParameters
}

func (*P4RTClientParameters) String

func (p *P4RTClientParameters) String() string

type P4RTClientStream

type P4RTClientStream struct {
	Params P4RTStreamParameters // Make a copy (initial config)
	// contains filtered or unexported fields
}

func (*P4RTClientStream) GetArbCounters

func (p *P4RTClientStream) GetArbCounters() *P4RTArbCounters

func (*P4RTClientStream) GetArbQSize

func (p *P4RTClientStream) GetArbQSize() int

func (*P4RTClientStream) GetArbitration

func (p *P4RTClientStream) GetArbitration(minSeqNum uint64) (uint64, *P4RTArbInfo, error)

func (*P4RTClientStream) GetDeviceId

func (p *P4RTClientStream) GetDeviceId() uint64

func (*P4RTClientStream) GetElectionId

func (p *P4RTClientStream) GetElectionId() *p4_v1.Uint128

func (*P4RTClientStream) GetPacket

func (p *P4RTClientStream) GetPacket(minSeqNum uint64) (uint64, *P4RTPacketInfo, error)

GetPacket returns the receivedPacketCounter, the first Packet in Queue and an error if any. The method blocks until minSeqNum number of packets are received. It is advisable to call only one of either GetPacket() or GetPacketsWithTimeout() as a timeout in GetPacketsWithTimeout() may also unblock GetPacket()

func (*P4RTClientStream) GetPacketCounters

func (p *P4RTClientStream) GetPacketCounters() *P4RTPacketCounters

func (*P4RTClientStream) GetPacketQSize

func (p *P4RTClientStream) GetPacketQSize() int

func (*P4RTClientStream) GetPacketsWithTimeout added in v0.1.1

func (p *P4RTClientStream) GetPacketsWithTimeout(minSeqNum uint64, timeout time.Duration) (uint64, []*P4RTPacketInfo, error)

GetPacketsWithTimeout returns the receivedPacketCounter, the list of Packets in Queue and an error if any. If timeout happens before minSeqNum of packets are received, the current Packets in queue are returned along with a DeadlineExceeded error. It is advisable to call only one of either GetPacket() or GetPacketsWithTimeout() as a timeout in GetPacketsWithTimeout() may also unblock GetPacket()

func (*P4RTClientStream) GetParams

func (p *P4RTClientStream) GetParams() (uint64, *p4_v1.Uint128)

func (*P4RTClientStream) QueueArbt

func (p *P4RTClientStream) QueueArbt(arbInfo *P4RTArbInfo)

XXX Do we need a callback function to avoid polling? Should this be Global or per device?

func (*P4RTClientStream) QueuePacket

func (p *P4RTClientStream) QueuePacket(pktInfo *P4RTPacketInfo)

XXX Do we need a callback function to avoid polling? Should this be Global or per device?

func (*P4RTClientStream) SetArbQSize

func (p *P4RTClientStream) SetArbQSize(size int)

func (*P4RTClientStream) SetDeviceId

func (p *P4RTClientStream) SetDeviceId(deviceId uint64)

func (*P4RTClientStream) SetElectionId

func (p *P4RTClientStream) SetElectionId(electionId *p4_v1.Uint128)

func (*P4RTClientStream) SetPacketQSize

func (p *P4RTClientStream) SetPacketQSize(size int)

func (*P4RTClientStream) SetParams

func (p *P4RTClientStream) SetParams(deviceId uint64, electionId *p4_v1.Uint128)

func (*P4RTClientStream) ShouldStop

func (p *P4RTClientStream) ShouldStop() bool

func (*P4RTClientStream) Stop

func (p *P4RTClientStream) Stop()

func (*P4RTClientStream) String

func (p *P4RTClientStream) String() string

type P4RTPacketCounters

type P4RTPacketCounters struct {
	RxPktCntr       uint64
	RxPktCntrDrop   uint64
	RxPktCntrQueued uint64
}

type P4RTPacketInfo

type P4RTPacketInfo struct {
	SeqNum uint64
	Pkt    *p4_v1.PacketIn
}

type P4RTParameters

type P4RTParameters struct {
	Clients []P4RTClientParameters
}

func P4RTParameterLoad

func P4RTParameterLoad(fileName *string) (*P4RTParameters, error)

type P4RTStreamParameters

type P4RTStreamParameters struct {
	Name        string
	DeviceId    uint64
	ElectionIdH uint64
	ElectionIdL uint64
}

func (*P4RTStreamParameters) String

func (p *P4RTStreamParameters) String() string

type P4RTStreamTermErr

type P4RTStreamTermErr struct {
	ClientParams *P4RTClientParameters
	StreamParams *P4RTStreamParameters
	StreamErr    error
}

func (*P4RTStreamTermErr) String

func (p *P4RTStreamTermErr) String() string

Jump to

Keyboard shortcuts

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