.. | .. |
---|
2 | 2 | /* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */ |
---|
3 | 3 | |
---|
4 | 4 | #include <linux/kernel.h> |
---|
| 5 | +#include <linux/mutex.h> |
---|
5 | 6 | #include <net/devlink.h> |
---|
6 | 7 | |
---|
7 | 8 | #include "spectrum.h" |
---|
.. | .. |
---|
210 | 211 | return err; |
---|
211 | 212 | |
---|
212 | 213 | rif_count = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); |
---|
213 | | - rtnl_lock(); |
---|
| 214 | + mutex_lock(&mlxsw_sp->router->lock); |
---|
214 | 215 | i = 0; |
---|
215 | 216 | start_again: |
---|
216 | 217 | err = devlink_dpipe_entry_ctx_prepare(dump_ctx); |
---|
.. | .. |
---|
220 | 221 | for (; i < rif_count; i++) { |
---|
221 | 222 | struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i); |
---|
222 | 223 | |
---|
223 | | - if (!rif) |
---|
| 224 | + if (!rif || !mlxsw_sp_rif_dev(rif)) |
---|
224 | 225 | continue; |
---|
225 | 226 | err = mlxsw_sp_erif_entry_get(mlxsw_sp, &entry, rif, |
---|
226 | 227 | counters_enabled); |
---|
.. | .. |
---|
241 | 242 | devlink_dpipe_entry_ctx_close(dump_ctx); |
---|
242 | 243 | if (i != rif_count) |
---|
243 | 244 | goto start_again; |
---|
244 | | - rtnl_unlock(); |
---|
| 245 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
245 | 246 | |
---|
246 | 247 | devlink_dpipe_entry_clear(&entry); |
---|
247 | 248 | return 0; |
---|
248 | 249 | err_entry_append: |
---|
249 | 250 | err_entry_get: |
---|
250 | 251 | err_ctx_prepare: |
---|
251 | | - rtnl_unlock(); |
---|
| 252 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
252 | 253 | devlink_dpipe_entry_clear(&entry); |
---|
253 | 254 | return err; |
---|
254 | 255 | } |
---|
.. | .. |
---|
258 | 259 | struct mlxsw_sp *mlxsw_sp = priv; |
---|
259 | 260 | int i; |
---|
260 | 261 | |
---|
261 | | - rtnl_lock(); |
---|
| 262 | + mutex_lock(&mlxsw_sp->router->lock); |
---|
262 | 263 | for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { |
---|
263 | 264 | struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i); |
---|
264 | 265 | |
---|
.. | .. |
---|
271 | 272 | mlxsw_sp_rif_counter_free(mlxsw_sp, rif, |
---|
272 | 273 | MLXSW_SP_RIF_COUNTER_EGRESS); |
---|
273 | 274 | } |
---|
274 | | - rtnl_unlock(); |
---|
| 275 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
275 | 276 | return 0; |
---|
276 | 277 | } |
---|
277 | 278 | |
---|
.. | .. |
---|
546 | 547 | int i, j; |
---|
547 | 548 | int err; |
---|
548 | 549 | |
---|
549 | | - rtnl_lock(); |
---|
| 550 | + mutex_lock(&mlxsw_sp->router->lock); |
---|
550 | 551 | i = 0; |
---|
551 | 552 | rif_count = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); |
---|
552 | 553 | start_again: |
---|
.. | .. |
---|
602 | 603 | if (i != rif_count) |
---|
603 | 604 | goto start_again; |
---|
604 | 605 | |
---|
605 | | - rtnl_unlock(); |
---|
| 606 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
606 | 607 | return 0; |
---|
607 | 608 | |
---|
608 | 609 | err_ctx_prepare: |
---|
609 | 610 | err_entry_append: |
---|
610 | | - rtnl_unlock(); |
---|
| 611 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
611 | 612 | return err; |
---|
612 | 613 | } |
---|
613 | 614 | |
---|
.. | .. |
---|
662 | 663 | { |
---|
663 | 664 | int i; |
---|
664 | 665 | |
---|
665 | | - rtnl_lock(); |
---|
| 666 | + mutex_lock(&mlxsw_sp->router->lock); |
---|
666 | 667 | for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { |
---|
667 | 668 | struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i); |
---|
668 | 669 | struct mlxsw_sp_neigh_entry *neigh_entry; |
---|
.. | .. |
---|
684 | 685 | enable); |
---|
685 | 686 | } |
---|
686 | 687 | } |
---|
687 | | - rtnl_unlock(); |
---|
| 688 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
688 | 689 | } |
---|
689 | 690 | |
---|
690 | 691 | static int mlxsw_sp_dpipe_table_host4_counters_update(void *priv, bool enable) |
---|
.. | .. |
---|
701 | 702 | u64 size = 0; |
---|
702 | 703 | int i; |
---|
703 | 704 | |
---|
704 | | - rtnl_lock(); |
---|
| 705 | + mutex_lock(&mlxsw_sp->router->lock); |
---|
705 | 706 | for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { |
---|
706 | 707 | struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i); |
---|
707 | 708 | struct mlxsw_sp_neigh_entry *neigh_entry; |
---|
.. | .. |
---|
721 | 722 | size++; |
---|
722 | 723 | } |
---|
723 | 724 | } |
---|
724 | | - rtnl_unlock(); |
---|
| 725 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
725 | 726 | |
---|
726 | 727 | return size; |
---|
727 | 728 | } |
---|
.. | .. |
---|
1093 | 1094 | int j; |
---|
1094 | 1095 | int err; |
---|
1095 | 1096 | |
---|
1096 | | - rtnl_lock(); |
---|
| 1097 | + mutex_lock(&mlxsw_sp->router->lock); |
---|
1097 | 1098 | nh_count_max = mlxsw_sp_dpipe_table_adj_size(mlxsw_sp); |
---|
1098 | 1099 | start_again: |
---|
1099 | 1100 | err = devlink_dpipe_entry_ctx_prepare(dump_ctx); |
---|
.. | .. |
---|
1130 | 1131 | devlink_dpipe_entry_ctx_close(dump_ctx); |
---|
1131 | 1132 | if (nh_count != nh_count_max) |
---|
1132 | 1133 | goto start_again; |
---|
1133 | | - rtnl_unlock(); |
---|
| 1134 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
1134 | 1135 | |
---|
1135 | 1136 | return 0; |
---|
1136 | 1137 | |
---|
1137 | 1138 | err_ctx_prepare: |
---|
1138 | 1139 | err_entry_append: |
---|
1139 | | - rtnl_unlock(); |
---|
| 1140 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
1140 | 1141 | return err; |
---|
1141 | 1142 | } |
---|
1142 | 1143 | |
---|
.. | .. |
---|
1206 | 1207 | struct mlxsw_sp *mlxsw_sp = priv; |
---|
1207 | 1208 | u64 size; |
---|
1208 | 1209 | |
---|
1209 | | - rtnl_lock(); |
---|
| 1210 | + mutex_lock(&mlxsw_sp->router->lock); |
---|
1210 | 1211 | size = mlxsw_sp_dpipe_table_adj_size(mlxsw_sp); |
---|
1211 | | - rtnl_unlock(); |
---|
| 1212 | + mutex_unlock(&mlxsw_sp->router->lock); |
---|
1212 | 1213 | |
---|
1213 | 1214 | return size; |
---|
1214 | 1215 | } |
---|