Lines Matching refs:pgt

32 	mutex_lock(&mlxsw_sp->pgt->lock);
33 index = idr_alloc(&mlxsw_sp->pgt->pgt_idr, NULL, 0,
34 mlxsw_sp->pgt->end_index, GFP_KERNEL);
42 mutex_unlock(&mlxsw_sp->pgt->lock);
46 mutex_unlock(&mlxsw_sp->pgt->lock);
52 mutex_lock(&mlxsw_sp->pgt->lock);
53 WARN_ON(idr_remove(&mlxsw_sp->pgt->pgt_idr, mid_base));
54 mutex_unlock(&mlxsw_sp->pgt->lock);
63 mutex_lock(&mlxsw_sp->pgt->lock);
65 mid_base = idr_get_cursor(&mlxsw_sp->pgt->pgt_idr);
67 err = idr_alloc_cyclic(&mlxsw_sp->pgt->pgt_idr, NULL,
73 mutex_unlock(&mlxsw_sp->pgt->lock);
79 idr_remove(&mlxsw_sp->pgt->pgt_idr, mid_base + i);
80 mutex_unlock(&mlxsw_sp->pgt->lock);
87 struct idr *pgt_idr = &mlxsw_sp->pgt->pgt_idr;
90 mutex_lock(&mlxsw_sp->pgt->lock);
95 mutex_unlock(&mlxsw_sp->pgt->lock);
113 mlxsw_sp_pgt_entry_create(struct mlxsw_sp_pgt *pgt, u16 mid, u16 smpe)
123 ret = idr_replace(&pgt->pgt_idr, pgt_entry, mid);
139 static void mlxsw_sp_pgt_entry_destroy(struct mlxsw_sp_pgt *pgt,
144 pgt_entry = idr_replace(&pgt->pgt_idr, NULL, pgt_entry->index);
152 mlxsw_sp_pgt_entry_get(struct mlxsw_sp_pgt *pgt, u16 mid, u16 smpe)
156 pgt_entry = idr_find(&pgt->pgt_idr, mid);
160 return mlxsw_sp_pgt_entry_create(pgt, mid, smpe);
163 static void mlxsw_sp_pgt_entry_put(struct mlxsw_sp_pgt *pgt, u16 mid)
167 pgt_entry = idr_find(&pgt->pgt_idr, mid);
172 mlxsw_sp_pgt_entry_destroy(pgt, pgt_entry);
195 mlxsw_sp->pgt->smpe_index_valid,
252 mutex_lock(&mlxsw_sp->pgt->lock);
254 pgt_entry = mlxsw_sp_pgt_entry_get(mlxsw_sp->pgt, mid, smpe);
267 mutex_unlock(&mlxsw_sp->pgt->lock);
271 mlxsw_sp_pgt_entry_put(mlxsw_sp->pgt, mid);
273 mutex_unlock(&mlxsw_sp->pgt->lock);
283 mutex_lock(&mlxsw_sp->pgt->lock);
285 pgt_entry = idr_find(&mlxsw_sp->pgt->pgt_idr, mid);
294 mlxsw_sp_pgt_entry_put(mlxsw_sp->pgt, mid);
297 mutex_unlock(&mlxsw_sp->pgt->lock);
313 struct mlxsw_sp_pgt *pgt;
318 pgt = kzalloc(sizeof(*mlxsw_sp->pgt), GFP_KERNEL);
319 if (!pgt)
322 idr_init(&pgt->pgt_idr);
323 pgt->end_index = MLXSW_CORE_RES_GET(mlxsw_sp->core, PGT_SIZE);
324 mutex_init(&pgt->lock);
325 pgt->smpe_index_valid = mlxsw_sp->pgt_smpe_index_valid;
326 mlxsw_sp->pgt = pgt;
332 mutex_destroy(&mlxsw_sp->pgt->lock);
333 WARN_ON(!idr_is_empty(&mlxsw_sp->pgt->pgt_idr));
334 idr_destroy(&mlxsw_sp->pgt->pgt_idr);
335 kfree(mlxsw_sp->pgt);