Lines Matching refs:nt

155 static void netconsole_target_get(struct netconsole_target *nt)  in netconsole_target_get()  argument
157 if (config_item_name(&nt->group.cg_item)) in netconsole_target_get()
158 config_group_get(&nt->group); in netconsole_target_get()
161 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
163 if (config_item_name(&nt->group.cg_item)) in netconsole_target_put()
164 config_group_put(&nt->group); in netconsole_target_put()
182 static void netconsole_target_get(struct netconsole_target *nt) in netconsole_target_get() argument
186 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
190 static void populate_configfs_item(struct netconsole_target *nt, in populate_configfs_item() argument
201 struct netconsole_target *nt; in alloc_and_init() local
203 nt = kzalloc(sizeof(*nt), GFP_KERNEL); in alloc_and_init()
204 if (!nt) in alloc_and_init()
205 return nt; in alloc_and_init()
208 nt->extended = true; in alloc_and_init()
210 nt->release = true; in alloc_and_init()
212 nt->np.name = "netconsole"; in alloc_and_init()
213 strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); in alloc_and_init()
214 nt->np.local_port = 6665; in alloc_and_init()
215 nt->np.remote_port = 6666; in alloc_and_init()
216 eth_broadcast_addr(nt->np.remote_mac); in alloc_and_init()
218 return nt; in alloc_and_init()
226 struct netconsole_target *nt, *tmp; in netconsole_process_cleanups_core() local
233 list_for_each_entry_safe(nt, tmp, &target_cleanup_list, list) { in netconsole_process_cleanups_core()
235 WARN_ON_ONCE(nt->enabled); in netconsole_process_cleanups_core()
236 do_netpoll_cleanup(&nt->np); in netconsole_process_cleanups_core()
241 list_move(&nt->list, &target_list); in netconsole_process_cleanups_core()
343 struct netconsole_target *nt = to_target(item); in local_ip_show() local
345 if (nt->np.ipv6) in local_ip_show()
346 return sysfs_emit(buf, "%pI6c\n", &nt->np.local_ip.in6); in local_ip_show()
348 return sysfs_emit(buf, "%pI4\n", &nt->np.local_ip); in local_ip_show()
353 struct netconsole_target *nt = to_target(item); in remote_ip_show() local
355 if (nt->np.ipv6) in remote_ip_show()
356 return sysfs_emit(buf, "%pI6c\n", &nt->np.remote_ip.in6); in remote_ip_show()
358 return sysfs_emit(buf, "%pI4\n", &nt->np.remote_ip); in remote_ip_show()
384 struct netconsole_target *nt = to_target(item); in enabled_store() local
395 if (enabled == nt->enabled) { in enabled_store()
397 nt->enabled ? "started" : "stopped"); in enabled_store()
402 if (nt->release && !nt->extended) { in enabled_store()
407 if (nt->extended && !console_is_registered(&netconsole_ext)) in enabled_store()
414 netpoll_print_options(&nt->np); in enabled_store()
416 ret = netpoll_setup(&nt->np); in enabled_store()
420 nt->enabled = true; in enabled_store()
429 nt->enabled = false; in enabled_store()
433 list_move(&nt->list, &target_cleanup_list); in enabled_store()
449 struct netconsole_target *nt = to_target(item); in release_store() local
454 if (nt->enabled) { in release_store()
456 config_item_name(&nt->group.cg_item)); in release_store()
465 nt->release = release; in release_store()
476 struct netconsole_target *nt = to_target(item); in extended_store() local
481 if (nt->enabled) { in extended_store()
483 config_item_name(&nt->group.cg_item)); in extended_store()
492 nt->extended = extended; in extended_store()
502 struct netconsole_target *nt = to_target(item); in dev_name_store() local
505 if (nt->enabled) { in dev_name_store()
507 config_item_name(&nt->group.cg_item)); in dev_name_store()
512 strscpy(nt->np.dev_name, buf, IFNAMSIZ); in dev_name_store()
513 trim_newline(nt->np.dev_name, IFNAMSIZ); in dev_name_store()
522 struct netconsole_target *nt = to_target(item); in local_port_store() local
526 if (nt->enabled) { in local_port_store()
528 config_item_name(&nt->group.cg_item)); in local_port_store()
532 ret = kstrtou16(buf, 10, &nt->np.local_port); in local_port_store()
544 struct netconsole_target *nt = to_target(item); in remote_port_store() local
548 if (nt->enabled) { in remote_port_store()
550 config_item_name(&nt->group.cg_item)); in remote_port_store()
554 ret = kstrtou16(buf, 10, &nt->np.remote_port); in remote_port_store()
566 struct netconsole_target *nt = to_target(item); in local_ip_store() local
570 if (nt->enabled) { in local_ip_store()
572 config_item_name(&nt->group.cg_item)); in local_ip_store()
579 if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { in local_ip_store()
584 nt->np.ipv6 = true; in local_ip_store()
588 if (!nt->np.ipv6) in local_ip_store()
589 nt->np.local_ip.ip = in_aton(buf); in local_ip_store()
603 struct netconsole_target *nt = to_target(item); in remote_ip_store() local
607 if (nt->enabled) { in remote_ip_store()
609 config_item_name(&nt->group.cg_item)); in remote_ip_store()
616 if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { in remote_ip_store()
621 nt->np.ipv6 = true; in remote_ip_store()
625 if (!nt->np.ipv6) in remote_ip_store()
626 nt->np.remote_ip.ip = in_aton(buf); in remote_ip_store()
640 struct netconsole_target *nt = to_target(item); in remote_mac_store() local
645 if (nt->enabled) { in remote_mac_store()
647 config_item_name(&nt->group.cg_item)); in remote_mac_store()
655 memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); in remote_mac_store()
695 static void update_userdata(struct netconsole_target *nt) in update_userdata() argument
701 nt->userdata_length = 0; in update_userdata()
702 nt->userdata_complete[0] = 0; in update_userdata()
704 list_for_each(entry, &nt->userdata_group.cg_children) { in update_userdata()
723 complete_idx += scnprintf(&nt->userdata_complete[complete_idx], in update_userdata()
727 nt->userdata_length = strnlen(nt->userdata_complete, in update_userdata()
728 sizeof(nt->userdata_complete)); in update_userdata()
735 struct netconsole_target *nt; in userdatum_value_store() local
750 nt = userdata_to_target(ud); in userdatum_value_store()
751 update_userdata(nt); in userdatum_value_store()
783 struct netconsole_target *nt; in userdatum_make_item() local
792 nt = userdata_to_target(ud); in userdatum_make_item()
793 child_count = list_count_nodes(&nt->userdata_group.cg_children); in userdatum_make_item()
807 struct netconsole_target *nt; in userdatum_drop() local
811 nt = userdata_to_target(ud); in userdatum_drop()
814 update_userdata(nt); in userdatum_drop()
879 static void init_target_config_group(struct netconsole_target *nt, in init_target_config_group() argument
882 config_group_init_type_name(&nt->group, name, &netconsole_target_type); in init_target_config_group()
883 config_group_init_type_name(&nt->userdata_group, "userdata", in init_target_config_group()
885 configfs_add_default_group(&nt->userdata_group, &nt->group); in init_target_config_group()
890 struct netconsole_target *nt, *ret = NULL; in find_cmdline_target() local
894 list_for_each_entry(nt, &target_list, list) { in find_cmdline_target()
895 if (!strcmp(nt->group.cg_item.ci_name, name)) { in find_cmdline_target()
896 ret = nt; in find_cmdline_target()
912 struct netconsole_target *nt; in make_netconsole_target() local
921 nt = find_cmdline_target(name); in make_netconsole_target()
922 if (nt) { in make_netconsole_target()
923 init_target_config_group(nt, name); in make_netconsole_target()
924 return &nt->group; in make_netconsole_target()
928 nt = alloc_and_init(); in make_netconsole_target()
929 if (!nt) in make_netconsole_target()
933 init_target_config_group(nt, name); in make_netconsole_target()
937 list_add(&nt->list, &target_list); in make_netconsole_target()
940 return &nt->group; in make_netconsole_target()
947 struct netconsole_target *nt = to_target(item); in drop_netconsole_target() local
950 list_del(&nt->list); in drop_netconsole_target()
957 if (nt->enabled) in drop_netconsole_target()
958 netpoll_cleanup(&nt->np); in drop_netconsole_target()
960 config_item_put(&nt->group.cg_item); in drop_netconsole_target()
983 static void populate_configfs_item(struct netconsole_target *nt, in populate_configfs_item() argument
990 init_target_config_group(nt, target_name); in populate_configfs_item()
1000 struct netconsole_target *nt, *tmp; in netconsole_netdev_event() local
1010 list_for_each_entry_safe(nt, tmp, &target_list, list) { in netconsole_netdev_event()
1011 netconsole_target_get(nt); in netconsole_netdev_event()
1012 if (nt->np.dev == dev) { in netconsole_netdev_event()
1015 strscpy(nt->np.dev_name, dev->name, IFNAMSIZ); in netconsole_netdev_event()
1020 nt->enabled = false; in netconsole_netdev_event()
1021 list_move(&nt->list, &target_cleanup_list); in netconsole_netdev_event()
1025 netconsole_target_put(nt); in netconsole_netdev_event()
1071 static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg, in send_ext_msg_udp() argument
1085 userdata = nt->userdata_complete; in send_ext_msg_udp()
1086 userdata_len = nt->userdata_length; in send_ext_msg_udp()
1089 if (nt->release) { in send_ext_msg_udp()
1096 if (nt->release) { in send_ext_msg_udp()
1109 netpoll_send_udp(&nt->np, msg_ready, msg_len); in send_ext_msg_udp()
1127 if (nt->release) in send_ext_msg_udp()
1178 netpoll_send_udp(&nt->np, buf, this_header + this_offset); in send_ext_msg_udp()
1186 struct netconsole_target *nt; in write_ext_msg() local
1193 list_for_each_entry(nt, &target_list, list) in write_ext_msg()
1194 if (nt->extended && nt->enabled && netif_running(nt->np.dev)) in write_ext_msg()
1195 send_ext_msg_udp(nt, msg, len); in write_ext_msg()
1203 struct netconsole_target *nt; in write_msg() local
1213 list_for_each_entry(nt, &target_list, list) { in write_msg()
1214 if (!nt->extended && nt->enabled && netif_running(nt->np.dev)) { in write_msg()
1224 netpoll_send_udp(&nt->np, tmp, frag); in write_msg()
1237 struct netconsole_target *nt; in alloc_param_target() local
1240 nt = alloc_and_init(); in alloc_param_target()
1241 if (!nt) { in alloc_param_target()
1247 nt->extended = true; in alloc_param_target()
1252 if (!nt->extended) { in alloc_param_target()
1257 nt->release = true; in alloc_param_target()
1262 err = netpoll_parse_options(&nt->np, target_config); in alloc_param_target()
1266 err = netpoll_setup(&nt->np); in alloc_param_target()
1276 nt->enabled = true; in alloc_param_target()
1278 populate_configfs_item(nt, cmdline_count); in alloc_param_target()
1280 return nt; in alloc_param_target()
1283 kfree(nt); in alloc_param_target()
1288 static void free_param_target(struct netconsole_target *nt) in free_param_target() argument
1290 netpoll_cleanup(&nt->np); in free_param_target()
1291 kfree(nt); in free_param_target()
1309 struct netconsole_target *nt, *tmp; in init_netconsole() local
1318 nt = alloc_param_target(target_config, count); in init_netconsole()
1319 if (IS_ERR(nt)) { in init_netconsole()
1322 err = PTR_ERR(nt); in init_netconsole()
1326 if (nt->extended) { in init_netconsole()
1334 list_add(&nt->list, &target_list); in init_netconsole()
1366 list_for_each_entry_safe(nt, tmp, &target_list, list) { in init_netconsole()
1367 list_del(&nt->list); in init_netconsole()
1368 free_param_target(nt); in init_netconsole()
1376 struct netconsole_target *nt, *tmp; in cleanup_netconsole() local
1392 list_for_each_entry_safe(nt, tmp, &target_list, list) { in cleanup_netconsole()
1393 list_del(&nt->list); in cleanup_netconsole()
1394 free_param_target(nt); in cleanup_netconsole()