]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/mlx5: Get rid of storing copy of device name
authorParav Pandit <parav@mellanox.com>
Mon, 29 Apr 2019 18:14:02 +0000 (18:14 +0000)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 29 Apr 2019 23:55:05 +0000 (16:55 -0700)
Currently mlx5 core stores copy of the PCI device name in a
mlx5_priv structure and uses pr_warn, pr_err helpers.

Get rid of the copy of this name; instead store the parent device
pointer that contains name as well as dma specific parameters.
This also allows to use kernel's well defined dev_warn, dev_err, dev_dbg
device specific print routines.

This is also a preparation patch to access non PCI parent device in
future.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/cmd.c
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer_tracepoint.h
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/health.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
include/linux/mlx5/driver.h

index 0a2ffe794a547170bbce5935dd596d0e2ca3b034..779fa1e9ee4e38ae92c104d81871905292811924 100644 (file)
@@ -1347,7 +1347,7 @@ static void set_wqname(struct mlx5_core_dev *dev)
        struct mlx5_cmd *cmd = &dev->cmd;
 
        snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s",
-                dev->priv.name);
+                dev_name(dev->device));
 }
 
 static void clean_debug_files(struct mlx5_core_dev *dev)
index 7b5901d42994fe18da6b18c4bdc6414e742042db..3038be575923b36aeee6e441be376aca4177507d 100644 (file)
@@ -47,7 +47,7 @@ TRACE_EVENT(mlx5_fw,
        TP_ARGS(tracer, trace_timestamp, lost, event_id, msg),
 
        TP_STRUCT__entry(
-               __string(dev_name, tracer->dev->priv.name)
+               __string(dev_name, dev_name(tracer->dev->device))
                __field(u64, trace_timestamp)
                __field(bool, lost)
                __field(u8, event_id)
@@ -55,7 +55,8 @@ TRACE_EVENT(mlx5_fw,
        ),
 
        TP_fast_assign(
-               __assign_str(dev_name, tracer->dev->priv.name);
+               __assign_str(dev_name,
+                            dev_name(tracer->dev->device));
                __entry->trace_timestamp = trace_timestamp;
                __entry->lost = lost;
                __entry->event_id = event_id;
index b4967a0ff8c7ba6ce51826e4ae61964a52bfebb5..a40e801cf713baa3cedeb6b8cf5a5ef5722f448e 100644 (file)
@@ -663,7 +663,8 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv,
        }
 
        netdev_dbg(priv->netdev, "add hairpin: tirn %x rqn %x peer %s sqn %x prio %d (log) data %d packets %d\n",
-                  hp->tirn, hp->pair->rqn[0], hp->pair->peer_mdev->priv.name,
+                  hp->tirn, hp->pair->rqn[0],
+                  dev_name(hp->pair->peer_mdev->device),
                   hp->pair->sqn[0], match_prio, params.log_data_size, params.log_num_packets);
 
        hpe->hp = hp;
@@ -700,7 +701,7 @@ static void mlx5e_hairpin_flow_del(struct mlx5e_priv *priv,
                hpe = list_entry(next, struct mlx5e_hairpin_entry, flows);
 
                netdev_dbg(priv->netdev, "del hairpin: peer %s\n",
-                          hpe->hp->pair->peer_mdev->priv.name);
+                          dev_name(hpe->hp->pair->peer_mdev->device));
 
                mlx5e_hairpin_destroy(hpe->hp);
                hash_del(&hpe->hairpin_hlist);
index 3f3cd32ae60a26c5544e15453ef9efcc6364d166..c1d6bb90cf04e0bb94b147797d0c29b0fb76e28a 100644 (file)
@@ -376,11 +376,11 @@ bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0,
 
 #define MLX5_DEBUG_ESWITCH_MASK BIT(3)
 
-#define esw_info(dev, format, ...)                             \
-       pr_info("(%s): E-Switch: " format, (dev)->priv.name, ##__VA_ARGS__)
+#define esw_info(__dev, format, ...)                   \
+       dev_info((__dev)->device, "E-Switch: " format, ##__VA_ARGS__)
 
-#define esw_warn(dev, format, ...)                             \
-       pr_warn("(%s): E-Switch: " format, (dev)->priv.name, ##__VA_ARGS__)
+#define esw_warn(__dev, format, ...)                   \
+       dev_warn((__dev)->device, "E-Switch: " format, ##__VA_ARGS__)
 
 #define esw_debug(dev, format, ...)                            \
        mlx5_core_dbg_mask(dev, MLX5_DEBUG_ESWITCH_MASK, format, ##__VA_ARGS__)
index 3b98fcdd7d0e4c9911668f857b5ec55b5737de8e..a2656f4008d9162b87ff2fc1f5639fcf8d3d4dda 100644 (file)
@@ -380,7 +380,7 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
                return -ENOMEM;
 
        strcpy(name, "mlx5_health");
-       strcat(name, dev->priv.name);
+       strcat(name, dev_name(dev->device));
        health->wq = create_singlethread_workqueue(name);
        kfree(name);
        if (!health->wq)
index b200a29d142057cd4e407b61fdccb1df074a01e2..bedf809737b5283eee1ec1101b30644e8aece3e9 100644 (file)
@@ -741,7 +741,6 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev,
        struct mlx5_priv *priv = &dev->priv;
        int err = 0;
 
-       dev->pdev = pdev;
        priv->pci_dev_data = id->driver_data;
 
        pci_set_drvdata(dev->pdev, dev);
@@ -1242,14 +1241,11 @@ static const struct devlink_ops mlx5_devlink_ops = {
 #endif
 };
 
-static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx, const char *name)
+static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
 {
        struct mlx5_priv *priv = &dev->priv;
        int err;
 
-       strncpy(priv->name, name, MLX5_MAX_NAME_LEN);
-       priv->name[MLX5_MAX_NAME_LEN - 1] = 0;
-
        dev->profile = &profile[profile_idx];
 
        INIT_LIST_HEAD(&priv->ctx_list);
@@ -1267,9 +1263,10 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx, const char
        INIT_LIST_HEAD(&priv->pgdir_list);
        spin_lock_init(&priv->mkey_lock);
 
-       priv->dbg_root = debugfs_create_dir(name, mlx5_debugfs_root);
+       priv->dbg_root = debugfs_create_dir(dev_name(dev->device),
+                                           mlx5_debugfs_root);
        if (!priv->dbg_root) {
-               pr_err("mlx5_core: %s error, Cannot create debugfs dir, aborting\n", name);
+               dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
                return -ENOMEM;
        }
 
@@ -1312,8 +1309,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        }
 
        dev = devlink_priv(devlink);
+       dev->device = &pdev->dev;
+       dev->pdev = pdev;
 
-       err = mlx5_mdev_init(dev, prof_sel, dev_name(&pdev->dev));
+       err = mlx5_mdev_init(dev, prof_sel);
        if (err)
                goto mdev_init_err;
 
index d66f4f082ef7914cfbbc5966e936e9b5802990a5..0e111b70c178cc1baa3984b79c23a46f3c99f358 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/ptp_clock_kernel.h>
 #include <linux/mlx5/cq.h>
 #include <linux/mlx5/fs.h>
+#include <linux/mlx5/driver.h>
 
 #define DRIVER_NAME "mlx5_core"
 #define DRIVER_VERSION "5.0-0"
 extern uint mlx5_core_debug_mask;
 
 #define mlx5_core_dbg(__dev, format, ...)                              \
-       pr_debug("%s:%s:%d:(pid %d): " format, (__dev)->priv.name,      \
+       dev_dbg((__dev)->device, "%s:%d:(pid %d): " format,             \
                 __func__, __LINE__, current->pid,                      \
                 ##__VA_ARGS__)
 
-#define mlx5_core_dbg_once(__dev, format, ...)                         \
-       pr_debug_once("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
-                    __func__, __LINE__, current->pid,                  \
+#define mlx5_core_dbg_once(__dev, format, ...)         \
+       dev_dbg_once((__dev)->device,           \
+                    "%s:%d:(pid %d): " format,         \
+                    __func__, __LINE__, current->pid,  \
                     ##__VA_ARGS__)
 
-#define mlx5_core_dbg_mask(__dev, mask, format, ...)                   \
-do {                                                                   \
-       if ((mask) & mlx5_core_debug_mask)                              \
-               mlx5_core_dbg(__dev, format, ##__VA_ARGS__);            \
+#define mlx5_core_dbg_mask(__dev, mask, format, ...)           \
+do {                                                           \
+       if ((mask) & mlx5_core_debug_mask)                      \
+               mlx5_core_dbg(__dev, format, ##__VA_ARGS__);    \
 } while (0)
 
-#define mlx5_core_err(__dev, format, ...)                              \
-       pr_err("%s:%s:%d:(pid %d): " format, (__dev)->priv.name,        \
-               __func__, __LINE__, current->pid,       \
+#define mlx5_core_err(__dev, format, ...)                      \
+       dev_err((__dev)->device, "%s:%d:(pid %d): " format,     \
+               __func__, __LINE__, current->pid,               \
               ##__VA_ARGS__)
 
-#define mlx5_core_err_rl(__dev, format, ...)                                \
-       pr_err_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
-                          __func__, __LINE__, current->pid,                 \
-                          ##__VA_ARGS__)
+#define mlx5_core_err_rl(__dev, format, ...)                   \
+       dev_err_ratelimited((__dev)->device,                    \
+                           "%s:%d:(pid %d): " format,          \
+                           __func__, __LINE__, current->pid,   \
+                           ##__VA_ARGS__)
 
-#define mlx5_core_warn(__dev, format, ...)                             \
-       pr_warn("%s:%s:%d:(pid %d): " format, (__dev)->priv.name,       \
-                __func__, __LINE__, current->pid,                      \
-               ##__VA_ARGS__)
+#define mlx5_core_warn(__dev, format, ...)                     \
+       dev_warn((__dev)->device, "%s:%d:(pid %d): " format,    \
+                __func__, __LINE__, current->pid,              \
+                ##__VA_ARGS__)
 
 #define mlx5_core_warn_once(__dev, format, ...)                                \
-       pr_warn_once("%s:%s:%d:(pid %d): " format, (__dev)->priv.name,  \
+       dev_warn_once((__dev)->device, "%s:%d:(pid %d): " format,       \
                      __func__, __LINE__, current->pid,                 \
                      ##__VA_ARGS__)
 
-#define mlx5_core_warn_rl(__dev, format, ...)                                \
-       pr_warn_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
-                          __func__, __LINE__, current->pid,                  \
-                          ##__VA_ARGS__)
+#define mlx5_core_warn_rl(__dev, format, ...)                  \
+       dev_warn_ratelimited((__dev)->device,                   \
+                            "%s:%d:(pid %d): " format,         \
+                            __func__, __LINE__, current->pid,  \
+                            ##__VA_ARGS__)
 
-#define mlx5_core_info(__dev, format, ...)                             \
-       pr_info("%s " format, (__dev)->priv.name, ##__VA_ARGS__)
+#define mlx5_core_info(__dev, format, ...)             \
+       dev_info((__dev)->device, format, ##__VA_ARGS__)
 
-#define mlx5_core_info_rl(__dev, format, ...)                                \
-       pr_info_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
-                          __func__, __LINE__, current->pid,                  \
-                          ##__VA_ARGS__)
+#define mlx5_core_info_rl(__dev, format, ...)                  \
+       dev_info_ratelimited((__dev)->device,                   \
+                            "%s:%d:(pid %d): " format,         \
+                            __func__, __LINE__, current->pid,  \
+                            ##__VA_ARGS__)
 
 enum {
        MLX5_CMD_DATA, /* print command payload only */
index 41025387ff2c170c0790bb64f2a73e1fd0f8f267..d87d42f4f6ddba54c0ea5157e5d4e866195b7f43 100644 (file)
@@ -600,8 +600,7 @@ int mlx5_wait_for_pages(struct mlx5_core_dev *dev, int *pages)
                return 0;
        }
 
-       mlx5_core_dbg(dev, "Waiting for %d pages from %s\n", prev_pages,
-                     dev->priv.name);
+       mlx5_core_dbg(dev, "Waiting for %d pages\n", prev_pages);
        while (*pages) {
                if (time_after(jiffies, end)) {
                        mlx5_core_warn(dev, "aborting while there are %d pending pages\n", *pages);
@@ -614,6 +613,6 @@ int mlx5_wait_for_pages(struct mlx5_core_dev *dev, int *pages)
                msleep(50);
        }
 
-       mlx5_core_dbg(dev, "All pages received from %s\n", dev->priv.name);
+       mlx5_core_dbg(dev, "All pages received\n");
        return 0;
 }
index 6c43191c0186c6cf595a7a2b1620831a1f2ebeca..582a9680b182f06377551a5db279b18883ae1678 100644 (file)
@@ -56,7 +56,6 @@
 
 enum {
        MLX5_BOARD_ID_LEN = 64,
-       MLX5_MAX_NAME_LEN = 16,
 };
 
 enum {
@@ -514,7 +513,6 @@ struct mlx5_rl_table {
 };
 
 struct mlx5_priv {
-       char                    name[MLX5_MAX_NAME_LEN];
        struct mlx5_eq_table    *eq_table;
 
        /* pages stuff */
@@ -641,6 +639,7 @@ struct mlx5_fw_tracer;
 struct mlx5_vxlan;
 
 struct mlx5_core_dev {
+       struct device *device;
        struct pci_dev         *pdev;
        /* sync pci state */
        struct mutex            pci_status_mutex;