bmv2
Designing your own switch target with bmv2
Classes | Public Types | Public Member Functions | List of all members
bm::McSimplePre Class Reference
Inheritance diagram for bm::McSimplePre:
Inheritance graph
[legend]

Classes

struct  McIn
 Input to replicate() method. More...
 
struct  McOut
 Output of replicate() method. More...
 

Public Types

using mgrp_t = unsigned int
 NC. More...
 
using rid_t = unsigned int
 NC. More...
 
using egress_port_t = unsigned int
 NC. More...
 

Public Member Functions

std::vector< McOutreplicate (const McIn) const
 
 McSimplePre (const McSimplePre &other)=delete
 Deleted copy constructor. More...
 
McSimplePreoperator= (const McSimplePre &other)=delete
 Deleted move assignment operator. More...
 
 McSimplePre (McSimplePre &&other)=delete
 Deleted move constructor. More...
 
McSimplePreoperator= (McSimplePre &&other)=delete
 Deleted move assignment operator. More...
 

Detailed Description

A simple, 2-level, packet replication engine, configurable by the control plane. See replicate() for more information.

Member Typedef Documentation

◆ egress_port_t

using bm::McSimplePre::egress_port_t = unsigned int

NC.

◆ mgrp_t

using bm::McSimplePre::mgrp_t = unsigned int

NC.

◆ rid_t

using bm::McSimplePre::rid_t = unsigned int

NC.

Constructor & Destructor Documentation

◆ McSimplePre() [1/2]

bm::McSimplePre::McSimplePre ( const McSimplePre other)
delete

Deleted copy constructor.

◆ McSimplePre() [2/2]

bm::McSimplePre::McSimplePre ( McSimplePre &&  other)
delete

Deleted move constructor.

Member Function Documentation

◆ operator=() [1/2]

McSimplePre& bm::McSimplePre::operator= ( const McSimplePre other)
delete

Deleted move assignment operator.

◆ operator=() [2/2]

McSimplePre& bm::McSimplePre::operator= ( McSimplePre &&  other)
delete

Deleted move assignment operator.

◆ replicate()

std::vector<McOut> bm::McSimplePre::replicate ( const  McIn) const

This is the only "dataplane" method for this class. It takes as input a multicast group id (set during pipeline processing) and returns a vector of McOut instances (rid + egress port).

The mgid (multicast group id) points to a L1 (level 1) node. Each L1 node has a unique rid and points to a L2 node. The L2 node includes a list of ports which we return in a vector (along with thr L1 node rid). It is the target responsibility to use this information to properly "clone" the packet. For example:

Field &f_mgid = phv->get_field("intrinsic_metadata.mcast_grp");
unsigned int mgid = f_mgid.get_uint();
if (mgid != 0) {
const auto pre_out = pre->replicate({mgid});
for (const auto &out : pre_out) {
egress_port = out.egress_port;
std::unique_ptr<Packet> packet_copy = packet->clone_with_phv_ptr();
// ...
// send packet_copy to egress_port
}
}

The documentation for this class was generated from the following file: