diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2014-02-23 07:19:10 -0500 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-03-07 14:26:49 -0500 |
commit | 3bcdb17a5e88288ead90be3c107e754a6075a5b0 (patch) | |
tree | 622f8951b185bc090d4b0943786e5cb504f105e6 /drivers/net | |
parent | 2ac45934f8700e0c2a579f6ee85a56c6e9ea89d5 (diff) |
IB/mlx5: Keep mlx5 MRs in a radix tree under device
This will be useful when processing signature errors on a specific
key. The mlx5 driver will lookup the matching mlx5 memory region
structure and mark it as dirty (contains signature errors).
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/main.c | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/mr.c | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index a064f06e0cb8..96a0617f7609 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |||
@@ -446,6 +446,7 @@ int mlx5_dev_init(struct mlx5_core_dev *dev, struct pci_dev *pdev) | |||
446 | mlx5_init_cq_table(dev); | 446 | mlx5_init_cq_table(dev); |
447 | mlx5_init_qp_table(dev); | 447 | mlx5_init_qp_table(dev); |
448 | mlx5_init_srq_table(dev); | 448 | mlx5_init_srq_table(dev); |
449 | mlx5_init_mr_table(dev); | ||
449 | 450 | ||
450 | return 0; | 451 | return 0; |
451 | 452 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c b/drivers/net/ethernet/mellanox/mlx5/core/mr.c index bb746bbe73c6..4cc927649404 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mr.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c | |||
@@ -36,11 +36,24 @@ | |||
36 | #include <linux/mlx5/cmd.h> | 36 | #include <linux/mlx5/cmd.h> |
37 | #include "mlx5_core.h" | 37 | #include "mlx5_core.h" |
38 | 38 | ||
39 | void mlx5_init_mr_table(struct mlx5_core_dev *dev) | ||
40 | { | ||
41 | struct mlx5_mr_table *table = &dev->priv.mr_table; | ||
42 | |||
43 | rwlock_init(&table->lock); | ||
44 | INIT_RADIX_TREE(&table->tree, GFP_ATOMIC); | ||
45 | } | ||
46 | |||
47 | void mlx5_cleanup_mr_table(struct mlx5_core_dev *dev) | ||
48 | { | ||
49 | } | ||
50 | |||
39 | int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, | 51 | int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, |
40 | struct mlx5_create_mkey_mbox_in *in, int inlen, | 52 | struct mlx5_create_mkey_mbox_in *in, int inlen, |
41 | mlx5_cmd_cbk_t callback, void *context, | 53 | mlx5_cmd_cbk_t callback, void *context, |
42 | struct mlx5_create_mkey_mbox_out *out) | 54 | struct mlx5_create_mkey_mbox_out *out) |
43 | { | 55 | { |
56 | struct mlx5_mr_table *table = &dev->priv.mr_table; | ||
44 | struct mlx5_create_mkey_mbox_out lout; | 57 | struct mlx5_create_mkey_mbox_out lout; |
45 | int err; | 58 | int err; |
46 | u8 key; | 59 | u8 key; |
@@ -73,14 +86,21 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, | |||
73 | mlx5_core_dbg(dev, "out 0x%x, key 0x%x, mkey 0x%x\n", | 86 | mlx5_core_dbg(dev, "out 0x%x, key 0x%x, mkey 0x%x\n", |
74 | be32_to_cpu(lout.mkey), key, mr->key); | 87 | be32_to_cpu(lout.mkey), key, mr->key); |
75 | 88 | ||
89 | /* connect to MR tree */ | ||
90 | write_lock_irq(&table->lock); | ||
91 | err = radix_tree_insert(&table->tree, mlx5_base_mkey(mr->key), mr); | ||
92 | write_unlock_irq(&table->lock); | ||
93 | |||
76 | return err; | 94 | return err; |
77 | } | 95 | } |
78 | EXPORT_SYMBOL(mlx5_core_create_mkey); | 96 | EXPORT_SYMBOL(mlx5_core_create_mkey); |
79 | 97 | ||
80 | int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) | 98 | int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) |
81 | { | 99 | { |
100 | struct mlx5_mr_table *table = &dev->priv.mr_table; | ||
82 | struct mlx5_destroy_mkey_mbox_in in; | 101 | struct mlx5_destroy_mkey_mbox_in in; |
83 | struct mlx5_destroy_mkey_mbox_out out; | 102 | struct mlx5_destroy_mkey_mbox_out out; |
103 | unsigned long flags; | ||
84 | int err; | 104 | int err; |
85 | 105 | ||
86 | memset(&in, 0, sizeof(in)); | 106 | memset(&in, 0, sizeof(in)); |
@@ -95,6 +115,10 @@ int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) | |||
95 | if (out.hdr.status) | 115 | if (out.hdr.status) |
96 | return mlx5_cmd_status_to_err(&out.hdr); | 116 | return mlx5_cmd_status_to_err(&out.hdr); |
97 | 117 | ||
118 | write_lock_irqsave(&table->lock, flags); | ||
119 | radix_tree_delete(&table->tree, mlx5_base_mkey(mr->key)); | ||
120 | write_unlock_irqrestore(&table->lock, flags); | ||
121 | |||
98 | return err; | 122 | return err; |
99 | } | 123 | } |
100 | EXPORT_SYMBOL(mlx5_core_destroy_mkey); | 124 | EXPORT_SYMBOL(mlx5_core_destroy_mkey); |