Lines Matching refs:mlxsw_sp

28 int mlxsw_sp_pgt_mid_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_mid)  in mlxsw_sp_pgt_mid_alloc()  argument
32 mutex_lock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_alloc()
33 index = idr_alloc(&mlxsw_sp->pgt->pgt_idr, NULL, 0, in mlxsw_sp_pgt_mid_alloc()
34 mlxsw_sp->pgt->end_index, GFP_KERNEL); in mlxsw_sp_pgt_mid_alloc()
42 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_alloc()
46 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_alloc()
50 void mlxsw_sp_pgt_mid_free(struct mlxsw_sp *mlxsw_sp, u16 mid_base) in mlxsw_sp_pgt_mid_free() argument
52 mutex_lock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_free()
53 WARN_ON(idr_remove(&mlxsw_sp->pgt->pgt_idr, mid_base)); in mlxsw_sp_pgt_mid_free()
54 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_free()
58 mlxsw_sp_pgt_mid_alloc_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base, u16 count) in mlxsw_sp_pgt_mid_alloc_range() argument
63 mutex_lock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_alloc_range()
70 idr_cursor = idr_get_cursor(&mlxsw_sp->pgt->pgt_idr); in mlxsw_sp_pgt_mid_alloc_range()
77 err = idr_alloc_cyclic(&mlxsw_sp->pgt->pgt_idr, NULL, in mlxsw_sp_pgt_mid_alloc_range()
83 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_alloc_range()
88 idr_remove(&mlxsw_sp->pgt->pgt_idr, mid_base + i); in mlxsw_sp_pgt_mid_alloc_range()
90 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_alloc_range()
95 mlxsw_sp_pgt_mid_free_range(struct mlxsw_sp *mlxsw_sp, u16 mid_base, u16 count) in mlxsw_sp_pgt_mid_free_range() argument
97 struct idr *pgt_idr = &mlxsw_sp->pgt->pgt_idr; in mlxsw_sp_pgt_mid_free_range()
100 mutex_lock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_free_range()
105 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_mid_free_range()
193 mlxsw_sp_pgt_entry_port_write(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_pgt_entry_port_write() argument
205 mlxsw_sp->pgt->smpe_index_valid, in mlxsw_sp_pgt_entry_port_write()
209 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(smid2), smid2_pl); in mlxsw_sp_pgt_entry_port_write()
217 mlxsw_sp_pgt_entry_port_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_pgt_entry_port_create() argument
228 err = mlxsw_sp_pgt_entry_port_write(mlxsw_sp, pgt_entry, local_port, in mlxsw_sp_pgt_entry_port_create()
244 mlxsw_sp_pgt_entry_port_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_pgt_entry_port_destroy() argument
250 mlxsw_sp_pgt_entry_port_write(mlxsw_sp, pgt_entry, in mlxsw_sp_pgt_entry_port_destroy()
255 static int mlxsw_sp_pgt_entry_port_add(struct mlxsw_sp *mlxsw_sp, u16 mid, in mlxsw_sp_pgt_entry_port_add() argument
262 mutex_lock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_entry_port_add()
264 pgt_entry = mlxsw_sp_pgt_entry_get(mlxsw_sp->pgt, mid, smpe); in mlxsw_sp_pgt_entry_port_add()
270 pgt_entry_port = mlxsw_sp_pgt_entry_port_create(mlxsw_sp, pgt_entry, in mlxsw_sp_pgt_entry_port_add()
277 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_entry_port_add()
281 mlxsw_sp_pgt_entry_put(mlxsw_sp->pgt, mid); in mlxsw_sp_pgt_entry_port_add()
283 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_entry_port_add()
287 static void mlxsw_sp_pgt_entry_port_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_pgt_entry_port_del() argument
293 mutex_lock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_entry_port_del()
295 pgt_entry = idr_find(&mlxsw_sp->pgt->pgt_idr, mid); in mlxsw_sp_pgt_entry_port_del()
303 mlxsw_sp_pgt_entry_port_destroy(mlxsw_sp, pgt_entry, pgt_entry_port); in mlxsw_sp_pgt_entry_port_del()
304 mlxsw_sp_pgt_entry_put(mlxsw_sp->pgt, mid); in mlxsw_sp_pgt_entry_port_del()
307 mutex_unlock(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_entry_port_del()
310 int mlxsw_sp_pgt_entry_port_set(struct mlxsw_sp *mlxsw_sp, u16 mid, in mlxsw_sp_pgt_entry_port_set() argument
314 return mlxsw_sp_pgt_entry_port_add(mlxsw_sp, mid, smpe, in mlxsw_sp_pgt_entry_port_set()
317 mlxsw_sp_pgt_entry_port_del(mlxsw_sp, mid, smpe, local_port); in mlxsw_sp_pgt_entry_port_set()
321 int mlxsw_sp_pgt_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_pgt_init() argument
325 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, PGT_SIZE)) in mlxsw_sp_pgt_init()
328 pgt = kzalloc(sizeof(*mlxsw_sp->pgt), GFP_KERNEL); in mlxsw_sp_pgt_init()
333 pgt->end_index = MLXSW_CORE_RES_GET(mlxsw_sp->core, PGT_SIZE); in mlxsw_sp_pgt_init()
335 pgt->smpe_index_valid = mlxsw_sp->pgt_smpe_index_valid; in mlxsw_sp_pgt_init()
336 mlxsw_sp->pgt = pgt; in mlxsw_sp_pgt_init()
340 void mlxsw_sp_pgt_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_pgt_fini() argument
342 mutex_destroy(&mlxsw_sp->pgt->lock); in mlxsw_sp_pgt_fini()
343 WARN_ON(!idr_is_empty(&mlxsw_sp->pgt->pgt_idr)); in mlxsw_sp_pgt_fini()
344 idr_destroy(&mlxsw_sp->pgt->pgt_idr); in mlxsw_sp_pgt_fini()
345 kfree(mlxsw_sp->pgt); in mlxsw_sp_pgt_fini()