p4lang / p4runtime

Specification documents for the P4Runtime control-plane API
Apache License 2.0
142 stars 88 forks source link

Allow Action Selectors to specify a maximum number of members. #364

Closed jonathan-dilorenzo closed 2 years ago

jonathan-dilorenzo commented 2 years ago

Currently, Action Selectors can only specify the maximum weight of members within a group and the maximum total weight of all members (see image below). It would be useful to be able to specify the maximum number of members for Action Selectors as well (much like for Action Profiles).

image

Non-breaking change suggestion:

Breaking change suggestions:

  1. Replace size with the max_num_members field from the above suggestion, unifying the semantics for Action Selectors and Action Profiles and clarifying the meaning of the name in the presence of both weight and member number. Then, add a max_total_weight field which has the semantics that size currently has for Action Selectors (i.e. maximum total weight) and should be 0 for Action Profiles.

  2. Instead of combining Action Profiles and Action Selectors into one message ActionProfile, separate them out. This simplifies ActionProfile since it only needs preamble, table_ids, and size (ideally renamed for clarity). Action selectors can then use the suggestion from just above, co-opting all but the with_selector field from the current ActionProfile message and adding the max_total_weight field (and ideally renaming size).

antoninbas commented 2 years ago

This sounds good to me. As I mentioned in today's meeting, having max_group_size be the cumulative sum of member weights was implementation-driven when we first added support for ActionSelector in P4Runtime (the implementation was replicating members according to their weight to achieve the desired load-balancing behavior). If an implementation can benefit from having this new piece of information, it is reasonable to add it.

@jonathan-dilorenzo could you submit a PR with this change (the non-breaking one). I would recommend that for an ActionProfile, we define max_num_members to be the same as size. Also, I assume we need a PSA annotation so that this value can be set from the P4 program for Action Selector extern instances?