# PSA egress behavior

**URL:** <https://forum.p4.org/t/psa-egress-behavior/466>\
**Category:** Getting Started with P4\
**Created:** [September 9, 2022, 11:11am UTC](https://forum.p4.org/t/psa-egress-behavior/466 "2022-09-09T11:11:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kesnar](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@kesnar](https://forum.p4.org/u/kesnar)\
**Post date:** [September 9, 2022, 11:11am UTC](https://forum.p4.org/t/psa-egress-behavior/466/1 "2022-09-09T11:11:25Z")

</div>

Hello,

I am trying to understand the egress part of the PSA.  
So I am using p4-dpdk-target and I have written a simple bounce-back program that switches dst and src mac addresses.  
To do that I am parsing the packet headers in the Ingress Parser block and then on the Ingress block, I am switching the fields.

My question comes when I move this procedure from the ingress to the egress blocks: So I am parsing in the Egress Parser block and switching the fields in the Egress block.  
Then the fields do not change.

I understand that three different things could happen:

1. Egress is not used for headers manipulation. (So what is it used for?)
2. I also have to change some specific metadata. (Which are they?)
3. This is not the expected behavior, it is a p4-dpdk-target bug.
4. ???

Thank you!

---

<div class="post-metadata">

**Author:** ![andyfingerhut](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/andyfingerhut/32/17_2.png) [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Post date:** [September 9, 2022, 1:28pm UTC](https://forum.p4.org/t/psa-egress-behavior/466/2 "2022-09-09T13:28:41Z")

</div>

PSA egress SHOULD be usable for packet modifications.

It is possible that the DPDK back end implementation of PSA does not support this. I can find out and report back here.

If you can publish your P4 program where you tried to modify the packet header in egress, but it failed, to some place with a link here, that may be helpful.

---

<div class="post-metadata">

**Author:** ![kesnar](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@kesnar](https://forum.p4.org/u/kesnar)\
**Post date:** [September 9, 2022, 1:49pm UTC](https://forum.p4.org/t/psa-egress-behavior/466/3 "2022-09-09T13:49:03Z")

</div>

You can find the program:

> **[main.p4 - Pastebin.com](https://pastebin.com/a61fmQxG)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

As you can see the ingress and egress blocks are identical (lines 41-43 are commented out)

Thank you!

---

<div class="post-metadata">

**Author:** ![ederollora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/ederollora/32/21_2.png) [@ederollora](https://forum.p4.org/u/ederollora)\
**Post date:** [September 9, 2022, 2:21pm UTC](https://forum.p4.org/t/psa-egress-behavior/466/4 "2022-09-09T14:21:46Z")

</div>

Hi @kesnar ,

I just wanted to add some (possibly) interesting information. There are some specific design choices in PSA (not related to your current question though) that you might find the answers for if you check the specification. If you already checked it, then sorry!.

> ## [D. Appendix: Rationale for design](https://p4.org/p4-spec/docs/PSA.html#appendix-rationale)
> 
> ### [D.1. Why egress processing?](https://p4.org/p4-spec/docs/PSA.html#appendix-rationale-egress)
> 
> ### [D.2. No output port change during egress](https://p4.org/p4-spec/docs/PSA.html#appendix-rationale-egress-cannot-change-output-port)
> 
> ### [D.3. Ingress deparser and egress parser](https://p4.org/p4-spec/docs/PSA.html#appendix-rationale-ingress-deparser-egress-parser)

Cheers,

---

<div class="post-metadata">

**Author:** ![andyfingerhut](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/andyfingerhut/32/17_2.png) [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Post date:** [September 12, 2022, 2:05pm UTC](https://forum.p4.org/t/psa-egress-behavior/466/5 "2022-09-12T14:05:19Z")

</div>

I checked with the DPDK developers, and they pointed out that this is actually documented in the README for the DPDK back end to p4c, in this paragraph, which you can find here: [p4c/README.md at main · p4lang/p4c · GitHub](https://github.com/p4lang/p4c/blob/main/backends/dpdk/README.md)

“Currently, programs written for DPDK target should limit the functionality in Ingress blocks, in case non empty Egress blocks are present it will be ignored by default unless Hidden temporary option `--enableEgress` used. When egress block support gets added to the DPDK target, and compiler can generate separate spec file for non empty ingress and egress blocks then option `--enableEgress` will be removed.”

I suggested they add a warning or error message if a P4 program is compiled for the DPDK PSA back end, if the egress parser, control, or deparser were “not empty”, and they have added such an item to their list of things to do, to make it more obvious when this occurs.
