patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 21.11] Revert "net/iavf: add thread for event callbacks"
@ 2022-12-15 10:57 Kevin Traynor
  2022-12-19 10:16 ` Kevin Traynor
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Traynor @ 2022-12-15 10:57 UTC (permalink / raw)
  To: stable
  Cc: bluca, david.marchand, john.mcnamara, qi.z.zhang, jie1x.wang,
	Kevin Traynor, Jingjing Wu, Beilei Xing

This reverts commit fcf8e69afb79eede8d14f8f5e16c6212d5c2dbfe.

Reverting this commit as it has just been backported for
21.11.3 but an issue has been identified. A fix is in
progress but it is not ready in time for 21.11.3.

It is better to revert the patch and keep the behaviour in
21.11.3 the same as 21.11/21.11.1/21.11.2 and do a correct
chain of fixes in a later release when they are available.

Link to discussion upstream patch being discussed [1] and for
reference commit id of patch being reverted in DPDK main
branch [2].

[1]
https://mails.dpdk.org/archives/dev/2022-November/256458.html
[2]
commit cb5c1b91f76f ("net/iavf: add thread for event callbacks")

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
---
 drivers/net/iavf/iavf.h        |   2 -
 drivers/net/iavf/iavf_ethdev.c |   5 --
 drivers/net/iavf/iavf_vchnl.c  | 153 ++-------------------------------
 3 files changed, 6 insertions(+), 154 deletions(-)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index afffc1a13e..29692e3994 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -401,6 +401,4 @@ _atomic_set_async_response_cmd(struct iavf_info *vf, enum virtchnl_ops ops)
 int iavf_check_api_version(struct iavf_adapter *adapter);
 int iavf_get_vf_resource(struct iavf_adapter *adapter);
-void iavf_dev_event_handler_fini(void);
-int iavf_dev_event_handler_init(void);
 void iavf_handle_virtchnl_msg(struct rte_eth_dev *dev);
 int iavf_enable_vlan_strip(struct iavf_adapter *adapter);
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 54a05b3658..630779fb21 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2563,7 +2563,4 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 			&eth_dev->data->mac_addrs[0]);
 
-	if (iavf_dev_event_handler_init())
-		goto init_vf_err;
-
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
 		/* register callback func to eal lib */
@@ -2720,6 +2717,4 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	iavf_dev_close(dev);
 
-	iavf_dev_event_handler_fini();
-
 	return 0;
 }
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index d408e19adc..1bd3559ec2 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -3,5 +3,4 @@
  */
 
-#include <fcntl.h>
 #include <stdio.h>
 #include <errno.h>
@@ -13,5 +12,4 @@
 #include <rte_byteorder.h>
 #include <rte_common.h>
-#include <rte_os_shim.h>
 
 #include <rte_debug.h>
@@ -30,144 +28,4 @@
 #define ASQ_DELAY_MS  1
 
-#define MAX_EVENT_PENDING 16
-
-struct iavf_event_element {
-	TAILQ_ENTRY(iavf_event_element) next;
-	struct rte_eth_dev *dev;
-	enum rte_eth_event_type event;
-	void *param;
-	size_t param_alloc_size;
-	uint8_t param_alloc_data[0];
-};
-
-struct iavf_event_handler {
-	uint32_t ndev;
-	pthread_t tid;
-	int fd[2];
-	pthread_mutex_t lock;
-	TAILQ_HEAD(event_lsit, iavf_event_element) pending;
-};
-
-static struct iavf_event_handler event_handler = {
-	.fd = {-1, -1},
-};
-
-#ifndef TAILQ_FOREACH_SAFE
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
-	for ((var) = TAILQ_FIRST((head)); \
-		(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
-	(var) = (tvar))
-#endif
-
-static void *
-iavf_dev_event_handle(void *param __rte_unused)
-{
-	struct iavf_event_handler *handler = &event_handler;
-	TAILQ_HEAD(event_list, iavf_event_element) pending;
-
-	while (true) {
-		char unused[MAX_EVENT_PENDING];
-		ssize_t nr = read(handler->fd[0], &unused, sizeof(unused));
-		if (nr <= 0)
-			break;
-
-		TAILQ_INIT(&pending);
-		pthread_mutex_lock(&handler->lock);
-		TAILQ_CONCAT(&pending, &handler->pending, next);
-		pthread_mutex_unlock(&handler->lock);
-
-		struct iavf_event_element *pos, *save_next;
-		TAILQ_FOREACH_SAFE(pos, &pending, next, save_next) {
-			TAILQ_REMOVE(&pending, pos, next);
-			rte_eth_dev_callback_process(pos->dev, pos->event, pos->param);
-			rte_free(pos);
-		}
-	}
-
-	return NULL;
-}
-
-static void
-iavf_dev_event_post(struct rte_eth_dev *dev,
-		enum rte_eth_event_type event,
-		void *param, size_t param_alloc_size)
-{
-	struct iavf_event_handler *handler = &event_handler;
-	char notify_byte;
-	struct iavf_event_element *elem = rte_malloc(NULL, sizeof(*elem) + param_alloc_size, 0);
-	if (!elem)
-		return;
-
-	elem->dev = dev;
-	elem->event = event;
-	elem->param = param;
-	elem->param_alloc_size = param_alloc_size;
-	if (param && param_alloc_size) {
-		rte_memcpy(elem->param_alloc_data, param, param_alloc_size);
-		elem->param = elem->param_alloc_data;
-	}
-
-	pthread_mutex_lock(&handler->lock);
-	TAILQ_INSERT_TAIL(&handler->pending, elem, next);
-	pthread_mutex_unlock(&handler->lock);
-
-	ssize_t nw = write(handler->fd[1], &notify_byte, 1);
-	RTE_SET_USED(nw);
-}
-
-int
-iavf_dev_event_handler_init(void)
-{
-	struct iavf_event_handler *handler = &event_handler;
-
-	if (__atomic_add_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 1)
-		return 0;
-#if defined(RTE_EXEC_ENV_WINDOWS) && RTE_EXEC_ENV_WINDOWS != 0
-	int err = _pipe(handler->fd, MAX_EVENT_PENDING, O_BINARY);
-#else
-	int err = pipe(handler->fd);
-#endif
-	if (err != 0) {
-		__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED);
-		return -1;
-	}
-
-	TAILQ_INIT(&handler->pending);
-	pthread_mutex_init(&handler->lock, NULL);
-
-	if (rte_ctrl_thread_create(&handler->tid, "iavf-event-thread",
-				NULL, iavf_dev_event_handle, NULL)) {
-		__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED);
-		return -1;
-	}
-
-	return 0;
-}
-
-void
-iavf_dev_event_handler_fini(void)
-{
-	struct iavf_event_handler *handler = &event_handler;
-
-	if (__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 0)
-		return;
-
-	int unused = pthread_cancel(handler->tid);
-	RTE_SET_USED(unused);
-	close(handler->fd[0]);
-	close(handler->fd[1]);
-	handler->fd[0] = -1;
-	handler->fd[1] = -1;
-
-	pthread_join(handler->tid, NULL);
-	pthread_mutex_destroy(&handler->lock);
-
-	struct iavf_event_element *pos, *save_next;
-	TAILQ_FOREACH_SAFE(pos, &handler->pending, next, save_next) {
-		TAILQ_REMOVE(&handler->pending, pos, next);
-		rte_free(pos);
-	}
-}
-
 static uint32_t
 iavf_convert_link_speed(enum virtchnl_link_speed virt_link_speed)
@@ -421,6 +279,6 @@ iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
 		vf->vf_reset = true;
-		iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_RESET,
-					      NULL, 0);
+		rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
+					      NULL);
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
@@ -436,5 +294,5 @@ iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
 		}
 		iavf_dev_link_update(dev, 0);
-		iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_LSC, NULL, 0);
+		rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 		break;
 	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
@@ -502,6 +360,7 @@ iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
 						RTE_ETH_EVENT_IPSEC_UNKNOWN;
 					desc.metadata = ev->ipsec_event_data;
-					iavf_dev_event_post(dev, RTE_ETH_EVENT_IPSEC,
-							&desc, sizeof(desc));
+					rte_eth_dev_callback_process(dev,
+							RTE_ETH_EVENT_IPSEC,
+							&desc);
 					return;
 				}
-- 
2.38.1


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

* Re: [PATCH 21.11] Revert "net/iavf: add thread for event callbacks"
  2022-12-15 10:57 [PATCH 21.11] Revert "net/iavf: add thread for event callbacks" Kevin Traynor
@ 2022-12-19 10:16 ` Kevin Traynor
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Traynor @ 2022-12-19 10:16 UTC (permalink / raw)
  To: stable
  Cc: bluca, david.marchand, john.mcnamara, qi.z.zhang, jie1x.wang,
	Jingjing Wu, Beilei Xing

On 15/12/2022 10:57, Kevin Traynor wrote:
> This reverts commit fcf8e69afb79eede8d14f8f5e16c6212d5c2dbfe.
> 
> Reverting this commit as it has just been backported for
> 21.11.3 but an issue has been identified. A fix is in
> progress but it is not ready in time for 21.11.3.
> 
> It is better to revert the patch and keep the behaviour in
> 21.11.3 the same as 21.11/21.11.1/21.11.2 and do a correct
> chain of fixes in a later release when they are available.
> 
> Link to discussion upstream patch being discussed [1] and for
> reference commit id of patch being reverted in DPDK main
> branch [2].
> 
> [1]
> https://mails.dpdk.org/archives/dev/2022-November/256458.html
> [2]
> commit cb5c1b91f76f ("net/iavf: add thread for event callbacks")
> 
> Signed-off-by: Kevin Traynor<ktraynor@redhat.com>
> ---

Applied and pushed to 21.11 branch. Thanks.


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

end of thread, other threads:[~2022-12-19 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 10:57 [PATCH 21.11] Revert "net/iavf: add thread for event callbacks" Kevin Traynor
2022-12-19 10:16 ` Kevin Traynor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).