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.
Unified · Split
| @@ -1347,7 +1347,7 @@ static void set_wqname(struct mlx5_core_dev *dev) · 1346 unmodified lines | |||
| 1347 | struct mlx5_cmd *cmd = &dev->cmd; | 1347 | struct mlx5_cmd *cmd = &dev->cmd; |
| 1348 | 1348 | ||
| 1349 | snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s", | 1349 | snprintf(cmd->wq_name, sizeof(cmd->wq_name), "mlx5_cmd_%s", |
| 1350 | dev->priv.name); | 1350 | dev_name(dev->device)); |
| 1351 | } | 1351 | } |
| 1352 | 1352 | ||
| 1353 | static void clean_debug_files(struct mlx5_core_dev *dev) | 1353 | static void clean_debug_files(struct mlx5_core_dev *dev) |
| @@ -47,7 +47,7 @@ TRACE_EVENT(mlx5_fw, · 46 unmodified lines | |||
| 47 | TP_ARGS(tracer, trace_timestamp, lost, event_id, msg), | 47 | TP_ARGS(tracer, trace_timestamp, lost, event_id, msg), |
| 48 | 48 | ||
| 49 | TP_STRUCT__entry( | 49 | TP_STRUCT__entry( |
| 50 | __string(dev_name, tracer->dev->priv.name) | 50 | __string(dev_name, dev_name(tracer->dev->device)) |
| 51 | __field(u64, trace_timestamp) | 51 | __field(u64, trace_timestamp) |
| 52 | __field(bool, lost) | 52 | __field(bool, lost) |
| 53 | __field(u8, event_id) | 53 | __field(u8, event_id) |
| @@ -55,7 +55,8 @@ TRACE_EVENT(mlx5_fw, · 1 unmodified line | |||
| 55 | ), | 55 | ), |
| 56 | 56 | ||
| 57 | TP_fast_assign( | 57 | TP_fast_assign( |
| 58 | __assign_str(dev_name, tracer->dev->priv.name); | 58 | __assign_str(dev_name, |
| 59 | dev_name(tracer->dev->device)); | ||
| 59 | __entry->trace_timestamp = trace_timestamp; | 60 | __entry->trace_timestamp = trace_timestamp; |
| 60 | __entry->lost = lost; | 61 | __entry->lost = lost; |
| 61 | __entry->event_id = event_id; | 62 | __entry->event_id = event_id; |
| @@ -663,7 +663,8 @@ static int mlx5e_hairpin_flow_add(struct mlx5e_priv *priv, · 662 unmodified lines | |||
| 663 | } | 663 | } |
| 664 | 664 | ||
| 665 | netdev_dbg(priv->netdev, "add hairpin: tirn %x rqn %x peer %s sqn %x prio %d (log) data %d packets %d\n", | 665 | 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), | ||
| 667 | hp->pair->sqn[0], match_prio, params.log_data_size, params.log_num_packets); | 668 | hp->pair->sqn[0], match_prio, params.log_data_size, params.log_num_packets); |
| 668 | 669 | ||
| 669 | hpe->hp = hp; | 670 | hpe->hp = hp; |
| @@ -700,7 +701,7 @@ static void mlx5e_hairpin_flow_del(struct mlx5e_priv *priv, · 30 unmodified lines | |||
| 700 | hpe = list_entry(next, struct mlx5e_hairpin_entry, flows); | 701 | hpe = list_entry(next, struct mlx5e_hairpin_entry, flows); |
| 701 | 702 | ||
| 702 | netdev_dbg(priv->netdev, "del hairpin: peer %s\n", | 703 | 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)); |
| 704 | 705 | ||
| 705 | mlx5e_hairpin_destroy(hpe->hp); | 706 | mlx5e_hairpin_destroy(hpe->hp); |
| 706 | hash_del(&hpe->hairpin_hlist); | 707 | hash_del(&hpe->hairpin_hlist); |
| @@ -376,11 +376,11 @@ bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0, · 375 unmodified lines | |||
| 376 | 376 | ||
| 377 | #define MLX5_DEBUG_ESWITCH_MASK BIT(3) | 377 | #define MLX5_DEBUG_ESWITCH_MASK BIT(3) |
| 378 | 378 | ||
| 379 | #define esw_info(dev, format, ...) \ | 379 | #define esw_info(__dev, format, ...) \ |
| 380 | pr_info("(%s): E-Switch: " format, (dev)->priv.name, ##__VA_ARGS__) | 380 | dev_info((__dev)->device, "E-Switch: " format, ##__VA_ARGS__) |
| 381 | 381 | ||
| 382 | #define esw_warn(dev, format, ...) \ | 382 | #define esw_warn(__dev, format, ...) \ |
| 383 | pr_warn("(%s): E-Switch: " format, (dev)->priv.name, ##__VA_ARGS__) | 383 | dev_warn((__dev)->device, "E-Switch: " format, ##__VA_ARGS__) |
| 384 | 384 | ||
| 385 | #define esw_debug(dev, format, ...) \ | 385 | #define esw_debug(dev, format, ...) \ |
| 386 | mlx5_core_dbg_mask(dev, MLX5_DEBUG_ESWITCH_MASK, format, ##__VA_ARGS__) | 386 | mlx5_core_dbg_mask(dev, MLX5_DEBUG_ESWITCH_MASK, format, ##__VA_ARGS__) |
| @@ -380,7 +380,7 @@ int mlx5_health_init(struct mlx5_core_dev *dev) · 379 unmodified lines | |||
| 380 | return -ENOMEM; | 380 | return -ENOMEM; |
| 381 | 381 | ||
| 382 | strcpy(name, "mlx5_health"); | 382 | strcpy(name, "mlx5_health"); |
| 383 | strcat(name, dev->priv.name); | 383 | strcat(name, dev_name(dev->device)); |
| 384 | health->wq = create_singlethread_workqueue(name); | 384 | health->wq = create_singlethread_workqueue(name); |
| 385 | kfree(name); | 385 | kfree(name); |
| 386 | if (!health->wq) | 386 | if (!health->wq) |
| @@ -741,7 +741,6 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev, · 740 unmodified lines | |||
| 741 | struct mlx5_priv *priv = &dev->priv; | 741 | struct mlx5_priv *priv = &dev->priv; |
| 742 | int err = 0; | 742 | int err = 0; |
| 743 | 743 | ||
| 744 | dev->pdev = pdev; | ||
| 745 | priv->pci_dev_data = id->driver_data; | 744 | priv->pci_dev_data = id->driver_data; |
| 746 | 745 | ||
| 747 | pci_set_drvdata(dev->pdev, dev); | 746 | pci_set_drvdata(dev->pdev, dev); |
| @@ -1242,14 +1241,11 @@ static const struct devlink_ops mlx5_devlink_ops = { · 494 unmodified lines | |||
| 1242 | #endif | 1241 | #endif |
| 1243 | }; | 1242 | }; |
| 1244 | 1243 | ||
| 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) |
| 1246 | { | 1245 | { |
| 1247 | struct mlx5_priv *priv = &dev->priv; | 1246 | struct mlx5_priv *priv = &dev->priv; |
| 1248 | int err; | 1247 | int err; |
| 1249 | 1248 | ||
| 1250 | strncpy(priv->name, name, MLX5_MAX_NAME_LEN); | ||
| 1251 | priv->name[MLX5_MAX_NAME_LEN - 1] = 0; | ||
| 1252 | |||
| 1253 | dev->profile = &profile[profile_idx]; | 1249 | dev->profile = &profile[profile_idx]; |
| 1254 | 1250 | ||
| 1255 | INIT_LIST_HEAD(&priv->ctx_list); | 1251 | 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 | |||
| 1267 | INIT_LIST_HEAD(&priv->pgdir_list); | 1263 | INIT_LIST_HEAD(&priv->pgdir_list); |
| 1268 | spin_lock_init(&priv->mkey_lock); | 1264 | spin_lock_init(&priv->mkey_lock); |
| 1269 | 1265 | ||
| 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); | ||
| 1271 | if (!priv->dbg_root) { | 1268 | 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"); |
| 1273 | return -ENOMEM; | 1270 | return -ENOMEM; |
| 1274 | } | 1271 | } |
| 1275 | 1272 | ||
| @@ -1312,8 +1309,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id) · 36 unmodified lines | |||
| 1312 | } | 1309 | } |
| 1313 | 1310 | ||
| 1314 | dev = devlink_priv(devlink); | 1311 | dev = devlink_priv(devlink); |
| 1312 | dev->device = &pdev->dev; | ||
| 1313 | dev->pdev = pdev; | ||
| 1315 | 1314 | ||
| 1316 | err = mlx5_mdev_init(dev, prof_sel, dev_name(&pdev->dev)); | 1315 | err = mlx5_mdev_init(dev, prof_sel); |
| 1317 | if (err) | 1316 | if (err) |
| 1318 | goto mdev_init_err; | 1317 | goto mdev_init_err; |
| 1319 | 1318 | ||
| @@ -41,6 +41,7 @@ · 40 unmodified lines | |||
| 41 | #include <linux/ptp_clock_kernel.h> | 41 | #include <linux/ptp_clock_kernel.h> |
| 42 | #include <linux/mlx5/cq.h> | 42 | #include <linux/mlx5/cq.h> |
| 43 | #include <linux/mlx5/fs.h> | 43 | #include <linux/mlx5/fs.h> |
| 44 | #include <linux/mlx5/driver.h> | ||
| 44 | 45 | ||
| 45 | #define DRIVER_NAME "mlx5_core" | 46 | #define DRIVER_NAME "mlx5_core" |
| 46 | #define DRIVER_VERSION "5.0-0" | 47 | #define DRIVER_VERSION "5.0-0" |
| @@ -48,53 +49,57 @@ · 1 unmodified line | |||
| 48 | extern uint mlx5_core_debug_mask; | 49 | extern uint mlx5_core_debug_mask; |
| 49 | 50 | ||
| 50 | #define mlx5_core_dbg(__dev, format, ...) \ | 51 | #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, \ |
| 52 | __func__, __LINE__, current->pid, \ | 53 | __func__, __LINE__, current->pid, \ |
| 53 | ##__VA_ARGS__) | 54 | ##__VA_ARGS__) |
| 54 | 55 | ||
| 55 | #define mlx5_core_dbg_once(__dev, format, ...) \ | 56 | #define mlx5_core_dbg_once(__dev, format, ...) \ |
| 56 | pr_debug_once("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \ | 57 | dev_dbg_once((__dev)->device, \ |
| 57 | __func__, __LINE__, current->pid, \ | 58 | "%s:%d:(pid %d): " format, \ |
| 59 | __func__, __LINE__, current->pid, \ | ||
| 58 | ##__VA_ARGS__) | 60 | ##__VA_ARGS__) |
| 59 | 61 | ||
| 60 | #define mlx5_core_dbg_mask(__dev, mask, format, ...) \ | 62 | #define mlx5_core_dbg_mask(__dev, mask, format, ...) \ |
| 61 | do { \ | 63 | do { \ |
| 62 | if ((mask) & mlx5_core_debug_mask) \ | 64 | if ((mask) & mlx5_core_debug_mask) \ |
| 63 | mlx5_core_dbg(__dev, format, ##__VA_ARGS__); \ | 65 | mlx5_core_dbg(__dev, format, ##__VA_ARGS__); \ |
| 64 | } while (0) | 66 | } while (0) |
| 65 | 67 | ||
| 66 | #define mlx5_core_err(__dev, format, ...) \ | 68 | #define mlx5_core_err(__dev, format, ...) \ |
| 67 | pr_err("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \ | 69 | dev_err((__dev)->device, "%s:%d:(pid %d): " format, \ |
| 68 | __func__, __LINE__, current->pid, \ | 70 | __func__, __LINE__, current->pid, \ |
| 69 | ##__VA_ARGS__) | 71 | ##__VA_ARGS__) |
| 70 | 72 | ||
| 71 | #define mlx5_core_err_rl(__dev, format, ...) \ | 73 | #define mlx5_core_err_rl(__dev, format, ...) \ |
| 72 | pr_err_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \ | 74 | dev_err_ratelimited((__dev)->device, \ |
| 73 | __func__, __LINE__, current->pid, \ | 75 | "%s:%d:(pid %d): " format, \ |
| 74 | ##__VA_ARGS__) | 76 | __func__, __LINE__, current->pid, \ |
| 77 | ##__VA_ARGS__) | ||
| 75 | 78 | ||
| 76 | #define mlx5_core_warn(__dev, format, ...) \ | 79 | #define mlx5_core_warn(__dev, format, ...) \ |
| 77 | pr_warn("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \ | 80 | dev_warn((__dev)->device, "%s:%d:(pid %d): " format, \ |
| 78 | __func__, __LINE__, current->pid, \ | 81 | __func__, __LINE__, current->pid, \ |
| 79 | ##__VA_ARGS__) | 82 | ##__VA_ARGS__) |
| 80 | 83 | ||
| 81 | #define mlx5_core_warn_once(__dev, format, ...) \ | 84 | #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, \ |
| 83 | __func__, __LINE__, current->pid, \ | 86 | __func__, __LINE__, current->pid, \ |
| 84 | ##__VA_ARGS__) | 87 | ##__VA_ARGS__) |
| 85 | 88 | ||
| 86 | #define mlx5_core_warn_rl(__dev, format, ...) \ | 89 | #define mlx5_core_warn_rl(__dev, format, ...) \ |
| 87 | pr_warn_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \ | 90 | dev_warn_ratelimited((__dev)->device, \ |
| 88 | __func__, __LINE__, current->pid, \ | 91 | "%s:%d:(pid %d): " format, \ |
| 89 | ##__VA_ARGS__) | 92 | __func__, __LINE__, current->pid, \ |
| 93 | ##__VA_ARGS__) | ||
| 90 | 94 | ||
| 91 | #define mlx5_core_info(__dev, format, ...) \ | 95 | #define mlx5_core_info(__dev, format, ...) \ |
| 92 | pr_info("%s " format, (__dev)->priv.name, ##__VA_ARGS__) | 96 | dev_info((__dev)->device, format, ##__VA_ARGS__) |
| 93 | 97 | ||
| 94 | #define mlx5_core_info_rl(__dev, format, ...) \ | 98 | #define mlx5_core_info_rl(__dev, format, ...) \ |
| 95 | pr_info_ratelimited("%s:%s:%d:(pid %d): " format, (__dev)->priv.name, \ | 99 | dev_info_ratelimited((__dev)->device, \ |
| 96 | __func__, __LINE__, current->pid, \ | 100 | "%s:%d:(pid %d): " format, \ |
| 97 | ##__VA_ARGS__) | 101 | __func__, __LINE__, current->pid, \ |
| 102 | ##__VA_ARGS__) | ||
| 98 | 103 | ||
| 99 | enum { | 104 | enum { |
| 100 | MLX5_CMD_DATA, /* print command payload only */ | 105 | MLX5_CMD_DATA, /* print command payload only */ |
| @@ -600,8 +600,7 @@ int mlx5_wait_for_pages(struct mlx5_core_dev *dev, int *pages) · 599 unmodified lines | |||
| 600 | return 0; | 600 | return 0; |
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | mlx5_core_dbg(dev, "Waiting for %d pages from %s\n", prev_pages, | 603 | mlx5_core_dbg(dev, "Waiting for %d pages\n", prev_pages); |
| 604 | dev->priv.name); | ||
| 605 | while (*pages) { | 604 | while (*pages) { |
| 606 | if (time_after(jiffies, end)) { | 605 | if (time_after(jiffies, end)) { |
| 607 | mlx5_core_warn(dev, "aborting while there are %d pending pages\n", *pages); | 606 | 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 | |||
| 614 | msleep(50); | 613 | msleep(50); |
| 615 | } | 614 | } |
| 616 | 615 | ||
| 617 | mlx5_core_dbg(dev, "All pages received from %s\n", dev->priv.name); | 616 | mlx5_core_dbg(dev, "All pages received\n"); |
| 618 | return 0; | 617 | return 0; |
| 619 | } | 618 | } |
| @@ -56,7 +56,6 @@ · 55 unmodified lines | |||
| 56 | 56 | ||
| 57 | enum { | 57 | enum { |
| 58 | MLX5_BOARD_ID_LEN = 64, | 58 | MLX5_BOARD_ID_LEN = 64, |
| 59 | MLX5_MAX_NAME_LEN = 16, | ||
| 60 | }; | 59 | }; |
| 61 | 60 | ||
| 62 | enum { | 61 | enum { |
| @@ -514,7 +513,6 @@ struct mlx5_rl_table { · 451 unmodified lines | |||
| 514 | }; | 513 | }; |
| 515 | 514 | ||
| 516 | struct mlx5_priv { | 515 | struct mlx5_priv { |
| 517 | char name[MLX5_MAX_NAME_LEN]; | ||
| 518 | struct mlx5_eq_table *eq_table; | 516 | struct mlx5_eq_table *eq_table; |
| 519 | 517 | ||
| 520 | /* pages stuff */ | 518 | /* pages stuff */ |
| @@ -641,6 +639,7 @@ struct mlx5_fw_tracer; · 120 unmodified lines | |||
| 641 | struct mlx5_vxlan; | 639 | struct mlx5_vxlan; |
| 642 | 640 | ||
| 643 | struct mlx5_core_dev { | 641 | struct mlx5_core_dev { |
| 642 | struct device *device; | ||
| 644 | struct pci_dev *pdev; | 643 | struct pci_dev *pdev; |
| 645 | /* sync pci state */ | 644 | /* sync pci state */ |
| 646 | struct mutex pci_status_mutex; | 645 | struct mutex pci_status_mutex; |