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__)
288 static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve) in find_skb() argument
303 netpoll_poll_dev(np->dev); in find_skb()
326 static netdev_tx_t __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) in __netpoll_send_skb() argument
336 dev = np->dev; in __netpoll_send_skb()
365 netpoll_poll_dev(np->dev); in __netpoll_send_skb()
383 netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) in netpoll_send_skb() argument
388 if (unlikely(!np)) { in netpoll_send_skb()
393 ret = __netpoll_send_skb(np, skb); in netpoll_send_skb()
400 void netpoll_send_udp(struct netpoll *np, const char *msg, int len) in netpoll_send_udp() argument
414 if (np->ipv6) in netpoll_send_udp()
419 total_len = ip_len + LL_RESERVED_SPACE(np->dev); in netpoll_send_udp()
421 skb = find_skb(np, total_len + np->dev->needed_tailroom, in netpoll_send_udp()
432 udph->source = htons(np->local_port); in netpoll_send_udp()
433 udph->dest = htons(np->remote_port); in netpoll_send_udp()
436 if (np->ipv6) { in netpoll_send_udp()
438 udph->check = csum_ipv6_magic(&np->local_ip.in6, in netpoll_send_udp()
439 &np->remote_ip.in6, in netpoll_send_udp()
458 ip6h->saddr = np->local_ip.in6; in netpoll_send_udp()
459 ip6h->daddr = np->remote_ip.in6; in netpoll_send_udp()
466 udph->check = csum_tcpudp_magic(np->local_ip.ip, in netpoll_send_udp()
467 np->remote_ip.ip, in netpoll_send_udp()
486 put_unaligned(np->local_ip.ip, &(iph->saddr)); in netpoll_send_udp()
487 put_unaligned(np->remote_ip.ip, &(iph->daddr)); in netpoll_send_udp()
495 ether_addr_copy(eth->h_source, np->dev->dev_addr); in netpoll_send_udp()
496 ether_addr_copy(eth->h_dest, np->remote_mac); in netpoll_send_udp()
498 skb->dev = np->dev; in netpoll_send_udp()
500 netpoll_send_skb(np, skb); in netpoll_send_udp()
504 void netpoll_print_options(struct netpoll *np) in netpoll_print_options() argument
506 np_info(np, "local port %d\n", np->local_port); in netpoll_print_options()
507 if (np->ipv6) in netpoll_print_options()
508 np_info(np, "local IPv6 address %pI6c\n", &np->local_ip.in6); in netpoll_print_options()
510 np_info(np, "local IPv4 address %pI4\n", &np->local_ip.ip); in netpoll_print_options()
511 np_info(np, "interface '%s'\n", np->dev_name); in netpoll_print_options()
512 np_info(np, "remote port %d\n", np->remote_port); in netpoll_print_options()
513 if (np->ipv6) in netpoll_print_options()
514 np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6); in netpoll_print_options()
516 np_info(np, "remote IPv4 address %pI4\n", &np->remote_ip.ip); in netpoll_print_options()
517 np_info(np, "remote ethernet address %pM\n", np->remote_mac); in netpoll_print_options()
541 int netpoll_parse_options(struct netpoll *np, char *opt) in netpoll_parse_options() argument
551 if (kstrtou16(cur, 10, &np->local_port)) in netpoll_parse_options()
562 ipv6 = netpoll_parse_ip_addr(cur, &np->local_ip); in netpoll_parse_options()
566 np->ipv6 = (bool)ipv6; in netpoll_parse_options()
576 strscpy(np->dev_name, cur, sizeof(np->dev_name)); in netpoll_parse_options()
587 np_info(np, "warning: whitespace is not allowed\n"); in netpoll_parse_options()
588 if (kstrtou16(cur, 10, &np->remote_port)) in netpoll_parse_options()
598 ipv6 = netpoll_parse_ip_addr(cur, &np->remote_ip); in netpoll_parse_options()
601 else if (ipversion_set && np->ipv6 != (bool)ipv6) in netpoll_parse_options()
604 np->ipv6 = (bool)ipv6; in netpoll_parse_options()
609 if (!mac_pton(cur, np->remote_mac)) in netpoll_parse_options()
613 netpoll_print_options(np); in netpoll_parse_options()
618 np_info(np, "couldn't parse config at '%s'!\n", cur); in netpoll_parse_options()
623 int __netpoll_setup(struct netpoll *np, struct net_device *ndev) in __netpoll_setup() argument
630 np_err(np, "%s doesn't support polling, aborting\n", in __netpoll_setup()
660 np->dev = ndev; in __netpoll_setup()
661 strscpy(np->dev_name, ndev->name, IFNAMSIZ); in __netpoll_setup()
662 npinfo->netpoll = np; in __netpoll_setup()
676 int netpoll_setup(struct netpoll *np) in netpoll_setup() argument
684 if (np->dev_name[0]) { in netpoll_setup()
686 ndev = __dev_get_by_name(net, np->dev_name); in netpoll_setup()
689 np_err(np, "%s doesn't exist, aborting\n", np->dev_name); in netpoll_setup()
693 netdev_hold(ndev, &np->dev_tracker, GFP_KERNEL); in netpoll_setup()
696 np_err(np, "%s is a slave device, aborting\n", np->dev_name); in netpoll_setup()
704 np_info(np, "device %s not up yet, forcing it\n", np->dev_name); in netpoll_setup()
709 np_err(np, "failed to open %s\n", ndev->name); in netpoll_setup()
717 np_notice(np, "timeout waiting for carrier\n"); in netpoll_setup()
726 if (!np->local_ip.ip) { in netpoll_setup()
727 if (!np->ipv6) { in netpoll_setup()
737 np_err(np, "no IP address for %s, aborting\n", in netpoll_setup()
738 np->dev_name); in netpoll_setup()
743 np->local_ip.ip = ifa->ifa_local; in netpoll_setup()
745 np_info(np, "local IP %pI4\n", &np->local_ip.ip); in netpoll_setup()
758 !!(ipv6_addr_type(&np->remote_ip.in6) & IPV6_ADDR_LINKLOCAL)) in netpoll_setup()
760 np->local_ip.in6 = ifp->addr; in netpoll_setup()
768 np_err(np, "no IPv6 address for %s, aborting\n", in netpoll_setup()
769 np->dev_name); in netpoll_setup()
772 np_info(np, "local IPv6 %pI6c\n", &np->local_ip.in6); in netpoll_setup()
774 np_err(np, "IPv6 is not supported %s, aborting\n", in netpoll_setup()
775 np->dev_name); in netpoll_setup()
785 err = __netpoll_setup(np, ndev); in netpoll_setup()
792 DEBUG_NET_WARN_ON_ONCE(np->dev); in netpoll_setup()
794 memset(&np->local_ip, 0, sizeof(np->local_ip)); in netpoll_setup()
795 netdev_put(ndev, &np->dev_tracker); in netpoll_setup()
826 void __netpoll_cleanup(struct netpoll *np) in __netpoll_cleanup() argument
830 npinfo = rtnl_dereference(np->dev->npinfo); in __netpoll_cleanup()
839 ops = np->dev->netdev_ops; in __netpoll_cleanup()
841 ops->ndo_netpoll_cleanup(np->dev); in __netpoll_cleanup()
843 RCU_INIT_POINTER(np->dev->npinfo, NULL); in __netpoll_cleanup()
846 RCU_INIT_POINTER(np->dev->npinfo, NULL); in __netpoll_cleanup()
850 void __netpoll_free(struct netpoll *np) in __netpoll_free() argument
856 __netpoll_cleanup(np); in __netpoll_free()
857 kfree(np); in __netpoll_free()
861 void netpoll_cleanup(struct netpoll *np) in netpoll_cleanup() argument
864 if (!np->dev) in netpoll_cleanup()
866 __netpoll_cleanup(np); in netpoll_cleanup()
867 netdev_put(np->dev, &np->dev_tracker); in netpoll_cleanup()
868 np->dev = NULL; in netpoll_cleanup()