Lines Matching full:rel
53 static void devlink_rel_free(struct devlink_rel *rel) in devlink_rel_free() argument
55 xa_erase(&devlink_rels, rel->index); in devlink_rel_free()
56 kfree(rel); in devlink_rel_free()
59 static void __devlink_rel_get(struct devlink_rel *rel) in __devlink_rel_get() argument
61 refcount_inc(&rel->refcount); in __devlink_rel_get()
64 static void __devlink_rel_put(struct devlink_rel *rel) in __devlink_rel_put() argument
66 if (refcount_dec_and_test(&rel->refcount)) in __devlink_rel_put()
67 devlink_rel_free(rel); in __devlink_rel_put()
72 struct devlink_rel *rel = container_of(work, struct devlink_rel, in devlink_rel_nested_in_notify_work() local
76 devlink = devlinks_xa_get(rel->nested_in.devlink_index); in devlink_rel_nested_in_notify_work()
88 if (!xa_get_mark(&devlink_rels, rel->index, DEVLINK_REL_IN_USE)) in devlink_rel_nested_in_notify_work()
89 rel->nested_in.cleanup_cb(devlink, rel->nested_in.obj_index, rel->index); in devlink_rel_nested_in_notify_work()
90 rel->nested_in.notify_cb(devlink, rel->nested_in.obj_index); in devlink_rel_nested_in_notify_work()
95 __devlink_rel_put(rel); in devlink_rel_nested_in_notify_work()
99 schedule_delayed_work(&rel->nested_in.notify_work, 1); in devlink_rel_nested_in_notify_work()
102 static void devlink_rel_nested_in_notify_work_schedule(struct devlink_rel *rel) in devlink_rel_nested_in_notify_work_schedule() argument
104 __devlink_rel_get(rel); in devlink_rel_nested_in_notify_work_schedule()
105 schedule_delayed_work(&rel->nested_in.notify_work, 0); in devlink_rel_nested_in_notify_work_schedule()
110 struct devlink_rel *rel; in devlink_rel_alloc() local
114 rel = kzalloc(sizeof(*rel), GFP_KERNEL); in devlink_rel_alloc()
115 if (!rel) in devlink_rel_alloc()
118 err = xa_alloc_cyclic(&devlink_rels, &rel->index, rel, in devlink_rel_alloc()
121 kfree(rel); in devlink_rel_alloc()
125 refcount_set(&rel->refcount, 1); in devlink_rel_alloc()
126 INIT_DELAYED_WORK(&rel->nested_in.notify_work, in devlink_rel_alloc()
128 return rel; in devlink_rel_alloc()
133 struct devlink_rel *rel = devlink->rel; in devlink_rel_put() local
135 if (!rel) in devlink_rel_put()
137 xa_clear_mark(&devlink_rels, rel->index, DEVLINK_REL_IN_USE); in devlink_rel_put()
138 devlink_rel_nested_in_notify_work_schedule(rel); in devlink_rel_put()
139 __devlink_rel_put(rel); in devlink_rel_put()
140 devlink->rel = NULL; in devlink_rel_put()
153 struct devlink_rel *rel = devlink_rel_alloc(); in devlink_rel_nested_in_add() local
157 if (IS_ERR(rel)) in devlink_rel_nested_in_add()
158 return PTR_ERR(rel); in devlink_rel_nested_in_add()
160 rel->devlink_index = devlink->index; in devlink_rel_nested_in_add()
161 rel->nested_in.devlink_index = devlink_index; in devlink_rel_nested_in_add()
162 rel->nested_in.obj_index = obj_index; in devlink_rel_nested_in_add()
163 rel->nested_in.notify_cb = notify_cb; in devlink_rel_nested_in_add()
164 rel->nested_in.cleanup_cb = cleanup_cb; in devlink_rel_nested_in_add()
165 *rel_index = rel->index; in devlink_rel_nested_in_add()
166 xa_set_mark(&devlink_rels, rel->index, DEVLINK_REL_IN_USE); in devlink_rel_nested_in_add()
167 devlink->rel = rel; in devlink_rel_nested_in_add()
187 struct devlink_rel *rel = devlink->rel; in devlink_rel_nested_in_notify() local
189 if (!rel) in devlink_rel_nested_in_notify()
191 devlink_rel_nested_in_notify_work_schedule(rel); in devlink_rel_nested_in_notify()
202 struct devlink_rel *rel; in devlink_rel_devlink_get() local
208 rel = devlink_rel_find(rel_index); in devlink_rel_devlink_get()
209 if (rel) in devlink_rel_devlink_get()
210 devlink_index = rel->devlink_index; in devlink_rel_devlink_get()
212 if (!rel) in devlink_rel_devlink_get()