From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: Gaetan Rivet <gaetan.rivet@6wind.com>, Matan Azrad <matan@mellanox.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v1 3/3] net/mlx4: merge interrupt collector function
Date: Tue, 5 Sep 2017 14:56:39 +0200 [thread overview]
Message-ID: <a2c5c66b100c46482037555de8ce56a1f939b256.1504614801.git.adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <cover.1504614801.git.adrien.mazarguil@6wind.com>
Since interrupt handler is the only function relying on it, merging them
simplifies the code as there is no need for an API to return collected
events.
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
drivers/net/mlx4/mlx4_intr.c | 94 +++++++++++++--------------------------
1 file changed, 30 insertions(+), 64 deletions(-)
diff --git a/drivers/net/mlx4/mlx4_intr.c b/drivers/net/mlx4/mlx4_intr.c
index e1e6c05..3806322 100644
--- a/drivers/net/mlx4/mlx4_intr.c
+++ b/drivers/net/mlx4/mlx4_intr.c
@@ -135,53 +135,6 @@ mlx4_rx_intr_vec_enable(struct priv *priv)
}
/**
- * Collect interrupt events.
- *
- * @param priv
- * Pointer to private structure.
- * @param events
- * Pointer to event flags holder.
- *
- * @return
- * Number of events.
- */
-static int
-mlx4_collect_interrupt_events(struct priv *priv, uint32_t *events)
-{
- struct ibv_async_event event;
- const struct rte_intr_conf *const intr_conf =
- &priv->dev->data->dev_conf.intr_conf;
- int ret = 0;
-
- *events = 0;
- /* Read all message and acknowledge them. */
- for (;;) {
- if (ibv_get_async_event(priv->ctx, &event))
- break;
- switch (event.event_type) {
- case IBV_EVENT_PORT_ACTIVE:
- case IBV_EVENT_PORT_ERR:
- if (!intr_conf->lsc || mlx4_link_status_check(priv))
- break;
- *events |= (1 << RTE_ETH_EVENT_INTR_LSC);
- ret++;
- break;
- case IBV_EVENT_DEVICE_FATAL:
- if (!intr_conf->rmv)
- break;
- *events |= (1 << RTE_ETH_EVENT_INTR_RMV);
- ret++;
- break;
- default:
- DEBUG("event type %d on port %d not handled",
- event.event_type, event.element.port_num);
- }
- ibv_ack_async_event(&event);
- }
- return ret;
-}
-
-/**
* Process scheduled link status check.
*
* If LSC interrupts are requested, process related callback.
@@ -250,26 +203,39 @@ mlx4_link_status_check(struct priv *priv)
static void
mlx4_interrupt_handler(struct priv *priv)
{
- int ret;
- uint32_t ev;
- int i;
+ enum { LSC, RMV, };
+ static const enum rte_eth_event_type type[] = {
+ [LSC] = RTE_ETH_EVENT_INTR_LSC,
+ [RMV] = RTE_ETH_EVENT_INTR_RMV,
+ };
+ uint32_t caught[RTE_DIM(type)] = { 0 };
+ struct ibv_async_event event;
+ const struct rte_intr_conf *const intr_conf =
+ &priv->dev->data->dev_conf.intr_conf;
+ unsigned int i;
- ret = mlx4_collect_interrupt_events(priv, &ev);
- if (ret > 0) {
- for (i = RTE_ETH_EVENT_UNKNOWN;
- i < RTE_ETH_EVENT_MAX;
- i++) {
- if (ev & (1 << i)) {
- ev &= ~(1 << i);
- _rte_eth_dev_callback_process(priv->dev, i,
- NULL, NULL);
- ret--;
- }
+ /* Read all message and acknowledge them. */
+ while (!ibv_get_async_event(priv->ctx, &event)) {
+ switch (event.event_type) {
+ case IBV_EVENT_PORT_ACTIVE:
+ case IBV_EVENT_PORT_ERR:
+ if (intr_conf->lsc && !mlx4_link_status_check(priv))
+ ++caught[LSC];
+ break;
+ case IBV_EVENT_DEVICE_FATAL:
+ if (intr_conf->rmv)
+ ++caught[RMV];
+ break;
+ default:
+ DEBUG("event type %d on physical port %d not handled",
+ event.event_type, event.element.port_num);
}
- if (ret)
- WARN("%d event%s not processed", ret,
- (ret > 1 ? "s were" : " was"));
+ ibv_ack_async_event(&event);
}
+ for (i = 0; i != RTE_DIM(caught); ++i)
+ if (caught[i])
+ _rte_eth_dev_callback_process(priv->dev, type[i],
+ NULL, NULL);
}
/**
--
2.1.4
next prev parent reply other threads:[~2017-09-05 12:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-05 12:56 [dpdk-dev] [PATCH v1 0/3] net/mlx4: additional interrupt handling fixes Adrien Mazarguil
2017-09-05 12:56 ` [dpdk-dev] [PATCH v1 1/3] net/mlx4: fix unhandled event debug message Adrien Mazarguil
2017-09-05 12:56 ` [dpdk-dev] [PATCH v1 2/3] net/mlx4: fix rescheduled link status check Adrien Mazarguil
2017-09-05 12:56 ` Adrien Mazarguil [this message]
2017-09-05 13:29 ` [dpdk-dev] [PATCH v1 3/3] net/mlx4: merge interrupt collector function Gaëtan Rivet
2017-09-05 13:28 ` [dpdk-dev] [PATCH v1 0/3] net/mlx4: additional interrupt handling fixes Gaëtan Rivet
2017-09-08 9:10 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a2c5c66b100c46482037555de8ce56a1f939b256.1504614801.git.adrien.mazarguil@6wind.com \
--to=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
--cc=gaetan.rivet@6wind.com \
--cc=matan@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).