History

net/mlx5: Get rid of storing copy of device name

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.

Parav Pandit committed 7 years ago

Commit 27b942f1 parent 316793f9 files · +57 −53Browse files

Unified · Split

9 files
  1. drivers/net/ethernet/mellanox/mlx5/core/cmd.c +1 −1
  2. drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer_tracepoint.h +3 −2
  3. drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +3 −2
  4. drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +4 −4
  5. drivers/net/ethernet/mellanox/mlx5/core/health.c +1 −1
  6. drivers/net/ethernet/mellanox/mlx5/core/main.c +7 −8
  7. drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +35 −30
  8. drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +2 −3
  9. include/linux/mlx5/driver.h +1 −2
drivers/net/ethernet/mellanox/mlx5/core/cmd.c+1−1
@@ -1347,7 +1347,7 @@ static void set_wqname(struct mlx5_core_dev *dev) · 1346 unmodified lines
13471347 struct mlx5_cmd *cmd = &dev->cmd;
13481348
13491349 snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s",
1350− dev->priv.name);
1350+ dev_name(dev->device));
13511351 }
13521352
13531353 static void clean_debug_files(struct mlx5_core_dev *dev)
drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer_tracepoint.h+3−2
@@ -47,7 +47,7 @@ TRACE_EVENT(mlx5_fw, · 46 unmodified lines
4747 TP_ARGS(tracer, trace_timestamp, lost, event_id, msg),
4848
4949 TP_STRUCT__entry(
50− __string(dev_name, tracer->dev->priv.name)
50+ __string(dev_name, dev_name(tracer->dev->device))
5151 __field(u64, trace_timestamp)
5252 __field(bool, lost)
5353 __field(u8, event_id)
@@ -55,7 +55,8 @@ TRACE_EVENT(mlx5_fw, · 1 unmodified line
5555 ),
5656
5757 TP_fast_assign(
58− __assign_str(dev_name, tracer->dev->priv.name);
58+ __assign_str(dev_name,
59+ dev_name(tracer->dev->device));
5960 __entry->trace_timestamp = trace_timestamp;
6061 __entry->lost = lost;
6162 __entry->event_id = event_id;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c+3−2
@@ -663,7 +663,8 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv, · 662 unmodified lines
663663 }
664664
665665 netdev_dbg(priv->netdev, "add hairpin: tirn %x rqn %x peer %s sqn %x prio %d (log) data %d packets %d\n",
666− hp->tirn, hp->pair->rqn[0], hp->pair->peer_mdev->priv.name,
666+ hp->tirn, hp->pair->rqn[0],
667+ dev_name(hp->pair->peer_mdev->device),
667668 hp->pair->sqn[0], match_prio, params.log_data_size, params.log_num_packets);
668669
669670 hpe->hp = hp;
@@ -700,7 +701,7 @@ static void mlx5e_hairpin_flow_del(struct mlx5e_priv *priv, · 30 unmodified lines
700701 hpe = list_entry(next, struct mlx5e_hairpin_entry, flows);
701702
702703 netdev_dbg(priv->netdev, "del hairpin: peer %s\n",
703− hpe->hp->pair->peer_mdev->priv.name);
704+ dev_name(hpe->hp->pair->peer_mdev->device));
704705
705706 mlx5e_hairpin_destroy(hpe->hp);
706707 hash_del(&hpe->hairpin_hlist);
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h+4−4
@@ -376,11 +376,11 @@ bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0, · 375 unmodified lines
376376
377377 #define MLX5_DEBUG_ESWITCH_MASK BIT(3)
378378
379−#define esw_info(dev, format, ...) \
380− pr_info("(%s): E-Switch: " format, (dev)->priv.name, ##__VA_ARGS__)
379+#define esw_info(__dev, format, ...) \
380+ dev_info((__dev)->device, "E-Switch: " format, ##__VA_ARGS__)
381381
382−#define esw_warn(dev, format, ...) \
383− pr_warn("(%s): E-Switch: " format, (dev)->priv.name, ##__VA_ARGS__)
382+#define esw_warn(__dev, format, ...) \
383+ dev_warn((__dev)->device, "E-Switch: " format, ##__VA_ARGS__)
384384
385385 #define esw_debug(dev, format, ...) \
386386 mlx5_core_dbg_mask(dev, MLX5_DEBUG_ESWITCH_MASK, format, ##__VA_ARGS__)
drivers/net/ethernet/mellanox/mlx5/core/health.c+1−1
@@ -380,7 +380,7 @@ int mlx5_health_init(struct mlx5_core_dev *dev) · 379 unmodified lines
380380 return -ENOMEM;
381381
382382 strcpy(name, "mlx5_health");
383− strcat(name, dev->priv.name);
383+ strcat(name, dev_name(dev->device));
384384 health->wq = create_singlethread_workqueue(name);
385385 kfree(name);
386386 if (!health->wq)
drivers/net/ethernet/mellanox/mlx5/core/main.c+7−8
@@ -741,7 +741,6 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev, · 740 unmodified lines
741741 struct mlx5_priv *priv = &dev->priv;
742742 int err = 0;
743743
744− dev->pdev = pdev;
745744 priv->pci_dev_data = id->driver_data;
746745
747746 pci_set_drvdata(dev->pdev, dev);
@@ -1242,14 +1241,11 @@ static const struct devlink_ops mlx5_devlink_ops = { · 494 unmodified lines
12421241 #endif
12431242 };
12441243
1245−static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx, const char *name)
1244+static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
12461245 {
12471246 struct mlx5_priv *priv = &dev->priv;
12481247 int err;
12491248
1250− strncpy(priv->name, name, MLX5_MAX_NAME_LEN);
1251− priv->name[MLX5_MAX_NAME_LEN - 1] = 0;
1252−
12531249 dev->profile = &profile[profile_idx];
12541250
12551251 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 · 11 unmodified lines
12671263 INIT_LIST_HEAD(&priv->pgdir_list);
12681264 spin_lock_init(&priv->mkey_lock);
12691265
1270− priv->dbg_root = debugfs_create_dir(name, mlx5_debugfs_root);
1266+ priv->dbg_root = debugfs_create_dir(dev_name(dev->device),
1267+ mlx5_debugfs_root);
12711268 if (!priv->dbg_root) {
1272− pr_err("mlx5_core: %s error, Cannot create debugfs dir, aborting\n", name);
1269+ dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
12731270 return -ENOMEM;
12741271 }
12751272
@@ -1312,8 +1309,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id) · 36 unmodified lines
13121309 }
13131310
13141311 dev = devlink_priv(devlink);
1312+ dev->device = &pdev->dev;
1313+ dev->pdev = pdev;
13151314
1316− err = mlx5_mdev_init(dev, prof_sel, dev_name(&pdev->dev));
1315+ err = mlx5_mdev_init(dev, prof_sel);
13171316 if (err)
13181317 goto mdev_init_err;
13191318
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h+35−30
@@ -41,6 +41,7 @@ · 40 unmodified lines
4141 #include <linux/ptp_clock_kernel.h>
4242 #include <linux/mlx5/cq.h>
4343 #include <linux/mlx5/fs.h>
44+#include <linux/mlx5/driver.h>
4445
4546 #define DRIVER_NAME "mlx5_core"
4647 #define DRIVER_VERSION "5.0-0"
@@ -48,53 +49,57 @@ · 1 unmodified line
4849 extern uint mlx5_core_debug_mask;
4950
5051 #define mlx5_core_dbg(__dev, format, ...) \
51− pr_debug("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
52+ dev_dbg((__dev)->device, "%s:%d:(pid %d): " format, \
5253 __func__, __LINE__, current->pid, \
5354 ##__VA_ARGS__)
5455
55−#define mlx5_core_dbg_once(__dev, format, ...) \
56− pr_debug_once("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
57− __func__, __LINE__, current->pid, \
56+#define mlx5_core_dbg_once(__dev, format, ...) \
57+ dev_dbg_once((__dev)->device, \
58+ "%s:%d:(pid %d): " format, \
59+ __func__, __LINE__, current->pid, \
5860 ##__VA_ARGS__)
5961
60−#define mlx5_core_dbg_mask(__dev, mask, format, ...) \
61−do { \
62− if ((mask) & mlx5_core_debug_mask) \
63− mlx5_core_dbg(__dev, format, ##__VA_ARGS__); \
62+#define mlx5_core_dbg_mask(__dev, mask, format, ...) \
63+do { \
64+ if ((mask) & mlx5_core_debug_mask) \
65+ mlx5_core_dbg(__dev, format, ##__VA_ARGS__); \
6466 } while (0)
6567
66−#define mlx5_core_err(__dev, format, ...) \
67− pr_err("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
68− __func__, __LINE__, current->pid, \
68+#define mlx5_core_err(__dev, format, ...) \
69+ dev_err((__dev)->device, "%s:%d:(pid %d): " format, \
70+ __func__, __LINE__, current->pid, \
6971 ##__VA_ARGS__)
7072
71−#define mlx5_core_err_rl(__dev, format, ...) \
72− pr_err_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
73− __func__, __LINE__, current->pid, \
74− ##__VA_ARGS__)
73+#define mlx5_core_err_rl(__dev, format, ...) \
74+ dev_err_ratelimited((__dev)->device, \
75+ "%s:%d:(pid %d): " format, \
76+ __func__, __LINE__, current->pid, \
77+ ##__VA_ARGS__)
7578
76−#define mlx5_core_warn(__dev, format, ...) \
77− pr_warn("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
78− __func__, __LINE__, current->pid, \
79− ##__VA_ARGS__)
79+#define mlx5_core_warn(__dev, format, ...) \
80+ dev_warn((__dev)->device, "%s:%d:(pid %d): " format, \
81+ __func__, __LINE__, current->pid, \
82+ ##__VA_ARGS__)
8083
8184 #define mlx5_core_warn_once(__dev, format, ...) \
82− pr_warn_once("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
85+ dev_warn_once((__dev)->device, "%s:%d:(pid %d): " format, \
8386 __func__, __LINE__, current->pid, \
8487 ##__VA_ARGS__)
8588
86−#define mlx5_core_warn_rl(__dev, format, ...) \
87− pr_warn_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
88− __func__, __LINE__, current->pid, \
89− ##__VA_ARGS__)
89+#define mlx5_core_warn_rl(__dev, format, ...) \
90+ dev_warn_ratelimited((__dev)->device, \
91+ "%s:%d:(pid %d): " format, \
92+ __func__, __LINE__, current->pid, \
93+ ##__VA_ARGS__)
9094
91−#define mlx5_core_info(__dev, format, ...) \
92− pr_info("%s " format, (__dev)->priv.name, ##__VA_ARGS__)
95+#define mlx5_core_info(__dev, format, ...) \
96+ dev_info((__dev)->device, format, ##__VA_ARGS__)
9397
94−#define mlx5_core_info_rl(__dev, format, ...) \
95− pr_info_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \
96− __func__, __LINE__, current->pid, \
97− ##__VA_ARGS__)
98+#define mlx5_core_info_rl(__dev, format, ...) \
99+ dev_info_ratelimited((__dev)->device, \
100+ "%s:%d:(pid %d): " format, \
101+ __func__, __LINE__, current->pid, \
102+ ##__VA_ARGS__)
98103
99104 enum {
100105 MLX5_CMD_DATA, /* print command payload only */
drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c+2−3
@@ -600,8 +600,7 @@ int mlx5_wait_for_pages(struct mlx5_core_dev *dev, int *pages) · 599 unmodified lines
600600 return 0;
601601 }
602602
603− mlx5_core_dbg(dev, "Waiting for %d pages from %s\n", prev_pages,
604− dev->priv.name);
603+ mlx5_core_dbg(dev, "Waiting for %d pages\n", prev_pages);
605604 while (*pages) {
606605 if (time_after(jiffies, end)) {
607606 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) · 6 unmodified lines
614613 msleep(50);
615614 }
616615
617− mlx5_core_dbg(dev, "All pages received from %s\n", dev->priv.name);
616+ mlx5_core_dbg(dev, "All pages received\n");
618617 return 0;
619618 }
include/linux/mlx5/driver.h+1−2
@@ -56,7 +56,6 @@ · 55 unmodified lines
5656
5757 enum {
5858 MLX5_BOARD_ID_LEN = 64,
59− MLX5_MAX_NAME_LEN = 16,
6059 };
6160
6261 enum {
@@ -514,7 +513,6 @@ struct mlx5_rl_table { · 451 unmodified lines
514513 };
515514
516515 struct mlx5_priv {
517− char name[MLX5_MAX_NAME_LEN];
518516 struct mlx5_eq_table *eq_table;
519517
520518 /* pages stuff */
@@ -641,6 +639,7 @@ struct mlx5_fw_tracer; · 120 unmodified lines
641639 struct mlx5_vxlan;
642640
643641 struct mlx5_core_dev {
642+ struct device *device;
644643 struct pci_dev *pdev;
645644 /* sync pci state */
646645 struct mutex pci_status_mutex;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t