From: Jason Gunthorpe <jgg@mellanox.com>
To: Saeed Mahameed <saeedm@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Mikhael Goikhman <migo@mellanox.com>
Subject: Re: [PATCH mlx5-next 01/10] net/mlx5: Rework handling of port module events
Date: Mon, 10 Dec 2018 16:09:46 +0000 [thread overview]
Message-ID: <20181210160938.GE3459@mellanox.com> (raw)
In-Reply-To: <20181210030442.7543-2-saeedm@mellanox.com>
On Sun, Dec 09, 2018 at 07:04:33PM -0800, Saeed Mahameed wrote:
> From: Mikhael Goikhman <migo@mellanox.com>
>
> Add explicit HW defined error values. For simplicity, keep counters for all
> statuses starting from 0, although currently status=0 is not used.
>
> Additionally, when HW signals an unexpected cable status, it is reported
> now rather than ignored. And status counter is now updated on errors.
>
> Signed-off-by: Mikhael Goikhman <migo@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> .../ethernet/mellanox/mlx5/core/en_stats.c | 8 +-
> .../net/ethernet/mellanox/mlx5/core/events.c | 83 ++++++++++++-------
> .../ethernet/mellanox/mlx5/core/lib/mlx5.h | 19 ++---
> 3 files changed, 65 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
> index 748d23806391..881c54c12e19 100644
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
> @@ -1087,13 +1087,13 @@ static void mlx5e_grp_per_prio_update_stats(struct mlx5e_priv *priv)
> }
>
> static const struct counter_desc mlx5e_pme_status_desc[] = {
> - { "module_unplug", 8 },
> + { "module_unplug", sizeof(u64) * MLX5_MODULE_STATUS_UNPLUGGED },
> };
>
> static const struct counter_desc mlx5e_pme_error_desc[] = {
> - { "module_bus_stuck", 16 }, /* bus stuck (I2C or data shorted) */
> - { "module_high_temp", 48 }, /* high temperature */
> - { "module_bad_shorted", 56 }, /* bad or shorted cable/module */
> + { "module_bus_stuck", sizeof(u64) * MLX5_MODULE_EVENT_ERROR_BUS_STUCK },
> + { "module_high_temp", sizeof(u64) * MLX5_MODULE_EVENT_ERROR_HIGH_TEMPERATURE },
> + { "module_bad_shorted", sizeof(u64) * MLX5_MODULE_EVENT_ERROR_BAD_CABLE },
> };
>
> #define NUM_PME_STATUS_STATS ARRAY_SIZE(mlx5e_pme_status_desc)
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/events.c b/drivers/net/ethernet/mellanox/mlx5/core/events.c
> index e92df7020a26..587d93ec905f 100644
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/events.c
> @@ -157,23 +157,43 @@ static int temp_warn(struct notifier_block *nb, unsigned long type, void *data)
> }
>
> /* MLX5_EVENT_TYPE_PORT_MODULE_EVENT */
> -static const char *mlx5_pme_status[MLX5_MODULE_STATUS_NUM] = {
> - "Cable plugged", /* MLX5_MODULE_STATUS_PLUGGED = 0x1 */
> - "Cable unplugged", /* MLX5_MODULE_STATUS_UNPLUGGED = 0x2 */
> - "Cable error", /* MLX5_MODULE_STATUS_ERROR = 0x3 */
> -};
> +static const char *mlx5_pme_status_to_string(enum port_module_event_status_type status)
> +{
> + switch (status) {
> + case MLX5_MODULE_STATUS_PLUGGED:
> + return "Cable plugged";
> + case MLX5_MODULE_STATUS_UNPLUGGED:
> + return "Cable unplugged";
> + case MLX5_MODULE_STATUS_ERROR:
> + return "Cable error";
> + default:
> + return "Unknown status";
> + }
> +}
Arrays are usually a bette codegen bet than switch/case unless the array is
very sparse, but it should be written as
[MLX5_MODULE_STATUS_PLUGGED] = "Cable plugged",
Commit message should explain why this is being converted. Maybe it is
very sparse?
Jason
next prev parent reply other threads:[~2018-12-10 16:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 3:04 [PATCH mlx5-next 00/10] mlx5 core updates and cleanups Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 01/10] net/mlx5: Rework handling of port module events Saeed Mahameed
2018-12-10 16:09 ` Jason Gunthorpe [this message]
2018-12-10 19:07 ` Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 02/10] net/mlx5: Add support for PCIe power slot exceeded error in PME Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 03/10] net/mlx5: Add support for plugged-disabled cable status " Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 04/10] net/mlx5: Add monitor commands layout and event data Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 05/10] net/mlx5: Revise gre and nvgre key formats Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 06/10] net/mlx5: Introduce extended destination fields Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 07/10] net/mlx5: E-Switch, Change vhca id valid bool field to bit flag Saeed Mahameed
2018-12-10 16:12 ` Jason Gunthorpe
2018-12-10 19:12 ` Saeed Mahameed
2018-12-10 21:05 ` Or Gerlitz
2018-12-10 21:18 ` Saeed Mahameed
2018-12-10 19:51 ` Or Gerlitz
2018-12-10 3:04 ` [PATCH mlx5-next 08/10] net/mlx5: Support extended destination format in flow steering command Saeed Mahameed
2018-12-10 16:16 ` Jason Gunthorpe
2018-12-10 19:13 ` Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 09/10] IB/mlx5: Simplify netdev unbinding Saeed Mahameed
2018-12-10 3:04 ` [PATCH mlx5-next 10/10] net/mlx5: Remove the get protocol device interface entry Saeed Mahameed
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=20181210160938.GE3459@mellanox.com \
--to=jgg@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=migo@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@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