Lines Matching full:region
29 struct devlink_region *region; member
37 struct devlink_region *region; in devlink_region_get_by_name() local
39 list_for_each_entry(region, &devlink->region_list, list) in devlink_region_get_by_name()
40 if (!strcmp(region->ops->name, region_name)) in devlink_region_get_by_name()
41 return region; in devlink_region_get_by_name()
50 struct devlink_region *region; in devlink_port_region_get_by_name() local
52 list_for_each_entry(region, &port->region_list, list) in devlink_port_region_get_by_name()
53 if (!strcmp(region->ops->name, region_name)) in devlink_port_region_get_by_name()
54 return region; in devlink_port_region_get_by_name()
60 devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id) in devlink_region_snapshot_get_by_id() argument
64 list_for_each_entry(snapshot, ®ion->snapshot_list, list) in devlink_region_snapshot_get_by_id()
96 struct devlink_region *region) in devlink_nl_region_snapshots_id_put() argument
107 list_for_each_entry(snapshot, ®ion->snapshot_list, list) { in devlink_nl_region_snapshots_id_put()
124 struct devlink_region *region) in devlink_nl_region_fill() argument
137 if (region->port) { in devlink_nl_region_fill()
139 region->port->index); in devlink_nl_region_fill()
144 err = nla_put_string(msg, DEVLINK_ATTR_REGION_NAME, region->ops->name); in devlink_nl_region_fill()
149 region->size, in devlink_nl_region_fill()
155 region->max_snapshots); in devlink_nl_region_fill()
159 err = devlink_nl_region_snapshots_id_put(msg, devlink, region); in devlink_nl_region_fill()
172 devlink_nl_region_notify_build(struct devlink_region *region, in devlink_nl_region_notify_build() argument
176 struct devlink *devlink = region->devlink; in devlink_nl_region_notify_build()
195 if (region->port) { in devlink_nl_region_notify_build()
197 region->port->index); in devlink_nl_region_notify_build()
203 region->ops->name); in devlink_nl_region_notify_build()
214 region->size, DEVLINK_ATTR_PAD); in devlink_nl_region_notify_build()
229 static void devlink_nl_region_notify(struct devlink_region *region, in devlink_nl_region_notify() argument
233 struct devlink *devlink = region->devlink; in devlink_nl_region_notify()
241 msg = devlink_nl_region_notify_build(region, snapshot, cmd, 0, 0); in devlink_nl_region_notify()
250 struct devlink_region *region; in devlink_regions_notify_register() local
252 list_for_each_entry(region, &devlink->region_list, list) in devlink_regions_notify_register()
253 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW); in devlink_regions_notify_register()
258 struct devlink_region *region; in devlink_regions_notify_unregister() local
260 list_for_each_entry_reverse(region, &devlink->region_list, list) in devlink_regions_notify_unregister()
261 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_DEL); in devlink_regions_notify_unregister()
404 * This will add a new snapshot of a region. The snapshot
405 * will be stored on the region struct and can be accessed
407 * Multiple snapshots can be created on a region.
410 * Must be called only while holding the region snapshot lock.
412 * @region: devlink region of the snapshot
417 __devlink_region_snapshot_create(struct devlink_region *region, in __devlink_region_snapshot_create() argument
420 struct devlink *devlink = region->devlink; in __devlink_region_snapshot_create()
424 lockdep_assert_held(®ion->snapshot_lock); in __devlink_region_snapshot_create()
426 /* check if region can hold one more snapshot */ in __devlink_region_snapshot_create()
427 if (region->cur_snapshots == region->max_snapshots) in __devlink_region_snapshot_create()
430 if (devlink_region_snapshot_get_by_id(region, snapshot_id)) in __devlink_region_snapshot_create()
442 snapshot->region = region; in __devlink_region_snapshot_create()
445 list_add_tail(&snapshot->list, ®ion->snapshot_list); in __devlink_region_snapshot_create()
447 region->cur_snapshots++; in __devlink_region_snapshot_create()
449 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_NEW); in __devlink_region_snapshot_create()
457 static void devlink_region_snapshot_del(struct devlink_region *region, in devlink_region_snapshot_del() argument
460 struct devlink *devlink = region->devlink; in devlink_region_snapshot_del()
462 lockdep_assert_held(®ion->snapshot_lock); in devlink_region_snapshot_del()
464 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_DEL); in devlink_region_snapshot_del()
465 region->cur_snapshots--; in devlink_region_snapshot_del()
467 region->ops->destructor(snapshot->data); in devlink_region_snapshot_del()
476 struct devlink_region *region; in devlink_nl_region_get_doit() local
495 region = devlink_port_region_get_by_name(port, region_name); in devlink_nl_region_get_doit()
497 region = devlink_region_get_by_name(devlink, region_name); in devlink_nl_region_get_doit()
499 if (!region) in devlink_nl_region_get_doit()
508 region); in devlink_nl_region_get_doit()
522 struct devlink_region *region; in devlink_nl_cmd_region_get_port_dumpit() local
525 list_for_each_entry(region, &port->region_list, list) { in devlink_nl_cmd_region_get_port_dumpit()
534 flags, region); in devlink_nl_cmd_region_get_port_dumpit()
550 struct devlink_region *region; in devlink_nl_region_get_dump_one() local
556 list_for_each_entry(region, &devlink->region_list, list) { in devlink_nl_region_get_dump_one()
565 region); in devlink_nl_region_get_dump_one()
596 struct devlink_region *region; in devlink_nl_region_del_doit() local
617 region = devlink_port_region_get_by_name(port, region_name); in devlink_nl_region_del_doit()
619 region = devlink_region_get_by_name(devlink, region_name); in devlink_nl_region_del_doit()
621 if (!region) in devlink_nl_region_del_doit()
624 mutex_lock(®ion->snapshot_lock); in devlink_nl_region_del_doit()
625 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id); in devlink_nl_region_del_doit()
627 mutex_unlock(®ion->snapshot_lock); in devlink_nl_region_del_doit()
631 devlink_region_snapshot_del(region, snapshot); in devlink_nl_region_del_doit()
632 mutex_unlock(®ion->snapshot_lock); in devlink_nl_region_del_doit()
642 struct devlink_region *region; in devlink_nl_region_new_doit() local
650 NL_SET_ERR_MSG(info->extack, "No region name provided"); in devlink_nl_region_new_doit()
665 region = devlink_port_region_get_by_name(port, region_name); in devlink_nl_region_new_doit()
667 region = devlink_region_get_by_name(devlink, region_name); in devlink_nl_region_new_doit()
669 if (!region) { in devlink_nl_region_new_doit()
670 NL_SET_ERR_MSG(info->extack, "The requested region does not exist"); in devlink_nl_region_new_doit()
674 if (!region->ops->snapshot) { in devlink_nl_region_new_doit()
675 …NL_SET_ERR_MSG(info->extack, "The requested region does not support taking an immediate snapshot"); in devlink_nl_region_new_doit()
679 mutex_lock(®ion->snapshot_lock); in devlink_nl_region_new_doit()
681 if (region->cur_snapshots == region->max_snapshots) { in devlink_nl_region_new_doit()
682 NL_SET_ERR_MSG(info->extack, "The region has reached the maximum number of stored snapshots"); in devlink_nl_region_new_doit()
691 if (devlink_region_snapshot_get_by_id(region, snapshot_id)) { in devlink_nl_region_new_doit()
709 err = region->port_ops->snapshot(port, region->port_ops, in devlink_nl_region_new_doit()
712 err = region->ops->snapshot(devlink, region->ops, in devlink_nl_region_new_doit()
717 err = __devlink_region_snapshot_create(region, data, snapshot_id); in devlink_nl_region_new_doit()
724 snapshot = devlink_region_snapshot_get_by_id(region, in devlink_nl_region_new_doit()
731 msg = devlink_nl_region_notify_build(region, snapshot, in devlink_nl_region_new_doit()
744 mutex_unlock(®ion->snapshot_lock); in devlink_nl_region_new_doit()
748 region->ops->destructor(data); in devlink_nl_region_new_doit()
751 mutex_unlock(®ion->snapshot_lock); in devlink_nl_region_new_doit()
755 devlink_region_snapshot_del(region, snapshot); in devlink_nl_region_new_doit()
757 mutex_unlock(®ion->snapshot_lock); in devlink_nl_region_new_doit()
850 struct devlink_region *region = cb_priv; in devlink_region_port_direct_fill() local
852 return region->port_ops->read(region->port, region->port_ops, extack, in devlink_region_port_direct_fill()
860 struct devlink_region *region = cb_priv; in devlink_region_direct_fill() local
862 return region->ops->read(region->devlink, region->ops, extack, in devlink_region_direct_fill()
876 struct devlink_region *region; in devlink_nl_region_read_dumpit() local
892 NL_SET_ERR_MSG(cb->extack, "No region name provided"); in devlink_nl_region_read_dumpit()
911 region = devlink_port_region_get_by_name(port, region_name); in devlink_nl_region_read_dumpit()
913 region = devlink_region_get_by_name(devlink, region_name); in devlink_nl_region_read_dumpit()
915 if (!region) { in devlink_nl_region_read_dumpit()
916 NL_SET_ERR_MSG_ATTR(cb->extack, region_attr, "Requested region does not exist"); in devlink_nl_region_read_dumpit()
929 if (!region->ops->read) { in devlink_nl_region_read_dumpit()
930 NL_SET_ERR_MSG(cb->extack, "Requested region does not support direct read"); in devlink_nl_region_read_dumpit()
939 region_cb_priv = region; in devlink_nl_region_read_dumpit()
945 NL_SET_ERR_MSG_ATTR(cb->extack, snapshot_attr, "Direct region read does not use snapshot"); in devlink_nl_region_read_dumpit()
951 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id); in devlink_nl_region_read_dumpit()
971 if (end_offset > region->size) in devlink_nl_region_read_dumpit()
972 end_offset = region->size; in devlink_nl_region_read_dumpit()
992 if (region->port) { in devlink_nl_region_read_dumpit()
994 region->port->index); in devlink_nl_region_read_dumpit()
1039 * devl_region_create - create a new address region
1042 * @ops: region operations and name
1043 * @region_max_snapshots: Maximum supported number of snapshots for region
1044 * @region_size: size of region
1051 struct devlink_region *region; in devl_region_create() local
1061 region = kzalloc(sizeof(*region), GFP_KERNEL); in devl_region_create()
1062 if (!region) in devl_region_create()
1065 region->devlink = devlink; in devl_region_create()
1066 region->max_snapshots = region_max_snapshots; in devl_region_create()
1067 region->ops = ops; in devl_region_create()
1068 region->size = region_size; in devl_region_create()
1069 INIT_LIST_HEAD(®ion->snapshot_list); in devl_region_create()
1070 mutex_init(®ion->snapshot_lock); in devl_region_create()
1071 list_add_tail(®ion->list, &devlink->region_list); in devl_region_create()
1072 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW); in devl_region_create()
1074 return region; in devl_region_create()
1079 * devlink_region_create - create a new address region
1082 * @ops: region operations and name
1083 * @region_max_snapshots: Maximum supported number of snapshots for region
1084 * @region_size: size of region
1093 struct devlink_region *region; in devlink_region_create() local
1096 region = devl_region_create(devlink, ops, region_max_snapshots, in devlink_region_create()
1099 return region; in devlink_region_create()
1104 * devlink_port_region_create - create a new address region for a port
1107 * @ops: region operations and name
1108 * @region_max_snapshots: Maximum supported number of snapshots for region
1109 * @region_size: size of region
1119 struct devlink_region *region; in devlink_port_region_create() local
1134 region = kzalloc(sizeof(*region), GFP_KERNEL); in devlink_port_region_create()
1135 if (!region) { in devlink_port_region_create()
1140 region->devlink = devlink; in devlink_port_region_create()
1141 region->port = port; in devlink_port_region_create()
1142 region->max_snapshots = region_max_snapshots; in devlink_port_region_create()
1143 region->port_ops = ops; in devlink_port_region_create()
1144 region->size = region_size; in devlink_port_region_create()
1145 INIT_LIST_HEAD(®ion->snapshot_list); in devlink_port_region_create()
1146 mutex_init(®ion->snapshot_lock); in devlink_port_region_create()
1147 list_add_tail(®ion->list, &port->region_list); in devlink_port_region_create()
1148 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW); in devlink_port_region_create()
1151 return region; in devlink_port_region_create()
1160 * devl_region_destroy - destroy address region
1162 * @region: devlink region to destroy
1164 void devl_region_destroy(struct devlink_region *region) in devl_region_destroy() argument
1166 struct devlink *devlink = region->devlink; in devl_region_destroy()
1171 /* Free all snapshots of region */ in devl_region_destroy()
1172 mutex_lock(®ion->snapshot_lock); in devl_region_destroy()
1173 list_for_each_entry_safe(snapshot, ts, ®ion->snapshot_list, list) in devl_region_destroy()
1174 devlink_region_snapshot_del(region, snapshot); in devl_region_destroy()
1175 mutex_unlock(®ion->snapshot_lock); in devl_region_destroy()
1177 list_del(®ion->list); in devl_region_destroy()
1178 mutex_destroy(®ion->snapshot_lock); in devl_region_destroy()
1180 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_DEL); in devl_region_destroy()
1181 kfree(region); in devl_region_destroy()
1186 * devlink_region_destroy - destroy address region
1188 * @region: devlink region to destroy
1192 void devlink_region_destroy(struct devlink_region *region) in devlink_region_destroy() argument
1194 struct devlink *devlink = region->devlink; in devlink_region_destroy()
1197 devl_region_destroy(region); in devlink_region_destroy()
1241 * This will add a new snapshot of a region. The snapshot
1242 * will be stored on the region struct and can be accessed
1244 * Multiple snapshots can be created on a region.
1247 * @region: devlink region of the snapshot
1251 int devlink_region_snapshot_create(struct devlink_region *region, in devlink_region_snapshot_create() argument
1256 mutex_lock(®ion->snapshot_lock); in devlink_region_snapshot_create()
1257 err = __devlink_region_snapshot_create(region, data, snapshot_id); in devlink_region_snapshot_create()
1258 mutex_unlock(®ion->snapshot_lock); in devlink_region_snapshot_create()