[P4-dev] How to dynamically set egress output port

Andy Fingerhut andy.fingerhut at gmail.com
Fri Jul 14 15:11:02 EDT 2017

In general, if you can think of a way to create a table in P4 that some
control plane software can set up its contents before packets arrive
(occasionally needing updating if port speeds change, ports go down, come
back up, etc.) that can be apply()'d in your P4 program to help it
determine which output port to use, that would probably be more efficient
than a long if-then-else-if sequence of statements in the P4 program.

It isn't clear to me what _method_ you are hoping to use for dynamically
selecting an egress port for a packet, so I don't have any concrete
suggestions for what kind of P4 table to create for your method.


On Fri, Jul 14, 2017 at 3:01 AM, Eric Ruan <ruanweizhang at gmail.com> wrote:

> Hello everyone,
> I am trying to dynamically set egress port for a packet.
> I think the possible way is to request the current port
> bit rate of physical output ports and then use if-else sentences to
> dynamically set up the egress port in the ingress pipeline stage.
> Then I came up with some questions.
> Q1: in this link *https://goo.gl/jqmD64 <https://goo.gl/jqmD64>*
> /** port speed */
> typedef enum {
>   SWITCH_API_PORT_SPEED_NONE, /**< Port Speed Not set */
>   SWITCH_API_PORT_SPEED_1G,   /**< port speed 1G */
>   SWITCH_API_PORT_SPEED_10G,  /**< port speed 10G */
>   SWITCH_API_PORT_SPEED_25G,  /**< port speed 25G */
>   SWITCH_API_PORT_SPEED_40G,  /**< port speed 40G */
>   SWITCH_API_PORT_SPEED_50G,  /**< port speed 50G */
>   SWITCH_API_PORT_SPEED_100G  /**< port speed 100G */
> } switch_port_speed_t;
> where switch_port_speed_t is not continuous number, how can it
> accurately record the current bit rate of a physical output port?
> Q2: again in the same link *https://goo.gl/jqmD64 <https://goo.gl/jqmD64>*
> the get function is like this, but I couldn't find any example on Internet
> on how to use this. Since it is written in C/C++ language, I don't know how
> to call this function in p4 program.
> switch_status_t switch_api_port_speed_get(switch_device_t device,
>                                           switch_port_t port,
>                                           switch_port_speed_t *speed) {
> }
> Thanks in advance.
> Best,
> Eric
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170714/f4448c5c/attachment-0002.html>

More information about the P4-dev mailing list