Lines Matching refs:pgt

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()
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()
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()
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()
123 mlxsw_sp_pgt_entry_create(struct mlxsw_sp_pgt *pgt, u16 mid, u16 smpe) in mlxsw_sp_pgt_entry_create() argument
133 ret = idr_replace(&pgt->pgt_idr, pgt_entry, mid); in mlxsw_sp_pgt_entry_create()
149 static void mlxsw_sp_pgt_entry_destroy(struct mlxsw_sp_pgt *pgt, in mlxsw_sp_pgt_entry_destroy() argument
154 pgt_entry = idr_replace(&pgt->pgt_idr, NULL, pgt_entry->index); in mlxsw_sp_pgt_entry_destroy()
162 mlxsw_sp_pgt_entry_get(struct mlxsw_sp_pgt *pgt, u16 mid, u16 smpe) in mlxsw_sp_pgt_entry_get() argument
166 pgt_entry = idr_find(&pgt->pgt_idr, mid); in mlxsw_sp_pgt_entry_get()
170 return mlxsw_sp_pgt_entry_create(pgt, mid, smpe); in mlxsw_sp_pgt_entry_get()
173 static void mlxsw_sp_pgt_entry_put(struct mlxsw_sp_pgt *pgt, u16 mid) in mlxsw_sp_pgt_entry_put() argument
177 pgt_entry = idr_find(&pgt->pgt_idr, mid); in mlxsw_sp_pgt_entry_put()
182 mlxsw_sp_pgt_entry_destroy(pgt, pgt_entry); in mlxsw_sp_pgt_entry_put()
205 mlxsw_sp->pgt->smpe_index_valid, in mlxsw_sp_pgt_entry_port_write()
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()
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()
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()
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()
323 struct mlxsw_sp_pgt *pgt; in mlxsw_sp_pgt_init() local
328 pgt = kzalloc(sizeof(*mlxsw_sp->pgt), GFP_KERNEL); in mlxsw_sp_pgt_init()
329 if (!pgt) in mlxsw_sp_pgt_init()
332 idr_init(&pgt->pgt_idr); in mlxsw_sp_pgt_init()
333 pgt->end_index = MLXSW_CORE_RES_GET(mlxsw_sp->core, PGT_SIZE); in mlxsw_sp_pgt_init()
334 mutex_init(&pgt->lock); 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()
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()