diff mbox

[net-next,RFC,5/6] mlx4: Implement hardware messages notification using devlink

Message ID 1454496482-13961-6-git-send-email-jiri@resnulli.us
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Jiri Pirko Feb. 3, 2016, 10:48 a.m. UTC
From: Jiri Pirko <jiri@mellanox.com>

Use devlink HW message notification facilities to pass massages going
to and from HW to userspace via Netlink multicast.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c | 9 +++++++++
 include/uapi/linux/devlink.h            | 1 +
 2 files changed, 10 insertions(+)
diff mbox

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index d66c690..2735211 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -36,6 +36,7 @@ 
 #include <linux/mlx4/cmd.h>
 #include <linux/module.h>
 #include <linux/cache.h>
+#include <net/devlink.h>
 
 #include "fw.h"
 #include "icm.h"
@@ -2734,6 +2735,8 @@  static int mlx4_ACCESS_REG(struct mlx4_dev *dev, u16 reg_id,
 {
 	struct mlx4_cmd_mailbox *inbox, *outbox;
 	struct mlx4_access_reg *inbuf, *outbuf;
+	struct mlx4_priv *priv = mlx4_priv(dev);
+	struct devlink *devlink = priv_to_devlink(priv);
 	int err;
 
 	inbox = mlx4_alloc_cmd_mailbox(dev);
@@ -2760,6 +2763,9 @@  static int mlx4_ACCESS_REG(struct mlx4_dev *dev, u16 reg_id,
 			    ((0x3) << 12));
 
 	memcpy(inbuf->reg_data, reg_data, reg_len);
+	devlink_hwmsg_notify(devlink, reg_data, reg_len,
+			     DEVLINK_HWMSG_TYPE_MLX_CMD_REG,
+			     DEVLINK_HWMSG_DIR_TO_HW, GFP_KERNEL);
 	err = mlx4_cmd_box(dev, inbox->dma, outbox->dma, 0, 0,
 			   MLX4_CMD_ACCESS_REG, MLX4_CMD_TIME_CLASS_C,
 			   MLX4_CMD_WRAPPED);
@@ -2775,6 +2781,9 @@  static int mlx4_ACCESS_REG(struct mlx4_dev *dev, u16 reg_id,
 	}
 
 	memcpy(reg_data, outbuf->reg_data, reg_len);
+	devlink_hwmsg_notify(devlink, reg_data, reg_len,
+			     DEVLINK_HWMSG_TYPE_MLX_CMD_REG,
+			     DEVLINK_HWMSG_DIR_FROM_HW, GFP_KERNEL);
 out:
 	mlx4_free_cmd_mailbox(dev, inbox);
 	mlx4_free_cmd_mailbox(dev, outbox);
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 761612b..f06f4f7 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -41,6 +41,7 @@  enum devlink_command {
 
 enum devlink_hwmsg_type {
 	DEVLINK_HWMSG_TYPE_MLX_EMAD, /* Mellanox EMAD packet */
+	DEVLINK_HWMSG_TYPE_MLX_CMD_REG, /* Mellanox CMD iface register access */
 };
 
 enum devlink_hwmsg_dir {