Lines Matching refs:region

29 	struct devlink_region *region;
37 struct devlink_region *region;
39 list_for_each_entry(region, &devlink->region_list, list)
40 if (!strcmp(region->ops->name, region_name))
41 return region;
50 struct devlink_region *region;
52 list_for_each_entry(region, &port->region_list, list)
53 if (!strcmp(region->ops->name, region_name))
54 return region;
60 devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id)
64 list_for_each_entry(snapshot, &region->snapshot_list, list)
96 struct devlink_region *region)
107 list_for_each_entry(snapshot, &region->snapshot_list, list) {
124 struct devlink_region *region)
137 if (region->port) {
139 region->port->index);
144 err = nla_put_string(msg, DEVLINK_ATTR_REGION_NAME, region->ops->name);
149 region->size,
155 region->max_snapshots);
159 err = devlink_nl_region_snapshots_id_put(msg, devlink, region);
172 devlink_nl_region_notify_build(struct devlink_region *region,
176 struct devlink *devlink = region->devlink;
195 if (region->port) {
197 region->port->index);
203 region->ops->name);
214 region->size, DEVLINK_ATTR_PAD);
229 static void devlink_nl_region_notify(struct devlink_region *region,
233 struct devlink *devlink = region->devlink;
240 msg = devlink_nl_region_notify_build(region, snapshot, cmd, 0, 0);
250 struct devlink_region *region;
252 list_for_each_entry(region, &devlink->region_list, list)
253 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW);
258 struct devlink_region *region;
260 list_for_each_entry_reverse(region, &devlink->region_list, list)
261 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_DEL);
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,
420 struct devlink *devlink = region->devlink;
424 lockdep_assert_held(&region->snapshot_lock);
426 /* check if region can hold one more snapshot */
427 if (region->cur_snapshots == region->max_snapshots)
430 if (devlink_region_snapshot_get_by_id(region, snapshot_id))
442 snapshot->region = region;
445 list_add_tail(&snapshot->list, &region->snapshot_list);
447 region->cur_snapshots++;
449 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_NEW);
457 static void devlink_region_snapshot_del(struct devlink_region *region,
460 struct devlink *devlink = region->devlink;
462 lockdep_assert_held(&region->snapshot_lock);
464 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_DEL);
465 region->cur_snapshots--;
467 region->ops->destructor(snapshot->data);
476 struct devlink_region *region;
495 region = devlink_port_region_get_by_name(port, region_name);
497 region = devlink_region_get_by_name(devlink, region_name);
499 if (!region)
508 region);
522 struct devlink_region *region;
525 list_for_each_entry(region, &port->region_list, list) {
534 flags, region);
550 struct devlink_region *region;
556 list_for_each_entry(region, &devlink->region_list, list) {
565 region);
596 struct devlink_region *region;
617 region = devlink_port_region_get_by_name(port, region_name);
619 region = devlink_region_get_by_name(devlink, region_name);
621 if (!region)
624 mutex_lock(&region->snapshot_lock);
625 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id);
627 mutex_unlock(&region->snapshot_lock);
631 devlink_region_snapshot_del(region, snapshot);
632 mutex_unlock(&region->snapshot_lock);
642 struct devlink_region *region;
650 NL_SET_ERR_MSG(info->extack, "No region name provided");
665 region = devlink_port_region_get_by_name(port, region_name);
667 region = devlink_region_get_by_name(devlink, region_name);
669 if (!region) {
670 NL_SET_ERR_MSG(info->extack, "The requested region does not exist");
674 if (!region->ops->snapshot) {
675 NL_SET_ERR_MSG(info->extack, "The requested region does not support taking an immediate snapshot");
679 mutex_lock(&region->snapshot_lock);
681 if (region->cur_snapshots == region->max_snapshots) {
682 NL_SET_ERR_MSG(info->extack, "The region has reached the maximum number of stored snapshots");
691 if (devlink_region_snapshot_get_by_id(region, snapshot_id)) {
709 err = region->port_ops->snapshot(port, region->port_ops,
712 err = region->ops->snapshot(devlink, region->ops,
717 err = __devlink_region_snapshot_create(region, data, snapshot_id);
724 snapshot = devlink_region_snapshot_get_by_id(region,
731 msg = devlink_nl_region_notify_build(region, snapshot,
744 mutex_unlock(&region->snapshot_lock);
748 region->ops->destructor(data);
751 mutex_unlock(&region->snapshot_lock);
755 devlink_region_snapshot_del(region, snapshot);
757 mutex_unlock(&region->snapshot_lock);
850 struct devlink_region *region = cb_priv;
852 return region->port_ops->read(region->port, region->port_ops, extack,
860 struct devlink_region *region = cb_priv;
862 return region->ops->read(region->devlink, region->ops, extack,
876 struct devlink_region *region;
891 NL_SET_ERR_MSG(cb->extack, "No region name provided");
910 region = devlink_port_region_get_by_name(port, region_name);
912 region = devlink_region_get_by_name(devlink, region_name);
914 if (!region) {
915 NL_SET_ERR_MSG_ATTR(cb->extack, region_attr, "Requested region does not exist");
928 if (!region->ops->read) {
929 NL_SET_ERR_MSG(cb->extack, "Requested region does not support direct read");
938 region_cb_priv = region;
944 NL_SET_ERR_MSG_ATTR(cb->extack, snapshot_attr, "Direct region read does not use snapshot");
950 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id);
970 if (end_offset > region->size)
971 end_offset = region->size;
991 if (region->port) {
993 region->port->index);
1038 * devl_region_create - create a new address region
1041 * @ops: region operations and name
1042 * @region_max_snapshots: Maximum supported number of snapshots for region
1043 * @region_size: size of region
1050 struct devlink_region *region;
1060 region = kzalloc(sizeof(*region), GFP_KERNEL);
1061 if (!region)
1064 region->devlink = devlink;
1065 region->max_snapshots = region_max_snapshots;
1066 region->ops = ops;
1067 region->size = region_size;
1068 INIT_LIST_HEAD(&region->snapshot_list);
1069 mutex_init(&region->snapshot_lock);
1070 list_add_tail(&region->list, &devlink->region_list);
1071 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW);
1073 return region;
1078 * devlink_region_create - create a new address region
1081 * @ops: region operations and name
1082 * @region_max_snapshots: Maximum supported number of snapshots for region
1083 * @region_size: size of region
1092 struct devlink_region *region;
1095 region = devl_region_create(devlink, ops, region_max_snapshots,
1098 return region;
1103 * devlink_port_region_create - create a new address region for a port
1106 * @ops: region operations and name
1107 * @region_max_snapshots: Maximum supported number of snapshots for region
1108 * @region_size: size of region
1118 struct devlink_region *region;
1133 region = kzalloc(sizeof(*region), GFP_KERNEL);
1134 if (!region) {
1139 region->devlink = devlink;
1140 region->port = port;
1141 region->max_snapshots = region_max_snapshots;
1142 region->port_ops = ops;
1143 region->size = region_size;
1144 INIT_LIST_HEAD(&region->snapshot_list);
1145 mutex_init(&region->snapshot_lock);
1146 list_add_tail(&region->list, &port->region_list);
1147 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW);
1150 return region;
1159 * devl_region_destroy - destroy address region
1161 * @region: devlink region to destroy
1163 void devl_region_destroy(struct devlink_region *region)
1165 struct devlink *devlink = region->devlink;
1170 /* Free all snapshots of region */
1171 mutex_lock(&region->snapshot_lock);
1172 list_for_each_entry_safe(snapshot, ts, &region->snapshot_list, list)
1173 devlink_region_snapshot_del(region, snapshot);
1174 mutex_unlock(&region->snapshot_lock);
1176 list_del(&region->list);
1177 mutex_destroy(&region->snapshot_lock);
1179 devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_DEL);
1180 kfree(region);
1185 * devlink_region_destroy - destroy address region
1187 * @region: devlink region to destroy
1191 void devlink_region_destroy(struct devlink_region *region)
1193 struct devlink *devlink = region->devlink;
1196 devl_region_destroy(region);
1240 * This will add a new snapshot of a region. The snapshot
1241 * will be stored on the region struct and can be accessed
1243 * Multiple snapshots can be created on a region.
1246 * @region: devlink region of the snapshot
1250 int devlink_region_snapshot_create(struct devlink_region *region,
1255 mutex_lock(&region->snapshot_lock);
1256 err = __devlink_region_snapshot_create(region, data, snapshot_id);
1257 mutex_unlock(&region->snapshot_lock);