Lines Matching refs:np

66 #define np_info(np, fmt, ...)				\  argument
67 pr_info("%s: " fmt, np->name, ##__VA_ARGS__)
68 #define np_err(np, fmt, ...) \ argument
69 pr_err("%s: " fmt, np->name, ##__VA_ARGS__)
70 #define np_notice(np, fmt, ...) \ argument
71 pr_notice("%s: " fmt, np->name, ##__VA_ARGS__)
271 static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve) in find_skb() argument
286 netpoll_poll_dev(np->dev); in find_skb()
309 static netdev_tx_t __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) in __netpoll_send_skb() argument
319 dev = np->dev; in __netpoll_send_skb()
348 netpoll_poll_dev(np->dev); in __netpoll_send_skb()
366 netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) in netpoll_send_skb() argument
371 if (unlikely(!np)) { in netpoll_send_skb()
376 ret = __netpoll_send_skb(np, skb); in netpoll_send_skb()
383 void netpoll_send_udp(struct netpoll *np, const char *msg, int len) in netpoll_send_udp() argument
397 if (np->ipv6) in netpoll_send_udp()
402 total_len = ip_len + LL_RESERVED_SPACE(np->dev); in netpoll_send_udp()
404 skb = find_skb(np, total_len + np->dev->needed_tailroom, in netpoll_send_udp()
415 udph->source = htons(np->local_port); in netpoll_send_udp()
416 udph->dest = htons(np->remote_port); in netpoll_send_udp()
419 if (np->ipv6) { in netpoll_send_udp()
421 udph->check = csum_ipv6_magic(&np->local_ip.in6, in netpoll_send_udp()
422 &np->remote_ip.in6, in netpoll_send_udp()
441 ip6h->saddr = np->local_ip.in6; in netpoll_send_udp()
442 ip6h->daddr = np->remote_ip.in6; in netpoll_send_udp()
449 udph->check = csum_tcpudp_magic(np->local_ip.ip, in netpoll_send_udp()
450 np->remote_ip.ip, in netpoll_send_udp()
469 put_unaligned(np->local_ip.ip, &(iph->saddr)); in netpoll_send_udp()
470 put_unaligned(np->remote_ip.ip, &(iph->daddr)); in netpoll_send_udp()
478 ether_addr_copy(eth->h_source, np->dev->dev_addr); in netpoll_send_udp()
479 ether_addr_copy(eth->h_dest, np->remote_mac); in netpoll_send_udp()
481 skb->dev = np->dev; in netpoll_send_udp()
483 netpoll_send_skb(np, skb); in netpoll_send_udp()
487 void netpoll_print_options(struct netpoll *np) in netpoll_print_options() argument
489 np_info(np, "local port %d\n", np->local_port); in netpoll_print_options()
490 if (np->ipv6) in netpoll_print_options()
491 np_info(np, "local IPv6 address %pI6c\n", &np->local_ip.in6); in netpoll_print_options()
493 np_info(np, "local IPv4 address %pI4\n", &np->local_ip.ip); in netpoll_print_options()
494 np_info(np, "interface '%s'\n", np->dev_name); in netpoll_print_options()
495 np_info(np, "remote port %d\n", np->remote_port); in netpoll_print_options()
496 if (np->ipv6) in netpoll_print_options()
497 np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6); in netpoll_print_options()
499 np_info(np, "remote IPv4 address %pI4\n", &np->remote_ip.ip); in netpoll_print_options()
500 np_info(np, "remote ethernet address %pM\n", np->remote_mac); in netpoll_print_options()
524 int netpoll_parse_options(struct netpoll *np, char *opt) in netpoll_parse_options() argument
534 if (kstrtou16(cur, 10, &np->local_port)) in netpoll_parse_options()
545 ipv6 = netpoll_parse_ip_addr(cur, &np->local_ip); in netpoll_parse_options()
549 np->ipv6 = (bool)ipv6; in netpoll_parse_options()
559 strscpy(np->dev_name, cur, sizeof(np->dev_name)); in netpoll_parse_options()
570 np_info(np, "warning: whitespace is not allowed\n"); in netpoll_parse_options()
571 if (kstrtou16(cur, 10, &np->remote_port)) in netpoll_parse_options()
581 ipv6 = netpoll_parse_ip_addr(cur, &np->remote_ip); in netpoll_parse_options()
584 else if (ipversion_set && np->ipv6 != (bool)ipv6) in netpoll_parse_options()
587 np->ipv6 = (bool)ipv6; in netpoll_parse_options()
592 if (!mac_pton(cur, np->remote_mac)) in netpoll_parse_options()
596 netpoll_print_options(np); in netpoll_parse_options()
601 np_info(np, "couldn't parse config at '%s'!\n", cur); in netpoll_parse_options()
606 int __netpoll_setup(struct netpoll *np, struct net_device *ndev) in __netpoll_setup() argument
612 np->dev = ndev; in __netpoll_setup()
613 strscpy(np->dev_name, ndev->name, IFNAMSIZ); in __netpoll_setup()
616 np_err(np, "%s doesn't support polling, aborting\n", in __netpoll_setup()
617 np->dev_name); in __netpoll_setup()
635 ops = np->dev->netdev_ops; in __netpoll_setup()
646 npinfo->netpoll = np; in __netpoll_setup()
660 int netpoll_setup(struct netpoll *np) in netpoll_setup() argument
667 if (np->dev_name[0]) { in netpoll_setup()
669 ndev = __dev_get_by_name(net, np->dev_name); in netpoll_setup()
672 np_err(np, "%s doesn't exist, aborting\n", np->dev_name); in netpoll_setup()
679 np_err(np, "%s is a slave device, aborting\n", np->dev_name); in netpoll_setup()
687 np_info(np, "device %s not up yet, forcing it\n", np->dev_name); in netpoll_setup()
692 np_err(np, "failed to open %s\n", ndev->name); in netpoll_setup()
701 np_notice(np, "timeout waiting for carrier\n"); in netpoll_setup()
713 np_notice(np, "carrier detect appears untrustworthy, waiting 4 seconds\n"); in netpoll_setup()
719 if (!np->local_ip.ip) { in netpoll_setup()
720 if (!np->ipv6) { in netpoll_setup()
730 np_err(np, "no IP address for %s, aborting\n", in netpoll_setup()
731 np->dev_name); in netpoll_setup()
736 np->local_ip.ip = ifa->ifa_local; in netpoll_setup()
737 np_info(np, "local IP %pI4\n", &np->local_ip.ip); in netpoll_setup()
750 !!(ipv6_addr_type(&np->remote_ip.in6) & IPV6_ADDR_LINKLOCAL)) in netpoll_setup()
752 np->local_ip.in6 = ifp->addr; in netpoll_setup()
759 np_err(np, "no IPv6 address for %s, aborting\n", in netpoll_setup()
760 np->dev_name); in netpoll_setup()
763 np_info(np, "local IPv6 %pI6c\n", &np->local_ip.in6); in netpoll_setup()
765 np_err(np, "IPv6 is not supported %s, aborting\n", in netpoll_setup()
766 np->dev_name); in netpoll_setup()
776 err = __netpoll_setup(np, ndev); in netpoll_setup()
779 netdev_tracker_alloc(ndev, &np->dev_tracker, GFP_KERNEL); in netpoll_setup()
815 void __netpoll_cleanup(struct netpoll *np) in __netpoll_cleanup() argument
819 npinfo = rtnl_dereference(np->dev->npinfo); in __netpoll_cleanup()
828 ops = np->dev->netdev_ops; in __netpoll_cleanup()
830 ops->ndo_netpoll_cleanup(np->dev); in __netpoll_cleanup()
832 RCU_INIT_POINTER(np->dev->npinfo, NULL); in __netpoll_cleanup()
835 RCU_INIT_POINTER(np->dev->npinfo, NULL); in __netpoll_cleanup()
839 void __netpoll_free(struct netpoll *np) in __netpoll_free() argument
845 __netpoll_cleanup(np); in __netpoll_free()
846 kfree(np); in __netpoll_free()
850 void netpoll_cleanup(struct netpoll *np) in netpoll_cleanup() argument
853 if (!np->dev) in netpoll_cleanup()
855 __netpoll_cleanup(np); in netpoll_cleanup()
856 netdev_put(np->dev, &np->dev_tracker); in netpoll_cleanup()
857 np->dev = NULL; in netpoll_cleanup()