On Thu, Jan 21, 2021 at 01:29:54PM +0200, Oleksandr Mazur wrote:
> Add support for new HARD_DROP action, which is used for
> trap hard drop statistics retrival. It's used whenever
> device is unable to report trapped packet to the devlink
> subsystem, and thus device could only state how many
> packets have been dropped, without passing a packet
> to the devlink subsystem to get track of traffic statistics.

This patch should also be marked as "RFC".

> 
> Signed-off-by: Oleksandr Mazur <oleksandr.ma...@plvision.eu>
> ---
>  devlink/devlink.c            | 4 ++++
>  include/uapi/linux/devlink.h | 4 ++++

Missing man page and bash completion extensions:

man/man8/devlink-trap.8
bash-completion/devlink

>  2 files changed, 8 insertions(+)
> 
> diff --git a/devlink/devlink.c b/devlink/devlink.c
> index a2e06644..77185f7c 100644
> --- a/devlink/devlink.c
> +++ b/devlink/devlink.c
> @@ -1335,6 +1335,8 @@ static int trap_action_get(const char *actionstr,
>  {
>       if (strcmp(actionstr, "drop") == 0) {
>               *p_action = DEVLINK_TRAP_ACTION_DROP;
> +     } else if (strcmp(actionstr, "hard_drop") == 0) {
> +             *p_action = DEVLINK_TRAP_ACTION_HARD_DROP;
>       } else if (strcmp(actionstr, "trap") == 0) {
>               *p_action = DEVLINK_TRAP_ACTION_TRAP;
>       } else if (strcmp(actionstr, "mirror") == 0) {
> @@ -7726,6 +7728,8 @@ static const char *trap_action_name(uint8_t action)
>       switch (action) {
>       case DEVLINK_TRAP_ACTION_DROP:
>               return "drop";
> +     case DEVLINK_TRAP_ACTION_HARD_DROP:
> +             return "hard_drop";
>       case DEVLINK_TRAP_ACTION_TRAP:
>               return "trap";
>       case DEVLINK_TRAP_ACTION_MIRROR:
> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
> index 1414acee..ecee2541 100644
> --- a/include/uapi/linux/devlink.h
> +++ b/include/uapi/linux/devlink.h
> @@ -261,12 +261,16 @@ enum {
>   * enum devlink_trap_action - Packet trap action.
>   * @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is 
> not
>   *                            sent to the CPU.
> + * @DEVLINK_TRAP_ACTION_HARD_DROP: Packet was dropped by the underlying 
> device,
> + *                                 and device cannot report packet to devlink
> + *                                 (or inject it into the kernel RX path).
>   * @DEVLINK_TRAP_ACTION_TRAP: The sole copy of the packet is sent to the CPU.
>   * @DEVLINK_TRAP_ACTION_MIRROR: Packet is forwarded by the device and a copy 
> is
>   *                              sent to the CPU.
>   */
>  enum devlink_trap_action {
>       DEVLINK_TRAP_ACTION_DROP,
> +     DEVLINK_TRAP_ACTION_HARD_DROP,
>       DEVLINK_TRAP_ACTION_TRAP,
>       DEVLINK_TRAP_ACTION_MIRROR,
>  };
> -- 
> 2.17.1
> 

Reply via email to