Some cleanups in preparation of further work. Signed-off-by: Michael Frank <[EMAIL PROTECTED]>
--- drivers/net/netconsole.c | 46 ++++++++--------- net/core/netpoll.c | 127 +++++++++++++++++++++++++---------------------- 2 files changed, 91 insertions(+), 82 deletions(-) Patch file: netpc-cleanups-mhfp15 --- linux-2.6.15-rc2-mhf260/net/core/netpoll.c.mhf.orig 2005-11-19 23:28:01.000000000 +0100 +++ linux-2.6.15-rc2-mhf260/net/core/netpoll.c 2005-11-21 08:28:58.000000000 +0100 @@ -9,6 +9,23 @@ * Copyright (C) 2002 Red Hat, Inc. */ +/****************************************************************************** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + *****************************************************************************/ + #include <linux/smp_lock.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> @@ -45,11 +62,11 @@ static atomic_t trapped; -#define NETPOLL_RX_ENABLED 1 -#define NETPOLL_RX_DROP 2 +#define NETPOLL_RX_ENABLED 1 +#define NETPOLL_RX_DROP 2 #define MAX_SKB_SIZE \ - (MAX_UDP_CHUNK + sizeof(struct udphdr) + \ + (MAX_UDP_CHUNK + sizeof(struct udphdr) + \ sizeof(struct iphdr) + sizeof(struct ethhdr)) static void zap_completion_queue(void); @@ -99,7 +116,7 @@ } static int checksum_udp(struct sk_buff *skb, struct udphdr *uh, - unsigned short ulen, u32 saddr, u32 daddr) + unsigned short ulen, u32 saddr, u32 daddr) { unsigned int psum; @@ -139,8 +156,8 @@ int budget = 16; if (test_bit(__LINK_STATE_RX_SCHED, &np->dev->state) && - npinfo->poll_owner != smp_processor_id() && - spin_trylock(&npinfo->poll_lock)) { + npinfo->poll_owner != smp_processor_id() && + spin_trylock(&npinfo->poll_lock)) { npinfo->rx_flags |= NETPOLL_RX_DROP; atomic_inc(&trapped); @@ -154,7 +171,7 @@ void netpoll_poll(struct netpoll *np) { - if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller) + if (!np->dev || !netif_running(np->dev) || !np->dev->poll_controller) return; /* Process pending work on NIC */ @@ -199,7 +216,7 @@ while (clist != NULL) { struct sk_buff *skb = clist; clist = clist->next; - if(skb->destructor) + if (skb->destructor) dev_kfree_skb_any(skb); /* put this one back */ else __kfree_skb(skb); @@ -233,7 +250,7 @@ spin_unlock_irqrestore(&skb_list_lock, flags); } - if(!skb) { + if (!skb) { count++; if (once && (count == 1000000)) { printk("out of netpoll skbs!\n"); @@ -262,7 +279,7 @@ /* avoid recursion */ if (npinfo->poll_owner == smp_processor_id() || - np->dev->xmit_lock_owner == smp_processor_id()) { + np->dev->xmit_lock_owner == smp_processor_id()) { if (np->drop) np->drop(skb); else @@ -292,7 +309,7 @@ spin_unlock(&np->dev->xmit_lock); /* success */ - if(!status) { + if (!status) { npinfo->tries = MAX_RETRIES; /* reset */ return; } @@ -332,16 +349,16 @@ /* iph->version = 4; iph->ihl = 5; */ put_unaligned(0x45, (unsigned char *)iph); - iph->tos = 0; + iph->tos = 0; put_unaligned(htons(ip_len), &(iph->tot_len)); - iph->id = 0; + iph->id = 0; iph->frag_off = 0; - iph->ttl = 64; + iph->ttl = 64; iph->protocol = IPPROTO_UDP; - iph->check = 0; + iph->check = 0; put_unaligned(htonl(np->local_ip), &(iph->saddr)); put_unaligned(htonl(np->remote_ip), &(iph->daddr)); - iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); + iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); eth = (struct ethhdr *) skb_push(skb, ETH_HLEN); @@ -374,17 +391,17 @@ return; if (!pskb_may_pull(skb, (sizeof(struct arphdr) + - (2 * skb->dev->addr_len) + - (2 * sizeof(u32))))) + (2 * skb->dev->addr_len) + + (2 * sizeof(u32))))) return; skb->h.raw = skb->nh.raw = skb->data; arp = skb->nh.arph; if ((arp->ar_hrd != htons(ARPHRD_ETHER) && - arp->ar_hrd != htons(ARPHRD_IEEE802)) || - arp->ar_pro != htons(ETH_P_IP) || - arp->ar_op != htons(ARPOP_REQUEST)) + arp->ar_hrd != htons(ARPHRD_IEEE802)) || + arp->ar_pro != htons(ETH_P_IP) || + arp->ar_op != htons(ARPOP_REQUEST)) return; arp_ptr = (unsigned char *)(arp+1) + skb->dev->addr_len; @@ -398,7 +415,7 @@ size = sizeof(struct arphdr) + 2 * (skb->dev->addr_len + 4); send_skb = find_skb(np, size + LL_RESERVED_SPACE(np->dev), - LL_RESERVED_SPACE(np->dev)); + LL_RESERVED_SPACE(np->dev)); if (!send_skb) return; @@ -411,9 +428,9 @@ /* Fill the device header for the ARP frame */ if (np->dev->hard_header && - np->dev->hard_header(send_skb, skb->dev, ptype, - np->remote_mac, np->local_mac, - send_skb->len) < 0) { + np->dev->hard_header(send_skb, skb->dev, ptype, + np->remote_mac, np->local_mac, + send_skb->len) < 0) { kfree_skb(send_skb); return; } @@ -457,7 +474,7 @@ /* check if netpoll clients need ARP */ if (skb->protocol == __constant_htons(ETH_P_ARP) && - atomic_read(&trapped)) { + atomic_read(&trapped)) { arp_reply(skb); return 1; } @@ -503,8 +520,7 @@ goto out; np->rx_hook(np, ntohs(uh->source), - (char *)(uh+1), - ulen - sizeof(struct udphdr)); + (char *)(uh+1), ulen - sizeof(struct udphdr)); kfree_skb(skb); return 1; @@ -522,7 +538,7 @@ { char *cur=opt, *delim; - if(*cur != '@') { + if (*cur != '@') { if ((delim = strchr(cur, '@')) == NULL) goto parse_failed; *delim=0; @@ -532,7 +548,7 @@ cur++; printk(KERN_INFO "%s: local port %d\n", np->name, np->local_port); - if(*cur != '/') { + if (*cur != '/') { if ((delim = strchr(cur, '/')) == NULL) goto parse_failed; *delim=0; @@ -540,11 +556,11 @@ cur=delim; printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n", - np->name, HIPQUAD(np->local_ip)); + np->name, HIPQUAD(np->local_ip)); } cur++; - if ( *cur != ',') { + if (*cur != ',') { /* parse out dev name */ if ((delim = strchr(cur, ',')) == NULL) goto parse_failed; @@ -556,7 +572,7 @@ printk(KERN_INFO "%s: interface %s\n", np->name, np->dev_name); - if ( *cur != '@' ) { + if (*cur != '@') { /* dst port */ if ((delim = strchr(cur, '@')) == NULL) goto parse_failed; @@ -575,10 +591,9 @@ cur=delim+1; printk(KERN_INFO "%s: remote IP %d.%d.%d.%d\n", - np->name, HIPQUAD(np->remote_ip)); + np->name, HIPQUAD(np->remote_ip)); - if( *cur != 0 ) - { + if (*cur != 0) { /* MAC address */ if ((delim = strchr(cur, ':')) == NULL) goto parse_failed; @@ -609,20 +624,14 @@ } printk(KERN_INFO "%s: remote ethernet address " - "%02x:%02x:%02x:%02x:%02x:%02x\n", - np->name, - np->remote_mac[0], - np->remote_mac[1], - np->remote_mac[2], - np->remote_mac[3], - np->remote_mac[4], - np->remote_mac[5]); + "%02x:%02x:%02x:%02x:%02x:%02x\n", np->name,np->remote_mac[0], + np->remote_mac[1], np->remote_mac[2], np->remote_mac[3], + np->remote_mac[4], np->remote_mac[5]); return 0; - parse_failed: - printk(KERN_INFO "%s: couldn't parse config at %s!\n", - np->name, cur); +parse_failed: + printk(KERN_INFO "%s: couldn't parse config at %s!\n", np->name, cur); return -1; } @@ -637,7 +646,7 @@ ndev = dev_get_by_name(np->dev_name); if (!ndev) { printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", - np->name, np->dev_name); + np->name, np->dev_name); return -1; } @@ -658,7 +667,7 @@ if (!ndev->poll_controller) { printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", - np->name, np->dev_name); + np->name, np->dev_name); goto release; } @@ -666,24 +675,24 @@ unsigned long atmost, atleast; printk(KERN_INFO "%s: device %s not up yet, forcing it\n", - np->name, np->dev_name); + np->name, np->dev_name); rtnl_shlock(); if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) { printk(KERN_ERR "%s: failed to open %s\n", - np->name, np->dev_name); + np->name, np->dev_name); rtnl_shunlock(); goto release; } rtnl_shunlock(); atleast = jiffies + HZ/10; - atmost = jiffies + 4*HZ; + atmost = jiffies + 4*HZ; while (!netif_carrier_ok(ndev)) { if (time_after(jiffies, atmost)) { printk(KERN_NOTICE - "%s: timeout waiting for carrier\n", - np->name); + "%s: timeout waiting for carrier\n", + np->name); break; } cond_resched(); @@ -696,8 +705,8 @@ if (time_before(jiffies, atleast)) { printk(KERN_NOTICE "%s: carrier detect appears" - " untrustworthy, waiting 4 seconds\n", - np->name); + " untrustworthy, waiting 4 seconds\n", + np->name); msleep(4000); } } @@ -712,14 +721,14 @@ if (!in_dev || !in_dev->ifa_list) { rcu_read_unlock(); printk(KERN_ERR "%s: no IP address for %s, aborting\n", - np->name, np->dev_name); + np->name, np->dev_name); goto release; } np->local_ip = ntohl(in_dev->ifa_list->ifa_local); rcu_read_unlock(); printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n", - np->name, HIPQUAD(np->local_ip)); + np->name, HIPQUAD(np->local_ip)); } if (np->rx_hook) { @@ -740,7 +749,7 @@ return 0; - release: +release: if (!ndev->npinfo) kfree(npinfo); np->dev = NULL; --- linux-2.6.15-rc2-mhf260/drivers/net/netconsole.c.mhf.orig 2005-11-08 20:22:55.000000000 +0100 +++ linux-2.6.15-rc2-mhf260/drivers/net/netconsole.c 2005-11-21 08:28:58.000000000 +0100 @@ -9,30 +9,30 @@ * * Modification history: * - * 2001-09-17 started by Ingo Molnar. - * 2003-08-11 2.6 port by Matt Mackall - * simplified options - * generic card hooks - * works non-modular - * 2003-09-07 rewritten with netpoll api + * 2001-09-17 started by Ingo Molnar. + * 2003-08-11 2.6 port by Matt Mackall + * simplified options + * generic card hooks + * works non-modular + * 2003-09-07 rewritten with netpoll api */ -/**************************************************************** - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. +/****************************************************************************** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - ****************************************************************/ + *****************************************************************************/ #include <linux/mm.h> #include <linux/tty.h> @@ -76,7 +76,7 @@ local_irq_save(flags); - for(left = len; left; ) { + for (left = len; left;) { frag = min(left, MAX_PRINT_CHUNK); netpoll_send_udp(&np, msg, frag); msg += frag; @@ -101,15 +101,15 @@ static int init_netconsole(void) { - if(strlen(config)) + if (strlen(config)) option_setup(config); - if(!configured) { + if (!configured) { printk("netconsole: not configured, aborting\n"); return -EINVAL; } - if(netpoll_setup(&np)) + if (netpoll_setup(&np)) return -EINVAL; register_console(&netconsole); - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html