aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-11-13 12:51:01 -0500
committerDavid S. Miller <davem@davemloft.net>2016-11-13 12:51:01 -0500
commit9e37aaa39dccad05c3d8883f0790a804e3ec4810 (patch)
tree3574728ce3bf65ab262de17abd6cc03e6dd1cd4a
parenta055450a3340fc0d9a6b39257e6710f121d92385 (diff)
parent42cdb338f40a98e6558bae35456fe86b6e90e1ef (diff)
Merge branch 'mlxsw-fixes'
Jiri Pirko says: ==================== mlxsw: Couple of fixes Please, queue-up both for stable. Thanks! ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c22
2 files changed, 24 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 1ec0a4ce3c46..dda5761e91bc 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -231,7 +231,7 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port)
231 231
232 span_entry->used = true; 232 span_entry->used = true;
233 span_entry->id = index; 233 span_entry->id = index;
234 span_entry->ref_count = 0; 234 span_entry->ref_count = 1;
235 span_entry->local_port = local_port; 235 span_entry->local_port = local_port;
236 return span_entry; 236 return span_entry;
237} 237}
@@ -270,6 +270,7 @@ static struct mlxsw_sp_span_entry
270 270
271 span_entry = mlxsw_sp_span_entry_find(port); 271 span_entry = mlxsw_sp_span_entry_find(port);
272 if (span_entry) { 272 if (span_entry) {
273 /* Already exists, just take a reference */
273 span_entry->ref_count++; 274 span_entry->ref_count++;
274 return span_entry; 275 return span_entry;
275 } 276 }
@@ -280,6 +281,7 @@ static struct mlxsw_sp_span_entry
280static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp, 281static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp,
281 struct mlxsw_sp_span_entry *span_entry) 282 struct mlxsw_sp_span_entry *span_entry)
282{ 283{
284 WARN_ON(!span_entry->ref_count);
283 if (--span_entry->ref_count == 0) 285 if (--span_entry->ref_count == 0)
284 mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry); 286 mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry);
285 return 0; 287 return 0;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 040737e14a3f..cbeeddd70c5a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -800,6 +800,26 @@ static void mlxsw_sp_router_neigh_rec_process(struct mlxsw_sp *mlxsw_sp,
800 } 800 }
801} 801}
802 802
803static bool mlxsw_sp_router_rauhtd_is_full(char *rauhtd_pl)
804{
805 u8 num_rec, last_rec_index, num_entries;
806
807 num_rec = mlxsw_reg_rauhtd_num_rec_get(rauhtd_pl);
808 last_rec_index = num_rec - 1;
809
810 if (num_rec < MLXSW_REG_RAUHTD_REC_MAX_NUM)
811 return false;
812 if (mlxsw_reg_rauhtd_rec_type_get(rauhtd_pl, last_rec_index) ==
813 MLXSW_REG_RAUHTD_TYPE_IPV6)
814 return true;
815
816 num_entries = mlxsw_reg_rauhtd_ipv4_rec_num_entries_get(rauhtd_pl,
817 last_rec_index);
818 if (++num_entries == MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC)
819 return true;
820 return false;
821}
822
803static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp) 823static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
804{ 824{
805 char *rauhtd_pl; 825 char *rauhtd_pl;
@@ -826,7 +846,7 @@ static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
826 for (i = 0; i < num_rec; i++) 846 for (i = 0; i < num_rec; i++)
827 mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl, 847 mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl,
828 i); 848 i);
829 } while (num_rec); 849 } while (mlxsw_sp_router_rauhtd_is_full(rauhtd_pl));
830 rtnl_unlock(); 850 rtnl_unlock();
831 851
832 kfree(rauhtd_pl); 852 kfree(rauhtd_pl);