Lines Matching refs:nt

133 static void netconsole_target_get(struct netconsole_target *nt)  in netconsole_target_get()  argument
135 if (config_item_name(&nt->item)) in netconsole_target_get()
136 config_item_get(&nt->item); in netconsole_target_get()
139 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
141 if (config_item_name(&nt->item)) in netconsole_target_put()
142 config_item_put(&nt->item); in netconsole_target_put()
160 static void netconsole_target_get(struct netconsole_target *nt) in netconsole_target_get() argument
164 static void netconsole_target_put(struct netconsole_target *nt) in netconsole_target_put() argument
174 struct netconsole_target *nt; in alloc_param_target() local
180 nt = kzalloc(sizeof(*nt), GFP_KERNEL); in alloc_param_target()
181 if (!nt) in alloc_param_target()
184 nt->np.name = "netconsole"; in alloc_param_target()
185 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); in alloc_param_target()
186 nt->np.local_port = 6665; in alloc_param_target()
187 nt->np.remote_port = 6666; in alloc_param_target()
188 mutex_init(&nt->mutex); in alloc_param_target()
189 eth_broadcast_addr(nt->np.remote_mac); in alloc_param_target()
192 err = netpoll_parse_options(&nt->np, target_config); in alloc_param_target()
196 err = netpoll_setup(&nt->np); in alloc_param_target()
200 nt->enabled = 1; in alloc_param_target()
202 return nt; in alloc_param_target()
205 kfree(nt); in alloc_param_target()
210 static void free_param_target(struct netconsole_target *nt) in free_param_target() argument
212 netpoll_cleanup(&nt->np); in free_param_target()
213 kfree(nt); in free_param_target()
238 ssize_t (*show)(struct netconsole_target *nt,
240 ssize_t (*store)(struct netconsole_target *nt,
256 static ssize_t show_enabled(struct netconsole_target *nt, char *buf) in show_enabled() argument
258 return snprintf(buf, PAGE_SIZE, "%d\n", nt->enabled); in show_enabled()
261 static ssize_t show_dev_name(struct netconsole_target *nt, char *buf) in show_dev_name() argument
263 return snprintf(buf, PAGE_SIZE, "%s\n", nt->np.dev_name); in show_dev_name()
266 static ssize_t show_local_port(struct netconsole_target *nt, char *buf) in show_local_port() argument
268 return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.local_port); in show_local_port()
271 static ssize_t show_remote_port(struct netconsole_target *nt, char *buf) in show_remote_port() argument
273 return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.remote_port); in show_remote_port()
276 static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) in show_local_ip() argument
278 if (nt->np.ipv6) in show_local_ip()
279 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); in show_local_ip()
281 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); in show_local_ip()
284 static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) in show_remote_ip() argument
286 if (nt->np.ipv6) in show_remote_ip()
287 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); in show_remote_ip()
289 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); in show_remote_ip()
292 static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) in show_local_mac() argument
294 struct net_device *dev = nt->np.dev; in show_local_mac()
300 static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf) in show_remote_mac() argument
302 return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac); in show_remote_mac()
312 static ssize_t store_enabled(struct netconsole_target *nt, in store_enabled() argument
325 if (enabled == nt->enabled) { in store_enabled()
327 nt->enabled ? "started" : "stopped"); in store_enabled()
336 netpoll_print_options(&nt->np); in store_enabled()
338 err = netpoll_setup(&nt->np); in store_enabled()
349 nt->enabled = 0; in store_enabled()
351 netpoll_cleanup(&nt->np); in store_enabled()
354 nt->enabled = enabled; in store_enabled()
359 static ssize_t store_dev_name(struct netconsole_target *nt, in store_dev_name() argument
365 if (nt->enabled) { in store_dev_name()
367 config_item_name(&nt->item)); in store_dev_name()
371 strlcpy(nt->np.dev_name, buf, IFNAMSIZ); in store_dev_name()
374 len = strnlen(nt->np.dev_name, IFNAMSIZ); in store_dev_name()
375 if (nt->np.dev_name[len - 1] == '\n') in store_dev_name()
376 nt->np.dev_name[len - 1] = '\0'; in store_dev_name()
381 static ssize_t store_local_port(struct netconsole_target *nt, in store_local_port() argument
387 if (nt->enabled) { in store_local_port()
389 config_item_name(&nt->item)); in store_local_port()
393 rv = kstrtou16(buf, 10, &nt->np.local_port); in store_local_port()
399 static ssize_t store_remote_port(struct netconsole_target *nt, in store_remote_port() argument
405 if (nt->enabled) { in store_remote_port()
407 config_item_name(&nt->item)); in store_remote_port()
411 rv = kstrtou16(buf, 10, &nt->np.remote_port); in store_remote_port()
417 static ssize_t store_local_ip(struct netconsole_target *nt, in store_local_ip() argument
421 if (nt->enabled) { in store_local_ip()
423 config_item_name(&nt->item)); in store_local_ip()
429 if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { in store_local_ip()
434 nt->np.ipv6 = true; in store_local_ip()
438 if (!nt->np.ipv6) { in store_local_ip()
439 nt->np.local_ip.ip = in_aton(buf); in store_local_ip()
447 static ssize_t store_remote_ip(struct netconsole_target *nt, in store_remote_ip() argument
451 if (nt->enabled) { in store_remote_ip()
453 config_item_name(&nt->item)); in store_remote_ip()
459 if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { in store_remote_ip()
464 nt->np.ipv6 = true; in store_remote_ip()
468 if (!nt->np.ipv6) { in store_remote_ip()
469 nt->np.remote_ip.ip = in_aton(buf); in store_remote_ip()
477 static ssize_t store_remote_mac(struct netconsole_target *nt, in store_remote_mac() argument
483 if (nt->enabled) { in store_remote_mac()
485 config_item_name(&nt->item)); in store_remote_mac()
493 memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); in store_remote_mac()
545 struct netconsole_target *nt = to_target(item); in netconsole_target_attr_show() local
550 ret = na->show(nt, buf); in netconsole_target_attr_show()
561 struct netconsole_target *nt = to_target(item); in netconsole_target_attr_store() local
565 mutex_lock(&nt->mutex); in netconsole_target_attr_store()
567 ret = na->store(nt, buf, count); in netconsole_target_attr_store()
568 mutex_unlock(&nt->mutex); in netconsole_target_attr_store()
593 struct netconsole_target *nt; in make_netconsole_target() local
599 nt = kzalloc(sizeof(*nt), GFP_KERNEL); in make_netconsole_target()
600 if (!nt) in make_netconsole_target()
603 nt->np.name = "netconsole"; in make_netconsole_target()
604 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); in make_netconsole_target()
605 nt->np.local_port = 6665; in make_netconsole_target()
606 nt->np.remote_port = 6666; in make_netconsole_target()
607 mutex_init(&nt->mutex); in make_netconsole_target()
608 eth_broadcast_addr(nt->np.remote_mac); in make_netconsole_target()
611 config_item_init_type_name(&nt->item, name, &netconsole_target_type); in make_netconsole_target()
615 list_add(&nt->list, &target_list); in make_netconsole_target()
618 return &nt->item; in make_netconsole_target()
625 struct netconsole_target *nt = to_target(item); in drop_netconsole_target() local
628 list_del(&nt->list); in drop_netconsole_target()
635 if (nt->enabled) in drop_netconsole_target()
636 netpoll_cleanup(&nt->np); in drop_netconsole_target()
638 config_item_put(&nt->item); in drop_netconsole_target()
668 struct netconsole_target *nt; in netconsole_netdev_event() local
678 list_for_each_entry(nt, &target_list, list) { in netconsole_netdev_event()
679 netconsole_target_get(nt); in netconsole_netdev_event()
680 if (nt->np.dev == dev) { in netconsole_netdev_event()
683 strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); in netconsole_netdev_event()
693 __netpoll_cleanup(&nt->np); in netconsole_netdev_event()
696 dev_put(nt->np.dev); in netconsole_netdev_event()
697 nt->np.dev = NULL; in netconsole_netdev_event()
698 nt->enabled = 0; in netconsole_netdev_event()
700 netconsole_target_put(nt); in netconsole_netdev_event()
704 netconsole_target_put(nt); in netconsole_netdev_event()
736 struct netconsole_target *nt; in write_msg() local
746 list_for_each_entry(nt, &target_list, list) { in write_msg()
747 netconsole_target_get(nt); in write_msg()
748 if (nt->enabled && netif_running(nt->np.dev)) { in write_msg()
758 netpoll_send_udp(&nt->np, tmp, frag); in write_msg()
763 netconsole_target_put(nt); in write_msg()
777 struct netconsole_target *nt, *tmp; in init_netconsole() local
784 nt = alloc_param_target(target_config); in init_netconsole()
785 if (IS_ERR(nt)) { in init_netconsole()
786 err = PTR_ERR(nt); in init_netconsole()
793 list_add(&nt->list, &target_list); in init_netconsole()
822 list_for_each_entry_safe(nt, tmp, &target_list, list) { in init_netconsole()
823 list_del(&nt->list); in init_netconsole()
824 free_param_target(nt); in init_netconsole()
832 struct netconsole_target *nt, *tmp; in cleanup_netconsole() local
846 list_for_each_entry_safe(nt, tmp, &target_list, list) { in cleanup_netconsole()
847 list_del(&nt->list); in cleanup_netconsole()
848 free_param_target(nt); in cleanup_netconsole()