All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] devlink: add support for HARD_DROP trap action
@ 2021-01-21 11:29 Oleksandr Mazur
  2021-01-21 12:25 ` Ido Schimmel
  0 siblings, 1 reply; 2+ messages in thread
From: Oleksandr Mazur @ 2021-01-21 11:29 UTC (permalink / raw)
  To: netdev; +Cc: jiri, davem, linux-kernel, kuba, Oleksandr Mazur

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.

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2-next] devlink: add support for HARD_DROP trap action
  2021-01-21 11:29 [PATCH iproute2-next] devlink: add support for HARD_DROP trap action Oleksandr Mazur
@ 2021-01-21 12:25 ` Ido Schimmel
  0 siblings, 0 replies; 2+ messages in thread
From: Ido Schimmel @ 2021-01-21 12:25 UTC (permalink / raw)
  To: Oleksandr Mazur; +Cc: netdev, jiri, davem, linux-kernel, kuba

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.mazur@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
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-21 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 11:29 [PATCH iproute2-next] devlink: add support for HARD_DROP trap action Oleksandr Mazur
2021-01-21 12:25 ` Ido Schimmel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.