Lines Matching +full:offset +full:- +full:x
1 // SPDX-License-Identifier: GPL-2.0
35 return single_open(file, __space ## _show, inode->i_private); \
62 return ERR_PTR(-EINVAL); in validate_and_copy_from_user()
65 return ERR_PTR(-EFAULT); in validate_and_copy_from_user()
69 return ERR_PTR(-ENOMEM); in validate_and_copy_from_user()
74 return ERR_PTR(-EFAULT); in validate_and_copy_from_user()
94 * Short format is: offset value\n in parse_line()
97 * offset relative_offset cap_id vs_cap_id value\n in parse_line()
101 * Short format is: offset\n in parse_line()
104 * offset relative_offset counter_id value\n in parse_line()
111 *val = v[short_fmt_len - 1]; in parse_line()
115 *val = v[long_fmt_len - 1]; in parse_line()
127 struct tb *tb = sw->tb; in regs_write()
129 u32 val, offset; in regs_write() local
136 pm_runtime_get_sync(&sw->dev); in regs_write()
138 if (mutex_lock_interruptible(&tb->lock)) { in regs_write()
139 ret = -ERESTARTSYS; in regs_write()
147 while (parse_line(&line, &offset, &val, 2, 5)) { in regs_write()
149 ret = tb_port_write(port, &val, TB_CFG_PORT, offset, 1); in regs_write()
151 ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, offset, 1); in regs_write()
156 mutex_unlock(&tb->lock); in regs_write()
159 pm_runtime_mark_last_busy(&sw->dev); in regs_write()
160 pm_runtime_put_autosuspend(&sw->dev); in regs_write()
169 struct seq_file *s = file->private_data; in port_regs_write()
170 struct tb_port *port = s->private; in port_regs_write()
172 return regs_write(port->sw, port, user_buf, count, ppos); in port_regs_write()
178 struct seq_file *s = file->private_data; in switch_regs_write()
179 struct tb_switch *sw = s->private; in switch_regs_write()
195 buf = kcalloc(COUNTER_SET_LEN * port->config.max_counters, sizeof(u32), in port_clear_all_counters()
198 return -ENOMEM; in port_clear_all_counters()
201 COUNTER_SET_LEN * port->config.max_counters); in port_clear_all_counters()
210 struct seq_file *s = file->private_data; in counters_write()
211 struct tb_port *port = s->private; in counters_write()
212 struct tb_switch *sw = port->sw; in counters_write()
213 struct tb *tb = port->sw->tb; in counters_write()
221 pm_runtime_get_sync(&sw->dev); in counters_write()
223 if (mutex_lock_interruptible(&tb->lock)) { in counters_write()
224 ret = -ERESTARTSYS; in counters_write()
233 u32 val, offset; in counters_write() local
235 ret = -EINVAL; in counters_write()
236 while (parse_line(&line, &offset, &val, 1, 4)) { in counters_write()
238 offset, 1); in counters_write()
244 mutex_unlock(&tb->lock); in counters_write()
247 pm_runtime_mark_last_busy(&sw->dev); in counters_write()
248 pm_runtime_put_autosuspend(&sw->dev); in counters_write()
256 unsigned int offset, u8 cap_id, u8 vsec_id, in cap_show_by_dw() argument
264 ret = tb_port_read(port, &data, TB_CFG_PORT, cap + offset + i, 1); in cap_show_by_dw()
266 ret = tb_sw_read(sw, &data, TB_CFG_SWITCH, cap + offset + i, 1); in cap_show_by_dw()
268 seq_printf(s, "0x%04x <not accessible>\n", cap + offset + i); in cap_show_by_dw()
272 seq_printf(s, "0x%04x %4d 0x%02x 0x%02x 0x%08x\n", cap + offset + i, in cap_show_by_dw()
273 offset + i, cap_id, vsec_id, data); in cap_show_by_dw()
281 int ret, offset = 0; in cap_show() local
288 ret = tb_port_read(port, data, TB_CFG_PORT, cap + offset, in cap_show()
291 ret = tb_sw_read(sw, data, TB_CFG_SWITCH, cap + offset, dwords); in cap_show()
293 cap_show_by_dw(s, sw, port, cap, offset, cap_id, vsec_id, length); in cap_show()
298 seq_printf(s, "0x%04x %4d 0x%02x 0x%02x 0x%08x\n", in cap_show()
299 cap + offset + i, offset + i, in cap_show()
303 length -= dwords; in cap_show()
304 offset += dwords; in cap_show()
318 seq_printf(s, "0x%04x <capability read failed>\n", cap); in port_cap_show()
344 seq_printf(s, "0x%04x <unsupported capability 0x%02x>\n", in port_cap_show()
355 seq_printf(s, "0x%04x <capability read failed>\n", in port_cap_show()
372 seq_printf(s, "0x%04x <unsupported capability 0x%02x>\n", in port_cap_show()
401 seq_printf(s, "0x%04x %4d 0x00 0x00 0x%08x\n", i, i, data[i]); in port_basic_regs_show()
408 struct tb_port *port = s->private; in port_regs_show()
409 struct tb_switch *sw = port->sw; in port_regs_show()
410 struct tb *tb = sw->tb; in port_regs_show()
413 pm_runtime_get_sync(&sw->dev); in port_regs_show()
415 if (mutex_lock_interruptible(&tb->lock)) { in port_regs_show()
416 ret = -ERESTARTSYS; in port_regs_show()
420 seq_puts(s, "# offset relative_offset cap_id vs_cap_id value\n"); in port_regs_show()
429 mutex_unlock(&tb->lock); in port_regs_show()
431 pm_runtime_mark_last_busy(&sw->dev); in port_regs_show()
432 pm_runtime_put_autosuspend(&sw->dev); in port_regs_show()
447 seq_printf(s, "0x%04x <capability read failed>\n", cap); in switch_cap_show()
456 seq_printf(s, "0x%04x <capability read failed>\n", in switch_cap_show()
469 seq_printf(s, "0x%04x <unknown capability 0x%02x>\n", in switch_cap_show()
506 seq_printf(s, "0x%04x %4d 0x00 0x00 0x%08x\n", i, i, data[i]); in switch_basic_regs_show()
513 struct tb_switch *sw = s->private; in switch_regs_show()
514 struct tb *tb = sw->tb; in switch_regs_show()
517 pm_runtime_get_sync(&sw->dev); in switch_regs_show()
519 if (mutex_lock_interruptible(&tb->lock)) { in switch_regs_show()
520 ret = -ERESTARTSYS; in switch_regs_show()
524 seq_puts(s, "# offset relative_offset cap_id vs_cap_id value\n"); in switch_regs_show()
533 mutex_unlock(&tb->lock); in switch_regs_show()
535 pm_runtime_mark_last_busy(&sw->dev); in switch_regs_show()
536 pm_runtime_put_autosuspend(&sw->dev); in switch_regs_show()
550 seq_printf(s, "0x%04x <not accessible>\n", hopid * PATH_LEN); in path_show_one()
555 seq_printf(s, "0x%04x %4d 0x%02x 0x%08x\n", in path_show_one()
564 struct tb_port *port = s->private; in path_show()
565 struct tb_switch *sw = port->sw; in path_show()
566 struct tb *tb = sw->tb; in path_show()
569 pm_runtime_get_sync(&sw->dev); in path_show()
571 if (mutex_lock_interruptible(&tb->lock)) { in path_show()
572 ret = -ERESTARTSYS; in path_show()
576 seq_puts(s, "# offset relative_offset in_hop_id value\n"); in path_show()
587 for (i = start; i <= port->config.max_in_hop_id; i++) { in path_show()
594 mutex_unlock(&tb->lock); in path_show()
596 pm_runtime_mark_last_busy(&sw->dev); in path_show()
597 pm_runtime_put_autosuspend(&sw->dev); in path_show()
612 seq_printf(s, "0x%04x <not accessible>\n", in counter_set_regs_show()
618 seq_printf(s, "0x%04x %4d 0x%02x 0x%08x\n", in counter_set_regs_show()
627 struct tb_port *port = s->private; in counters_show()
628 struct tb_switch *sw = port->sw; in counters_show()
629 struct tb *tb = sw->tb; in counters_show()
632 pm_runtime_get_sync(&sw->dev); in counters_show()
634 if (mutex_lock_interruptible(&tb->lock)) { in counters_show()
635 ret = -ERESTARTSYS; in counters_show()
639 seq_puts(s, "# offset relative_offset counter_id value\n"); in counters_show()
641 for (i = 0; i < port->config.max_counters; i++) { in counters_show()
647 mutex_unlock(&tb->lock); in counters_show()
650 pm_runtime_mark_last_busy(&sw->dev); in counters_show()
651 pm_runtime_put_autosuspend(&sw->dev); in counters_show()
658 * tb_switch_debugfs_init() - Add debugfs entries for router
668 debugfs_dir = debugfs_create_dir(dev_name(&sw->dev), tb_debugfs_root); in tb_switch_debugfs_init()
669 sw->debugfs_dir = debugfs_dir; in tb_switch_debugfs_init()
677 if (port->disabled) in tb_switch_debugfs_init()
679 if (port->config.type == TB_TYPE_INACTIVE) in tb_switch_debugfs_init()
682 snprintf(dir_name, sizeof(dir_name), "port%d", port->port); in tb_switch_debugfs_init()
683 debugfs_dir = debugfs_create_dir(dir_name, sw->debugfs_dir); in tb_switch_debugfs_init()
688 if (port->config.counters_support) in tb_switch_debugfs_init()
695 * tb_switch_debugfs_remove() - Remove all router debugfs entries
702 debugfs_remove_recursive(sw->debugfs_dir); in tb_switch_debugfs_remove()
706 * tb_service_debugfs_init() - Add debugfs directory for service
713 svc->debugfs_dir = debugfs_create_dir(dev_name(&svc->dev), in tb_service_debugfs_init()
718 * tb_service_debugfs_remove() - Remove service debugfs directory
725 debugfs_remove_recursive(svc->debugfs_dir); in tb_service_debugfs_remove()
726 svc->debugfs_dir = NULL; in tb_service_debugfs_remove()