[v5,6/7] examples/ipsec-secgw: add ethdev reset callback

Message ID 20211027114530.2244661-7-radu.nicolau@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series IPsec Sec GW new features |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Radu Nicolau Oct. 27, 2021, 11:45 a.m. UTC
  Applications should not quietly ignore an ethdev reset event.
Register an event handler for ethdev reset callback
RTE_ETH_EVENT_INTR_RESET that prints a message and
quits the application.

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Akhil Goyal Oct. 31, 2021, 8:25 p.m. UTC | #1
> Applications should not quietly ignore an ethdev reset event.
> Register an event handler for ethdev reset callback
> RTE_ETH_EVENT_INTR_RESET that prints a message and
> quits the application.
> 
> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
>  examples/ipsec-secgw/ipsec-secgw.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-
> secgw/ipsec-secgw.c
> index 1ef24b7b5c..bfa2070b8d 100644
> --- a/examples/ipsec-secgw/ipsec-secgw.c
> +++ b/examples/ipsec-secgw/ipsec-secgw.c
> @@ -2545,6 +2545,17 @@ inline_ipsec_event_callback(uint16_t port_id,
> enum rte_eth_event_type type,
>  	return -1;
>  }
> 
> +static int
> +ethdev_reset_event_callback(uint16_t port_id,
> +		enum rte_eth_event_type type __rte_unused,
> +		 void *param __rte_unused, void *ret_param __rte_unused)
> +{
> +	printf("Reset Event on port id %d\n", port_id);

You can also print the type of eth event that has happened.
With this fixed,
Acked-by: Akhil Goyal <gakhil@marvell.com>

> +	printf("Force quit application");
> +	force_quit = true;
> +	return 0;
> +}
> +
>  static uint16_t
>  rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue,
>  	struct rte_mbuf *pkt[], uint16_t nb_pkts,
> @@ -3311,6 +3322,9 @@ main(int32_t argc, char **argv)
>  					rte_strerror(-ret), portid);
>  		}
> 
> +		rte_eth_dev_callback_register(portid,
> RTE_ETH_EVENT_INTR_RESET,
> +			ethdev_reset_event_callback, NULL);
> +
>  		rte_eth_dev_callback_register(portid,
>  			RTE_ETH_EVENT_IPSEC, inline_ipsec_event_callback,
> NULL);
>  	}
> --
> 2.25.1
  

Patch

diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 1ef24b7b5c..bfa2070b8d 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -2545,6 +2545,17 @@  inline_ipsec_event_callback(uint16_t port_id, enum rte_eth_event_type type,
 	return -1;
 }
 
+static int
+ethdev_reset_event_callback(uint16_t port_id,
+		enum rte_eth_event_type type __rte_unused,
+		 void *param __rte_unused, void *ret_param __rte_unused)
+{
+	printf("Reset Event on port id %d\n", port_id);
+	printf("Force quit application");
+	force_quit = true;
+	return 0;
+}
+
 static uint16_t
 rx_callback(__rte_unused uint16_t port, __rte_unused uint16_t queue,
 	struct rte_mbuf *pkt[], uint16_t nb_pkts,
@@ -3311,6 +3322,9 @@  main(int32_t argc, char **argv)
 					rte_strerror(-ret), portid);
 		}
 
+		rte_eth_dev_callback_register(portid, RTE_ETH_EVENT_INTR_RESET,
+			ethdev_reset_event_callback, NULL);
+
 		rte_eth_dev_callback_register(portid,
 			RTE_ETH_EVENT_IPSEC, inline_ipsec_event_callback, NULL);
 	}