From arjanv@redhat.com Wed Sep 1 00:03:29 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 00:03:37 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8173TkB000493 for ; Wed, 1 Sep 2004 00:03:29 -0700 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i81738S0014472; Wed, 1 Sep 2004 03:03:13 -0400 Received: from [172.31.3.35] (arjanv.cipe.redhat.com [10.0.2.48]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i81732322346; Wed, 1 Sep 2004 03:03:02 -0400 Subject: Re: [Announce] Update on ipw2100, ipw2200, and support for Intel PRO/Wireless 2915ABG From: Arjan van de Ven Reply-To: arjanv@redhat.com To: James Ketrenos Cc: Linux kernel mailing list , Netdev In-Reply-To: <4134E8EA.9080605@linux.intel.com> References: <4134E8EA.9080605@linux.intel.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-X7szBpNK5mljMglKnPP8" Organization: Red Hat UK Message-Id: <1094022177.2801.1.camel@laptop.fenrus.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 01 Sep 2004 09:02:57 +0200 X-archive-position: 8295 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: arjanv@redhat.com Precedence: bulk X-list: netdev --=-X7szBpNK5mljMglKnPP8 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2004-08-31 at 23:08, James Ketrenos wrote: > It's been a while since I've updated lkml and netdev on the progress of > the ipw projects. Given the recent announcement by Intel for the > introduction of Intel PRO/Wireless 2915 ABG Network Connection miniPCI > adapter, I thought now was a good time... you guys seem to be doing a really great job on these drivers; thanks! --=-X7szBpNK5mljMglKnPP8 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBBNXQgxULwo51rQBIRAvHCAJwOJrJP6DLAJuGhAuK9d1qoOUQJZgCghNlA Msq9xpw2hH+gug8KYZg9s0c= =kpDZ -----END PGP SIGNATURE----- --=-X7szBpNK5mljMglKnPP8-- From ricklind@us.ibm.com Wed Sep 1 01:33:53 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 01:33:59 -0700 (PDT) Received: from e2.ny.us.ibm.com (e2.ny.us.ibm.com [32.97.182.102]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i818XlqM005862 for ; Wed, 1 Sep 2004 01:33:53 -0700 Received: from northrelay04.pok.ibm.com (northrelay04.pok.ibm.com [9.56.224.206]) by e2.ny.us.ibm.com (8.12.10/8.12.9) with ESMTP id i818XOKK349602; Wed, 1 Sep 2004 04:33:24 -0400 Received: from owlet.beaverton.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by northrelay04.pok.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i818YXrm160062; Wed, 1 Sep 2004 04:34:34 -0400 Received: from owlet.beaverton.ibm.com (rick@localhost) by owlet.beaverton.ibm.com (8.11.6/8.11.6) with ESMTP id i818XPZ04210; Wed, 1 Sep 2004 01:33:26 -0700 Message-Id: <200409010833.i818XPZ04210@owlet.beaverton.ibm.com> To: Nivedita Singhvi cc: Andrew Morton , netdev@oss.sgi.com, linux-kernel@vger.kernel.org Subject: Re: Fw: Re: 2.6.9-rc1-mm2 In-reply-to: Your message of "Tue, 31 Aug 2004 17:49:10 PDT." <41351C86.7000704@us.ibm.com> Date: Wed, 01 Sep 2004 01:33:25 -0700 From: Rick Lindsley X-archive-position: 8296 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ricklind@us.ibm.com Precedence: bulk X-list: netdev Thanks for pointing out the specific config options. Granted a more recent config is warranted .. the one I'm using is 2.6.0-based. But considering I ran make oldconfig on this and chose the defaults in each and every case, should I end up with a config that doesn't compile? Is there still a config issue here, especially considering that both rc1 and rc1-mm1 compiled fine using this method? Or is make oldconfig only going to help for a version or two back? Rick From akpm@osdl.org Wed Sep 1 01:43:51 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 01:43:57 -0700 (PDT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i818hpT5006334 for ; Wed, 1 Sep 2004 01:43:51 -0700 Received: from bix (build.pdx.osdl.net [172.20.1.2]) by mail.osdl.org (8.11.6/8.11.6) with SMTP id i818h7114811; Wed, 1 Sep 2004 01:43:07 -0700 Date: Wed, 1 Sep 2004 01:41:18 -0700 From: Andrew Morton To: Rick Lindsley Cc: niv@us.ibm.com, netdev@oss.sgi.com, linux-kernel@vger.kernel.org Subject: Re: Fw: Re: 2.6.9-rc1-mm2 Message-Id: <20040901014118.45204bcb.akpm@osdl.org> In-Reply-To: <200409010833.i818XPZ04210@owlet.beaverton.ibm.com> References: <41351C86.7000704@us.ibm.com> <200409010833.i818XPZ04210@owlet.beaverton.ibm.com> X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8297 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: akpm@osdl.org Precedence: bulk X-list: netdev Rick Lindsley wrote: > > But considering I ran make oldconfig on this and chose > the defaults in each and every case, should I end up with a config that > doesn't compile? No, you shouldn't. This indicates a Kconfig bug. From yoshfuji@linux-ipv6.org Wed Sep 1 02:01:51 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 02:01:56 -0700 (PDT) Received: from yue.st-paulia.net ([203.178.140.15]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8191pPF007324 for ; Wed, 1 Sep 2004 02:01:51 -0700 Received: from localhost (localhost [127.0.0.1]) by yue.st-paulia.net (Postfix) with ESMTP id B532333CE6; Wed, 1 Sep 2004 18:02:37 +0900 (JST) Date: Wed, 01 Sep 2004 18:02:36 +0900 (JST) Message-Id: <20040901.180236.102852119.yoshfuji@linux-ipv6.org> To: thomasz@hostmaster.org Cc: linux-kernel@vger.kernel.org, netdev@oss.sgi.com Subject: Re: 2.6.9-rc1 oops From: YOSHIFUJI Hideaki / =?iso-2022-jp?B?GyRCNUhGIzFRTEAbKEI=?= In-Reply-To: <1094028647.16908.42.camel@hostmaster.org> References: <1093945177.16908.14.camel@hostmaster.org> <1094028647.16908.42.camel@hostmaster.org> Organization: USAGI Project X-URL: http://www.yoshifuji.org/%7Ehideaki/ X-Fingerprint: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA X-PGP-Key-URL: http://www.yoshifuji.org/%7Ehideaki/hideaki@yoshifuji.org.asc X-Face: "5$Al-.M>NJ%a'@hhZdQm:."qn~PA^gq4o*>iCFToq*bAi#4FRtx}enhuQKz7fNqQz\BYU] $~O_5m-9'}MIs`XGwIEscw;e5b>n"B_?j/AkL~i/MEaZBLP X-Mailer: Mew version 2.2 on Emacs 20.7 / Mule 4.1 (AOI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-archive-position: 8298 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: yoshfuji@linux-ipv6.org Precedence: bulk X-list: netdev In article <1094028647.16908.42.camel@hostmaster.org> (at Wed, 01 Sep 2004 10:50:47 +0200), Thomas Zehetbauer says: > I have now created a bug report for this issue: > http://bugzilla.kernel.org/show_bug.cgi?id=3323 (Plase use netdev...) I think this is already fixed in current bk tree. --yoshfuji From zhikui.chen@rus.uni-stuttgart.de Wed Sep 1 03:23:58 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 03:24:07 -0700 (PDT) Received: from uni-stuttgart.de (mbox.rus.uni-stuttgart.de [129.69.1.9]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81ANuWY011252 for ; Wed, 1 Sep 2004 03:23:57 -0700 Received: from [129.69.30.152] (HELO rus.uni-stuttgart.de) by uni-stuttgart.de (CommuniGate Pro SMTP 4.0.3) with ESMTP id 8883643; Wed, 01 Sep 2004 12:23:47 +0200 Message-ID: <4135A32A.4030901@rus.uni-stuttgart.de> Date: Wed, 01 Sep 2004 12:23:38 +0200 From: Zhikui Chen User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: hadi@cyberus.ca CC: dccp@ietf.org, netdev@oss.sgi.com, acme@conectiva.com.br Subject: Re: HELP for dccp implementation. References: <412CC269.8080907@rus.uni-stuttgart.de> <1093454747.1034.85.camel@jzny.localdomain> In-Reply-To: <1093454747.1034.85.camel@jzny.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8299 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: zhikui.chen@rus.uni-stuttgart.de Precedence: bulk X-list: netdev Hi, all If I assign a value such as 0x ee9fbc00 to sk in dccp_rcv (before lookup calling), and comment lookkup calling, I get a error report from bh_lock_sock(sk) calling inside dccp_rcv, which error report is spin_is_locked on uninitialized spinlock ee9fbc00, and spin_lock (:ee9fbc00) already locked by /73. Do you know its reason? Thanks, Best regards, Zhikui i there, >Could you please work with >Arnaldo Carvalho de Melo since he is >already working on this - this way we could have a coherent >implementation. >He is quiet knowledgeable on the internals of Linux and you could bring >in the protocol expertise. > >cheers, >jamal > >On Wed, 2004-08-25 at 12:46, Zhikui Chen wrote: > > >>Hi, dear all >> >>I could not assign __sk_head(head) value to sk in lookup_listen. >> >>I have writen the partial code for receive the request packet at server >>accodring to kernel TCP stuff, which is almost closed to TCP stuff. >> >>Anyone can tell me the reason or any hints? Thanks in advance. >> >>The details is following: >> >>The server for receiveing request packet firstly has following steps: >>1. Initialize dccp sock, >>2. dccp bind >>3. get_port >>3. hash >>4. accpet and waiting packet >>5. calling dccp_rcv to get packet ( I have checked dccp_rcv got the >>request packet). >>6. to get sk value by call dccp_lookup >>7 .... >> >>My problem is still in geting sk value, The follwing is my printing out: >> >>Aug 25 09:28:38 localhost kernel: DCCP: Hash tables configured >>(established 262144 bind 65536) >> >>dccp_init_sock: >>dccp_sock_init_common: >>allocated cctp successfully >>allocated pkt vectors successfully >>dccp_bind. >>New dccp_get_port start.65536 >>New dccp_get_port start.else:start >>db not found. >>bind hash add:sk:ee9fbc00,node:0,snum:7000 >>New dccp_get_port start.OK. sk:ee9fbc00,node:0 >>New dccp_get_port start.65536 >>New dccp_get_port start.else:start >>hlist_empty(&db->owners) not empty. >>New dccp_get_port start.OK. sk:ee9fbc00,node:ee5a0444 >>__dccp_v4_hash, list:c04eb670,num:7000,c0558780 >>__dccp_v4_hash, list:c04eb670,sk:ee9fbc00 >>dccp_accept start.7000,sk->sk_family=2,sk->sk_state=1,sk:ee9fbc00 >>dccp_accept 1 ..flags=2 >>dccp_accept 2 .. >>dccp_accept 3 ..timeo=2147483647,sk:ee9fbc00 >>wait_for_incoming_connection: >>dccp wait for connect start!sk:ee9fbc00 >>dccp wait for connect start!..sk:ee9fbc00 >>dccp_rcv start.ee9d3580 >>dccp_rcv: sk->sk_state=0, type=0,dh->dport=22555 >>dccp_v4_lookup >>__dccp_v4_lookup. >>dccp_v4_lookup_connection. >>hash 13291 >>dccp_v4_lookup_connection. head:f7619f58,node:eeaf5834,sk:ee9d3580 >>dccp_v4_lookup_connection. head:f7619f58,node:,sk:0 >>dccp_bhash_size: 65536,ntohs(dport):7000 >>first of head is not empty >>dccp_v4_lookup_listen: head: c04eb670,c0558780,__sk_head(head):ee9fbc00 >>dccp_v4_lookup_listen:sk: 0 >>dccp_rcv: unable to find socket() >> >>At print out, dccp_bind did not call get_port and inet_sk(sk) is >>assigned a port number which is 7000 from application. >> >>For printing __sk_head(head):ee9fbc00, I let sk = NULL in the >>dccp_v4_lookup_listen. >>HASH_TABLE = 32 or 128 I have the same result. >>And the source code is enclosed. >> >>Best regards, >> >>Zhikui >> >>------------------------------------------------------------------------ >> >>struct dccp_hashinfo __cacheline_aligned dccp_hashinfo = { >> .__dccp_lhash_lock = RW_LOCK_UNLOCKED, >> .__dccp_lhash_users = ATOMIC_INIT(0), >> .__dccp_lhash_wait >> = __WAIT_QUEUE_HEAD_INITIALIZER(dccp_hashinfo.__dccp_lhash_wait), >> .__dccp_portalloc_lock = SPIN_LOCK_UNLOCKED >>}; >> >> >> >> >>struct sockaddr_dccp { >> struct sockaddr_in in; >> __u32 service; >>}; >> >>static __inline__ int dccp_hashfn(__u32 laddr, __u16 lport, >> __u32 faddr, __u16 fport) >>{ >> int h = (laddr ^ lport) ^ (faddr ^ fport); >> h ^= h >> 16; >> h ^= h >> 8; >> return h & (dccp_ehash_size - 1);; >>} >> >>static __inline__ int dccp_sk_hashfn(struct sock *sk) >>{ >> struct inet_opt *inet = inet_sk(sk); >> __u32 laddr = inet->rcv_saddr; >> __u16 lport = inet->num; >> __u32 faddr = inet->daddr; >> __u16 fport = inet->dport; >> >> return dccp_hashfn(laddr, lport, faddr, fport); >>} >> >>kmem_cache_t *dccp_bucket_cachep; >> >>struct dccp_bind_bucket *dccp_bucket_create(struct dccp_bind_hashbucket *head, >> unsigned short snum) >>{ >> struct dccp_bind_bucket *db = kmem_cache_alloc(dccp_bucket_cachep, >> SLAB_ATOMIC); >> if (db) { >> db->port = snum; >> db->fastreuse = 0; >> INIT_HLIST_HEAD(&db->owners); >> hlist_add_head(&db->node, &head->chain); >> } >> return db; >>} >> >>void dccp_bucket_destroy(struct dccp_bind_bucket *db) >>{ >> if (hlist_empty(&db->owners)) { >> __hlist_del(&db->node); >> kmem_cache_free(dccp_bucket_cachep, db); >> } >>} >> >>/******************************************************************************/ >> >>static int parse_uaddr(struct sockaddr *uaddr, int addr_len, struct sockaddr_in **iaddr, struct sockaddr_dccp **dccp_addr){ >> if(addr_len < sizeof(struct sockaddr_in)) return -1; >> if(addr_len >= sizeof(struct sockaddr_dccp)){ >> *dccp_addr = (struct sockaddr_dccp *)uaddr; >> *iaddr = &((*dccp_addr)->in); >> }else{ >> *dccp_addr = NULL; >> *iaddr = (struct sockaddr_in *)uaddr; >> } >> return 0; >>} >> >>/******************************************************************************/ >>/* refer to net/ipv4/af_inet.c:inet_bind() */ >>static int dccp_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len){ >> printk("dccp_bind.\n"); >> struct sockaddr_in *iaddr; >> struct sockaddr_dccp *dccp_addr; >> struct inet_opt *inet = inet_sk(sk); >> int addr_type; >> int err; >> unsigned short port; >> >> if(parse_uaddr(uaddr, addr_len, &iaddr, &dccp_addr)) return -EINVAL; >> >> addr_type = inet_addr_type(iaddr->sin_addr.s_addr); >> if( inet->freebind == 0 >> && iaddr->sin_addr.s_addr != INADDR_ANY && addr_type != RTN_LOCAL >> && addr_type != RTN_MULTICAST && addr_type != RTN_BROADCAST) >> return -EADDRNOTAVAIL; >> >> port = ntohs(iaddr->sin_port); >> if(port && port < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) >> return -EACCES; >> >> lock_sock(sk); >> >> if(sk->sk_state != DCCP_STATE_CLOSED) ERR(-EISCONN); >> >> if(inet->num) ERR(-EINVAL); >> >> inet->rcv_saddr = inet->saddr = iaddr->sin_addr.s_addr; >> if(addr_type == RTN_MULTICAST || addr_type == RTN_BROADCAST) >> inet->saddr = 0; >> >> if(dccp_addr) dccp_sk(sk)->service = dccp_addr->service; >> else dccp_sk(sk)->service = 0; >>/*Note if we comment sk_port->getport() function calling, we should assign a local listen port number for building a listen hash and adding hash to node.*/ >>/* >> if(sk->sk_prot->get_port(sk, port) != 0){ >> inet->saddr = inet->rcv_saddr = 0; >> ERR(-EADDRINUSE); >> } >>*/ >> if(inet->rcv_saddr) sk->sk_userlocks |= SOCK_BINDADDR_LOCK; >> if(port) sk->sk_userlocks |= SOCK_BINDPORT_LOCK; >> inet->num = port;/*added 24.08.04, Note if we comment sk_port->getport() function calling, we should assign a local listen port number for building a listen hash and adding hash to node.*/ >> inet->dport = inet->daddr = 0; >> sk_dst_reset(sk); >> err = 0; >>out: >> release_sock(sk); >> return err; >>} >> >>void dccp_bind_hash(struct sock *sk, struct dccp_bind_bucket *db, >> unsigned short snum) >>{ >> inet_sk(sk)->num = snum; >> sk_add_bind_node(sk, &db->owners); >> dccp_sk(sk)->bind_hash = db; >>} >> >>static inline int dccp_bind_conflict(struct sock *sk, struct dccp_bind_bucket *db) >>{ >> printk("dccp_bind_conflict is called.\n"); >> const u32 sk_rcv_saddr = dccp_v4_rcv_saddr(sk); >> struct sock *sk2; >> struct hlist_node *node; >> int reuse = sk->sk_reuse; >> >> sk_for_each_bound(sk2, node, &db->owners) { >> if (sk != sk2 && >> !dccp_v6_ipv6only(sk2) && >> (!sk->sk_bound_dev_if || >> !sk2->sk_bound_dev_if || >> sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) { >> if (!reuse || !sk2->sk_reuse || >> sk2->sk_state == DCCP_STATE_LISTEN) { >> const u32 sk2_rcv_saddr = dccp_v4_rcv_saddr(sk2); >> if (!sk2_rcv_saddr || !sk_rcv_saddr || >> sk2_rcv_saddr == sk_rcv_saddr) >> break; >> } >> } >> } >> return node != NULL; >>} >> >>/* Obtain a reference to a local port for the given sock, >> * if snum is zero it means select any available local port. >> */ >>static int dccp_get_port(struct sock *sk, unsigned short snum) >>{ >> printk("New dccp_get_port start.%d, inet_sk(sk)->num=%d\n",dccp_bhash_size,inet_sk(sk)->num); >> struct dccp_bind_hashbucket *head; >> >> struct hlist_node *node; >> struct dccp_bind_bucket *db; >> int ret; >> >> if(inet_sk(sk)->num !=snum) >> snum=inet_sk(sk)->num; >> local_bh_disable(); >> if (!snum) { >> int low = sysctl_local_port_range[0]; >> int high = sysctl_local_port_range[1]; >> int remaining = (high - low) + 1; >> int rover; >> >> spin_lock(&dccp_portalloc_lock); >> rover = dccp_port_rover; >> do { >> printk("New dccp_get_port start.rover:%d\n",rover); >> rover++; >> if (rover < low || rover > high) >> rover = low; >> head = &dccp_bhash[dccp_bhashfn(rover)]; >> spin_lock(&head->lock); >> db_for_each(db, node, &head->chain) >> if (db->port == rover) >> goto next; >> break; >> next: >> spin_unlock(&head->lock); >> } while (--remaining > 0); >> dccp_port_rover = rover; >> spin_unlock(&dccp_portalloc_lock); >> >> /* Exhausted local port range during search? */ >> ret = 1; >> if (remaining <= 0) >> goto fail; >> >> /* OK, here is the one we will use. HEAD is >> * non-NULL and we hold it's mutex. >> */ >> printk("New dccp_get_port start.if:OK\n"); >> snum = rover; >> } else { >> printk("New dccp_get_port start.else:start\n"); >> head = &dccp_bhash[dccp_bhashfn(snum)]; >> spin_lock(&head->lock); >> db_for_each(db, node, &head->chain) >> if (db->port == snum) >> goto db_found; >> } >> db = NULL; >> goto db_not_found; >>db_found: >> if (!hlist_empty(&db->owners)) { >> printk("hlist_empty(&db->owners) not empty.\n"); >> if (sk->sk_reuse > 1) >> goto success; >> if (db->fastreuse > 0 && >> sk->sk_reuse && sk->sk_state != DCCP_STATE_LISTEN) { >> goto success; >> } else { >> ret = 1; >> if (dccp_bind_conflict(sk, db)) >> goto fail_unlock; >> } >> } >>db_not_found: >> printk("db not found.\n"); >> ret = 1; >> if (!db && (db = dccp_bucket_create(head, snum)) == NULL) >> goto fail_unlock; >> if (hlist_empty(&db->owners)) { >> if (sk->sk_reuse && sk->sk_state != DCCP_STATE_LISTEN) >> db->fastreuse = 1; >> else >> db->fastreuse = 0; >> } else if (db->fastreuse && >> (!sk->sk_reuse || sk->sk_state == DCCP_STATE_LISTEN)) >> db->fastreuse = 0; >>success: >> if (!dccp_sk(sk)->bind_hash){ >> dccp_bind_hash(sk, db, snum); >> printk("bind hash add:sk:%x,node:%x,snum:%d\n",sk,node,snum); >> } >> BUG_TRAP(dccp_sk(sk)->bind_hash == db); >> ret = 0; >> >>fail_unlock: >> spin_unlock(&head->lock); >>fail: >> local_bh_enable(); >> printk("New dccp_get_port start.OK. sk:%x,node:%x\n",sk,node); >> return ret; >>} >>/*****************************************************************************/ >>static int wait_for_incoming_connection(struct sock *sk, long timeo) >>{ >> printk("wait_for_incoming_connection: \n"); >> DECLARE_WAITQUEUE(wait, current); >> int err; >> struct dccp_opt *tp = dccp_sk(sk); >> >> /* >> * True wake-one mechanism for incoming connections: only >> * one process gets woken up, not the 'whole herd'. >> * Since we do not 'race & poll' for established sockets >> * anymore, the common case will execute the loop only once. >> * >> * Subtle issue: "add_wait_queue_exclusive()" will be added >> * after any current non-exclusive waiters, and we know that >> * it will always _stay_ after any new non-exclusive waiters >> * because all non-exclusive waiters are added at the >> * beginning of the wait-queue. As such, it's ok to "drop" >> * our exclusiveness temporarily when we get woken up without >> * having to remove and re-insert us on the wait queue. >> */ >> add_wait_queue_exclusive(sk->sk_sleep, &wait); >> printk("dccp wait for connect start!sk:%x\n",sk); >> for (;;) { >> current->state = TASK_INTERRUPTIBLE; >> release_sock(sk); >> printk("dccp wait for connect start!..sk:%x\n",sk); >> if (tp->accept_queue == NULL){ >> timeo = schedule_timeout(timeo); >> } >> printk("dccp wait for connect start .1!sk_state=%d, sk_family=%d\n",sk->sk_state,sk->sk_family); >> lock_sock(sk); >> err = 0; >> if (tp->accept_queue){ >> break; >> } >> err = -EINVAL; >> printk("dccp wait for connect start .1!sk_state=%d, sk_family=%d\n",sk->sk_state,sk->sk_family); >> if (sk->sk_state != DCCP_STATE_LISTEN){ >> printk("dccp wait for connect start .01!sk_state=%d\n",sk->sk_state); >> break; >> } >> err = sock_intr_errno(timeo); >> printk("dccp wait for connect start .2!\n"); >> if (signal_pending(current)){ >> break; >> } >> err = -EAGAIN; >> if (!timeo) >> break; >> } >> printk("dccp wait for connect end!\n"); >> current->state = TASK_RUNNING; >> remove_wait_queue(sk->sk_sleep, &wait); >> printk("dccp wait for connect end ok err=%d\n",err); >> return err; >>} >> >>struct sock *dccp_accept(struct sock *sk, int flags, int *err){ >> struct dccp_opt *tp = dccp_sk(sk); >> int error; >> struct sock *newsk = NULL; >> >> lock_sock(sk); >> >> printk("dccp_accept start.%d,sk->sk_family=%d,sk->sk_state=%d,sk:%x\n",inet_sk(sk)->num,sk->sk_family,sk->sk_state,sk); >> /* this socket must be listening */ >> error = -EINVAL; >> printk("dccp_accept 1 ..flags=%d\n",flags); >> if(sk->sk_state != DCCP_STATE_LISTEN) >> goto out; >> printk("dccp_accept 2 ..\n"); >> >> /* Find already established connection */ >> if(!tp->accept_queue){ >> long timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); >> printk("dccp_accept 3 ..timeo=%d,sk:%x\n",timeo,sk); >> >> error = -EAGAIN; >> if(!timeo) >> goto out; >> >> error = wait_for_incoming_connection(sk, timeo); >>// error = wait_for_connection(sk, timeo); >> printk("dccp_accept 4 ..\n"); >> //sleep(1000); >> if(error) goto out; >> BUG_TRAP(tp->accept_queue); >> } >> printk("dccp_accept 5 ..\n"); >> newsk = tp->accept_queue; >> tp->accept_queue = sk_next(newsk);//newsk->sk_bind_next; >> if(tp->accept_queue == NULL) tp->accept_queue_tail = NULL; >> BUG_TRAP(sk->sk_ack_backlog); >> sk->sk_ack_backlog -- ; /* since we are removing one */ >> dccp_sk(newsk)->flag_hashandle = 1; >>#if 0 >> /* remove from accept queue, will be referenced by socket */ >> sock_put(newsk); /* removed from the queue */ >> sock_hold(newsk); >>#endif >> >> error = 0; >>out: >> printk("dccp_accept 6 ..err=%d\n",err); >> release_sock(sk); >> *err = error; >> return newsk; >>} >> >>void dccp_listen_wlock(void) >>{ >> write_lock(&dccp_lhash_lock); >> >> if (atomic_read(&dccp_lhash_users)) { >> DEFINE_WAIT(wait); >> >> for (;;) { >> prepare_to_wait_exclusive(&dccp_lhash_wait, >> &wait, TASK_UNINTERRUPTIBLE); >> if (!atomic_read(&dccp_lhash_users)) >> break; >> write_unlock_bh(&dccp_lhash_lock); >> schedule(); >> write_lock_bh(&dccp_lhash_lock); >> } >> >> finish_wait(&dccp_lhash_wait, &wait); >> } >>} >> >>static __inline__ void __dccp_v4_hash(struct sock *sk, const int listen_possible) >>{ >> struct hlist_head *list; >> rwlock_t *lock; >> >> BUG_TRAP(sk_unhashed(sk)); >> if (listen_possible && sk->sk_state == DCCP_STATE_LISTEN) { >> list = &dccp_listening_hash[dccp_sk_listen_hashfn(sk)]; >> >> printk("__dccp_v4_hash, list:%x,num:%d,%x\n",list,inet_sk(sk)->num,&dccp_hash[inet_sk(sk)->num & (DCCP_HTABLE_SIZE - 1)]); >> lock = &dccp_lhash_lock; >> dccp_listen_wlock(); >> } else { >> list = &dccp_ehash[(sk->sk_hashent = dccp_sk_hashfn(sk))].chain; >> lock = &dccp_ehash[sk->sk_hashent].lock; >> write_lock(lock); >> } >> __sk_add_node(sk, list); >> sock_prot_inc_use(sk->sk_prot); >> write_unlock(lock); >> if (listen_possible && sk->sk_state == DCCP_STATE_LISTEN) >> wake_up(&dccp_lhash_wait); >> printk("__dccp_v4_hash, list:%x,sk:%x\n",list,sk); >>} >> >>static void dccp_v4_hash(struct sock *sk) >>{ >> if (sk->sk_state != DCCP_STATE_CLOSED) { >> local_bh_disable(); >> __dccp_v4_hash(sk, 1); >> local_bh_enable(); >> } >>} >> >>void dccp_unhash(struct sock *sk) >>{ >> rwlock_t *lock; >> >> if (sk_unhashed(sk)) >> goto ende; >> >> if (sk->sk_state == DCCP_STATE_LISTEN) { >> local_bh_disable(); >> dccp_listen_wlock(); >> lock = &dccp_lhash_lock; >> } else { >> struct dccp_ehash_bucket *head = &dccp_ehash[sk->sk_hashent]; >> lock = &head->lock; >> write_lock_bh(&head->lock); >> } >> >> if (__sk_del_node_init(sk)) >> sock_prot_dec_use(sk->sk_prot); >> write_unlock_bh(lock); >> >> ende: >> if (sk->sk_state == DCCP_STATE_LISTEN) >> wake_up(&dccp_lhash_wait); >>} >> >>/*****************************************************************************/ >>static struct sock *__dccp_v4_lookup_listen(struct hlist_head *head, u32 daddr, >> unsigned short hnum, int dif) >>{ >> struct sock *result = NULL, *sk; >> struct hlist_node *node; >> int score, hiscore; >> >> printk("__dccp_v4_lookup_listen: sk:%x,node:%x,head:%x,sk_state:%d\n",sk,node,head,sk->sk_state); >> hiscore=-1; >> sk_for_each(sk, node, head) { >> struct inet_opt *inet = inet_sk(sk); >> >> if (inet->num == hnum && !ipv6_only_sock(sk)) { >> __u32 rcv_saddr = inet->rcv_saddr; >> >> score = (sk->sk_family == PF_INET ? 1 : 0); >> if (rcv_saddr) { >> if (rcv_saddr != daddr) >> continue; >> score+=2; >> } >> if (sk->sk_bound_dev_if) { >> if (sk->sk_bound_dev_if != dif) >> continue; >> score+=2; >> } >> if (score == 5) >> return sk; >> if (score > hiscore) { >> hiscore = score; >> result = sk; >> } >> } >> } >> printk("dccp_v4_lookup_listen:sk:%x,result:%x\n",sk,result); >> return result; >>} >> >>/* Optimize the common listener case. */ >>inline struct sock *dccp_v4_lookup_listen(u32 daddr, u16 hnum,int dif) >>{ >> struct sock *sk = NULL; >> struct hlist_head *head; >> >> read_lock(&dccp_lhash_lock); >> printk("dccp_bhash_size: %d,ntohs(dport):%d\n",dccp_bhash_size,hnum); >> head = &dccp_listening_hash[dccp_lhashfn(hnum)]; >> >> if(head->first) >> printk("first of head is not empty\n"); >> >> printk("dccp_v4_lookup_listen: head: %x,%x,__sk_head(head):%x\n",head,&dccp_hash[hnum & (DCCP_HTABLE_SIZE - 1)],__sk_head(head)); >> >> if (!hlist_empty(head)) { >> struct inet_opt *inet = inet_sk((sk = __sk_head(head))); >> printk("dccp_v4_lookup_listen:sk: %x\n",sk); >> >> if (inet->num == hnum && !sk->sk_node.next && >> (!inet->rcv_saddr || inet->rcv_saddr == daddr) && >> (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) && >> !sk->sk_bound_dev_if) >> goto sherry_cache; >> sk = __dccp_v4_lookup_listen(head, daddr, hnum, dif); >> } >> else >> printk("hlist_empty(head) is empty.\n"); >> if (sk) { >>sherry_cache: >> sock_hold(sk); >> } >> printk("dccp_v4_lookup_listen:sk: %x\n",sk); >> read_unlock(&dccp_lhash_lock); >> return sk; >>} >> >> >>/*****************************************************************************/ >> >>static inline struct sock *dccp_v4_lookup_connection(u32 saddr, u16 sport, u32 daddr, u16 hnum, int dif){ >> printk("dccp_v4_lookup_connection.\n"); >> struct dccp_ehash_bucket *head; >> DCCP_V4_ADDR_COOKIE(acookie, saddr, daddr) >> __u32 ports = DCCP_COMBINED_PORTS(sport, hnum); >> struct sock *sk; >> struct hlist_node *node; >> int hash = dccp_hashfn(daddr, hnum, saddr, sport); >> printk("hash %d\n",hash); >> head = &dccp_ehash[hash]; >> printk("dccp_v4_lookup_connection. head:%x,node:%x,sk:%x\n",head,node,sk); >> read_lock(&head->lock); >> sk_for_each(sk, node, &head->chain) { >> if (DCCP_IPV4_MATCH(sk, acookie, saddr, daddr, ports, dif)) >> goto hit; >> } >> >> sk_for_each(sk, node, &(head + dccp_ehash_size)->chain) { >> if (DCCP_IPV4_DW_MATCH(sk, acookie, saddr, daddr, ports, dif)) >> goto hit; >> } >> sk = NULL; >>out: >> read_unlock(&head->lock); >> printk("dccp_v4_lookup_connection. head:%x,node:,sk:%x\n",head,sk); >> return sk; >>hit: >> sock_hold(sk); >> goto out; >>} >> >>/*****************************************************************************/ >> >>static inline struct sock *__dccp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport,int dif){ >> printk("__dccp_v4_lookup.\n"); >> >> struct sock *sk = dccp_v4_lookup_connection(saddr, sport, daddr, ntohs(dport), dif); >> return sk ? : dccp_v4_lookup_listen(daddr, ntohs(dport),dif); >>} >> >>inline struct sock *dccp_v4_lookup(u32 saddr, u16 sport, u32 daddr, >> u16 dport, int dif) >>{ >> printk("dccp_v4_lookup\n"); >> struct sock *sk; >> >> local_bh_disable(); >> sk = __dccp_v4_lookup(saddr, sport, daddr, dport, dif); >> local_bh_enable(); >> >> return sk; >>} >> >>Best regards, >> >>Zhikui >> >> >> >> >> > > > > From vatsa@in.ibm.com Wed Sep 1 04:34:48 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 04:35:01 -0700 (PDT) Received: from e6.ny.us.ibm.com (e6.ny.us.ibm.com [32.97.182.106]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81BYlS7017442 for ; Wed, 1 Sep 2004 04:34:48 -0700 Received: from northrelay04.pok.ibm.com (northrelay04.pok.ibm.com [9.56.224.206]) by e6.ny.us.ibm.com (8.12.10/8.12.9) with ESMTP id i81BYOnt158880; Wed, 1 Sep 2004 07:34:24 -0400 Received: from snowy.in.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by northrelay04.pok.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i81BZSGY128368; Wed, 1 Sep 2004 07:35:32 -0400 Received: by snowy.in.ibm.com (Postfix, from userid 502) id 981C424E32; Wed, 1 Sep 2004 17:06:41 +0530 (IST) Date: Wed, 1 Sep 2004 17:06:41 +0530 From: Srivatsa Vaddagiri To: Andi Kleen Cc: davem@redhat.com, netdev@oss.sgi.com, linux-kernel@vger.kernel.org, Dipankar , paulmck@us.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Message-ID: <20040901113641.GA3918@in.ibm.com> Reply-To: vatsa@in.ibm.com References: <20040831125941.GA5534@in.ibm.com> <20040831135419.GA17642@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040831135419.GA17642@wotan.suse.de> User-Agent: Mutt/1.4.1i X-archive-position: 8300 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vatsa@in.ibm.com Precedence: bulk X-list: netdev On Tue, Aug 31, 2004 at 03:54:20PM +0200, Andi Kleen wrote: > I bet also when you just do rdtsc timing for the TCP receive > path the cycle numbers will be way down (excluding the copy). I got cycle numbers for the lookup routine (with CONFIG_PREEMPT turned off). They were taken on a 900MHz 8way Intel P3 SMP box. The results are as below: ------------------------------------------------------------------------------- | 2.6.8.1 | 2.6.8.1 + my patch ------------------------------------------------------------------------------- Average cycles | | spent in | | __tcp_v4_lookup_established | 2970.65 | 668.227 | (~3.3 micro-seconds) | (~0.74 microseconds) ------------------------------------------------------------------------------- This repesents improvement by a factor of 77.5%! > > And it should also fix the performance problems with > cat /proc/net/tcp on ppc64/ia64 for large hash tables because the rw locks > are gone. But spinlocks are in! Would that still improve the performance compared to rw locks? (See me earlier note where I have explained that lookup done for /proc/net/tcp is _not_ lock-free yet). > I haven't studied it in detail (yet), just two minor style > comments: [snip] > Can you rewrite that without goto? [snip] > And that too. I have avoided the goto's in the updated patch below. Thanks!! --- linux-2.6.8.1-vatsa/include/net/sock.h | 22 +++++++++-- linux-2.6.8.1-vatsa/include/net/tcp.h | 24 +++++++++--- linux-2.6.8.1-vatsa/net/core/sock.c | 11 +++++ linux-2.6.8.1-vatsa/net/ipv4/tcp.c | 2 - linux-2.6.8.1-vatsa/net/ipv4/tcp_diag.c | 11 +++-- linux-2.6.8.1-vatsa/net/ipv4/tcp_ipv4.c | 50 ++++++++++++++++----------- linux-2.6.8.1-vatsa/net/ipv4/tcp_minisocks.c | 47 ++++++++++++++++++++----- linux-2.6.8.1-vatsa/net/ipv6/tcp_ipv6.c | 22 +++++++---- 8 files changed, 135 insertions(+), 54 deletions(-) diff -puN include/net/sock.h~tcp_ehash include/net/sock.h --- linux-2.6.8.1/include/net/sock.h~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/include/net/sock.h 2004-09-01 10:09:43.000000000 +0530 @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -178,6 +179,7 @@ struct sock_common { * @sk_error_report - callback to indicate errors (e.g. %MSG_ERRQUEUE) * @sk_backlog_rcv - callback to process the backlog * @sk_destruct - called at sock freeing time, i.e. when all refcnt == 0 + * @sk_rcu - RCU callback structure */ struct sock { /* @@ -266,6 +268,7 @@ struct sock { int (*sk_backlog_rcv)(struct sock *sk, struct sk_buff *skb); void (*sk_destruct)(struct sock *sk); + struct rcu_head sk_rcu; }; /* @@ -350,7 +353,7 @@ static __inline__ int sk_del_node_init(s static __inline__ void __sk_add_node(struct sock *sk, struct hlist_head *list) { - hlist_add_head(&sk->sk_node, list); + hlist_add_head_rcu(&sk->sk_node, list); } static __inline__ void sk_add_node(struct sock *sk, struct hlist_head *list) @@ -371,7 +374,7 @@ static __inline__ void sk_add_bind_node( } #define sk_for_each(__sk, node, list) \ - hlist_for_each_entry(__sk, node, list, sk_node) + hlist_for_each_entry_rcu(__sk, node, list, sk_node) #define sk_for_each_from(__sk, node) \ if (__sk && ({ node = &(__sk)->sk_node; 1; })) \ hlist_for_each_entry_from(__sk, node, sk_node) @@ -703,6 +706,7 @@ extern void FASTCALL(release_sock(struct extern struct sock * sk_alloc(int family, int priority, int zero_it, kmem_cache_t *slab); extern void sk_free(struct sock *sk); +extern void sk_free_rcu(struct rcu_head *head); extern struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, @@ -888,8 +892,18 @@ static inline void sk_filter_charge(stru /* Ungrab socket and destroy it, if it was the last reference. */ static inline void sock_put(struct sock *sk) { - if (atomic_dec_and_test(&sk->sk_refcnt)) - sk_free(sk); + while (atomic_dec_and_test(&sk->sk_refcnt)) { + /* Restore ref count and schedule callback. + * If we don't restore ref count, then the callback can be + * scheduled by more than one CPU. + */ + atomic_inc(&sk->sk_refcnt); + + if (atomic_read(&sk->sk_refcnt) == 1) { + call_rcu(&sk->sk_rcu, sk_free_rcu); + break; + } + } } /* Detach socket from process context. diff -puN include/net/tcp.h~tcp_ehash include/net/tcp.h --- linux-2.6.8.1/include/net/tcp.h~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/include/net/tcp.h 2004-09-01 10:13:40.000000000 +0530 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,7 @@ * for the rest. I'll experiment with dynamic table growth later. */ struct tcp_ehash_bucket { - rwlock_t lock; + spinlock_t lock; struct hlist_head chain; } __attribute__((__aligned__(8))); @@ -222,12 +223,13 @@ struct tcp_tw_bucket { struct in6_addr tw_v6_rcv_saddr; int tw_v6_ipv6only; #endif + struct rcu_head tw_rcu; }; static __inline__ void tw_add_node(struct tcp_tw_bucket *tw, struct hlist_head *list) { - hlist_add_head(&tw->tw_node, list); + hlist_add_head_rcu(&tw->tw_node, list); } static __inline__ void tw_add_bind_node(struct tcp_tw_bucket *tw, @@ -305,14 +307,22 @@ static inline int tcp_v6_ipv6only(const #endif extern kmem_cache_t *tcp_timewait_cachep; +extern void tcp_tw_free(struct rcu_head *head); static inline void tcp_tw_put(struct tcp_tw_bucket *tw) { - if (atomic_dec_and_test(&tw->tw_refcnt)) { -#ifdef INET_REFCNT_DEBUG - printk(KERN_DEBUG "tw_bucket %p released\n", tw); -#endif - kmem_cache_free(tcp_timewait_cachep, tw); + while (atomic_dec_and_test(&tw->tw_refcnt)) { + /* Restore ref count and schedule callback. + * If we don't restore ref count, then the callback can be + * scheduled by more than one CPU. + */ + + atomic_inc(&tw->tw_refcnt); + + if (atomic_read(&tw->tw_refcnt) == 1) { + call_rcu(&tw->tw_rcu, tcp_tw_free); + break; + } } } diff -puN net/core/sock.c~tcp_ehash net/core/sock.c --- linux-2.6.8.1/net/core/sock.c~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/net/core/sock.c 2004-08-26 16:53:14.000000000 +0530 @@ -657,6 +657,16 @@ void sk_free(struct sock *sk) module_put(owner); } +/* RCU callback to free a socket */ + +void sk_free_rcu(struct rcu_head *head) +{ + struct sock *sk = container_of(head, struct sock, sk_rcu); + + if (atomic_dec_and_test(&sk->sk_refcnt)) + sk_free(sk); +} + void __init sk_init(void) { sk_cachep = kmem_cache_create("sock", sizeof(struct sock), 0, @@ -1347,6 +1357,7 @@ EXPORT_SYMBOL(__lock_sock); EXPORT_SYMBOL(__release_sock); EXPORT_SYMBOL(sk_alloc); EXPORT_SYMBOL(sk_free); +EXPORT_SYMBOL(sk_free_rcu); EXPORT_SYMBOL(sk_send_sigurg); EXPORT_SYMBOL(sock_alloc_send_pskb); EXPORT_SYMBOL(sock_alloc_send_skb); diff -puN net/ipv4/tcp_ipv4.c~tcp_ehash net/ipv4/tcp_ipv4.c --- linux-2.6.8.1/net/ipv4/tcp_ipv4.c~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/net/ipv4/tcp_ipv4.c 2004-08-25 18:07:27.000000000 +0530 @@ -351,7 +351,8 @@ void tcp_listen_wlock(void) static __inline__ void __tcp_v4_hash(struct sock *sk, const int listen_possible) { struct hlist_head *list; - rwlock_t *lock; + rwlock_t *lock = NULL; + spinlock_t *slock = NULL; BUG_TRAP(sk_unhashed(sk)); if (listen_possible && sk->sk_state == TCP_LISTEN) { @@ -360,14 +361,16 @@ static __inline__ void __tcp_v4_hash(str tcp_listen_wlock(); } else { list = &tcp_ehash[(sk->sk_hashent = tcp_sk_hashfn(sk))].chain; - lock = &tcp_ehash[sk->sk_hashent].lock; - write_lock(lock); + slock = &tcp_ehash[sk->sk_hashent].lock; + spin_lock(slock); } __sk_add_node(sk, list); sock_prot_inc_use(sk->sk_prot); - write_unlock(lock); - if (listen_possible && sk->sk_state == TCP_LISTEN) + if (listen_possible && sk->sk_state == TCP_LISTEN) { + write_unlock(lock); wake_up(&tcp_lhash_wait); + } else + spin_unlock(slock); } static void tcp_v4_hash(struct sock *sk) @@ -381,7 +384,8 @@ static void tcp_v4_hash(struct sock *sk) void tcp_unhash(struct sock *sk) { - rwlock_t *lock; + rwlock_t *lock = NULL; + spinlock_t *slock = NULL; if (sk_unhashed(sk)) goto ende; @@ -392,17 +396,20 @@ void tcp_unhash(struct sock *sk) lock = &tcp_lhash_lock; } else { struct tcp_ehash_bucket *head = &tcp_ehash[sk->sk_hashent]; - lock = &head->lock; - write_lock_bh(&head->lock); + slock = &head->lock; + spin_lock_bh(&head->lock); } if (__sk_del_node_init(sk)) sock_prot_dec_use(sk->sk_prot); - write_unlock_bh(lock); + if (sk->sk_state != TCP_LISTEN) + spin_unlock_bh(slock); + else { + write_unlock_bh(lock); ende: - if (sk->sk_state == TCP_LISTEN) wake_up(&tcp_lhash_wait); + } } /* Don't inline this cruft. Here are some nice properties to @@ -494,7 +501,7 @@ static inline struct sock *__tcp_v4_look */ int hash = tcp_hashfn(daddr, hnum, saddr, sport); head = &tcp_ehash[hash]; - read_lock(&head->lock); + rcu_read_lock(); sk_for_each(sk, node, &head->chain) { if (TCP_IPV4_MATCH(sk, acookie, saddr, daddr, ports, dif)) goto hit; /* You sunk my battleship! */ @@ -507,7 +514,7 @@ static inline struct sock *__tcp_v4_look } sk = NULL; out: - read_unlock(&head->lock); + rcu_read_unlock(); return sk; hit: sock_hold(sk); @@ -559,7 +566,7 @@ static int __tcp_v4_check_established(st struct hlist_node *node; struct tcp_tw_bucket *tw; - write_lock(&head->lock); + spin_lock(&head->lock); /* Check TIME-WAIT sockets first. */ sk_for_each(sk2, node, &(head + tcp_ehash_size)->chain) { @@ -614,7 +621,7 @@ unique: BUG_TRAP(sk_unhashed(sk)); __sk_add_node(sk, &head->chain); sock_prot_inc_use(sk->sk_prot); - write_unlock(&head->lock); + spin_unlock(&head->lock); if (twp) { *twp = tw; @@ -630,7 +637,7 @@ unique: return 0; not_unique: - write_unlock(&head->lock); + spin_unlock(&head->lock); return -EADDRNOTAVAIL; } @@ -2228,7 +2235,10 @@ static void *established_get_first(struc struct hlist_node *node; struct tcp_tw_bucket *tw; - read_lock(&tcp_ehash[st->bucket].lock); + /* Take the spinlock. Otherwise a dancing socket + * (__tcp_tw_hashdance) may be reported twice! + */ + spin_lock(&tcp_ehash[st->bucket].lock); sk_for_each(sk, node, &tcp_ehash[st->bucket].chain) { if (sk->sk_family != st->family) { continue; @@ -2245,7 +2255,7 @@ static void *established_get_first(struc rc = tw; goto out; } - read_unlock(&tcp_ehash[st->bucket].lock); + spin_unlock(&tcp_ehash[st->bucket].lock); st->state = TCP_SEQ_STATE_ESTABLISHED; } out: @@ -2272,10 +2282,10 @@ get_tw: cur = tw; goto out; } - read_unlock(&tcp_ehash[st->bucket].lock); + spin_unlock(&tcp_ehash[st->bucket].lock); st->state = TCP_SEQ_STATE_ESTABLISHED; if (++st->bucket < tcp_ehash_size) { - read_lock(&tcp_ehash[st->bucket].lock); + spin_lock(&tcp_ehash[st->bucket].lock); sk = sk_head(&tcp_ehash[st->bucket].chain); } else { cur = NULL; @@ -2385,7 +2395,7 @@ static void tcp_seq_stop(struct seq_file case TCP_SEQ_STATE_TIME_WAIT: case TCP_SEQ_STATE_ESTABLISHED: if (v) - read_unlock(&tcp_ehash[st->bucket].lock); + spin_unlock(&tcp_ehash[st->bucket].lock); local_bh_enable(); break; } diff -puN net/ipv4/tcp.c~tcp_ehash net/ipv4/tcp.c --- linux-2.6.8.1/net/ipv4/tcp.c~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/net/ipv4/tcp.c 2004-08-25 18:07:27.000000000 +0530 @@ -2258,7 +2258,7 @@ void __init tcp_init(void) if (!tcp_ehash) panic("Failed to allocate TCP established hash table\n"); for (i = 0; i < (tcp_ehash_size << 1); i++) { - tcp_ehash[i].lock = RW_LOCK_UNLOCKED; + tcp_ehash[i].lock = SPIN_LOCK_UNLOCKED; INIT_HLIST_HEAD(&tcp_ehash[i].chain); } diff -puN net/ipv4/tcp_diag.c~tcp_ehash net/ipv4/tcp_diag.c --- linux-2.6.8.1/net/ipv4/tcp_diag.c~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/net/ipv4/tcp_diag.c 2004-08-25 18:07:27.000000000 +0530 @@ -522,7 +522,10 @@ skip_listen_ht: if (i > s_i) s_num = 0; - read_lock_bh(&head->lock); + /* Take the spinlock. Otherwise a dancing socket + * (__tcp_tw_hashdance) may be reported twice! + */ + spin_lock_bh(&head->lock); num = 0; sk_for_each(sk, node, &head->chain) { @@ -542,7 +545,7 @@ skip_listen_ht: if (tcpdiag_fill(skb, sk, r->tcpdiag_ext, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq) <= 0) { - read_unlock_bh(&head->lock); + spin_unlock_bh(&head->lock); goto done; } ++num; @@ -568,13 +571,13 @@ skip_listen_ht: if (tcpdiag_fill(skb, sk, r->tcpdiag_ext, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq) <= 0) { - read_unlock_bh(&head->lock); + spin_unlock_bh(&head->lock); goto done; } ++num; } } - read_unlock_bh(&head->lock); + spin_unlock_bh(&head->lock); } done: diff -puN net/ipv4/tcp_minisocks.c~tcp_ehash net/ipv4/tcp_minisocks.c --- linux-2.6.8.1/net/ipv4/tcp_minisocks.c~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/net/ipv4/tcp_minisocks.c 2004-08-26 16:58:08.000000000 +0530 @@ -64,14 +64,14 @@ static void tcp_timewait_kill(struct tcp /* Unlink from established hashes. */ ehead = &tcp_ehash[tw->tw_hashent]; - write_lock(&ehead->lock); + spin_lock(&ehead->lock); if (hlist_unhashed(&tw->tw_node)) { - write_unlock(&ehead->lock); + spin_unlock(&ehead->lock); return; } __hlist_del(&tw->tw_node); sk_node_init(&tw->tw_node); - write_unlock(&ehead->lock); + spin_unlock(&ehead->lock); /* Disassociate with bind bucket. */ bhead = &tcp_bhash[tcp_bhashfn(tw->tw_num)]; @@ -308,17 +308,28 @@ static void __tcp_tw_hashdance(struct so tw_add_bind_node(tw, &tw->tw_tb->owners); spin_unlock(&bhead->lock); - write_lock(&ehead->lock); + spin_lock(&ehead->lock); - /* Step 2: Remove SK from established hash. */ - if (__sk_del_node_init(sk)) - sock_prot_dec_use(sk->sk_prot); + /* + * We have to be carefull here since there could be racing + * (lock-free) lookups happening on other CPUs. If we remove SK first + * and then add TW, then there is a tiny window where this socket is + * in neither the established half nor in the TIMEWAIT half of the ehash + * table. Lookups occuring in that window can drop packets! + * Hence we first add TW and then remove SK, with a barrier in between. + */ - /* Step 3: Hash TW into TIMEWAIT half of established hash table. */ + /* Step 2: Hash TW into TIMEWAIT half of established hash table. */ tw_add_node(tw, &(ehead + tcp_ehash_size)->chain); atomic_inc(&tw->tw_refcnt); - write_unlock(&ehead->lock); + smp_wmb(); + + /* Step 3: Remove SK from established hash. */ + if (__sk_del_node_init(sk)) + sock_prot_dec_use(sk->sk_prot); + + spin_unlock(&ehead->lock); } /* @@ -1069,11 +1080,29 @@ int tcp_child_process(struct sock *paren return ret; } +/* RCU callback to free a timewait bucket */ + +void tcp_tw_free(struct rcu_head *head) +{ + struct tcp_tw_bucket *tw = + container_of(head, struct tcp_tw_bucket, tw_rcu); + + if (atomic_dec_and_test(&tw->tw_refcnt)) { +#ifdef INET_REFCNT_DEBUG + printk(KERN_DEBUG "tw_bucket %p released\n", tw); +#endif + kmem_cache_free(tcp_timewait_cachep, tw); + } +} + + + EXPORT_SYMBOL(tcp_check_req); EXPORT_SYMBOL(tcp_child_process); EXPORT_SYMBOL(tcp_create_openreq_child); EXPORT_SYMBOL(tcp_timewait_state_process); EXPORT_SYMBOL(tcp_tw_deschedule); +EXPORT_SYMBOL(tcp_tw_free); #ifdef CONFIG_SYSCTL EXPORT_SYMBOL(sysctl_tcp_tw_recycle); diff -puN net/ipv6/tcp_ipv6.c~tcp_ehash net/ipv6/tcp_ipv6.c --- linux-2.6.8.1/net/ipv6/tcp_ipv6.c~tcp_ehash 2004-08-25 18:06:42.000000000 +0530 +++ linux-2.6.8.1-vatsa/net/ipv6/tcp_ipv6.c 2004-08-25 18:07:27.000000000 +0530 @@ -210,7 +210,8 @@ fail: static __inline__ void __tcp_v6_hash(struct sock *sk) { struct hlist_head *list; - rwlock_t *lock; + rwlock_t *lock = NULL; + spinlock_t *slock = NULL; BUG_TRAP(sk_unhashed(sk)); @@ -221,13 +222,16 @@ static __inline__ void __tcp_v6_hash(str } else { sk->sk_hashent = tcp_v6_sk_hashfn(sk); list = &tcp_ehash[sk->sk_hashent].chain; - lock = &tcp_ehash[sk->sk_hashent].lock; - write_lock(lock); + slock = &tcp_ehash[sk->sk_hashent].lock; + spin_lock(slock); } __sk_add_node(sk, list); sock_prot_inc_use(sk->sk_prot); - write_unlock(lock); + if (sk->sk_state == TCP_LISTEN) + write_unlock(lock); + else + spin_unlock(slock); } @@ -307,7 +311,7 @@ static inline struct sock *__tcp_v6_look */ hash = tcp_v6_hashfn(daddr, hnum, saddr, sport); head = &tcp_ehash[hash]; - read_lock(&head->lock); + rcu_read_lock(); sk_for_each(sk, node, &head->chain) { /* For IPV6 do the cheaper port and family tests first. */ if(TCP_IPV6_MATCH(sk, saddr, daddr, ports, dif)) @@ -326,12 +330,12 @@ static inline struct sock *__tcp_v6_look goto hit; } } - read_unlock(&head->lock); + rcu_read_unlock(); return NULL; hit: sock_hold(sk); - read_unlock(&head->lock); + rcu_read_unlock(); return sk; } @@ -452,7 +456,7 @@ static int tcp_v6_check_established(stru struct hlist_node *node; struct tcp_tw_bucket *tw; - write_lock_bh(&head->lock); + spin_lock_bh(&head->lock); /* Check TIME-WAIT sockets first. */ sk_for_each(sk2, node, &(head + tcp_ehash_size)->chain) { @@ -491,7 +495,7 @@ unique: __sk_add_node(sk, &head->chain); sk->sk_hashent = hash; sock_prot_inc_use(sk->sk_prot); - write_unlock_bh(&head->lock); + spin_unlock_bh(&head->lock); if (tw) { /* Silly. Should hash-dance instead... */ _ -- Thanks and Regards, Srivatsa Vaddagiri, Linux Technology Center, IBM Software Labs, Bangalore, INDIA - 560017 From DanE@aiinet.com Wed Sep 1 07:13:35 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 07:13:42 -0700 (PDT) Received: from aiexchange.ai.aiinet.com (ai181-26.aiinet.com [205.245.181.26]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81EDZc4021183 for ; Wed, 1 Sep 2004 07:13:35 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C4902D.D3F1B09D" Subject: RE: [Bridge] BCP status Date: Wed, 1 Sep 2004 10:13:17 -0400 Message-ID: X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [Bridge] BCP status Thread-Index: AcSQBeEZdLXyu5JNTQGZbEJfr4S2kAAIN/oA From: "Eble, Dan" To: "Petter Larsen" Cc: , X-archive-position: 8301 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: DanE@aiinet.com Precedence: bulk X-list: netdev This is a multi-part message in MIME format. ------_=_NextPart_001_01C4902D.D3F1B09D Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Petter Larsen [mailto:petter.larsen@morecom.no]=20 > Subject: RE: [Bridge] BCP status >=20 > Ok. The patches that you sent to the mailing list in March,=20 > are they the latest from your side? You mentioned that you had some=20 > plug-ins for HDLC ppp-layer drivers. =20 >=20 > Are you working on this now, or are you finished?=20 Nothing is ever finished; however, I have not worked on it for months. Kernel BCP patch: http://marc.theaimsgroup.com/?l=3Dlinux-ppp&m=3D107814944215772&w=3D2 No changes since then, AFAICT. PPP daemon BCP patch: http://marc.theaimsgroup.com/?l=3Dlinux-ppp&m=3D107772784930462&w=3D2 No changes since then, AFAICT. PPP daemon "wanppp" plugin: http://marc.theaimsgroup.com/?l=3Dlinux-ppp&m=3D105526128502635&w=3D2 It looks current except for a correction of spelling (s/compliled/compiled/) and the addition of prototypes for wanppp_cleanup() and wanppp_close(). Kernel generic HDLC to generic PPP layer: http://marc.theaimsgroup.com/?l=3Dlinux-net&m=3D105525978800615&w=3D2 This has changed slightly. I have attached our latest drivers/net/wan/hdlc_ppp.c. --=20 Dan Eble _____ . Software Engineer | _ |/| Applied Innovation Inc. | |_| | | http://www.aiinet.com/ |__/|_|_| ------_=_NextPart_001_01C4902D.D3F1B09D Content-Type: application/octet-stream; name="hdlc_ppp.c" Content-Transfer-Encoding: base64 Content-Description: hdlc_ppp.c Content-Disposition: attachment; filename="hdlc_ppp.c" LyoKICogR2VuZXJpYyBIRExDIHN1cHBvcnQgcm91dGluZXMgZm9yIExpbnV4CiAqIFBvaW50LXRv LXBvaW50IHByb3RvY29sIHN1cHBvcnQKICoKICogQ29weXJpZ2h0IChDKSAxOTk5IC0gMjAwMyBL cnp5c3p0b2YgSGFsYXNhIDxraGNAcG0ud2F3LnBsPgogKgogKiBUaGlzIHByb2dyYW0gaXMgZnJl ZSBzb2Z0d2FyZTsgeW91IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yIG1vZGlmeSBpdAogKiB1 bmRlciB0aGUgdGVybXMgb2YgdmVyc2lvbiAyIG9mIHRoZSBHTlUgR2VuZXJhbCBQdWJsaWMgTGlj ZW5zZQogKiBhcyBwdWJsaXNoZWQgYnkgdGhlIEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbi4KICov CgojaW5jbHVkZSA8bGludXgvY29uZmlnLmg+CiNpbmNsdWRlIDxsaW51eC9tb2R1bGUuaD4KI2lu Y2x1ZGUgPGxpbnV4L2tlcm5lbC5oPgojaW5jbHVkZSA8bGludXgvc2xhYi5oPgojaW5jbHVkZSA8 bGludXgvcG9sbC5oPgojaW5jbHVkZSA8bGludXgvZXJybm8uaD4KI2luY2x1ZGUgPGxpbnV4L2lm X2FycC5oPgojaW5jbHVkZSA8bGludXgvaW5pdC5oPgojaW5jbHVkZSA8bGludXgvc2tidWZmLmg+ CiNpbmNsdWRlIDxsaW51eC9wa3Rfc2NoZWQuaD4KI2luY2x1ZGUgPGxpbnV4L2luZXRkZXZpY2Uu aD4KI2luY2x1ZGUgPGxpbnV4L2xhcGIuaD4KI2luY2x1ZGUgPGxpbnV4L3J0bmV0bGluay5oPgoj aW5jbHVkZSA8bGludXgvaGRsYy5oPgojaW5jbHVkZSA8bGludXgvcHBwX2RlZnMuaD4KI2luY2x1 ZGUgPGxpbnV4L2lmX3BwcC5oPgojaW5jbHVkZSA8bGludXgvcHBwX2NoYW5uZWwuaD4KCi8qKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKgogKiBDb25zdGFudHMgYW5kIFN0cnVjdHVyZXMKICoqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KiovCgovKiBUaGUgUFBQIGhlYWRlciBpbmNsdWRlcyB0aGUgSERMQyBhZGRyZXNzICYgY29udHJv bCBieXRlcywKICogc28gZG8gbm90IGNvdW50IHRoZW0gaW4gTVRVIGFkanVzdG1lbnRzLgogKi8K I2RlZmluZSBQUFBfT1ZFUkhFQUQJKFBQUF9IRFJMRU4gLSAyKQoKLyoqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq CiAqIFByb3RvdHlwZXMKICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgpzdGF0aWMgaW50IGhkbGNfcHBwX3Jl Z2lzdGVyKGhkbGNfZGV2aWNlICpoZGxjKTsKc3RhdGljIHZvaWQgaGRsY19wcHBfdW5yZWdpc3Rl cihoZGxjX2RldmljZSAqaGRsYyk7CnN0YXRpYyB2b2lkIGhkbGNfcHBwX25ldGlmX3J4KHN0cnVj dCBza19idWZmICpza2IpOwpzdGF0aWMgaW50IGhkbGNfZ2VucHBwX3N0YXJ0X3htaXQoc3RydWN0 IHBwcF9jaGFubmVsICosIHN0cnVjdCBza19idWZmICopOwpzdGF0aWMgaW50IGhkbGNfZ2VucHBw X2lvY3RsKHN0cnVjdCBwcHBfY2hhbm5lbCosIHVuc2lnbmVkIGludCwgdW5zaWduZWQgbG9uZyk7 CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioKICogVmFyaWFibGVzCiAqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwoKc3Rh dGljIHN0cnVjdCBwcHBfY2hhbm5lbF9vcHMgaGRsY19nZW5wcHBfb3BzID0KewoJLnN0YXJ0X3ht aXQgPQloZGxjX2dlbnBwcF9zdGFydF94bWl0LAoJLmlvY3RsID0JaGRsY19nZW5wcHBfaW9jdGwK fTsKCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKgogKiBJbmxpbmUgRnVuY3Rpb25zCiAqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqLwoKLyoqIEdldCB0aGUgUFBQIGNoYW5uZWwgb3duZWQgYnkgYW4gSERMQyBkZXZpY2UuICov CnN0YXRpYyBfX2lubGluZV9fIHN0cnVjdCBwcHBfY2hhbm5lbCogaGRsY190b19jaGFuKGhkbGNf ZGV2aWNlICpoZGxjKQp7CglyZXR1cm4gKHN0cnVjdCBwcHBfY2hhbm5lbCopJmhkbGMtPnN0YXRl LnBwcC5jaGFuOwp9CgovKiogR2V0IGFuIEhETEMgZGV2aWNlIGZyb20gaXRzIFBQUCBjaGFubmVs LiAqLwpzdGF0aWMgX19pbmxpbmVfXyBoZGxjX2RldmljZSogY2hhbl90b19oZGxjKHN0cnVjdCBw cHBfY2hhbm5lbCAqY2hhbikKewoJcmV0dXJuIChoZGxjX2RldmljZSopY2hhbi0+cHJ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cm4gLUVQRVJNOwoKCQlpZihkZXYtPmZsYWdzICYgSUZGX1VQKQoJCQlyZXR1cm4gLUVCVVNZOwoK CQkvKiBubyBzZXR0YWJsZSBwYXJhbWV0ZXJzICovCgoJCWVyciA9IGhkbGMtPmF0dGFjaChoZGxj LCBFTkNPRElOR19OUlosUEFSSVRZX0NSQzE2X1BSMV9DQ0lUVCk7CgkJaWYgKCFlcnIpIHsKCQkJ aGRsY19wcm90b19kZXRhY2goaGRsYyk7CgkJCWVyciA9IGhkbGNfcHBwX3JlZ2lzdGVyKGhkbGMp OwoJCX0KCgkJcmV0dXJuIGVycjsKCX0KCglyZXR1cm4gLUVJTlZBTDsKfQo= ------_=_NextPart_001_01C4902D.D3F1B09D-- From davem@davemloft.net Wed Sep 1 13:37:54 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 13:38:01 -0700 (PDT) Received: from smtp109.mail.sc5.yahoo.com (smtp109.mail.sc5.yahoo.com [66.163.170.7]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i81Kbs8b005999 for ; Wed, 1 Sep 2004 13:37:54 -0700 Received: from unknown (HELO cheetah.davemloft.net) (davem?330@63.197.226.105 with login) by smtp109.mail.sc5.yahoo.com with SMTP; 1 Sep 2004 20:37:46 -0000 Date: Wed, 1 Sep 2004 13:37:09 -0700 From: "David S. Miller" To: Zhikui Chen Cc: hadi@cyberus.ca, dccp@ietf.org, netdev@oss.sgi.com, acme@conectiva.com.br Subject: Re: HELP for dccp implementation. Message-Id: <20040901133709.3637d63d.davem@davemloft.net> In-Reply-To: <4135A32A.4030901@rus.uni-stuttgart.de> References: <412CC269.8080907@rus.uni-stuttgart.de> <1093454747.1034.85.camel@jzny.localdomain> <4135A32A.4030901@rus.uni-stuttgart.de> Organization: DaveM Loft Enterprises X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8304 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 594 Lines: 14 On Wed, 01 Sep 2004 12:23:38 +0200 Zhikui Chen wrote: > If I assign a value such as 0x ee9fbc00 to sk in dccp_rcv (before lookup > calling), and comment lookkup calling, I get a error report from > bh_lock_sock(sk) calling inside dccp_rcv, which error report is > spin_is_locked on uninitialized spinlock ee9fbc00, and spin_lock > (:ee9fbc00) already locked by /73. > > Do you know its reason? Thanks, Zhikui, are you working together with Arnaldo using his code base, like we suggested to you? Or are you working still on your own code? From janitor@sternwelten.at Wed Sep 1 13:49:25 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 13:49:30 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81KnOW9006538 for ; Wed, 1 Sep 2004 13:49:25 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 087725C065; Wed, 1 Sep 2004 22:49:14 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19512-07; Wed, 1 Sep 2004 22:49:13 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id A22D75C008; Wed, 1 Sep 2004 22:49:13 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2c2d-00077g-Sz; Wed, 01 Sep 2004 22:49:15 +0200 Subject: [patch 1/1] remove old ifdefs dmascc To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 22:49:15 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8305 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 832 Lines: 28 Patches to remove some old ifdefs. remove most of the #include kill compat cruft like #define ahd_pci_set_dma_mask pci_set_dma_mask Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/hamradio/dmascc.c | 1 - 1 files changed, 1 deletion(-) diff -puN drivers/net/hamradio/dmascc.c~remove-old-ifdefs-dmascc drivers/net/hamradio/dmascc.c --- linux-2.6.9-rc1-bk7/drivers/net/hamradio/dmascc.c~remove-old-ifdefs-dmascc 2004-08-31 17:42:11.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/hamradio/dmascc.c 2004-08-31 17:42:11.000000000 +0200 @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include _ From janitor@sternwelten.at Wed Sep 1 14:03:08 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:13 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L372Z007121 for ; Wed, 1 Sep 2004 14:03:08 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id D225B5C065; Wed, 1 Sep 2004 23:02:57 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19160-06; Wed, 1 Sep 2004 23:02:57 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 3B3025C008; Wed, 1 Sep 2004 23:02:57 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cFv-0007nx-Fp; Wed, 01 Sep 2004 23:02:59 +0200 Subject: [patch 05/16] net/e100: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:02:59 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8310 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 2783 Lines: 93 I would appreciate any comments from the janitor@sternweltens list. This is one (of many) cases where I made a decision about replacing set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(some_time); with msleep(jiffies_to_msecs(some_time)); msleep() is not exactly the same as the previous code, but I only did this replacement where I thought long delays were *desired*. If this is not the case here, then just disregard this patch. Thanks, Nish Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/e100.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-) diff -puN drivers/net/e100.c~msleep-drivers_net_e100 drivers/net/e100.c --- linux-2.6.9-rc1-bk7/drivers/net/e100.c~msleep-drivers_net_e100 2004-09-01 19:35:28.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/e100.c 2004-09-01 19:35:28.000000000 +0200 @@ -623,8 +623,7 @@ static int e100_self_test(struct nic *ni writel(selftest | dma_addr, &nic->csr->port); e100_write_flush(nic); /* Wait 10 msec for self-test to complete */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 100 + 1); + msleep(10); /* Interrupts are enabled after self-test */ e100_disable_irq(nic); @@ -672,8 +671,7 @@ static void e100_eeprom_write(struct nic e100_write_flush(nic); udelay(4); } /* Wait 10 msec for cmd to complete */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 100 + 1); + msleep(10); /* Chip deselect */ writeb(0, &nic->csr->eeprom_ctrl_lo); @@ -1758,8 +1756,7 @@ static int e100_loopback_test(struct nic memset(skb->data, 0xFF, ETH_DATA_LEN); e100_xmit_frame(skb, nic->netdev); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 100 + 1); + msleep(10); if(memcmp(nic->rx_to_clean->skb->data + sizeof(struct rfd), skb->data, ETH_DATA_LEN)) @@ -1845,8 +1842,7 @@ static void e100_get_regs(struct net_dev mdio_read(netdev, nic->mii.phy_id, i); memset(nic->mem->dump_buf, 0, sizeof(nic->mem->dump_buf)); e100_exec_cb(nic, NULL, e100_dump); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 100 + 1); + msleep(10); memcpy(&buff[2 + E100_PHY_REGS], nic->mem->dump_buf, sizeof(nic->mem->dump_buf)); } @@ -2020,8 +2016,7 @@ static int e100_phys_id(struct net_devic if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ); mod_timer(&nic->blink_timer, jiffies); - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(data * HZ); + msleep(data * 1000); del_timer_sync(&nic->blink_timer); mdio_write(netdev, nic->mii.phy_id, MII_LED_CONTROL, 0); _ From janitor@sternwelten.at Wed Sep 1 14:02:46 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:02:52 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L2j0l007089 for ; Wed, 1 Sep 2004 14:02:46 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id B08D95C065; Wed, 1 Sep 2004 23:02:35 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19160-04; Wed, 1 Sep 2004 23:02:35 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 3C3265C008; Wed, 1 Sep 2004 23:02:35 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cFZ-0007l7-Gh; Wed, 01 Sep 2004 23:02:37 +0200 Subject: [patch 01/16] __FUNCTION__ string concatenation To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:02:37 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8306 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1608 Lines: 43 I've replaced the __FUNCTION__ string concatenation with the %s placeholder and a printf parameter in drivers/net/wireless/prism65/islpci_mgt.h, as suggested in the TODO list. I don't have the hardware to do a run-time check. It should not pose any problems though. # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/07/04 22:08:37+02:00 drizzd@aon.at # __FUNCTION__ string concatenation is deprecated # # drivers/net/wireless/prism54/islpci_mgt.h # 2004/07/03 17:18:20+02:00 drizzd@aon.at +1 -1 # __FUNCTION__ string concatenation is deprecated # Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/wireless/prism54/islpci_mgt.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) diff -puN drivers/net/wireless/prism54/islpci_mgt.h~printk-net_wireless_prism54_islpci_mgt.h drivers/net/wireless/prism54/islpci_mgt.h --- linux-2.6.9-rc1-bk7/drivers/net/wireless/prism54/islpci_mgt.h~printk-net_wireless_prism54_islpci_mgt.h 2004-09-01 19:34:23.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/wireless/prism54/islpci_mgt.h 2004-09-01 19:34:23.000000000 +0200 @@ -31,7 +31,7 @@ #define K_DEBUG(f, m, args...) do { if(f & m) printk(KERN_DEBUG args); } while(0) #define DEBUG(f, args...) K_DEBUG(f, pc_debug, args) -#define TRACE(devname) K_DEBUG(SHOW_TRACING, VERBOSE, "%s: -> " __FUNCTION__ "()\n", devname) +#define TRACE(devname) K_DEBUG(SHOW_TRACING, VERBOSE, "%s: -> %s()\n", devname, __FUNCTION__) extern int pc_debug; #define init_wds 0 /* help compiler optimize away dead code */ _ From janitor@sternwelten.at Wed Sep 1 14:02:51 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:02:57 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L2pwo007095 for ; Wed, 1 Sep 2004 14:02:51 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 2E21D5C066; Wed, 1 Sep 2004 23:02:41 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26133-04; Wed, 1 Sep 2004 23:02:40 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id AEE925C008; Wed, 1 Sep 2004 23:02:40 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cFf-0007lp-03; Wed, 01 Sep 2004 23:02:43 +0200 Subject: [patch 02/16] net/3c505: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:02:42 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8307 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1440 Lines: 51 I would appreciate any comments from the janitor@sternweltens list. Thanks, Nish Description: Uses msleep() instead of schedule_timeout() so the task is guaranteed to delay the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/3c505.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff -puN drivers/net/3c505.c~msleep-drivers_net_3c505 drivers/net/3c505.c --- linux-2.6.9-rc1-bk7/drivers/net/3c505.c~msleep-drivers_net_3c505 2004-09-01 19:35:25.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/3c505.c 2004-09-01 19:35:25.000000000 +0200 @@ -1327,8 +1327,7 @@ static int __init elp_sense(struct net_d if (orig_HSR & DIR) { /* If HCR.DIR is up, we pull it down. HSR.DIR should follow. */ outb(0, dev->base_addr + PORT_CONTROL); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(30*HZ/100); + msleep(300); if (inb_status(addr) & DIR) { if (elp_debug > 0) printk(notfound_msg, 2); @@ -1337,8 +1336,7 @@ static int __init elp_sense(struct net_d } else { /* If HCR.DIR is down, we pull it up. HSR.DIR should follow. */ outb(DIR, dev->base_addr + PORT_CONTROL); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(30*HZ/100); + msleep(300); if (!(inb_status(addr) & DIR)) { if (elp_debug > 0) printk(notfound_msg, 3); _ From janitor@sternwelten.at Wed Sep 1 14:02:57 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:01 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L2ukq007103 for ; Wed, 1 Sep 2004 14:02:57 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id ABB7B5C066; Wed, 1 Sep 2004 23:02:46 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19160-05; Wed, 1 Sep 2004 23:02:46 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 3FC3C5C008; Wed, 1 Sep 2004 23:02:46 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cFk-0007mX-Fq; Wed, 01 Sep 2004 23:02:48 +0200 Subject: [patch 03/16] net/appletalk: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:02:48 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8308 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1299 Lines: 51 I would appreciate any comments from the janitor@sternweltens list. Thanks, Nish Description: Uses msleep() instead of schedule_timeout() so the task is guaranteed to delay the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/appletalk/ltpc.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff -puN drivers/net/appletalk/ltpc.c~msleep-drivers_net_appletalk_ltpc drivers/net/appletalk/ltpc.c --- linux-2.6.9-rc1-bk7/drivers/net/appletalk/ltpc.c~msleep-drivers_net_appletalk_ltpc 2004-09-01 19:35:26.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/appletalk/ltpc.c 2004-09-01 19:35:26.000000000 +0200 @@ -1109,8 +1109,7 @@ struct net_device * __init ltpc_probe(vo inb_p(io+1); inb_p(io+3); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(2*HZ/100); + msleep(20); inb_p(io+0); inb_p(io+2); @@ -1120,8 +1119,7 @@ struct net_device * __init ltpc_probe(vo inb_p(io+5); /* enable dma */ inb_p(io+6); /* tri-state interrupt line */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ); + msleep(1000); /* now, figure out which dma channel we're using, unless it's already been specified */ _ From janitor@sternwelten.at Wed Sep 1 14:03:02 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:07 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L32RC007113 for ; Wed, 1 Sep 2004 14:03:02 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 376FC5C066; Wed, 1 Sep 2004 23:02:52 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26133-05; Wed, 1 Sep 2004 23:02:51 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id BDA2B5C008; Wed, 1 Sep 2004 23:02:51 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cFp-0007nF-Vx; Wed, 01 Sep 2004 23:02:54 +0200 Subject: [patch 04/16] net/cs89x0: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:02:53 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8309 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1375 Lines: 52 I would appreciate any comments from the janitor@sternweltens list. This is one (of many) cases where I made a decision about replacing set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(some_time); with msleep(jiffies_to_msecs(some_time)); msleep() is not exactly the same as the previous code, but I only did this replacement where I thought long delays were *desired*. If this is not the case here, then just disregard this patch. Thanks, Nish Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/cs89x0.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/cs89x0.c~msleep-drivers_net_cs89x0 drivers/net/cs89x0.c --- linux-2.6.9-rc1-bk7/drivers/net/cs89x0.c~msleep-drivers_net_cs89x0 2004-09-01 19:35:27.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/cs89x0.c 2004-09-01 19:35:27.000000000 +0200 @@ -891,8 +891,7 @@ void __init reset_chip(struct net_devic writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET); /* wait 30 ms */ - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(30*HZ/1000); + msleep(30); if (lp->chip_type != CS8900) { /* Hardware problem requires PNP registers to be reconfigured after a reset */ _ From janitor@sternwelten.at Wed Sep 1 14:03:14 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:18 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3DOU007127 for ; Wed, 1 Sep 2004 14:03:13 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 2D9985C067; Wed, 1 Sep 2004 23:03:03 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26133-06; Wed, 1 Sep 2004 23:03:02 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id AA7EE5C008; Wed, 1 Sep 2004 23:03:02 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cG0-0007of-Vj; Wed, 01 Sep 2004 23:03:05 +0200 Subject: [patch 06/16] net/e1000_osdep: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:04 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8311 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1764 Lines: 59 On Tue, Jul 27, 2004 at 04:00:52AM +0100, Matthew Wilcox wrote: > On Mon, Jul 26, 2004 at 05:00:01PM -0700, Nishanth Aravamudan wrote: > > I would appreciate any comments from the janitor@sternweltens list. > > > > > > > > Description: Replace schedule_timeout() with msleep() to guarantee the > > task delays for the desired time. > > } else { \ > > - set_current_state(TASK_UNINTERRUPTIBLE); \ > > - schedule_timeout((x * HZ)/1000 + 2); \ > > + msleep(x); \ > > } } while(0) > > Looks much better than the previous code. It's actually possible to do > better, though. Simply change to: > > #define msec_delay(x) msleep(x) > > If msleep() ends up scheduling, the bad attempt to sleep will be caught > by schedule(). There's no need to do the check in the driver. Thanks for the tip and here is this change: Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/e1000/e1000_osdep.h | 8 +------- 1 files changed, 1 insertion(+), 7 deletions(-) diff -puN drivers/net/e1000/e1000_osdep.h~msleep-drivers_net_e1000_osdep drivers/net/e1000/e1000_osdep.h --- linux-2.6.9-rc1-bk7/drivers/net/e1000/e1000_osdep.h~msleep-drivers_net_e1000_osdep 2004-09-01 19:35:28.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/e1000/e1000_osdep.h 2004-09-01 19:35:28.000000000 +0200 @@ -42,13 +42,7 @@ #include #ifndef msec_delay -#define msec_delay(x) do { if(in_interrupt()) { \ - /* Don't mdelay in interrupt context! */ \ - BUG(); \ - } else { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - schedule_timeout((x * HZ)/1000 + 2); \ - } } while(0) +#define msec_delay(x) msleep(x) #endif #define PCI_COMMAND_REGISTER PCI_COMMAND _ From janitor@sternwelten.at Wed Sep 1 14:03:19 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:23 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3Ivw007137 for ; Wed, 1 Sep 2004 14:03:19 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 9FFA55C068; Wed, 1 Sep 2004 23:03:08 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19160-07; Wed, 1 Sep 2004 23:03:08 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 3C4ED5C008; Wed, 1 Sep 2004 23:03:08 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cG6-0007pN-FM; Wed, 01 Sep 2004 23:03:10 +0200 Subject: [patch 07/16] net/ewrk3: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:10 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8312 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 938 Lines: 37 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/ewrk3.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/ewrk3.c~msleep-drivers_net_ewrk3 drivers/net/ewrk3.c --- linux-2.6.9-rc1-bk7/drivers/net/ewrk3.c~msleep-drivers_net_ewrk3 2004-09-01 19:35:29.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/ewrk3.c 2004-09-01 19:35:29.000000000 +0200 @@ -1681,8 +1681,7 @@ static int ewrk3_ethtool_ioctl(struct ne /* Wait a little while */ spin_unlock_irqrestore(&lp->hw_lock, flags); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ>>2); + msleep(250); spin_lock_irqsave(&lp->hw_lock, flags); /* Exit if we got a signal */ _ From janitor@sternwelten.at Wed Sep 1 14:03:25 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:29 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3ObA007145 for ; Wed, 1 Sep 2004 14:03:24 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 67CE25C066; Wed, 1 Sep 2004 23:03:14 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26133-07; Wed, 1 Sep 2004 23:03:14 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id B790E5C008; Wed, 1 Sep 2004 23:03:13 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGB-0007q6-VQ; Wed, 01 Sep 2004 23:03:16 +0200 Subject: [patch 08/16] net/gt96100eth: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:15 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8313 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 3299 Lines: 109 I would appreciate any comments from the janitor@sternweltens list. This is one (of many) cases where I made a decision about replacing set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(some_time); with msleep(jiffies_to_msecs(some_time)); msleep() is not exactly the same as the previous code, but I only did this replacement where I thought long delays were *desired*. If this is not the case here, then just disregard this patch. Thanks, Nish PS. In this patch, the last delay is a bit confusing. It, in code, delayed for 1 msec, but the comment said 20 msecs, does anyone know which it should be? Description: Replace gt96100_delay() with msleep() to guarantee the task delays for the desired time. Remove the definition of gt96100_delay(). Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/gt96100eth.c | 19 ++++--------------- 1 files changed, 4 insertions(+), 15 deletions(-) diff -puN drivers/net/gt96100eth.c~msleep-drivers_net_gt96100eth drivers/net/gt96100eth.c --- linux-2.6.9-rc1-bk7/drivers/net/gt96100eth.c~msleep-drivers_net_gt96100eth 2004-09-01 19:35:29.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/gt96100eth.c 2004-09-01 19:35:29.000000000 +0200 @@ -59,7 +59,6 @@ // prototypes static void* dmaalloc(size_t size, dma_addr_t *dma_handle); static void dmafree(size_t size, void *vaddr); -static void gt96100_delay(int msec); static int gt96100_add_hash_entry(struct net_device *dev, unsigned char* addr); static void read_mib_counters(struct gt96100_private *gp); @@ -183,16 +182,6 @@ static void dmafree(size_t size, void *v free_pages((unsigned long)vaddr, get_order(size)); } -static void gt96100_delay(int ms) -{ - if (in_interrupt()) - return; - else { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(ms*HZ/1000); - } -} - static int parse_mac_addr(struct net_device *dev, char* macstr) { @@ -238,7 +227,7 @@ read_MII(int phy_addr, u32 reg) // wait for last operation to complete while (GT96100_READ(GT96100_ETH_SMI_REG) & smirBusy) { // snooze for 1 msec and check again - gt96100_delay(1); + msleep(1); if (--timedout == 0) { printk(KERN_ERR "%s: busy timeout!!\n", __FUNCTION__); @@ -252,7 +241,7 @@ read_MII(int phy_addr, u32 reg) // wait for read to complete while (!((smir = GT96100_READ(GT96100_ETH_SMI_REG)) & smirReadValid)) { // snooze for 1 msec and check again - gt96100_delay(1); + msleep(1); if (--timedout == 0) { printk(KERN_ERR "%s: timeout!!\n", __FUNCTION__); @@ -304,7 +293,7 @@ write_MII(int phy_addr, u32 reg, u16 dat // wait for last operation to complete while (GT96100_READ(GT96100_ETH_SMI_REG) & smirBusy) { // snooze for 1 msec and check again - gt96100_delay(1); + msleep(1); if (--timedout == 0) { printk(KERN_ERR "%s: busy timeout!!\n", __FUNCTION__); @@ -528,7 +517,7 @@ abort(struct net_device *dev, u32 abort_ // wait for abort to complete while (GT96100ETH_READ(gp, GT96100_ETH_SDMA_COMM) & abort_bits) { // snooze for 20 msec and check again - gt96100_delay(1); + msleep(20); // was gt96100_delay(1) -> should it be 20 or 1? if (--timedout == 0) { err("%s: timeout!!\n", __FUNCTION__); _ From janitor@sternwelten.at Wed Sep 1 14:03:30 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:35 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3UFA007155 for ; Wed, 1 Sep 2004 14:03:30 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 16B385C065; Wed, 1 Sep 2004 23:03:20 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19160-08; Wed, 1 Sep 2004 23:03:19 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 407E75C008; Wed, 1 Sep 2004 23:03:19 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGH-0007qo-Fw; Wed, 01 Sep 2004 23:03:21 +0200 Subject: [patch 09/16] ixgb/ixgb_osdep: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:21 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8314 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1197 Lines: 44 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Redefine msec_delay(x) to directly call msleep(x). Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/ixgb/ixgb_osdep.h | 8 +------- 1 files changed, 1 insertion(+), 7 deletions(-) diff -puN drivers/net/ixgb/ixgb_osdep.h~msleep-drivers_net_ixgb_osdep drivers/net/ixgb/ixgb_osdep.h --- linux-2.6.9-rc1-bk7/drivers/net/ixgb/ixgb_osdep.h~msleep-drivers_net_ixgb_osdep 2004-09-01 19:35:34.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/ixgb/ixgb_osdep.h 2004-09-01 19:35:34.000000000 +0200 @@ -41,13 +41,7 @@ #include #ifndef msec_delay -#define msec_delay(x) do { if(in_interrupt()) { \ - /* Don't mdelay in interrupt context! */ \ - BUG(); \ - } else { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - schedule_timeout((x * HZ)/1000 + 2); \ - } } while(0) +#define msec_delay(x) msleep(x) #endif #define PCI_COMMAND_REGISTER PCI_COMMAND _ From janitor@sternwelten.at Wed Sep 1 14:03:35 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:39 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3Z0C007170 for ; Wed, 1 Sep 2004 14:03:35 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 209A35C065; Wed, 1 Sep 2004 23:03:25 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26133-08; Wed, 1 Sep 2004 23:03:24 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id A468B5C008; Wed, 1 Sep 2004 23:03:24 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGN-0007rW-0B; Wed, 01 Sep 2004 23:03:27 +0200 Subject: [patch 10/16] net/mac89x0: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:26 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8315 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1387 Lines: 53 I would appreciate any comments from the janitor@sternweltens list. This is one (of many) cases where I made a decision about replacing set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(some_time); with msleep(jiffies_to_msecs(some_time)); msleep() is not exactly the same as the previous code, but I only did this replacement where I thought long delays were *desired*. If this is not the case here, then just disregard this patch. Thanks, Nish Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/mac89x0.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/mac89x0.c~msleep-drivers_net_max89x0 drivers/net/mac89x0.c --- linux-2.6.9-rc1-bk7/drivers/net/mac89x0.c~msleep-drivers_net_max89x0 2004-09-01 19:35:34.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/mac89x0.c 2004-09-01 19:35:34.000000000 +0200 @@ -308,8 +308,7 @@ void __init reset_chip(struct net_device writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET); /* wait 30 ms */ - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(30*HZ/1000); + msleep(30); /* Wait until the chip is reset */ reset_start_time = jiffies; _ From janitor@sternwelten.at Wed Sep 1 14:03:41 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:46 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3ej7007189 for ; Wed, 1 Sep 2004 14:03:41 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 8A3A25C065; Wed, 1 Sep 2004 23:03:30 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19160-09; Wed, 1 Sep 2004 23:03:30 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 2119F5C008; Wed, 1 Sep 2004 23:03:30 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGS-0007sE-Ej; Wed, 01 Sep 2004 23:03:32 +0200 Subject: [patch 11/16] net/ni65: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:32 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8316 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1021 Lines: 38 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/ni65.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/ni65.c~msleep-drivers_net_ni65 drivers/net/ni65.c --- linux-2.6.9-rc1-bk7/drivers/net/ni65.c~msleep-drivers_net_ni65 2004-09-01 19:35:35.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/ni65.c 2004-09-01 19:35:35.000000000 +0200 @@ -526,8 +526,7 @@ static int __init ni65_probe1(struct net ni65_init_lance(p,dev->dev_addr,0,0); irq_mask = probe_irq_on(); writereg(CSR0_INIT|CSR0_INEA,CSR0); /* trigger interrupt */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/50); + msleep(20); dev->irq = probe_irq_off(irq_mask); if(!dev->irq) { _ From janitor@sternwelten.at Wed Sep 1 14:03:46 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:03:52 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3kMm007301 for ; Wed, 1 Sep 2004 14:03:46 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 0C0875C065; Wed, 1 Sep 2004 23:03:36 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26133-09; Wed, 1 Sep 2004 23:03:35 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 96E9C5C008; Wed, 1 Sep 2004 23:03:35 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGX-0007sw-WC; Wed, 01 Sep 2004 23:03:38 +0200 Subject: [patch 12/16] net/ns83820: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:37 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8317 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1220 Lines: 45 On Tue, Jul 27, 2004 at 02:34:08PM -0400, Benjamin LaHaise wrote: > The commit message doesn't seem correspond to the actual patch. What > are you trying to "fix"? Thanks for catching this - it was another typo. Please find the corrected patch below. -Nish Description: Uses msleep() instead of schedule_timeout() to guarantee the task delays the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/ns83820.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/ns83820.c~msleep-drivers_net_ns83820 drivers/net/ns83820.c --- linux-2.6.9-rc1-bk7/drivers/net/ns83820.c~msleep-drivers_net_ns83820 2004-09-01 19:35:35.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/ns83820.c 2004-09-01 19:35:35.000000000 +0200 @@ -1960,8 +1960,7 @@ static int __devinit ns83820_init_one(st if (reset_phy) { printk(KERN_INFO "%s: resetting phy\n", ndev->name); writel(dev->CFG_cache | CFG_PHY_RST, dev->base + CFG); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout((HZ+99)/100); + msleep(10); writel(dev->CFG_cache, dev->base + CFG); } _ From janitor@sternwelten.at Wed Sep 1 14:03:52 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:04:00 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3qlf007420 for ; Wed, 1 Sep 2004 14:03:52 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id ED3A75C065; Wed, 1 Sep 2004 23:03:41 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19160-10; Wed, 1 Sep 2004 23:03:41 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 1A0BB5C008; Wed, 1 Sep 2004 23:03:41 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGd-0007te-EC; Wed, 01 Sep 2004 23:03:43 +0200 Subject: [patch 13/16] net/s2io.c: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:43 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8318 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 4651 Lines: 176 I would appreciate any comments from the janitor@sternweltens list. Description: Use msleep() instead of schedule_timeout() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/s2io.c | 45 +++++++++-------------------- 1 files changed, 15 insertions(+), 30 deletions(-) diff -puN drivers/net/s2io.c~msleep-drivers_net_s2io drivers/net/s2io.c --- linux-2.6.9-rc1-bk7/drivers/net/s2io.c~msleep-drivers_net_s2io 2004-09-01 19:35:36.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/s2io.c 2004-09-01 19:35:36.000000000 +0200 @@ -555,8 +555,7 @@ static int initNic(struct s2io_nic *nic) val64 = 0; writeq(val64, &bar0->sw_reset); val64 = readq(&bar0->sw_reset); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 2); + msleep(500); /* Enable Receiving broadcasts */ val64 = readq(&bar0->mac_cfg); @@ -803,8 +802,7 @@ static int initNic(struct s2io_nic *nic) dev->name); return -1; } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 20); + msleep(50); time++; } @@ -838,8 +836,7 @@ static int initNic(struct s2io_nic *nic) return -1; } time++; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 20); + msleep(50); } /* Initializing proper values as Pause threshold into all @@ -1182,8 +1179,7 @@ static int startNic(struct s2io_nic *nic writeq(val64, &bar0->mc_rldram_mrs); val64 = readq(&bar0->mc_rldram_mrs); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 10); /* Delay by around 100 ms. */ + msleep(100); /* Enabling ECC Protection. */ val64 = readq(&bar0->adapter_control); @@ -1891,8 +1887,7 @@ int waitForCmdComplete(nic_t * sp) ret = SUCCESS; break; } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 20); + msleep(50); if (cnt++ > 10) break; } @@ -1931,15 +1926,13 @@ void s2io_reset(nic_t * sp) * As of now I'am just giving a 250ms delay and hoping that the * PCI write to sw_reset register is done by this time. */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 4); + msleep(250); /* Restore the PCI state saved during initializarion. */ pci_restore_state(sp->pdev, sp->config_space); s2io_init_pci(sp); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 4); + msleep(250); /* SXE-002: Configure link and activity LED to turn it off */ subid = sp->pdev->subsystem_device; @@ -2157,8 +2150,7 @@ int s2io_close(struct net_device *dev) /* If the device tasklet is running, wait till its done before killing it */ while (atomic_read(&(sp->tasklet_status))) { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 10); + msleep(100); } tasklet_kill(&sp->task); @@ -2169,8 +2161,7 @@ int s2io_close(struct net_device *dev) break; } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 20); + msleep(50); cnt++; if (cnt == 10) { DBG_PRINT(ERR_DBG, @@ -2943,8 +2934,7 @@ static u32 readEeprom(nic_t * sp, int of data = I2C_CONTROL_GET_DATA(val64); break; } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 20); + msleep(50); exit_cnt++; } @@ -2983,8 +2973,7 @@ static int writeEeprom(nic_t * sp, int o ret = 0; break; } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 20); + msleep(50); exit_cnt++; } @@ -3256,8 +3245,7 @@ static int s2io_bistTest(nic_t * sp, uin ret = 0; break; } - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 10); + msleep(100); cnt++; } @@ -3356,8 +3344,7 @@ static int s2io_rldramTest(nic_t * sp, u val64 = readq(&bar0->mc_rldram_test_ctrl); if (val64 & MC_RLDRAM_TEST_DONE) break; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 5); + msleep(200); } if (cnt == 5) @@ -3373,8 +3360,7 @@ static int s2io_rldramTest(nic_t * sp, u val64 = readq(&bar0->mc_rldram_test_ctrl); if (val64 & MC_RLDRAM_TEST_DONE) break; - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 2); + msleep(500); } if (cnt == 5) @@ -3711,8 +3697,7 @@ static void s2io_set_link(unsigned long /* Allow a small delay for the NICs self initiated * cleanup to complete. */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ / 10); + msleep(100); val64 = readq(&bar0->adapter_status); if (verify_xena_quiescence(val64, nic->device_enabled_once)) { _ From janitor@sternwelten.at Wed Sep 1 14:03:58 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:04:06 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L3vCR007517 for ; Wed, 1 Sep 2004 14:03:58 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 122495C066; Wed, 1 Sep 2004 23:03:47 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26133-10; Wed, 1 Sep 2004 23:03:46 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 930D85C008; Wed, 1 Sep 2004 23:03:46 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGi-0007uM-UH; Wed, 01 Sep 2004 23:03:49 +0200 Subject: [patch 14/16] net/ibmtr: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:48 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8319 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1505 Lines: 50 On Tue, Jul 27, 2004 at 01:43:32PM -0700, Nishanth Aravamudan wrote: > I would appreciate any comments from the janitor@sternweltens list. > > > > Description: Use msleep() instead of schedule_timeout() to guarantee > the task delays for the desired time. > > Signed-off-by: Nishanth Aravamudan The previous patch introduced extraneous whitespace, sorry. Thanks, Domen. Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/tokenring/ibmtr.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff -puN drivers/net/tokenring/ibmtr.c~msleep-drivers_net_tokenring_ibmtr drivers/net/tokenring/ibmtr.c --- linux-2.6.9-rc1-bk7/drivers/net/tokenring/ibmtr.c~msleep-drivers_net_tokenring_ibmtr 2004-09-01 19:35:37.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/tokenring/ibmtr.c 2004-09-01 19:35:37.000000000 +0200 @@ -108,6 +108,7 @@ in the event that chatty debug messages #define IBMTR_DEBUG_MESSAGES 0 #include +#include #ifdef PCMCIA /* required for ibmtr_cs.c to build */ #undef MODULE /* yes, really */ @@ -858,8 +859,7 @@ static int tok_init_card(struct net_devi writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN); outb(0, PIOaddr + ADAPTRESET); - current->state=TASK_UNINTERRUPTIBLE; - schedule_timeout(TR_RST_TIME); /* wait 50ms */ + msleep(jiffies_to_msecs(TR_RST_TIME)); outb(0, PIOaddr + ADAPTRESETREL); #ifdef ENABLE_PAGING _ From janitor@sternwelten.at Wed Sep 1 14:04:04 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:04:12 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L42Bn007682 for ; Wed, 1 Sep 2004 14:04:03 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id A9D0C5C067; Wed, 1 Sep 2004 23:03:52 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01102-01; Wed, 1 Sep 2004 23:03:52 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 262A35C008; Wed, 1 Sep 2004 23:03:52 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGo-0007v4-E1; Wed, 01 Sep 2004 23:03:54 +0200 Subject: [patch 15/16] tulip/de2104x: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:54 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8320 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 997 Lines: 38 I would appreciate any comments from the janitor@sternweltens list. Description: Use msleep() instead of schedule_timeout() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/tulip/de2104x.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/tulip/de2104x.c~msleep-drivers_net_tulip_de2104x drivers/net/tulip/de2104x.c --- linux-2.6.9-rc1-bk7/drivers/net/tulip/de2104x.c~msleep-drivers_net_tulip_de2104x 2004-09-01 19:35:38.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/tulip/de2104x.c 2004-09-01 19:35:38.000000000 +0200 @@ -1208,8 +1208,7 @@ static void de_adapter_wake (struct de_p pci_write_config_dword(de->pdev, PCIPM, pmctl); /* de4x5.c delays, so we do too */ - current->state = TASK_UNINTERRUPTIBLE; - schedule_timeout(msecs_to_jiffies(10)); + msleep(10); } } _ From janitor@sternwelten.at Wed Sep 1 14:04:10 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:04:17 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L48SU007823 for ; Wed, 1 Sep 2004 14:04:09 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 85B5F5C008; Wed, 1 Sep 2004 23:03:58 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01102-02; Wed, 1 Sep 2004 23:03:58 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id A00B65C068; Wed, 1 Sep 2004 23:03:57 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cGt-0007vm-Tz; Wed, 01 Sep 2004 23:04:00 +0200 Subject: [patch 16/16] parport/ieee1284_ops: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:03:59 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8321 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1477 Lines: 53 I would appreciate any comments from the janitor@sternweltens list. This is one (of many) cases where I made a decision about replacing set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(some_time); with msleep(jiffies_to_msecs(some_time)); msleep() is not exactly the same as the previous code, but I only did this replacement where I thought long delays were *desired*. If this is not the case here, then just disregard this patch. Thanks, Nish Description: Uses msleep() instead of schedule_timeout() to guarantee the task delays the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/parport/ieee1284_ops.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/parport/ieee1284_ops.c~msleep-drivers_parport_ieee1284_ops drivers/parport/ieee1284_ops.c --- linux-2.6.9-rc1-bk7/drivers/parport/ieee1284_ops.c~msleep-drivers_parport_ieee1284_ops 2004-09-01 19:35:41.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/parport/ieee1284_ops.c 2004-09-01 19:35:41.000000000 +0200 @@ -542,8 +542,7 @@ size_t parport_ieee1284_ecp_read_data (s /* Yield the port for a while. */ if (count && dev->port->irq != PARPORT_IRQ_NONE) { parport_release (dev); - __set_current_state (TASK_INTERRUPTIBLE); - schedule_timeout ((HZ + 24) / 25); + msleep(40); parport_claim_or_block (dev); } else _ From janitor@sternwelten.at Wed Sep 1 14:05:34 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:05:42 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L5Vfm009733 for ; Wed, 1 Sep 2004 14:05:32 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id D4AB75C065; Wed, 1 Sep 2004 23:05:21 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01102-06; Wed, 1 Sep 2004 23:05:21 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 6BB3A5C008; Wed, 1 Sep 2004 23:05:21 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIF-0007yy-Lb; Wed, 01 Sep 2004 23:05:23 +0200 Subject: [patch 1/8] irda/act200l-sir: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:05:23 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8322 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1050 Lines: 38 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/irda/act200l-sir.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/irda/act200l-sir.c~msleep-drivers_net_irda_act200l-sir drivers/net/irda/act200l-sir.c --- linux-2.6.9-rc1-bk7/drivers/net/irda/act200l-sir.c~msleep-drivers_net_irda_act200l-sir 2004-09-01 19:35:31.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/irda/act200l-sir.c 2004-09-01 19:35:31.000000000 +0200 @@ -177,8 +177,7 @@ static int act200l_change_speed(struct s /* Write control bytes */ sirdev_raw_write(dev, control, 3); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(5)); + msleep(5); /* Go back to normal mode */ sirdev_set_dtr_rts(dev, TRUE, TRUE); _ From janitor@sternwelten.at Wed Sep 1 14:05:38 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:05:44 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L5cWq009866 for ; Wed, 1 Sep 2004 14:05:38 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id AA92C5C066; Wed, 1 Sep 2004 23:05:27 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04663-06; Wed, 1 Sep 2004 23:05:27 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id E40355C008; Wed, 1 Sep 2004 23:05:26 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIL-0007zg-5D; Wed, 01 Sep 2004 23:05:29 +0200 Subject: [patch 2/8] irda/irtty-sir: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:05:28 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8323 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1258 Lines: 49 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/irda/irtty-sir.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff -puN drivers/net/irda/irtty-sir.c~msleep-drivers_net_irda_irtty-sir drivers/net/irda/irtty-sir.c --- linux-2.6.9-rc1-bk7/drivers/net/irda/irtty-sir.c~msleep-drivers_net_irda_irtty-sir 2004-09-01 19:35:31.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/irda/irtty-sir.c 2004-09-01 19:35:31.000000000 +0200 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -96,10 +97,8 @@ static void irtty_wait_until_sent(struct tty->driver->wait_until_sent(tty, msecs_to_jiffies(100)); unlock_kernel(); } - else { - set_task_state(current, TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(USBSERIAL_TX_DONE_DELAY)); - } + else + msleep(USBSERIAL_TX_DONE_DELAY); } /* _ From janitor@sternwelten.at Wed Sep 1 14:05:51 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:05:56 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L5mv8010060 for ; Wed, 1 Sep 2004 14:05:48 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 5E4395C068; Wed, 1 Sep 2004 23:05:38 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04663-07; Wed, 1 Sep 2004 23:05:38 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id E49035C008; Wed, 1 Sep 2004 23:05:37 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIW-000816-6g; Wed, 01 Sep 2004 23:05:40 +0200 Subject: [patch 4/8] irda/sir_dev: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:05:39 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8325 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1317 Lines: 46 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/irda/sir_dev.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff -puN drivers/net/irda/sir_dev.c~msleep-drivers_net_irda_sir_dev drivers/net/irda/sir_dev.c --- linux-2.6.9-rc1-bk7/drivers/net/irda/sir_dev.c~msleep-drivers_net_irda_sir_dev 2004-09-01 19:35:32.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/irda/sir_dev.c 2004-09-01 19:35:32.000000000 +0200 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -73,8 +74,7 @@ int sirdev_raw_write(struct sir_dev *dev spin_lock_irqsave(&dev->tx_lock, flags); /* serialize with other tx operations */ while (dev->tx_buff.len > 0) { /* wait until tx idle */ spin_unlock_irqrestore(&dev->tx_lock, flags); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(10)); + msleep(10); spin_lock_irqsave(&dev->tx_lock, flags); } _ From janitor@sternwelten.at Wed Sep 1 14:05:46 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:05:53 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L5gFg009961 for ; Wed, 1 Sep 2004 14:05:43 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id DE3005C067; Wed, 1 Sep 2004 23:05:32 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01102-07; Wed, 1 Sep 2004 23:05:32 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 5E9A05C008; Wed, 1 Sep 2004 23:05:32 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIQ-00080O-LF; Wed, 01 Sep 2004 23:05:34 +0200 Subject: [patch 3/8] irda/ma600-sir: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:05:34 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8324 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1945 Lines: 64 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/irda/ma600-sir.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff -puN drivers/net/irda/ma600-sir.c~msleep-drivers_net_irda_ma600-sir drivers/net/irda/ma600-sir.c --- linux-2.6.9-rc1-bk7/drivers/net/irda/ma600-sir.c~msleep-drivers_net_irda_ma600-sir 2004-09-01 19:35:32.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/irda/ma600-sir.c 2004-09-01 19:35:32.000000000 +0200 @@ -191,8 +191,7 @@ static int ma600_change_speed(struct sir sirdev_raw_write(dev, &byte, sizeof(byte)); /* Wait at least 10ms: fake wait_until_sent - 10 bits at 9600 baud*/ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(15)); /* old ma600 uses 15ms */ + msleep(15); /* old ma600 uses 15ms */ #if 1 /* read-back of the control byte. ma600 is the first dongle driver @@ -215,8 +214,7 @@ static int ma600_change_speed(struct sir sirdev_set_dtr_rts(dev, TRUE, TRUE); /* Wait at least 10ms */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(10)); + msleep(10); /* dongle is now switched to the new speed */ dev->speed = speed; @@ -245,13 +243,11 @@ int ma600_reset(struct sir_dev *dev) /* Reset the dongle : set DTR low for 10 ms */ sirdev_set_dtr_rts(dev, FALSE, TRUE); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(10)); + msleep(10); /* Go back to normal mode */ sirdev_set_dtr_rts(dev, TRUE, TRUE); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(10)); + msleep(10); dev->speed = 9600; /* That's the dongle-default */ _ From janitor@sternwelten.at Wed Sep 1 14:05:56 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:06:03 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L5spH010172 for ; Wed, 1 Sep 2004 14:05:54 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id CC3AB5C06A; Wed, 1 Sep 2004 23:05:43 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01102-08; Wed, 1 Sep 2004 23:05:43 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 63B025C069; Wed, 1 Sep 2004 23:05:43 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIb-00081o-MO; Wed, 01 Sep 2004 23:05:45 +0200 Subject: [patch 5/8] irda/tekram-sir: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:05:45 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8326 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1039 Lines: 38 I would appreciate any comments from the janitor@sternweltens list. Description: Replace schedule_timeout() with msleep() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/irda/tekram-sir.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/irda/tekram-sir.c~msleep-drivers_net_irda_tekram-sir drivers/net/irda/tekram-sir.c --- linux-2.6.9-rc1-bk7/drivers/net/irda/tekram-sir.c~msleep-drivers_net_irda_tekram-sir 2004-09-01 19:35:32.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/irda/tekram-sir.c 2004-09-01 19:35:32.000000000 +0200 @@ -210,8 +210,7 @@ static int tekram_reset(struct sir_dev * sirdev_set_dtr_rts(dev, FALSE, TRUE); /* Should sleep 1 ms */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(msecs_to_jiffies(1)); + msleep(1); /* Set DTR, Set RTS */ sirdev_set_dtr_rts(dev, TRUE, TRUE); _ From janitor@sternwelten.at Wed Sep 1 14:06:02 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:06:08 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L5xwp010292 for ; Wed, 1 Sep 2004 14:06:00 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 7876A5C06B; Wed, 1 Sep 2004 23:05:49 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04663-09; Wed, 1 Sep 2004 23:05:49 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id DF0FE5C008; Wed, 1 Sep 2004 23:05:48 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIh-00082W-6F; Wed, 01 Sep 2004 23:05:51 +0200 Subject: [patch 6/8] wireless/airo: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:05:50 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8327 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 2419 Lines: 82 I would appreciate any comments from the janitor@sternweltens list. Description: Use msleep() instead of schedule_timeout() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/wireless/airo.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-) diff -puN drivers/net/wireless/airo.c~msleep-drivers_net_wireless_airo drivers/net/wireless/airo.c --- linux-2.6.9-rc1-bk7/drivers/net/wireless/airo.c~msleep-drivers_net_wireless_airo 2004-09-01 19:35:39.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/wireless/airo.c 2004-09-01 19:35:39.000000000 +0200 @@ -2670,11 +2670,9 @@ int reset_card( struct net_device *dev , return -1; waitbusy (ai); OUT4500(ai,COMMAND,CMD_SOFTRESET); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ/5); + msleep(200); waitbusy (ai); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ/5); + msleep(200); if (lock) up(&ai->sem); return 0; @@ -7436,8 +7434,7 @@ int cmdreset(struct airo_info *ai) { OUT4500(ai,COMMAND,CMD_SOFTRESET); - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); /* WAS 600 12/7/00 */ + msleep(1000); /* WAS 600 12/7/00 */ if(!waitbusy (ai)){ printk(KERN_INFO "Waitbusy hang AFTER RESET\n"); @@ -7464,8 +7461,7 @@ int setflashmode (struct airo_info *ai) OUT4500(ai, SWS3, FLASH_COMMAND); OUT4500(ai, COMMAND,0); } - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ/2); /* 500ms delay */ + msleep(500); if(!waitbusy(ai)) { clear_bit (FLAG_FLASHING, &ai->flags); @@ -7575,8 +7571,7 @@ int flashputbuf(struct airo_info *ai){ int flashrestart(struct airo_info *ai,struct net_device *dev){ int i,status; - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); /* Added 12/7/00 */ + msleep(1000); /* Added 12/7/00 */ clear_bit (FLAG_FLASHING, &ai->flags); if (test_bit(FLAG_MPI, &ai->flags)) { status = mpi_init_descriptors(ai); @@ -7591,8 +7586,7 @@ int flashrestart(struct airo_info *ai,st ( ai, 2312, i >= MAX_FIDS / 2 ); } - set_current_state (TASK_UNINTERRUPTIBLE); - schedule_timeout (HZ); /* Added 12/7/00 */ + msleep(1000); /* Added 12/7/00 */ return status; } #endif /* CISCO_EXT */ _ From janitor@sternwelten.at Wed Sep 1 14:06:08 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:06:14 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L65at010414 for ; Wed, 1 Sep 2004 14:06:05 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id EE3955C069; Wed, 1 Sep 2004 23:05:54 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04663-10; Wed, 1 Sep 2004 23:05:54 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 6B25F5C008; Wed, 1 Sep 2004 23:05:54 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIm-00083E-M9; Wed, 01 Sep 2004 23:05:56 +0200 Subject: [patch 7/8] wireless/airport: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:05:56 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8328 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 2171 Lines: 72 I would appreciate any comments from the janitor@sternweltens list. Description: Use msleep() instead of schedule_timeout() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/wireless/airport.c | 15 +++++---------- 1 files changed, 5 insertions(+), 10 deletions(-) diff -puN drivers/net/wireless/airport.c~msleep-drivers_net_wireless_airport drivers/net/wireless/airport.c --- linux-2.6.9-rc1-bk7/drivers/net/wireless/airport.c~msleep-drivers_net_wireless_airport 2004-09-01 19:35:41.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/wireless/airport.c 2004-09-01 19:35:41.000000000 +0200 @@ -94,8 +94,7 @@ airport_resume(struct macio_dev *mdev) printk(KERN_DEBUG "%s: Airport waking up\n", dev->name); pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 1); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ/5); + msleep(200); enable_irq(dev->irq); @@ -147,8 +146,7 @@ airport_detach(struct macio_dev *mdev) macio_release_resource(mdev, 0); pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 0); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ); + msleep(1000); macio_set_drvdata(mdev, NULL); free_netdev(dev); @@ -174,11 +172,9 @@ static int airport_hard_reset(struct ori disable_irq(dev->irq); pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(card->mdev), 0, 0); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ); + msleep(1000); pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(card->mdev), 0, 1); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ); + msleep(1000); enable_irq(dev->irq); schedule_timeout(HZ); @@ -240,8 +236,7 @@ airport_attach(struct macio_dev *mdev, c /* Power up card */ pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 1); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(HZ); + msleep(1000); /* Reset it before we get the interrupt */ hermes_init(hw); _ From janitor@sternwelten.at Wed Sep 1 14:06:13 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:06:20 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L6Alo010538 for ; Wed, 1 Sep 2004 14:06:11 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 968A55C06C; Wed, 1 Sep 2004 23:06:00 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 15352-01; Wed, 1 Sep 2004 23:06:00 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 16C7C5C008; Wed, 1 Sep 2004 23:06:00 +0200 (CEST) Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by sputnik with esmtp (Exim 4.34) id 1C2cIs-00083w-5t; Wed, 01 Sep 2004 23:06:02 +0200 Subject: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() To: netdev@oss.sgi.com Cc: jgarzik@pobox.com, jt@hpl.hp.com, janitor@sternwelten.at From: janitor@sternwelten.at Date: Wed, 01 Sep 2004 23:06:01 +0200 Message-ID: X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8329 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 1055 Lines: 38 I would appreciate any comments from the janitor@sternweltens list. Description: Use msleep() instead of schedule_timeout() to guarantee the task delays for the desired time. Signed-off-by: Nishanth Aravamudan Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-max/drivers/net/wireless/prism54/islpci_dev.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) diff -puN drivers/net/wireless/prism54/islpci_dev.c~msleep-drivers_net_wireless_prism54_islpci_dev drivers/net/wireless/prism54/islpci_dev.c --- linux-2.6.9-rc1-bk7/drivers/net/wireless/prism54/islpci_dev.c~msleep-drivers_net_wireless_prism54_islpci_dev 2004-09-01 19:35:41.000000000 +0200 +++ linux-2.6.9-rc1-bk7-max/drivers/net/wireless/prism54/islpci_dev.c 2004-09-01 19:35:41.000000000 +0200 @@ -436,8 +436,7 @@ prism54_bring_down(islpci_private *priv) wmb(); /* wait a while for the device to reset */ - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(50*HZ/1000); + msleep(50); return 0; } _ From jt@bougret.hpl.hp.com Wed Sep 1 14:09:39 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:09:44 -0700 (PDT) Received: from palrel12.hp.com (palrel12.hp.com [156.153.255.237]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81L9c39014539 for ; Wed, 1 Sep 2004 14:09:39 -0700 Received: from tomil.hpl.hp.com (tomil.hpl.hp.com [15.0.152.100]) by palrel12.hp.com (Postfix) with ESMTP id 5A0224000A2; Wed, 1 Sep 2004 14:09:30 -0700 (PDT) Received: from bougret.hpl.hp.com (bougret.hpl.hp.com [15.4.92.227]) by tomil.hpl.hp.com (8.9.3 (PHNE_29774)/8.9.3 HPLabs Timeshare Server) with ESMTP id OAA12874; Wed, 1 Sep 2004 14:12:01 -0700 (PDT) Received: from jt by bougret.hpl.hp.com with local (Exim 3.35 #1 (Debian)) id 1C2cMD-000363-00; Wed, 01 Sep 2004 14:09:29 -0700 Date: Wed, 1 Sep 2004 14:09:29 -0700 To: janitor@sternwelten.at Cc: netdev@oss.sgi.com, jgarzik@pobox.com Subject: Re: [patch 1/8] irda/act200l-sir: replace schedule_timeout() with msleep() Message-ID: <20040901210929.GA11442@bougret.hpl.hp.com> Reply-To: jt@hpl.hp.com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i Organisation: HP Labs Palo Alto Address: HP Labs, 1U-17, 1501 Page Mill road, Palo Alto, CA 94304, USA. E-mail: jt@hpl.hp.com From: Jean Tourrilhes X-archive-position: 8330 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jt@bougret.hpl.hp.com Precedence: bulk X-list: netdev Content-Length: 309 Lines: 14 On Wed, Sep 01, 2004 at 11:05:23PM +0200, janitor@sternwelten.at wrote: > > > > > > > I would appreciate any comments from the janitor@sternweltens list. I already commented that I don't like the confusing msleep() API and I prefer the more explicit schedule_timeout(). But that's only me... Jean From max@stro.at Wed Sep 1 14:40:13 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:40:17 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81LeCas015306 for ; Wed, 1 Sep 2004 14:40:13 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 59E035C065; Wed, 1 Sep 2004 23:40:02 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26747-03; Wed, 1 Sep 2004 23:40:01 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id C027F5C008; Wed, 1 Sep 2004 23:40:01 +0200 (CEST) Received: from max by sputnik with local (Exim 4.34) id 1C2cpn-0000e6-Sl; Wed, 01 Sep 2004 23:40:03 +0200 Date: Wed, 1 Sep 2004 23:40:03 +0200 From: maximilian attems To: jt@hpl.hp.com Cc: netdev@oss.sgi.com, jgarzik@pobox.com, kj Subject: Re: [patch 1/8] irda/act200l-sir: replace schedule_timeout() with msleep() Message-ID: <20040901214003.GC7467@stro.at> Mail-Followup-To: jt@hpl.hp.com, netdev@oss.sgi.com, jgarzik@pobox.com, kj References: <20040901210929.GA11442@bougret.hpl.hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901210929.GA11442@bougret.hpl.hp.com> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8331 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 666 Lines: 22 On Wed, 01 Sep 2004, Jean Tourrilhes wrote: > On Wed, Sep 01, 2004 at 11:05:23PM +0200, janitor@sternwelten.at wrote: > > I would appreciate any comments from the janitor@sternweltens list. uups mangled some text there sorry for this silly email. > > I already commented that I don't like the confusing msleep() > API and I prefer the more explicit schedule_timeout(). > But that's only me... > > Jean hmm we have still archs were HZ < 100. i find msleep use msecs units a lot more readable than schedule_timeout((HZ + 99) / 100); the schedule_timeout(HZ/100) gets safely converted with msleep. -- maks kernel janitor http://janitor.kernelnewbies.org/ From jt@bougret.hpl.hp.com Wed Sep 1 14:48:24 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 14:48:30 -0700 (PDT) Received: from palrel13.hp.com (palrel13.hp.com [156.153.255.238]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81LmOaM015754 for ; Wed, 1 Sep 2004 14:48:24 -0700 Received: from tomil.hpl.hp.com (tomil.hpl.hp.com [15.0.152.100]) by palrel13.hp.com (Postfix) with ESMTP id 7FE3B1C0851D; Wed, 1 Sep 2004 14:48:16 -0700 (PDT) Received: from bougret.hpl.hp.com (bougret.hpl.hp.com [15.4.92.227]) by tomil.hpl.hp.com (8.9.3 (PHNE_29774)/8.9.3 HPLabs Timeshare Server) with ESMTP id OAA13748; Wed, 1 Sep 2004 14:50:47 -0700 (PDT) Received: from jt by bougret.hpl.hp.com with local (Exim 3.35 #1 (Debian)) id 1C2cxj-0003Oy-00; Wed, 01 Sep 2004 14:48:15 -0700 Date: Wed, 1 Sep 2004 14:48:15 -0700 To: netdev@oss.sgi.com, jgarzik@pobox.com, kj Subject: Re: [patch 1/8] irda/act200l-sir: replace schedule_timeout() with msleep() Message-ID: <20040901214815.GA13071@bougret.hpl.hp.com> Reply-To: jt@hpl.hp.com References: <20040901210929.GA11442@bougret.hpl.hp.com> <20040901214003.GC7467@stro.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901214003.GC7467@stro.at> User-Agent: Mutt/1.3.28i Organisation: HP Labs Palo Alto Address: HP Labs, 1U-17, 1501 Page Mill road, Palo Alto, CA 94304, USA. E-mail: jt@hpl.hp.com From: Jean Tourrilhes X-archive-position: 8332 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jt@bougret.hpl.hp.com Precedence: bulk X-list: netdev Content-Length: 926 Lines: 27 On Wed, Sep 01, 2004 at 11:40:03PM +0200, maximilian attems wrote: > On Wed, 01 Sep 2004, Jean Tourrilhes wrote: > > > On Wed, Sep 01, 2004 at 11:05:23PM +0200, janitor@sternwelten.at wrote: > > > I would appreciate any comments from the janitor@sternweltens list. > uups mangled some text there sorry for this silly email. > > > > I already commented that I don't like the confusing msleep() > > API and I prefer the more explicit schedule_timeout(). > > But that's only me... > > > > Jean > > hmm we have still archs were HZ < 100. > i find msleep use msecs units a lot more readable than > schedule_timeout((HZ + 99) / 100); > > the schedule_timeout(HZ/100) gets safely converted with msleep. I don't have complain about converting the (HZ + 99) / 100 expressions to something saner. My beef is the fact that msleep hide the fact that a schedule might happen. This is important in the IrDA code. > maks Jean From nacc@us.ibm.com Wed Sep 1 15:07:57 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 15:08:03 -0700 (PDT) Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.130]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81M7oDP016384 for ; Wed, 1 Sep 2004 15:07:57 -0700 Received: from westrelay04.boulder.ibm.com (westrelay04.boulder.ibm.com [9.17.193.32]) by e32.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id i81M3UsB481516; Wed, 1 Sep 2004 18:03:30 -0400 Received: from arkanoid.beaverton.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by westrelay04.boulder.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i81M3ShU204832; Wed, 1 Sep 2004 16:03:29 -0600 Received: from arkanoid.beaverton.ibm.com (arkanoid [127.0.0.1]) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) with ESMTP id i81M3R6a004197; Wed, 1 Sep 2004 22:03:27 GMT Received: (from aravamud@localhost) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) id i81M3RWP004194; Wed, 1 Sep 2004 22:03:27 GMT X-Authentication-Warning: arkanoid.beaverton.ibm.com: aravamud set sender to nacc@us.ibm.com using -f Date: Wed, 1 Sep 2004 22:03:26 +0000 From: Nishanth Aravamudan To: jt@hpl.hp.com Cc: netdev@oss.sgi.com, jgarzik@pobox.com, kj Subject: Re: [Kernel-janitors] Re: [patch 1/8] irda/act200l-sir: replace schedule_timeout() with msleep() Message-ID: <20040901220326.GB2516@us.ibm.com> References: <20040901210929.GA11442@bougret.hpl.hp.com> <20040901214003.GC7467@stro.at> <20040901214815.GA13071@bougret.hpl.hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901214815.GA13071@bougret.hpl.hp.com> X-Operating-System: Linux 2.6.73 (i686) User-Agent: Mutt/1.5.6+20040803i X-archive-position: 8333 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nacc@us.ibm.com Precedence: bulk X-list: netdev Content-Length: 1508 Lines: 34 On Wed, Sep 01, 2004 at 02:48:15PM -0700, Jean Tourrilhes wrote: > On Wed, Sep 01, 2004 at 11:40:03PM +0200, maximilian attems wrote: > > On Wed, 01 Sep 2004, Jean Tourrilhes wrote: > > > > > On Wed, Sep 01, 2004 at 11:05:23PM +0200, janitor@sternwelten.at wrote: > > > > I would appreciate any comments from the janitor@sternweltens list. > > uups mangled some text there sorry for this silly email. > > > > > > I already commented that I don't like the confusing msleep() > > > API and I prefer the more explicit schedule_timeout(). > > > But that's only me... > > > > > > Jean > > > > hmm we have still archs were HZ < 100. > > i find msleep use msecs units a lot more readable than > > schedule_timeout((HZ + 99) / 100); > > > > the schedule_timeout(HZ/100) gets safely converted with msleep. > > I don't have complain about converting the (HZ + 99) / 100 > expressions to something saner. My beef is the fact that msleep hide > the fact that a schedule might happen. This is important in the IrDA > code. It *is* important for developers to realize that invoking msleep() may involve giving up the CPU (ie. eventually calling schedule()); however, I think my previous point, that the name itself (the "sleep" part, I mean) is a fair and clear indication of this behavior, is valid. In those cases where a busy-wait is desired, then mdelay() should be used, as indicated by "delay". I think with this in mind & with a quick glance at the source, if need be, the naming is quite safe. -Nish From max@stro.at Wed Sep 1 15:58:55 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 15:59:06 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i81Mwsp0017551 for ; Wed, 1 Sep 2004 15:58:55 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id DFA3E5C008; Thu, 2 Sep 2004 00:58:43 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 01686-10; Thu, 2 Sep 2004 00:58:43 +0200 (CEST) Received: from sputnik (M830P021.adsl.highway.telekom.at [62.47.135.181]) by baikonur.stro.at (Postfix) with ESMTP id 3AAC15C065; Thu, 2 Sep 2004 00:58:43 +0200 (CEST) Received: from max by sputnik with local (Exim 4.34) id 1C2e3u-0001e1-TX; Thu, 02 Sep 2004 00:58:43 +0200 Date: Thu, 2 Sep 2004 00:58:42 +0200 From: maximilian attems To: jt@hpl.hp.com Cc: netdev@oss.sgi.com, jgarzik@pobox.com, kj Subject: Re: [Kernel-janitors] Re: [patch 1/8] irda/act200l-sir: replace schedule_timeout() with msleep() Message-ID: <20040901225841.GF7467@stro.at> Mail-Followup-To: jt@hpl.hp.com, netdev@oss.sgi.com, jgarzik@pobox.com, kj References: <20040901210929.GA11442@bougret.hpl.hp.com> <20040901214003.GC7467@stro.at> <20040901214815.GA13071@bougret.hpl.hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901214815.GA13071@bougret.hpl.hp.com> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8334 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 737 Lines: 26 On Wed, 01 Sep 2004, Jean Tourrilhes wrote: > On Wed, Sep 01, 2004 at 11:40:03PM +0200, maximilian attems wrote: > > On Wed, 01 Sep 2004, Jean Tourrilhes wrote: .. > > > > hmm we have still archs were HZ < 100. > > i find msleep use msecs units a lot more readable than > > schedule_timeout((HZ + 99) / 100); > > > > the schedule_timeout(HZ/100) gets safely converted with msleep. > > I don't have complain about converting the (HZ + 99) / 100 > expressions to something saner. My beef is the fact that msleep hide > the fact that a schedule might happen. This is important in the IrDA > code. sorry my woding was confusing: (HZ + 99) / 100 is correct! as msleep(10) -- maks kernel janitor http://janitor.kernelnewbies.org/ From acme@conectiva.com.br Wed Sep 1 19:46:25 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 19:46:31 -0700 (PDT) Received: from perninha.conectiva.com.br (perninha.conectiva.com.br [200.140.247.100]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i822kOCt024942 for ; Wed, 1 Sep 2004 19:46:25 -0700 Received: by perninha.conectiva.com.br (Postfix, from userid 568) id 5FC4147429; Wed, 1 Sep 2004 23:46:14 -0300 (BRT) Received: from burns.conectiva (burns.conectiva [10.0.0.4]) by perninha.conectiva.com.br (Postfix) with SMTP id B313F4796E for ; Wed, 1 Sep 2004 23:46:13 -0300 (BRT) Received: (qmail 31263 invoked by uid 0); 2 Sep 2004 03:43:59 -0000 Received: from mapi8.distro.conectiva (HELO oops.kerneljanitors.org) (10.0.16.10) by burns.conectiva with SMTP; 2 Sep 2004 03:43:59 -0000 Received: by oops.kerneljanitors.org (Postfix, from userid 500) id CA0F21464C; Wed, 1 Sep 2004 23:48:05 -0300 (BRT) Date: Wed, 1 Sep 2004 23:48:05 -0300 From: Arnaldo Carvalho de Melo To: "David S. Miller" Cc: Zhikui Chen , hadi@cyberus.ca, dccp@ietf.org, netdev@oss.sgi.com Subject: Re: HELP for dccp implementation. Message-ID: <20040902024805.GA23844@conectiva.com.br> References: <412CC269.8080907@rus.uni-stuttgart.de> <1093454747.1034.85.camel@jzny.localdomain> <4135A32A.4030901@rus.uni-stuttgart.de> <20040901133709.3637d63d.davem@davemloft.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901133709.3637d63d.davem@davemloft.net> X-Url: http://advogato.org/person/acme User-Agent: Mutt/1.5.5.1i X-Bogosity: No, tests=bogofilter, spamicity=0.051111, version=0.16.3 X-archive-position: 8335 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: acme@conectiva.com.br Precedence: bulk X-list: netdev Content-Length: 882 Lines: 23 Em Wed, Sep 01, 2004 at 01:37:09PM -0700, David S. Miller escreveu: > On Wed, 01 Sep 2004 12:23:38 +0200 > Zhikui Chen wrote: > > > If I assign a value such as 0x ee9fbc00 to sk in dccp_rcv (before lookup > > calling), and comment lookkup calling, I get a error report from > > bh_lock_sock(sk) calling inside dccp_rcv, which error report is > > spin_is_locked on uninitialized spinlock ee9fbc00, and spin_lock > > (:ee9fbc00) already locked by /73. > > > > Do you know its reason? Thanks, > > Zhikui, are you working together with Arnaldo using his > code base, like we suggested to you? Or are you working > still on your own code? Dave, I've been quite busy lately with some other projects and haven't been able to colaborate with Zhikui, I hope to change this situation soon. Regards, - Arnaldo From davem@davemloft.net Wed Sep 1 22:22:22 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 22:22:29 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i825MM5j031276 for ; Wed, 1 Sep 2004 22:22:22 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C2k2A-0005yV-00; Wed, 01 Sep 2004 22:21:18 -0700 Date: Wed, 1 Sep 2004 22:21:18 -0700 From: "David S. Miller" To: Herbert Xu Cc: shemminger@osdl.org, netdev@oss.sgi.com Subject: Re: neigh_create/inetdev_destroy race? Message-Id: <20040901222118.0ce4bcc6.davem@davemloft.net> In-Reply-To: <20040831104139.GA2124@gondor.apana.org.au> References: <20040814005411.GA18350@gondor.apana.org.au> <20040814012513.GA721@gondor.apana.org.au> <20040814013030.GA2042@gondor.apana.org.au> <20040814050848.GA11874@gondor.apana.org.au> <20040814062703.GA4806@gondor.apana.org.au> <20040815191450.77532d5d.davem@redhat.com> <20040816105131.GA11299@gondor.apana.org.au> <20040828234201.79556f6e.davem@davemloft.net> <20040829065031.GA786@gondor.apana.org.au> <20040830230820.7514985d.davem@davemloft.net> <20040831104139.GA2124@gondor.apana.org.au> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8336 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 2207 Lines: 81 On Tue, 31 Aug 2004 20:41:39 +1000 Herbert Xu wrote: > > I think we can clear this by putting neigh_parms_release() into an > > RCU handler. It can't be in in_dev_rcu_put. > > Yes that should go a long way in resolving this problem. So here's the first step. No rcu_read_lock()'s are needed since the tbl->lock needs to be held as a write when traversing these things anyways for other reasons. Can you work on the next bit you mentioned, making sure the corresponding idev is still alive when we add a neighbour with its neigh_parms to the hash table? Thanks. ===== include/net/neighbour.h 1.8 vs edited ===== --- 1.8/include/net/neighbour.h 2004-08-16 14:10:51 -07:00 +++ edited/include/net/neighbour.h 2004-09-01 21:57:37 -07:00 @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,8 @@ void *priv; void *sysctl_table; + + struct rcu_head rcu_head; int base_reachable_time; int retrans_time; ===== net/core/neighbour.c 1.28 vs edited ===== --- 1.28/net/core/neighbour.c 2004-04-29 16:26:35 -07:00 +++ edited/net/core/neighbour.c 2004-09-01 22:00:59 -07:00 @@ -1120,6 +1120,7 @@ if (p) { memcpy(p, &tbl->parms, sizeof(*p)); p->tbl = tbl; + INIT_RCU_HEAD(&p->rcu_head); p->reachable_time = neigh_rand_reach_time(p->base_reachable_time); if (dev && dev->neigh_setup && dev->neigh_setup(dev, p)) { @@ -1135,6 +1136,14 @@ return p; } +static void neigh_rcu_free_parms(struct rcu_head *head) +{ + struct neigh_parms *parms = + container_of(head, struct neigh_parms, rcu_head); + + kfree(parms); +} + void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms) { struct neigh_parms **p; @@ -1146,7 +1155,7 @@ if (*p == parms) { *p = parms->next; write_unlock_bh(&tbl->lock); - kfree(parms); + call_rcu(&parms->rcu_head, neigh_rcu_free_parms); return; } } @@ -1159,6 +1168,7 @@ { unsigned long now = jiffies; + INIT_RCU_HEAD(&tbl->parms.rcu_head); tbl->parms.reachable_time = neigh_rand_reach_time(tbl->parms.base_reachable_time); From davem@redhat.com Wed Sep 1 22:27:33 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 22:27:38 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i825RWEM031668 for ; Wed, 1 Sep 2004 22:27:32 -0700 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i825RES0025351; Thu, 2 Sep 2004 01:27:19 -0400 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i825R9313941; Thu, 2 Sep 2004 01:27:09 -0400 Received: from cheetah.davemloft.net (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11/8.12.10) with SMTP id i825R1hU011844; Thu, 2 Sep 2004 01:27:01 -0400 Date: Wed, 1 Sep 2004 22:26:24 -0700 From: "David S. Miller" To: Andi Kleen Cc: netdev@oss.sgi.com Subject: Re: [PATCH] Fix CONFIG_COMPAT with !CONFIG_NET Message-Id: <20040901222624.31205ef5.davem@redhat.com> In-Reply-To: References: X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8337 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@redhat.com Precedence: bulk X-list: netdev Content-Length: 394 Lines: 12 On Tue, 31 Aug 2004 12:06:30 +0200 Andi Kleen wrote: > Fix compilation with CONFIG_COMPAT set and CONFIG_NET disabled. I like this patch, but... > -static int ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) > +static __attribute__((used)) int > +ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) Ahem... use something in linux/compiler.h ok? :) From davem@redhat.com Wed Sep 1 22:34:09 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 22:34:14 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i825Y85k032101 for ; Wed, 1 Sep 2004 22:34:09 -0700 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i825XqS0026489; Thu, 2 Sep 2004 01:33:52 -0400 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i825Xl314921; Thu, 2 Sep 2004 01:33:47 -0400 Received: from cheetah.davemloft.net (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11/8.12.10) with SMTP id i825XdiV013008; Thu, 2 Sep 2004 01:33:39 -0400 Date: Wed, 1 Sep 2004 22:33:01 -0700 From: "David S. Miller" To: Andi Kleen Cc: kuznet@ms2.inr.ac.ru, netdev@oss.sgi.com, akepner@sgi.com Subject: Re: [PATCH] Extend lock less TX to real devices Message-Id: <20040901223301.1a8d97a8.davem@redhat.com> In-Reply-To: References: X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8338 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@redhat.com Precedence: bulk X-list: netdev Content-Length: 1126 Lines: 32 On Tue, 31 Aug 2004 14:38:20 +0200 Andi Kleen wrote: > This patch extends the recently added NETIF_F_LLTX to real devices. Well, it does a lot of other things too. > I added support for trylocking instead of spinning like sch_generic > does - for that the driver has to return -1, then the packet is requeued. > The check for a local device deadlock is lost for this case, > but that doesn't seem to be a big loss (I've never seen this printk > ever get triggered) It is triggerable if you misconfigure your system. I'm totally against this change, because previously at least the user would find out in their logs. With your change the system explodes looping with no explanation why. > The patch looks bigger than it really is because i moved some code > around and converted the macros into inlines. .. > I also did an additional micro optimization: And for this reason you need to split this patch up. I would recommend: patch 1) Change macros into inlines patch 2) local_bh_disable() preemption count optimization patch 3) support for F_LLTX on real devices patch 4) locking changes Thanks Andi. From davem@redhat.com Wed Sep 1 22:42:12 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 22:42:18 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i825gCc2032568 for ; Wed, 1 Sep 2004 22:42:12 -0700 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i825fsS0028432; Thu, 2 Sep 2004 01:41:54 -0400 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i825fs316499; Thu, 2 Sep 2004 01:41:54 -0400 Received: from cheetah.davemloft.net (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11/8.12.10) with SMTP id i825fjLG015242; Thu, 2 Sep 2004 01:41:46 -0400 Date: Wed, 1 Sep 2004 22:41:08 -0700 From: "David S. Miller" To: vatsa@in.ibm.com Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org, dipankar@in.ibm.com, paulmck@us.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Message-Id: <20040901224108.3b2d692d.davem@redhat.com> In-Reply-To: <20040831125941.GA5534@in.ibm.com> References: <20040831125941.GA5534@in.ibm.com> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8339 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@redhat.com Precedence: bulk X-list: netdev Content-Length: 3453 Lines: 71 On Tue, 31 Aug 2004 18:29:41 +0530 Srivatsa Vaddagiri wrote: > Some notes on the patch: > > - Although readprofile shows improvement in tick count for > __tcp_v4_lookup_established, I haven't come across any benchmarks that is > benefited noticeably by the lock-free lookup. I have tried httperf, netperf > and simple file transfer tests so far. > > This could possibly be because the hash table size on the machines I was > testing was high (tcp_ehash_size = 128K), leading to low contention rate on > the hash bucket locks. Also because of the fact that lookup could happen in > parallel to socket input packet processing. > > I would be interested to know if anyone has seen high-rate of lock contention > for hash bucket lock. Such workloads would benefit from the lock-free lookup. The reason you don't see any improvement is that the ehash table is pretty write heavy. I'm not totally against your patch, I just don't think that the TCP established hash table qualifies as "read heavy" as per what RCU is truly effective for. > - I presume that one of the reasons for keeping the hash table so big is to > keep lock contention low (& to reduce the size of hash chains). If the lookup > is made lock-free, then could the size of the hash table be reduced (without > adversely impacting performance)? It's large so that the hash itself is effective, not for locking reasons. > - Biggest problem I had converting over to RCU was the refcount race between > sock_put and sock_hold. sock_put might see the refcount go to zero and decide > to free the object, while on some other CPU, sock_get's are pending against > the same object. The patch handles the race by deciding to free the object > only from the RCU callback. That's exactly what I was concerned about when I saw that you had attempted this change. It is incredibly important for state changes and updates to be seen as atomic by the packet input processing engine. It would be illegal for a cpu running TCP input to see a socket in two tables at the same time (for example, in the main established area and in the second half for TIME_WAIT buckets). If the visibility of the socket is wrong, sockets could be erroneously be reset during the transition from established to TIME_WAIT state. Beware! > - Socket table lookups that happens thr', say /proc/net/tcp or tcpdiag_dump, is > not lock-free yet. This is because of movement of socket performed in > __tcp_tw_hashdance, between established half to time-wait half. > There is a window during this movement, when the same socket is present > on both time-wait half as well as established half. I felt that it is not > good to have /proc/net/tcp report two instances of the same socket. Hence > I resorted to have /proc/net/tcp and tcpdiag_dump doing the lookup using > a spinlock. /proc/net/tcp should simply not be used by people, we have the netlink interface to get socket listings which actually scales. Leaving /proc/net/tcp readable on servers with real users is a DoS waiting to happen. > Note that __tcp_v4_lookup_established should not be affected by the above > movement because I found it scans the established half first and _then_ the > time wait half. So even if the same socket is present in both established half > and time wait half, __tcp_v4_lookup_established will lookup only one of them > (& not both). I hope this is true. From davem@davemloft.net Wed Sep 1 22:44:00 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 22:44:06 -0700 (PDT) Received: from smtp110.mail.sc5.yahoo.com (smtp110.mail.sc5.yahoo.com [66.163.170.8]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i825hxhA000393 for ; Wed, 1 Sep 2004 22:44:00 -0700 Received: from unknown (HELO cheetah.davemloft.net) (davem?330@63.197.226.105 with login) by smtp110.mail.sc5.yahoo.com with SMTP; 2 Sep 2004 05:43:51 -0000 Date: Wed, 1 Sep 2004 22:43:06 -0700 From: "David S. Miller" To: Andi Kleen Cc: vatsa@in.ibm.com, davem@redhat.com, netdev@oss.sgi.com, linux-kernel@vger.kernel.org, dipankar@in.ibm.com, paulmck@us.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Message-Id: <20040901224306.7dd80458.davem@davemloft.net> In-Reply-To: <20040831135419.GA17642@wotan.suse.de> References: <20040831125941.GA5534@in.ibm.com> <20040831135419.GA17642@wotan.suse.de> Organization: DaveM Loft Enterprises X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8340 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 760 Lines: 19 On Tue, 31 Aug 2004 15:54:20 +0200 Andi Kleen wrote: > And it should also fix the performance problems with > cat /proc/net/tcp on ppc64/ia64 for large hash tables because the rw locks > are gone. Time to convert netstat et al. over the netlink too. > > - I presume that one of the reasons for keeping the hash table so big is to > > keep lock contention low (& to reduce the size of hash chains). If the lookup > > is made lock-free, then could the size of the hash table be reduced (without > > adversely impacting performance)? > > Definitely worth trying IMHO. The current hash tables are far > too big. I would do that as followon patches though. The hashes are big to make the hash effective, not to help the locking contention. From davem@davemloft.net Wed Sep 1 22:46:39 2004 Received: with ECARTIS (v1.0.0; list netdev); Wed, 01 Sep 2004 22:46:44 -0700 (PDT) Received: from smtp108.mail.sc5.yahoo.com (smtp108.mail.sc5.yahoo.com [66.163.170.6]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i825kdsQ000774 for ; Wed, 1 Sep 2004 22:46:39 -0700 Received: from unknown (HELO cheetah.davemloft.net) (davem?330@63.197.226.105 with login) by smtp108.mail.sc5.yahoo.com with SMTP; 2 Sep 2004 05:46:31 -0000 Date: Wed, 1 Sep 2004 22:45:46 -0700 From: "David S. Miller" To: vatsa@in.ibm.com Cc: ak@suse.de, davem@redhat.com, netdev@oss.sgi.com, linux-kernel@vger.kernel.org, dipankar@in.ibm.com, paulmck@us.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Message-Id: <20040901224546.03765c8d.davem@davemloft.net> In-Reply-To: <20040901113641.GA3918@in.ibm.com> References: <20040831125941.GA5534@in.ibm.com> <20040831135419.GA17642@wotan.suse.de> <20040901113641.GA3918@in.ibm.com> Organization: DaveM Loft Enterprises X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8341 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 1484 Lines: 34 On Wed, 1 Sep 2004 17:06:41 +0530 Srivatsa Vaddagiri wrote: > On Tue, Aug 31, 2004 at 03:54:20PM +0200, Andi Kleen wrote: > > I bet also when you just do rdtsc timing for the TCP receive > > path the cycle numbers will be way down (excluding the copy). > > I got cycle numbers for the lookup routine (with CONFIG_PREEMPT turned off). > They were taken on a 900MHz 8way Intel P3 SMP box. The results are as below: > > > ------------------------------------------------------------------------------- > | 2.6.8.1 | 2.6.8.1 + my patch > ------------------------------------------------------------------------------- > Average cycles | | > spent in | | > __tcp_v4_lookup_established | 2970.65 | 668.227 > | (~3.3 micro-seconds) | (~0.74 microseconds) > ------------------------------------------------------------------------------- > > This repesents improvement by a factor of 77.5%! And yet none of your benchmarks show noticable improvements, which means that this micro-measurement is totally unimportant in the grand scheme of things as far as we know. I'm not adding in a patch that merely provides some micro-measurement improvement that someone can do a shamans dance over. :) If we're going to add this new level of complexity to the TCP code we need to see some real usage performance improvement, not just something that shows up when we put a microscope on a single function. From margitsw@t-online.de Thu Sep 2 00:02:33 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 00:02:45 -0700 (PDT) Received: from mailout07.sul.t-online.com (mailout07.sul.t-online.com [194.25.134.83]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8272W1O002697 for ; Thu, 2 Sep 2004 00:02:33 -0700 Received: from fwd00.aul.t-online.de by mailout07.sul.t-online.com with smtp id 1C2lbz-0003TC-04; Thu, 02 Sep 2004 09:02:23 +0200 Received: from roglap.local (ZZMK7oZb8e9+xkugoAKd-ri8Nbyr6YNpR3taY7+k50x-7OKsWGqCcl@[217.224.24.102]) by fwd00.sul.t-online.com with esmtp id 1C2lbn-2FEFIe0; Thu, 2 Sep 2004 09:02:11 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: netdev@oss.sgi.com Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Date: Thu, 2 Sep 2004 08:50:38 +0200 User-Agent: KMail/1.5.4 Cc: janitor@sternwelten.at MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409020850.38177.margitsw@t-online.de> X-ID: ZZMK7oZb8e9+xkugoAKd-ri8Nbyr6YNpR3taY7+k50x-7OKsWGqCcl X-TOI-MSGID: 750c7a0a-8598-42e0-be04-32caec994a4a X-archive-position: 8342 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev Content-Length: 306 Lines: 10 I agree with Jean and add the following : You are assuming HZ = 1000. In 2.4, HZ = 100 (And in 2.6, HZ is not necessarily = 1000). The prism54 code base is identical between 2.4/2.6 and is maintained as such in the project. Therefore, I look forward to your implementation of msleep() in 2.4 ;-) Margit From max@stro.at Thu Sep 2 01:24:44 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 01:24:49 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i828OhMH008902 for ; Thu, 2 Sep 2004 01:24:44 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 569FE5C065; Thu, 2 Sep 2004 10:24:33 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 11776-07; Thu, 2 Sep 2004 10:24:32 +0200 (CEST) Received: from sputnik (M965P030.adsl.highway.telekom.at [62.47.152.158]) by baikonur.stro.at (Postfix) with ESMTP id B5D775C008; Thu, 2 Sep 2004 10:24:32 +0200 (CEST) Received: from max by sputnik with local (Exim 4.34) id 1C2mtV-00012b-A6; Thu, 02 Sep 2004 10:24:33 +0200 Date: Thu, 2 Sep 2004 10:24:33 +0200 From: maximilian attems To: Margit Schubert-While Cc: netdev@oss.sgi.com, kj Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Message-ID: <20040902082432.GA1876@stro.at> Mail-Followup-To: Margit Schubert-While , netdev@oss.sgi.com, kj References: <200409020850.38177.margitsw@t-online.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200409020850.38177.margitsw@t-online.de> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8343 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 724 Lines: 24 On Thu, 02 Sep 2004, Margit Schubert-While wrote: > I agree with Jean and add the following : > You are assuming HZ = 1000. > In 2.4, HZ = 100 (And in 2.6, HZ is not necessarily = 1000). shure, but this is an argument for msleep as it uses msecs as unit, which don't depend on your arch. (well physics says different for arch/relativistic :) > The prism54 code base is identical between 2.4/2.6 and is > maintained as such in the project. > Therefore, I look forward to your implementation of msleep() > in 2.4 ;-) 2.4 is closed for such stuff, you'll know that better than me, it shouldn't hinder 2.6 in it's progression. one day you will need to branch. -- maks kernel janitor http://janitor.kernelnewbies.org/ From margitsw@t-online.de Thu Sep 2 02:47:59 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 02:48:04 -0700 (PDT) Received: from mailout10.sul.t-online.com (mailout10.sul.t-online.com [194.25.134.21]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i829lwLE013269 for ; Thu, 2 Sep 2004 02:47:59 -0700 Received: from fwd09.aul.t-online.de by mailout10.sul.t-online.com with smtp id 1C2oC6-0000xj-01; Thu, 02 Sep 2004 11:47:50 +0200 Received: from roglap.local (SUHUzvZ-8eXCHB3xcEwbuSp0Mp4mYoutEzX8sHfg8jiJjYa1rVMWw+@[217.255.115.148]) by fwd09.sul.t-online.com with esmtp id 1C2oBr-0hwnce0; Thu, 2 Sep 2004 11:47:35 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: netdev@oss.sgi.com Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Date: Thu, 2 Sep 2004 11:35:57 +0200 User-Agent: KMail/1.5.4 Cc: janitor@sternwelten.at MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409021135.57632.margitsw@t-online.de> X-ID: SUHUzvZ-8eXCHB3xcEwbuSp0Mp4mYoutEzX8sHfg8jiJjYa1rVMWw+ X-TOI-MSGID: 5ef338f1-34c6-4bd0-8378-af70bc838370 X-archive-position: 8344 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev Content-Length: 237 Lines: 8 On Thu, 02 Sep 2004, Maximilian scribeth: > it shouldn't hinder 2.6 in it's progression. I consider this a regression. As schedule_timeout is used elesewhere in the prism54 code, we are using a consistent and documented method. Margit From max@stro.at Thu Sep 2 03:03:32 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 03:03:38 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82A3WFo014123 for ; Thu, 2 Sep 2004 03:03:32 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id E87C65C065; Thu, 2 Sep 2004 12:03:21 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09880-07; Thu, 2 Sep 2004 12:03:21 +0200 (CEST) Received: from sputnik (M965P030.adsl.highway.telekom.at [62.47.152.158]) by baikonur.stro.at (Postfix) with ESMTP id 71EDB5C008; Thu, 2 Sep 2004 12:03:21 +0200 (CEST) Received: from max by sputnik with local (Exim 4.34) id 1C2oR8-0001sT-5r; Thu, 02 Sep 2004 12:03:22 +0200 Date: Thu, 2 Sep 2004 12:03:22 +0200 From: maximilian attems To: Margit Schubert-While Cc: netdev@oss.sgi.com, kj Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Message-ID: <20040902100322.GD1876@stro.at> Mail-Followup-To: Margit Schubert-While , netdev@oss.sgi.com, kj References: <200409021135.57632.margitsw@t-online.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200409021135.57632.margitsw@t-online.de> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8345 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev Content-Length: 460 Lines: 16 On Thu, 02 Sep 2004, Margit Schubert-While wrote: > On Thu, 02 Sep 2004, Maximilian scribeth: > > it shouldn't hinder 2.6 in it's progression. > I consider this a regression. > As schedule_timeout is used elesewhere in the prism54 code, > we are using a consistent and documented method. you didn't answer to the unit argument in favour of msleep. shure msleep is also consistent and documented. -- maks kernel janitor http://janitor.kernelnewbies.org/ From margitsw@t-online.de Thu Sep 2 03:33:38 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 03:33:44 -0700 (PDT) Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com [194.25.134.82]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82AXcn7016072 for ; Thu, 2 Sep 2004 03:33:38 -0700 Received: from fwd01.aul.t-online.de by mailout05.sul.t-online.com with smtp id 1C2ouH-0003kY-05; Thu, 02 Sep 2004 12:33:29 +0200 Received: from roglap.local (Tnz5qYZF8e9457pYQieTTeEIqQdc7lGj+UHe6PaeG+V07c5IS8Ns4h@[217.224.28.77]) by fwd01.sul.t-online.com with esmtp id 1C2ouE-1a48OG0; Thu, 2 Sep 2004 12:33:26 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: netdev@oss.sgi.com Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Date: Thu, 2 Sep 2004 12:21:42 +0200 User-Agent: KMail/1.5.4 Cc: janitor@sternwelten.at MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409021221.42287.margitsw@t-online.de> X-ID: Tnz5qYZF8e9457pYQieTTeEIqQdc7lGj+UHe6PaeG+V07c5IS8Ns4h X-TOI-MSGID: 68c3e6c7-4a05-4969-9a8a-cb9a86876b9b X-archive-position: 8346 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev On Thu, 02 Sep 2004, Maximilian scribeth: > you didn't answer to the unit argument in favour of msleep. Don't need to, here's msleep - void msleep(unsigned int msecs) { unsigned long timeout = msecs_to_jiffies(msecs); while (timeout) { set_current_state(TASK_UNINTERRUPTIBLE); timeout = schedule_timeout(timeout); } } In other words, with the subtle exception of the while loop, it reconstitutes the original code. (Although m_to_j doesn't even exactly do that) (And note because of the while loop, this may not be what the author intended) > shure msleep is also consistent and documented. grep -r Documentation = Nix Margit From margitsw@t-online.de Thu Sep 2 04:14:15 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 04:14:23 -0700 (PDT) Received: from mailout09.sul.t-online.com (mailout09.sul.t-online.com [194.25.134.84]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82BEEAT021128 for ; Thu, 2 Sep 2004 04:14:15 -0700 Received: from fwd08.aul.t-online.de by mailout09.sul.t-online.com with smtp id 1C2pXZ-0001mb-05; Thu, 02 Sep 2004 13:14:05 +0200 Received: from roglap.local (ZYwoviZSreF-pdqRDHwkJ74gIjgQ8CI3ZTOcIys3IeGfg8e2b7Hmcy@[80.128.222.2]) by fwd08.sul.t-online.com with esmtp id 1C2pXR-0VU6C00; Thu, 2 Sep 2004 13:13:57 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: netdev@oss.sgi.com Subject: Re: [patch 01/16] __FUNCTION__ string concatenation Date: Thu, 2 Sep 2004 13:02:22 +0200 User-Agent: KMail/1.5.4 Cc: janitor@sternwelten.at MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409021302.22823.margitsw@t-online.de> X-ID: ZYwoviZSreF-pdqRDHwkJ74gIjgQ8CI3ZTOcIys3IeGfg8e2b7Hmcy X-TOI-MSGID: 9470ae78-2f8a-4cc5-a808-7cfeabfe9e97 X-archive-position: 8347 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev On Thu, 02 Sep 2004, Maximilian scribeth: > drivers/net/wireless/prism65/islpci_mgt.h, as suggested Woo, we got another project ? (prism65) > I don't have the hardware to do a run-time check. > It should not pose any problems though. Oh, I think we can safely say that, especially as TRACE is nowhere referenced ;-) (And therefore the patch is unnecessary) Margit From herbert@gondor.apana.org.au Thu Sep 2 06:06:33 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 06:06:41 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82D6WjR004015 for ; Thu, 2 Sep 2004 06:06:33 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1C2rI2-0002ob-00; Thu, 02 Sep 2004 23:06:10 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1C2rHx-0008TX-00; Thu, 02 Sep 2004 23:06:05 +1000 Date: Thu, 2 Sep 2004 23:06:05 +1000 To: "David S. Miller" Cc: shemminger@osdl.org, netdev@oss.sgi.com Subject: Re: neigh_create/inetdev_destroy race? Message-ID: <20040902130605.GA32570@gondor.apana.org.au> References: <20040814013030.GA2042@gondor.apana.org.au> <20040814050848.GA11874@gondor.apana.org.au> <20040814062703.GA4806@gondor.apana.org.au> <20040815191450.77532d5d.davem@redhat.com> <20040816105131.GA11299@gondor.apana.org.au> <20040828234201.79556f6e.davem@davemloft.net> <20040829065031.GA786@gondor.apana.org.au> <20040830230820.7514985d.davem@davemloft.net> <20040831104139.GA2124@gondor.apana.org.au> <20040901222118.0ce4bcc6.davem@davemloft.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901222118.0ce4bcc6.davem@davemloft.net> User-Agent: Mutt/1.5.6+20040722i From: Herbert Xu X-archive-position: 8348 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev On Wed, Sep 01, 2004 at 10:21:18PM -0700, David S. Miller wrote: > > So here's the first step. No rcu_read_lock()'s are needed > since the tbl->lock needs to be held as a write when > traversing these things anyways for other reasons. Thanks. > Can you work on the next bit you mentioned, making > sure the corresponding idev is still alive when we add > a neighbour with its neigh_parms to the hash table? Sure. Actually I prefer to do it by ref counting neigh_parms directly. I'll send you a patch soon. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt From khc@pm.waw.pl Thu Sep 2 07:06:43 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 07:06:55 -0700 (PDT) Received: from inx.pm.waw.pl (IDENT:1YwU6gXiFp5E39BXnhw2yBkLOvILUoL1@inx.pm.waw.pl [195.116.170.20]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82E6gHA015644 for ; Thu, 2 Sep 2004 07:06:43 -0700 Received: from defiant.pm.waw.pl (pk124.warszawa.cvx.ppp.tpnet.pl [213.76.106.124]) by inx.pm.waw.pl (Postfix) with ESMTP id 9EA61E0E2; Thu, 2 Sep 2004 16:05:08 +0200 (CEST) Received: by defiant.pm.waw.pl (Postfix, from userid 500) id 40E49302D6; Thu, 2 Sep 2004 14:27:57 +0200 (CEST) To: Jeff Garzik Cc: Subject: [PATCH][REPOST] 21143 Tulip problems with 10BaseT References: From: Krzysztof Halasa Date: Thu, 02 Sep 2004 14:27:57 +0200 In-Reply-To: (Krzysztof Halasa's message of "Fri, 28 May 2004 14:21:57 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-archive-position: 8349 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: khc@pm.waw.pl Precedence: bulk X-list: netdev Hi, Looking at my kernel tree I noticed this patch has not been applied. I'm currently unable to test it, but it was required in the past and I don't think the situation has changed. Please apply. Thanks. --- linux-2.6/drivers/net/tulip/21142.c 19 Mar 2004 15:01:15 -0000 +++ linux-2.6/drivers/net/tulip/21142.c 2 Sep 2004 12:26:31 -0000 @@ -149,11 +149,13 @@ else if (negotiated & 0x0080) dev->if_port = 3; else if (negotiated & 0x0040) dev->if_port = 4; else if (negotiated & 0x0020) dev->if_port = 0; - else { + else if ((csr12 & 2) == 0 && (tp->sym_advertise & 0x0180)) + dev->if_port = 3; + else if ((csr12 & 4) == 0 && (tp->sym_advertise & 0x0060)) + dev->if_port = 0; + else tp->nwayset = 0; - if ((csr12 & 2) == 0 && (tp->sym_advertise & 0x0180)) - dev->if_port = 3; - } + tp->full_duplex = (tulip_media_cap[dev->if_port] & MediaAlwaysFD) ? 1:0; if (tulip_debug > 1) { My original mail: From: Krzysztof Halasa Subject: [PATCH] 21143 Tulip problems with 10BaseT To: Jeff Garzik Cc: Date: Fri, 28 May 2004 14:21:57 +0200 Current 2.4 and 2.6 kernels have problems with Tulip 21143 on 10BaseT link (with not-NWay-capable 10 Mbps peer) - tulip_debug shows: Linux Tulip driver version 1.1.13 (May 11, 2002) tulip0: EEPROM default media type Autosense. tulip0: Index #0 - Media 10baseT (#0) described by a 21142 Serial PHY (2) block. tulip0: Index #1 - Media 10baseT-FDX (#4) described by a 21142 Serial PHY (2) block. tulip0: Index #2 - Media 100baseTx (#3) described by a 21143 SYM PHY (4) block. tulip0: Index #3 - Media 100baseTx-FDX (#5) described by a 21143 SYM PHY (4) block. eth2: Digital DS21143 Tulip rev 48 at 0xe400, 00:C0:CA:13:48:10, IRQ 9. eth2: Restarting 21143 autonegotiation, csr14=0003ffff. eth2: tulip_up(), irq==9. eth2: Restarting 21143 autonegotiation, csr14=0003ffff. eth2: Done tulip_up(), CSR0 ffa08000, CSR5 f0760000 CSR6 b2422202. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: interrupt csr5=0xf0668010 new csr5=0xf0660000. eth2: 21143 link status interrupt 000050ca, CSR5 f0668010, fffbffff. ^^^^^^^^ = got NLP but no FLP (no NWay) eth2: Autonegotiation failed, using 10baseT, link beat status 50ca. ... while we know the peer is using NLP and therefore is 10BaseT-HD capable. eth2: 21143 non-MII 10baseT transceiver control 08af/00a5. eth2: Setting CSR15 to 08af0008/00a50008. eth2: Using media type 10baseT, CSR12 is c6. eth2: Setting CSR6 82420000/b2422002 CSR12 000010c6. eth2: exiting interrupt, csr5=0xf0660000. eth2: 21143 negotiation status 000010c6, 10baseT. eth2: 21143 negotiation failed, status 000010c6. eth2: Testing new 21143 media 100baseTx. eth2: interrupt csr5=0xf0008102 new csr5=0xf0000000. eth2: The transmitter stopped. CSR5 is f0008102, CSR6 b2420000, new CSR6 83860000. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: 21143 negotiation status 000000c6, 100baseTx. eth2: No 21143 100baseTx link beat, 000000c6, trying NWay. eth2: Restarting 21143 autonegotiation, csr14=0003ffff. eth2: interrupt csr5=0xf0008102 new csr5=0xf0000000. eth2: The transmitter stopped. CSR5 is f0008102, CSR6 b2420200, new CSR6 82420200. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: interrupt csr5=0xf0668010 new csr5=0xf0660000. eth2: 21143 link status interrupt 000050ca, CSR5 f0668010, fffbffff. eth2: Autonegotiation failed, using 10baseT, link beat status 50ca. After the attached patch is applied: eth2: Restarting 21143 autonegotiation, csr14=0003ffff. eth2: tulip_up(), irq==9. eth2: Restarting 21143 autonegotiation, csr14=0003ffff. eth2: Done tulip_up(), CSR0 ffa08000, CSR5 f0360000 CSR6 b2422202. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: interrupt csr5=0xf0670004 new csr5=0xf0660000. eth2: exiting interrupt, csr5=0xf0660000. eth2: interrupt csr5=0xf0668010 new csr5=0xf0660000. eth2: 21143 link status interrupt 000050ca, CSR5 f0668010, fffbffff. ^^^^^^^^ The same here - 0x50CA = got NLP, negotiation ok (seems like NLP only sets this bit as well), no 100 Mbps link status (whatever that means). eth2: Switching to 10baseT based on link negotiation 01e0 & 0000 = 0000. Correct, we haven't received FLP so no "capability bits" are present. eth2: 21143 non-MII 10baseT transceiver control 08af/00a5. eth2: Setting CSR15 to 08af0008/00a50008. eth2: Using media type 10baseT, CSR12 is c6. eth2: Setting CSR6 82420000/b2422002 CSR12 000010c6. eth2: exiting interrupt, csr5=0xf0660000. eth2: 21143 negotiation status 000010c6, 10baseT. ^^^^ Not sure about it (no 10 nor 100 Mbps link pulse?). But the chip does it this way. Possibly the bit should be cleared before read? eth2: Using NWay-set 10baseT media, csr12 000010c6. eth2: interrupt csr5=0xf0668010 new csr5=0xf0660000. eth2: 21143 link status interrupt 000050ca, CSR5 f0668010, fff8ffff. eth2: 21143 10baseT link beat good. eth2: exiting interrupt, csr5=0xf0660000. eth2: 21143 negotiation status 000050ca, 10baseT. eth2: Using NWay-set 10baseT media, csr12 000050ca. eth2: 21143 negotiation status 000050ca, 10baseT. eth2: Using NWay-set 10baseT media, csr12 000050ca. The chip on this card (Micronet SP2500K - Taiwan I think) is DEC 21143-PC: 00:08.0 Class 0200: 1011:0019 (rev 30) Subsystem: 1113:1207 Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- Status: Cap- 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- SERR- ; Thu, 2 Sep 2004 08:28:21 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 3C4615C065; Thu, 2 Sep 2004 17:28:08 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 06176-05; Thu, 2 Sep 2004 17:28:07 +0200 (CEST) Received: from sputnik (M802P011.adsl.highway.telekom.at [62.47.132.43]) by baikonur.stro.at (Postfix) with ESMTP id C08005C008; Thu, 2 Sep 2004 17:28:07 +0200 (CEST) Received: from max by sputnik with local (Exim 4.34) id 1C2tVQ-00016b-71; Thu, 02 Sep 2004 17:28:08 +0200 Date: Thu, 2 Sep 2004 17:28:08 +0200 From: maximilian attems To: Margit Schubert-While Cc: netdev@oss.sgi.com Subject: Re: [patch 01/16] __FUNCTION__ string concatenation Message-ID: <20040902152807.GA1894@stro.at> Mail-Followup-To: Margit Schubert-While , netdev@oss.sgi.com References: <200409021302.22823.margitsw@t-online.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200409021302.22823.margitsw@t-online.de> User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8350 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev On Thu, 02 Sep 2004, Margit Schubert-While wrote: > On Thu, 02 Sep 2004, Maximilian scribeth: > > I don't have the hardware to do a run-time check. > > It should not pose any problems though. > > Oh, I think we can safely say that, especially as TRACE > is nowhere referenced ;-) > (And therefore the patch is unnecessary) yup nice hint it was used: drivers/net/wireless/prism54/islpci_hotplug.c: /* TRACE(DRV_NAME); */ will resent patch that removes both. -- maks From andre.correa@pobox.com Thu Sep 2 08:40:39 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 08:40:46 -0700 (PDT) Received: from sasl.smtp.pobox.com (puzzle.sasl.smtp.pobox.com [207.8.226.4]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82FedSp023470 for ; Thu, 2 Sep 2004 08:40:39 -0700 Received: from localhost.localdomain (localhost [127.0.0.1]) by puzzle.pobox.com (Postfix) with ESMTP id 9373F138F05; Thu, 2 Sep 2004 11:38:24 -0400 (EDT) Received: from pobox.com (unknown [200.150.240.34]) by puzzle.pobox.com (Postfix) with ESMTP id D8FDE138EF7; Thu, 2 Sep 2004 11:38:21 -0400 (EDT) Message-ID: <41373ED5.5070606@pobox.com> Date: Thu, 02 Sep 2004 12:40:05 -0300 From: Andre Correa User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: netdev@oss.sgi.com, andre.correa@pobox.com Subject: Bad: scheduling while atomic! in 2.6.8.1 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8351 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: andre.correa@pobox.com Precedence: bulk X-list: netdev Hi, I set up a Linux box as a firewall with 4 NICs (3C905) on a Dell with 2.6.8.1 and iptables 1.2.11. 3 NICs have several IP addresses and the 4th has 4 VLANs associated. This box is plugged on Cisco switches. Everything was fine, firewalling OK, until I plugged the 4th NIC. When traffic start to flow the box logs a _LOT_ of errors on syslog: Sep 1 03:58:48 fw01 kernel: bad: scheduling while atomic! Sep 1 03:58:48 fw01 kernel: [] schedule+0x3c/0x428 Sep 1 03:58:48 fw01 kernel: [] sys_socketcall+0x150/0x1f4 Sep 1 03:58:48 fw01 kernel: [] work_resched+0x5/0x16 Sep 1 03:58:48 fw01 kernel: bad: scheduling while atomic! Sep 1 03:58:48 fw01 kernel: [] schedule+0x3c/0x428 Sep 1 03:58:48 fw01 kernel: [] __kfree_skb+0xd3/0xd8 Sep 1 03:58:48 fw01 kernel: [] schedule_timeout+0x14/0xb0 Sep 1 03:58:48 fw01 kernel: [] unix_wait_for_peer+0xac/0xc8 Sep 1 03:58:48 fw01 kernel: [] autoremove_wake_function+0x0/0x40 Sep 1 03:58:48 fw01 kernel: [] autoremove_wake_function+0x0/0x40 Sep 1 03:58:48 fw01 kernel: [] unix_dgram_sendmsg+0x39b/0x4b0 Sep 1 03:58:48 fw01 kernel: [] sock_aio_write+0x101/0x10c Sep 1 03:58:48 fw01 kernel: [] do_sync_write+0x7a/0xac Sep 1 03:58:48 fw01 kernel: [] kfree_skbmem+0x17/0x1c Sep 1 03:58:48 fw01 kernel: [] __kfree_skb+0xd3/0xd8 Sep 1 03:58:48 fw01 kernel: [] vfs_write+0xb5/0xd4 Sep 1 03:58:48 fw01 kernel: [] sys_write+0x40/0x6c Sep 1 03:58:48 fw01 kernel: [] syscall_call+0x7/0xb Sep 1 03:58:48 fw01 kernel: bad: scheduling while atomic! Sep 1 03:58:48 fw01 kernel: [] schedule+0x3c/0x428 Sep 1 03:58:49 fw01 kernel: [] sys_socketcall+0x150/0x1f4 Sep 1 03:58:49 fw01 kernel: [] work_resched+0x5/0x16 Sep 1 03:58:49 fw01 kernel: bad: scheduling while atomic! Sep 1 03:58:49 fw01 kernel: [] schedule+0x3c/0x428 Sep 1 03:58:49 fw01 kernel: [] __kfree_skb+0xd3/0xd8 Sep 1 03:58:49 fw01 kernel: [] schedule_timeout+0x14/0xb0 Sep 1 03:58:49 fw01 kernel: [] unix_wait_for_peer+0xac/0xc8 Sep 1 03:58:49 fw01 kernel: [] autoremove_wake_function+0x0/0x40 Sep 1 03:58:49 fw01 kernel: [] autoremove_wake_function+0x0/0x40 Sep 1 03:58:49 fw01 kernel: [] unix_dgram_sendmsg+0x39b/0x4b0 Sep 1 03:58:49 fw01 kernel: [] sock_aio_write+0x101/0x10c Sep 1 03:58:49 fw01 kernel: [] do_sync_write+0x7a/0xac Sep 1 03:58:49 fw01 kernel: [] kfree_skbmem+0x17/0x1c Sep 1 03:58:49 fw01 kernel: [] __kfree_skb+0xd3/0xd8 Sep 1 03:58:49 fw01 kernel: [] vfs_write+0xb5/0xd4 Sep 1 03:58:49 fw01 kernel: [] sys_write+0x40/0x6c Sep 1 03:58:49 fw01 kernel: [] syscall_call+0x7/0xb I got more then 110Mb of it in ~2 hours of tests. Shutting down interface doesn't stop it, just a reboot takes the machine back to its normal state, if cable is unplugged. I've tested NIC, cable, PCI slot, switch port, switch and even changed the box itself, but nothing helped. When I take VLAN down, on Cisco switch, no errors are logged. If I go back to 2.6.7 + VLAN, no errors too, all OK. It seens to be related to VLAN on 2.6.8.1 only. Searching kernel source I found that it comes from kernel/sched.c, but it doesn't tells me much. /* * Test if we are atomic. Since do_exit() needs to call into * schedule() atomically, we ignore that path for now. * Otherwise, whine if we are scheduling when we should not be. */ if (likely(!(current->state & (TASK_DEAD | TASK_ZOMBIE)))) { if (unlikely(in_atomic())) { printk(KERN_ERR "bad: scheduling while atomic!\n"); dump_stack(); } } Does anybody can help on it?! Does it look like a bug or what? Any help is appreciated. tks Andre From vatsa@in.ibm.com Thu Sep 2 08:46:38 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 08:46:45 -0700 (PDT) Received: from e6.ny.us.ibm.com (e6.ny.us.ibm.com [32.97.182.106]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82FkcoB023856 for ; Thu, 2 Sep 2004 08:46:38 -0700 Received: from northrelay02.pok.ibm.com (northrelay02.pok.ibm.com [9.56.224.150]) by e6.ny.us.ibm.com (8.12.10/8.12.9) with ESMTP id i82FkNnt734040; Thu, 2 Sep 2004 11:46:23 -0400 Received: from snowy.in.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by northrelay02.pok.ibm.com (8.12.10/NCO/VER6.6) with SMTP id i82FlQND083086; Thu, 2 Sep 2004 11:47:30 -0400 Received: by snowy.in.ibm.com (Postfix, from userid 502) id 7AA9B24E33; Thu, 2 Sep 2004 21:18:37 +0530 (IST) Date: Thu, 2 Sep 2004 21:18:37 +0530 From: Srivatsa Vaddagiri To: davem@redhat.com Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org, dipankar@in.ibm.com, paulmck@us.ibm.com Subject: Fw: Re: [RFC] Use RCU for tcp_ehash lookup Message-ID: <20040902154837.GA5435@in.ibm.com> Reply-To: vatsa@in.ibm.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-archive-position: 8352 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vatsa@in.ibm.com Precedence: bulk X-list: netdev Resending. Looks like my earlier mail didn't make it. ----- Forwarded message from Srivatsa Vaddagiri ----- Date: Thu, 2 Sep 2004 19:34:44 +0530 From: Srivatsa Vaddagiri To: "David S. Miller" Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org, dipankar@in.ibm.com, paulmck@us.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Reply-To: vatsa@in.ibm.com On Wed, Sep 01, 2004 at 10:41:08PM -0700, David S. Miller wrote: > The reason you don't see any improvement is that the ehash table is > pretty write heavy. In my simple one-file-transfer-test-at-a-time, it should have been read-mostly. Probably the fact lookups are not serialized wrt input pakcet processing may have shadowed the benefits of lock-free lookup. However perhaps if I have multiple file transfer sessions in progress (one per cpu maybe), then the benefit of reduced time spent in looking up a socket, could be passed on to threads doing network input. > I'm not totally against your patch, I just don't think that the TCP established > hash table qualifies as "read heavy" as per what RCU is truly effective for. IMHO the benefits of lock-free will be seen only in such scenarios, i.e where read_lock ended up having to spin-wait on a update to finish. In the lock-free case, there is no such wait. > That's exactly what I was concerned about when I saw that you had attempted > this change. It is incredibly important for state changes and updates to > be seen as atomic by the packet input processing engine. It would be illegal > for a cpu running TCP input to see a socket in two tables at the same time > (for example, in the main established area and in the second half for TIME_WAIT > buckets). > > If the visibility of the socket is wrong, sockets could be erroneously > be reset during the transition from established to TIME_WAIT state. > Beware! This is precisely the reason why I changed the order of movement in __tcp_tw_hashdance. Earlier, it was removing the socket from the established half and _then_ adding it to time-wait half. This would have lead to a window where the socket is neither in established-half not in the time-wait half. A packet arriving in this window (& doing lock-free lookup) would have been dropped. Hence I reversed the order of movement to add in time-wait first before removing from established half. > > Note that __tcp_v4_lookup_established should not be affected by the above > > movement because I found it scans the established half first and _then_ the > > time wait half. So even if the same socket is present in both established half > > and time wait half, __tcp_v4_lookup_established will lookup only one of them > > (& not both). > > I hope this is true. AFAICS it is true! If __tcp_v4_lookup_established finds it in the established half, it does no further lookup in the time-wait half. -- Thanks and Regards, Srivatsa Vaddagiri, Linux Technology Center, IBM Software Labs, Bangalore, INDIA - 560017 ----- End forwarded message ----- -- Thanks and Regards, Srivatsa Vaddagiri, Linux Technology Center, IBM Software Labs, Bangalore, INDIA - 560017 From nacc@us.ibm.com Thu Sep 2 09:10:19 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 09:10:24 -0700 (PDT) Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.133]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82GAD75024762 for ; Thu, 2 Sep 2004 09:10:19 -0700 Received: from westrelay04.boulder.ibm.com (westrelay04.boulder.ibm.com [9.17.193.32]) by e35.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id i82G9p06025910; Thu, 2 Sep 2004 12:09:51 -0400 Received: from arkanoid.beaverton.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by westrelay04.boulder.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i82G9oZC037834; Thu, 2 Sep 2004 10:09:50 -0600 Received: from arkanoid.beaverton.ibm.com (arkanoid [127.0.0.1]) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) with ESMTP id i82G9n0t002058; Thu, 2 Sep 2004 16:09:49 GMT Received: (from aravamud@localhost) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) id i82G9nU6002055; Thu, 2 Sep 2004 16:09:49 GMT X-Authentication-Warning: arkanoid.beaverton.ibm.com: aravamud set sender to nacc@us.ibm.com using -f Date: Thu, 2 Sep 2004 16:09:49 +0000 From: Nishanth Aravamudan To: Margit Schubert-While , netdev@oss.sgi.com, kj Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Message-ID: <20040902160948.GA1944@us.ibm.com> References: <200409020850.38177.margitsw@t-online.de> <20040902082432.GA1876@stro.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040902082432.GA1876@stro.at> X-Operating-System: Linux 2.6.73 (i686) User-Agent: Mutt/1.5.6+20040803i X-archive-position: 8353 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nacc@us.ibm.com Precedence: bulk X-list: netdev On Thu, Sep 02, 2004 at 10:24:33AM +0200, maximilian attems wrote: > On Thu, 02 Sep 2004, Margit Schubert-While wrote: > > > I agree with Jean and add the following : > > You are assuming HZ = 1000. > > In 2.4, HZ = 100 (And in 2.6, HZ is not necessarily = 1000). As the original author of the patches, I feel I should interject . . . Why/Where do you see an assumption about the value of HZ? The conversion of the parameter to schedule_timeout() from jiffies to msecs is the only place I can see where that might appear to be the case. But, upon closer examination, there is no such assumption: 1000 = the number of milliseconds in a second. HZ = the number of jiffies in a second (regardless of architecture) In the original code for prism54/islpci_dev.c: set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(50*HZ/1000); Thus, to convert (50*HZ/1000) from jiffies to msecs, multiply by 1000 and divide by HZ, or: 50*HZ/1000 jiffies * 1000/HZ msecs/jiffie = 50 msecs. And thus, in the patched code, the above becomes: msleep(50); Does that clear things up? -Nish From nacc@us.ibm.com Thu Sep 2 09:23:31 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 09:23:37 -0700 (PDT) Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.129]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82GNOG1025237 for ; Thu, 2 Sep 2004 09:23:31 -0700 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e31.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id i82GN3gM506480; Thu, 2 Sep 2004 12:23:04 -0400 Received: from arkanoid.beaverton.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by westrelay02.boulder.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i82GN2l9402682; Thu, 2 Sep 2004 10:23:03 -0600 Received: from arkanoid.beaverton.ibm.com (arkanoid [127.0.0.1]) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) with ESMTP id i82GN2Ww002105; Thu, 2 Sep 2004 16:23:02 GMT Received: (from aravamud@localhost) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) id i82GN1Bd002102; Thu, 2 Sep 2004 16:23:01 GMT X-Authentication-Warning: arkanoid.beaverton.ibm.com: aravamud set sender to nacc@us.ibm.com using -f Date: Thu, 2 Sep 2004 16:23:01 +0000 From: Nishanth Aravamudan To: Margit Schubert-While , netdev@oss.sgi.com, kj Subject: Re: [Kernel-janitors] Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Message-ID: <20040902162301.GB1944@us.ibm.com> References: <200409021135.57632.margitsw@t-online.de> <20040902100322.GD1876@stro.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040902100322.GD1876@stro.at> X-Operating-System: Linux 2.6.73 (i686) User-Agent: Mutt/1.5.6+20040803i X-archive-position: 8354 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nacc@us.ibm.com Precedence: bulk X-list: netdev On Thu, Sep 02, 2004 at 12:03:22PM +0200, maximilian attems wrote: > On Thu, 02 Sep 2004, Margit Schubert-While wrote: > > > On Thu, 02 Sep 2004, Maximilian scribeth: > > > it shouldn't hinder 2.6 in it's progression. > > I consider this a regression. > > As schedule_timeout is used elesewhere in the prism54 code, > > we are using a consistent and documented method. A grep of drivers/net/wireless/prism54 for schedule_timeout showed three occurrences (in 2.6.9-rc1-bk7): islpci_dev.c: schedule_timeout(50*HZ/1000); islpci_dev.c: remaining = schedule_timeout(HZ); islpci_mgt.c: timeleft = schedule_timeout(wait_cycle_jiffies); The first is removed by my patch. The second & third are potentially bugs as there is no set_current_state() preceding the call to schedule_timeout(). As per the source: /** * schedule_timeout - sleep until timeout * @timeout: timeout value in jiffies * * Make the current task sleep until @timeout jiffies have * elapsed. The routine will return immediately unless * the current task state has been set (see set_current_state()). Therefore, in the current code, the schedule_timeout() call does not have the desired effect (the same information is available in kernel-hacking.ps). Both of these calls should probably be fixed, but I'm not sure if you wish to sleep in TASK_INTERUPTIBLE or TASK_UNINTERRUPTIBLE. Keep in mind that msleep_interruptible() is also (hopefully) being pushed to the kernel soon. As to consistency or documentation . . . I have no evidence to suggest that msleep() is inconsistent. And I don't think there is any need for more documentation than the source in this case: /** * msleep - sleep safely even with waitqueue interruptions * @msecs: Time in milliseconds to sleep for */ Hope this helps clear things up. -Nish From paulmck@us.ibm.com Thu Sep 2 09:36:07 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 09:36:13 -0700 (PDT) Received: from linux.local (bi01p1.co.us.ibm.com [32.97.110.142]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82Ga0j7025740 for ; Thu, 2 Sep 2004 09:36:06 -0700 Received: by linux.local (Postfix on SuSE Linux 7.3 (i386), from userid 500) id 4A40E148B98; Thu, 2 Sep 2004 09:31:50 -0700 (PDT) Date: Thu, 2 Sep 2004 09:31:50 -0700 From: "Paul E. McKenney" To: "David S. Miller" Cc: vatsa@in.ibm.com, netdev@oss.sgi.com, linux-kernel@vger.kernel.org, dipankar@in.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Message-ID: <20040902163149.GB1258@us.ibm.com> Reply-To: paulmck@us.ibm.com References: <20040831125941.GA5534@in.ibm.com> <20040901224108.3b2d692d.davem@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901224108.3b2d692d.davem@redhat.com> User-Agent: Mutt/1.4.1i X-archive-position: 8355 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: paulmck@us.ibm.com Precedence: bulk X-list: netdev On Wed, Sep 01, 2004 at 10:41:08PM -0700, David S. Miller wrote: > On Tue, 31 Aug 2004 18:29:41 +0530 > Srivatsa Vaddagiri wrote: > > - Biggest problem I had converting over to RCU was the refcount race between > > sock_put and sock_hold. sock_put might see the refcount go to zero and decide > > to free the object, while on some other CPU, sock_get's are pending against > > the same object. The patch handles the race by deciding to free the object > > only from the RCU callback. > > That's exactly what I was concerned about when I saw that you had attempted > this change. It is incredibly important for state changes and updates to > be seen as atomic by the packet input processing engine. It would be illegal > for a cpu running TCP input to see a socket in two tables at the same time > (for example, in the main established area and in the second half for TIME_WAIT > buckets). > > If the visibility of the socket is wrong, sockets could be erroneously > be reset during the transition from established to TIME_WAIT state. > Beware! If the usages is too write-intensive, then RCU will certainly be less likely to work well. But there is nothing quite like actually trying it to see how it works. ;-) That aside, it -is- possible to make such state changes appear atomic, even when moving elements from one list to another. One way of doing this is to atomically replace the element with a "tombstone" element. Normal pointer writes suffice. The "tombstone" is set up so that searches for the outgoing element will stall (e.g., spin or sleep, depending on the environment). The element is moved to its destination list. At this point, searches for the element in the old list will still stall, while searches for the element in the new list will succeed. The tombstone is now marked so that CPUs stall on it now resume, but indicating failure to find the element in the old list. Of course, this approach makes writes more expensive than they otherwise would be, so, again, RCU is best for read-intensive uses. ;-) The fact that this data structure is not very read-intensive is due to the fact that short-lived TCP connections are quite common, right? Or am I missing the finer points of this data structure's workings? Thanx, Paul From margitsw@t-online.de Thu Sep 2 10:42:10 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 10:42:14 -0700 (PDT) Received: from mailout06.sul.t-online.com (mailout06.sul.t-online.com [194.25.134.19]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82Hg9YQ027077 for ; Thu, 2 Sep 2004 10:42:09 -0700 Received: from fwd03.aul.t-online.de by mailout06.sul.t-online.com with smtp id 1C2vay-0002NZ-00; Thu, 02 Sep 2004 19:42:00 +0200 Received: from roglap.local (rShJCvZ1oekYZs039dSpPc+qIpI7GJcpa8ZytgJ7WvedNZzrj1mEZV@[217.255.125.194]) by fwd03.sul.t-online.com with esmtp id 1C2var-0j45wm0; Thu, 2 Sep 2004 19:41:53 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: netdev@oss.sgi.com Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Date: Thu, 2 Sep 2004 19:30:18 +0200 User-Agent: KMail/1.5.4 Cc: janitor@sternwelten.at MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409021930.18414.margitsw@t-online.de> X-ID: rShJCvZ1oekYZs039dSpPc+qIpI7GJcpa8ZytgJ7WvedNZzrj1mEZV X-TOI-MSGID: e1e2d3ca-1c83-40a9-a21f-7e2330d4634a X-archive-position: 8356 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev On Thu, 02 Sep 2004, Nishanth scribeth: > A grep of drivers/net/wireless/prism54 for schedule_timeout showed three > occurrences (in 2.6.9-rc1-bk7): > islpci_dev.c: schedule_timeout(50*HZ/1000); > islpci_dev.c: remaining = schedule_timeout(HZ); > islpci_mgt.c: timeleft = schedule_timeout(wait_cycle_jiffies); > The first is removed by my patch. > The second & third are potentially bugs as there is no > set_current_state() preceding the call to schedule_timeout(). As per the > source: Nope, look a few lines above: DEFINE_WAIT() and prepare_to_wait(). Margit From margitsw@t-online.de Thu Sep 2 11:04:11 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 11:04:21 -0700 (PDT) Received: from mailout11.sul.t-online.com (mailout11.sul.t-online.com [194.25.134.85]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82I4ANW027860 for ; Thu, 2 Sep 2004 11:04:11 -0700 Received: from fwd03.aul.t-online.de by mailout11.sul.t-online.com with smtp id 1C2vwF-0006Qv-02; Thu, 02 Sep 2004 20:03:59 +0200 Received: from roglap.local (VgPdmiZvoeP7taiB8A7bbXy2sknkngKrtbSxwLtFFwgu92JIs-MOkm@[217.255.125.194]) by fwd03.sul.t-online.com with esmtp id 1C2vwE-024Pq40; Thu, 2 Sep 2004 20:03:58 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: netdev@oss.sgi.com Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Date: Thu, 2 Sep 2004 19:52:18 +0200 User-Agent: KMail/1.5.4 Cc: janitor@sternwelten.at, nacc@us.ibm.com MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409021952.18280.margitsw@t-online.de> X-ID: VgPdmiZvoeP7taiB8A7bbXy2sknkngKrtbSxwLtFFwgu92JIs-MOkm X-TOI-MSGID: 9117e798-6f49-4eaf-b79c-44d2921846f0 X-archive-position: 8357 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev On Thu, 02 Sep 2004, Nishanth scribeth: > Keep in mind that msleep_interruptible() is also > (hopefully) being pushed to the kernel soon I think you need this for your current patch set ;-) eg. In e100, where you replace an interruptible timeout: > @@ -2020,8 +2016,7 @@ I don't think that's correct. Margit From nacc@us.ibm.com Thu Sep 2 11:27:43 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 11:27:49 -0700 (PDT) Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.131]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82IRbEr028661 for ; Thu, 2 Sep 2004 11:27:43 -0700 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e33.co.us.ibm.com (8.12.10/8.12.9) with ESMTP id i82IRMDD385518; Thu, 2 Sep 2004 14:27:22 -0400 Received: from arkanoid.beaverton.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by westrelay02.boulder.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i82IRLl9300046; Thu, 2 Sep 2004 12:27:21 -0600 Received: from arkanoid.beaverton.ibm.com (arkanoid [127.0.0.1]) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) with ESMTP id i82IRKjg002786; Thu, 2 Sep 2004 18:27:20 GMT Received: (from aravamud@localhost) by arkanoid.beaverton.ibm.com (8.13.1/8.13.1/Debian-6) id i82IRJaf002783; Thu, 2 Sep 2004 18:27:19 GMT X-Authentication-Warning: arkanoid.beaverton.ibm.com: aravamud set sender to nacc@us.ibm.com using -f Date: Thu, 2 Sep 2004 18:27:19 +0000 From: Nishanth Aravamudan To: Margit Schubert-While Cc: netdev@oss.sgi.com, janitor@sternwelten.at Subject: Re: [patch 8/8] prism54/islpci_dev: replace schedule_timeout() with msleep() Message-ID: <20040902182719.GD1944@us.ibm.com> References: <200409021952.18280.margitsw@t-online.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200409021952.18280.margitsw@t-online.de> X-Operating-System: Linux 2.6.73 (i686) User-Agent: Mutt/1.5.6+20040803i X-archive-position: 8358 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nacc@us.ibm.com Precedence: bulk X-list: netdev On Thu, Sep 02, 2004 at 07:52:18PM +0200, Margit Schubert-While wrote: > On Thu, 02 Sep 2004, Nishanth scribeth: > > Keep in mind that msleep_interruptible() is also > > (hopefully) being pushed to the kernel soon > > I think you need this for your current patch set ;-) > eg. In e100, where you replace an interruptible timeout: > > @@ -2020,8 +2016,7 @@ > > I don't think that's correct. The reasoning for me behind changing some of the TASK_INTERRUPTIBLE'd schedule_timeout()s to msleep()s was that LDD somewhat incorrectly advised device driver authors to use an INTERRUPTIBLE timeout for longer delays, when, in fact, they should probably use an UNINTERRUPTIBLE one. Only if signals are explicitly expected to occur is INTERRUPTIBLE necessary (in general). [By long delays, I mean those measurable in msecs] I am not an expert on the E100, so perhaps this was an error on my part. But this is also why I have a header on my patch submission regarding exactly this issue. If someone could verify (none of the maintainers I sent the original patch to did not reply with any problems for this patch) that there is or is not an issue, I'd appreciate it. -Nish From kaber@trash.net Thu Sep 2 11:36:52 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 11:36:58 -0700 (PDT) Received: from gw.localnet ([62.206.217.67]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82IapdD029088 for ; Thu, 2 Sep 2004 11:36:52 -0700 Received: from [172.16.1.123] (helo=trash.net ident=kaber) by gw.localnet with esmtp (Exim 3.36 #1 (Debian)) id 1C2wWi-0004h7-00; Thu, 02 Sep 2004 20:41:40 +0200 Message-ID: <4137681D.3000902@trash.net> Date: Thu, 02 Sep 2004 20:36:13 +0200 From: Patrick McHardy User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5 X-Accept-Language: en MIME-Version: 1.0 To: "David S. Miller" CC: yoshfuji@linux-ipv6.org, Herbert Xu , netdev@oss.sgi.com Subject: [PATCH 2.6]: Fix suboptimal fragment sizing for last fragment Content-Type: multipart/mixed; boundary="------------050003050700070306040006" X-archive-position: 8359 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: kaber@trash.net Precedence: bulk X-list: netdev This is a multi-part message in MIME format. --------------050003050700070306040006 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Yoshifuji's recent fragment patch prevents unnecessary fragmentation when the data can be kept in a single packet, but only for the first packet. When fragmenting, all fragments are still truncated to multiples of 8 and we might end up creating an unnecessary fragment. This dump shows the problem (MTU 1499): 172.16.1.123.32771 > 172.16.195.3.4135: udp 2937 (frag 7066:1472@0+) 172.16.1.123 > 172.16.195.3: udp (frag 7066:1472@1472+) 172.16.1.123 > 172.16.195.3: udp (frag 7066:1@2944) This patch always builds mtu sized fragments and truncates the previous fragment to a multiple of 8 bytes when allocating a new one. With the patch the dump looks like this: 172.16.1.123.32772 > 172.16.195.3.4135: udp 2937 (frag 49641:1472@0+) 172.16.1.123 > 172.16.195.3: udp (frag 49641:1473@1472) Regards Patrick --------------050003050700070306040006 Content-Type: text/x-patch; name="frag.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="frag.diff" # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/09/02 17:35:32+02:00 kaber@coreworks.de # [IPV4/IPV6]: Fix suboptimal fragment sizing for last fragment # # Signed-off-by: Patrick McHardy # # net/ipv6/ip6_output.c # 2004/09/02 17:35:14+02:00 kaber@coreworks.de +13 -22 # [IPV4/IPV6]: Fix suboptimal fragment sizing for last fragment # # net/ipv4/ip_output.c # 2004/09/02 17:35:14+02:00 kaber@coreworks.de +20 -49 # [IPV4/IPV6]: Fix suboptimal fragment sizing for last fragment # diff -Nru a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c --- a/net/ipv4/ip_output.c 2004-09-02 17:39:01 +02:00 +++ b/net/ipv4/ip_output.c 2004-09-02 17:39:01 +02:00 @@ -735,10 +735,10 @@ int hh_len; int exthdrlen; int mtu; - int copy = 0; + int copy; int err; int offset = 0; - unsigned int maxfraglen, fragheaderlen, fraggap = 0; + unsigned int maxfraglen, fragheaderlen; int csummode = CHECKSUM_NONE; if (flags&MSG_PROBE) @@ -781,6 +781,7 @@ hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); + maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; if (inet->cork.length + length > 0xFFFF - fragheaderlen) { ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, mtu-exthdrlen); @@ -788,26 +789,11 @@ } /* - * Let's try using as much space as possible to avoid generating - * additional unnecessary small fragment of length - * (mtu-fragheaderlen)%8 if mtu-fragheaderlen is not 0 modulo 8. - * -- yoshfuji - */ - if (fragheaderlen + inet->cork.length + length <= mtu) - maxfraglen = mtu; - else - maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; - - if (fragheaderlen + inet->cork.length <= mtu && - fragheaderlen + inet->cork.length + length > mtu) - fraggap = 1; - - /* * transhdrlen > 0 means that this is the first fragment and we wish * it won't be fragmented in the future. */ if (transhdrlen && - length + fragheaderlen <= maxfraglen && + length + fragheaderlen <= mtu && rt->u.dst.dev->features&(NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM) && !exthdrlen) csummode = CHECKSUM_HW; @@ -821,34 +807,33 @@ * adding appropriate IP header. */ - if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) { - fraggap = 0; + if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) goto alloc_new_skb; - } while (length > 0) { - if ((copy = maxfraglen - skb->len) <= 0) { + if ((copy = mtu - skb->len) <= 0) { char *data; unsigned int datalen; unsigned int fraglen; + unsigned int fraggap; unsigned int alloclen; struct sk_buff *skb_prev; - BUG_TRAP(fraggap || copy == 0); + BUG_TRAP(copy == 0); alloc_new_skb: skb_prev = skb; + fraggap = 0; + if (skb_prev) + fraggap = mtu - maxfraglen; - if (fraggap) - fraggap = -copy; - - datalen = maxfraglen - fragheaderlen; + datalen = mtu - fragheaderlen; if (datalen > length + fraggap) datalen = length + fraggap; fraglen = datalen + fragheaderlen; if ((flags & MSG_MORE) && !(rt->u.dst.dev->features&NETIF_F_SG)) - alloclen = maxfraglen; + alloclen = mtu; else alloclen = datalen + fragheaderlen; @@ -913,7 +898,6 @@ length -= datalen - fraggap; transhdrlen = 0; exthdrlen = 0; - fraggap = 0; csummode = CHECKSUM_NONE; /* @@ -1006,7 +990,7 @@ int mtu; int len; int err; - unsigned int maxfraglen, fragheaderlen, fraggap = 0; + unsigned int maxfraglen, fragheaderlen, fraggap; if (inet->hdrincl) return -EPERM; @@ -1028,27 +1012,13 @@ mtu = inet->cork.fragsize; fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); + maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; if (inet->cork.length + size > 0xFFFF - fragheaderlen) { ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, mtu); return -EMSGSIZE; } - /* - * Let's try using as much space as possible to avoid generating - * additional unnecessary small fragment of length - * (mtu-fragheaderlen)%8 if mtu-fragheaderlen is not 0 modulo 8. - * -- yoshfuji - */ - if (fragheaderlen + inet->cork.length + size <= mtu) - maxfraglen = mtu; - else - maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; - - if (fragheaderlen + inet->cork.length <= mtu && - fragheaderlen + inet->cork.length + size > mtu) - fraggap = 1; - if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) return -EINVAL; @@ -1056,17 +1026,18 @@ while (size > 0) { int i; - if ((len = maxfraglen - skb->len) <= 0) { + if ((len = mtu - skb->len) <= 0) { struct sk_buff *skb_prev; char *data; struct iphdr *iph; int alloclen; - BUG_TRAP(fraggap || len == 0); + BUG_TRAP(len == 0); skb_prev = skb; - if (fraggap) - fraggap = -len; + fraggap = 0; + if (skb_prev) + fraggap = mtu - maxfraglen; alloclen = fragheaderlen + hh_len + fraggap + 15; skb = sock_wmalloc(sk, alloclen, 1, sk->sk_allocation); diff -Nru a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c --- a/net/ipv6/ip6_output.c 2004-09-02 17:39:01 +02:00 +++ b/net/ipv6/ip6_output.c 2004-09-02 17:39:01 +02:00 @@ -814,11 +814,11 @@ struct inet_opt *inet = inet_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk); struct sk_buff *skb; - unsigned int maxfraglen, fragheaderlen, fraggap = 0; + unsigned int maxfraglen, fragheaderlen; int exthdrlen; int hh_len; int mtu; - int copy = 0; + int copy; int err; int offset = 0; int csummode = CHECKSUM_NONE; @@ -867,6 +867,7 @@ hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); fragheaderlen = sizeof(struct ipv6hdr) + (opt ? opt->opt_nflen : 0); + maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - sizeof(struct frag_hdr); if (mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) { if (inet->cork.length + length > sizeof(struct ipv6hdr) + IPV6_MAXPLEN - fragheaderlen) { @@ -883,46 +884,37 @@ * * Note that we may need to "move" the data from the tail of * of the buffer to the new fragment when we split - * the message at the first time. + * the message. * * FIXME: It may be fragmented into multiple chunks * at once if non-fragmentable extension headers * are too large. * --yoshfuji */ - if (fragheaderlen + inet->cork.length + length <= mtu) - maxfraglen = mtu; - else - maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - - sizeof(struct frag_hdr); - - if (fragheaderlen + inet->cork.length <= mtu && - fragheaderlen + inet->cork.length + length > mtu) - fraggap = 1; inet->cork.length += length; - if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) { - fraggap = 0; + if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) goto alloc_new_skb; - } while (length > 0) { - if ((copy = maxfraglen - skb->len) <= 0) { + if ((copy = mtu - skb->len) <= 0) { char *data; unsigned int datalen; unsigned int fraglen; + unsigned int fraggap; unsigned int alloclen; struct sk_buff *skb_prev; - BUG_TRAP(fraggap || copy == 0); + BUG_TRAP(copy == 0); alloc_new_skb: skb_prev = skb; /* There's no room in the current skb */ - if (fraggap) - fraggap = -copy; + fraggap = 0; + if (skb_prev) + fraggap = mtu - maxfraglen; - datalen = maxfraglen - fragheaderlen; + datalen = mtu - fragheaderlen; if (datalen > length + fraggap) datalen = length + fraggap; @@ -930,7 +922,7 @@ fraglen = datalen + fragheaderlen; if ((flags & MSG_MORE) && !(rt->u.dst.dev->features&NETIF_F_SG)) - alloclen = maxfraglen; + alloclen = mtu; else alloclen = datalen + fragheaderlen; @@ -1005,7 +997,6 @@ length -= datalen - fraggap; transhdrlen = 0; exthdrlen = 0; - fraggap = 0; csummode = CHECKSUM_NONE; /* --------------050003050700070306040006-- From yoshfuji@linux-ipv6.org Thu Sep 2 12:47:38 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 12:47:44 -0700 (PDT) Received: from yue.st-paulia.net ([203.178.140.15]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82Jlbg2001233 for ; Thu, 2 Sep 2004 12:47:38 -0700 Received: from localhost (localhost [127.0.0.1]) by yue.st-paulia.net (Postfix) with ESMTP id 1976B33CE6; Fri, 3 Sep 2004 04:48:25 +0900 (JST) Date: Fri, 03 Sep 2004 04:48:23 +0900 (JST) Message-Id: <20040903.044823.82214059.yoshfuji@linux-ipv6.org> To: kaber@trash.net Cc: davem@redhat.com, herbert@debian.org, netdev@oss.sgi.com, yoshfuji@linux-ipv6.org Subject: Re: [PATCH 2.6]: Fix suboptimal fragment sizing for last fragment From: YOSHIFUJI Hideaki / =?iso-2022-jp?B?GyRCNUhGIzFRTEAbKEI=?= In-Reply-To: <4137681D.3000902@trash.net> References: <4137681D.3000902@trash.net> Organization: USAGI Project X-URL: http://www.yoshifuji.org/%7Ehideaki/ X-Fingerprint: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA X-PGP-Key-URL: http://www.yoshifuji.org/%7Ehideaki/hideaki@yoshifuji.org.asc X-Face: "5$Al-.M>NJ%a'@hhZdQm:."qn~PA^gq4o*>iCFToq*bAi#4FRtx}enhuQKz7fNqQz\BYU] $~O_5m-9'}MIs`XGwIEscw;e5b>n"B_?j/AkL~i/MEaZBLP X-Mailer: Mew version 2.2 on Emacs 20.7 / Mule 4.1 (AOI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-archive-position: 8360 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: yoshfuji@linux-ipv6.org Precedence: bulk X-list: netdev In article <4137681D.3000902@trash.net> (at Thu, 02 Sep 2004 20:36:13 +0200), Patrick McHardy says: > Yoshifuji's recent fragment patch prevents unnecessary fragmentation > when the data can be kept in a single packet, but only for the first > packet. When fragmenting, all fragments are still truncated to > multiples of 8 and we might end up creating an unnecessary fragment. > > This dump shows the problem (MTU 1499): > > 172.16.1.123.32771 > 172.16.195.3.4135: udp 2937 (frag 7066:1472@0+) > 172.16.1.123 > 172.16.195.3: udp (frag 7066:1472@1472+) > 172.16.1.123 > 172.16.195.3: udp (frag 7066:1@2944) > > This patch always builds mtu sized fragments and truncates the previous > fragment to a multiple of 8 bytes when allocating a new one. With the > patch the dump looks like this: > > > 172.16.1.123.32772 > 172.16.195.3.4135: udp 2937 (frag 49641:1472@0+) > 172.16.1.123 > 172.16.195.3: udp (frag 49641:1473@1472) Let me clarify. Are you sending payload of 2945 bytes (= udp payload of 2937 bytes)? Good point. I'll check this patch today. (Let me sleep for now...) Anyway, please update the comment instead of removing completely. Thanks. --yoshfuji From vkondra@mail.ru Thu Sep 2 13:25:51 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 13:26:37 -0700 (PDT) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82KPolW003606 for ; Thu, 2 Sep 2004 13:25:51 -0700 Received: from [212.179.200.204] (port=14794 helo=[192.168.10.2]) by mx1.mail.ru with esmtp id 1C2y91-00093I-00; Fri, 03 Sep 2004 00:25:21 +0400 From: Vladimir Kondratiev To: netdev@oss.sgi.com Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Thu, 2 Sep 2004 23:24:35 +0300 User-Agent: KMail/1.7 Cc: Jeff Garzik , Denis Vlasenko , Jean Tourrilhes , Jouni Malinen , acx100-devel@lists.sourceforge.net, prism54-devel@prism54.org References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <4134C1A7.50600@pobox.com> In-Reply-To: <4134C1A7.50600@pobox.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3883509.4mOIAh7QTs"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200409022324.43117.vkondra@mail.ru> X-Spam: Probable Spam X-archive-position: 8361 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vkondra@mail.ru Precedence: bulk X-list: netdev --nextPart3883509.4mOIAh7QTs Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Jeff, On Tuesday 31 August 2004 21:21, Jeff Garzik wrote: JG> Denis Vlasenko wrote: JG> > I think 'senior' network guys are in position to decide upon which JG> > of currently available 802.11 stacks we should continue to work. JG> > (Atheros has one, said to be derived from BSD, is there any others?) JG> JG> JG> Already have. Start with the code in wireless-2.6 -- HostAP -- and use JG> DaveM's 802.11 stack template as a model for actually integrating 802.11 JG> very tightly with the rest of the net stack. JG> JG> http://www.kernel.org/pub/linux/kernel/people/jgarzik/patchkits/2.6/davem-= p8 0211.tar.bz2=20 Is this stack the main one that is going to be used? I.e. if I am working o= n=20 driver for next generation .11 card - should I try to use it, request/submi= tt=20 missing features etc.? Or should I use wireless extensions? --nextPart3883509.4mOIAh7QTs Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBBN4GKqxdj7mhC6o0RAsfgAJ9Nz7PdFdRc+2ywEfCEYcS+qutHsQCcCOKM JlRXzBD/qeiPNnWtwViO/VQ= =HvC8 -----END PGP SIGNATURE----- --nextPart3883509.4mOIAh7QTs-- From jgarzik@pobox.com Thu Sep 2 13:34:18 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 13:35:04 -0700 (PDT) Received: from www.linux.org.uk (IDENT:93@parcelfarce.linux.theplanet.co.uk [195.92.249.252]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82KYH72003984 for ; Thu, 2 Sep 2004 13:34:18 -0700 Received: from rdu74-155-169.nc.rr.com ([24.74.155.169] helo=[10.10.10.88]) by www.linux.org.uk with asmtp (TLSv1:AES256-SHA:256) (Exim 4.33) id 1C2yHC-0004JW-Dp; Thu, 02 Sep 2004 21:33:46 +0100 Message-ID: <4137839B.4000303@pobox.com> Date: Thu, 02 Sep 2004 16:33:31 -0400 From: Jeff Garzik User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Vladimir Kondratiev CC: netdev@oss.sgi.com, Denis Vlasenko , Jean Tourrilhes , Jouni Malinen , acx100-devel@lists.sourceforge.net, prism54-devel@prism54.org, "David S. Miller" Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <4134C1A7.50600@pobox.com> <200409022324.43117.vkondra@mail.ru> In-Reply-To: <200409022324.43117.vkondra@mail.ru> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8362 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jgarzik@pobox.com Precedence: bulk X-list: netdev Vladimir Kondratiev wrote: > Jeff, > > On Tuesday 31 August 2004 21:21, Jeff Garzik wrote: > JG> Denis Vlasenko wrote: > JG> > I think 'senior' network guys are in position to decide upon which > JG> > of currently available 802.11 stacks we should continue to work. > JG> > (Atheros has one, said to be derived from BSD, is there any others?) > JG> > JG> > JG> Already have. Start with the code in wireless-2.6 -- HostAP -- and use > JG> DaveM's 802.11 stack template as a model for actually integrating 802.11 > JG> very tightly with the rest of the net stack. > JG> > JG> > http://www.kernel.org/pub/linux/kernel/people/jgarzik/patchkits/2.6/davem-p8 > 0211.tar.bz2 > > Is this stack the main one that is going to be used? I.e. if I am working on > driver for next generation .11 card - should I try to use it, request/submitt > missing features etc.? Or should I use wireless extensions? DaveM's code is a template for how a wireless stack would look when properly and fully integrated into the net core. Although JeanT and I disagree about this, I am less interested in backwards compatibility than I am about making wireless a "first class citizen" in the kernel. As I have proven with kcompat (http://sf.net/projects/gkernel/) you can be backwards compatible while still evolving the current kernel driver API to meet current design needs. Jeff From ak@suse.de Thu Sep 2 14:20:37 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 14:20:55 -0700 (PDT) Received: from Cantor.suse.de (cantor.suse.de [195.135.220.2]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82LKauk004895 for ; Thu, 2 Sep 2004 14:20:37 -0700 Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 85706B6C4D8; Thu, 2 Sep 2004 23:19:50 +0200 (CEST) Date: Thu, 2 Sep 2004 23:19:50 +0200 From: Andi Kleen To: Srivatsa Vaddagiri Cc: Andi Kleen , davem@redhat.com, netdev@oss.sgi.com, linux-kernel@vger.kernel.org, Dipankar , paulmck@us.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Message-ID: <20040902211950.GH16175@wotan.suse.de> References: <20040831125941.GA5534@in.ibm.com> <20040831135419.GA17642@wotan.suse.de> <20040901113641.GA3918@in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901113641.GA3918@in.ibm.com> X-archive-position: 8363 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ak@suse.de Precedence: bulk X-list: netdev On Wed, Sep 01, 2004 at 05:06:41PM +0530, Srivatsa Vaddagiri wrote: > | 2.6.8.1 | 2.6.8.1 + my patch > ------------------------------------------------------------------------------- > Average cycles | | > spent in | | > __tcp_v4_lookup_established | 2970.65 | 668.227 > | (~3.3 micro-seconds) | (~0.74 microseconds) > ------------------------------------------------------------------------------- > > This repesents improvement by a factor of 77.5%! Nice. > > > > > > And it should also fix the performance problems with > > cat /proc/net/tcp on ppc64/ia64 for large hash tables because the rw locks > > are gone. > > But spinlocks are in! Would that still improve the performance compared to rw > locks? (See me earlier note where I have explained that lookup done for > /proc/net/tcp is _not_ lock-free yet). Yes, spinlocks are much faster than rwlocks. -Andi From davem@redhat.com Thu Sep 2 14:45:52 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 14:45:58 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82Ljpn3005512 for ; Thu, 2 Sep 2004 14:45:52 -0700 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i82LjZS0001754; Thu, 2 Sep 2004 17:45:40 -0400 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i82LjZ315553; Thu, 2 Sep 2004 17:45:35 -0400 Received: from cheetah.davemloft.net (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11/8.12.10) with SMTP id i82LjRBl012123; Thu, 2 Sep 2004 17:45:27 -0400 Date: Thu, 2 Sep 2004 14:44:36 -0700 From: "David S. Miller" To: Patrick McHardy Cc: yoshfuji@linux-ipv6.org, herbert@debian.org, netdev@oss.sgi.com Subject: Re: [PATCH 2.6]: Fix suboptimal fragment sizing for last fragment Message-Id: <20040902144436.2c8c1337.davem@redhat.com> In-Reply-To: <4137681D.3000902@trash.net> References: <4137681D.3000902@trash.net> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8364 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@redhat.com Precedence: bulk X-list: netdev On Thu, 02 Sep 2004 20:36:13 +0200 Patrick McHardy wrote: > This patch always builds mtu sized fragments and truncates the previous > fragment to a multiple of 8 bytes when allocating a new one. With the > patch the dump looks like this: Looks great Patrick, applied. I see only one remaining possible improvement. If the fraggap area is paged data, we probably should try use page frags in the new SKB if this split occurs in ip_append_page(). From herbert@gondor.apana.org.au Thu Sep 2 15:04:19 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 15:04:28 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82M4HDs006026 for ; Thu, 2 Sep 2004 15:04:18 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1C2zgK-0007pN-00; Fri, 03 Sep 2004 08:03:48 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1C2zgG-0000vj-00; Fri, 03 Sep 2004 08:03:44 +1000 Date: Fri, 3 Sep 2004 08:03:44 +1000 To: "David S. Miller" Cc: Patrick McHardy , yoshfuji@linux-ipv6.org, netdev@oss.sgi.com Subject: Re: [PATCH 2.6]: Fix suboptimal fragment sizing for last fragment Message-ID: <20040902220343.GA3250@gondor.apana.org.au> References: <4137681D.3000902@trash.net> <20040902144436.2c8c1337.davem@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="fdj2RfSjLxBAspz7" Content-Disposition: inline In-Reply-To: <20040902144436.2c8c1337.davem@redhat.com> User-Agent: Mutt/1.5.6+20040722i From: Herbert Xu X-archive-position: 8365 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 02, 2004 at 02:44:36PM -0700, David S. Miller wrote: > > I see only one remaining possible improvement. If the fraggap > area is paged data, we probably should try use page frags > in the new SKB if this split occurs in ip_append_page(). Yes. That could also tie into another optimisation. But it's an ugly one :) The sk->csum values are added up at the end of the processing so when we move bytes to and fro the total csum value stays the same even if the fragment csum values change. Therefore we can get rid of the csum adjustments except for the parity bit in the getfrag call. Is this an acceptable optimisation to you guys? Another thing we can do is to not always fill up the frags in the middle and then move bytes off them. As it is if you do a send that spans multiple packets each fragment will be filled up to the full and then chopped off when the next one is started. And to finish it off, here is a really trivial patch to shave off 27 bytes from the source code :) It does nothing else, well unless your compiler decides to compile csum_block_sub out-of-line. Signed-off-by: Herbert Xu Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p ===== net/ipv4/ip_output.c 1.65 vs edited ===== --- 1.65/net/ipv4/ip_output.c 2004-09-02 15:07:28 +10:00 +++ edited/net/ipv4/ip_output.c 2004-09-03 07:53:54 +10:00 @@ -896,8 +896,8 @@ skb->csum = skb_copy_and_csum_bits( skb_prev, maxfraglen, data + transhdrlen, fraggap, 0); - skb_prev->csum = csum_block_sub( - skb_prev->csum, skb->csum, 0); + skb_prev->csum = csum_sub(skb_prev->csum, + skb->csum); data += fraggap; skb_trim(skb_prev, maxfraglen); } @@ -1094,8 +1094,8 @@ skb->csum = skb_copy_and_csum_bits( skb_prev, maxfraglen, data, fraggap, 0); - skb_prev->csum = csum_block_sub( - skb_prev->csum, skb->csum, 0); + skb_prev->csum = csum_sub(skb_prev->csum, + skb->csum); skb_trim(skb_prev, maxfraglen); } ===== net/ipv6/ip6_output.c 1.70 vs edited ===== --- 1.70/net/ipv6/ip6_output.c 2004-09-02 15:07:29 +10:00 +++ edited/net/ipv6/ip6_output.c 2004-09-03 07:54:41 +10:00 @@ -985,8 +985,8 @@ skb->csum = skb_copy_and_csum_bits( skb_prev, maxfraglen, data + transhdrlen, fraggap, 0); - skb_prev->csum = csum_block_sub( - skb_prev->csum, skb->csum, 0); + skb_prev->csum = csum_sub(skb_prev->csum, + skb->csum); data += fraggap; skb_trim(skb_prev, maxfraglen); } --fdj2RfSjLxBAspz7-- From keizerflipje@home.nl Thu Sep 2 15:05:56 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 15:06:03 -0700 (PDT) Received: from smtpq3.home.nl (smtpq3.home.nl [213.51.128.198]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82M5tmo006283 for ; Thu, 2 Sep 2004 15:05:56 -0700 Received: from [213.51.128.135] (port=55609 helo=smtp4.home.nl) by smtpq3.home.nl with esmtp (Exim 4.30) id 1C2ziE-0008C4-D0; Fri, 03 Sep 2004 00:05:46 +0200 Received: from cp232498-a.gelen1.lb.home.nl ([217.120.68.81]:51665 helo=[10.0.0.200]) by smtp4.home.nl with esmtp (Exim 4.30) id 1C2ziB-0002zZ-Ev; Fri, 03 Sep 2004 00:05:43 +0200 Message-ID: <41379937.5060301@home.nl> Date: Fri, 03 Sep 2004 00:05:43 +0200 From: Pascal de Bruijn User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Francois Romieu CC: netdev@oss.sgi.com Subject: Re: r8169 1.6LK lockup References: <4137418D.2040706@home.nl> <20040902174437.GA12068@electric-eye.fr.zoreil.com> In-Reply-To: <20040902174437.GA12068@electric-eye.fr.zoreil.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AtHome-MailScanner-Information: Neem contact op met support@home.nl voor meer informatie X-AtHome-MailScanner: Found to be clean X-archive-position: 8366 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: keizerflipje@home.nl Precedence: bulk X-list: netdev Right, I've patched my kernel, and now everything works like a breeze... I enabled all features: ethtool -K eth0 rx on tx on sg on tso on Then I uploaded 10GB and downloaded about 2GB (in an alternating style). No more lockups... Good work! Thanks, Pascal de Bruijn Francois Romieu wrote: >Pascal de Bruijn : >[francois messed the r8169 update] > >How does the system perform if you apply the patches below as well: >http://www.fr.zoreil.com/linux/kernel/2.6.x/2.6.9-rc1-mm1/r8169-130.patch >http://www.fr.zoreil.com/linux/kernel/2.6.x/2.6.9-rc1-mm1/r8169-140.patch > >Please Cc: netdev@oss.sgi.com > >-- >Ueimor > > > From davem@redhat.com Thu Sep 2 15:10:00 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 15:10:06 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82M9x4x006811 for ; Thu, 2 Sep 2004 15:10:00 -0700 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i82M9US0007366; Thu, 2 Sep 2004 18:09:42 -0400 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i82M9T321944; Thu, 2 Sep 2004 18:09:29 -0400 Received: from cheetah.davemloft.net (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11/8.12.10) with SMTP id i82M9Ljj022112; Thu, 2 Sep 2004 18:09:21 -0400 Date: Thu, 2 Sep 2004 15:08:30 -0700 From: "David S. Miller" To: Herbert Xu Cc: kaber@trash.net, yoshfuji@linux-ipv6.org, netdev@oss.sgi.com Subject: Re: [PATCH 2.6]: Fix suboptimal fragment sizing for last fragment Message-Id: <20040902150830.6585cfc5.davem@redhat.com> In-Reply-To: <20040902220343.GA3250@gondor.apana.org.au> References: <4137681D.3000902@trash.net> <20040902144436.2c8c1337.davem@redhat.com> <20040902220343.GA3250@gondor.apana.org.au> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8367 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@redhat.com Precedence: bulk X-list: netdev On Fri, 3 Sep 2004 08:03:44 +1000 Herbert Xu wrote: > That could also tie into another optimisation. But it's > an ugly one :) The sk->csum values are added up at the end of > the processing so when we move bytes to and fro the total csum > value stays the same even if the fragment csum values change. > > Therefore we can get rid of the csum adjustments except for the > parity bit in the getfrag call. > > Is this an acceptable optimisation to you guys? I have no problems with this. > Another thing we can do is to not always fill up the frags in the middle > and then move bytes off them. As it is if you do a send that spans > multiple packets each fragment will be filled up to the full and then > chopped off when the next one is started. Please elaborate. > And to finish it off, here is a really trivial patch to shave off 27 > bytes from the source code :) It does nothing else, well unless your > compiler decides to compile csum_block_sub out-of-line. Applied :-) From romieu@fr.zoreil.com Thu Sep 2 16:06:21 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 16:06:27 -0700 (PDT) Received: from fr.zoreil.com (electric-eye.fr.zoreil.com [213.41.134.224]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i82N6KBe007957 for ; Thu, 2 Sep 2004 16:06:21 -0700 Received: from electric-eye.fr.zoreil.com (localhost.localdomain [127.0.0.1]) by fr.zoreil.com (8.12.10/8.12.1) with ESMTP id i82N2fvr016876; Fri, 3 Sep 2004 01:02:41 +0200 Received: (from romieu@localhost) by electric-eye.fr.zoreil.com (8.12.10/8.12.10/Submit) id i82N2eqD016875; Fri, 3 Sep 2004 01:02:40 +0200 Date: Fri, 3 Sep 2004 01:02:40 +0200 From: Francois Romieu To: Pascal de Bruijn Cc: netdev@oss.sgi.com Subject: Re: r8169 1.6LK lockup Message-ID: <20040902230240.GA16747@electric-eye.fr.zoreil.com> References: <4137418D.2040706@home.nl> <20040902174437.GA12068@electric-eye.fr.zoreil.com> <41379937.5060301@home.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41379937.5060301@home.nl> User-Agent: Mutt/1.4.1i X-Organisation: Land of Sunshine Inc. X-archive-position: 8368 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: romieu@fr.zoreil.com Precedence: bulk X-list: netdev Pascal de Bruijn : [fully featured patched r8169 driver] > > Then I uploaded 10GB and downloaded about 2GB (in an alternating style). > > No more lockups... > > Good work! It appears to be better but still not rock solid. Grrr... -- Ueimor From yoshfuji@linux-ipv6.org Thu Sep 2 18:40:04 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 18:40:10 -0700 (PDT) Received: from yue.st-paulia.net ([203.178.140.15]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i831e3Wr014315 for ; Thu, 2 Sep 2004 18:40:03 -0700 Received: from localhost (localhost [127.0.0.1]) by yue.st-paulia.net (Postfix) with ESMTP id 4CB4633CE6; Fri, 3 Sep 2004 10:40:51 +0900 (JST) Date: Fri, 03 Sep 2004 10:40:50 +0900 (JST) Message-Id: <20040903.104050.29603454.yoshfuji@linux-ipv6.org> To: davem@redhat.com, herbert@gondor.apana.org.au Cc: kaber@trash.net, netdev@oss.sgi.com, yoshfuji@linux-ipv6.org Subject: Re: [PATCH 2.6]: Fix suboptimal fragment sizing for last fragment From: YOSHIFUJI Hideaki / =?iso-2022-jp?B?GyRCNUhGIzFRTEAbKEI=?= In-Reply-To: <20040902220343.GA3250@gondor.apana.org.au> References: <4137681D.3000902@trash.net> <20040902144436.2c8c1337.davem@redhat.com> <20040902220343.GA3250@gondor.apana.org.au> Organization: USAGI Project X-URL: http://www.yoshifuji.org/%7Ehideaki/ X-Fingerprint: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA X-PGP-Key-URL: http://www.yoshifuji.org/%7Ehideaki/hideaki@yoshifuji.org.asc X-Face: "5$Al-.M>NJ%a'@hhZdQm:."qn~PA^gq4o*>iCFToq*bAi#4FRtx}enhuQKz7fNqQz\BYU] $~O_5m-9'}MIs`XGwIEscw;e5b>n"B_?j/AkL~i/MEaZBLP X-Mailer: Mew version 2.2 on Emacs 20.7 / Mule 4.1 (AOI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-archive-position: 8369 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: yoshfuji@linux-ipv6.org Precedence: bulk X-list: netdev In article <20040902220343.GA3250@gondor.apana.org.au> (at Fri, 3 Sep 2004 08:03:44 +1000), Herbert Xu says: > Another thing we can do is to not always fill up the frags in the middle > and then move bytes off them. As it is if you do a send that spans > multiple packets each fragment will be filled up to the full and then > chopped off when the next one is started. I think I had similar impression when I saw the Patrick's patch. Here's the optimization: if we know the remaining data exceeds the mtu, we do not need to fill up full of it. skb_prev: mtu +----------+--+-+ | | | | +----------+--+-+ ^ ^ skb_prev->len | maxfraglen appending data: +--------+ | | +--------+ ---------> length In this case, we know we need more fragment(s). So, let's fill up to maxfraglen (instead of mtu) to avoid needless copy in the next loop. Signed-off-by: Hideaki YOSHIFUJI ===== net/ipv4/ip_output.c 1.67 vs edited ===== --- 1.67/net/ipv4/ip_output.c 2004-09-03 06:50:20 +09:00 +++ edited/net/ipv4/ip_output.c 2004-09-03 10:15:53 +09:00 @@ -811,26 +811,33 @@ goto alloc_new_skb; while (length > 0) { - if ((copy = mtu - skb->len) <= 0) { + /* Check if the remaining data fits into current packet. */ + copy = mtu - skb->len; + if (copy < length) + copy = maxfraglen - skb->len; + if (copy <= 0) { char *data; unsigned int datalen; unsigned int fraglen; unsigned int fraggap; unsigned int alloclen; struct sk_buff *skb_prev; - BUG_TRAP(copy == 0); - alloc_new_skb: skb_prev = skb; - fraggap = 0; if (skb_prev) - fraggap = mtu - maxfraglen; - - datalen = mtu - fragheaderlen; - if (datalen > length + fraggap) - datalen = length + fraggap; + fraggap = skb_prev->len - maxfraglen; + else + fraggap = 0; + /* + * If remaining data exceeds the mtu, + * we know we need more fragment(s). + */ + datalen = length + fraggap; + if (datalen > mtu - fragheaderlen) + datalen = maxfraglen - fragheaderlen; fraglen = datalen + fragheaderlen; + if ((flags & MSG_MORE) && !(rt->u.dst.dev->features&NETIF_F_SG)) alloclen = mtu; @@ -1026,18 +1033,22 @@ while (size > 0) { int i; - if ((len = mtu - skb->len) <= 0) { + + /* Check if the remaining data fits into current packet. */ + len = mtu - skb->len; + if (len > size) + len = maxfraglen - skb->len; + if (len <= 0) { struct sk_buff *skb_prev; char *data; struct iphdr *iph; int alloclen; - BUG_TRAP(len == 0); - skb_prev = skb; - fraggap = 0; if (skb_prev) - fraggap = mtu - maxfraglen; + fraggap = skb_prev->len - maxfraglen; + else + fraggap = 0; alloclen = fragheaderlen + hh_len + fraggap + 15; skb = sock_wmalloc(sk, alloclen, 1, sk->sk_allocation); ===== net/ipv6/ip6_output.c 1.72 vs edited ===== --- 1.72/net/ipv6/ip6_output.c 2004-09-03 06:50:20 +09:00 +++ edited/net/ipv6/ip6_output.c 2004-09-03 10:24:57 +09:00 @@ -898,26 +898,34 @@ goto alloc_new_skb; while (length > 0) { - if ((copy = mtu - skb->len) <= 0) { + /* Check if the remaining data fits into current packet. */ + copy = mtu - skb->len; + if (copy < length) + copy = maxfraglen - skb->len; + + if (copy <= 0) { char *data; unsigned int datalen; unsigned int fraglen; unsigned int fraggap; unsigned int alloclen; struct sk_buff *skb_prev; - BUG_TRAP(copy == 0); alloc_new_skb: skb_prev = skb; /* There's no room in the current skb */ - fraggap = 0; if (skb_prev) - fraggap = mtu - maxfraglen; - - datalen = mtu - fragheaderlen; + fraggap = skb_prev->len - maxfraglen; + else + fraggap = 0; - if (datalen > length + fraggap) - datalen = length + fraggap; + /* + * If remaining data exceeds the mtu, + * we know we need more fragment(s). + */ + datalen = length + fraggap; + if (datalen > mtu - fragheaderlen) + datalen = maxfraglen - fragheaderlen; fraglen = datalen + fragheaderlen; if ((flags & MSG_MORE) && -- Hideaki YOSHIFUJI @ USAGI Project GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA From vatsa@in.ibm.com Thu Sep 2 21:04:53 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 21:05:05 -0700 (PDT) Received: from e1.ny.us.ibm.com (e1.ny.us.ibm.com [32.97.182.101]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8344qbw020552 for ; Thu, 2 Sep 2004 21:04:53 -0700 Received: from northrelay02.pok.ibm.com (northrelay02.pok.ibm.com [9.56.224.150]) by e1.ny.us.ibm.com (8.12.10/NS PXFA) with ESMTP id i8344dCR013368; Fri, 3 Sep 2004 00:04:39 -0400 Received: from snowy.in.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by northrelay02.pok.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i8345mND146320; Fri, 3 Sep 2004 00:05:51 -0400 Received: by snowy.in.ibm.com (Postfix, from userid 502) id ED4CD24E32; Thu, 2 Sep 2004 19:34:44 +0530 (IST) Date: Thu, 2 Sep 2004 19:34:44 +0530 From: Srivatsa Vaddagiri To: "David S. Miller" Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org, dipankar@in.ibm.com, paulmck@us.ibm.com Subject: Re: [RFC] Use RCU for tcp_ehash lookup Message-ID: <20040902140444.GA4808@in.ibm.com> Reply-To: vatsa@in.ibm.com References: <20040831125941.GA5534@in.ibm.com> <20040901224108.3b2d692d.davem@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901224108.3b2d692d.davem@redhat.com> User-Agent: Mutt/1.4.1i X-archive-position: 8370 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vatsa@in.ibm.com Precedence: bulk X-list: netdev On Wed, Sep 01, 2004 at 10:41:08PM -0700, David S. Miller wrote: > The reason you don't see any improvement is that the ehash table is > pretty write heavy. In my simple one-file-transfer-test-at-a-time, it should have been read-mostly. Probably the fact lookups are not serialized wrt input pakcet processing may have shadowed the benefits of lock-free lookup. However perhaps if I have multiple file transfer sessions in progress (one per cpu maybe), then the benefit of reduced time spent in looking up a socket, could be passed on to threads doing network input. > I'm not totally against your patch, I just don't think that the TCP established > hash table qualifies as "read heavy" as per what RCU is truly effective for. IMHO the benefits of lock-free will be seen only in such scenarios, i.e where read_lock ended up having to spin-wait on a update to finish. In the lock-free case, there is no such wait. > That's exactly what I was concerned about when I saw that you had attempted > this change. It is incredibly important for state changes and updates to > be seen as atomic by the packet input processing engine. It would be illegal > for a cpu running TCP input to see a socket in two tables at the same time > (for example, in the main established area and in the second half for TIME_WAIT > buckets). > > If the visibility of the socket is wrong, sockets could be erroneously > be reset during the transition from established to TIME_WAIT state. > Beware! This is precisely the reason why I changed the order of movement in __tcp_tw_hashdance. Earlier, it was removing the socket from the established half and _then_ adding it to time-wait half. This would have lead to a window where the socket is neither in established-half not in the time-wait half. A packet arriving in this window (& doing lock-free lookup) would have been dropped. Hence I reversed the order of movement to add in time-wait first before removing from established half. > > Note that __tcp_v4_lookup_established should not be affected by the above > > movement because I found it scans the established half first and _then_ the > > time wait half. So even if the same socket is present in both established half > > and time wait half, __tcp_v4_lookup_established will lookup only one of them > > (& not both). > > I hope this is true. AFAICS it is true! If __tcp_v4_lookup_established finds it in the established half, it does no further lookup in the time-wait half. -- Thanks and Regards, Srivatsa Vaddagiri, Linux Technology Center, IBM Software Labs, Bangalore, INDIA - 560017 From max@stro.at Thu Sep 2 23:47:02 2004 Received: with ECARTIS (v1.0.0; list netdev); Thu, 02 Sep 2004 23:47:08 -0700 (PDT) Received: from baikonur.stro.at (baikonur.stro.at [213.239.196.228]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i836l1Yp024411 for ; Thu, 2 Sep 2004 23:47:02 -0700 Received: from localhost (localhost [127.0.0.1]) by baikonur.stro.at (Postfix) with ESMTP id 271885C065; Fri, 3 Sep 2004 08:46:51 +0200 (CEST) Received: from baikonur.stro.at ([127.0.0.1]) by localhost (baikonur [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28481-06; Fri, 3 Sep 2004 08:46:50 +0200 (CEST) Received: from sputnik (M914P027.adsl.highway.telekom.at [62.47.146.59]) by baikonur.stro.at (Postfix) with ESMTP id 8A0AA5C008; Fri, 3 Sep 2004 08:46:50 +0200 (CEST) Received: from max by sputnik with local (Exim 4.34) id 1C37qV-0001Hl-Le; Fri, 03 Sep 2004 08:46:51 +0200 Date: Fri, 3 Sep 2004 08:46:51 +0200 From: maximilian attems To: netdev@oss.sgi.com, jgarzik@pobox.com Subject: [patch] prism54 remove unused macro Message-ID: <20040903064651.GB1856@stro.at> Mail-Followup-To: netdev@oss.sgi.com, jgarzik@pobox.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040722i X-Virus-Scanned: by Amavis (ClamAV) at stro.at X-archive-position: 8371 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: janitor@sternwelten.at Precedence: bulk X-list: netdev the TRACE macro was noticed because of it's string concatenation. this patch removes it as it's unused. Signed-off-by: Maximilian Attems --- linux-2.6.9-rc1-bk7-orig/drivers/net/wireless/prism54/islpci_mgt.h 2004-08-14 12:54:51.000000000 +0200 +++ linux-2.6.9-rc1-bk7/drivers/net/wireless/prism54/islpci_mgt.h 2004-09-03 08:35:30.000000000 +0200 @@ -31,8 +31,6 @@ #define K_DEBUG(f, m, args...) do { if(f & m) printk(KERN_DEBUG args); } while(0) #define DEBUG(f, args...) K_DEBUG(f, pc_debug, args) -#define TRACE(devname) K_DEBUG(SHOW_TRACING, VERBOSE, "%s: -> " __FUNCTION__ "()\n", devname) - extern int pc_debug; #define init_wds 0 /* help compiler optimize away dead code */ --- linux-2.6.9-rc1-bk7-orig/drivers/net/wireless/prism54/islpci_hotplug.c 2004-08-14 12:55:32.000000000 +0200 +++ linux-2.6.9-rc1-bk7/drivers/net/wireless/prism54/islpci_hotplug.c 2004-09-03 08:35:45.000000000 +0200 @@ -107,8 +107,6 @@ prism54_probe(struct pci_dev *pdev, cons islpci_private *priv; int rvalue; - /* TRACE(DRV_NAME); */ - /* Enable the pci device */ if (pci_enable_device(pdev)) { From laforge@netfilter.org Fri Sep 3 00:02:53 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 00:03:00 -0700 (PDT) Received: from coruscant.gnumonks.org (mail@coruscant.franken.de [193.174.159.226]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8372q8R025104 for ; Fri, 3 Sep 2004 00:02:52 -0700 Received: from [192.168.200.2] (helo=sunbeam.gnumonks.org) by coruscant.gnumonks.org with esmtp (TLSv1:RC4-SHA:128) (Exim 4.20) id 1C385p-0001iI-J5; Fri, 03 Sep 2004 09:02:42 +0200 Received: from laforge by sunbeam.gnumonks.org with local (Exim 4.34) id 1C385i-0000R6-LU; Fri, 03 Sep 2004 09:02:34 +0200 Date: Fri, 3 Sep 2004 09:02:34 +0200 From: Harald Welte To: David Miller Cc: Netfilter Development Mailinglist , netdev@oss.sgi.com Subject: [PATCH 2.6] 2/2: Fix NAT helper locking Message-ID: <20040903070234.GQ26263@sunbeam.de.gnumonks.org> Mail-Followup-To: Harald Welte , David Miller , Netfilter Development Mailinglist , netdev@oss.sgi.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CRjAHycgiaTQGSqU" Content-Disposition: inline User-Agent: Mutt/1.5.6+20040818i X-archive-position: 8372 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: laforge@netfilter.org Precedence: bulk X-list: netdev --CRjAHycgiaTQGSqU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Dave! This is the second of a two part patch. This part fixes the locking in NAT helpers. Please apply, Thanks. # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/08/08 01:40:28+02:00 kaber@coreworks.de=20 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers # =20 # There is a possible deadlock condition with conntrack/nat-helpers: # =20 # CPU1: # conntrack-helper:help: lock(private_lock) # ip_conntrack_expect_related: write_lock(ip_conntrack_lock) # =20 # CPU2: # nat-core:do_bindings: read_lock(ip_conntrack_lock) # nat-helper:help: lock(private_lock) # =20 # The lock in the nat-helper is unneccessary because the expectation # is never changed and is protected by ip_conntrack_lock. # =20 # Signed-off-by: Patrick McHardy # Signed-off-by: Harald Welte #=20 # net/ipv4/netfilter/ip_nat_irc.c # 2004/08/08 01:40:10+02:00 kaber@coreworks.de +1 -17 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # net/ipv4/netfilter/ip_nat_ftp.c # 2004/08/08 01:40:10+02:00 kaber@coreworks.de +1 -19 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # net/ipv4/netfilter/ip_conntrack_irc.c # 2004/08/08 01:40:10+02:00 kaber@coreworks.de +3 -4 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # net/ipv4/netfilter/ip_conntrack_ftp.c # 2004/08/08 01:40:10+02:00 kaber@coreworks.de +1 -2 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # include/linux/netfilter_ipv4/ip_conntrack_irc.h # 2004/08/08 01:40:10+02:00 kaber@coreworks.de +0 -5 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # include/linux/netfilter_ipv4/ip_conntrack_ftp.h # 2004/08/08 01:40:10+02:00 kaber@coreworks.de +0 -5 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 diff -Nru a/include/linux/netfilter_ipv4/ip_conntrack_ftp.h b/include/linux= /netfilter_ipv4/ip_conntrack_ftp.h --- a/include/linux/netfilter_ipv4/ip_conntrack_ftp.h 2004-08-08 01:41:23 += 02:00 +++ b/include/linux/netfilter_ipv4/ip_conntrack_ftp.h 2004-08-08 01:41:23 += 02:00 @@ -4,11 +4,6 @@ =20 #ifdef __KERNEL__ =20 -#include - -/* Protects ftp part of conntracks */ -DECLARE_LOCK_EXTERN(ip_ftp_lock); - #define FTP_PORT 21 =20 #endif /* __KERNEL__ */ diff -Nru a/include/linux/netfilter_ipv4/ip_conntrack_irc.h b/include/linux= /netfilter_ipv4/ip_conntrack_irc.h --- a/include/linux/netfilter_ipv4/ip_conntrack_irc.h 2004-08-08 01:41:23 += 02:00 +++ b/include/linux/netfilter_ipv4/ip_conntrack_irc.h 2004-08-08 01:41:23 += 02:00 @@ -33,12 +33,7 @@ =20 #ifdef __KERNEL__ =20 -#include - #define IRC_PORT 6667 - -/* Protects irc part of conntracks */ -DECLARE_LOCK_EXTERN(ip_irc_lock); =20 #endif /* __KERNEL__ */ =20 diff -Nru a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_c= onntrack_ftp.c --- a/net/ipv4/netfilter/ip_conntrack_ftp.c 2004-08-08 01:41:23 +02:00 +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c 2004-08-08 01:41:23 +02:00 @@ -27,7 +27,7 @@ /* This is slow, but it's simple. --RR */ static char ftp_buffer[65536]; =20 -DECLARE_LOCK(ip_ftp_lock); +static DECLARE_LOCK(ip_ftp_lock); struct module *ip_conntrack_ftp =3D THIS_MODULE; =20 #define MAX_PORTS 8 @@ -455,7 +455,6 @@ } =20 PROVIDES_CONNTRACK(ftp); -EXPORT_SYMBOL(ip_ftp_lock); =20 module_init(init); module_exit(fini); diff -Nru a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_c= onntrack_irc.c --- a/net/ipv4/netfilter/ip_conntrack_irc.c 2004-08-08 01:41:23 +02:00 +++ b/net/ipv4/netfilter/ip_conntrack_irc.c 2004-08-08 01:41:23 +02:00 @@ -40,6 +40,7 @@ static unsigned int dcc_timeout =3D 300; /* This is slow, but it's simple. --RR */ static char irc_buffer[65536]; +static DECLARE_LOCK(irc_buffer_lock); =20 MODULE_AUTHOR("Harald Welte "); MODULE_DESCRIPTION("IRC (DCC) connection tracking helper"); @@ -54,7 +55,6 @@ static char *dccprotos[] =3D { "SEND ", "CHAT ", "MOVE ", "TSEND ", "SCHAT= " }; #define MINMATCHLEN 5 =20 -DECLARE_LOCK(ip_irc_lock); struct module *ip_conntrack_irc =3D THIS_MODULE; =20 #if 0 @@ -134,7 +134,7 @@ if (dataoff >=3D skb->len) return NF_ACCEPT; =20 - LOCK_BH(&ip_irc_lock); + LOCK_BH(&irc_buffer_lock); skb_copy_bits(skb, dataoff, irc_buffer, skb->len - dataoff); =20 data =3D irc_buffer; @@ -227,7 +227,7 @@ } /* while data < ... */ =20 out: - UNLOCK_BH(&ip_irc_lock); + UNLOCK_BH(&irc_buffer_lock); return NF_ACCEPT; } =20 @@ -302,7 +302,6 @@ } =20 PROVIDES_CONNTRACK(irc); -EXPORT_SYMBOL(ip_irc_lock); =20 module_init(init); module_exit(fini); diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp= =2Ec --- a/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 01:41:23 +02:00 +++ b/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 01:41:23 +02:00 @@ -35,8 +35,6 @@ =20 MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i"); =20 -DECLARE_LOCK_EXTERN(ip_ftp_lock); - /* FIXME: Time out? --RR */ =20 static unsigned int @@ -59,8 +57,6 @@ DEBUGP("nat_expected: We have a connection!\n"); exp_ftp_info =3D &ct->master->help.exp_ftp_info; =20 - LOCK_BH(&ip_ftp_lock); - if (exp_ftp_info->ftptype =3D=3D IP_CT_FTP_PORT || exp_ftp_info->ftptype =3D=3D IP_CT_FTP_EPRT) { /* PORT command: make connection go to the client. */ @@ -75,7 +71,6 @@ DEBUGP("nat_expected: PASV cmd. %u.%u.%u.%u->%u.%u.%u.%u\n", NIPQUAD(newsrcip), NIPQUAD(newdstip)); } - UNLOCK_BH(&ip_ftp_lock); =20 if (HOOK2MANIP(hooknum) =3D=3D IP_NAT_MANIP_SRC) newip =3D newsrcip; @@ -111,8 +106,6 @@ { char buffer[sizeof("nnn,nnn,nnn,nnn,nnn,nnn")]; =20 - MUST_BE_LOCKED(&ip_ftp_lock); - sprintf(buffer, "%u,%u,%u,%u,%u,%u", NIPQUAD(newip), port>>8, port&0xFF); =20 @@ -134,8 +127,6 @@ { char buffer[sizeof("|1|255.255.255.255|65535|")]; =20 - MUST_BE_LOCKED(&ip_ftp_lock); - sprintf(buffer, "|1|%u.%u.%u.%u|%u|", NIPQUAD(newip), port); =20 DEBUGP("calling ip_nat_mangle_tcp_packet\n"); @@ -156,8 +147,6 @@ { char buffer[sizeof("|||65535|")]; =20 - MUST_BE_LOCKED(&ip_ftp_lock); - sprintf(buffer, "|||%u|", port); =20 DEBUGP("calling ip_nat_mangle_tcp_packet\n"); @@ -189,7 +178,6 @@ u_int16_t port; struct ip_conntrack_tuple newtuple; =20 - MUST_BE_LOCKED(&ip_ftp_lock); DEBUGP("FTP_NAT: seq %u + %u in %u\n", expect->seq, exp_ftp_info->len, ntohl(tcph->seq)); @@ -268,15 +256,12 @@ } =20 datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; - LOCK_BH(&ip_ftp_lock); /* If it's in the right range... */ if (between(exp->seq + exp_ftp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!ftp_data_fixup(exp_ftp_info, ct, pskb, ctinfo, exp)) { - UNLOCK_BH(&ip_ftp_lock); + if (!ftp_data_fixup(exp_ftp_info, ct, pskb, ctinfo, exp)) return NF_DROP; - } } else { /* Half a match? This means a partial retransmisison. It's a cracker being funky. */ @@ -286,11 +271,8 @@ ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } - UNLOCK_BH(&ip_ftp_lock); return NF_DROP; } - UNLOCK_BH(&ip_ftp_lock); - return NF_ACCEPT; } =20 diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc= =2Ec --- a/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 01:41:23 +02:00 +++ b/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 01:41:23 +02:00 @@ -44,9 +44,6 @@ MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i"); MODULE_PARM_DESC(ports, "port numbers of IRC servers"); =20 -/* protects irc part of conntracks */ -DECLARE_LOCK_EXTERN(ip_irc_lock); - /* FIXME: Time out? --RR */ =20 static unsigned int @@ -102,8 +99,6 @@ /* "4294967296 65635 " */ char buffer[18]; =20 - MUST_BE_LOCKED(&ip_irc_lock); - DEBUGP("IRC_NAT: info (seq %u + %u) in %u\n", expect->seq, exp_irc_info->len, ntohl(tcph->seq)); @@ -111,11 +106,6 @@ newip =3D ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; =20 /* Alter conntrack's expectations. */ - - /* We can read expect here without conntrack lock, since it's - only set in ip_conntrack_irc, with ip_irc_lock held - writable */ - t =3D expect->tuple; t.dst.ip =3D newip; for (port =3D exp_irc_info->port; port !=3D 0; port++) { @@ -185,15 +175,12 @@ DEBUGP("got beyond not touching\n"); =20 datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; - LOCK_BH(&ip_irc_lock); /* Check whether the whole IP/address pattern is carried in the payload */ if (between(exp->seq + exp_irc_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!irc_data_fixup(exp_irc_info, ct, pskb, ctinfo, exp)) { - UNLOCK_BH(&ip_irc_lock); + if (!irc_data_fixup(exp_irc_info, ct, pskb, ctinfo, exp)) return NF_DROP; - } } else {=20 /* Half a match? This means a partial retransmisison. It's a cracker being funky. */ @@ -204,11 +191,8 @@ ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } - UNLOCK_BH(&ip_irc_lock); return NF_DROP; } - UNLOCK_BH(&ip_irc_lock); - return NF_ACCEPT; } =20 --=20 - Harald Welte http://www.netfilter.org/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie --CRjAHycgiaTQGSqU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOBcKXaXGVTD0i/8RAt9bAJ9mgosYQaErcJ6v/8dofPmfdB+HPwCcC+hu q/G+Xbg03/ej1aGUj2zhWSE= =+hPN -----END PGP SIGNATURE----- --CRjAHycgiaTQGSqU-- From laforge@netfilter.org Fri Sep 3 00:04:15 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 00:04:21 -0700 (PDT) Received: from coruscant.gnumonks.org (mail@coruscant.franken.de [193.174.159.226]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8374ElJ025288 for ; Fri, 3 Sep 2004 00:04:14 -0700 Received: from [192.168.200.2] (helo=sunbeam.gnumonks.org) by coruscant.gnumonks.org with esmtp (TLSv1:RC4-SHA:128) (Exim 4.20) id 1C387A-0001kd-FJ; Fri, 03 Sep 2004 09:04:05 +0200 Received: from laforge by sunbeam.gnumonks.org with local (Exim 4.34) id 1C3873-0000RP-M4; Fri, 03 Sep 2004 09:03:57 +0200 Date: Fri, 3 Sep 2004 09:03:57 +0200 From: Harald Welte To: David Miller Cc: Netfilter Development Mailinglist , netdev@oss.sgi.com Subject: [PATCH 2.4] 1/2: Rename NAT helper structures Message-ID: <20040903070357.GR26263@sunbeam.de.gnumonks.org> Mail-Followup-To: Harald Welte , David Miller , Netfilter Development Mailinglist , netdev@oss.sgi.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bxF9Dep5HzwGj9mC" Content-Disposition: inline User-Agent: Mutt/1.5.6+20040818i X-archive-position: 8373 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: laforge@netfilter.org Precedence: bulk X-list: netdev --bxF9Dep5HzwGj9mC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Dave! This is the first of a two part patch. Part one fixes confusing naming of some NAT helper data structures (ct_ are part of ip_conntrack, exp_ are part of ip_conntrack_expect). This patch is required to make the second apply, which fixes NAT helper locking. Please apply, thanks. # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/08/08 12:26:16+02:00 kaber@coreworks.de=20 # [NETFILTER]: Fix confusing naming in NAT-helpers # =20 # Signed-off-by: Patrick McHardy # Signed-off-by: Harald Welte #=20 # net/ipv4/netfilter/ip_nat_irc.c # 2004/08/08 12:26:12+02:00 kaber@coreworks.de +9 -9 # [NETFILTER]: Fix confusing naming in NAT-helpers #=20 # net/ipv4/netfilter/ip_nat_ftp.c # 2004/08/08 12:26:12+02:00 kaber@coreworks.de +12 -12 # [NETFILTER]: Fix confusing naming in NAT-helpers #=20 diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp= =2Ec --- a/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 12:49:36 +02:00 +++ b/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 12:49:36 +02:00 @@ -166,7 +166,7 @@ [IP_CT_FTP_EPSV] mangle_epsv_packet }; =20 -static int ftp_data_fixup(const struct ip_ct_ftp_expect *ct_ftp_info, +static int ftp_data_fixup(const struct ip_ct_ftp_expect *exp_ftp_info, struct ip_conntrack *ct, struct sk_buff **pskb, enum ip_conntrack_info ctinfo, @@ -180,13 +180,13 @@ =20 MUST_BE_LOCKED(&ip_ftp_lock); DEBUGP("FTP_NAT: seq %u + %u in %u\n", - expect->seq, ct_ftp_info->len, + expect->seq, exp_ftp_info->len, ntohl(tcph->seq)); =20 /* Change address inside packet to match way we're mapping this connection. */ - if (ct_ftp_info->ftptype =3D=3D IP_CT_FTP_PASV - || ct_ftp_info->ftptype =3D=3D IP_CT_FTP_EPSV) { + if (exp_ftp_info->ftptype =3D=3D IP_CT_FTP_PASV + || exp_ftp_info->ftptype =3D=3D IP_CT_FTP_EPSV) { /* PASV/EPSV response: must be where client thinks server is */ newip =3D ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; @@ -208,7 +208,7 @@ newtuple.src.u.tcp.port =3D expect->tuple.src.u.tcp.port; =20 /* Try to get same port: if not, try to change it. */ - for (port =3D ct_ftp_info->port; port !=3D 0; port++) { + for (port =3D exp_ftp_info->port; port !=3D 0; port++) { newtuple.dst.u.tcp.port =3D htons(port); =20 if (ip_conntrack_change_expect(expect, &newtuple) =3D=3D 0) @@ -217,9 +217,9 @@ if (port =3D=3D 0) return 0; =20 - if (!mangle[ct_ftp_info->ftptype](pskb, newip, port, + if (!mangle[exp_ftp_info->ftptype](pskb, newip, port, expect->seq - ntohl(tcph->seq), - ct_ftp_info->len, ct, ctinfo)) + exp_ftp_info->len, ct, ctinfo)) return 0; =20 return 1; @@ -236,12 +236,12 @@ struct tcphdr *tcph =3D (void *)iph + iph->ihl*4; unsigned int datalen; int dir; - struct ip_ct_ftp_expect *ct_ftp_info; + struct ip_ct_ftp_expect *exp_ftp_info; =20 if (!exp) DEBUGP("ip_nat_ftp: no exp!!"); =20 - ct_ftp_info =3D &exp->help.exp_ftp_info; + exp_ftp_info =3D &exp->help.exp_ftp_info; =20 /* Only mangle things once: original direction in POST_ROUTING and reply direction on PRE_ROUTING. */ @@ -259,10 +259,10 @@ datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; LOCK_BH(&ip_ftp_lock); /* If it's in the right range... */ - if (between(exp->seq + ct_ftp_info->len, + if (between(exp->seq + exp_ftp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!ftp_data_fixup(ct_ftp_info, ct, pskb, ctinfo, exp)) { + if (!ftp_data_fixup(exp_ftp_info, ct, pskb, ctinfo, exp)) { UNLOCK_BH(&ip_ftp_lock); return NF_DROP; } @@ -271,7 +271,7 @@ It's a cracker being funky. */ if (net_ratelimit()) { printk("FTP_NAT: partial packet %u/%u in %u/%u\n", - exp->seq, ct_ftp_info->len, + exp->seq, exp_ftp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc= =2Ec --- a/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 12:49:36 +02:00 +++ b/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 12:49:36 +02:00 @@ -89,7 +89,7 @@ return ip_nat_setup_info(ct, &mr, hooknum); } =20 -static int irc_data_fixup(const struct ip_ct_irc_expect *ct_irc_info, +static int irc_data_fixup(const struct ip_ct_irc_expect *exp_irc_info, struct ip_conntrack *ct, struct sk_buff **pskb, enum ip_conntrack_info ctinfo, @@ -107,7 +107,7 @@ MUST_BE_LOCKED(&ip_irc_lock); =20 DEBUGP("IRC_NAT: info (seq %u + %u) in %u\n", - expect->seq, ct_irc_info->len, + expect->seq, exp_irc_info->len, ntohl(tcph->seq)); =20 newip =3D ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; @@ -120,7 +120,7 @@ =20 t =3D expect->tuple; t.dst.ip =3D newip; - for (port =3D ct_irc_info->port; port !=3D 0; port++) { + for (port =3D exp_irc_info->port; port !=3D 0; port++) { t.dst.u.tcp.port =3D htons(port); if (ip_conntrack_change_expect(expect, &t) =3D=3D 0) { DEBUGP("using port %d", port); @@ -150,7 +150,7 @@ =20 return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,=20 expect->seq - ntohl(tcph->seq), - ct_irc_info->len, buffer,=20 + exp_irc_info->len, buffer,=20 strlen(buffer)); } =20 @@ -165,12 +165,12 @@ struct tcphdr *tcph =3D (void *) iph + iph->ihl * 4; unsigned int datalen; int dir; - struct ip_ct_irc_expect *ct_irc_info; + struct ip_ct_irc_expect *exp_irc_info; =20 if (!exp) DEBUGP("ip_nat_irc: no exp!!"); =09 - ct_irc_info =3D &exp->help.exp_irc_info; + exp_irc_info =3D &exp->help.exp_irc_info; =20 /* Only mangle things once: original direction in POST_ROUTING and reply direction on PRE_ROUTING. */ @@ -189,10 +189,10 @@ datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; LOCK_BH(&ip_irc_lock); /* Check wether the whole IP/address pattern is carried in the payload */ - if (between(exp->seq + ct_irc_info->len, + if (between(exp->seq + exp_irc_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!irc_data_fixup(ct_irc_info, ct, pskb, ctinfo, exp)) { + if (!irc_data_fixup(exp_irc_info, ct, pskb, ctinfo, exp)) { UNLOCK_BH(&ip_irc_lock); return NF_DROP; } @@ -202,7 +202,7 @@ if (net_ratelimit()) { printk ("IRC_NAT: partial packet %u/%u in %u/%u\n", - exp->seq, ct_irc_info->len, + exp->seq, exp_irc_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } --=20 - Harald Welte http://www.netfilter.org/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie --bxF9Dep5HzwGj9mC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOBddXaXGVTD0i/8RAjD2AJ0d2eu3tiW8CgGBQmfLfMQ6fMsXjQCff2qV iiENgsMIUj+DlK6U5GumqEc= =F4Nx -----END PGP SIGNATURE----- --bxF9Dep5HzwGj9mC-- From laforge@netfilter.org Fri Sep 3 00:05:12 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 00:05:21 -0700 (PDT) Received: from coruscant.gnumonks.org (mail@coruscant.franken.de [193.174.159.226]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i8375BQr025559 for ; Fri, 3 Sep 2004 00:05:12 -0700 Received: from [192.168.200.2] (helo=sunbeam.gnumonks.org) by coruscant.gnumonks.org with esmtp (TLSv1:RC4-SHA:128) (Exim 4.20) id 1C3885-0001kx-Km; Fri, 03 Sep 2004 09:05:02 +0200 Received: from laforge by sunbeam.gnumonks.org with local (Exim 4.34) id 1C387z-0000Rd-1u; Fri, 03 Sep 2004 09:04:55 +0200 Date: Fri, 3 Sep 2004 09:04:55 +0200 From: Harald Welte To: David Miller Cc: Netfilter Development Mailinglist , netdev@oss.sgi.com Subject: [PATCH 2.4] 2/2: Fix NAT helper locking Message-ID: <20040903070455.GS26263@sunbeam.de.gnumonks.org> Mail-Followup-To: Harald Welte , David Miller , Netfilter Development Mailinglist , netdev@oss.sgi.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qgEfXXHyyarqcYJd" Content-Disposition: inline User-Agent: Mutt/1.5.6+20040818i X-archive-position: 8374 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: laforge@netfilter.org Precedence: bulk X-list: netdev --qgEfXXHyyarqcYJd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Dave! This is the second of a two part patch. This part fixes the locking in NAT helpers. Please apply, Thanks. # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/08/08 12:49:20+02:00 kaber@coreworks.de=20 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers # =20 # There is a possible deadlock condition with conntrack/nat-helpers: # =20 # CPU1: # conntrack-helper:help: lock(private_lock) # ip_conntrack_expect_related: write_lock(ip_conntrack_lock) # =20 # CPU2: # nat-core:do_bindings: read_lock(ip_conntrack_lock) # nat-helper:help: lock(private_lock) # =20 # The lock in the nat-helper is unneccessary because the expectation # is never changed and is protected by ip_conntrack_lock. # =20 # Signed-off-by: Patrick McHardy # Signed-off-by: Harald Welte #=20 # net/ipv4/netfilter/ip_nat_irc.c # 2004/08/08 12:49:15+02:00 kaber@coreworks.de +1 -17 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # net/ipv4/netfilter/ip_nat_ftp.c # 2004/08/08 12:49:15+02:00 kaber@coreworks.de +1 -19 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # net/ipv4/netfilter/ip_conntrack_irc.c # 2004/08/08 12:49:15+02:00 kaber@coreworks.de +0 -8 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # net/ipv4/netfilter/ip_conntrack_ftp.c # 2004/08/08 12:49:15+02:00 kaber@coreworks.de +3 -6 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # include/linux/netfilter_ipv4/ip_conntrack_irc.h # 2004/08/08 12:49:15+02:00 kaber@coreworks.de +0 -5 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 # include/linux/netfilter_ipv4/ip_conntrack_ftp.h # 2004/08/08 12:49:15+02:00 kaber@coreworks.de +0 -5 # [NETFILTER]: Fix deadlock condition in conntrack/nat-helpers #=20 diff -Nru a/include/linux/netfilter_ipv4/ip_conntrack_ftp.h b/include/linux= /netfilter_ipv4/ip_conntrack_ftp.h --- a/include/linux/netfilter_ipv4/ip_conntrack_ftp.h 2004-08-08 12:49:45 += 02:00 +++ b/include/linux/netfilter_ipv4/ip_conntrack_ftp.h 2004-08-08 12:49:45 += 02:00 @@ -4,11 +4,6 @@ =20 #ifdef __KERNEL__ =20 -#include - -/* Protects ftp part of conntracks */ -DECLARE_LOCK_EXTERN(ip_ftp_lock); - #define FTP_PORT 21 =20 #endif /* __KERNEL__ */ diff -Nru a/include/linux/netfilter_ipv4/ip_conntrack_irc.h b/include/linux= /netfilter_ipv4/ip_conntrack_irc.h --- a/include/linux/netfilter_ipv4/ip_conntrack_irc.h 2004-08-08 12:49:45 += 02:00 +++ b/include/linux/netfilter_ipv4/ip_conntrack_irc.h 2004-08-08 12:49:45 += 02:00 @@ -33,17 +33,12 @@ =20 #ifdef __KERNEL__ =20 -#include - #define IRC_PORT 6667 =20 struct dccproto { char* match; int matchlen; }; - -/* Protects irc part of conntracks */ -DECLARE_LOCK_EXTERN(ip_irc_lock); =20 #endif /* __KERNEL__ */ =20 diff -Nru a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_c= onntrack_ftp.c --- a/net/ipv4/netfilter/ip_conntrack_ftp.c 2004-08-08 12:49:45 +02:00 +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c 2004-08-08 12:49:45 +02:00 @@ -11,7 +11,7 @@ #include #include =20 -DECLARE_LOCK(ip_ftp_lock); +static DECLARE_LOCK(ip_ftp_lock); struct module *ip_conntrack_ftp =3D THIS_MODULE; =20 #define MAX_PORTS 8 @@ -338,7 +338,6 @@ memset(&expect, 0, sizeof(expect)); =20 /* Update the ftp info */ - LOCK_BH(&ip_ftp_lock); if (htonl((array[0] << 24) | (array[1] << 16) | (array[2] << 8) | array[3= ]) =3D=3D ct->tuplehash[dir].tuple.src.ip) { exp->seq =3D ntohl(tcph->seq) + matchoff; @@ -358,7 +357,8 @@ for reporting this potential problem (DMZ machines opening holes to internal networks, or the packet filter itself). */ - if (!loose) goto out; + if (!loose) + return NF_ACCEPT; } =20 exp->tuple =3D ((struct ip_conntrack_tuple) @@ -376,9 +376,6 @@ =20 /* Ignore failure; should only happen with NAT */ ip_conntrack_expect_related(ct, &expect); - out: - UNLOCK_BH(&ip_ftp_lock); - return NF_ACCEPT; } =20 diff -Nru a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_c= onntrack_irc.c --- a/net/ipv4/netfilter/ip_conntrack_irc.c 2004-08-08 12:49:45 +02:00 +++ b/net/ipv4/netfilter/ip_conntrack_irc.c 2004-08-08 12:49:45 +02:00 @@ -29,7 +29,6 @@ #include #include =20 -#include #include #include =20 @@ -61,7 +60,6 @@ }; #define MINMATCHLEN 5 =20 -DECLARE_LOCK(ip_irc_lock); struct module *ip_conntrack_irc =3D THIS_MODULE; =20 #if 0 @@ -208,8 +206,6 @@ =09 memset(&expect, 0, sizeof(expect)); =20 - LOCK_BH(&ip_irc_lock); - /* save position of address in dcc string, * neccessary for NAT */ DEBUGP("tcph->seq =3D %u\n", tcph->seq); @@ -236,8 +232,6 @@ ntohs(exp->tuple.dst.u.tcp.port)); =20 ip_conntrack_expect_related(ct, &expect); - UNLOCK_BH(&ip_irc_lock); - return NF_ACCEPT; } /* for .. NUM_DCCPROTO */ } /* while data < ... */ @@ -314,8 +308,6 @@ ip_conntrack_helper_unregister(&irc_helpers[i]); } } - -EXPORT_SYMBOL(ip_irc_lock); =20 module_init(init); module_exit(fini); diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp= =2Ec --- a/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 12:49:45 +02:00 +++ b/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 12:49:45 +02:00 @@ -24,8 +24,6 @@ MODULE_PARM(ports, "1-" __MODULE_STRING(MAX_PORTS) "i"); #endif =20 -DECLARE_LOCK_EXTERN(ip_ftp_lock); - /* FIXME: Time out? --RR */ =20 static unsigned int @@ -48,8 +46,6 @@ DEBUGP("nat_expected: We have a connection!\n"); exp_ftp_info =3D &ct->master->help.exp_ftp_info; =20 - LOCK_BH(&ip_ftp_lock); - if (exp_ftp_info->ftptype =3D=3D IP_CT_FTP_PORT || exp_ftp_info->ftptype =3D=3D IP_CT_FTP_EPRT) { /* PORT command: make connection go to the client. */ @@ -64,7 +60,6 @@ DEBUGP("nat_expected: PASV cmd. %u.%u.%u.%u->%u.%u.%u.%u\n", NIPQUAD(newsrcip), NIPQUAD(newdstip)); } - UNLOCK_BH(&ip_ftp_lock); =20 if (HOOK2MANIP(hooknum) =3D=3D IP_NAT_MANIP_SRC) newip =3D newsrcip; @@ -100,8 +95,6 @@ { char buffer[sizeof("nnn,nnn,nnn,nnn,nnn,nnn")]; =20 - MUST_BE_LOCKED(&ip_ftp_lock); - sprintf(buffer, "%u,%u,%u,%u,%u,%u", NIPQUAD(newip), port>>8, port&0xFF); =20 @@ -123,8 +116,6 @@ { char buffer[sizeof("|1|255.255.255.255|65535|")]; =20 - MUST_BE_LOCKED(&ip_ftp_lock); - sprintf(buffer, "|1|%u.%u.%u.%u|%u|", NIPQUAD(newip), port); =20 DEBUGP("calling ip_nat_mangle_tcp_packet\n"); @@ -145,8 +136,6 @@ { char buffer[sizeof("|||65535|")]; =20 - MUST_BE_LOCKED(&ip_ftp_lock); - sprintf(buffer, "|||%u|", port); =20 DEBUGP("calling ip_nat_mangle_tcp_packet\n"); @@ -178,7 +167,6 @@ u_int16_t port; struct ip_conntrack_tuple newtuple; =20 - MUST_BE_LOCKED(&ip_ftp_lock); DEBUGP("FTP_NAT: seq %u + %u in %u\n", expect->seq, exp_ftp_info->len, ntohl(tcph->seq)); @@ -257,15 +245,12 @@ } =20 datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; - LOCK_BH(&ip_ftp_lock); /* If it's in the right range... */ if (between(exp->seq + exp_ftp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!ftp_data_fixup(exp_ftp_info, ct, pskb, ctinfo, exp)) { - UNLOCK_BH(&ip_ftp_lock); + if (!ftp_data_fixup(exp_ftp_info, ct, pskb, ctinfo, exp)) return NF_DROP; - } } else { /* Half a match? This means a partial retransmisison. It's a cracker being funky. */ @@ -275,11 +260,8 @@ ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } - UNLOCK_BH(&ip_ftp_lock); return NF_DROP; } - UNLOCK_BH(&ip_ftp_lock); - return NF_ACCEPT; } =20 diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc= =2Ec --- a/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 12:49:45 +02:00 +++ b/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 12:49:45 +02:00 @@ -46,9 +46,6 @@ MODULE_PARM_DESC(ports, "port numbers of IRC servers"); #endif =20 -/* protects irc part of conntracks */ -DECLARE_LOCK_EXTERN(ip_irc_lock); - /* FIXME: Time out? --RR */ =20 static unsigned int @@ -104,8 +101,6 @@ /* "4294967296 65635 " */ char buffer[18]; =20 - MUST_BE_LOCKED(&ip_irc_lock); - DEBUGP("IRC_NAT: info (seq %u + %u) in %u\n", expect->seq, exp_irc_info->len, ntohl(tcph->seq)); @@ -113,11 +108,6 @@ newip =3D ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; =20 /* Alter conntrack's expectations. */ - - /* We can read expect here without conntrack lock, since it's - only set in ip_conntrack_irc, with ip_irc_lock held - writable */ - t =3D expect->tuple; t.dst.ip =3D newip; for (port =3D exp_irc_info->port; port !=3D 0; port++) { @@ -187,15 +177,12 @@ DEBUGP("got beyond not touching\n"); =20 datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; - LOCK_BH(&ip_irc_lock); /* Check wether the whole IP/address pattern is carried in the payload */ if (between(exp->seq + exp_irc_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!irc_data_fixup(exp_irc_info, ct, pskb, ctinfo, exp)) { - UNLOCK_BH(&ip_irc_lock); + if (!irc_data_fixup(exp_irc_info, ct, pskb, ctinfo, exp)) return NF_DROP; - } } else {=20 /* Half a match? This means a partial retransmisison. It's a cracker being funky. */ @@ -206,11 +193,8 @@ ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } - UNLOCK_BH(&ip_irc_lock); return NF_DROP; } - UNLOCK_BH(&ip_irc_lock); - return NF_ACCEPT; } =20 --=20 - Harald Welte http://www.netfilter.org/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie --qgEfXXHyyarqcYJd Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOBeXXaXGVTD0i/8RAjEuAJ41bNu5bI3O7R6UJQskFf5wGN5G9QCfbGDk Joq5HfUvLv0Fokn9mwXPG50= =aVT1 -----END PGP SIGNATURE----- --qgEfXXHyyarqcYJd-- From laforge@netfilter.org Fri Sep 3 00:06:03 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 00:06:13 -0700 (PDT) Received: from coruscant.gnumonks.org (mail@coruscant.franken.de [193.174.159.226]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83762W2025812 for ; Fri, 3 Sep 2004 00:06:02 -0700 Received: from [192.168.200.2] (helo=sunbeam.gnumonks.org) by coruscant.gnumonks.org with esmtp (TLSv1:RC4-SHA:128) (Exim 4.20) id 1C388u-0001lP-Oc; Fri, 03 Sep 2004 09:05:53 +0200 Received: from laforge by sunbeam.gnumonks.org with local (Exim 4.34) id 1C388p-0000Rs-Jh; Fri, 03 Sep 2004 09:05:47 +0200 Date: Fri, 3 Sep 2004 09:05:47 +0200 From: Harald Welte To: Netfilter Development Mailinglist Cc: netdev@oss.sgi.com Subject: [PATCH 2.6] 1/2: Rename NAT helper structures Message-ID: <20040903070547.GT26263@sunbeam.de.gnumonks.org> Mail-Followup-To: Harald Welte , Netfilter Development Mailinglist , netdev@oss.sgi.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Ca23f2aBZR6YDKM9" Content-Disposition: inline User-Agent: Mutt/1.5.6+20040818i X-archive-position: 8375 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: laforge@netfilter.org Precedence: bulk X-list: netdev --Ca23f2aBZR6YDKM9 Content-Type: multipart/mixed; boundary="ngiTnHdmUEG79yp6" Content-Disposition: inline --ngiTnHdmUEG79yp6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I forgot to Cc' the lists with this part of the patchset, here is the forwarded message: --=20 - Harald Welte http://www.netfilter.org/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie --ngiTnHdmUEG79yp6 Content-Type: message/rfc822 Content-Disposition: inline Date: Fri, 3 Sep 2004 09:00:17 +0200 From: Harald Welte To: David Miller Subject: [PATCH 2.6] 1/2: Rename NAT helper structures Message-ID: <20040903070017.GP26263@sunbeam.de.gnumonks.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="6eUvXotnMb6+obQB" Content-Disposition: inline User-Agent: Mutt/1.5.6+20040818i --6eUvXotnMb6+obQB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Dave! This is the first of a two part patch. Part one fixes confusing naming of some NAT helper data structures (ct_ are part of ip_conntrack, exp_ are part of ip_conntrack_expect). This patch is required to make the second apply, which fixes NAT helper locking. # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/08/07 23:30:12+02:00 kaber@coreworks.de=20 # [NETFILTER]: Fix confusing naming in NAT-helpers # # Signed-off-by: Patrick McHardy # Signed-off-by: Harald Welte #=20 # net/ipv4/netfilter/ip_nat_irc.c # 2004/08/07 23:29:48+02:00 kaber@coreworks.de +9 -9 # [NETFILTER]: Fix confusing naming in NAT-helpers #=20 # net/ipv4/netfilter/ip_nat_ftp.c # 2004/08/07 23:29:48+02:00 kaber@coreworks.de +12 -12 # [NETFILTER]: Fix confusing naming in NAT-helpers #=20 diff -Nru a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp= =2Ec --- a/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 01:41:06 +02:00 +++ b/net/ipv4/netfilter/ip_nat_ftp.c 2004-08-08 01:41:06 +02:00 @@ -177,7 +177,7 @@ [IP_CT_FTP_EPSV] =3D mangle_epsv_packet }; =20 -static int ftp_data_fixup(const struct ip_ct_ftp_expect *ct_ftp_info, +static int ftp_data_fixup(const struct ip_ct_ftp_expect *exp_ftp_info, struct ip_conntrack *ct, struct sk_buff **pskb, enum ip_conntrack_info ctinfo, @@ -191,13 +191,13 @@ =20 MUST_BE_LOCKED(&ip_ftp_lock); DEBUGP("FTP_NAT: seq %u + %u in %u\n", - expect->seq, ct_ftp_info->len, + expect->seq, exp_ftp_info->len, ntohl(tcph->seq)); =20 /* Change address inside packet to match way we're mapping this connection. */ - if (ct_ftp_info->ftptype =3D=3D IP_CT_FTP_PASV - || ct_ftp_info->ftptype =3D=3D IP_CT_FTP_EPSV) { + if (exp_ftp_info->ftptype =3D=3D IP_CT_FTP_PASV + || exp_ftp_info->ftptype =3D=3D IP_CT_FTP_EPSV) { /* PASV/EPSV response: must be where client thinks server is */ newip =3D ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip; @@ -219,7 +219,7 @@ newtuple.src.u.tcp.port =3D expect->tuple.src.u.tcp.port; =20 /* Try to get same port: if not, try to change it. */ - for (port =3D ct_ftp_info->port; port !=3D 0; port++) { + for (port =3D exp_ftp_info->port; port !=3D 0; port++) { newtuple.dst.u.tcp.port =3D htons(port); =20 if (ip_conntrack_change_expect(expect, &newtuple) =3D=3D 0) @@ -228,9 +228,9 @@ if (port =3D=3D 0) return 0; =20 - if (!mangle[ct_ftp_info->ftptype](pskb, newip, port, + if (!mangle[exp_ftp_info->ftptype](pskb, newip, port, expect->seq - ntohl(tcph->seq), - ct_ftp_info->len, ct, ctinfo)) + exp_ftp_info->len, ct, ctinfo)) return 0; =20 return 1; @@ -247,12 +247,12 @@ struct tcphdr *tcph =3D (void *)iph + iph->ihl*4; unsigned int datalen; int dir; - struct ip_ct_ftp_expect *ct_ftp_info; + struct ip_ct_ftp_expect *exp_ftp_info; =20 if (!exp) DEBUGP("ip_nat_ftp: no exp!!"); =20 - ct_ftp_info =3D &exp->help.exp_ftp_info; + exp_ftp_info =3D &exp->help.exp_ftp_info; =20 /* Only mangle things once: original direction in POST_ROUTING and reply direction on PRE_ROUTING. */ @@ -270,10 +270,10 @@ datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; LOCK_BH(&ip_ftp_lock); /* If it's in the right range... */ - if (between(exp->seq + ct_ftp_info->len, + if (between(exp->seq + exp_ftp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!ftp_data_fixup(ct_ftp_info, ct, pskb, ctinfo, exp)) { + if (!ftp_data_fixup(exp_ftp_info, ct, pskb, ctinfo, exp)) { UNLOCK_BH(&ip_ftp_lock); return NF_DROP; } @@ -282,7 +282,7 @@ It's a cracker being funky. */ if (net_ratelimit()) { printk("FTP_NAT: partial packet %u/%u in %u/%u\n", - exp->seq, ct_ftp_info->len, + exp->seq, exp_ftp_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } diff -Nru a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc= =2Ec --- a/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 01:41:06 +02:00 +++ b/net/ipv4/netfilter/ip_nat_irc.c 2004-08-08 01:41:06 +02:00 @@ -87,7 +87,7 @@ return ip_nat_setup_info(ct, &mr, hooknum); } =20 -static int irc_data_fixup(const struct ip_ct_irc_expect *ct_irc_info, +static int irc_data_fixup(const struct ip_ct_irc_expect *exp_irc_info, struct ip_conntrack *ct, struct sk_buff **pskb, enum ip_conntrack_info ctinfo, @@ -105,7 +105,7 @@ MUST_BE_LOCKED(&ip_irc_lock); =20 DEBUGP("IRC_NAT: info (seq %u + %u) in %u\n", - expect->seq, ct_irc_info->len, + expect->seq, exp_irc_info->len, ntohl(tcph->seq)); =20 newip =3D ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip; @@ -118,7 +118,7 @@ =20 t =3D expect->tuple; t.dst.ip =3D newip; - for (port =3D ct_irc_info->port; port !=3D 0; port++) { + for (port =3D exp_irc_info->port; port !=3D 0; port++) { t.dst.u.tcp.port =3D htons(port); if (ip_conntrack_change_expect(expect, &t) =3D=3D 0) { DEBUGP("using port %d", port); @@ -148,7 +148,7 @@ =20 return ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,=20 expect->seq - ntohl(tcph->seq), - ct_irc_info->len, buffer,=20 + exp_irc_info->len, buffer,=20 strlen(buffer)); } =20 @@ -163,12 +163,12 @@ struct tcphdr *tcph =3D (void *) iph + iph->ihl * 4; unsigned int datalen; int dir; - struct ip_ct_irc_expect *ct_irc_info; + struct ip_ct_irc_expect *exp_irc_info; =20 if (!exp) DEBUGP("ip_nat_irc: no exp!!"); =09 - ct_irc_info =3D &exp->help.exp_irc_info; + exp_irc_info =3D &exp->help.exp_irc_info; =20 /* Only mangle things once: original direction in POST_ROUTING and reply direction on PRE_ROUTING. */ @@ -187,10 +187,10 @@ datalen =3D (*pskb)->len - iph->ihl * 4 - tcph->doff * 4; LOCK_BH(&ip_irc_lock); /* Check whether the whole IP/address pattern is carried in the payload */ - if (between(exp->seq + ct_irc_info->len, + if (between(exp->seq + exp_irc_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen)) { - if (!irc_data_fixup(ct_irc_info, ct, pskb, ctinfo, exp)) { + if (!irc_data_fixup(exp_irc_info, ct, pskb, ctinfo, exp)) { UNLOCK_BH(&ip_irc_lock); return NF_DROP; } @@ -200,7 +200,7 @@ if (net_ratelimit()) { printk ("IRC_NAT: partial packet %u/%u in %u/%u\n", - exp->seq, ct_irc_info->len, + exp->seq, exp_irc_info->len, ntohl(tcph->seq), ntohl(tcph->seq) + datalen); } --=20 - Harald Welte http://www.netfilter.org/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie --6eUvXotnMb6+obQB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOBaBXaXGVTD0i/8RAotRAJ90N4o+BXwF6PAX/6OQANliZbjCggCgquzv tIf1zDcRfMVMkcFaTJTcVpI= =zNZp -----END PGP SIGNATURE----- --6eUvXotnMb6+obQB-- --ngiTnHdmUEG79yp6-- --Ca23f2aBZR6YDKM9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOBfLXaXGVTD0i/8RAvWeAJ9cvcIu6ttmq5c5FpcZDQywBqlc8QCeJn44 c0xfFnKWBmgfVAoQS8qkUrM= =VeXZ -----END PGP SIGNATURE----- --Ca23f2aBZR6YDKM9-- From davem@davemloft.net Fri Sep 3 00:26:13 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 00:26:25 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i837QCP7030073 for ; Fri, 3 Sep 2004 00:26:13 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C38RJ-0008SX-00; Fri, 03 Sep 2004 00:24:53 -0700 Date: Fri, 3 Sep 2004 00:24:53 -0700 From: "David S. Miller" To: Harald Welte Cc: netfilter-devel@lists.netfilter.org, netdev@oss.sgi.com Subject: Re: [PATCH 2.6] 2/2: Fix NAT helper locking Message-Id: <20040903002453.77beee16.davem@davemloft.net> In-Reply-To: <20040903070234.GQ26263@sunbeam.de.gnumonks.org> References: <20040903070234.GQ26263@sunbeam.de.gnumonks.org> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8376 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev On Fri, 3 Sep 2004 09:02:34 +0200 Harald Welte wrote: > This is the second of a two part patch. > > This part fixes the locking in NAT helpers. > > Please apply, Thanks. Applied both patches, but the first had serious offsets and the second had to be applied by hand due to rejects against the current 2.6.x sources. Ummm... wow what ancient tree did you patch against Harald? The tree you patched against didn't even have the skb_header_pointer() changes in it, that's caveman era :-) That's what caused the rejects. Anyways, I merged it all in cleanly. Thanks. From davem@davemloft.net Fri Sep 3 00:28:30 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 00:28:37 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i837SUaF030315 for ; Fri, 3 Sep 2004 00:28:30 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C38TY-0008TQ-00; Fri, 03 Sep 2004 00:27:12 -0700 Date: Fri, 3 Sep 2004 00:27:12 -0700 From: "David S. Miller" To: Harald Welte Cc: netfilter-devel@lists.netfilter.org, netdev@oss.sgi.com Subject: Re: [PATCH 2.4] 2/2: Fix NAT helper locking Message-Id: <20040903002712.4fdf8194.davem@davemloft.net> In-Reply-To: <20040903070455.GS26263@sunbeam.de.gnumonks.org> References: <20040903070455.GS26263@sunbeam.de.gnumonks.org> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8377 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev On Fri, 3 Sep 2004 09:04:55 +0200 Harald Welte wrote: > This is the second of a two part patch. > > This part fixes the locking in NAT helpers. These 2.4.x variants of the NAT locking fixes are applied as well. Thanks. From herbert@gondor.apana.org.au Fri Sep 3 06:37:04 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 06:37:13 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83Db1Yk015955 for ; Fri, 3 Sep 2004 06:37:03 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1C3EEu-0005sv-00; Fri, 03 Sep 2004 23:36:28 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1C3EEp-000630-00; Fri, 03 Sep 2004 23:36:23 +1000 Date: Fri, 3 Sep 2004 23:36:23 +1000 To: "David S. Miller" Cc: shemminger@osdl.org, netdev@oss.sgi.com Subject: Re: neigh_create/inetdev_destroy race? Message-ID: <20040903133623.GA23179@gondor.apana.org.au> References: <20040814050848.GA11874@gondor.apana.org.au> <20040814062703.GA4806@gondor.apana.org.au> <20040815191450.77532d5d.davem@redhat.com> <20040816105131.GA11299@gondor.apana.org.au> <20040828234201.79556f6e.davem@davemloft.net> <20040829065031.GA786@gondor.apana.org.au> <20040830230820.7514985d.davem@davemloft.net> <20040831104139.GA2124@gondor.apana.org.au> <20040901222118.0ce4bcc6.davem@davemloft.net> <20040902130605.GA32570@gondor.apana.org.au> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: <20040902130605.GA32570@gondor.apana.org.au> User-Agent: Mutt/1.5.6+20040722i From: Herbert Xu X-archive-position: 8378 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 02, 2004 at 11:06:05PM +1000, herbert wrote: > > > Can you work on the next bit you mentioned, making > > sure the corresponding idev is still alive when we add > > a neighbour with its neigh_parms to the hash table? > > Sure. Actually I prefer to do it by ref counting neigh_parms directly. > I'll send you a patch soon. Here is the patch. I've added a refcnt on neigh_parms as well as a dead flag. The latter is checked under the tbl_lock before adding a neigh entry to the hash table. The non-trivial bit of the patch is the first chunk of net/core/neighbour.c. I removed that line because not doing so would mean that I have to drop the reference to the parms right there. That would've lead to race conditions since many places dereference neigh->parms without holding locks. It's also unnecessary to reset n->parms since we're no longer in a hurry to see it go due to the new ref counting. You'll also notice that I've put all dereferences of dev->*_ptr under the rcu_read_lock(). Without this we may get a neigh_parms that's already been released. Incidentally a lot of these places were racy even before the RCU change. For example, in the IPv6 case neigh->parms may be set to a value that's just been released. Finally in order to make sure that all stale entries are purged as quickly as possible I've added neigh_ifdown/arp_ifdown calls after every neigh_parms_release call. In many cases we now have multiple calls to neigh_ifdown in the shutdown path. I didn't remove the earlier calls because there may be hidden dependencies for them to be there. Once the respective maintainers have looked at them we can probably remove most of them. Signed-off-by: Herbert Xu Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p ===== drivers/s390/net/qeth_main.c 1.13 vs edited ===== --- 1.13/drivers/s390/net/qeth_main.c 2004-08-27 17:02:36 +10:00 +++ edited/drivers/s390/net/qeth_main.c 2004-09-03 23:16:30 +10:00 @@ -6710,19 +6710,28 @@ qeth_arp_constructor(struct neighbour *neigh) { struct net_device *dev = neigh->dev; - struct in_device *in_dev = in_dev_get(dev); + struct in_device *in_dev; + struct neigh_parms *parms; - if (in_dev == NULL) - return -EINVAL; if (!qeth_verify_dev(dev)) { - in_dev_put(in_dev); return qeth_old_arp_constructor(neigh); } + rcu_read_lock(); + in_dev = __in_dev_get(dev); + if (in_dev == NULL) { + rcu_read_unlock(); + return -EINVAL; + } + + parms = in_dev->arp_parms; + if (parms) { + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); + } + rcu_read_unlock(); + neigh->type = inet_addr_type(*(u32 *) neigh->primary_key); - if (in_dev->arp_parms) - neigh->parms = in_dev->arp_parms; - in_dev_put(in_dev); neigh->nud_state = NUD_NOARP; neigh->ops = arp_direct_ops; neigh->output = neigh->ops->queue_xmit; ===== include/net/neighbour.h 1.9 vs edited ===== --- 1.9/include/net/neighbour.h 2004-09-02 15:03:13 +10:00 +++ edited/include/net/neighbour.h 2004-09-03 23:15:51 +10:00 @@ -67,6 +67,8 @@ void *sysctl_table; + int dead; + atomic_t refcnt; struct rcu_head rcu_head; int base_reachable_time; @@ -199,6 +201,7 @@ extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); +extern void neigh_parms_destroy(struct neigh_parms *parms); extern unsigned long neigh_rand_reach_time(unsigned long base); extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, @@ -219,6 +222,23 @@ char *p_name, proc_handler *proc_handler); extern void neigh_sysctl_unregister(struct neigh_parms *p); + +static inline void __neigh_parms_put(struct neigh_parms *parms) +{ + atomic_dec(&parms->refcnt); +} + +static inline void neigh_parms_put(struct neigh_parms *parms) +{ + if (atomic_dec_and_test(&parms->refcnt)) + neigh_parms_destroy(parms); +} + +static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms) +{ + atomic_inc(&parms->refcnt); + return parms; +} /* * Neighbour references ===== net/atm/clip.c 1.36 vs edited ===== --- 1.36/net/atm/clip.c 2004-08-16 12:05:46 +10:00 +++ edited/net/atm/clip.c 2004-09-03 23:16:55 +10:00 @@ -26,6 +26,7 @@ #include #include #include +#include #include /* for struct rtable and routing */ #include /* icmp_send */ #include /* for HZ */ @@ -311,13 +312,27 @@ { struct atmarp_entry *entry = NEIGH2ENTRY(neigh); struct net_device *dev = neigh->dev; - struct in_device *in_dev = dev->ip_ptr; + struct in_device *in_dev; + struct neigh_parms *parms; DPRINTK("clip_constructor (neigh %p, entry %p)\n",neigh,entry); - if (!in_dev) return -EINVAL; neigh->type = inet_addr_type(entry->ip); if (neigh->type != RTN_UNICAST) return -EINVAL; - if (in_dev->arp_parms) neigh->parms = in_dev->arp_parms; + + rcu_read_lock(); + in_dev = __in_dev_get(dev); + if (!in_dev) { + rcu_read_unlock(); + return -EINVAL; + } + + parms = in_dev->arp_parms; + if (parms) { + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); + } + rcu_read_unlock(); + neigh->ops = &clip_neigh_ops; neigh->output = neigh->nud_state & NUD_VALID ? neigh->ops->connected_output : neigh->ops->output; ===== net/core/neighbour.c 1.29 vs edited ===== --- 1.29/net/core/neighbour.c 2004-09-02 15:03:13 +10:00 +++ edited/net/core/neighbour.c 2004-09-03 23:17:17 +10:00 @@ -227,7 +227,6 @@ we must kill timers etc. and move it to safe state. */ - n->parms = &tbl->parms; skb_queue_purge(&n->arp_queue); n->output = neigh_blackhole; if (n->nud_state & NUD_VALID) @@ -273,7 +272,7 @@ n->updated = n->used = now; n->nud_state = NUD_NONE; n->output = neigh_blackhole; - n->parms = &tbl->parms; + n->parms = neigh_parms_clone(&tbl->parms); init_timer(&n->timer); n->timer.function = neigh_timer_handler; n->timer.data = (unsigned long)n; @@ -340,12 +339,16 @@ hash_val = tbl->hash(pkey, dev); write_lock_bh(&tbl->lock); + if (n->parms->dead) { + rc = ERR_PTR(-EINVAL); + goto out_tbl_unlock; + } + for (n1 = tbl->hash_buckets[hash_val]; n1; n1 = n1->next) { if (dev == n1->dev && !memcmp(n1->primary_key, pkey, key_len)) { neigh_hold(n1); - write_unlock_bh(&tbl->lock); rc = n1; - goto out_neigh_release; + goto out_tbl_unlock; } } @@ -358,6 +361,8 @@ rc = n; out: return rc; +out_tbl_unlock: + write_unlock_bh(&tbl->lock); out_neigh_release: neigh_release(n); goto out; @@ -494,6 +499,7 @@ skb_queue_purge(&neigh->arp_queue); dev_put(neigh->dev); + neigh_parms_put(neigh->parms); NEIGH_PRINTK2("neigh %p is destroyed.\n", neigh); @@ -1120,6 +1126,7 @@ if (p) { memcpy(p, &tbl->parms, sizeof(*p)); p->tbl = tbl; + atomic_set(&p->refcnt, 1); INIT_RCU_HEAD(&p->rcu_head); p->reachable_time = neigh_rand_reach_time(p->base_reachable_time); @@ -1141,7 +1148,7 @@ struct neigh_parms *parms = container_of(head, struct neigh_parms, rcu_head); - kfree(parms); + neigh_parms_put(parms); } void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms) @@ -1154,6 +1161,7 @@ for (p = &tbl->parms.next; *p; p = &(*p)->next) { if (*p == parms) { *p = parms->next; + parms->dead = 1; write_unlock_bh(&tbl->lock); call_rcu(&parms->rcu_head, neigh_rcu_free_parms); return; @@ -1163,11 +1171,17 @@ NEIGH_PRINTK1("neigh_parms_release: not found\n"); } +void neigh_parms_destroy(struct neigh_parms *parms) +{ + kfree(parms); +} + void neigh_table_init(struct neigh_table *tbl) { unsigned long now = jiffies; + atomic_set(&tbl->parms.refcnt, 1); INIT_RCU_HEAD(&tbl->parms.rcu_head); tbl->parms.reachable_time = neigh_rand_reach_time(tbl->parms.base_reachable_time); ===== net/decnet/dn_dev.c 1.24 vs edited ===== --- 1.24/net/decnet/dn_dev.c 2004-08-19 07:36:05 +10:00 +++ edited/net/decnet/dn_dev.c 2004-09-03 22:19:04 +10:00 @@ -1215,6 +1215,7 @@ dev->dn_ptr = NULL; neigh_parms_release(&dn_neigh_table, dn_db->neigh_parms); + neigh_ifdown(&dn_neigh_table, dev); if (dn_db->router) neigh_release(dn_db->router); ===== net/decnet/dn_neigh.c 1.10 vs edited ===== --- 1.10/net/decnet/dn_neigh.c 2004-01-26 16:13:52 +11:00 +++ edited/net/decnet/dn_neigh.c 2004-09-03 23:17:26 +10:00 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -134,13 +135,22 @@ { struct net_device *dev = neigh->dev; struct dn_neigh *dn = (struct dn_neigh *)neigh; - struct dn_dev *dn_db = (struct dn_dev *)dev->dn_ptr; + struct dn_dev *dn_db; + struct neigh_parms *parms; - if (dn_db == NULL) + rcu_read_lock(); + dn_db = dev->dn_ptr; + if (dn_db == NULL) { + rcu_read_unlock(); return -EINVAL; + } - if (dn_db->neigh_parms) - neigh->parms = dn_db->neigh_parms; + parms = dn_db->neigh_parms; + if (parms) { + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); + } + rcu_read_unlock(); if (dn_db->use_long) neigh->ops = &dn_long_ops; ===== net/ipv4/arp.c 1.43 vs edited ===== --- 1.43/net/ipv4/arp.c 2004-09-02 11:12:37 +10:00 +++ edited/net/ipv4/arp.c 2004-09-03 23:17:42 +10:00 @@ -96,6 +96,7 @@ #include #include #include +#include #ifdef CONFIG_SYSCTL #include #endif @@ -237,16 +238,24 @@ { u32 addr = *(u32*)neigh->primary_key; struct net_device *dev = neigh->dev; - struct in_device *in_dev = in_dev_get(dev); - - if (in_dev == NULL) - return -EINVAL; + struct in_device *in_dev; + struct neigh_parms *parms; neigh->type = inet_addr_type(addr); - if (in_dev->arp_parms) - neigh->parms = in_dev->arp_parms; - in_dev_put(in_dev); + rcu_read_lock(); + in_dev = __in_dev_get(dev); + if (in_dev == NULL) { + rcu_read_unlock(); + return -EINVAL; + } + + parms = in_dev->arp_parms; + if (parms) { + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); + } + rcu_read_unlock(); if (dev->hard_header == NULL) { neigh->nud_state = NUD_NOARP; ===== net/ipv4/devinet.c 1.36 vs edited ===== --- 1.36/net/ipv4/devinet.c 2004-08-16 16:11:59 +10:00 +++ edited/net/ipv4/devinet.c 2004-09-03 22:19:04 +10:00 @@ -184,6 +184,7 @@ static void inetdev_destroy(struct in_device *in_dev) { struct in_ifaddr *ifa; + struct net_device *dev; ASSERT_RTNL(); @@ -200,12 +201,15 @@ devinet_sysctl_unregister(&in_dev->cnf); #endif - in_dev->dev->ip_ptr = NULL; + dev = in_dev->dev; + dev->ip_ptr = NULL; #ifdef CONFIG_SYSCTL neigh_sysctl_unregister(in_dev->arp_parms); #endif neigh_parms_release(&arp_tbl, in_dev->arp_parms); + arp_ifdown(dev); + call_rcu(&in_dev->rcu_head, in_dev_rcu_put); } ===== net/ipv6/addrconf.c 1.106 vs edited ===== --- 1.106/net/ipv6/addrconf.c 2004-08-17 12:25:06 +10:00 +++ edited/net/ipv6/addrconf.c 2004-09-03 23:04:03 +10:00 @@ -2072,6 +2072,7 @@ neigh_sysctl_unregister(idev->nd_parms); #endif neigh_parms_release(&nd_tbl, idev->nd_parms); + neigh_ifdown(&nd_tbl, dev); in6_dev_put(idev); } return 0; ===== net/ipv6/ndisc.c 1.87 vs edited ===== --- 1.87/net/ipv6/ndisc.c 2004-08-08 16:43:41 +10:00 +++ edited/net/ipv6/ndisc.c 2004-09-03 23:17:56 +10:00 @@ -58,6 +58,7 @@ #include #include #include +#include #ifdef CONFIG_SYSCTL #include #endif @@ -284,14 +285,23 @@ { struct in6_addr *addr = (struct in6_addr*)&neigh->primary_key; struct net_device *dev = neigh->dev; - struct inet6_dev *in6_dev = in6_dev_get(dev); + struct inet6_dev *in6_dev; + struct neigh_parms *parms; int is_multicast = ipv6_addr_is_multicast(addr); - if (in6_dev == NULL) + rcu_read_lock(); + in6_dev = in6_dev_get(dev); + if (in6_dev == NULL) { + rcu_read_unlock(); return -EINVAL; + } - if (in6_dev->nd_parms) - neigh->parms = in6_dev->nd_parms; + parms = in6_dev->nd_parms; + if (parms) { + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); + } + rcu_read_unlock(); neigh->type = is_multicast ? RTN_MULTICAST : RTN_UNICAST; if (dev->hard_header == NULL) { --huq684BweRXVnRxX-- From stigge@antcom.de Fri Sep 3 07:07:25 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 07:07:30 -0700 (PDT) Received: from stigge.org (pD9E7EEC6.dip.t-dialin.net [217.231.238.198]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83E7NSE017083 for ; Fri, 3 Sep 2004 07:07:25 -0700 Received: (qmail 20881 invoked from network); 3 Sep 2004 14:07:07 -0000 Received: from unknown (HELO atari.stigge.org) (192.168.1.99) by sbo.stigge.org with SMTP; 3 Sep 2004 14:07:07 -0000 Received: from localhost (localhost [127.0.0.1]) by atari.stigge.org (Postfix) with ESMTP id D788910034F50; Fri, 3 Sep 2004 16:07:06 +0200 (CEST) Subject: Re: Debian #240812 - tg3 problems with NFS From: Roland Stigge To: "David S. Miller" Cc: Christoph Hellwig , netdev@oss.sgi.com, 240812@bugs.debian.org In-Reply-To: <20040819102941.70c94182.davem@redhat.com> References: <20040819161933.GA27114@lst.de> <20040819170619.GA28226@lst.de> <20040819102941.70c94182.davem@redhat.com> Content-Type: text/plain Organization: Antcom Message-Id: <1094220426.4139.5.camel@atari.stigge.org> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 03 Sep 2004 16:07:06 +0200 Content-Transfer-Encoding: 7bit X-archive-position: 8379 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: stigge@antcom.de Precedence: bulk X-list: netdev On Thu, 2004-08-19 at 19:29, David S. Miller wrote: > Maybe it's checksum offload related. Try: > > ethtool -K $(DEVICE_NAME) rx off tx off sg off tso off > > Does that make the problem go away? No. From kaber@trash.net Fri Sep 3 08:54:11 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 08:54:17 -0700 (PDT) Received: from gw.localnet ([62.206.217.67]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83FsAOE024381 for ; Fri, 3 Sep 2004 08:54:11 -0700 Received: from [172.16.1.123] (helo=trash.net ident=kaber) by gw.localnet with esmtp (Exim 3.36 #1 (Debian)) id 1C3GSf-0007b8-00; Fri, 03 Sep 2004 17:58:49 +0200 Message-ID: <41389371.2030009@trash.net> Date: Fri, 03 Sep 2004 17:53:21 +0200 From: Patrick McHardy User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5 X-Accept-Language: en MIME-Version: 1.0 To: "David S. Miller" CC: Harald Welte , netfilter-devel@lists.netfilter.org, netdev@oss.sgi.com Subject: Re: [PATCH 2.6] 2/2: Fix NAT helper locking References: <20040903070234.GQ26263@sunbeam.de.gnumonks.org> <20040903002453.77beee16.davem@davemloft.net> In-Reply-To: <20040903002453.77beee16.davem@davemloft.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8380 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: kaber@trash.net Precedence: bulk X-list: netdev David S. Miller wrote: >Applied both patches, but the first had serious offsets >and the second had to be applied by hand due to rejects >against the current 2.6.x sources. > >Ummm... wow what ancient tree did you patch against >Harald? The tree you patched against didn't even have the >skb_header_pointer() changes in it, that's caveman >era :-) That's what caused the rejects. > > My fault, I put the patches into patch-o-matic about two or three weeks ago and didn't expect they wouldn't apply anymore so quickly :) > >Anyways, I merged it all in cleanly. > Thanks. Patrick From shemminger@osdl.org Fri Sep 3 09:01:24 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 09:01:30 -0700 (PDT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83G1Npv024802 for ; Fri, 3 Sep 2004 09:01:24 -0700 Received: from dell_ss3.pdx.osdl.net (dell_ss3.pdx.osdl.net [172.20.1.60]) by mail.osdl.org (8.11.6/8.11.6) with SMTP id i83G0r120723; Fri, 3 Sep 2004 09:00:53 -0700 Date: Fri, 3 Sep 2004 09:00:53 -0700 From: Stephen Hemminger To: Herbert Xu Cc: "David S. Miller" , netdev@oss.sgi.com Subject: Re: neigh_create/inetdev_destroy race? Message-Id: <20040903090053.22c67bb9@dell_ss3.pdx.osdl.net> In-Reply-To: <20040903133623.GA23179@gondor.apana.org.au> References: <20040814050848.GA11874@gondor.apana.org.au> <20040814062703.GA4806@gondor.apana.org.au> <20040815191450.77532d5d.davem@redhat.com> <20040816105131.GA11299@gondor.apana.org.au> <20040828234201.79556f6e.davem@davemloft.net> <20040829065031.GA786@gondor.apana.org.au> <20040830230820.7514985d.davem@davemloft.net> <20040831104139.GA2124@gondor.apana.org.au> <20040901222118.0ce4bcc6.davem@davemloft.net> <20040902130605.GA32570@gondor.apana.org.au> <20040903133623.GA23179@gondor.apana.org.au> Organization: Open Source Development Lab X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i386-redhat-linux-gnu) X-Face: &@E+xe?c%:&e4D{>f1O<&U>2qwRREG5!}7R4;D<"NO^UI2mJ[eEOA2*3>(`Th.yP,VDPo9$ /`~cw![cmj~~jWe?AHY7D1S+\}5brN0k*NE?pPh_'_d>6;XGG[\KDRViCfumZT3@[ Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8381 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: shemminger@osdl.org Precedence: bulk X-list: netdev On Fri, 3 Sep 2004 23:36:23 +1000 Herbert Xu wrote: > On Thu, Sep 02, 2004 at 11:06:05PM +1000, herbert wrote: > > > > > Can you work on the next bit you mentioned, making > > > sure the corresponding idev is still alive when we add > > > a neighbour with its neigh_parms to the hash table? > > > > Sure. Actually I prefer to do it by ref counting neigh_parms directly. > > I'll send you a patch soon. > > Here is the patch. > > I've added a refcnt on neigh_parms as well as a dead flag. The latter > is checked under the tbl_lock before adding a neigh entry to the hash > table. > > The non-trivial bit of the patch is the first chunk of net/core/neighbour.c. > I removed that line because not doing so would mean that I have to drop > the reference to the parms right there. That would've lead to race > conditions since many places dereference neigh->parms without holding > locks. It's also unnecessary to reset n->parms since we're no longer > in a hurry to see it go due to the new ref counting. > > You'll also notice that I've put all dereferences of dev->*_ptr under > the rcu_read_lock(). Without this we may get a neigh_parms that's > already been released. I haven't looked at the exact code in detail, but don't you need use rcu_dereference() as well to make sure and get the smp_read_barrier_depends on Alpha. From davem@davemloft.net Fri Sep 3 09:19:54 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 09:20:00 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83GJsow025997 for ; Fri, 3 Sep 2004 09:19:54 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C3GlW-0001oW-00; Fri, 03 Sep 2004 09:18:18 -0700 Date: Fri, 3 Sep 2004 09:18:17 -0700 From: "David S. Miller" To: Herbert Xu Cc: shemminger@osdl.org, netdev@oss.sgi.com Subject: Re: neigh_create/inetdev_destroy race? Message-Id: <20040903091817.7b97d090.davem@davemloft.net> In-Reply-To: <20040903133623.GA23179@gondor.apana.org.au> References: <20040814050848.GA11874@gondor.apana.org.au> <20040814062703.GA4806@gondor.apana.org.au> <20040815191450.77532d5d.davem@redhat.com> <20040816105131.GA11299@gondor.apana.org.au> <20040828234201.79556f6e.davem@davemloft.net> <20040829065031.GA786@gondor.apana.org.au> <20040830230820.7514985d.davem@davemloft.net> <20040831104139.GA2124@gondor.apana.org.au> <20040901222118.0ce4bcc6.davem@davemloft.net> <20040902130605.GA32570@gondor.apana.org.au> <20040903133623.GA23179@gondor.apana.org.au> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8382 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev On Fri, 3 Sep 2004 23:36:23 +1000 Herbert Xu wrote: > Here is the patch. Looks great. Yes, I see how the existing cases were racey pre-RCU, it is similar to the sysctl stuff and that area was truly horrible before Stephen and myself redid how generic device destruction works. Patch applied, thanks Herbert. From jeffpc@optonline.net Fri Sep 3 10:07:11 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 10:07:18 -0700 (PDT) Received: from mta8.srv.hcvlny.cv.net (mta8.srv.hcvlny.cv.net [167.206.5.75]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83H7BYf027180 for ; Fri, 3 Sep 2004 10:07:11 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta8.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3H001KI67Q2C@mta8.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Fri, 03 Sep 2004 13:07:02 -0400 (EDT) Date: Fri, 03 Sep 2004 13:06:55 -0400 From: josef Jeff Sipek Subject: [PATCH/RFC 2.6] NET: 64-bit network statistics To: linux-kernel@vger.kernel.org Cc: netdev@oss.sgi.com Message-id: <200409031307.01240.jeffpc@optonline.net> MIME-version: 1.0 Content-type: Text/Plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: KMail/1.6.2 X-archive-position: 8384 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've created a patch that monitors changes to the network statistics variables and keeps internal 64-bit counter. I decided to split it into two parts (patches are to follow in next emails): 1) generic variable monitoring system (watch64) The watch64 system allows the programmer to specify the approximate interval at which he wants his variables checked. If he tries to specify shorter interval than the minimum a default value of HZ/10 is used. To minimize locking, RCU and seqlock are used. On 64-bit systems, all is optimized away. 2) network statistics specific patch (64network) Upon registration of a network device, all the statistics variables are registered with watch64. Additionally, a new proc file is created /proc/net/dev64 displays the 64-bit values as supposed to /proc/net/dev which is left to display the original 32-bit variables for backward compatibility. The sysfs interface (/sys/class/net//statistics/*) displays the 64-bit values only. On 64-bit systems, all is optimized away through watch64. Josef "Jeff" Sipek. - -- *NOTE: This message is ROT-13 encrypted twice for extra protection* -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOKSzwFP0+seVj/4RAkz7AJ0Ut21nPMkHGKv1dXK17yoA5hQ1+ACglpMq IHh+tYW3innmwjlA7EU2x78= =LnHg -----END PGP SIGNATURE----- From Rezwanul_Kabir@Dell.com Fri Sep 3 10:06:18 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 10:06:22 -0700 (PDT) Received: from ausc60pc101.us.dell.com (ausc60pc101.us.dell.com [143.166.85.206]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83H6H0F027153 for ; Fri, 3 Sep 2004 10:06:18 -0700 Received: from ausx2kcpc115.aus.amer.dell.com (10.166.84.69) by ausc60pc101.us.dell.com with ESMTP; 03 Sep 2004 12:06:05 -0500 X-Ironport-AV: i="3.84,129,1091422800"; d="scan'208"; a="84464312:sNHT20663774" X-MimeOLE: Produced By Microsoft Exchange V6.0.6527.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Subject: ioctl() to get MAC address from EEPROM Date: Fri, 3 Sep 2004 12:06:02 -0500 Message-ID: <06226F23984D7A49A694576CF06603F908BBCC@ausx2kmpc106.aus.amer.dell.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: ioctl() to get MAC address from EEPROM Thread-Index: AcSR2EpqqtgahXMFRfmmyUt8DI/YOw== From: To: X-OriginalArrivalTime: 03 Sep 2004 17:06:03.0956 (UTC) FILETIME=[4B8AAF40:01C491D8] Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by oss.sgi.com id i83H6H0F027153 X-archive-position: 8383 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: Rezwanul_Kabir@Dell.com Precedence: bulk X-list: netdev Hi There seems to be no standard way to retrieve the MAC address of a NIC stored in the EEPROM ( ETHTOOL_GEEPROM ioctl may be used to do such thing but there's a need for a more direct standard interface).This is sometimes necessary when the MAC address in EEPROM may differ from the one associated with the software interface (i.e. dev_addr in struct net_device).For example, in some modes of channel bonding , the MAC address of the active NIC is duplicated on the rest of the members of the specific bond/team. How to fetch the "permanent" MAC address in this case? Any plan to include such commands in ethtool ioctls? Is there a better way to do this? Any suggestions would be appreciated.. Thanks.. --rez From jeffpc@optonline.net Fri Sep 3 10:19:35 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 10:19:40 -0700 (PDT) Received: from mta4.srv.hcvlny.cv.net (mta4.srv.hcvlny.cv.net [167.206.5.70]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83HJYt9028073 for ; Fri, 3 Sep 2004 10:19:35 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta4.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3H00DMR6SDS8@mta4.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Fri, 03 Sep 2004 13:19:25 -0400 (EDT) Date: Fri, 03 Sep 2004 13:19:24 -0400 From: "Josef 'Jeff' Sipek" Subject: [PATCH 2.6] watch64: generic variable monitoring system In-reply-to: <200409031307.01240.jeffpc@optonline.net> To: linux-kernel@vger.kernel.org Cc: netdev@oss.sgi.com Message-id: <200409031319.24863.jeffpc@optonline.net> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: KMail/1.6.2 References: <200409031307.01240.jeffpc@optonline.net> X-archive-position: 8385 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev The watch64 system allows the programmer to specify the approximate interval at which he wants his variables checked. If he tries to specify shorter interval than the minimum a default value of HZ/10 is used. To minimize locking, RCU and seqlock are used. On 64-bit systems, all is optimized away. The following patch can be also pulled from http://jeffpc.bkbits.net/watch64-2.6 Josef "Jeff" Sipek. Signed-off-by: Josef "Jeff" Sipek diff -Nru a/Documentation/00-INDEX b/Documentation/00-INDEX --- a/Documentation/00-INDEX 2004-09-03 12:21:17 -04:00 +++ b/Documentation/00-INDEX 2004-09-03 12:21:17 -04:00 @@ -250,6 +250,8 @@ - directory with info regarding video/TV/radio cards and linux. vm/ - directory with info on the Linux vm code. +watch64.txt + - watch64 API description watchdog/ - how to auto-reboot Linux if it has "fallen and can't get up". ;-) x86_64/ diff -Nru a/Documentation/watch64.txt b/Documentation/watch64.txt --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/Documentation/watch64.txt 2004-09-03 12:21:17 -04:00 @@ -0,0 +1,35 @@ +int watch64_register(unsigned long* ptr, unsigned int interval); + + - Registers *ptr to be monitored every interval jiffies. + - If interval==0, WATCH64_INTERVAL will be used (HZ/10 by default) + +int watch64_unregister(unsigned long* ptr, struct watch64* st); + + - Unregister *ptr + - st is optional pointer to the struct containing the registration + information + - if st==NULL, it will be looked up automatically + +struct watch64* watch64_find(unsigned long* ptr); + + - Return struct with registration information of *ptr + +int watch64_disable(unsigned long* ptr, struct watch64* st); + + - Disable *ptr from being monitored, without removing it from the list + - st is optional (see watch64_unregister for more information) + +int watch64_enable(unsigned long* ptr, struct watch64* st); + + - Enable *ptr from being monitored (opposite of watch64_disable) + - st is optional (see watch64_unregister for more information) + +int watch64_toggle(unsigned long* ptr, struct watch64* st); + + - Toggle the enable/disable status + - st is optional (see watch64_unregister for more information) + +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st); + + - Return the whole 64-bit counter + - st is optional (see watch64_unregister for more information) diff -Nru a/include/linux/watch64.h b/include/linux/watch64.h --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/include/linux/watch64.h 2004-09-03 12:21:17 -04:00 @@ -0,0 +1,63 @@ +/* + * inclue/linux/watch64.h + * + * Copyright (C) 2003 Josef "Jeff" Sipek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef _LINUX_64WATCH_H +#define _LINUX_64WATCH_H + +#include +#include +#include +#include +#include + +#define WATCH64_INTERVAL (HZ/10) +#define WATCH64_MINIMUM (HZ/20) +#define WATCH64_MAGIC 0x573634 + +#if (BITS_PER_LONG == 64) + +struct watch64 { +}; + +#else + +struct watch64 { + struct list_head list; + unsigned long *ptr; + unsigned long oldval; + u_int64_t total; + unsigned int interval; + int active; + seqlock_t lock; + struct rcu_head rcuhead; +}; + +#endif /* (BITS_PER_LONG == 64) */ + +/* + * Prototypes + */ + +void watch64_init(void); +void watch64_run(unsigned long var); +int watch64_register(unsigned long* ptr, unsigned int interval); +int watch64_unregister(unsigned long* ptr, struct watch64* st); +void watch64_rcufree(struct rcu_head* p); +struct watch64* watch64_find(unsigned long* ptr); +inline struct watch64* __watch64_find(unsigned long* ptr); +int watch64_disable(unsigned long* ptr, struct watch64* st); +inline int __watch64_disable(unsigned long* ptr, struct watch64* st); +int watch64_enable(unsigned long* ptr, struct watch64* st); +inline int __watch64_enable(unsigned long* ptr, struct watch64* st); +int watch64_toggle(unsigned long* ptr, struct watch64* st); +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st); + +#endif /* _LINUX_WATCH64_H */ diff -Nru a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile 2004-09-03 12:21:17 -04:00 +++ b/kernel/Makefile 2004-09-03 12:21:17 -04:00 @@ -7,7 +7,7 @@ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o intermodule.o extable.o params.o posix-timers.o \ - kthread.o + kthread.o watch64.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o diff -Nru a/kernel/watch64.c b/kernel/watch64.c --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/kernel/watch64.c 2004-09-03 12:21:17 -04:00 @@ -0,0 +1,392 @@ +/* + * kernel/watch64.c + * + * Copyright (C) 2003 Josef "Jeff" Sipek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Watch64 global variables + */ + +spinlock_t watch64_biglock = SPIN_LOCK_UNLOCKED; +LIST_HEAD(watch64_head); +struct timer_list watch64_timer; +int watch64_setup; + +#if (BITS_PER_LONG == 64) + +void watch64_init(void) +{ +} + +void watch64_run(unsigned long var) +{ +} + +int watch64_register(unsigned long* ptr, unsigned int interval) +{ + return 0; +} + +int watch64_unregister(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +void watch64_rcufree(void* p) +{ +} + +struct watch64* watch64_find(unsigned long* ptr) +{ + return NULL; +} + +struct watch64* __watch64_find(unsigned long* ptr) +{ + return NULL; +} + +int watch64_disable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int __watch64_disable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int watch64_enable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int __watch64_enable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int watch64_toggle(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st) +{ + return (u_int64_t) *ptr; +} + +#else + +/* + * Initiate watch64 system + */ + +void watch64_init(void) +{ + spin_lock(&watch64_biglock); + + if (watch64_setup==WATCH64_MAGIC) { + spin_unlock(&watch64_biglock); + return; + } + + printk(KERN_WARNING "watch64: 2003/08/22 Josef 'Jeff' Sipek \n"); + printk(KERN_WARNING "watch64: Enabling Watch64 extensions..."); + + init_timer(&watch64_timer); + watch64_timer.function = watch64_run; + watch64_timer.data = (unsigned long) NULL; + watch64_timer.expires = jiffies + WATCH64_MINIMUM; + add_timer(&watch64_timer); + + printk("done.\n"); + + watch64_setup = WATCH64_MAGIC; + + spin_unlock(&watch64_biglock); +} + +/* + * Go through the list of registered variables and check them for changes + */ + +void watch64_run(unsigned long var) +{ + struct list_head* entry; + struct watch64* watch_struct; + unsigned long tmp; + + rcu_read_lock(); + list_for_each_rcu(entry, &watch64_head) { + watch_struct = list_entry(entry, struct watch64, list); + if (*watch_struct->ptr != watch_struct->oldval) { + tmp = *watch_struct->ptr; + if (tmp > watch_struct->oldval) { + write_seqlock(&watch_struct->lock); + watch_struct->total += tmp - watch_struct->oldval; + write_sequnlock(&watch_struct->lock); + } else if (tmp < watch_struct->oldval) { + write_seqlock(&watch_struct->lock); + watch_struct->total += ((u_int64_t) 1<oldval + tmp; + write_sequnlock(&watch_struct->lock); + } + watch_struct->oldval = tmp; + } + } + rcu_read_unlock(); + + mod_timer(&watch64_timer, jiffies + WATCH64_MINIMUM); +} + +/* + * Register a new variable with watch64 + */ + +int watch64_register(unsigned long* ptr, unsigned int interval) +{ + struct watch64* temp; + + temp = (struct watch64*) kmalloc(sizeof(struct watch64),GFP_ATOMIC); + + if (!temp) + return -ENOMEM; + + if (watch64_setup!=WATCH64_MAGIC) + watch64_init(); + + temp->ptr = ptr; + temp->oldval = 0; + temp->total = 0; + if (interval==0) + temp->interval = WATCH64_INTERVAL; + else if (intervalinterval = WATCH64_MINIMUM; + printk("watch64: attempted to add new watch with interval below %d jiffies",WATCH64_MINIMUM); + } else + temp->interval = interval; + + temp->active = 0; + + seqlock_init(&temp->lock); + + list_add_rcu(&temp->list, &watch64_head); + + return 0; +} + +/* + * Unregister a variable with watch64 + */ + +int watch64_unregister(unsigned long* ptr, struct watch64* st) +{ + rcu_read_lock(); + if (!st) + st = __watch64_find(ptr); + + if (!st) + return -EINVAL; + + __watch64_disable(ptr, st); + list_del_rcu(&st->list); + + call_rcu(&st->rcuhead, watch64_rcufree); + rcu_read_unlock(); + + return 0; +} + +/* + * Free memory via RCU + */ + +void watch64_rcufree(struct rcu_head* p) +{ + kfree(container_of(p, struct watch64, rcuhead)); +} + +/* + * Find watch64 structure with RCU lock + */ + +struct watch64* watch64_find(unsigned long* ptr) +{ + struct watch64* tmp; + + rcu_read_lock(); + tmp = __watch64_find(ptr); + rcu_read_unlock(); + + return tmp; +} + +/* + * Find watch64 structure without RCU lock + */ + +inline struct watch64* __watch64_find(unsigned long* ptr) +{ + struct list_head* tmp; + struct watch64* watch64_struct; + + list_for_each_rcu(tmp, &watch64_head) { + watch64_struct = list_entry(tmp, struct watch64, list); + if (watch64_struct->ptr==ptr) + return watch64_struct; + } + + return NULL; +} + +/* + * Disable a variable watch with RCU lock + */ + +int watch64_disable(unsigned long* ptr, struct watch64* st) +{ + int tmp; + + rcu_read_lock(); + tmp = __watch64_disable(ptr,st); + rcu_read_unlock(); + + return tmp; +} + +/* + * Disable a variable watch without RCU lock + */ + +inline int __watch64_disable(unsigned long* ptr, struct watch64* st) +{ + if (!st) + st = watch64_find(ptr); + + if (!st) + return -EINVAL; + + st->active = 0; + + return 0; +} + +/* + * Enable a variable watch with RCU lock + */ + +int watch64_enable(unsigned long* ptr, struct watch64* st) +{ + int tmp; + + rcu_read_lock(); + tmp = __watch64_enable(ptr,st); + rcu_read_unlock(); + + return tmp; +} + +/* + * Enable a variable watch without RCU lock + */ + +inline int __watch64_enable(unsigned long* ptr, struct watch64* st) +{ + if (!st) + st = __watch64_find(ptr); + + if (!st) + return -EINVAL; + + st->oldval = *ptr; + write_seqlock(&st->lock); + st->total = (u_int64_t) st->oldval; + write_sequnlock(&st->lock); + st->active = 1; + + return 0; +} + +/* + * Toggle a variable watch + */ + +int watch64_toggle(unsigned long* ptr, struct watch64* st) +{ + rcu_read_lock(); + if (!st) + st = __watch64_find(ptr); + + if (!st) { + rcu_read_unlock(); + return -EINVAL; + } + + if (st->active) + __watch64_disable(ptr,st); + else + __watch64_enable(ptr,st); + rcu_read_unlock(); + + return 0; +} + +/* + * Return the total 64-bit value + */ + +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st) +{ + unsigned int seq; + u_int64_t total; + + rcu_read_lock(); + if (!st) + st = __watch64_find(ptr); + + if (!st) { + rcu_read_unlock(); + return *ptr; + } + + do { + seq = read_seqbegin(&st->lock); + total = st->total; + } while (read_seqretry(&st->lock, seq)); + rcu_read_unlock(); + + return total; +} + +#endif /* (BITS_PER_LONG == 64) */ + +/* + * Export all the necessary symbols + */ + +EXPORT_SYMBOL(watch64_register); +EXPORT_SYMBOL(watch64_unregister); +EXPORT_SYMBOL(watch64_find); +EXPORT_SYMBOL(watch64_disable); +EXPORT_SYMBOL(watch64_enable); +EXPORT_SYMBOL(watch64_toggle); +EXPORT_SYMBOL(watch64_getval); From jeffpc@optonline.net Fri Sep 3 10:22:40 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 10:22:49 -0700 (PDT) Received: from mta10.srv.hcvlny.cv.net (mta10.srv.hcvlny.cv.net [167.206.5.85]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83HMdXi028435 for ; Fri, 3 Sep 2004 10:22:40 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta10.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3H00IO36XIC9@mta10.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Fri, 03 Sep 2004 13:22:30 -0400 (EDT) Date: Fri, 03 Sep 2004 13:22:29 -0400 From: "Josef 'Jeff' Sipek" Subject: [PATCH 2.6] 64network: 64-bit network statistics In-reply-to: <200409031307.01240.jeffpc@optonline.net> To: linux-kernel@vger.kernel.org Cc: netdev@oss.sgi.com Message-id: <200409031322.29981.jeffpc@optonline.net> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: KMail/1.6.2 References: <200409031307.01240.jeffpc@optonline.net> X-archive-position: 8386 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev Upon registration of a network device, all the statistics variables are registered with watch64. Additionally, a new proc file is created /proc/net/dev64 displays the 64-bit values as supposed to /proc/net/dev which is left to display the original 32-bit variables for backward compatibility. The sysfs interface (/sys/class/net//statistics/*) displays the 64-bit values only. On 64-bit systems, all is optimized away through watch64. Requires: watch64 The following patch can be also pulled from http://jeffpc.bkbits.net/64network-2.6 (includes watch64) Josef "Jeff" Sipek Signed-off-by: Josef "Jeff" Sipek diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h --- a/include/linux/netdevice.h 2004-09-03 12:22:08 -04:00 +++ b/include/linux/netdevice.h 2004-09-03 12:22:08 -04:00 @@ -14,6 +14,7 @@ * Alan Cox, * Bjorn Ekwall. * Pekka Riikonen + * Josef "Jeff" Sipek * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -945,6 +946,10 @@ #ifdef CONFIG_SYSCTL extern char *net_sysctl_strdup(const char *s); #endif + +/* Register/unregister all the members of struct net_device_stats with watch64 */ +inline void net_register_stats64(struct net_device_stats* stats); +inline void net_unregister_stats64(struct net_device_stats* stats); #endif /* __KERNEL__ */ diff -Nru a/net/core/dev.c b/net/core/dev.c --- a/net/core/dev.c 2004-09-03 12:22:08 -04:00 +++ b/net/core/dev.c 2004-09-03 12:22:08 -04:00 @@ -18,6 +18,7 @@ * Alexey Kuznetsov * Adam Sulmicki * Pekka Riikonen + * Josef "Jeff" Sipek * * Changes: * D.J. Barrow : Fixed bug where dev->refcnt gets set @@ -70,6 +71,7 @@ * indefinitely on dev->refcnt * J Hadi Salim : - Backlog queue sampling * - netif_rx() feedback + * Josef "Jeff" Sipek : Added watch64 calls for network statistics */ #include @@ -108,6 +110,7 @@ #include #include #include +#include #ifdef CONFIG_NET_RADIO #include /* Note : will define WIRELESS_EXT */ #include @@ -2110,6 +2113,49 @@ seq_printf(seq, "%6s: No statistics available.\n", dev->name); } +static void dev_seq_printf_stats64(struct seq_file *seq, struct net_device *dev) +{ + if (dev->get_stats) { + struct net_device_stats *stats = dev->get_stats(dev); + + seq_printf(seq, "%6s:%8llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu " + "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n", + dev->name, watch64_getval(&stats->rx_bytes,NULL), + watch64_getval(&stats->rx_packets,NULL), + watch64_getval(&stats->rx_errors,NULL), + watch64_getval(&stats->rx_dropped,NULL) + + watch64_getval(&stats->rx_missed_errors,NULL), + watch64_getval(&stats->rx_fifo_errors,NULL), + watch64_getval(&stats->rx_length_errors,NULL) + + watch64_getval(&stats->rx_over_errors,NULL) + + watch64_getval(&stats->rx_crc_errors,NULL) + + watch64_getval(&stats->rx_frame_errors,NULL), + watch64_getval(&stats->rx_compressed,NULL), + watch64_getval(&stats->multicast,NULL), + watch64_getval(&stats->tx_bytes,NULL), + watch64_getval(&stats->tx_packets,NULL), + watch64_getval(&stats->tx_errors,NULL), + watch64_getval(&stats->tx_dropped,NULL), + watch64_getval(&stats->tx_fifo_errors,NULL), + watch64_getval(&stats->collisions,NULL), + watch64_getval(&stats->tx_carrier_errors,NULL) + + watch64_getval(&stats->tx_aborted_errors,NULL) + + watch64_getval(&stats->tx_window_errors,NULL) + + watch64_getval(&stats->tx_heartbeat_errors,NULL), + watch64_getval(&stats->tx_compressed,NULL)); + } else + seq_printf(seq, "%6s: No statistics available.\n", dev->name); +} + +static void dev_seq_show_header(struct seq_file *seq) +{ + seq_puts(seq, "Inter-| Receive " + " | Transmit\n" + " face |bytes packets errs drop fifo frame " + "compressed multicast|bytes packets errs " + "drop fifo colls carrier compressed\n"); +} + /* * Called from the PROCfs module. This now uses the new arbitrary sized * /proc/net interface to create /proc/net/dev @@ -2117,16 +2163,21 @@ static int dev_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) - seq_puts(seq, "Inter-| Receive " - " | Transmit\n" - " face |bytes packets errs drop fifo frame " - "compressed multicast|bytes packets errs " - "drop fifo colls carrier compressed\n"); + dev_seq_show_header(seq); else dev_seq_printf_stats(seq, v); return 0; } +static int dev_seq_show64(struct seq_file *seq, void *v) +{ + if (v == SEQ_START_TOKEN) + dev_seq_show_header(seq); + else + dev_seq_printf_stats64(seq, v); + return 0; +} + static struct netif_rx_stats *softnet_get_online(loff_t *pos) { struct netif_rx_stats *rc = NULL; @@ -2179,11 +2230,23 @@ .show = dev_seq_show, }; +static struct seq_operations dev_seq_ops64 = { + .start = dev_seq_start, + .next = dev_seq_next, + .stop = dev_seq_stop, + .show = dev_seq_show64, +}; + static int dev_seq_open(struct inode *inode, struct file *file) { return seq_open(file, &dev_seq_ops); } +static int dev_seq_open64(struct inode *inode, struct file *file) +{ + return seq_open(file, &dev_seq_ops64); +} + static struct file_operations dev_seq_fops = { .owner = THIS_MODULE, .open = dev_seq_open, @@ -2192,6 +2255,14 @@ .release = seq_release, }; +static struct file_operations dev_seq_fops64 = { + .owner = THIS_MODULE, + .open = dev_seq_open64, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static struct seq_operations softnet_seq_ops = { .start = softnet_seq_start, .next = softnet_seq_next, @@ -2224,8 +2295,10 @@ if (!proc_net_fops_create("dev", S_IRUGO, &dev_seq_fops)) goto out; - if (!proc_net_fops_create("softnet_stat", S_IRUGO, &softnet_seq_fops)) + if (!proc_net_fops_create("dev64", S_IRUGO, &dev_seq_fops64)) goto out_dev; + if (!proc_net_fops_create("softnet_stat", S_IRUGO, &softnet_seq_fops)) + goto out_dev64; if (wireless_proc_init()) goto out_softnet; rc = 0; @@ -2233,6 +2306,8 @@ return rc; out_softnet: proc_net_remove("softnet_stat"); +out_dev64: + proc_net_remove("dev64"); out_dev: proc_net_remove("dev"); goto out; @@ -2910,6 +2985,9 @@ * device is present. */ + if (dev->get_stats) + net_register_stats64(dev->get_stats(dev)); + set_bit(__LINK_STATE_PRESENT, &dev->state); dev->next = NULL; @@ -2922,7 +3000,7 @@ dev_hold(dev); dev->reg_state = NETREG_REGISTERING; write_unlock_bh(&dev_base_lock); - + /* Notify protocols, that a new device appeared. */ notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev); @@ -3145,6 +3223,9 @@ /* If device is running, close it first. */ if (dev->flags & IFF_UP) dev_close(dev); + + if (dev->get_stats) + net_unregister_stats64(dev->get_stats(dev)); /* And unlink it from device chain. */ for (dp = &dev_base; (d = *dp) != NULL; dp = &d->next) { @@ -3246,6 +3327,98 @@ } #endif /* CONFIG_HOTPLUG_CPU */ +/* + * Register all the members of the net_device_stats structure + * + */ + +inline void net_register_stats64(struct net_device_stats* stats) +{ + if (!stats) + return; + + watch64_register(&stats->tx_packets,0); + watch64_enable (&stats->tx_packets,NULL); + watch64_register(&stats->rx_packets,0); + watch64_enable (&stats->rx_packets,NULL); + watch64_register(&stats->tx_bytes,0); + watch64_enable (&stats->tx_bytes,NULL); + watch64_register(&stats->rx_bytes,0); + watch64_enable (&stats->rx_bytes,NULL); + watch64_register(&stats->tx_errors,0); + watch64_enable (&stats->tx_errors,NULL); + watch64_register(&stats->rx_errors,0); + watch64_enable (&stats->rx_errors,NULL); + watch64_register(&stats->tx_dropped,0); + watch64_enable (&stats->tx_dropped,NULL); + watch64_register(&stats->rx_dropped,0); + watch64_enable (&stats->rx_dropped,NULL); + watch64_register(&stats->multicast,0); + watch64_enable (&stats->multicast,NULL); + watch64_register(&stats->collisions,0); + watch64_enable (&stats->collisions,NULL); + watch64_register(&stats->rx_length_errors,0); + watch64_enable (&stats->rx_length_errors,NULL); + watch64_register(&stats->rx_over_errors,0); + watch64_enable (&stats->rx_over_errors,NULL); + watch64_register(&stats->rx_crc_errors,0); + watch64_enable (&stats->rx_crc_errors,NULL); + watch64_register(&stats->rx_frame_errors,0); + watch64_enable (&stats->rx_frame_errors,NULL); + watch64_register(&stats->rx_fifo_errors,0); + watch64_enable (&stats->rx_fifo_errors,NULL); + watch64_register(&stats->rx_missed_errors,0); + watch64_enable (&stats->rx_missed_errors,NULL); + watch64_register(&stats->tx_aborted_errors,0); + watch64_enable (&stats->tx_aborted_errors,NULL); + watch64_register(&stats->tx_carrier_errors,0); + watch64_enable (&stats->tx_carrier_errors,NULL); + watch64_register(&stats->tx_fifo_errors,0); + watch64_enable (&stats->tx_fifo_errors,NULL); + watch64_register(&stats->tx_heartbeat_errors,0); + watch64_enable (&stats->tx_heartbeat_errors,NULL); + watch64_register(&stats->tx_window_errors,0); + watch64_enable (&stats->tx_window_errors,NULL); + watch64_register(&stats->rx_compressed,0); + watch64_enable (&stats->rx_compressed,NULL); + watch64_register(&stats->tx_compressed,0); + watch64_enable (&stats->tx_compressed,NULL); +} + +/* + * Unregister all the members of the net_device_stats structure + * + */ + +inline void net_unregister_stats64(struct net_device_stats* stats) +{ + if (!stats) + return; + + watch64_unregister(&stats->tx_packets,0); + watch64_unregister(&stats->rx_packets,0); + watch64_unregister(&stats->tx_bytes,0); + watch64_unregister(&stats->rx_bytes,0); + watch64_unregister(&stats->tx_errors,0); + watch64_unregister(&stats->rx_errors,0); + watch64_unregister(&stats->tx_dropped,0); + watch64_unregister(&stats->rx_dropped,0); + watch64_unregister(&stats->multicast,0); + watch64_unregister(&stats->collisions,0); + watch64_unregister(&stats->rx_length_errors,0); + watch64_unregister(&stats->rx_over_errors,0); + watch64_unregister(&stats->rx_crc_errors,0); + watch64_unregister(&stats->rx_frame_errors,0); + watch64_unregister(&stats->rx_fifo_errors,0); + watch64_unregister(&stats->rx_missed_errors,0); + watch64_unregister(&stats->tx_aborted_errors,0); + watch64_unregister(&stats->tx_carrier_errors,0); + watch64_unregister(&stats->tx_fifo_errors,0); + watch64_unregister(&stats->tx_heartbeat_errors,0); + watch64_unregister(&stats->tx_window_errors,0); + watch64_unregister(&stats->rx_compressed,0); + watch64_unregister(&stats->tx_compressed,0); +} /* * Initialize the DEV module. At boot time this walks the device list and diff -Nru a/net/core/net-sysfs.c b/net/core/net-sysfs.c --- a/net/core/net-sysfs.c 2004-09-03 12:22:08 -04:00 +++ b/net/core/net-sysfs.c 2004-09-03 12:22:08 -04:00 @@ -16,6 +16,7 @@ #include #include #include +#include #define to_class_dev(obj) container_of(obj,struct class_device,kobj) #define to_net_dev(class) container_of(class, struct net_device, class_dev) @@ -23,6 +24,7 @@ static const char fmt_hex[] = "%#x\n"; static const char fmt_dec[] = "%d\n"; static const char fmt_ulong[] = "%lu\n"; +static const char fmt_ullong[] = "%llu\n"; static inline int dev_isalive(const struct net_device *dev) { @@ -204,8 +206,8 @@ read_lock(&dev_base_lock); if (dev_isalive(dev) && dev->get_stats && (stats = (*dev->get_stats)(dev))) - ret = sprintf(buf, fmt_ulong, - *(unsigned long *)(((u8 *) stats) + offset)); + ret = sprintf(buf, fmt_ullong, + watch64_getval((unsigned long *)(((u8 *) stats) + offset),NULL)); read_unlock(&dev_base_lock); return ret; From jeffpc@optonline.net Fri Sep 3 10:25:26 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 10:25:31 -0700 (PDT) Received: from mta6.srv.hcvlny.cv.net (mta6.srv.hcvlny.cv.net [167.206.5.72]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83HPPCq028777 for ; Fri, 3 Sep 2004 10:25:26 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta6.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3H00FI771066@mta6.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Fri, 03 Sep 2004 13:24:37 -0400 (EDT) Date: Fri, 03 Sep 2004 13:24:28 -0400 From: Jeff Sipek Subject: Re: [PATCH/RFC 2.6] NET: 64-bit network statistics In-reply-to: <200409031307.01240.jeffpc@optonline.net> To: linux-kernel@vger.kernel.org Cc: netdev@oss.sgi.com Message-id: <200409031324.36252.jeffpc@optonline.net> MIME-version: 1.0 Content-type: Text/Plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: KMail/1.6.2 References: <200409031307.01240.jeffpc@optonline.net> X-archive-position: 8387 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 03 September 2004 13:06, josef Jeff Sipek wrote: > I've created a patch that monitors changes to the network statistics > variables and keeps internal 64-bit counter. I decided to split it into two > parts (patches are to follow in next emails): > 1) generic variable monitoring system (watch64) > 2) network statistics specific patch (64network) Btw, both of these patches apply cleanly against 2.6.9-rc1-bk10. Jeff. - -- bad pun of the week: the formula 1 control computer suffered from a race condition -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOKjQwFP0+seVj/4RApg/AKDEFSTVOMSvVh9zVU65o/P6ZcfBxgCffeId QddOVsR+uHdkV2D4/U8QVO4= =jQIT -----END PGP SIGNATURE----- From vkondra@mail.ru Fri Sep 3 11:04:47 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 11:05:32 -0700 (PDT) Received: from mx2.mail.ru (mx2.mail.ru [194.67.23.122]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83I4k8w029921 for ; Fri, 3 Sep 2004 11:04:47 -0700 Received: from [212.179.200.204] (port=25901 helo=[192.168.10.2]) by mx2.mail.ru with esmtp id 1C3IQ2-000Jtq-00; Fri, 03 Sep 2004 22:04:16 +0400 From: Vladimir Kondratiev To: netdev@oss.sgi.com Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Fri, 3 Sep 2004 20:37:54 +0300 User-Agent: KMail/1.7 Cc: Jeff Garzik , Denis Vlasenko , Jean Tourrilhes , Jouni Malinen , acx100-devel@lists.sourceforge.net, prism54-devel@prism54.org, "David S. Miller" References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <200409022324.43117.vkondra@mail.ru> <4137839B.4000303@pobox.com> In-Reply-To: <4137839B.4000303@pobox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409032039.28201.vkondra@mail.ru> X-Spam: Probable Spam X-archive-position: 8388 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vkondra@mail.ru Precedence: bulk X-list: netdev Is anyone working on this stack? I asked Dave, he is hot working on it. Or is this code dead? On Thursday 02 September 2004 23:33, Jeff Garzik wrote: JG> Vladimir Kondratiev wrote: JG> > Jeff, JG> > JG> > On Tuesday 31 August 2004 21:21, Jeff Garzik wrote: JG> > JG> Denis Vlasenko wrote: JG> > JG> > I think 'senior' network guys are in position to decide upon which JG> > JG> > of currently available 802.11 stacks we should continue to work. JG> > JG> > (Atheros has one, said to be derived from BSD, is there any others?) JG> > JG> JG> > JG> JG> > JG> Already have. Start with the code in wireless-2.6 -- HostAP -- and use JG> > JG> DaveM's 802.11 stack template as a model for actually integrating 802.11 JG> > JG> very tightly with the rest of the net stack. JG> > JG> JG> > JG> JG> > http://www.kernel.org/pub/linux/kernel/people/jgarzik/patchkits/2.6/davem-p8 JG> > 0211.tar.bz2 JG> > JG> > Is this stack the main one that is going to be used? I.e. if I am working on JG> > driver for next generation .11 card - should I try to use it, request/submitt JG> > missing features etc.? Or should I use wireless extensions? JG> JG> DaveM's code is a template for how a wireless stack would look when JG> properly and fully integrated into the net core. JG> JG> Although JeanT and I disagree about this, I am less interested in JG> backwards compatibility than I am about making wireless a "first class JG> citizen" in the kernel. As I have proven with kcompat JG> (http://sf.net/projects/gkernel/) you can be backwards compatible while JG> still evolving the current kernel driver API to meet current design needs. JG> JG> Jeff JG> JG> JG> JG> From yoshfuji@linux-ipv6.org Fri Sep 3 12:06:41 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 12:06:48 -0700 (PDT) Received: from yue.st-paulia.net ([203.178.140.15]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83J6fWW001538 for ; Fri, 3 Sep 2004 12:06:41 -0700 Received: from localhost (localhost [127.0.0.1]) by yue.st-paulia.net (Postfix) with ESMTP id D6C2533CE6; Sat, 4 Sep 2004 04:07:29 +0900 (JST) Date: Sat, 04 Sep 2004 04:07:27 +0900 (JST) Message-Id: <20040904.040727.72671952.yoshfuji@linux-ipv6.org> To: jeffpc@optonline.net Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org, yoshfuji@linux-ipv6.org Subject: Re: [PATCH 2.6] watch64: generic variable monitoring system From: YOSHIFUJI Hideaki / =?iso-2022-jp?B?GyRCNUhGIzFRTEAbKEI=?= In-Reply-To: <200409031319.24863.jeffpc@optonline.net> References: <200409031307.01240.jeffpc@optonline.net> <200409031319.24863.jeffpc@optonline.net> Organization: USAGI Project X-URL: http://www.yoshifuji.org/%7Ehideaki/ X-Fingerprint: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA X-PGP-Key-URL: http://www.yoshifuji.org/%7Ehideaki/hideaki@yoshifuji.org.asc X-Face: "5$Al-.M>NJ%a'@hhZdQm:."qn~PA^gq4o*>iCFToq*bAi#4FRtx}enhuQKz7fNqQz\BYU] $~O_5m-9'}MIs`XGwIEscw;e5b>n"B_?j/AkL~i/MEaZBLP X-Mailer: Mew version 2.2 on Emacs 20.7 / Mule 4.1 (AOI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-archive-position: 8389 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: yoshfuji@linux-ipv6.org Precedence: bulk X-list: netdev In article <200409031319.24863.jeffpc@optonline.net> (at Fri, 03 Sep 2004 13:19:24 -0400), "Josef 'Jeff' Sipek" says: > The watch64 system allows the programmer to specify the approximate interval > at which he wants his variables checked. If he tries to specify shorter > interval than the minimum a default value of HZ/10 is used. To minimize > locking, RCU and seqlock are used. On 64-bit systems, all is optimized away. I agree with the basic principle; it is very similar to mine. However, it is too complicated isn't it? I would do per-"table" registration (instead of per-variable one); watch64_getval() seems very ugly to me... -- Hideaki YOSHIFUJI @ USAGI Project GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA From jeffpc@optonline.net Fri Sep 3 13:24:34 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 13:24:40 -0700 (PDT) Received: from mta6.srv.hcvlny.cv.net (mta6.srv.hcvlny.cv.net [167.206.5.72]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83KOWIQ006212 for ; Fri, 3 Sep 2004 13:24:34 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta6.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3H00EK9FCNLU@mta6.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Fri, 03 Sep 2004 16:24:23 -0400 (EDT) Date: Fri, 03 Sep 2004 16:24:15 -0400 From: Jeff Sipek Subject: Re: [PATCH 2.6] watch64: generic variable monitoring system In-reply-to: <20040904.040727.72671952.yoshfuji@linux-ipv6.org> To: YOSHIFUJI Hideaki / =?utf-8?q?=E5=90=89=E8=97=A4=E8=8B=B1=E6=98=8E?= Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org Message-id: <200409031624.22665.jeffpc@optonline.net> MIME-version: 1.0 Content-type: Text/Plain; charset=utf-8 Content-disposition: inline User-Agent: KMail/1.6.2 References: <200409031307.01240.jeffpc@optonline.net> <200409031319.24863.jeffpc@optonline.net> <20040904.040727.72671952.yoshfuji@linux-ipv6.org> Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by oss.sgi.com id i83KOWIQ006212 X-archive-position: 8390 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 03 September 2004 15:07, YOSHIFUJI Hideaki / 吉藤英明 wrote: > I agree with the basic principle; it is very similar to mine. Yes, I saw a patch on lkml a while a go (possibly yours?) that used a workqueue (IIRC.) > However, it is too complicated isn't it? I considered the option of removing the capability of the programmer asking for a certain interval, and instead having all the variables checked every WATCH64_INTERVAL. > I would do per-"table" registration (instead of per-variable one); I considered that option, but then decided to make the watch64 system generic enough so that it could be used from anywhere in the kernel. Is my idea of having a kernel-wide subsystem like this too heavy-weight? > watch64_getval() seems very ugly to me... How so? Is it the multiplicity of "if (!st)"? Jeff. - -- bad pun of the week: the formula 1 control computer suffered from a race condition -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBONLzwFP0+seVj/4RAvYsAKCdVy9EzivcGtwa9CDiuvy/nwWuJwCglQ4L iIf4QXC7PA+YwQs3905sRv0= =NkA4 -----END PGP SIGNATURE----- From jgarzik@pobox.com Fri Sep 3 13:30:23 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 13:31:07 -0700 (PDT) Received: from www.linux.org.uk (IDENT:93@parcelfarce.linux.theplanet.co.uk [195.92.249.252]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83KUMva006625 for ; Fri, 3 Sep 2004 13:30:23 -0700 Received: from rdu74-155-169.nc.rr.com ([24.74.155.169] helo=[10.10.10.88]) by www.linux.org.uk with asmtp (TLSv1:AES256-SHA:256) (Exim 4.33) id 1C3Kgy-0002Ry-Ss; Fri, 03 Sep 2004 21:29:53 +0100 Message-ID: <4138D431.8040206@pobox.com> Date: Fri, 03 Sep 2004 16:29:37 -0400 From: Jeff Garzik User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Vladimir Kondratiev CC: netdev@oss.sgi.com, Denis Vlasenko , Jean Tourrilhes , Jouni Malinen , acx100-devel@lists.sourceforge.net, prism54-devel@prism54.org, "David S. Miller" Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <200409022324.43117.vkondra@mail.ru> <4137839B.4000303@pobox.com> <200409032039.28201.vkondra@mail.ru> In-Reply-To: <200409032039.28201.vkondra@mail.ru> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8391 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jgarzik@pobox.com Precedence: bulk X-list: netdev Vladimir Kondratiev wrote: > Is anyone working on this stack? I asked Dave, he is hot working on it. > Or is this code dead? Nobody is actively working on that stack AFAIK. Jeff From jeffpc@optonline.net Fri Sep 3 13:40:55 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 13:41:01 -0700 (PDT) Received: from mta8.srv.hcvlny.cv.net (mta8.srv.hcvlny.cv.net [167.206.5.75]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83KetC2007208 for ; Fri, 3 Sep 2004 13:40:55 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta8.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3H00DA2G3JO9@mta8.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Fri, 03 Sep 2004 16:40:32 -0400 (EDT) Date: Fri, 03 Sep 2004 16:40:30 -0400 From: "Josef 'Jeff' Sipek" Subject: Re: [PATCH 2.6] watch64: generic variable monitoring system In-reply-to: <200409031618.47521.jeffpc@optonline.net> To: Stephen Hemminger Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org Message-id: <200409031640.30731.jeffpc@optonline.net> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: KMail/1.6.2 References: <200409031307.01240.jeffpc@optonline.net> <20040903121657.355a6a8b@dell_ss3.pdx.osdl.net> <200409031618.47521.jeffpc@optonline.net> X-archive-position: 8392 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev The following fixes watch64 patch previously submitted to follow CodingStyle guidelines. BK repo is up to date as well Jeff. Signed-off-by: Josef "Jeff" Sipek --- 1.7/kernel/watch64.c 2004-07-14 16:41:26 -04:00 +++ edited/watch64.c 2004-09-03 16:12:39 -04:00 @@ -110,7 +110,8 @@ return; } - printk(KERN_WARNING "watch64: 2003/08/22 Josef 'Jeff' Sipek \n"); + printk(KERN_WARNING "watch64: 2003/08/22 Josef 'Jeff' Sipek " + "\n"); printk(KERN_WARNING "watch64: Enabling Watch64 extensions..."); init_timer(&watch64_timer); @@ -139,19 +140,21 @@ rcu_read_lock(); list_for_each_rcu(entry, &watch64_head) { watch_struct = list_entry(entry, struct watch64, list); - if (*watch_struct->ptr != watch_struct->oldval) { - tmp = *watch_struct->ptr; - if (tmp > watch_struct->oldval) { - write_seqlock(&watch_struct->lock); - watch_struct->total += tmp - watch_struct->oldval; - write_sequnlock(&watch_struct->lock); - } else if (tmp < watch_struct->oldval) { - write_seqlock(&watch_struct->lock); - watch_struct->total += ((u_int64_t) 1<oldval + tmp; - write_sequnlock(&watch_struct->lock); - } - watch_struct->oldval = tmp; + if (*watch_struct->ptr == watch_struct->oldval) + continue; + + tmp = *watch_struct->ptr; + if (tmp > watch_struct->oldval) { + write_seqlock(&watch_struct->lock); + watch_struct->total += tmp - watch_struct->oldval; + write_sequnlock(&watch_struct->lock); + } else if (tmp < watch_struct->oldval) { + write_seqlock(&watch_struct->lock); + watch_struct->total += ((u_int64_t) 1<oldval + tmp; + write_sequnlock(&watch_struct->lock); } + watch_struct->oldval = tmp; } rcu_read_unlock(); @@ -181,7 +184,8 @@ temp->interval = WATCH64_INTERVAL; else if (intervalinterval = WATCH64_MINIMUM; - printk("watch64: attempted to add new watch with interval below %d jiffies",WATCH64_MINIMUM); + printk("watch64: attempted to add new watch with " + "interval below %d jiffies",WATCH64_MINIMUM); } else temp->interval = interval; From davej@redhat.com Fri Sep 3 13:53:14 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 13:53:19 -0700 (PDT) Received: from delerium.codemonkey.org.uk (delerium.kernelslacker.org [81.187.208.145]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83KrBOr008042 for ; Fri, 3 Sep 2004 13:53:14 -0700 Received: from delerium.codemonkey.org.uk (localhost.localdomain [127.0.0.1]) by delerium.codemonkey.org.uk (8.13.1/8.13.1) with ESMTP id i83Kq6OV021868; Fri, 3 Sep 2004 21:52:06 +0100 Received: (from davej@localhost) by delerium.codemonkey.org.uk (8.13.1/8.13.1/Submit) id i83Kq6lu021867; Fri, 3 Sep 2004 21:52:06 +0100 X-Authentication-Warning: delerium.codemonkey.org.uk: davej set sender to davej@redhat.com using -f Date: Fri, 3 Sep 2004 21:52:06 +0100 From: Dave Jones To: "David S. Miller" Cc: netdev@oss.sgi.com Subject: Too late check in af_packet.c Message-ID: <20040903205206.GT26419@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-archive-position: 8393 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davej@redhat.com Precedence: bulk X-list: netdev Using the automated source checker at coverity.com, they picked up on some code in packet_release() where a NULL check was done after dereferencing. Patch below. Signed-off-by: Dave Jones Dave --- linux-2.6.8/net/packet/af_packet.c~ 2004-09-03 21:48:14.653433072 +0100 +++ linux-2.6.8/net/packet/af_packet.c 2004-09-03 21:49:23.652943552 +0100 @@ -785,11 +785,13 @@ static int packet_release(struct socket *sock) { struct sock *sk = sock->sk; - struct packet_opt *po = pkt_sk(sk); + struct packet_opt *po; if (!sk) return 0; + po = pkt_sk(sk); + write_lock_bh(&packet_sklist_lock); sk_del_node_init(sk); write_unlock_bh(&packet_sklist_lock); From jeffpc@optonline.net Fri Sep 3 14:45:07 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 14:45:14 -0700 (PDT) Received: from mta9.srv.hcvlny.cv.net (mta9.srv.hcvlny.cv.net [167.206.5.42]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83Lj62F009118 for ; Fri, 3 Sep 2004 14:45:07 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta9.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3H00JKEJ29E3@mta9.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Fri, 03 Sep 2004 17:44:34 -0400 (EDT) Date: Fri, 03 Sep 2004 17:44:24 -0400 From: "Josef 'Jeff' Sipek" Subject: Re: [PATCH 2.6] watch64: generic variable monitoring system In-reply-to: <20040903121657.355a6a8b@dell_ss3.pdx.osdl.net> To: Stephen Hemminger Cc: linux-kernel@vger.kernel.org, netdev@oss.sgi.com Message-id: <200409031744.32970.jeffpc@optonline.net> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_Gu5A8t3yfXnZW0k3kEIBKg)" Content-disposition: inline User-Agent: KMail/1.6.2 References: <200409031307.01240.jeffpc@optonline.net> <200409031319.24863.jeffpc@optonline.net> <20040903121657.355a6a8b@dell_ss3.pdx.osdl.net> X-archive-position: 8394 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev --Boundary_(ID_Gu5A8t3yfXnZW0k3kEIBKg) Content-type: Text/Plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 03 September 2004 15:16, Stephen Hemminger wrote: > - Code doesn't match the kernel style (read Documentation/CodingStyle) Sorry about the white space, KMail apparently likes to butcher the text. These are the same patches with the little cleanup update. Jeff. - -- Reality is merely an illusion, albeit a very persistent one. - Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD4DBQFBOOW+wFP0+seVj/4RAgSiAJj54qcqdEx66lbMW9ik0XviupTNAKC82an1 R0pGX0pTBZ78NWrZpxJm+w== =EesC -----END PGP SIGNATURE----- --Boundary_(ID_Gu5A8t3yfXnZW0k3kEIBKg) Content-type: text/x-diff; charset=iso-8859-1; name=watch64-patch Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=watch64-patch diff -Nru a/Documentation/00-INDEX b/Documentation/00-INDEX --- a/Documentation/00-INDEX 2004-09-03 17:41:06 -04:00 +++ b/Documentation/00-INDEX 2004-09-03 17:41:06 -04:00 @@ -250,6 +250,8 @@ - directory with info regarding video/TV/radio cards and linux. vm/ - directory with info on the Linux vm code. +watch64.txt + - watch64 API description watchdog/ - how to auto-reboot Linux if it has "fallen and can't get up". ;-) x86_64/ diff -Nru a/Documentation/watch64.txt b/Documentation/watch64.txt --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/Documentation/watch64.txt 2004-09-03 17:41:06 -04:00 @@ -0,0 +1,35 @@ +int watch64_register(unsigned long* ptr, unsigned int interval); + + - Registers *ptr to be monitored every interval jiffies. + - If interval==0, WATCH64_INTERVAL will be used (HZ/10 by default) + +int watch64_unregister(unsigned long* ptr, struct watch64* st); + + - Unregister *ptr + - st is optional pointer to the struct containing the registration + information + - if st==NULL, it will be looked up automatically + +struct watch64* watch64_find(unsigned long* ptr); + + - Return struct with registration information of *ptr + +int watch64_disable(unsigned long* ptr, struct watch64* st); + + - Disable *ptr from being monitored, without removing it from the list + - st is optional (see watch64_unregister for more information) + +int watch64_enable(unsigned long* ptr, struct watch64* st); + + - Enable *ptr from being monitored (opposite of watch64_disable) + - st is optional (see watch64_unregister for more information) + +int watch64_toggle(unsigned long* ptr, struct watch64* st); + + - Toggle the enable/disable status + - st is optional (see watch64_unregister for more information) + +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st); + + - Return the whole 64-bit counter + - st is optional (see watch64_unregister for more information) diff -Nru a/include/linux/watch64.h b/include/linux/watch64.h --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/include/linux/watch64.h 2004-09-03 17:41:06 -04:00 @@ -0,0 +1,63 @@ +/* + * inclue/linux/watch64.h + * + * Copyright (C) 2003 Josef "Jeff" Sipek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef _LINUX_64WATCH_H +#define _LINUX_64WATCH_H + +#include +#include +#include +#include +#include + +#define WATCH64_INTERVAL (HZ/10) +#define WATCH64_MINIMUM (HZ/20) +#define WATCH64_MAGIC 0x573634 + +#if (BITS_PER_LONG == 64) + +struct watch64 { +}; + +#else + +struct watch64 { + struct list_head list; + unsigned long *ptr; + unsigned long oldval; + u_int64_t total; + unsigned int interval; + int active; + seqlock_t lock; + struct rcu_head rcuhead; +}; + +#endif /* (BITS_PER_LONG == 64) */ + +/* + * Prototypes + */ + +void watch64_init(void); +void watch64_run(unsigned long var); +int watch64_register(unsigned long* ptr, unsigned int interval); +int watch64_unregister(unsigned long* ptr, struct watch64* st); +void watch64_rcufree(struct rcu_head* p); +struct watch64* watch64_find(unsigned long* ptr); +inline struct watch64* __watch64_find(unsigned long* ptr); +int watch64_disable(unsigned long* ptr, struct watch64* st); +inline int __watch64_disable(unsigned long* ptr, struct watch64* st); +int watch64_enable(unsigned long* ptr, struct watch64* st); +inline int __watch64_enable(unsigned long* ptr, struct watch64* st); +int watch64_toggle(unsigned long* ptr, struct watch64* st); +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st); + +#endif /* _LINUX_WATCH64_H */ diff -Nru a/kernel/Makefile b/kernel/Makefile --- a/kernel/Makefile 2004-09-03 17:41:06 -04:00 +++ b/kernel/Makefile 2004-09-03 17:41:06 -04:00 @@ -7,7 +7,7 @@ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o intermodule.o extable.o params.o posix-timers.o \ - kthread.o + kthread.o watch64.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o diff -Nru a/kernel/watch64.c b/kernel/watch64.c --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/kernel/watch64.c 2004-09-03 17:41:06 -04:00 @@ -0,0 +1,396 @@ +/* + * kernel/watch64.c + * + * Copyright (C) 2003 Josef "Jeff" Sipek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Watch64 global variables + */ + +spinlock_t watch64_biglock = SPIN_LOCK_UNLOCKED; +LIST_HEAD(watch64_head); +struct timer_list watch64_timer; +int watch64_setup; + +#if (BITS_PER_LONG == 64) + +void watch64_init(void) +{ +} + +void watch64_run(unsigned long var) +{ +} + +int watch64_register(unsigned long* ptr, unsigned int interval) +{ + return 0; +} + +int watch64_unregister(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +void watch64_rcufree(void* p) +{ +} + +struct watch64* watch64_find(unsigned long* ptr) +{ + return NULL; +} + +struct watch64* __watch64_find(unsigned long* ptr) +{ + return NULL; +} + +int watch64_disable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int __watch64_disable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int watch64_enable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int __watch64_enable(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +int watch64_toggle(unsigned long* ptr, struct watch64* st) +{ + return 0; +} + +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st) +{ + return (u_int64_t) *ptr; +} + +#else + +/* + * Initiate watch64 system + */ + +void watch64_init(void) +{ + spin_lock(&watch64_biglock); + + if (watch64_setup==WATCH64_MAGIC) { + spin_unlock(&watch64_biglock); + return; + } + + printk(KERN_WARNING "watch64: 2003/08/22 Josef 'Jeff' Sipek " + "\n"); + printk(KERN_WARNING "watch64: Enabling Watch64 extensions..."); + + init_timer(&watch64_timer); + watch64_timer.function = watch64_run; + watch64_timer.data = (unsigned long) NULL; + watch64_timer.expires = jiffies + WATCH64_MINIMUM; + add_timer(&watch64_timer); + + printk("done.\n"); + + watch64_setup = WATCH64_MAGIC; + + spin_unlock(&watch64_biglock); +} + +/* + * Go through the list of registered variables and check them for changes + */ + +void watch64_run(unsigned long var) +{ + struct list_head* entry; + struct watch64* watch_struct; + unsigned long tmp; + + rcu_read_lock(); + list_for_each_rcu(entry, &watch64_head) { + watch_struct = list_entry(entry, struct watch64, list); + if (*watch_struct->ptr == watch_struct->oldval) + continue; + + tmp = *watch_struct->ptr; + if (tmp > watch_struct->oldval) { + write_seqlock(&watch_struct->lock); + watch_struct->total += tmp - watch_struct->oldval; + write_sequnlock(&watch_struct->lock); + } else if (tmp < watch_struct->oldval) { + write_seqlock(&watch_struct->lock); + watch_struct->total += ((u_int64_t) 1<oldval + tmp; + write_sequnlock(&watch_struct->lock); + } + watch_struct->oldval = tmp; + } + rcu_read_unlock(); + + mod_timer(&watch64_timer, jiffies + WATCH64_MINIMUM); +} + +/* + * Register a new variable with watch64 + */ + +int watch64_register(unsigned long* ptr, unsigned int interval) +{ + struct watch64* temp; + + temp = (struct watch64*) kmalloc(sizeof(struct watch64),GFP_ATOMIC); + + if (!temp) + return -ENOMEM; + + if (watch64_setup!=WATCH64_MAGIC) + watch64_init(); + + temp->ptr = ptr; + temp->oldval = 0; + temp->total = 0; + if (interval==0) + temp->interval = WATCH64_INTERVAL; + else if (intervalinterval = WATCH64_MINIMUM; + printk("watch64: attempted to add new watch with " + "interval below %d jiffies",WATCH64_MINIMUM); + } else + temp->interval = interval; + + temp->active = 0; + + seqlock_init(&temp->lock); + + list_add_rcu(&temp->list, &watch64_head); + + return 0; +} + +/* + * Unregister a variable with watch64 + */ + +int watch64_unregister(unsigned long* ptr, struct watch64* st) +{ + rcu_read_lock(); + if (!st) + st = __watch64_find(ptr); + + if (!st) + return -EINVAL; + + __watch64_disable(ptr, st); + list_del_rcu(&st->list); + + call_rcu(&st->rcuhead, watch64_rcufree); + rcu_read_unlock(); + + return 0; +} + +/* + * Free memory via RCU + */ + +void watch64_rcufree(struct rcu_head* p) +{ + kfree(container_of(p, struct watch64, rcuhead)); +} + +/* + * Find watch64 structure with RCU lock + */ + +struct watch64* watch64_find(unsigned long* ptr) +{ + struct watch64* tmp; + + rcu_read_lock(); + tmp = __watch64_find(ptr); + rcu_read_unlock(); + + return tmp; +} + +/* + * Find watch64 structure without RCU lock + */ + +inline struct watch64* __watch64_find(unsigned long* ptr) +{ + struct list_head* tmp; + struct watch64* watch64_struct; + + list_for_each_rcu(tmp, &watch64_head) { + watch64_struct = list_entry(tmp, struct watch64, list); + if (watch64_struct->ptr==ptr) + return watch64_struct; + } + + return NULL; +} + +/* + * Disable a variable watch with RCU lock + */ + +int watch64_disable(unsigned long* ptr, struct watch64* st) +{ + int tmp; + + rcu_read_lock(); + tmp = __watch64_disable(ptr,st); + rcu_read_unlock(); + + return tmp; +} + +/* + * Disable a variable watch without RCU lock + */ + +inline int __watch64_disable(unsigned long* ptr, struct watch64* st) +{ + if (!st) + st = watch64_find(ptr); + + if (!st) + return -EINVAL; + + st->active = 0; + + return 0; +} + +/* + * Enable a variable watch with RCU lock + */ + +int watch64_enable(unsigned long* ptr, struct watch64* st) +{ + int tmp; + + rcu_read_lock(); + tmp = __watch64_enable(ptr,st); + rcu_read_unlock(); + + return tmp; +} + +/* + * Enable a variable watch without RCU lock + */ + +inline int __watch64_enable(unsigned long* ptr, struct watch64* st) +{ + if (!st) + st = __watch64_find(ptr); + + if (!st) + return -EINVAL; + + st->oldval = *ptr; + write_seqlock(&st->lock); + st->total = (u_int64_t) st->oldval; + write_sequnlock(&st->lock); + st->active = 1; + + return 0; +} + +/* + * Toggle a variable watch + */ + +int watch64_toggle(unsigned long* ptr, struct watch64* st) +{ + rcu_read_lock(); + if (!st) + st = __watch64_find(ptr); + + if (!st) { + rcu_read_unlock(); + return -EINVAL; + } + + if (st->active) + __watch64_disable(ptr,st); + else + __watch64_enable(ptr,st); + rcu_read_unlock(); + + return 0; +} + +/* + * Return the total 64-bit value + */ + +inline u_int64_t watch64_getval(unsigned long* ptr, struct watch64* st) +{ + unsigned int seq; + u_int64_t total; + + rcu_read_lock(); + if (!st) + st = __watch64_find(ptr); + + if (!st) { + rcu_read_unlock(); + return *ptr; + } + + do { + seq = read_seqbegin(&st->lock); + total = st->total; + } while (read_seqretry(&st->lock, seq)); + rcu_read_unlock(); + + return total; +} + +#endif /* (BITS_PER_LONG == 64) */ + +/* + * Export all the necessary symbols + */ + +EXPORT_SYMBOL(watch64_register); +EXPORT_SYMBOL(watch64_unregister); +EXPORT_SYMBOL(watch64_find); +EXPORT_SYMBOL(watch64_disable); +EXPORT_SYMBOL(watch64_enable); +EXPORT_SYMBOL(watch64_toggle); +EXPORT_SYMBOL(watch64_getval); --Boundary_(ID_Gu5A8t3yfXnZW0k3kEIBKg) Content-type: text/x-diff; charset=iso-8859-1; name=64network-patch Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=64network-patch diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h --- a/include/linux/netdevice.h 2004-09-03 12:22:08 -04:00 +++ b/include/linux/netdevice.h 2004-09-03 12:22:08 -04:00 @@ -14,6 +14,7 @@ * Alan Cox, * Bjorn Ekwall. * Pekka Riikonen + * Josef "Jeff" Sipek * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -945,6 +946,10 @@ #ifdef CONFIG_SYSCTL extern char *net_sysctl_strdup(const char *s); #endif + +/* * Register/unregister all the members of struct net_device_stats with watch64 */ +inline void net_register_stats64(struct net_device_stats* stats); +inline void net_unregister_stats64(struct net_device_stats* stats); #endif /* __KERNEL__ */ diff -Nru a/net/core/dev.c b/net/core/dev.c --- a/net/core/dev.c 2004-09-03 12:22:08 -04:00 +++ b/net/core/dev.c 2004-09-03 12:22:08 -04:00 @@ -18,6 +18,7 @@ * Alexey Kuznetsov * Adam Sulmicki * Pekka Riikonen + * Josef "Jeff" Sipek * * Changes: * D.J. Barrow : Fixed bug where dev->refcnt gets set @@ -70,6 +71,7 @@ * indefinitely on dev->refcnt * J Hadi Salim : - Backlog queue sampling * - netif_rx() feedback + * Josef "Jeff" Sipek : Added watch64 calls for network statistics */ #include @@ -108,6 +110,7 @@ #include #include #include +#include #ifdef CONFIG_NET_RADIO #include /* Note : will define WIRELESS_EXT */ #include @@ -2110,6 +2113,49 @@ seq_printf(seq, "%6s: No statistics available.\n", dev->name); } +static void dev_seq_printf_stats64(struct seq_file *seq, struct net_device *dev) +{ + if (dev->get_stats) { + struct net_device_stats *stats = dev->get_stats(dev); + + seq_printf(seq, "%6s:%8llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu " + "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n", + dev->name, watch64_getval(&stats->rx_bytes,NULL), + watch64_getval(&stats->rx_packets,NULL), + watch64_getval(&stats->rx_errors,NULL), + watch64_getval(&stats->rx_dropped,NULL) + + watch64_getval(&stats->rx_missed_errors,NULL), + watch64_getval(&stats->rx_fifo_errors,NULL), + watch64_getval(&stats->rx_length_errors,NULL) + + watch64_getval(&stats->rx_over_errors,NULL) + + watch64_getval(&stats->rx_crc_errors,NULL) + + watch64_getval(&stats->rx_frame_errors,NULL), + watch64_getval(&stats->rx_compressed,NULL), + watch64_getval(&stats->multicast,NULL), + watch64_getval(&stats->tx_bytes,NULL), + watch64_getval(&stats->tx_packets,NULL), + watch64_getval(&stats->tx_errors,NULL), + watch64_getval(&stats->tx_dropped,NULL), + watch64_getval(&stats->tx_fifo_errors,NULL), + watch64_getval(&stats->collisions,NULL), + watch64_getval(&stats->tx_carrier_errors,NULL) + + watch64_getval(&stats->tx_aborted_errors,NULL) + + watch64_getval(&stats->tx_window_errors,NULL) + + watch64_getval(&stats->tx_heartbeat_errors,NULL), + watch64_getval(&stats->tx_compressed,NULL)); + } else + seq_printf(seq, "%6s: No statistics available.\n", dev->name); +} + +static void dev_seq_show_header(struct seq_file *seq) +{ + seq_puts(seq, "Inter-| Receive " + " | Transmit\n" + " face |bytes packets errs drop fifo frame " + "compressed multicast|bytes packets errs " + "drop fifo colls carrier compressed\n"); +} + /* * Called from the PROCfs module. This now uses the new arbitrary sized * /proc/net interface to create /proc/net/dev @@ -2117,16 +2163,21 @@ static int dev_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) - seq_puts(seq, "Inter-| Receive " - " | Transmit\n" - " face |bytes packets errs drop fifo frame " - "compressed multicast|bytes packets errs " - "drop fifo colls carrier compressed\n"); + dev_seq_show_header(seq); else dev_seq_printf_stats(seq, v); return 0; } +static int dev_seq_show64(struct seq_file *seq, void *v) +{ + if (v == SEQ_START_TOKEN) + dev_seq_show_header(seq); + else + dev_seq_printf_stats64(seq, v); + return 0; +} + static struct netif_rx_stats *softnet_get_online(loff_t *pos) { struct netif_rx_stats *rc = NULL; @@ -2179,11 +2230,23 @@ .show = dev_seq_show, }; +static struct seq_operations dev_seq_ops64 = { + .start = dev_seq_start, + .next = dev_seq_next, + .stop = dev_seq_stop, + .show = dev_seq_show64, +}; + static int dev_seq_open(struct inode *inode, struct file *file) { return seq_open(file, &dev_seq_ops); } +static int dev_seq_open64(struct inode *inode, struct file *file) +{ + return seq_open(file, &dev_seq_ops64); +} + static struct file_operations dev_seq_fops = { .owner = THIS_MODULE, .open = dev_seq_open, @@ -2192,6 +2255,14 @@ .release = seq_release, }; +static struct file_operations dev_seq_fops64 = { + .owner = THIS_MODULE, + .open = dev_seq_open64, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static struct seq_operations softnet_seq_ops = { .start = softnet_seq_start, .next = softnet_seq_next, @@ -2224,8 +2295,10 @@ if (!proc_net_fops_create("dev", S_IRUGO, &dev_seq_fops)) goto out; - if (!proc_net_fops_create("softnet_stat", S_IRUGO, &softnet_seq_fops)) + if (!proc_net_fops_create("dev64", S_IRUGO, &dev_seq_fops64)) goto out_dev; + if (!proc_net_fops_create("softnet_stat", S_IRUGO, &softnet_seq_fops)) + goto out_dev64; if (wireless_proc_init()) goto out_softnet; rc = 0; @@ -2233,6 +2306,8 @@ return rc; out_softnet: proc_net_remove("softnet_stat"); +out_dev64: + proc_net_remove("dev64"); out_dev: proc_net_remove("dev"); goto out; @@ -2910,6 +2985,9 @@ * device is present. */ + if (dev->get_stats) + net_register_stats64(dev->get_stats(dev)); + set_bit(__LINK_STATE_PRESENT, &dev->state); dev->next = NULL; @@ -2922,7 +3000,7 @@ dev_hold(dev); dev->reg_state = NETREG_REGISTERING; write_unlock_bh(&dev_base_lock); - + /* Notify protocols, that a new device appeared. */ notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev); @@ -3145,6 +3223,9 @@ /* If device is running, close it first. */ if (dev->flags & IFF_UP) dev_close(dev); + + if (dev->get_stats) + net_unregister_stats64(dev->get_stats(dev)); /* And unlink it from device chain. */ for (dp = &dev_base; (d = *dp) != NULL; dp = &d->next) { @@ -3246,6 +3327,98 @@ } #endif /* CONFIG_HOTPLUG_CPU */ +/* + * Register all the members of the net_device_stats structure + * + */ + +inline void net_register_stats64(struct net_device_stats* stats) +{ + if (!stats) + return; + + watch64_register(&stats->tx_packets,0); + watch64_enable (&stats->tx_packets,NULL); + watch64_register(&stats->rx_packets,0); + watch64_enable (&stats->rx_packets,NULL); + watch64_register(&stats->tx_bytes,0); + watch64_enable (&stats->tx_bytes,NULL); + watch64_register(&stats->rx_bytes,0); + watch64_enable (&stats->rx_bytes,NULL); + watch64_register(&stats->tx_errors,0); + watch64_enable (&stats->tx_errors,NULL); + watch64_register(&stats->rx_errors,0); + watch64_enable (&stats->rx_errors,NULL); + watch64_register(&stats->tx_dropped,0); + watch64_enable (&stats->tx_dropped,NULL); + watch64_register(&stats->rx_dropped,0); + watch64_enable (&stats->rx_dropped,NULL); + watch64_register(&stats->multicast,0); + watch64_enable (&stats->multicast,NULL); + watch64_register(&stats->collisions,0); + watch64_enable (&stats->collisions,NULL); + watch64_register(&stats->rx_length_errors,0); + watch64_enable (&stats->rx_length_errors,NULL); + watch64_register(&stats->rx_over_errors,0); + watch64_enable (&stats->rx_over_errors,NULL); + watch64_register(&stats->rx_crc_errors,0); + watch64_enable (&stats->rx_crc_errors,NULL); + watch64_register(&stats->rx_frame_errors,0); + watch64_enable (&stats->rx_frame_errors,NULL); + watch64_register(&stats->rx_fifo_errors,0); + watch64_enable (&stats->rx_fifo_errors,NULL); + watch64_register(&stats->rx_missed_errors,0); + watch64_enable (&stats->rx_missed_errors,NULL); + watch64_register(&stats->tx_aborted_errors,0); + watch64_enable (&stats->tx_aborted_errors,NULL); + watch64_register(&stats->tx_carrier_errors,0); + watch64_enable (&stats->tx_carrier_errors,NULL); + watch64_register(&stats->tx_fifo_errors,0); + watch64_enable (&stats->tx_fifo_errors,NULL); + watch64_register(&stats->tx_heartbeat_errors,0); + watch64_enable (&stats->tx_heartbeat_errors,NULL); + watch64_register(&stats->tx_window_errors,0); + watch64_enable (&stats->tx_window_errors,NULL); + watch64_register(&stats->rx_compressed,0); + watch64_enable (&stats->rx_compressed,NULL); + watch64_register(&stats->tx_compressed,0); + watch64_enable (&stats->tx_compressed,NULL); +} + +/* + * Unregister all the members of the net_device_stats structure + * + */ + +inline void net_unregister_stats64(struct net_device_stats* stats) +{ + if (!stats) + return; + + watch64_unregister(&stats->tx_packets,0); + watch64_unregister(&stats->rx_packets,0); + watch64_unregister(&stats->tx_bytes,0); + watch64_unregister(&stats->rx_bytes,0); + watch64_unregister(&stats->tx_errors,0); + watch64_unregister(&stats->rx_errors,0); + watch64_unregister(&stats->tx_dropped,0); + watch64_unregister(&stats->rx_dropped,0); + watch64_unregister(&stats->multicast,0); + watch64_unregister(&stats->collisions,0); + watch64_unregister(&stats->rx_length_errors,0); + watch64_unregister(&stats->rx_over_errors,0); + watch64_unregister(&stats->rx_crc_errors,0); + watch64_unregister(&stats->rx_frame_errors,0); + watch64_unregister(&stats->rx_fifo_errors,0); + watch64_unregister(&stats->rx_missed_errors,0); + watch64_unregister(&stats->tx_aborted_errors,0); + watch64_unregister(&stats->tx_carrier_errors,0); + watch64_unregister(&stats->tx_fifo_errors,0); + watch64_unregister(&stats->tx_heartbeat_errors,0); + watch64_unregister(&stats->tx_window_errors,0); + watch64_unregister(&stats->rx_compressed,0); + watch64_unregister(&stats->tx_compressed,0); +} /* * Initialize the DEV module. At boot time this walks the device list and diff -Nru a/net/core/net-sysfs.c b/net/core/net-sysfs.c --- a/net/core/net-sysfs.c 2004-09-03 12:22:08 -04:00 +++ b/net/core/net-sysfs.c 2004-09-03 12:22:08 -04:00 @@ -16,6 +16,7 @@ #include #include #include +#include #define to_class_dev(obj) container_of(obj,struct class_device,kobj) #define to_net_dev(class) container_of(class, struct net_device, class_dev) @@ -23,6 +24,7 @@ static const char fmt_hex[] = "%#x\n"; static const char fmt_dec[] = "%d\n"; static const char fmt_ulong[] = "%lu\n"; +static const char fmt_ullong[] = "%llu\n"; static inline int dev_isalive(const struct net_device *dev) { @@ -204,8 +206,8 @@ read_lock(&dev_base_lock); if (dev_isalive(dev) && dev->get_stats && (stats = (*dev->get_stats)(dev))) - ret = sprintf(buf, fmt_ulong, - *(unsigned long *)(((u8 *) stats) + offset)); + ret = sprintf(buf, fmt_ullong, + watch64_getval((unsigned long *)(((u8 *) stats) + offset),NULL)); read_unlock(&dev_base_lock); return ret; --Boundary_(ID_Gu5A8t3yfXnZW0k3kEIBKg)-- From afleming@freescale.com Fri Sep 3 15:18:39 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 15:18:44 -0700 (PDT) Received: from motgate8.mot.com (motgate8.mot.com [129.188.136.8]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83MIdDg009752 for ; Fri, 3 Sep 2004 15:18:39 -0700 Received: from az33exr04.mot.com (pobox4.mot.com [10.64.251.243]) by motgate8.mot.com (Motorola/Motgate8) with ESMTP id i83MJYF7003825 for ; Fri, 3 Sep 2004 15:19:34 -0700 (MST) Received: from [10.82.17.240] ([10.82.17.240]) by az33exr04.mot.com (Motorola/az33exr04) with ESMTP id i83KHo3r026899 for ; Fri, 3 Sep 2004 15:18:16 -0500 Mime-Version: 1.0 (Apple Message framework v618) Content-Transfer-Encoding: 7bit Message-Id: <29D06014-FDF7-11D8-942E-000393C30512@freescale.com> Content-Type: text/plain; charset=US-ASCII; format=flowed To: netdev@oss.sgi.com From: Andy Fleming Subject: Using schedule_work for interrupt handling Date: Fri, 3 Sep 2004 17:18:20 -0500 X-Mailer: Apple Mail (2.618) X-archive-position: 8395 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: afleming@freescale.com Precedence: bulk X-list: netdev So I've done another bk pull (just a few minutes ago), and my driver is still broken. If this isn't the place to ask, please direct me to the appropriate list -- I'm getting desperate! So what I'm doing in my driver is handling the PHY link change interrupt by disabling and clearing the interrupt I recieve, then calling schedule_work() to invoke my actual handler outside of interrupt time. That function calls the various PHY configuration functions, configures the controller state appropriately, and then enables interrupts before returning. The entire interrupt function is: static irqreturn_t phy_interrupt(int irq, void *dev_id, struct pt_regs *regs) { struct net_device *dev = (struct net_device *) dev_id; struct gfar_private *priv = netdev_priv(dev); /* Clear the interrupt */ mii_clear_phy_interrupt(priv->mii_info); /* Disable PHY interrupts */ mii_configure_phy_interrupt(priv->mii_info, MII_INTERRUPT_DISABLED); /* Schedule the phy change */ schedule_work(&priv->tq); return IRQ_HANDLED; } In the gfar_startup() function (called from gfar_open()), I initialize the work queue: INIT_WORK(&priv->tq, gfar_phy_change, dev); And later, I request the irq: if (priv->einfo->flags & GFAR_HAS_PHY_INTR) { if (request_irq(priv->einfo->interruptPHY, phy_interrupt, SA_SHIRQ, "phy_interrupt", mii_info->dev) < 0) { printk(KERN_ERR "%s: Can't get IRQ %d (PHY)\n", mii_info->dev->name, priv->einfo->interruptPHY); } else { mii_configure_phy_interrupt(priv->mii_info, MII_INTERRUPT_ENABLED); return; } } (If the requesting the interrupt fails, it uses a timer, instead) Is this right? Am I missing a crucial step? I ask because this no longer works. The driver never successfully invokes gfar_phy_change(), and therefore never brings up the interface. I have tried MANY, MANY things to get this working for the last 2+ weeks, and nothing has succeeded. I can detail what I have done so far, if people think it will help, but for now I'm just seeing if anyone notices a flaw in my code (code which, I might add, works in 2.6.8.1). Is this just what I get for not using a "stable" kernel? If that's the case, then should I be submitting a bug to someone, so they know there may be a problem...somewhere? Thanks for any help, Andy Fleming PowerPC Software Enablement Freescale Semiconductor, Inc. From herbert@gondor.apana.org.au Fri Sep 3 16:50:06 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 16:50:14 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i83No40i014551 for ; Fri, 3 Sep 2004 16:50:05 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1C3NoP-0002T3-00; Sat, 04 Sep 2004 09:49:45 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1C3NoM-0001am-00; Sat, 04 Sep 2004 09:49:42 +1000 Date: Sat, 4 Sep 2004 09:49:41 +1000 To: Stephen Hemminger Cc: "David S. Miller" , netdev@oss.sgi.com Subject: Re: neigh_create/inetdev_destroy race? Message-ID: <20040903234941.GA26247@gondor.apana.org.au> References: <20040815191450.77532d5d.davem@redhat.com> <20040816105131.GA11299@gondor.apana.org.au> <20040828234201.79556f6e.davem@davemloft.net> <20040829065031.GA786@gondor.apana.org.au> <20040830230820.7514985d.davem@davemloft.net> <20040831104139.GA2124@gondor.apana.org.au> <20040901222118.0ce4bcc6.davem@davemloft.net> <20040902130605.GA32570@gondor.apana.org.au> <20040903133623.GA23179@gondor.apana.org.au> <20040903090053.22c67bb9@dell_ss3.pdx.osdl.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="DocE+STaALJfprDB" Content-Disposition: inline In-Reply-To: <20040903090053.22c67bb9@dell_ss3.pdx.osdl.net> User-Agent: Mutt/1.5.6+20040722i From: Herbert Xu X-archive-position: 8396 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Sep 03, 2004 at 09:00:53AM -0700, Stephen Hemminger wrote: > > > You'll also notice that I've put all dereferences of dev->*_ptr under > > the rcu_read_lock(). Without this we may get a neigh_parms that's > > already been released. > > I haven't looked at the exact code in detail, but don't you need > use rcu_dereference() as well to make sure and get the smp_read_barrier_depends > on Alpha. Not really because we're not depending on *dev->neigh_parms to be set to NULLon shutdown. In fact *dev->neigh_parms never gets set to NULL at all. If it did we'd have trouble cleaning up dead entries from the hash table. So there is no data-dependent read here whose order must be preserved when *dev is destroyed. But hang on a second, I had forgotten about the creation path. Indeed that is buggy without a barrier for every path except IPv6. Without the barrier, we may be reading NULL pointers from parms which may result in stale neigh entries lingering around. Or worse we may read complete garbage that was there before the memset on *dev was done. Fortunately the last bit probably can only be triggered if you're stepping through gdb :) So here is a patch to make sure that there is a barrier between the reading of dev->*_ptr and *dev->neigh_parms. With these barriers in place, it's clear that *dev->neigh_parms can no longer be NULL since once the parms are allocated, that pointer is never reset to NULL again. Therefore I've also removed the parms check in these paths. They were bogus to begin with since if they ever triggered then we'll have dead neigh entries stuck in the hash table. Unfortunately I couldn't arrange for this to happen with DECnet due to the dn_db->parms.up() call that's sandwiched between the assignment of dev->dn_ptr and dn_db->neigh_parms. So I've kept the parms check there but it will now fail instead of continuing. I've also added an smp_wmb() there so that at least we won't be reading garbage from dn_db->neigh_parms. DECnet is also buggy since there is no locking at all in the destruction path. It either needs locking or RCU like IPv4. Signed-off-by: Herbert Xu Thanks a lot, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p ===== drivers/s390/net/qeth_main.c 1.14 vs edited ===== --- 1.14/drivers/s390/net/qeth_main.c 2004-09-04 08:22:06 +10:00 +++ edited/drivers/s390/net/qeth_main.c 2004-09-04 09:17:17 +10:00 @@ -6718,17 +6718,15 @@ } rcu_read_lock(); - in_dev = __in_dev_get(dev); + in_dev = rcu_dereference(__in_dev_get(dev)); if (in_dev == NULL) { rcu_read_unlock(); return -EINVAL; } parms = in_dev->arp_parms; - if (parms) { - __neigh_parms_put(neigh->parms); - neigh->parms = neigh_parms_clone(parms); - } + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); rcu_read_unlock(); neigh->type = inet_addr_type(*(u32 *) neigh->primary_key); ===== net/atm/clip.c 1.37 vs edited ===== --- 1.37/net/atm/clip.c 2004-09-04 08:22:07 +10:00 +++ edited/net/atm/clip.c 2004-09-04 09:18:22 +10:00 @@ -320,17 +320,15 @@ if (neigh->type != RTN_UNICAST) return -EINVAL; rcu_read_lock(); - in_dev = __in_dev_get(dev); + in_dev = rcu_dereference(__in_dev_get(dev)); if (!in_dev) { rcu_read_unlock(); return -EINVAL; } parms = in_dev->arp_parms; - if (parms) { - __neigh_parms_put(neigh->parms); - neigh->parms = neigh_parms_clone(parms); - } + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); rcu_read_unlock(); neigh->ops = &clip_neigh_ops; ===== net/decnet/dn_dev.c 1.25 vs edited ===== --- 1.25/net/decnet/dn_dev.c 2004-09-04 08:22:07 +10:00 +++ edited/net/decnet/dn_dev.c 2004-09-04 09:36:51 +10:00 @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -1108,6 +1109,7 @@ memset(dn_db, 0, sizeof(struct dn_dev)); memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms)); + smp_wmb(); dev->dn_ptr = dn_db; dn_db->dev = dev; init_timer(&dn_db->timer); ===== net/decnet/dn_neigh.c 1.11 vs edited ===== --- 1.11/net/decnet/dn_neigh.c 2004-09-04 08:22:07 +10:00 +++ edited/net/decnet/dn_neigh.c 2004-09-04 09:33:12 +10:00 @@ -139,17 +139,20 @@ struct neigh_parms *parms; rcu_read_lock(); - dn_db = dev->dn_ptr; + dn_db = rcu_dereference(dev->dn_ptr); if (dn_db == NULL) { rcu_read_unlock(); return -EINVAL; } parms = dn_db->neigh_parms; - if (parms) { - __neigh_parms_put(neigh->parms); - neigh->parms = neigh_parms_clone(parms); + if (!parms) { + rcu_read_unlock(); + return -EINVAL; } + + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); rcu_read_unlock(); if (dn_db->use_long) ===== net/ipv4/arp.c 1.45 vs edited ===== --- 1.45/net/ipv4/arp.c 2004-09-04 08:22:07 +10:00 +++ edited/net/ipv4/arp.c 2004-09-04 09:17:46 +10:00 @@ -244,17 +244,15 @@ neigh->type = inet_addr_type(addr); rcu_read_lock(); - in_dev = __in_dev_get(dev); + in_dev = rcu_dereference(__in_dev_get(dev)); if (in_dev == NULL) { rcu_read_unlock(); return -EINVAL; } parms = in_dev->arp_parms; - if (parms) { - __neigh_parms_put(neigh->parms); - neigh->parms = neigh_parms_clone(parms); - } + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); rcu_read_unlock(); if (dev->hard_header == NULL) { ===== net/ipv6/ndisc.c 1.88 vs edited ===== --- 1.88/net/ipv6/ndisc.c 2004-09-04 08:22:07 +10:00 +++ edited/net/ipv6/ndisc.c 2004-09-04 09:28:12 +10:00 @@ -297,10 +297,8 @@ } parms = in6_dev->nd_parms; - if (parms) { - __neigh_parms_put(neigh->parms); - neigh->parms = neigh_parms_clone(parms); - } + __neigh_parms_put(neigh->parms); + neigh->parms = neigh_parms_clone(parms); rcu_read_unlock(); neigh->type = is_multicast ? RTN_MULTICAST : RTN_UNICAST; --DocE+STaALJfprDB-- From jgarzik@infradead.org Fri Sep 3 19:56:52 2004 Received: with ECARTIS (v1.0.0; list netdev); Fri, 03 Sep 2004 19:56:57 -0700 (PDT) Received: from canuck.infradead.org (canuck.infradead.org [205.233.218.70]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i842upX2017313 for ; Fri, 3 Sep 2004 19:56:52 -0700 Received: from jgarzik by canuck.infradead.org with local (Exim 4.33 #1 (Red Hat Linux)) id 1C3QjI-00074m-PP; Fri, 03 Sep 2004 22:56:40 -0400 Date: Fri, 3 Sep 2004 22:56:40 -0400 From: Jeff Garzik To: akpm@osdl.org, torvalds@osdl.org Cc: netdev@oss.sgi.com Subject: [BK PATCHES] 2.6.x net driver fixes Message-ID: <20040904025640.GA27001@canuck.infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-archive-position: 8397 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jgarzik@pobox.com Precedence: bulk X-list: netdev Please do a bk pull bk://gkernel.bkbits.net/net-drivers-2.6 This will update the following files: drivers/net/3c527.c | 13 ++---- drivers/net/8139cp.c | 2 - drivers/net/forcedeth.c | 78 +++++++++++++++++++++++++++-------------- drivers/net/r8169.c | 2 - drivers/net/wireless/airo.c | 1 drivers/net/wireless/wavelan.c | 11 +++-- 6 files changed, 66 insertions(+), 41 deletions(-) through these ChangeSets: (04/09/03 1.2021) [PATCH] fix media detection for nForce 2 nics attached is a patch that polls the media setting for non GigE nForce nics: Without polling, media changes are not autodetected. This is fatal, because the nic initialization is asynchroneous, thus "modprobe;ifup" resulted in a dead network connection. The attached patch fixes that problem. It's a repost of a patch I sent around three weeks ago: you objected that I rely on the nic irq instead of a software timer. I've documented why this is ok. (04/09/03 1.2020) [PATCH] airo build fix drivers/net/wireless/airo.c: In function `issuecommand': drivers/net/wireless/airo.c:3812: warning: implicit declaration of function `kernel_locked' *** Warning: "kernel_locked" [drivers/net/wireless/airo.ko] undefined! Signed-off-by: Andrew Morton (04/09/03 1.2019) [PATCH] wavelan uninitalised var. This seems a little odd, printing out the value of a variable we haven't read yet. Signed-off-by: Dave Jones (04/09/03 1.2018) [PATCH] 3c527 possible oops. If the alloc_skb() fails, we dereference it in the skb_reserve() call. Move the skb_reserve() call to after the NULL check. Also clean up some CodingStyle violations whilst in the vicinity. Signed-off-by: Dave Jones (04/08/31 1.1860.2.1) [netdrvr 8139cp,r8169] fix dma_addr_t sizeof test diff -Nru a/drivers/net/3c527.c b/drivers/net/3c527.c --- a/drivers/net/3c527.c 2004-09-03 22:20:03 -04:00 +++ b/drivers/net/3c527.c 2004-09-03 22:20:03 -04:00 @@ -751,18 +751,15 @@ rx_base=lp->rx_chain; - for(i=0; irx_ring[i].skb=alloc_skb(1532, GFP_KERNEL); - skb_reserve(lp->rx_ring[i].skb, 18); - - if(lp->rx_ring[i].skb==NULL) - { - for(;i>=0;i--) + if (lp->rx_ring[i].skb==NULL) { + for (;i>=0;i--) kfree_skb(lp->rx_ring[i].skb); return -ENOBUFS; } - + skb_reserve(lp->rx_ring[i].skb, 18); + p=isa_bus_to_virt(lp->base+rx_base); p->control=0; diff -Nru a/drivers/net/8139cp.c b/drivers/net/8139cp.c --- a/drivers/net/8139cp.c 2004-09-03 22:20:03 -04:00 +++ b/drivers/net/8139cp.c 2004-09-03 22:20:03 -04:00 @@ -1698,7 +1698,7 @@ } /* Configure DMA attributes. */ - if ((sizeof(dma_addr_t) > 32) && + if ((sizeof(dma_addr_t) > 4) && !pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL) && !pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) { pci_using_dac = 1; diff -Nru a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c --- a/drivers/net/forcedeth.c 2004-09-03 22:20:03 -04:00 +++ b/drivers/net/forcedeth.c 2004-09-03 22:20:03 -04:00 @@ -75,6 +75,7 @@ * added CK804/MCP04 device IDs, code fixes * for registers, link status and other minor fixes. * 0.28: 21 Jun 2004: Big cleanup, making driver mostly endian safe + * 0.29: 31 Aug 2004: Add backup timer for link change notification. * * Known bugs: * We suspect that on some hardware no TX done interrupts are generated. @@ -86,7 +87,7 @@ * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few * superfluous timer interrupts from the nic. */ -#define FORCEDETH_VERSION "0.28" +#define FORCEDETH_VERSION "0.29" #define DRV_NAME "forcedeth" #include @@ -120,10 +121,11 @@ * Hardware access: */ -#define DEV_NEED_LASTPACKET1 0x0001 -#define DEV_IRQMASK_1 0x0002 -#define DEV_IRQMASK_2 0x0004 -#define DEV_NEED_TIMERIRQ 0x0008 +#define DEV_NEED_LASTPACKET1 0x0001 /* set LASTPACKET1 in tx flags */ +#define DEV_IRQMASK_1 0x0002 /* use NVREG_IRQMASK_WANTED_1 for irq mask */ +#define DEV_IRQMASK_2 0x0004 /* use NVREG_IRQMASK_WANTED_2 for irq mask */ +#define DEV_NEED_TIMERIRQ 0x0008 /* set the timer irq flag in the irq mask */ +#define DEV_NEED_LINKTIMER 0x0010 /* poll link settings. Relies on the timer irq */ enum { NvRegIrqStatus = 0x000, @@ -367,6 +369,7 @@ #define OOM_REFILL (1+HZ/20) #define POLL_WAIT (1+HZ/100) +#define LINK_TIMEOUT (3*HZ) #define DESC_VER_1 0x0 #define DESC_VER_2 0x02100 @@ -446,6 +449,11 @@ struct timer_list oom_kick; struct timer_list nic_poll; + /* media detection workaround. + * Locking: Within irq hander or disable_irq+spin_lock(&np->lock); + */ + int need_linktimer; + unsigned long link_timeout; /* * tx specific fields. */ @@ -1384,6 +1392,25 @@ return retval; } +static void nv_linkchange(struct net_device *dev) +{ + if (nv_update_linkspeed(dev)) { + if (netif_carrier_ok(dev)) { + nv_stop_rx(dev); + } else { + netif_carrier_on(dev); + printk(KERN_INFO "%s: link up.\n", dev->name); + } + nv_start_rx(dev); + } else { + if (netif_carrier_ok(dev)) { + netif_carrier_off(dev); + printk(KERN_INFO "%s: link down.\n", dev->name); + nv_stop_rx(dev); + } + } +} + static void nv_link_irq(struct net_device *dev) { u8 *base = get_hwbase(dev); @@ -1391,25 +1418,10 @@ miistat = readl(base + NvRegMIIStatus); writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus); - dprintk(KERN_DEBUG "%s: link change notification, status 0x%x.\n", dev->name, miistat); + dprintk(KERN_INFO "%s: link change irq, status 0x%x.\n", dev->name, miistat); - if (miistat & (NVREG_MIISTAT_LINKCHANGE)) { - if (nv_update_linkspeed(dev)) { - if (netif_carrier_ok(dev)) { - nv_stop_rx(dev); - } else { - netif_carrier_on(dev); - printk(KERN_INFO "%s: link up.\n", dev->name); - } - nv_start_rx(dev); - } else { - if (netif_carrier_ok(dev)) { - netif_carrier_off(dev); - printk(KERN_INFO "%s: link down.\n", dev->name); - nv_stop_rx(dev); - } - } - } + if (miistat & (NVREG_MIISTAT_LINKCHANGE)) + nv_linkchange(dev); dprintk(KERN_DEBUG "%s: link change notification done.\n", dev->name); } @@ -1452,6 +1464,12 @@ nv_link_irq(dev); spin_unlock(&np->lock); } + if (np->need_linktimer && time_after(jiffies, np->link_timeout)) { + spin_lock(&np->lock); + nv_linkchange(dev); + spin_unlock(&np->lock); + np->link_timeout = jiffies + LINK_TIMEOUT; + } if (events & (NVREG_IRQ_TX_ERR)) { dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n", dev->name, events); @@ -1816,6 +1834,14 @@ np->irqmask = NVREG_IRQMASK_WANTED_2; if (id->driver_data & DEV_NEED_TIMERIRQ) np->irqmask |= NVREG_IRQ_TIMER; + if (id->driver_data & DEV_NEED_LINKTIMER) { + dprintk(KERN_INFO "%s: link timer on.\n", pci_name(pci_dev)); + np->need_linktimer = 1; + np->link_timeout = jiffies + LINK_TIMEOUT; + } else { + dprintk(KERN_INFO "%s: link timer off.\n", pci_name(pci_dev)); + np->need_linktimer = 0; + } /* find a suitable phy */ for (i = 1; i < 32; i++) { @@ -1909,21 +1935,21 @@ .device = PCI_DEVICE_ID_NVIDIA_NVENET_1, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, - .driver_data = DEV_IRQMASK_1|DEV_NEED_TIMERIRQ, + .driver_data = DEV_IRQMASK_1|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER, }, { /* nForce2 Ethernet Controller */ .vendor = PCI_VENDOR_ID_NVIDIA, .device = PCI_DEVICE_ID_NVIDIA_NVENET_2, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, - .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER, }, { /* nForce3 Ethernet Controller */ .vendor = PCI_VENDOR_ID_NVIDIA, .device = PCI_DEVICE_ID_NVIDIA_NVENET_3, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, - .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER, }, { /* nForce3 Ethernet Controller */ .vendor = PCI_VENDOR_ID_NVIDIA, diff -Nru a/drivers/net/r8169.c b/drivers/net/r8169.c --- a/drivers/net/r8169.c 2004-09-03 22:20:03 -04:00 +++ b/drivers/net/r8169.c 2004-09-03 22:20:03 -04:00 @@ -983,7 +983,7 @@ tp->cp_cmd = PCIMulRW | RxChkSum; - if ((sizeof(dma_addr_t) > 32) && + if ((sizeof(dma_addr_t) > 4) && !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) tp->cp_cmd |= PCIDAC; else { diff -Nru a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c --- a/drivers/net/wireless/airo.c 2004-09-03 22:20:03 -04:00 +++ b/drivers/net/wireless/airo.c 2004-09-03 22:20:03 -04:00 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff -Nru a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c --- a/drivers/net/wireless/wavelan.c 2004-09-03 22:20:03 -04:00 +++ b/drivers/net/wireless/wavelan.c 2004-09-03 22:20:03 -04:00 @@ -3822,17 +3822,18 @@ if ((hasr & HASR_MMC_INTR) && (lp->hacr & HACR_MMC_INT_ENABLE)) { u8 dce_status; -#ifdef DEBUG_INTERRUPT_ERROR - printk(KERN_INFO - "%s: wavelan_interrupt(): unexpected mmc interrupt: status 0x%04x.\n", - dev->name, dce_status); -#endif /* * Interrupt from the modem management controller. * This will clear it -- ignored for now. */ mmc_read(ioaddr, mmroff(0, mmr_dce_status), &dce_status, sizeof(dce_status)); + +#ifdef DEBUG_INTERRUPT_ERROR + printk(KERN_INFO + "%s: wavelan_interrupt(): unexpected mmc interrupt: status 0x%04x.\n", + dev->name, dce_status); +#endif } /* Check if not controller interrupt */ From hadi@cyberus.ca Sat Sep 4 06:20:31 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 06:20:36 -0700 (PDT) Received: from lotus.znyx.com (znx208-2-156-007.znyx.com [208.2.156.7]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84DKVQn007432 for ; Sat, 4 Sep 2004 06:20:31 -0700 Received: from localhost ([208.2.156.2]) by lotus.znyx.com (Lotus Domino Release 5.0.11) with ESMTP id 2004090406215222:29254 ; Sat, 4 Sep 2004 06:21:52 -0700 Subject: Re: [PATCH 2.6] watch64: generic variable monitoring system From: jamal Reply-To: hadi@cyberus.ca To: "Josef 'Jeff' Sipek" Cc: Stephen Hemminger , linux-kernel@vger.kernel.org, netdev@oss.sgi.com In-Reply-To: <200409031744.32970.jeffpc@optonline.net> References: <200409031307.01240.jeffpc@optonline.net> <200409031319.24863.jeffpc@optonline.net> <20040903121657.355a6a8b@dell_ss3.pdx.osdl.net> <200409031744.32970.jeffpc@optonline.net> Organization: jamalopolis Message-Id: <1094303999.1633.116.camel@jzny.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 04 Sep 2004 09:19:59 -0400 X-MIMETrack: Itemize by SMTP Server on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/04/2004 06:21:52 AM, Serialize by Router on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/04/2004 06:21:55 AM, Serialize complete at 09/04/2004 06:21:55 AM Content-Transfer-Encoding: 7bit Content-Type: text/plain X-archive-position: 8398 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hadi@cyberus.ca Precedence: bulk X-list: netdev I have a feeling this was discussed somewhere(other than netdev) and i missed it. Why isnt this watch64 being done in user space? cheers, jamal On Fri, 2004-09-03 at 17:44, Josef 'Jeff' Sipek wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Friday 03 September 2004 15:16, Stephen Hemminger wrote: > > - Code doesn't match the kernel style (read Documentation/CodingStyle) > > Sorry about the white space, KMail apparently likes to butcher the text. These > are the same patches with the little cleanup update. > > Jeff. > > - -- > Reality is merely an illusion, albeit a very persistent one. > - Albert Einstein > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.5 (GNU/Linux) > > iD4DBQFBOOW+wFP0+seVj/4RAgSiAJj54qcqdEx66lbMW9ik0XviupTNAKC82an1 > R0pGX0pTBZ78NWrZpxJm+w== > =EesC > -----END PGP SIGNATURE----- From ak@muc.de Sat Sep 4 06:28:20 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 06:28:24 -0700 (PDT) Received: from colin2.muc.de (qmailr@colin2.muc.de [193.149.48.15]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i84DSJ1o007817 for ; Sat, 4 Sep 2004 06:28:19 -0700 Received: (qmail 42471 invoked by uid 3709); 4 Sep 2004 13:28:09 -0000 Date: 4 Sep 2004 15:28:09 +0200 Date: Sat, 4 Sep 2004 15:28:09 +0200 From: Andi Kleen To: "David S. Miller" Cc: kuznet@ms2.inr.ac.ru, netdev@oss.sgi.com, akepner@sgi.com Subject: Re: [PATCH] Extend lock less TX to real devices Message-ID: <20040904132809.GB33964@muc.de> References: <20040901223301.1a8d97a8.davem@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040901223301.1a8d97a8.davem@redhat.com> User-Agent: Mutt/1.4.1i X-archive-position: 8399 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ak@muc.de Precedence: bulk X-list: netdev On Wed, Sep 01, 2004 at 10:33:01PM -0700, David S. Miller wrote: > On Tue, 31 Aug 2004 14:38:20 +0200 > Andi Kleen wrote: > > > This patch extends the recently added NETIF_F_LLTX to real devices. > > Well, it does a lot of other things too. Not really, it all works to the same goal. > > > I added support for trylocking instead of spinning like sch_generic > > does - for that the driver has to return -1, then the packet is requeued. > > The check for a local device deadlock is lost for this case, > > but that doesn't seem to be a big loss (I've never seen this printk > > ever get triggered) > > It is triggerable if you misconfigure your system. Really? The only reason I can see for it is a buggy driver. > I'm totally against this change, because previously at There is no change, except for drivers that set LLTX and these get different semantics anyways because they have to handle this on their own. In case the driver has bugs I guess it would be better to add the printk directly below the try_lock in the LLTX driver. > least the user would find out in their logs. With your > change the system explodes looping with no explanation why. Hmm, I guess if you're really worried about this class of driver bugs being common adding some real error handling for it (like bailing out and disabling the device) would be the far better option. > > > The patch looks bigger than it really is because i moved some code > > around and converted the macros into inlines. > .. > > I also did an additional micro optimization: > > And for this reason you need to split this patch up. > I would recommend: > > patch 1) Change macros into inlines > patch 2) local_bh_disable() preemption count optimization > patch 3) support for F_LLTX on real devices > patch 4) locking changes At least (3) and (4) are the same thing. I can drop the inlines, it was only for making the code clearer and less ugly but is not essential for the optimizations. -Andi From ak@suse.de Sat Sep 4 06:54:55 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 06:55:00 -0700 (PDT) Received: from Cantor.suse.de (cantor.suse.de [195.135.220.2]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84Dsrud008610 for ; Sat, 4 Sep 2004 06:54:54 -0700 Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id C6BCEB7E597; Sat, 4 Sep 2004 15:54:39 +0200 (CEST) Date: Sat, 4 Sep 2004 15:54:39 +0200 From: Andi Kleen To: davem@redhat.com, netdev@oss.sgi.com Subject: [PATCH] Do less atomic count changes in dev_queue_xmit Message-ID: <20040904135439.GA23934@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-archive-position: 8400 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ak@suse.de Precedence: bulk X-list: netdev Do a single local_bh_disable and a single local_bh_enable instead of changing the atomic count all the time in dev_queue_xmit. Should mostly benefit preemptible kernels, but others see some small improvements too. diff -u linux-2.6.8/net/core/dev.c-o linux-2.6.8/net/core/dev.c --- linux-2.6.8/net/core/dev.c-o 2004-09-04 13:10:47.000000000 +0000 +++ linux-2.6.8/net/core/dev.c 2004-09-04 13:47:16.765722813 +0000 @@ -1249,14 +1249,14 @@ return 0; } -#define HARD_TX_LOCK_BH(dev, cpu) { \ +#define HARD_TX_LOCK(dev, cpu) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \ spin_lock_bh(&dev->xmit_lock); \ dev->xmit_lock_owner = cpu; \ } \ } -#define HARD_TX_UNLOCK_BH(dev) { \ +#define HARD_TX_UNLOCK(dev) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \ dev->xmit_lock_owner = -1; \ spin_unlock_bh(&dev->xmit_lock); \ @@ -1313,7 +1313,12 @@ if (skb_checksum_help(&skb, 0)) goto out_kfree_skb; - rcu_read_lock(); + + /* Disable soft irqs for various locks below. Also + * stops preemption for RCU. + */ + local_bh_disable(); + /* Updates of qdisc are serialized by queue_lock. * The struct Qdisc which is pointed to by qdisc is now a * rcu structure - it may be accessed without acquiring @@ -1332,18 +1337,16 @@ #endif if (q->enqueue) { /* Grab device queue */ - spin_lock_bh(&dev->queue_lock); + spin_lock(&dev->queue_lock); rc = q->enqueue(skb, q); qdisc_run(dev); - spin_unlock_bh(&dev->queue_lock); - rcu_read_unlock(); + spin_unlock(&dev->queue_lock); rc = rc == NET_XMIT_BYPASS ? NET_XMIT_SUCCESS : rc; goto out; } - rcu_read_unlock(); /* The device has no queue. Common case for software devices: loopback, all the sorts of tunnels... @@ -1358,12 +1361,11 @@ Either shot noqueue qdisc, it is even simpler 8) */ if (dev->flags & IFF_UP) { - int cpu = get_cpu(); + int cpu = smp_processor_id(); /* ok because BHs are off */ if (dev->xmit_lock_owner != cpu) { - HARD_TX_LOCK_BH(dev, cpu); - put_cpu(); + HARD_TX_LOCK(dev, cpu); if (!netif_queue_stopped(dev)) { if (netdev_nit) @@ -1371,17 +1373,16 @@ rc = 0; if (!dev->hard_start_xmit(skb, dev)) { - HARD_TX_UNLOCK_BH(dev); + HARD_TX_UNLOCK(dev); goto out; } } - HARD_TX_UNLOCK_BH(dev); + HARD_TX_UNLOCK(dev); if (net_ratelimit()) printk(KERN_CRIT "Virtual device %s asks to " "queue packet!\n", dev->name); goto out_enetdown; } else { - put_cpu(); /* Recursion is detected! It is possible, * unfortunately */ if (net_ratelimit()) @@ -1394,6 +1395,7 @@ out_kfree_skb: kfree_skb(skb); out: + local_bh_enable(); return rc; } From hadi@cyberus.ca Sat Sep 4 07:12:20 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 07:12:25 -0700 (PDT) Received: from lotus.znyx.com (znx208-2-156-007.znyx.com [208.2.156.7]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84ECK2R009182 for ; Sat, 4 Sep 2004 07:12:20 -0700 Received: from localhost ([208.2.156.2]) by lotus.znyx.com (Lotus Domino Release 5.0.11) with ESMTP id 2004090407134204:29279 ; Sat, 4 Sep 2004 07:13:42 -0700 Subject: Re: [PATCH] Extend lock less TX to real devices From: jamal Reply-To: hadi@cyberus.ca To: Andi Kleen Cc: "David S. Miller" , Alexey , netdev@oss.sgi.com, akepner@sgi.com In-Reply-To: <20040904132809.GB33964@muc.de> References: <20040901223301.1a8d97a8.davem@redhat.com> <20040904132809.GB33964@muc.de> Organization: jamalopolis Message-Id: <1094307106.1634.147.camel@jzny.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 04 Sep 2004 10:11:46 -0400 X-MIMETrack: Itemize by SMTP Server on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/04/2004 07:13:42 AM, Serialize by Router on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/04/2004 07:13:44 AM, Serialize complete at 09/04/2004 07:13:44 AM Content-Transfer-Encoding: 7bit Content-Type: text/plain X-archive-position: 8401 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hadi@cyberus.ca Precedence: bulk X-list: netdev On Sat, 2004-09-04 at 09:28, Andi Kleen wrote: > On Wed, Sep 01, 2004 at 10:33:01PM -0700, David S. Miller wrote: > > On Tue, 31 Aug 2004 14:38:20 +0200 > > Andi Kleen wrote: > > > > > This patch extends the recently added NETIF_F_LLTX to real devices. > > > > Well, it does a lot of other things too. > > Not really, it all works to the same goal. Must be my sleep depravation - what is LLTX again? > > least the user would find out in their logs. With your > > change the system explodes looping with no explanation why. > > Hmm, I guess if you're really worried about this class > of driver bugs ble eing common adding some real error handling > for it (like bailing out and disabling the device) would > be the far better option. Actually that message is pretty useful. I have seen at least a handful of badly written drivers do that. Was also very useful for me when i was doing the tc extensions. I was able to catch a few bugs - so not just driver related. > > patch 1) Change macros into inlines > > patch 2) local_bh_disable() preemption count optimization > > patch 3) support for F_LLTX on real devices > > patch 4) locking changes > > At least (3) and (4) are the same thing. I can drop the > inlines, it was only for making the code clearer and less ugly > but is not essential for the optimizations. do you guys mind if i test these patches/patch out first before final inclusion? Next weekend i will have the chance. cheers, jamal From ak@suse.de Sat Sep 4 07:27:08 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 07:27:13 -0700 (PDT) Received: from Cantor.suse.de (cantor.suse.de [195.135.220.2]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84ER76U009692 for ; Sat, 4 Sep 2004 07:27:07 -0700 Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 0D877B7DB65; Sat, 4 Sep 2004 16:24:14 +0200 (CEST) Date: Sat, 4 Sep 2004 16:24:04 +0200 From: Andi Kleen To: jamal Cc: Andi Kleen , "David S. Miller" , Alexey , netdev@oss.sgi.com, akepner@sgi.com Subject: Re: [PATCH] Extend lock less TX to real devices Message-ID: <20040904142404.GA6850@wotan.suse.de> References: <20040901223301.1a8d97a8.davem@redhat.com> <20040904132809.GB33964@muc.de> <1094307106.1634.147.camel@jzny.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1094307106.1634.147.camel@jzny.localdomain> X-archive-position: 8402 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ak@suse.de Precedence: bulk X-list: netdev On Sat, Sep 04, 2004 at 10:11:46AM -0400, jamal wrote: > On Sat, 2004-09-04 at 09:28, Andi Kleen wrote: > > On Wed, Sep 01, 2004 at 10:33:01PM -0700, David S. Miller wrote: > > > On Tue, 31 Aug 2004 14:38:20 +0200 > > > Andi Kleen wrote: > > > > > > > This patch extends the recently added NETIF_F_LLTX to real devices. > > > > > > Well, it does a lot of other things too. > > > > Not really, it all works to the same goal. > > Must be my sleep depravation - what is LLTX again? NETIF_F_LLTX - a new flag that tells the stack the the driver doesn't want an xmit lock. > > > > > least the user would find out in their logs. With your > > > change the system explodes looping with no explanation why. > > > > Hmm, I guess if you're really worried about this class > > of driver bugs ble eing common adding some real error handling > > for it (like bailing out and disabling the device) would > > be the far better option. > > Actually that message is pretty useful. > I have seen at least a handful of badly written drivers do that. They will still print that, no problem. > > > > patch 1) Change macros into inlines > > > patch 2) local_bh_disable() preemption count optimization > > > patch 3) support for F_LLTX on real devices > > > patch 4) locking changes > > > > At least (3) and (4) are the same thing. I can drop the > > inlines, it was only for making the code clearer and less ugly > > but is not essential for the optimizations. > > do you guys mind if i test these patches/patch out first before final > inclusion? Next weekend i will have the chance. You can do that, but they won't do much unless your driver sets NETIF_F_LLTX. -Andi From herbert@gondor.apana.org.au Sat Sep 4 12:40:41 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 12:40:49 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84Jeeam022183 for ; Sat, 4 Sep 2004 12:40:41 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1C3gNk-0000EX-00; Sun, 05 Sep 2004 05:39:28 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1C3gNb-0006DO-00; Sun, 05 Sep 2004 05:39:19 +1000 From: Herbert Xu To: ak@muc.de (Andi Kleen) Subject: Re: [PATCH] Extend lock less TX to real devices Cc: davem@redhat.com, kuznet@ms2.inr.ac.ru, netdev@oss.sgi.com, akepner@sgi.com Organization: Core In-Reply-To: <20040904132809.GB33964@muc.de> X-Newsgroups: apana.lists.os.linux.netdev User-Agent: tin/1.7.4-20040225 ("Benbecula") (UNIX) (Linux/2.4.26-1-686-smp (i686)) Message-Id: Date: Sun, 05 Sep 2004 05:39:19 +1000 X-archive-position: 8403 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev Andi Kleen wrote: > >> > I added support for trylocking instead of spinning like sch_generic >> > does - for that the driver has to return -1, then the packet is requeued. >> > The check for a local device deadlock is lost for this case, >> > but that doesn't seem to be a big loss (I've never seen this printk >> > ever get triggered) >> >> It is triggerable if you misconfigure your system. > > Really? The only reason I can see for it is a buggy driver. Is this the dead loop message? If so it can happen with tunnels. -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt From han@mijncomputer.nl Sat Sep 4 13:21:20 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 13:21:26 -0700 (PDT) Received: from boetes.org (cc15467-a.groni1.gr.home.nl [217.120.147.78]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i84KLH2b023278 for ; Sat, 4 Sep 2004 13:21:18 -0700 Received: (qmail 1941 invoked by uid 1000); 4 Sep 2004 20:21:29 -0000 Date: Sat, 4 Sep 2004 22:21:07 +0200 From: Han Boetes To: Francois Romieu Cc: netdev@oss.sgi.com Subject: Re: [Fwd: rtl8169 driver from realtek] Message-ID: <20040904202129.GJ2387@boetes.org> References: <4139ED5B.2030002@pobox.com> <20040904182404.GB16875@electric-eye.fr.zoreil.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040904182404.GB16875@electric-eye.fr.zoreil.com> User-Agent: Mutt/1.5.6i X-archive-position: 8404 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: han@mijncomputer.nl Precedence: bulk X-list: netdev Francois Romieu wrote: > Hello M. Boetes, Bonjour :) > Jeff was kind enough to forward your message to me. Very kind indeed. > Can you provide: > - the kernel/compiler version (vendor/hand built/modular kernel); One thing: this is with the driver from realtek. After this run I'll send you another reply with the normal kernel driver. So you are about to get a very similar mail from me. Linux marsupilami 2.6.9-rc1 #3 Thu Sep 2 21:39:26 CEST 2004 i686 unknown unknown GNU/Linux, a hand build static kernel, only one module ( nvidia driver ) Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs Configured with: ../gcc-3.3.3/configure --prefix=/usr --enable-languages=c,c++,objc --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-shared --disable-nls Thread model: posix gcc version 3.3.3 (CRUX) > - the complete dmesg after boot once the r8169 is ifconfig'ed up Linux version 2.6.9-rc1 (han@bereboot) (gcc version 3.3.3 (CRUX)) #3 Thu Sep 2 21:39:26 CEST 2004 BIOS-provided physical RAM map: BIOS-e820: 0000000000000000 - 000000000009fc00 (usable) BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved) BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved) BIOS-e820: 0000000000100000 - 000000002fff0000 (usable) BIOS-e820: 000000002fff0000 - 000000002fff8000 (ACPI data) BIOS-e820: 000000002fff8000 - 0000000030000000 (ACPI NVS) BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved) BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved) BIOS-e820: 00000000fff80000 - 0000000100000000 (reserved) 767MB LOWMEM available. On node 0 totalpages: 196592 DMA zone: 4096 pages, LIFO batch:1 Normal zone: 192496 pages, LIFO batch:16 HighMem zone: 0 pages, LIFO batch:1 DMI 2.3 present. Built 1 zonelists Kernel command line: BOOT_IMAGE=269rc1 ro root=305 acpi=off hdc=ide-cd hdd=ide-cd ide_setup: hdc=ide-cd ide_setup: hdd=ide-cd Initializing CPU#0 PID hash table entries: 4096 (order 12: 32768 bytes) Detected 1467.420 MHz processor. Using tsc for high-res timesource Console: colour dummy device 80x25 Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) Memory: 774920k/786368k available (2321k kernel code, 10696k reserved, 710k data, 396k init, 0k highmem) Checking if this processor honours the WP bit even in supervisor mode... Ok. Calibrating delay loop... 2891.77 BogoMIPS Mount-cache hash table entries: 512 (order: 0, 4096 bytes) CPU: After generic identify, caps: 0383fbff c1c3fbff 00000000 00000000 CPU: After vendor identify, caps: 0383fbff c1c3fbff 00000000 00000000 CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line) CPU: L2 Cache: 256K (64 bytes/line) CPU: After all inits, caps: 0383fbff c1c3fbff 00000000 00000020 Intel machine check architecture supported. Intel machine check reporting enabled on CPU#0. CPU: AMD Athlon(tm) XP 1700+ stepping 02 Enabling fast FPU save and restore... done. Enabling unmasked SIMD FPU exception support... done. Checking 'hlt' instruction... OK. ACPI: IRQ9 SCI: Edge set to Level Trigger. NET: Registered protocol family 16 PCI: PCI BIOS revision 2.10 entry at 0xfdaf1, last bus=1 PCI: Using configuration type 1 mtrr: v2.0 (20020519) ACPI: Subsystem revision 20040715 ACPI: Interpreter disabled. usbcore: registered new driver usbfs usbcore: registered new driver hub PCI: Probing PCI hardware PCI: Probing PCI hardware (bus 00) PCI: Using IRQ router default [1106/3147] at 0000:00:11.0 PCI: IRQ 0 for device 0000:00:11.1 doesn't match PIRQ mask - try pci=usepirqmask PCI: Hardcoded IRQ 14 for device 0000:00:11.1 get_random_bytes called before random driver initialization vesafb: framebuffer at 0xd0000000, mapped to 0xf0807000, size 3072k vesafb: mode is 1024x768x16, linelength=2048, pages=1 vesafb: protected mode interface info at c000:e4d0 vesafb: scrolling: redraw vesafb: Truecolor: size=0:5:6:5, shift=0:11:5:0 fb0: VESA VGA frame buffer device Machine check exception polling timer started. apm: BIOS version 1.2 Flags 0x03 (Driver version 1.16ac) apm: driver version: No APM present Console: switching to colour frame buffer device 128x48 Real Time Clock Driver v1.12 Linux agpgart interface v0.100 (c) Dave Jones agpgart: Detected VIA KT266/KY266x/KT333 chipset agpgart: Maximum main memory to use for agp memory: 690M agpgart: AGP aperture is 128M @ 0xe0000000 Serial: 8250/16550 driver $Revision: 1.90 $ 8 ports, IRQ sharing disabled RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: loaded (max 8 devices) 8139too Fast Ethernet driver 0.9.27 eth0: RealTek RTL8139 at 0xf0b88f00, 00:e0:4c:67:52:80, IRQ 10 eth0: Identified 8139 chip type 'RTL-8139B' Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky eth1: Identified chip type is 'RTL8169s/8110s'. eth1: RTL8169s/8110s Gigabit Ethernet driver 2.2 at 0xe400, 00:08:a1:3c:34:7a, IRQ 12 eth1: Auto-negotiation Enabled. eth1: 1000Mbps Full-duplex operation. Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx VP_IDE: IDE controller at PCI slot 0000:00:11.1 PCI: Hardcoded IRQ 14 for device 0000:00:11.1 VP_IDE: chipset revision 6 VP_IDE: not 100% native mode: will probe irqs later VP_IDE: VIA vt8233a (rev 00) IDE UDMA133 controller on pci0000:00:11.1 ide0: BM-DMA at 0xfc00-0xfc07, BIOS settings: hda:DMA, hdb:DMA ide1: BM-DMA at 0xfc08-0xfc0f, BIOS settings: hdc:DMA, hdd:pio hda: ST340823A, ATA DISK drive hdb: BDV 108A DVDROM, ATAPI CD/DVD-ROM drive Using anticipatory io scheduler ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 hdc: LITE-ON LTR-40125S, ATAPI CD/DVD-ROM drive ide1 at 0x170-0x177,0x376 on irq 15 hda: max request size: 128KiB hda: 78165360 sectors (40020 MB) w/512KiB Cache, CHS=65535/16/63, UDMA(100) hda: cache flushes supported hda: hda1 hda2 < hda5 hda6 hda7 hda8 hda9 hda10 > hdb: ATAPI DVD-ROM drive, 512kB Cache, UDMA(33) Uniform CD-ROM driver Revision: 3.20 hdc: ATAPI 48X CD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33) ide-floppy driver 0.99.newide USB Universal Host Controller Interface driver v2.2 uhci_hcd 0000:00:11.2: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller uhci_hcd 0000:00:11.2: irq 5, io base 0000d800 uhci_hcd 0000:00:11.2: new USB bus registered, assigned bus number 1 hub 1-0:1.0: USB hub found hub 1-0:1.0: 2 ports detected uhci_hcd 0000:00:11.3: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (#2) uhci_hcd 0000:00:11.3: irq 5, io base 0000dc00 uhci_hcd 0000:00:11.3: new USB bus registered, assigned bus number 2 hub 2-0:1.0: USB hub found hub 2-0:1.0: 2 ports detected usbcore: registered new driver usbhid drivers/usb/input/hid-core.c: v2.0:USB HID core driver mice: PS/2 mouse device common for all mice serio: i8042 AUX port at 0x60,0x64 irq 12 serio: i8042 KBD port at 0x60,0x64 irq 1 input: AT Translated Set 2 keyboard on isa0060/serio0 Advanced Linux Sound Architecture Driver Version 1.0.4 (Mon May 17 14:31:44 2004 UTC). AC'97 0 analog subsections not ready ALSA device list: #0: Sound Blaster Live! (rev.7) at 0xe000, irq 10 NET: Registered protocol family 2 IP: routing cache hash table of 8192 buckets, 64Kbytes TCP: Hash tables configured (established 262144 bind 65536) NET: Registered protocol family 1 NET: Registered protocol family 17 usb 1-1: new low speed USB device using address 2 UDF-fs: No VRS found HID Mouse 0xc024 forced to 2 ms polling VFS: Mounted root (jfs filesystem) readonly. Freeing unused kernel memory: 396k freed input: USB HID v1.10 Mouse [B16_b_02 USB-PS/2 Optical Mouse] on usb-0000:00:11.2-1 Adding 257000k swap on /dev/hda6. Priority:-1 extents:1 > - the content of the /proc/interrupts file once the r8169 is ifconfig'ed up CPU0 0: 365527 XT-PIC timer 1: 1830 XT-PIC i8042 2: 0 XT-PIC cascade 5: 2310 XT-PIC uhci_hcd, uhci_hcd 8: 1 XT-PIC rtc 10: 0 XT-PIC EMU10K1 12: 2819 XT-PIC eth1 14: 3207 XT-PIC ide0 15: 20 XT-PIC ide1 NMI: 0 ERR: 0 > - a short description of the "does not work" I'm terribly sorry I didn't provide it. This is the description of what goes wrong with the realtek-driver: One single transfer goes ok as far as I can tell. But once I start doing multiple things, all over nfs, like listening to an mp3 and sending over files the connection gets the hickups. > - the brand of the 8169 cards (if any) This is a real GIGABIT ETHERNET CARD from 19 Euro at my favourite provider. :-) > If you have some version of the Realtek's driver prior to the 2.2 version > which are not available on their site any more, I'll welcome these. No I don't have any other drivers from them. > > Please let me know which driver you think is the best. > > None :o) > -> in tree driver does not work for you > -> From a quick look, Realtek's driver does not include a single barrier > instruction and the failure paths in rtl8169_open() are broken. I would > not be surprized that some fixes are missing which are available in the > kernel tree. No NAPI nor ethtool. Jumbo frames support and other > goodies are there though. Okay, I'll have to isolate the differences. > If you can stay with us until an in kernel, modified, r8169 driver works > with your setup, it should be possible to get the best of both worlds. Ok, now lets try the normal kernel driver with a clear head. # Han -- (I hate large) \||/ A man is already halfway in love with any (sigs) Oo. | @___oo woman who listens to him. -- Brendan Francis /\ /\ / (__,,,,| ) /^\) ^\/ _) ) /^\/ _) ) _ / / _) /\ )/\/ || | )_) < > |(,,) )__) || / \)___)\ | \____( )___) )___ \______(_______;;; __;;; From uucp@ganesha.gnumonks.org Sat Sep 4 13:38:12 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 13:38:18 -0700 (PDT) Received: from ganesha.gnumonks.org (Debian-exim@ganesha.gnumonks.org [213.95.27.120]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84KcB77023776 for ; Sat, 4 Sep 2004 13:38:12 -0700 Received: from uucp by ganesha.gnumonks.org with local-bsmtp (Exim 4.30) id 1C3hIL-0001yt-6q for netdev@oss.sgi.com; Sat, 04 Sep 2004 22:37:57 +0200 Received: from laforge by obroa-skai.gnumonks.org with local (Exim 3.36 #1) id 1C3gmk-0004cM-00; Sat, 04 Sep 2004 22:05:18 +0200 Date: Sat, 4 Sep 2004 22:05:18 +0200 From: Harald Welte To: "David S. Miller" Cc: Harald Welte , netfilter-devel@lists.netfilter.org, netdev@oss.sgi.com Subject: Re: [PATCH 2.6] 2/2: Fix NAT helper locking Message-ID: <20040904200518.GC11414@obroa-skai.de.gnumonks.org> Mail-Followup-To: Harald Welte , "David S. Miller" , netfilter-devel@lists.netfilter.org, netdev@oss.sgi.com References: <20040903070234.GQ26263@sunbeam.de.gnumonks.org> <20040903002453.77beee16.davem@davemloft.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="adJ1OR3c6QgCpb/j" Content-Disposition: inline In-Reply-To: <20040903002453.77beee16.davem@davemloft.net> X-Operating-System: Linux obroa-skai.de.gnumonks.org 2.6.8-rc2-nfp0722-tcpwin X-Date: Today is Pungenday, the 23rd day of Chaos in the YOLD 3070 User-Agent: Mutt/1.5.6+20040722i X-archive-position: 8405 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: laforge@netfilter.org Precedence: bulk X-list: netdev --adJ1OR3c6QgCpb/j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 03, 2004 at 12:24:53AM -0700, David S. Miller wrote: =20 > Ummm... wow what ancient tree did you patch against > Harald? The tree you patched against didn't even have the > skb_header_pointer() changes in it, that's caveman > era :-) That's what caused the rejects. I tried to apply the patch against 2.6.9-rc1 before sending it to you. It had offsets, but applied cleanly > Thanks. --=20 - Harald Welte http://www.netfilter.org/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie --adJ1OR3c6QgCpb/j Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBOh/+XaXGVTD0i/8RAgXLAJ4tcjBuw7+0CoQGe1FK9Dc1/2LB+ACbBtxK 8sWfs0Pl9hdUDYNq+oDE+KA= =k3Xl -----END PGP SIGNATURE----- --adJ1OR3c6QgCpb/j-- From han@mijncomputer.nl Sat Sep 4 14:18:52 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 14:18:57 -0700 (PDT) Received: from boetes.org (cc15467-a.groni1.gr.home.nl [217.120.147.78]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i84LIoPT024864 for ; Sat, 4 Sep 2004 14:18:51 -0700 Received: (qmail 21712 invoked by uid 1000); 4 Sep 2004 21:19:02 -0000 Date: Sat, 4 Sep 2004 23:18:40 +0159 From: Han Boetes To: Francois Romieu Cc: netdev@oss.sgi.com Subject: Re: [Fwd: rtl8169 driver from realtek] Message-ID: <20040904211902.GK2387@boetes.org> References: <4139ED5B.2030002@pobox.com> <20040904182404.GB16875@electric-eye.fr.zoreil.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040904182404.GB16875@electric-eye.fr.zoreil.com> User-Agent: Mutt/1.5.6i X-archive-position: 8406 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: han@mijncomputer.nl Precedence: bulk X-list: netdev Here we go again. This is with the normal kernel-driver. It works fine. Obviously I did something else wrong and drew the wrong conclusion. Excuse me for that. Heavy stress-tests work fine with this driver! Francois Romieu wrote: > - the complete dmesg after boot once the r8169 is ifconfig'ed up Linux version 2.6.9-rc1 (han@marsupilami) (gcc version 3.3.3 (CRUX)) #1 Sat Sep 4 22:43:12 CEST 2004 BIOS-provided physical RAM map: BIOS-e820: 0000000000000000 - 000000000009fc00 (usable) BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved) BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved) BIOS-e820: 0000000000100000 - 000000002fff0000 (usable) BIOS-e820: 000000002fff0000 - 000000002fff8000 (ACPI data) BIOS-e820: 000000002fff8000 - 0000000030000000 (ACPI NVS) BIOS-e820: 00000000fec00000 - 00000000fec01000 (reserved) BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved) BIOS-e820: 00000000fff80000 - 0000000100000000 (reserved) 767MB LOWMEM available. On node 0 totalpages: 196592 DMA zone: 4096 pages, LIFO batch:1 Normal zone: 192496 pages, LIFO batch:16 HighMem zone: 0 pages, LIFO batch:1 DMI 2.3 present. Built 1 zonelists Kernel command line: BOOT_IMAGE=269rc1 ro root=305 acpi=off hdc=ide-cd hdd=ide-cd ide_setup: hdc=ide-cd ide_setup: hdd=ide-cd Initializing CPU#0 PID hash table entries: 4096 (order 12: 32768 bytes) Detected 1467.420 MHz processor. Using tsc for high-res timesource Console: colour dummy device 80x25 Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) Memory: 774912k/786368k available (2324k kernel code, 10704k reserved, 714k data, 396k init, 0k highmem) Checking if this processor honours the WP bit even in supervisor mode... Ok. Calibrating delay loop... 2891.77 BogoMIPS Mount-cache hash table entries: 512 (order: 0, 4096 bytes) CPU: After generic identify, caps: 0383fbff c1c3fbff 00000000 00000000 CPU: After vendor identify, caps: 0383fbff c1c3fbff 00000000 00000000 CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line) CPU: L2 Cache: 256K (64 bytes/line) CPU: After all inits, caps: 0383fbff c1c3fbff 00000000 00000020 Intel machine check architecture supported. Intel machine check reporting enabled on CPU#0. CPU: AMD Athlon(tm) XP 1700+ stepping 02 Enabling fast FPU save and restore... done. Enabling unmasked SIMD FPU exception support... done. Checking 'hlt' instruction... OK. ACPI: IRQ9 SCI: Edge set to Level Trigger. NET: Registered protocol family 16 PCI: PCI BIOS revision 2.10 entry at 0xfdaf1, last bus=1 PCI: Using configuration type 1 mtrr: v2.0 (20020519) ACPI: Subsystem revision 20040715 ACPI: Interpreter disabled. usbcore: registered new driver usbfs usbcore: registered new driver hub PCI: Probing PCI hardware PCI: Probing PCI hardware (bus 00) PCI: Using IRQ router default [1106/3147] at 0000:00:11.0 PCI: IRQ 0 for device 0000:00:11.1 doesn't match PIRQ mask - try pci=usepirqmask PCI: Hardcoded IRQ 14 for device 0000:00:11.1 get_random_bytes called before random driver initialization vesafb: framebuffer at 0xd0000000, mapped to 0xf0807000, size 3072k vesafb: mode is 1024x768x16, linelength=2048, pages=1 vesafb: protected mode interface info at c000:e4d0 vesafb: scrolling: redraw vesafb: Truecolor: size=0:5:6:5, shift=0:11:5:0 fb0: VESA VGA frame buffer device Machine check exception polling timer started. apm: BIOS version 1.2 Flags 0x03 (Driver version 1.16ac) apm: driver version: No APM present Console: switching to colour frame buffer device 128x48 Real Time Clock Driver v1.12 Linux agpgart interface v0.100 (c) Dave Jones agpgart: Detected VIA KT266/KY266x/KT333 chipset agpgart: Maximum main memory to use for agp memory: 690M agpgart: AGP aperture is 128M @ 0xe0000000 Serial: 8250/16550 driver $Revision: 1.90 $ 8 ports, IRQ sharing disabled RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: loaded (max 8 devices) 8139too Fast Ethernet driver 0.9.27 eth0: RealTek RTL8139 at 0xf0b88f00, 00:e0:4c:67:52:80, IRQ 10 eth0: Identified 8139 chip type 'RTL-8139B' Universal TUN/TAP device driver 1.5 (C)1999-2002 Maxim Krasnyansky r8169 Gigabit Ethernet driver 1.2 loaded eth1: Identified chip type is 'RTL8169s/8110s'. eth1: RTL8169 at 0xf0b8ae00, 00:08:a1:3c:34:7a, IRQ 12 Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx VP_IDE: IDE controller at PCI slot 0000:00:11.1 PCI: Hardcoded IRQ 14 for device 0000:00:11.1 VP_IDE: chipset revision 6 VP_IDE: not 100% native mode: will probe irqs later VP_IDE: VIA vt8233a (rev 00) IDE UDMA133 controller on pci0000:00:11.1 ide0: BM-DMA at 0xfc00-0xfc07, BIOS settings: hda:DMA, hdb:DMA ide1: BM-DMA at 0xfc08-0xfc0f, BIOS settings: hdc:DMA, hdd:pio hda: ST340823A, ATA DISK drive hdb: BDV 108A DVDROM, ATAPI CD/DVD-ROM drive Using anticipatory io scheduler ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 hdc: LITE-ON LTR-40125S, ATAPI CD/DVD-ROM drive ide1 at 0x170-0x177,0x376 on irq 15 hda: max request size: 128KiB hda: 78165360 sectors (40020 MB) w/512KiB Cache, CHS=65535/16/63, UDMA(100) hda: cache flushes supported hda: hda1 hda2 < hda5 hda6 hda7 hda8 hda9 hda10 > hdb: ATAPI DVD-ROM drive, 512kB Cache, UDMA(33) Uniform CD-ROM driver Revision: 3.20 hdc: ATAPI 48X CD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33) ide-floppy driver 0.99.newide USB Universal Host Controller Interface driver v2.2 uhci_hcd 0000:00:11.2: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller uhci_hcd 0000:00:11.2: irq 5, io base 0000d800 uhci_hcd 0000:00:11.2: new USB bus registered, assigned bus number 1 hub 1-0:1.0: USB hub found hub 1-0:1.0: 2 ports detected uhci_hcd 0000:00:11.3: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (#2) uhci_hcd 0000:00:11.3: irq 5, io base 0000dc00 uhci_hcd 0000:00:11.3: new USB bus registered, assigned bus number 2 hub 2-0:1.0: USB hub found hub 2-0:1.0: 2 ports detected usbcore: registered new driver usbhid drivers/usb/input/hid-core.c: v2.0:USB HID core driver mice: PS/2 mouse device common for all mice serio: i8042 AUX port at 0x60,0x64 irq 12 serio: i8042 KBD port at 0x60,0x64 irq 1 input: AT Translated Set 2 keyboard on isa0060/serio0 Advanced Linux Sound Architecture Driver Version 1.0.4 (Mon May 17 14:31:44 2004 UTC). ALSA device list: #0: Sound Blaster Live! (rev.7) at 0xe000, irq 10 NET: Registered protocol family 2 IP: routing cache hash table of 8192 buckets, 64Kbytes TCP: Hash tables configured (established 262144 bind 65536) NET: Registered protocol family 1 NET: Registered protocol family 17 usb 1-1: new low speed USB device using address 2 UDF-fs: No VRS found VFS: Mounted root (jfs filesystem) readonly. Freeing unused kernel memory: 396k freed HID Mouse 0xc024 forced to 2 ms polling input: USB HID v1.10 Mouse [B16_b_02 USB-PS/2 Optical Mouse] on usb-0000:00:11.2-1 Adding 257000k swap on /dev/hda6. Priority:-1 extents:1 > - the content of the /proc/interrupts file once the r8169 is ifconfig'ed up CPU0 0: 1012596 XT-PIC timer 1: 2271 XT-PIC i8042 2: 0 XT-PIC cascade 5: 35354 XT-PIC uhci_hcd, uhci_hcd 8: 1 XT-PIC rtc 10: 8922 XT-PIC EMU10K1 11: 68450 XT-PIC nvidia 12: 203034 XT-PIC eth1 14: 7347 XT-PIC ide0 15: 20 XT-PIC ide1 NMI: 0 ERR: 0 > If you can stay with us until an in kernel, modified, r8169 driver > works with your setup, it should be possible to get the best of both > worlds. Please let me know if you want to test new patches based on stuff you found in the realtek driver. # Han -- A random bookmark: http://crypto.yashy.com/nmap.php From romieu@fr.zoreil.com Sat Sep 4 14:46:34 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 14:46:39 -0700 (PDT) Received: from fr.zoreil.com (electric-eye.fr.zoreil.com [213.41.134.224]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84LkWso025634 for ; Sat, 4 Sep 2004 14:46:33 -0700 Received: from electric-eye.fr.zoreil.com (localhost.localdomain [127.0.0.1]) by fr.zoreil.com (8.12.10/8.12.1) with ESMTP id i84LiLvr019952; Sat, 4 Sep 2004 23:44:21 +0200 Received: (from romieu@localhost) by electric-eye.fr.zoreil.com (8.12.10/8.12.10/Submit) id i84LiLBQ019951; Sat, 4 Sep 2004 23:44:21 +0200 Date: Sat, 4 Sep 2004 23:44:21 +0200 From: Francois Romieu To: Han Boetes Cc: netdev@oss.sgi.com Subject: Re: [Fwd: rtl8169 driver from realtek] Message-ID: <20040904214243.GA19728@electric-eye.fr.zoreil.com> References: <4139ED5B.2030002@pobox.com> <20040904182404.GB16875@electric-eye.fr.zoreil.com> <20040904211902.GK2387@boetes.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040904211902.GK2387@boetes.org> User-Agent: Mutt/1.4.1i X-Organisation: Land of Sunshine Inc. X-archive-position: 8407 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: romieu@fr.zoreil.com Precedence: bulk X-list: netdev Han Boetes : > > Here we go again. This is with the normal kernel-driver. It works > fine. Obviously I did something else wrong and drew the wrong > conclusion. Excuse me for that. Success reports are welcome too :o) -- Ueimor From alex@towebs.com Sat Sep 4 15:34:10 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 15:34:17 -0700 (PDT) Received: from gate-one.toservers.com (customer.iplannetworks.net [200.69.210.29] (may be forged)) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i84MY9wS026615; Sat, 4 Sep 2004 15:34:10 -0700 Received: from 127.0.0.1 (localhost [127.0.0.1]) by dummy.domain.name (Postfix) with SMTP id 0F1695F9EB; Sat, 4 Sep 2004 22:32:13 +0000 (UTC) Received: from [10.10.1.38] (alexis [10.10.1.38]) by gate-one.toservers.com (Postfix) with ESMTP id 804305F9C7; Sat, 4 Sep 2004 22:32:12 +0000 (UTC) Message-ID: <413A1566.6050807@towebs.com> Date: Sat, 04 Sep 2004 19:20:06 +0000 From: Alex User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040819 X-Accept-Language: en-us, en MIME-Version: 1.0 To: netdev@oss.sgi.com, majordomo@oss.sgi.com Subject: Host AP driver for Intersil Prism2/2.5/3 X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8408 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: alex@towebs.com Precedence: bulk X-list: netdev This driver is not build-in in linux kernel. http://www.inlab.csp.it/tools/wireless/hostqs/ From listmoved@calle.in-berlin.de Sat Sep 4 19:15:47 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 19:15:52 -0700 (PDT) Received: from gnu.in-berlin.de (gnu.in-berlin.de [192.109.42.4]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i852FjMV001172 for ; Sat, 4 Sep 2004 19:15:46 -0700 X-Envelope-From: listmoved@calle.in-berlin.de X-Envelope-To: Received: from calle.in-berlin.de (calle.in-berlin.de [217.197.81.210]) by gnu.in-berlin.de (8.12.11/8.12.11/Debian-4) with ESMTP id i852FZlx011951 for ; Sun, 5 Sep 2004 04:15:35 +0200 Received: by calle.in-berlin.de (Smail3.2.0.115) id ; Sun, 5 Sep 2004 04:15:35 +0200 (CEST) Message-Id: Date: Sun, 5 Sep 2004 04:15:35 +0200 (CEST) To: netdev@oss.sgi.com From: calle@calle.in-berlin.de Subject: Re: Server Error (majordomo@calle.in-berlin.de) Precedence: bulk X-Scanned-By: MIMEDefang 2.43 X-archive-position: 8409 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: calle@calle.in-berlin.de Precedence: bulk X-list: netdev Hallo. Die Mailingliste linux-avmb1@calle.in-berlin.de ist umgezogen, da sie durch Spams verseucht wurde. Siehe https://mlists.in-berlin.de/mailman/listinfo/linux-avmb1 The mailing list linux-avmb1@calle.in-berlin.de was been moved, we got too many spams. Visit https://mlists.in-berlin.de/mailman/listinfo/linux-avmb1 calle From mcgrof@studorgs.rutgers.edu Sat Sep 4 23:46:07 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 23:46:12 -0700 (PDT) Received: from ruslug.rutgers.edu (studorgs.rutgers.edu [128.6.24.131]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i856k7J6008868 for ; Sat, 4 Sep 2004 23:46:07 -0700 Received: by ruslug.rutgers.edu (Postfix, from userid 503) id 505F6F99C1; Sun, 5 Sep 2004 02:45:58 -0400 (EDT) Date: Sun, 5 Sep 2004 02:45:58 -0400 To: Jeff Garzik Cc: prism54-devel@prism54.org, Netdev Subject: [PATCH 0/4] prism54: remove some module_params, WE17 and initial WPA work Message-ID: <20040905064558.GT31207@ruslug.rutgers.edu> Mail-Followup-To: Jeff Garzik , prism54-devel@prism54.org, Netdev Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ctP54qlpMx3WjD+/" Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Operating-System: 2.4.18-1-686 Organization: Rutgers University Student Linux Users Group From: mcgrof@studorgs.rutgers.edu (Luis R. Rodriguez) X-archive-position: 8410 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: mcgrof@studorgs.rutgers.edu Precedence: bulk X-list: netdev --ctP54qlpMx3WjD+/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [ Note: I'm resending these as Jeff's HD died ] Jeff, = =20 = =20 The following patches go ontop of Margit's recent patches which have not = =20 yet been integrated by you. These patches add remove some unncessary = =20 module_params, adds WE17 support and adds our initial WPA work -- = =20 striving to get prism54 wpa_supplicant to work with prism54. = =20 = =20 Please note that these patches are for *both* 2.6 and 2.4. = =20 = =20 Thanks, = =20 = =20 Luis=20 --=20 GnuPG Key fingerprint =3D 113F B290 C6D2 0251 4D84 A34A 6ADD 4937 E20A 525E --ctP54qlpMx3WjD+/ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBOrYmat1JN+IKUl4RAprmAKCoB+ioyNxT3fGzKg+e5EWPCorzKwCeJC9C DHiJKtT7d+2+wU7JFuR9Jok= =yZXR -----END PGP SIGNATURE----- --ctP54qlpMx3WjD+/-- From mcgrof@studorgs.rutgers.edu Sat Sep 4 23:49:43 2004 Received: with ECARTIS (v1.0.0; list netdev); Sat, 04 Sep 2004 23:49:48 -0700 (PDT) Received: from ruslug.rutgers.edu (studorgs.rutgers.edu [128.6.24.131]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i856nhms009204 for ; Sat, 4 Sep 2004 23:49:43 -0700 Received: by ruslug.rutgers.edu (Postfix, from userid 503) id 73114F99C1; Sun, 5 Sep 2004 02:49:34 -0400 (EDT) Date: Sun, 5 Sep 2004 02:49:34 -0400 To: Jeff Garzik , prism54-devel@prism54.org, Netdev Subject: Re: [PATCH 0/4] prism54: remove some module_params, WE17 and initial WPA work Message-ID: <20040905064934.GV31207@ruslug.rutgers.edu> Mail-Followup-To: Jeff Garzik , prism54-devel@prism54.org, Netdev References: <20040905064558.GT31207@ruslug.rutgers.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040905064558.GT31207@ruslug.rutgers.edu> User-Agent: Mutt/1.3.28i X-Operating-System: 2.4.18-1-686 Organization: Rutgers University Student Linux Users Group From: mcgrof@studorgs.rutgers.edu (Luis R. Rodriguez) X-archive-position: 8411 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: mcgrof@studorgs.rutgers.edu Precedence: bulk X-list: netdev nevermind, I'm going to coordinate with Margit so we send her and my patches together to make life easier for you. Luis On Sun, Sep 05, 2004 at 02:45:58AM -0400, Luis R. Rodriguez wrote: > > [ Note: I'm resending these as Jeff's HD died ] > > Jeff, > > The following patches go ontop of Margit's recent patches which have not > yet been integrated by you. These patches add remove some unncessary > module_params, adds WE17 support and adds our initial WPA work -- > striving to get prism54 wpa_supplicant to work with prism54. > > Please note that these patches are for *both* 2.6 and 2.4. > > Thanks, > > Luis > > -- > GnuPG Key fingerprint = 113F B290 C6D2 0251 4D84 A34A 6ADD 4937 E20A 525E -- GnuPG Key fingerprint = 113F B290 C6D2 0251 4D84 A34A 6ADD 4937 E20A 525E From margitsw@t-online.de Sun Sep 5 02:28:04 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 02:28:11 -0700 (PDT) Received: from mailout08.sul.t-online.com (mailout08.sul.t-online.com [194.25.134.20]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i859S24b015399 for ; Sun, 5 Sep 2004 02:28:03 -0700 Received: from fwd05.aul.t-online.de by mailout08.sul.t-online.com with smtp id 1C3tJ4-0004LB-02; Sun, 05 Sep 2004 11:27:30 +0200 Received: from roglap.local (ZwnRR8Z68eRo4AfVV-pfOw7R64FAxblgxc62jXHZyNUEFIjgZRTbZS@[217.224.19.205]) by fwd05.sul.t-online.com with esmtp id 1C3tIw-0qpJXE0; Sun, 5 Sep 2004 11:27:22 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH Linux-2.4.28-pre2] prism54 Update to 2.6 status Date: Sun, 5 Sep 2004 11:15:49 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org, marcelo.tosatti@cyclades.com MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_FltOBefVy+CGV5h" Message-Id: <200409051115.50083.margitsw@t-online.de> X-ID: ZwnRR8Z68eRo4AfVV-pfOw7R64FAxblgxc62jXHZyNUEFIjgZRTbZS X-TOI-MSGID: e065345e-8edf-45e4-9b72-74b221704805 X-archive-position: 8412 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev --Boundary-00=_FltOBefVy+CGV5h Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 2004-09-05 Margit Schubert-While * This rollup patch brings 2.4 into line with current * 2.6 status. * The code base is then IDENTICAL for both 2.4 and 2.6 with * the exception of an extra compatibility header for 2.4. * There is no point in doing a split out for this patch * as all changes have already been individually posted * against 2.6 and passed through Jeff. * As of now, we can post one patch for both kernels. * I have included Marcelo in the CC so that he is informed. * Jeff, after this patch, the upcoming resend of patches * apply equally to 2.4 and 2.6 unless explicitly stated. Margit --Boundary-00=_FltOBefVy+CGV5h Content-Type: text/x-diff; charset="us-ascii"; name="01_rollup.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="01_rollup.patch" diff -Naur linux-2.4.28-pre2/drivers/net/wireless/prism54/isl_38xx.c linux-2.4.28-pre2msw/drivers/net/wireless/prism54/isl_38xx.c --- linux-2.4.28-pre2/drivers/net/wireless/prism54/isl_38xx.c 2004-09-05 10:08:56.000000000 +0200 +++ linux-2.4.28-pre2msw/drivers/net/wireless/prism54/isl_38xx.c 2004-09-05 10:36:25.000000000 +0200 @@ -18,8 +18,6 @@ * */ -#define __KERNEL_SYSCALLS__ - #include #include #include diff -Naur linux-2.4.28-pre2/drivers/net/wireless/prism54/isl_ioctl.c linux-2.4.28-pre2msw/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.4.28-pre2/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:08:56.000000000 +0200 +++ linux-2.4.28-pre2msw/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:36:25.000000000 +0200 @@ -436,7 +436,7 @@ { struct iw_range *range = (struct iw_range *) extra; islpci_private *priv = netdev_priv(ndev); - char *data; + u8 *data; int i, m, rvalue; struct obj_frequencies *freq; union oid_res_t r; @@ -513,8 +513,7 @@ i = 0; while ((i < IW_MAX_BITRATES) && (*data != 0)) { /* the result must be in bps. The card gives us 500Kbps */ - range->bitrate[i] = (__s32) (*data >> 1); - range->bitrate[i] *= 1000000; + range->bitrate[i] = *data * 500000; i++; data++; } @@ -820,9 +819,11 @@ return mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile); } - if ((ret = - mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r))) + ret = mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r); + if (ret) { + kfree(r.ptr); return ret; + } rate = (u32) (vwrq->value / 500000); data = r.ptr; @@ -840,6 +841,7 @@ } if (!data[i]) { + kfree(r.ptr); return -EINVAL; } @@ -888,8 +890,11 @@ vwrq->value = r.u * 500000; /* request the device for the enabled rates */ - if ((rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r))) + rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r); + if (rvalue) { + kfree(r.ptr); return rvalue; + } data = r.ptr; vwrq->fixed = (data[0] != 0) && (data[1] == 0); kfree(r.ptr); @@ -1942,7 +1947,7 @@ { islpci_private *priv = netdev_priv(ndev); struct islpci_mgmtframe *response = NULL; - int ret = -EIO, response_op = PIMFOR_OP_ERROR; + int ret = -EIO; printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid); data->length = 0; @@ -1952,9 +1957,7 @@ islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET, priv->priv_oid, extra, 256, &response); - response_op = response->header->operation; printk("%s: ret: %i\n", ndev->name, ret); - printk("%s: response_op: %i\n", ndev->name, response_op); if (ret || !response || response->header->operation == PIMFOR_OP_ERROR) { if (response) { @@ -1991,16 +1994,20 @@ priv->priv_oid, extra, data->length, &response); printk("%s: ret: %i\n", ndev->name, ret); + if (ret || !response + || response->header->operation == PIMFOR_OP_ERROR) { + if (response) { + islpci_mgt_release(response); + } + printk("%s: EIO\n", ndev->name); + ret = -EIO; + } if (!ret) { response_op = response->header->operation; printk("%s: response_op: %i\n", ndev->name, response_op); islpci_mgt_release(response); } - if (ret || response_op == PIMFOR_OP_ERROR) { - printk("%s: EIO\n", ndev->name); - ret = -EIO; - } } return (ret ? ret : -EINPROGRESS); diff -Naur linux-2.4.28-pre2/drivers/net/wireless/prism54/islpci_dev.c linux-2.4.28-pre2msw/drivers/net/wireless/prism54/islpci_dev.c --- linux-2.4.28-pre2/drivers/net/wireless/prism54/islpci_dev.c 2004-09-05 10:08:56.000000000 +0200 +++ linux-2.4.28-pre2msw/drivers/net/wireless/prism54/islpci_dev.c 2004-09-05 10:36:25.000000000 +0200 @@ -39,6 +39,7 @@ #include "oid_mgt.h" #define ISL3877_IMAGE_FILE "isl3877" +#define ISL3886_IMAGE_FILE "isl3886" #define ISL3890_IMAGE_FILE "isl3890" static int prism54_bring_down(islpci_private *); @@ -82,7 +83,7 @@ mdelay(50); { - const struct firmware *fw_entry = 0; + const struct firmware *fw_entry = NULL; long fw_len; const u32 *fw_ptr; @@ -185,6 +186,9 @@ void *device = priv->device_base; int powerstate = ISL38XX_PSM_POWERSAVE_STATE; + /* lock the interrupt handler */ + spin_lock(&priv->slock); + /* received an interrupt request on a shared IRQ line * first check whether the device is in sleep mode */ reg = readl(device + ISL38XX_CTRL_STAT_REG); @@ -194,14 +198,10 @@ #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "Assuming someone else called the IRQ\n"); #endif + spin_unlock(&priv->slock); return IRQ_NONE; } - if (islpci_get_state(priv) != PRV_STATE_SLEEP) - powerstate = ISL38XX_PSM_ACTIVE_STATE; - - /* lock the interrupt handler */ - spin_lock(&priv->slock); /* check whether there is any source of interrupt on the device */ reg = readl(device + ISL38XX_INT_IDENT_REG); @@ -212,6 +212,9 @@ reg &= ISL38XX_INT_SOURCES; if (reg != 0) { + if (islpci_get_state(priv) != PRV_STATE_SLEEP) + powerstate = ISL38XX_PSM_ACTIVE_STATE; + /* reset the request bits in the Identification register */ isl38xx_w32_flush(device, reg, ISL38XX_INT_ACK_REG); @@ -339,6 +342,12 @@ isl38xx_handle_wakeup(priv->control_block, &powerstate, priv->device_base); } + } else { +#if VERBOSE > SHOW_ERROR_MESSAGES + DEBUG(SHOW_TRACING, "Assuming someone else called the IRQ\n"); +#endif + spin_unlock(&priv->slock); + return IRQ_NONE; } /* sleep -> ready */ @@ -716,7 +725,7 @@ if (priv->device_base) iounmap(priv->device_base); - priv->device_base = 0; + priv->device_base = NULL; /* free consistent DMA area... */ if (priv->driver_mem_address) @@ -725,10 +734,10 @@ priv->device_host_address); /* clear some dangling pointers */ - priv->driver_mem_address = 0; + priv->driver_mem_address = NULL; priv->device_host_address = 0; priv->device_psm_buffer = 0; - priv->control_block = 0; + priv->control_block = NULL; /* clean up mgmt rx buffers */ for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) { @@ -754,7 +763,7 @@ if (priv->data_low_rx[counter]) dev_kfree_skb(priv->data_low_rx[counter]); - priv->data_low_rx[counter] = 0; + priv->data_low_rx[counter] = NULL; } /* Free the acces control list and the WPA list */ @@ -856,14 +865,14 @@ /* select the firmware file depending on the device id */ switch (pdev->device) { - case PCIDEVICE_ISL3890: - case PCIDEVICE_3COM6001: - strcpy(priv->firmware, ISL3890_IMAGE_FILE); - break; - case PCIDEVICE_ISL3877: + case 0x3877: strcpy(priv->firmware, ISL3877_IMAGE_FILE); break; + case 0x3886: + strcpy(priv->firmware, ISL3886_IMAGE_FILE); + break; + default: strcpy(priv->firmware, ISL3890_IMAGE_FILE); break; @@ -880,9 +889,9 @@ do_islpci_free_memory: islpci_free_memory(priv); do_free_netdev: - pci_set_drvdata(pdev, 0); + pci_set_drvdata(pdev, NULL); free_netdev(ndev); - priv = 0; + priv = NULL; return NULL; } diff -Naur linux-2.4.28-pre2/drivers/net/wireless/prism54/islpci_hotplug.c linux-2.4.28-pre2msw/drivers/net/wireless/prism54/islpci_hotplug.c --- linux-2.4.28-pre2/drivers/net/wireless/prism54/islpci_hotplug.c 2004-09-05 10:08:56.000000000 +0200 +++ linux-2.4.28-pre2msw/drivers/net/wireless/prism54/islpci_hotplug.c 2004-09-05 10:36:25.000000000 +0200 @@ -44,102 +44,30 @@ * If you have an update for this please contact prism54-devel@prism54.org * The latest list can be found at http://prism54.org/supported_cards.php */ static const struct pci_device_id prism54_id_tbl[] = { - /* 3COM 3CRWE154G72 Wireless LAN adapter */ - { - PCIVENDOR_3COM, PCIDEVICE_3COM6001, - PCIVENDOR_3COM, PCIDEVICE_3COM6001, - 0, 0, 0 - }, - - /* D-Link Air Plus Xtreme G A1 - DWL-g650 A1 */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_DLINK, 0x3202UL, - 0, 0, 0 - }, - - /* I-O Data WN-G54/CB - WN-G54/CB */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_IODATA, 0xd019UL, - 0, 0, 0 - }, - - /* Netgear WG511 */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_NETGEAR, 0x4800UL, - 0, 0, 0 - }, - - /* Tekram Technology clones, Allnet, Netcomm, Zyxel */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_TTL, 0x1605UL, - 0, 0, 0 - }, - - /* SMC2802W */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_SMC, 0x2802UL, - 0, 0, 0 - }, - - /* SMC2835W */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_SMC, 0x2835UL, - 0, 0, 0 - }, - - /* Corega CG-WLCB54GT */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_ATI, 0xc104UL, - 0, 0, 0 - }, - - /* I4 Z-Com XG-600 */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_I4, 0x0014UL, - 0, 0, 0 - }, - - /* I4 Z-Com XG-900 and clones Macer, Ovislink, Planex, Peabird, */ - /* Sitecom, Xterasys */ - { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_I4, 0x0020UL, - 0, 0, 0 - }, - - /* SMC 2802W V2 */ + /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_ACCTON, 0xee03UL, + 0x1260, 0x3890, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - /* SMC 2835W V2 */ + /* 3COM 3CRWE154G72 Wireless LAN adapter */ { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_SMC, 0xa835UL, + 0x10b7, 0x6001, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Intersil PRISM Indigo Wireless LAN adapter */ { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3877, + 0x1260, 0x3877, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ - /* Default */ + /* Intersil PRISM Javelin/Xbow Wireless LAN adapter */ { - PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, + 0x1260, 0x3886, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, @@ -166,85 +94,6 @@ /* .enable_wake ; we don't support this yet */ }; -static void -prism54_get_card_model(struct net_device *ndev) -{ - islpci_private *priv; - char *modelp; - int notwork = 0; - - priv = netdev_priv(ndev); - switch (priv->pdev->subsystem_device) { - case PCIDEVICE_ISL3877: - modelp = "PRISM Indigo"; - break; - case PCIDEVICE_ISL3886: - modelp = "PRISM Javelin / Xbow"; - break; - case PCIDEVICE_3COM6001: - modelp = "3COM 3CRWE154G72"; - break; - case 0x3202UL: - modelp = "D-Link DWL-g650 A1"; - break; - case 0xd019UL: - modelp = "WN-G54/CB"; - break; - case 0x4800UL: - modelp = "Netgear WG511"; - break; - case 0x2802UL: - modelp = "SMC2802W"; - break; - case 0xee03UL: - modelp = "SMC2802W V2"; - notwork = 1; - break; - case 0x2835UL: - modelp = "SMC2835W"; - break; - case 0xa835UL: - modelp = "SMC2835W V2"; - notwork = 1; - break; - case 0xc104UL: - modelp = "CG-WLCB54GT"; - break; - case 0x1605UL: - modelp = "Tekram Technology clone"; - break; - /* Let's leave this one out for now since it seems bogus/wrong - * Even if the manufacturer did use 0x0000UL it may not be correct - * by their part, therefore deserving no name ;) */ - /* case 0x0000UL: - * modelp = "SparkLAN WL-850F"; - * break;*/ - - /* We have two reported for the one below :( */ - case 0x0014UL: - modelp = "I4 Z-Com XG-600 and clones"; - break; - case 0x0020UL: - modelp = "I4 Z-Com XG-900 and clones"; - break; -/* Default it */ -/* - case PCIDEVICE_ISL3890: - modelp = "PRISM Duette/GT"; - break; -*/ - default: - modelp = "PRISM Duette/GT"; - } - printk(KERN_DEBUG "%s: %s driver detected card model: %s\n", - ndev->name, DRV_NAME, modelp); - if ( notwork ) { - printk(KERN_DEBUG "%s: %s Warning - This may not work\n", - ndev->name, DRV_NAME); - } - return; -} - /****************************************************************************** Module initialization functions ******************************************************************************/ @@ -354,17 +203,14 @@ /* firmware upload is triggered in islpci_open */ - /* Pretty card model discovery output */ - prism54_get_card_model(ndev); - return 0; do_unregister_netdev: unregister_netdev(ndev); islpci_free_memory(priv); - pci_set_drvdata(pdev, 0); + pci_set_drvdata(pdev, NULL); free_netdev(ndev); - priv = 0; + priv = NULL; do_pci_release_regions: pci_release_regions(pdev); do_pci_disable_device: @@ -380,7 +226,7 @@ prism54_remove(struct pci_dev *pdev) { struct net_device *ndev = pci_get_drvdata(pdev); - islpci_private *priv = ndev ? netdev_priv(ndev) : 0; + islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; BUG_ON(!priv); if (!__in_cleanup_module) { @@ -408,9 +254,9 @@ /* free the PCI memory and unmap the remapped page */ islpci_free_memory(priv); - pci_set_drvdata(pdev, 0); + pci_set_drvdata(pdev, NULL); free_netdev(ndev); - priv = 0; + priv = NULL; pci_release_regions(pdev); @@ -421,7 +267,7 @@ prism54_suspend(struct pci_dev *pdev, u32 state) { struct net_device *ndev = pci_get_drvdata(pdev); - islpci_private *priv = ndev ? netdev_priv(ndev) : 0; + islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; BUG_ON(!priv); printk(KERN_NOTICE "%s: got suspend request (state %d)\n", @@ -446,7 +292,7 @@ prism54_resume(struct pci_dev *pdev) { struct net_device *ndev = pci_get_drvdata(pdev); - islpci_private *priv = ndev ? netdev_priv(ndev) : 0; + islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; BUG_ON(!priv); printk(KERN_NOTICE "%s: got resume request\n", ndev->name); diff -Naur linux-2.4.28-pre2/drivers/net/wireless/prism54/islpci_mgt.h linux-2.4.28-pre2msw/drivers/net/wireless/prism54/islpci_mgt.h --- linux-2.4.28-pre2/drivers/net/wireless/prism54/islpci_mgt.h 2004-09-05 10:08:56.000000000 +0200 +++ linux-2.4.28-pre2msw/drivers/net/wireless/prism54/islpci_mgt.h 2004-09-05 10:36:25.000000000 +0200 @@ -38,21 +38,6 @@ /* General driver definitions */ -#define PCIVENDOR_INTERSIL 0x1260UL -#define PCIVENDOR_3COM 0x10b7UL -#define PCIVENDOR_DLINK 0x1186UL -#define PCIVENDOR_I4 0x17cfUL -#define PCIVENDOR_IODATA 0x10fcUL -#define PCIVENDOR_NETGEAR 0x1385UL -#define PCIVENDOR_SMC 0x10b8UL -#define PCIVENDOR_ACCTON 0x1113UL -#define PCIVENDOR_ATI 0x1259UL -#define PCIVENDOR_TTL 0x16a5UL - -#define PCIDEVICE_ISL3877 0x3877UL -#define PCIDEVICE_ISL3886 0x3886UL -#define PCIDEVICE_ISL3890 0x3890UL -#define PCIDEVICE_3COM6001 0x6001UL #define PCIDEVICE_LATENCY_TIMER_MIN 0x40 #define PCIDEVICE_LATENCY_TIMER_VAL 0x50 diff -Naur linux-2.4.28-pre2/drivers/net/wireless/prism54/oid_mgt.c linux-2.4.28-pre2msw/drivers/net/wireless/prism54/oid_mgt.c --- linux-2.4.28-pre2/drivers/net/wireless/prism54/oid_mgt.c 2004-09-05 10:08:56.000000000 +0200 +++ linux-2.4.28-pre2msw/drivers/net/wireless/prism54/oid_mgt.c 2004-09-05 10:36:25.000000000 +0200 @@ -219,7 +219,7 @@ OID_UNKNOWN(OID_INL_MEMORY, 0xFF020002), OID_U32_C(OID_INL_MODE, 0xFF020003), OID_UNKNOWN(OID_INL_COMPONENT_NR, 0xFF020004), - OID_UNKNOWN(OID_INL_VERSION, 0xFF020005), + OID_STRUCT(OID_INL_VERSION, 0xFF020005, u8[8], OID_TYPE_RAW), OID_UNKNOWN(OID_INL_INTERFACE_ID, 0xFF020006), OID_UNKNOWN(OID_INL_COMPONENT_ID, 0xFF020007), OID_U32_C(OID_INL_CONFIG, 0xFF020008), @@ -481,6 +481,8 @@ BUG_ON(OID_NUM_LAST <= n); BUG_ON(extra > isl_oid[n].range); + res->ptr = NULL; + if (!priv->mib) /* memory has been freed */ return -1; @@ -613,7 +615,9 @@ DOT11_OID_DEFKEYID, DOT11_OID_DOT1XENABLE, OID_INL_DOT11D_CONFORMANCE, + /* Do not initialize this - fw < 1.0.4.3 rejects it OID_INL_OUTPUTPOWER, + */ }; /* update the MAC addr. */ diff -Naur linux-2.4.28-pre2/drivers/net/wireless/prism54/prismcompat24.h linux-2.4.28-pre2msw/drivers/net/wireless/prism54/prismcompat24.h --- linux-2.4.28-pre2/drivers/net/wireless/prism54/prismcompat24.h 2004-09-05 10:08:56.000000000 +0200 +++ linux-2.4.28-pre2msw/drivers/net/wireless/prism54/prismcompat24.h 2004-09-05 10:36:55.000000000 +0200 @@ -52,7 +52,7 @@ #define schedule_work schedule_task #if !defined(HAVE_NETDEV_PRIV) -#define netdev_priv(x) x->priv +#define netdev_priv(x) (x)->priv #endif #if !defined(CONFIG_FW_LOADER) && !defined(CONFIG_FW_LOADER_MODULE) --Boundary-00=_FltOBefVy+CGV5h-- From zdzichu@irc.pl Sun Sep 5 02:53:30 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 02:53:35 -0700 (PDT) Received: from mother.localdomain (serwer.tvgawex.pl [212.122.214.2]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i859rS3Y017784 for ; Sun, 5 Sep 2004 02:53:29 -0700 Received: (qmail 22454 invoked by uid 1000); 5 Sep 2004 09:46:36 -0000 Date: Sun, 5 Sep 2004 11:46:36 +0200 From: Tomasz Torcz To: netdev@oss.sgi.com Subject: Improvements in FreeBSD 5.3 networking Message-ID: <20040905094636.GA10086@irc.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i X-archive-position: 8413 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: zdzichu@irc.pl Precedence: bulk X-list: netdev Hi, reading Slashdot I'm sutmbled upon presentation of FreeBSD new features: http://people.freebsd.org/~andre/FreeBSD-5.3-Networking.pdf It look pretty interesting (e.g. tcphostcache), especially they claim that FreeBSD on 2.8 GHz Xeon can route 1Mpps. Original slashodt story: http://bsd.slashdot.org/article.pl?sid=04/09/04/133253 -- Tomasz Torcz Morality must always be based on practicality. zdzichu@irc.-nie.spam-.pl -- Baron Vladimir Harkonnen From margitsw@t-online.de Sun Sep 5 03:10:46 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 03:10:51 -0700 (PDT) Received: from mailout03.sul.t-online.com (mailout03.sul.t-online.com [194.25.134.81]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85AAjtP018366 for ; Sun, 5 Sep 2004 03:10:46 -0700 Received: from fwd08.aul.t-online.de by mailout03.sul.t-online.com with smtp id 1C3tyk-0006cQ-02; Sun, 05 Sep 2004 12:10:34 +0200 Received: from roglap.local (Z4iPzrZSQeHK3nA2mEOEbmeO6F6DnZim6TtDvGVX5o0j2ba6zholQg@[217.224.19.205]) by fwd08.sul.t-online.com with esmtp id 1C3tyj-14ymbA0; Sun, 5 Sep 2004 12:10:33 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH 0/6 linux-2.6.9-rc1/linux-2.4.28-pre2] prism54 patches resend Date: Sun, 5 Sep 2004 11:58:59 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409051158.59976.margitsw@t-online.de> X-ID: Z4iPzrZSQeHK3nA2mEOEbmeO6F6DnZim6TtDvGVX5o0j2ba6zholQg X-TOI-MSGID: 34695457-a5df-400d-82d6-203e26ddb276 X-archive-position: 8414 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev 2004-09-05 Margit Schubert-While * Resend of patches as follows : * 01_frequency.patch * Fix frequency reporting * 02_codeclean.patch * Code clean up * 03_remove_modparms.patch * Remove unneeded module params * 04_handle_we17.patch * Handle WE17 extensions * 05_start_wpa.patch * Initial WPA work * 06_fix_freqparse.patch * Fix frequency parsing * After the 2.4.28 rollup patch, this applies to both 2.4 and 2.6. Margit From margitsw@t-online.de Sun Sep 5 03:13:28 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 03:13:33 -0700 (PDT) Received: from mailout03.sul.t-online.com (mailout03.sul.t-online.com [194.25.134.81]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85ADSbw018679 for ; Sun, 5 Sep 2004 03:13:28 -0700 Received: from fwd02.aul.t-online.de by mailout03.sul.t-online.com with smtp id 1C3u1N-0004eY-01; Sun, 05 Sep 2004 12:13:17 +0200 Received: from roglap.local (X7k0eqZVYeTQjcbUPUkjpDJPzedXj3J5n---3hj2aCXrzcBpZJ32Ud@[217.224.19.205]) by fwd02.sul.t-online.com with esmtp id 1C3u1M-06zvAu0; Sun, 5 Sep 2004 12:13:16 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH 1/6 linux-2.6.9-rc1/2.4.28-pre2] prism54 Bug - Fix frequency reporting Date: Sun, 5 Sep 2004 12:01:43 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_HQuOB3p1Mjavrdt" Message-Id: <200409051201.43676.margitsw@t-online.de> X-ID: X7k0eqZVYeTQjcbUPUkjpDJPzedXj3J5n---3hj2aCXrzcBpZJ32Ud X-TOI-MSGID: f59740aa-d3e4-4063-bbd2-b706c8994501 X-archive-position: 8415 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev --Boundary-00=_HQuOB3p1Mjavrdt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 2004-09-05 Margit Schubert-While * prism54_get_freq is incorrectly returning channel * and not frequency. Wireless tools detect this, but * other programs do not, leading to insane reported * values. (As Jean documents, drivers should really be * reporting the frequency). * An example is wavemon. Margit --Boundary-00=_HQuOB3p1Mjavrdt Content-Type: text/x-diff; charset="us-ascii"; name="01_frequency.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="01_frequency.patch" diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c 2004-08-14 07:36:44.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:16:55.000000000 +0200 @@ -334,9 +334,10 @@ int rvalue; rvalue = mgt_get_request(priv, DOT11_OID_CHANNEL, 0, NULL, &r); - + fwrq->i = r.u; + rvalue |= mgt_get_request(priv, DOT11_OID_FREQUENCY, 0, NULL, &r); fwrq->m = r.u; - fwrq->e = 0; + fwrq->e = 3; return rvalue; } --Boundary-00=_HQuOB3p1Mjavrdt-- From margitsw@t-online.de Sun Sep 5 03:18:39 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 03:18:45 -0700 (PDT) Received: from mailout10.sul.t-online.com (mailout10.sul.t-online.com [194.25.134.21]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85AIcU8019061 for ; Sun, 5 Sep 2004 03:18:39 -0700 Received: from fwd09.aul.t-online.de by mailout10.sul.t-online.com with smtp id 1C3u5z-0007H1-01; Sun, 05 Sep 2004 12:18:03 +0200 Received: from roglap.local (SgCav+Z68eNk54ssHAOzKTfoEV+ZEXjIvRR12CKIOzYzKeloIs5Fw3@[217.224.19.205]) by fwd09.sul.t-online.com with esmtp id 1C3u5m-1hKpY80; Sun, 5 Sep 2004 12:17:50 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH 2/6 linux-2.6.9-rc1/2.4.28-pre2] prism54 Code cleanup Date: Sun, 5 Sep 2004 12:06:17 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_ZUuOBkgLRqNii/g" Message-Id: <200409051206.17586.margitsw@t-online.de> X-ID: SgCav+Z68eNk54ssHAOzKTfoEV+ZEXjIvRR12CKIOzYzKeloIs5Fw3 X-TOI-MSGID: f7b73a37-c6b4-47fe-86e0-40bcffd21008 X-archive-position: 8416 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev --Boundary-00=_ZUuOBkgLRqNii/g Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 2004-09-05 Margit Schubert-While (Patches submitted by Denis Vlasenko) There are neither functionality changes nor bug fixes. * 2004-08-14 Denis Vlasenko * Move assignment out of if() * Remove trailing space from printk * Eliminate not needed local 'u32 reg' * Add a comment about undoc bits * Add #define VEC_SIZE, use it as appropriate * Add some printks to reset error code path (our * current area of trouble) * Make printk text less confusing * Some not needed NULL assignments removed * mgt_commit_list(): tell which oid has failed Margit --Boundary-00=_ZUuOBkgLRqNii/g Content-Type: text/x-diff; charset="us-ascii"; name="02_codeclean.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="02_codeclean.patch" diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_38xx.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_38xx.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_38xx.c 2004-08-14 07:36:58.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_38xx.c 2004-09-05 10:41:07.000000000 +0200 @@ -133,8 +133,8 @@ readl(device_base + ISL38XX_CTRL_STAT_REG)); udelay(ISL38XX_WRITEIO_DELAY); - if (reg = readl(device_base + ISL38XX_INT_IDENT_REG), - reg == 0xabadface) { + reg = readl(device_base + ISL38XX_INT_IDENT_REG); + if (reg == 0xabadface) { #if VERBOSE > SHOW_ERROR_MESSAGES do_gettimeofday(¤t_time); DEBUG(SHOW_TRACING, @@ -192,10 +192,8 @@ void isl38xx_interface_reset(void *device_base, dma_addr_t host_address) { - u32 reg; - #if VERBOSE > SHOW_ERROR_MESSAGES - DEBUG(SHOW_FUNCTION_CALLS, "isl38xx_interface_reset \n"); + DEBUG(SHOW_FUNCTION_CALLS, "isl38xx_interface_reset\n"); #endif /* load the address of the control block in the device */ @@ -203,8 +201,7 @@ udelay(ISL38XX_WRITEIO_DELAY); /* set the reset bit in the Device Interrupt Register */ - isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_RESET, - ISL38XX_DEV_INT_REG); + isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_RESET, ISL38XX_DEV_INT_REG); udelay(ISL38XX_WRITEIO_DELAY); /* enable the interrupt for detecting initialization */ @@ -212,9 +209,7 @@ /* Note: Do not enable other interrupts here. We want the * device to have come up first 100% before allowing any other * interrupts. */ - reg = ISL38XX_INT_IDENT_INIT; - - isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG); + isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG); udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */ } diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_38xx.h linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_38xx.h --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_38xx.h 2004-08-14 07:38:11.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_38xx.h 2004-09-05 10:41:07.000000000 +0200 @@ -95,6 +95,10 @@ #define ISL38XX_INT_SOURCES 0x001E /* Control/Status register bits */ +/* Looks like there are other meaningful bits + 0x20004400 seen in normal operation, + 0x200044db at 'timeout waiting for mgmt response' +*/ #define ISL38XX_CTRL_STAT_SLEEPMODE 0x00000200 #define ISL38XX_CTRL_STAT_CLKRUN 0x00800000 #define ISL38XX_CTRL_STAT_RESET 0x10000000 diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:39:09.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:41:07.000000000 +0200 @@ -1947,7 +1947,7 @@ struct iw_point *data, char *extra) { islpci_private *priv = netdev_priv(ndev); - struct islpci_mgmtframe *response = NULL; + struct islpci_mgmtframe *response; int ret = -EIO; printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid); @@ -1983,7 +1983,7 @@ struct iw_point *data, char *extra) { islpci_private *priv = netdev_priv(ndev); - struct islpci_mgmtframe *response = NULL; + struct islpci_mgmtframe *response; int ret = 0, response_op = PIMFOR_OP_ERROR; printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid, diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_dev.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_dev.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_dev.c 2004-08-14 07:36:11.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_dev.c 2004-09-05 10:41:07.000000000 +0200 @@ -375,8 +375,6 @@ u32 rc; islpci_private *priv = netdev_priv(ndev); - printk(KERN_DEBUG "%s: islpci_open()\n", ndev->name); - /* reset data structures, upload firmware and reset device */ rc = islpci_reset(priv,1); if (rc) { @@ -462,8 +460,7 @@ return rc; } - printk(KERN_DEBUG - "%s: firmware uploaded done, now triggering reset...\n", + printk(KERN_DEBUG "%s: firmware upload complete\n", priv->ndev->name); islpci_set_state(priv, PRV_STATE_POSTBOOT); @@ -499,15 +496,16 @@ /* If we're here it's because our IRQ hasn't yet gone through. * Retry a bit more... */ - printk(KERN_ERR "%s: device soft reset timed out\n", - priv->ndev->name); - + printk(KERN_ERR "%s: reset problem: no 'reset complete' IRQ seen\n", + priv->ndev->name); } finish_wait(&priv->reset_done, &wait); - if(result) + if (result) { + printk(KERN_ERR "%s: islpci_reset_if: failure\n", priv->ndev->name); return result; + } islpci_set_state(priv, PRV_STATE_INIT); @@ -524,6 +522,7 @@ islpci_set_state(priv, PRV_STATE_READY); + printk(KERN_DEBUG "%s: interface reset complete\n", priv->ndev->name); return 0; } @@ -584,18 +583,18 @@ /* now that the data structures are cleaned up, upload * firmware and reset interface */ rc = islpci_upload_fw(priv); - if (rc) + if (rc) { + printk(KERN_ERR "%s: islpci_reset: failure\n", + priv->ndev->name); return rc; + } } /* finally reset interface */ rc = islpci_reset_if(priv); - if (!rc) /* If successful */ - return rc; - - printk(KERN_DEBUG "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n"); + if (rc) + printk(KERN_ERR "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n"); return rc; - } struct net_device_stats * @@ -604,7 +603,7 @@ islpci_private *priv = netdev_priv(ndev); #if VERBOSE > SHOW_ERROR_MESSAGES - DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics \n"); + DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics\n"); #endif return &priv->statistics; diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_eth.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_eth.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_eth.c 2004-08-14 07:36:14.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_eth.c 2004-09-05 10:41:07.000000000 +0200 @@ -508,11 +508,12 @@ /* increment the transmit error counter */ statistics->tx_errors++; + printk(KERN_WARNING "%s: tx_timeout", ndev->name); if (!priv->reset_task_pending) { priv->reset_task_pending = 1; + printk(", scheduling a reset"); netif_stop_queue(ndev); schedule_work(&priv->reset_task); } - - return; + printk("\n"); } diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/oid_mgt.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/oid_mgt.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/oid_mgt.c 2004-08-14 07:38:04.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/oid_mgt.c 2004-09-05 10:41:07.000000000 +0200 @@ -555,15 +555,18 @@ u32 oid = t->oid; BUG_ON(data == NULL); while (j <= t->range) { - response = NULL; - ret |= islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET, + int r = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET, oid, data, t->size, &response); if (response) { - ret |= (response->header->operation == - PIMFOR_OP_ERROR); + r |= (response->header->operation == PIMFOR_OP_ERROR); islpci_mgt_release(response); } + if (r) + printk(KERN_ERR "%s: mgt_commit_list: failure. " + "oid=%08x err=%d\n", + priv->ndev->name, oid, r); + ret |= r; j++; oid++; data += t->size; @@ -624,7 +627,7 @@ static int mgt_update_addr(islpci_private *priv) { - struct islpci_mgmtframe *res = NULL; + struct islpci_mgmtframe *res; int ret; ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET, @@ -638,9 +641,13 @@ if (res) islpci_mgt_release(res); + if (ret) + printk(KERN_ERR "%s: mgt_update_addr: failure\n", priv->ndev->name); return ret; } +#define VEC_SIZE(a) (sizeof(a)/sizeof(a[0])) + void mgt_commit(islpci_private *priv) { @@ -650,14 +657,10 @@ if (islpci_get_state(priv) < PRV_STATE_INIT) return; - rvalue = mgt_commit_list(priv, commit_part1, - sizeof (commit_part1) / - sizeof (commit_part1[0])); + rvalue = mgt_commit_list(priv, commit_part1, VEC_SIZE(commit_part1)); if (priv->iw_mode != IW_MODE_MONITOR) - rvalue |= mgt_commit_list(priv, commit_part2, - sizeof (commit_part2) / - sizeof (commit_part2[0])); + rvalue |= mgt_commit_list(priv, commit_part2, VEC_SIZE(commit_part2)); u = OID_INL_MODE; rvalue |= mgt_commit_list(priv, &u, 1); @@ -666,8 +669,7 @@ if (rvalue) { /* some request have failed. The device might be in an incoherent state. We should reset it ! */ - printk(KERN_DEBUG "%s: mgt_commit has failed. Restart the " - "device \n", priv->ndev->name); + printk(KERN_DEBUG "%s: mgt_commit: failure\n", priv->ndev->name); } } --Boundary-00=_ZUuOBkgLRqNii/g-- From margitsw@t-online.de Sun Sep 5 03:24:36 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 03:24:40 -0700 (PDT) Received: from mailout06.sul.t-online.com (mailout06.sul.t-online.com [194.25.134.19]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85AOZqP019418 for ; Sun, 5 Sep 2004 03:24:35 -0700 Received: from fwd07.aul.t-online.de by mailout06.sul.t-online.com with smtp id 1C3uBo-0005EG-03; Sun, 05 Sep 2004 12:24:04 +0200 Received: from roglap.local (Z62NCBZ-YeBMptqq76hoeXXDLHfTPmTnsbnxFciOMtFTK14FljJtgW@[217.224.19.205]) by fwd07.sul.t-online.com with esmtp id 1C3uBl-06ZWTo0; Sun, 5 Sep 2004 12:24:01 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH 3/6 linux-2.6.9-rc1/2.4.28-pre2] prism54 remove module params Date: Sun, 5 Sep 2004 12:12:28 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_MauOBTDXmybLGKK" Message-Id: <200409051212.28081.margitsw@t-online.de> X-ID: Z62NCBZ-YeBMptqq76hoeXXDLHfTPmTnsbnxFciOMtFTK14FljJtgW X-TOI-MSGID: 59e3e93a-549b-41cb-8710-5cb397a8c1b4 X-archive-position: 8417 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev --Boundary-00=_MauOBTDXmybLGKK Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 2004-09-05 Margit Schubert-While 2004-08-18 Luis R. Rodriguez * Remove unneeded module params. Margit --Boundary-00=_MauOBTDXmybLGKK Content-Type: text/x-diff; charset="us-ascii"; name="03_remove_modparms.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="03_remove_modparms.patch" diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:44:54.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:45:27.000000000 +0200 @@ -36,38 +36,6 @@ #include /* New driver API */ -static int init_mode = CARD_DEFAULT_IW_MODE; -static int init_channel = CARD_DEFAULT_CHANNEL; -static int init_wep = CARD_DEFAULT_WEP; -static int init_filter = CARD_DEFAULT_FILTER; -static int init_authen = CARD_DEFAULT_AUTHEN; -static int init_dot1x = CARD_DEFAULT_DOT1X; -static int init_conformance = CARD_DEFAULT_CONFORMANCE; -static int init_mlme = CARD_DEFAULT_MLME_MODE; - -module_param(init_mode, int, 0); -MODULE_PARM_DESC(init_mode, - "Set card mode:\n0: Auto\n1: Ad-Hoc\n2: Managed Client (Default)\n3: Master / Access Point\n4: Repeater (Not supported yet)\n5: Secondary (Not supported yet)\n6: Monitor"); - -module_param(init_channel, int, 0); -MODULE_PARM_DESC(init_channel, - "Check `iwpriv ethx channel` for available channels"); - -module_param(init_wep, int, 0); -module_param(init_filter, int, 0); - -module_param(init_authen, int, 0); -MODULE_PARM_DESC(init_authen, - "Authentication method. Can be of seven types:\n0 0x0000: None\n1 0x0001: DOT11_AUTH_OS (Default)\n2 0x0002: DOT11_AUTH_SK\n3 0x0003: DOT11_AUTH_BOTH"); - -module_param(init_dot1x, int, 0); -MODULE_PARM_DESC(init_dot1x, - "\n0: None/not set (Default)\n1: DOT11_DOT1X_AUTHENABLED\n2: DOT11_DOT1X_KEYTXENABLED"); - -module_param(init_mlme, int, 0); -MODULE_PARM_DESC(init_mlme, - "Sets the MAC layer management entity (MLME) mode of operation,\n0: DOT11_MLME_AUTO (Default)\n1: DOT11_MLME_INTERMEDIATE\n2: DOT11_MLME_EXTENDED"); - /** * prism54_mib_mode_helper - MIB change mode helper function * @mib: the &struct islpci_mib object to modify @@ -141,36 +109,34 @@ void prism54_mib_init(islpci_private *priv) { - u32 t; + u32 channel, authen, wep, filter, dot1x, mlme, conformance, power, mode; struct obj_buffer psm_buffer = { .size = PSM_BUFFER_SIZE, .addr = priv->device_psm_buffer }; - mgt_set(priv, DOT11_OID_CHANNEL, &init_channel); - mgt_set(priv, DOT11_OID_AUTHENABLE, &init_authen); - mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &init_wep); - + channel = CARD_DEFAULT_CHANNEL; + authen = CARD_DEFAULT_AUTHEN; + wep = CARD_DEFAULT_WEP; + filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */ + dot1x = CARD_DEFAULT_DOT1X; + mlme = CARD_DEFAULT_MLME_MODE; + conformance = CARD_DEFAULT_CONFORMANCE; + power = 127; + mode = CARD_DEFAULT_IW_MODE; + + mgt_set(priv, DOT11_OID_CHANNEL, &channel); + mgt_set(priv, DOT11_OID_AUTHENABLE, &authen); + mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &wep); mgt_set(priv, DOT11_OID_PSMBUFFER, &psm_buffer); - mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &init_filter); - mgt_set(priv, DOT11_OID_DOT1XENABLE, &init_dot1x); - mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &init_mlme); - mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &init_conformance); - - t = 127; - mgt_set(priv, OID_INL_OUTPUTPOWER, &t); - - /* Important: we are setting a default wireless mode and we are - * forcing a valid one, so prism54_mib_mode_helper should just set - * mib values depending on what the wireless mode given is. No need - * for it save old values */ - if (init_mode > IW_MODE_MONITOR || init_mode < IW_MODE_AUTO) { - printk(KERN_DEBUG "%s(): You passed a non-valid init_mode. " - "Using default mode\n", __FUNCTION__); - init_mode = CARD_DEFAULT_IW_MODE; - } + mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &filter); + mgt_set(priv, DOT11_OID_DOT1XENABLE, &dot1x); + mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlme); + mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &conformance); + mgt_set(priv, OID_INL_OUTPUTPOWER, &power); + /* This sets all of the mode-dependent values */ - prism54_mib_mode_helper(priv, init_mode); + prism54_mib_mode_helper(priv, mode); } /* this will be executed outside of atomic context thanks to --Boundary-00=_MauOBTDXmybLGKK-- From margitsw@t-online.de Sun Sep 5 03:30:37 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 03:30:43 -0700 (PDT) Received: from mailout02.sul.t-online.com (mailout02.sul.t-online.com [194.25.134.17]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85AUaQm019825 for ; Sun, 5 Sep 2004 03:30:37 -0700 Received: from fwd01.aul.t-online.de by mailout02.sul.t-online.com with smtp id 1C3uHd-0008De-04; Sun, 05 Sep 2004 12:30:05 +0200 Received: from roglap.local (E1vS+gZpQeR2fTuStRecyuTIyhPusaGaaSBQO-DNq18oh8FczBkEY5@[217.224.19.205]) by fwd01.sul.t-online.com with esmtp id 1C3uHa-1GyKqO0; Sun, 5 Sep 2004 12:30:02 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH 4/6 linux-2.6.9-rc1/2.4.28-pre2] prism54 add WE17 support Date: Sun, 5 Sep 2004 12:18:28 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_0fuOBMb4BojZJud" Message-Id: <200409051218.28597.margitsw@t-online.de> X-ID: E1vS+gZpQeR2fTuStRecyuTIyhPusaGaaSBQO-DNq18oh8FczBkEY5 X-TOI-MSGID: 59bffabe-404c-443e-933d-c999c4290065 X-archive-position: 8418 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev --Boundary-00=_0fuOBMb4BojZJud Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 2004-09-05 Margit Schubert-While 2004-08-18 Luis R. Rodriguez * Add support for WE17 from Jean Tourrilhes Margit --Boundary-00=_0fuOBMb4BojZJud Content-Type: text/x-diff; charset="us-ascii"; name="04_handle_we17.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="04_handle_we17.patch" diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:46:50.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:47:13.000000000 +0200 @@ -451,6 +451,15 @@ /* txpower is supported in dBm's */ range->txpower_capa = IW_TXPOW_DBM; +#if WIRELESS_EXT > 16 + /* Event capability (kernel + driver) */ + range->event_capa[0] = (IW_EVENT_CAPA_K_0 | + IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) | + IW_EVENT_CAPA_MASK(SIOCGIWAP)); + range->event_capa[1] = IW_EVENT_CAPA_K_1; + range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM); +#endif /* WIRELESS_EXT > 16 */ + if (islpci_get_state(priv) < PRV_STATE_INIT) return 0; @@ -656,19 +665,33 @@ rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r); noise = r.u; - /* Ask the device for a list of known bss. We can report at most - * IW_MAX_AP=64 to the range struct. But the device won't repport anything - * if you change the value of IWMAX_BSS=24. - */ + /* Ask the device for a list of known bss. + * The old API, using SIOCGIWAPLIST, had a hard limit of IW_MAX_AP=64. + * The new API, using SIOCGIWSCAN, is only limited by the buffer size. + * WE-14->WE-16, the buffer is limited to IW_SCAN_MAX_DATA bytes. + * Starting with WE-17, the buffer can be as big as needed. + * But the device won't repport anything if you change the value + * of IWMAX_BSS=24. */ + rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r); bsslist = r.ptr; /* ok now, scan the list and translate its info */ - for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++) + for (i = 0; i < (int) bsslist->nr; i++) { current_ev = prism54_translate_bss(ndev, current_ev, - extra + IW_SCAN_MAX_DATA, + extra + dwrq->length, &(bsslist->bsslist[i]), noise); +#if WIRELESS_EXT > 16 + /* Check if there is space for one more entry */ + if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) { + /* Ask user space to try again with a bigger buffer */ + rvalue = -E2BIG; + break; + } +#endif /* WIRELESS_EXT > 16 */ + } + kfree(bsslist); dwrq->length = (current_ev - extra); dwrq->flags = 0; /* todo */ @@ -2222,7 +2245,9 @@ .standard = (iw_handler *) prism54_handler, .private = (iw_handler *) prism54_private_handler, .private_args = (struct iw_priv_args *) prism54_private_args, +#if WIRELESS_EXT == 16 .spy_offset = offsetof(islpci_private, spy_data), +#endif /* WIRELESS_EXT == 16 */ }; /* For ioctls that don't work with the new API */ diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_dev.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_dev.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_dev.c 2004-09-05 10:44:54.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_dev.c 2004-09-05 10:47:13.000000000 +0200 @@ -829,6 +829,12 @@ priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ? priv->monitor_type : ARPHRD_ETHER; +#if WIRELESS_EXT > 16 + /* Add pointers to enable iwspy support. */ + priv->wireless_data.spy_data = &priv->spy_data; + ndev->wireless_data = &priv->wireless_data; +#endif /* WIRELESS_EXT > 16 */ + /* save the start and end address of the PCI memory area */ ndev->mem_start = (unsigned long) priv->device_base; ndev->mem_end = ndev->mem_start + ISL38XX_PCI_MEM_SIZE; diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_dev.h linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_dev.h --- linux-2.6.9rc1/drivers/net/wireless/prism54/islpci_dev.h 2004-08-14 07:36:56.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/islpci_dev.h 2004-09-05 10:47:13.000000000 +0200 @@ -100,6 +100,10 @@ struct iw_spy_data spy_data; /* iwspy support */ +#if WIRELESS_EXT > 16 + struct iw_public_data wireless_data; +#endif /* WIRELESS_EXT > 16 */ + int monitor_type; /* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_PRISM */ struct islpci_acl acl; --Boundary-00=_0fuOBMb4BojZJud-- From margitsw@t-online.de Sun Sep 5 03:44:44 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 03:44:50 -0700 (PDT) Received: from mailout10.sul.t-online.com (mailout10.sul.t-online.com [194.25.134.21]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85Aiggd020364 for ; Sun, 5 Sep 2004 03:44:43 -0700 Received: from fwd10.aul.t-online.de by mailout10.sul.t-online.com with smtp id 1C3uVI-0001oZ-00; Sun, 05 Sep 2004 12:44:12 +0200 Received: from roglap.local (bLP3BgZAQelsixkqQpxiwtFJhKW4nqAz9RAU0Ur8S8O1yxjsTCOFEz@[217.224.19.205]) by fwd10.sul.t-online.com with esmtp id 1C3uV8-2JwpKy0; Sun, 5 Sep 2004 12:44:02 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH 5/6 linux-2.6.9-rc1/2.4.28-pre2] prism54 initial WPA support Date: Sun, 5 Sep 2004 12:32:29 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_9suOBTiZpSr4nE3" Message-Id: <200409051232.29014.margitsw@t-online.de> X-ID: bLP3BgZAQelsixkqQpxiwtFJhKW4nqAz9RAU0Ur8S8O1yxjsTCOFEz X-TOI-MSGID: 025dfab6-3039-49f2-9ecc-bb89e97d05db X-archive-position: 8419 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev --Boundary-00=_9suOBTiZpSr4nE3 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 2004-09-05 Margit Schubert-While 2004-08-18 Luis R. Rodriguez * Work based on initial patches from Jouni Malinen * Initial wpa_supplicant support work: * isl_ioctl.c (prism54_process_trap_helper): Start to use mlmeex, * start doing what's right for * DOT11_OID_AUTHENTICATEEX, * DOT11_OID_ASSOCIATEEX, * DOT11_OID_ASSOCIATEEX, and * DOT11_OID_REASSOCIATEEX * isl_ioctl.c: add temporary structure for wpa_supplicant requests, * isl_ioctl.c: add prism2_ioctl_set_encryption which can probably be removed later * isl_ioctl.c: add prism2_ioctl_set_generic_element (well tested) * isl_ioctl.c: add prism2_ioctl_mlme which should be unnecessary since * WE scan should be used by wpa_supplicant * isl_ioctl.c: add prism54_hostapd - this parses wpa_supplicant * requests and does the right job for each * isl_ioctl.c (prism54_set_wpa): changed to not use mgt_set/mgt_commit * as commit is unecessary. Added proper OID sets to enable/disable WPA. * This is called by wpa_supplicant at startup. This should eventually * be part of WE18. * isl_ioctl.c (prism54_ioctl): Links wpa_supplicant to prism54 * isl_ioctl.h: defined prism54_set_wpa to allow prism54_hostapd to use * isl_oid.h: add struct obj_attachment for OID OID_TYPE_ATTACH * oid_mgt.c: map OID DOT11_OID_ATTACHMENT to struct obj_attachment * oid_mgt.c (mgt_le_to_cpu, mgt_cpu_to_le): handle endianness for * obj_attachment * oid_mgt.c: add mgt_set_varlen, needed for mlmeex as it has a * variable size field. * oid_mgt.c: add mgt_unlatch_all, this can be used to force a commit * on OIDs: * MEDIUMLIMIT, BEACONPERIOD, DTIMPERIOD, ATIMWINDOW, * LISTENINTERVAL, FREQUENCY, EXTENDEDRATES * These OIDs are "latched". TODO: config mode handling. * oid_mgt.c (mgt_response_to_str): learn to parse OID_TYPE_ATTACH * oid_mgt.h: add mgt_set_varlen, and mgt_unlatch_all Margit --Boundary-00=_9suOBTiZpSr4nE3 Content-Type: text/x-diff; charset="us-ascii"; name="05_start_wpa.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="05_start_wpa.patch" diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:48:32.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:49:05.000000000 +0200 @@ -1735,11 +1735,13 @@ char *data) { struct obj_mlme *mlme = (struct obj_mlme *) data; - size_t len; - u8 *payload, *pos = (u8 *) (mlme + 1); - - len = pos[0] | (pos[1] << 8); /* little endian data length */ - payload = pos + 2; + struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data; + struct obj_mlmeex *confirm; + u8 wpa_ie[MAX_WPA_IE_LEN]; + int wpa_ie_len; + size_t len = 0; /* u16, better? */ + u8 *payload = 0, *pos = 0; + int ret; /* I think all trapable objects are listed here. * Some oids have a EX version. The difference is that they are emitted @@ -1749,9 +1751,14 @@ * suited. We use the more flexible custom event facility. */ + if (oid >= DOT11_OID_BEACON) { + len = mlmeex->size; + payload = pos = mlmeex->data; + } + /* I fear prism54_process_bss_data won't work with big endian data */ if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE)) - prism54_process_bss_data(priv, oid, mlme->address, + prism54_process_bss_data(priv, oid, mlmeex->address, payload, len); mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme); @@ -1811,21 +1818,134 @@ case DOT11_OID_AUTHENTICATEEX: handle_request(priv, mlme, oid); - send_formatted_event(priv, "Authenticate request", mlme, 1); + send_formatted_event(priv, "Authenticate request (ex)", mlme, 1); + + if (priv->iw_mode != IW_MODE_MASTER + && mlmeex->state != DOT11_STATE_AUTHING) + break; + + confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC); + + if (!confirm) + break; + + memcpy(&confirm->address, mlmeex->address, ETH_ALEN); + printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", + mlmeex->address[0], + mlmeex->address[1], + mlmeex->address[2], + mlmeex->address[3], + mlmeex->address[4], + mlmeex->address[5] + ); + confirm->id = -1; /* or mlmeex->id ? */ + confirm->state = 0; /* not used */ + confirm->code = 0; + confirm->size = 6; + confirm->data[0] = 0x00; + confirm->data[1] = 0x00; + confirm->data[2] = 0x02; + confirm->data[3] = 0x00; + confirm->data[4] = 0x00; + confirm->data[5] = 0x00; + + ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6); + + kfree(confirm); + if (ret) + return ret; break; case DOT11_OID_DISASSOCIATEEX: - send_formatted_event(priv, "Disassociate request", mlme, 0); + send_formatted_event(priv, "Disassociate request (ex)", mlme, 0); break; case DOT11_OID_ASSOCIATEEX: handle_request(priv, mlme, oid); - send_formatted_event(priv, "Associate request", mlme, 1); + send_formatted_event(priv, "Associate request (ex)", mlme, 1); + + if (priv->iw_mode != IW_MODE_MASTER + && mlmeex->state != DOT11_STATE_AUTHING) + break; + + confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC); + + if (!confirm) + break; + + memcpy(&confirm->address, mlmeex->address, ETH_ALEN); + + confirm->id = ((struct obj_mlmeex *)mlme)->id; + confirm->state = 0; /* not used */ + confirm->code = 0; + + wpa_ie_len = prism54_wpa_ie_get(priv, mlmeex->address, wpa_ie); + + if (!wpa_ie_len) { + printk(KERN_DEBUG "No WPA IE found from " + "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", + mlmeex->address[0], + mlmeex->address[1], + mlmeex->address[2], + mlmeex->address[3], + mlmeex->address[4], + mlmeex->address[5] + ); + kfree(confirm); + break; + } + + confirm->size = wpa_ie_len; + memcpy(&confirm->data, wpa_ie, wpa_ie_len); + + mgt_set_varlen(priv, oid, confirm, wpa_ie_len); + + kfree(confirm); + break; case DOT11_OID_REASSOCIATEEX: handle_request(priv, mlme, oid); - send_formatted_event(priv, "Reassociate request", mlme, 1); + send_formatted_event(priv, "Reassociate request (ex)", mlme, 1); + + if (priv->iw_mode != IW_MODE_MASTER + && mlmeex->state != DOT11_STATE_ASSOCING) + break; + + confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC); + + if (!confirm) + break; + + memcpy(&confirm->address, mlmeex->address, ETH_ALEN); + + confirm->id = mlmeex->id; + confirm->state = 0; /* not used */ + confirm->code = 0; + + wpa_ie_len = prism54_wpa_ie_get(priv, mlmeex->address, wpa_ie); + + if (!wpa_ie_len) { + printk(KERN_DEBUG "No WPA IE found from " + "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", + mlmeex->address[0], + mlmeex->address[1], + mlmeex->address[2], + mlmeex->address[3], + mlmeex->address[4], + mlmeex->address[5] + ); + kfree(confirm); + break; + } + + confirm->size = wpa_ie_len; + memcpy(&confirm->data, wpa_ie, wpa_ie_len); + + mgt_set_varlen(priv, oid, confirm, wpa_ie_len); + + kfree(confirm); + break; default: @@ -1868,23 +1988,367 @@ return ret; } +/* Note: currently, use hostapd ioctl from the Host AP driver for WPA + * support. This is to be replaced with Linux wireless extensions once they + * get WPA support. */ + +/* Note II: please leave all this together as it will be easier to remove later, + * once wireless extensions add WPA support -mcgrof */ + +/* PRISM54_HOSTAPD ioctl() cmd: */ +enum { + PRISM2_SET_ENCRYPTION = 6, + PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12, + PRISM2_HOSTAPD_MLME = 13, + PRISM2_HOSTAPD_SCAN_REQ = 14, +}; + +#define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12 +#define PRISM54_HOSTAPD SIOCIWFIRSTPRIV+25 +#define PRISM54_DROP_UNENCRYPTED SIOCIWFIRSTPRIV+26 + +#define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024 +#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ +((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data)) + +/* Maximum length for algorithm names (-1 for nul termination) + * used in ioctl() */ +#define HOSTAP_CRYPT_ALG_NAME_LEN 16 + +struct prism2_hostapd_param { + u32 cmd; + u8 sta_addr[ETH_ALEN]; + union { + struct { + u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN]; + u32 flags; + u32 err; + u8 idx; + u8 seq[8]; /* sequence counter (set: RX, get: TX) */ + u16 key_len; + u8 key[0]; + } crypt; + struct { + u8 len; + u8 data[0]; + } generic_elem; + struct { +#define MLME_STA_DEAUTH 0 +#define MLME_STA_DISASSOC 1 + u16 cmd; + u16 reason_code; + } mlme; + struct { + u8 ssid_len; + u8 ssid[32]; + } scan_req; + } u; +}; + + +static int +prism2_ioctl_set_encryption(struct net_device *dev, + struct prism2_hostapd_param *param, + int param_len) +{ + islpci_private *priv = netdev_priv(dev); + int rvalue = 0, force = 0; + int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0; + union oid_res_t r; + + /* with the new API, it's impossible to get a NULL pointer. + * New version of iwconfig set the IW_ENCODE_NOKEY flag + * when no key is given, but older versions don't. */ + + if (param->u.crypt.key_len > 0) { + /* we have a key to set */ + int index = param->u.crypt.idx; + int current_index; + struct obj_key key = { DOT11_PRIV_TKIP, 0, "" }; + + /* get the current key index */ + rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r); + current_index = r.u; + /* Verify that the key is not marked as invalid */ + if (!(param->u.crypt.flags & IW_ENCODE_NOKEY)) { + key.length = param->u.crypt.key_len > sizeof (param->u.crypt.key) ? + sizeof (param->u.crypt.key) : param->u.crypt.key_len; + memcpy(key.key, param->u.crypt.key, key.length); + if (key.length == 32) + /* we want WPA-PSK */ + key.type = DOT11_PRIV_TKIP; + if ((index < 0) || (index > 3)) + /* no index provided use the current one */ + index = current_index; + + /* now send the key to the card */ + rvalue |= + mgt_set_request(priv, DOT11_OID_DEFKEYX, index, + &key); + } + /* + * If a valid key is set, encryption should be enabled + * (user may turn it off later). + * This is also how "iwconfig ethX key on" works + */ + if ((index == current_index) && (key.length > 0)) + force = 1; + } else { + int index = (param->u.crypt.flags & IW_ENCODE_INDEX) - 1; + if ((index >= 0) && (index <= 3)) { + /* we want to set the key index */ + rvalue |= + mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, + &index); + } else { + if (!param->u.crypt.flags & IW_ENCODE_MODE) { + /* we cannot do anything. Complain. */ + return -EINVAL; + } + } + } + /* now read the flags */ + if (param->u.crypt.flags & IW_ENCODE_DISABLED) { + /* Encoding disabled, + * authen = DOT11_AUTH_OS; + * invoke = 0; + * exunencrypt = 0; */ + } + if (param->u.crypt.flags & IW_ENCODE_OPEN) + /* Encode but accept non-encoded packets. No auth */ + invoke = 1; + if ((param->u.crypt.flags & IW_ENCODE_RESTRICTED) || force) { + /* Refuse non-encoded packets. Auth */ + authen = DOT11_AUTH_BOTH; + invoke = 1; + exunencrypt = 1; + } + /* do the change if requested */ + if ((param->u.crypt.flags & IW_ENCODE_MODE) || force) { + rvalue |= + mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen); + rvalue |= + mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke); + rvalue |= + mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, + &exunencrypt); + } + return rvalue; +} + +static int +prism2_ioctl_set_generic_element(struct net_device *ndev, + struct prism2_hostapd_param *param, + int param_len) +{ + islpci_private *priv = netdev_priv(ndev); + int max_len, len, alen, ret=0; + struct obj_attachment *attach; + + len = param->u.generic_elem.len; + max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN; + if (max_len < 0 || max_len < len) + return -EINVAL; + + alen = sizeof(*attach) + len; + attach = kmalloc(alen, GFP_KERNEL); + if (attach == NULL) + return -ENOMEM; + + memset(attach, 0, alen); +#define WLAN_FC_TYPE_MGMT 0 +#define WLAN_FC_STYPE_ASSOC_REQ 0 +#define WLAN_FC_STYPE_REASSOC_REQ 2 + + /* Note: endianness is covered by mgt_set_varlen */ + + attach->type = (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_ASSOC_REQ << 4); + attach->id = -1; + attach->size = len; + memcpy(attach->data, param->u.generic_elem.data, len); + + ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len); + + if (ret == 0) { + attach->type = (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_REASSOC_REQ << 4); + + ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len); + + if (ret == 0) + printk(KERN_DEBUG "%s: WPA IE Attachment was set\n", + ndev->name); + } + + kfree(attach); + return ret; + +} + +static int +prism2_ioctl_mlme(struct net_device *dev, struct prism2_hostapd_param *param) +{ + return -EOPNOTSUPP; +} + +static int +prism2_ioctl_scan_req(struct net_device *ndev, + struct prism2_hostapd_param *param) +{ + islpci_private *priv = netdev_priv(ndev); + int i, rvalue; + struct obj_bsslist *bsslist; + u32 noise = 0; + char *extra = ""; + char *current_ev = "foo"; + union oid_res_t r; + + if (islpci_get_state(priv) < PRV_STATE_INIT) { + /* device is not ready, fail gently */ + return 0; + } + + /* first get the noise value. We will use it to report the link quality */ + rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r); + noise = r.u; + + /* Ask the device for a list of known bss. We can report at most + * IW_MAX_AP=64 to the range struct. But the device won't repport anything + * if you change the value of IWMAX_BSS=24. + */ + rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r); + bsslist = r.ptr; + + /* ok now, scan the list and translate its info */ + for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++) + current_ev = prism54_translate_bss(ndev, current_ev, + extra + IW_SCAN_MAX_DATA, + &(bsslist->bsslist[i]), + noise); + kfree(bsslist); + + return rvalue; +} + +static int +prism54_hostapd(struct net_device *ndev, struct iw_point *p) +{ + struct prism2_hostapd_param *param; + int ret = 0; + u32 uwrq; + + printk(KERN_DEBUG "prism54_hostapd - len=%d\n", p->length); + if (p->length < sizeof(struct prism2_hostapd_param) || + p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) + return -EINVAL; + + param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL); + if (param == NULL) + return -ENOMEM; + + if (copy_from_user(param, p->pointer, p->length)) { + kfree(param); + return -EFAULT; + } + + switch (param->cmd) { + case PRISM2_SET_ENCRYPTION: + printk(KERN_DEBUG "%s: Caught WPA supplicant set encryption request\n", + ndev->name); + ret = prism2_ioctl_set_encryption(ndev, param, p->length); + break; + case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT: + printk(KERN_DEBUG "%s: Caught WPA supplicant set WPA IE request\n", + ndev->name); + ret = prism2_ioctl_set_generic_element(ndev, param, + p->length); + break; + case PRISM2_HOSTAPD_MLME: + printk(KERN_DEBUG "%s: Caught WPA supplicant MLME request\n", + ndev->name); + ret = prism2_ioctl_mlme(ndev, param); + break; + case PRISM2_HOSTAPD_SCAN_REQ: + printk(KERN_DEBUG "%s: Caught WPA supplicant scan request\n", + ndev->name); + ret = prism2_ioctl_scan_req(ndev, param); + break; + case PRISM54_SET_WPA: + printk(KERN_DEBUG "%s: Caught WPA supplicant wpa init request\n", + ndev->name); + uwrq = 1; + ret = prism54_set_wpa(ndev, NULL, &uwrq, NULL); + break; + case PRISM54_DROP_UNENCRYPTED: + printk(KERN_DEBUG "%s: Caught WPA drop unencrypted request\n", + ndev->name); +#if 0 + uwrq = 0x01; + mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &uwrq); + down_write(&priv->mib_sem); + mgt_commit(priv); + up_write(&priv->mib_sem); +#endif + /* Not necessary, as set_wpa does it, should we just do it here though? */ + ret = 0; + break; + default: + printk(KERN_DEBUG "%s: Caught a WPA supplicant request that is not supported\n", + ndev->name); + ret = -EOPNOTSUPP; + break; + } + + if (ret == 0 && copy_to_user(p->pointer, param, p->length)) + ret = -EFAULT; + + kfree(param); + + return ret; +} + int prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info, __u32 * uwrq, char *extra) { islpci_private *priv = netdev_priv(ndev); + u32 mlme, authen, dot1x, filter, wep; - down_write(&priv->mib_sem); + if (islpci_get_state(priv) < PRV_STATE_INIT) + return 0; + wep = 1; /* For privacy invoked */ + filter = 1; /* Filter out all unencrypted frames */ + dot1x = 0x01; /* To enable eap filter */ + mlme = DOT11_MLME_EXTENDED; + authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */ + + down_write(&priv->mib_sem); priv->wpa = *uwrq; - if (priv->wpa) { - u32 l = DOT11_MLME_EXTENDED; - mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &l); + + switch (priv->wpa) { + default: + case 0: /* Clears/disables WPA and friends */ + wep = 0; + filter = 0; /* Do not filter un-encrypted data */ + dot1x = 0; + mlme = DOT11_MLME_AUTO; + printk("%s: Disabling WPA\n", ndev->name); + break; + case 2: + case 1: /* WPA */ + printk("%s: Enabling WPA\n", ndev->name); + break; } - /* restart the card with new level. Needed ? */ - mgt_commit(priv); up_write(&priv->mib_sem); + mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen); + mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep); + mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter); + mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x); + mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme); + return 0; } @@ -2250,11 +2714,19 @@ #endif /* WIRELESS_EXT == 16 */ }; -/* For ioctls that don't work with the new API */ +/* For wpa_supplicant */ int prism54_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) { - + struct iwreq *wrq = (struct iwreq *) rq; + int ret = -1; + switch (cmd) { + case PRISM54_HOSTAPD: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + ret = prism54_hostapd(ndev, &wrq->u.data); + return ret; + } return -EOPNOTSUPP; } diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.h linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.h --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.h 2004-08-14 07:36:58.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.h 2004-09-05 10:49:05.000000000 +0200 @@ -48,6 +48,8 @@ int prism54_set_mac_address(struct net_device *, void *); int prism54_ioctl(struct net_device *, struct ifreq *, int); +int prism54_set_wpa(struct net_device *, struct iw_request_info *, + __u32 *, char *); extern const struct iw_handler_def prism54_handler_def; diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_oid.h linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_oid.h --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_oid.h 2004-08-14 07:37:15.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_oid.h 2004-09-05 10:49:05.000000000 +0200 @@ -91,6 +91,14 @@ u16 mhz[0]; } __attribute__ ((packed)); +struct obj_attachment { + char type; + char reserved; + short id; + short size; + char data[0]; +} __attribute__((packed)); + /* * in case everything's ok, the inlined function below will be * optimized away by the compiler... @@ -472,6 +480,7 @@ #define OID_TYPE_MLMEEX 0x09 #define OID_TYPE_ADDR 0x0A #define OID_TYPE_RAW 0x0B +#define OID_TYPE_ATTACH 0x0C /* OID_TYPE_MLMEEX is special because of a variable size field when sending. * Not yet implemented (not used in driver anyway). diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/oid_mgt.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/oid_mgt.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/oid_mgt.c 2004-09-05 10:44:54.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/oid_mgt.c 2004-09-05 10:49:05.000000000 +0200 @@ -201,7 +201,8 @@ OID_U32(DOT11_OID_STATIMEOUT, 0x19000000), OID_U32_C(DOT11_OID_MLMEAUTOLEVEL, 0x19000001), OID_U32(DOT11_OID_BSSTIMEOUT, 0x19000002), - OID_UNKNOWN(DOT11_OID_ATTACHMENT, 0x19000003), + [DOT11_OID_ATTACHMENT] = {0x19000003, 0, + sizeof(struct obj_attachment), OID_TYPE_ATTACH}, OID_STRUCT_C(DOT11_OID_PSMBUFFER, 0x19000004, struct obj_buffer, OID_TYPE_BUFFER), @@ -329,6 +330,12 @@ mlme->size = le16_to_cpu(mlme->size); break; } + case OID_TYPE_ATTACH:{ + struct obj_attachment *attach = data; + attach->id = le16_to_cpu(attach->id); + attach->size = le16_to_cpu(attach->size);; + break; + } case OID_TYPE_SSID: case OID_TYPE_KEY: case OID_TYPE_ADDR: @@ -392,6 +399,12 @@ mlme->size = cpu_to_le16(mlme->size); break; } + case OID_TYPE_ATTACH:{ + struct obj_attachment *attach = data; + attach->id = cpu_to_le16(attach->id); + attach->size = cpu_to_le16(attach->size);; + break; + } case OID_TYPE_SSID: case OID_TYPE_KEY: case OID_TYPE_ADDR: @@ -465,6 +478,42 @@ return ret; } +/* None of these are cached */ +int +mgt_set_varlen(islpci_private *priv, enum oid_num_t n, void *data, int extra_len) +{ + int ret = 0; + struct islpci_mgmtframe *response; + int response_op = PIMFOR_OP_ERROR; + int dlen; + u32 oid; + + BUG_ON(OID_NUM_LAST <= n); + + dlen = isl_oid[n].size; + oid = isl_oid[n].oid; + + mgt_cpu_to_le(isl_oid[n].flags & OID_FLAG_TYPE, data); + + if (islpci_get_state(priv) >= PRV_STATE_READY) { + ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET, oid, + data, dlen + extra_len, &response); + if (!ret) { + response_op = response->header->operation; + islpci_mgt_release(response); + } + if (ret || response_op == PIMFOR_OP_ERROR) + ret = -EIO; + } else + ret = -EIO; + + /* re-set given data to what it was */ + if (data) + mgt_le_to_cpu(isl_oid[n].flags & OID_FLAG_TYPE, data); + + return ret; +} + int mgt_get_request(islpci_private *priv, enum oid_num_t n, int extra, void *data, union oid_res_t *res) @@ -673,6 +722,40 @@ } } +/* The following OIDs need to be "unlatched": + * + * MEDIUMLIMIT,BEACONPERIOD,DTIMPERIOD,ATIMWINDOW,LISTENINTERVAL + * FREQUENCY,EXTENDEDRATES. + * + * The way to do this is to set ESSID. Note though that they may get + * unlatch before though by setting another OID. */ +void +mgt_unlatch_all(islpci_private *priv) +{ + u32 u; + int rvalue = 0; + + if (islpci_get_state(priv) < PRV_STATE_INIT) + return; + + u = DOT11_OID_SSID; + rvalue = mgt_commit_list(priv, &u, 1); + /* Necessary if in MANUAL RUN mode? */ +#if 0 + u = OID_INL_MODE; + rvalue |= mgt_commit_list(priv, &u, 1); + + u = DOT11_OID_MLMEAUTOLEVEL; + rvalue |= mgt_commit_list(priv, &u, 1); + + u = OID_INL_MODE; + rvalue |= mgt_commit_list(priv, &u, 1); +#endif + + if (rvalue) + printk(KERN_DEBUG "%s: Unlatching OIDs failed\n", priv->ndev->name); +} + /* This will tell you if you are allowed to answer a mlme(ex) request .*/ int @@ -773,6 +856,14 @@ mlme->state, mlme->code, mlme->size); } break; + case OID_TYPE_ATTACH:{ + struct obj_attachment *attach = r->ptr; + return snprintf(str, PRIV_STR_SIZE, + "id=%d\nsize=%d\n", + attach->id, + attach->size); + } + break; case OID_TYPE_SSID:{ struct obj_ssid *ssid = r->ptr; return snprintf(str, PRIV_STR_SIZE, diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/oid_mgt.h linux-2.6.9-rc1msw/drivers/net/wireless/prism54/oid_mgt.h --- linux-2.6.9rc1/drivers/net/wireless/prism54/oid_mgt.h 2004-08-14 07:38:07.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/oid_mgt.h 2004-09-05 10:49:05.000000000 +0200 @@ -36,6 +36,8 @@ void mgt_le_to_cpu(int, void *); int mgt_set_request(islpci_private *, enum oid_num_t, int, void *); +int mgt_set_varlen(islpci_private *, enum oid_num_t, void *, int); + int mgt_get_request(islpci_private *, enum oid_num_t, int, void *, union oid_res_t *); @@ -47,6 +49,7 @@ void mgt_get(islpci_private *, enum oid_num_t, void *); void mgt_commit(islpci_private *); +void mgt_unlatch_all(islpci_private *); int mgt_mlme_answer(islpci_private *); --Boundary-00=_9suOBTiZpSr4nE3-- From margitsw@t-online.de Sun Sep 5 03:50:17 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 03:50:22 -0700 (PDT) Received: from mailout09.sul.t-online.com (mailout09.sul.t-online.com [194.25.134.84]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85AoGPm020739 for ; Sun, 5 Sep 2004 03:50:17 -0700 Received: from fwd02.aul.t-online.de by mailout09.sul.t-online.com with smtp id 1C3uaZ-0006iB-00; Sun, 05 Sep 2004 12:49:39 +0200 Received: from roglap.local (X7k0e6Zage4T9+QRRYGXn7udS1tgLRjBj2jmqKiHeAFSkscfqCAQr7@[217.224.19.205]) by fwd02.sul.t-online.com with esmtp id 1C3uaP-1TlewS0; Sun, 5 Sep 2004 12:49:29 +0200 From: margitsw@t-online.de (Margit Schubert-While) To: jgarzik@pobox.com Subject: [PATCH 6/6 linux-2.6.9-rc1/2.4.28-pre2] prism54 fix wpa_supplicant frequency parsing Date: Sun, 5 Sep 2004 12:37:56 +0200 User-Agent: KMail/1.5.4 Cc: netdev@oss.sgi.com, prism54-devel@prism54.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_EyuOBgflA0PJwpo" Message-Id: <200409051237.56058.margitsw@t-online.de> X-ID: X7k0e6Zage4T9+QRRYGXn7udS1tgLRjBj2jmqKiHeAFSkscfqCAQr7 X-TOI-MSGID: 1062f646-4f41-46e4-a193-d554d8adf83a X-archive-position: 8420 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: margitsw@t-online.de Precedence: bulk X-list: netdev --Boundary-00=_EyuOBgflA0PJwpo Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 2004-09-05 Margit Schubert-While 2004-08-22 Luis R. Rodriguez * This work fixes wpa_supplicant frequency parsing. iwlist eth0 * scan will now show channel and frequency. Margit --Boundary-00=_EyuOBgflA0PJwpo Content-Type: text/x-diff; charset="us-ascii"; name="06_fix_freqparse.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="06_fix_freqparse.patch" diff -Naur linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c --- linux-2.6.9rc1/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:49:37.000000000 +0200 +++ linux-2.6.9-rc1msw/drivers/net/wireless/prism54/isl_ioctl.c 2004-09-05 10:49:53.000000000 +0200 @@ -604,8 +604,8 @@ current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, NULL); /* Add frequency. (short) bss->channel is the frequency in MHz */ - iwe.u.freq.m = channel_of_freq(bss->channel); - iwe.u.freq.e = 0; + iwe.u.freq.m = bss->channel; + iwe.u.freq.e = 6; iwe.cmd = SIOCGIWFREQ; current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); --Boundary-00=_EyuOBgflA0PJwpo-- From hadi@cyberus.ca Sun Sep 5 05:15:59 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 05:16:06 -0700 (PDT) Received: from lotus.znyx.com (znx208-2-156-007.znyx.com [208.2.156.7]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85CFxRY031106 for ; Sun, 5 Sep 2004 05:15:59 -0700 Received: from localhost.tpn.ch ([208.2.156.2]) by lotus.znyx.com (Lotus Domino Release 5.0.11) with ESMTP id 2004090505172011:29825 ; Sun, 5 Sep 2004 05:17:20 -0700 Subject: Re: Improvements in FreeBSD 5.3 networking From: jamal Reply-To: hadi@cyberus.ca To: Tomasz Torcz Cc: netdev@oss.sgi.com, "David S. Miller" , Robert Olsson In-Reply-To: <20040905094636.GA10086@irc.pl> References: <20040905094636.GA10086@irc.pl> Organization: jamalopolis Message-Id: <1094386350.1340.6.camel@jzny.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 05 Sep 2004 08:15:25 -0400 X-MIMETrack: Itemize by SMTP Server on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/05/2004 05:17:20 AM, Serialize by Router on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/05/2004 05:17:22 AM, Serialize complete at 09/05/2004 05:17:22 AM Content-Transfer-Encoding: 7bit Content-Type: text/plain X-archive-position: 8421 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hadi@cyberus.ca Precedence: bulk X-list: netdev Guess didnt take too long for those BSDers to post on slashdot. It would be nice for someone to install freebsd and verify the claims on the routing aspect. Anyone in Ottawa with BSD expertise drop me a note - I have access to measurement equipment (and really dont wanna touch BSD if i can avoid it). cheers, jamal PS: We can certainly do better than that on Opterons. Robert reports a 1.3 Mpps rate on a dual opteron 1.6Ghz. Our numbers on Xeons are less than 1Mpps. But we can let an old OS like BSD beat us, can we now ? ;-> On Sun, 2004-09-05 at 05:46, Tomasz Torcz wrote: > Hi, > > reading Slashdot I'm sutmbled upon presentation of FreeBSD new > features: > http://people.freebsd.org/~andre/FreeBSD-5.3-Networking.pdf > > It look pretty interesting (e.g. tcphostcache), especially they claim > that FreeBSD on 2.8 GHz Xeon can route 1Mpps. > > Original slashodt story: > http://bsd.slashdot.org/article.pl?sid=04/09/04/133253 From manfred@colorfullife.com Sun Sep 5 06:10:54 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 06:11:03 -0700 (PDT) Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3] (may be forged)) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85DAoUC032224 for ; Sun, 5 Sep 2004 06:10:51 -0700 Received: from dbl.q-ag.de (dbl [127.0.0.1]) by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i85DAKuG016390; Sun, 5 Sep 2004 15:10:20 +0200 Received: from localhost (manfred@localhost) by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i85DAJSp016386; Sun, 5 Sep 2004 15:10:20 +0200 X-Authentication-Warning: dbl.q-ag.de: manfred owned process doing -bs Date: Sun, 5 Sep 2004 15:10:19 +0200 (CEST) From: Manfred Spraul X-X-Sender: manfred@dbl.q-ag.de To: linux-kernel@vger.kernel.org cc: netdev@oss.sgi.com Subject: [PATCH] backport of forcedeth 0.29 to 2.4 Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-archive-position: 8422 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: manfred@colorfullife.com Precedence: bulk X-list: netdev Hi, attached is as backport of the latest forcedeth driver to 2.4: It adds gigabit ethernet support and lots of bugfixes from the 2.6 driver. The most notable change is gigabit ethernet support and a complete rewrite of the PHY initialization and media detection code. Please test it: It works for me (nForce 250-Gb), but I don't have a non-GigE board to test the media detection. The actual backport was done by Jane Liu: - all occurrences of msleep changed to mdelay - invocations of synchronize_irq changed to take no parameters - SET_NETDEV_DEV calls removed - module_param call changed to MODULE_PARM -- Manfred // Kernel Version: // VERSION = 2 // PATCHLEVEL = 4 // SUBLEVEL = 28 // EXTRAVERSION = -pre2 --- 2.4/drivers/net/forcedeth.c 2004-04-14 15:05:30.000000000 +0200 +++ build-2.4/drivers/net/forcedeth.c 2004-09-05 14:34:44.019230793 +0200 @@ -10,8 +10,11 @@ * trademarks of NVIDIA Corporation in the United States and other * countries. * - * Copyright (C) 2003 Manfred Spraul + * Copyright (C) 2003,4 Manfred Spraul * Copyright (C) 2004 Andrew de Quincey (wol support) + * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane + * IRQ rate fixes, bigendian fixes, cleanups, verification) + * Copyright (c) 2004 NVIDIA Corporation * * 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 @@ -60,15 +63,19 @@ * 0.19: 29 Nov 2003: Handle RxNoBuf, detect & handle invalid mac * addresses, really stop rx if already running * in nv_start_rx, clean up a bit. - * (C) Carl-Daniel Hailfinger * 0.20: 07 Dec 2003: alloc fixes * 0.21: 12 Jan 2004: additional alloc fix, nic polling fix. * 0.22: 19 Jan 2004: reprogram timer to a sane rate, avoid lockup - * on close. - * (C) Carl-Daniel Hailfinger, Manfred Spraul + * on close. * 0.23: 26 Jan 2004: various small cleanups * 0.24: 27 Feb 2004: make driver even less anonymous in backtraces * 0.25: 09 Mar 2004: wol support + * 0.26: 03 Jun 2004: netdriver specific annotation, sparse-related fixes + * 0.27: 19 Jun 2004: Gigabit support, new descriptor rings, + * added CK804/MCP04 device IDs, code fixes + * for registers, link status and other minor fixes. + * 0.28: 21 Jun 2004: Big cleanup, making driver mostly endian safe + * 0.29: 31 Aug 2004: Add backup timer for link change notification. * * Known bugs: * We suspect that on some hardware no TX done interrupts are generated. @@ -80,7 +87,8 @@ * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few * superfluous timer interrupts from the nic. */ -#define FORCEDETH_VERSION "0.25" +#define FORCEDETH_VERSION "0.29" +#define DRV_NAME "forcedeth" #include #include @@ -113,16 +121,18 @@ * Hardware access: */ -#define DEV_NEED_LASTPACKET1 0x0001 -#define DEV_IRQMASK_1 0x0002 -#define DEV_IRQMASK_2 0x0004 -#define DEV_NEED_TIMERIRQ 0x0008 +#define DEV_NEED_LASTPACKET1 0x0001 /* set LASTPACKET1 in tx flags */ +#define DEV_IRQMASK_1 0x0002 /* use NVREG_IRQMASK_WANTED_1 for irq mask */ +#define DEV_IRQMASK_2 0x0004 /* use NVREG_IRQMASK_WANTED_2 for irq mask */ +#define DEV_NEED_TIMERIRQ 0x0008 /* set the timer irq flag in the irq mask */ +#define DEV_NEED_LINKTIMER 0x0010 /* poll link settings. Relies on the timer irq */ enum { NvRegIrqStatus = 0x000, #define NVREG_IRQSTAT_MIIEVENT 0x040 #define NVREG_IRQSTAT_MASK 0x1ff NvRegIrqMask = 0x004, +#define NVREG_IRQ_RX_ERROR 0x0001 #define NVREG_IRQ_RX 0x0002 #define NVREG_IRQ_RX_NOBUF 0x0004 #define NVREG_IRQ_TX_ERR 0x0008 @@ -132,7 +142,7 @@ enum { #define NVREG_IRQ_TX1 0x0100 #define NVREG_IRQMASK_WANTED_1 0x005f #define NVREG_IRQMASK_WANTED_2 0x0147 -#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR|NVREG_IRQ_TX2|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX1)) +#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR|NVREG_IRQ_TX2|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX1)) NvRegUnknownSetupReg6 = 0x008, #define NVREG_UNKSETUP6_VAL 3 @@ -159,7 +169,7 @@ enum { NvRegOffloadConfig = 0x90, #define NVREG_OFFLOAD_HOMEPHY 0x601 -#define NVREG_OFFLOAD_NORMAL 0x5ee +#define NVREG_OFFLOAD_NORMAL RX_NIC_BUFSIZE NvRegReceiverControl = 0x094, #define NVREG_RCVCTL_START 0x01 NvRegReceiverStatus = 0x98, @@ -168,6 +178,8 @@ enum { NvRegRandomSeed = 0x9c, #define NVREG_RNDSEED_MASK 0x00ff #define NVREG_RNDSEED_FORCE 0x7f00 +#define NVREG_RNDSEED_FORCE2 0x2d00 +#define NVREG_RNDSEED_FORCE3 0x7400 NvRegUnknownSetupReg1 = 0xA0, #define NVREG_UNKSETUP1_VAL 0x16070f @@ -181,6 +193,9 @@ enum { NvRegMulticastMaskA = 0xB8, NvRegMulticastMaskB = 0xBC, + NvRegPhyInterface = 0xC0, +#define PHY_RGMII 0x10000000 + NvRegTxRingPhysAddr = 0x100, NvRegRxRingPhysAddr = 0x104, NvRegRingSizes = 0x108, @@ -189,12 +204,12 @@ enum { NvRegUnknownTransmitterReg = 0x10c, NvRegLinkSpeed = 0x110, #define NVREG_LINKSPEED_FORCE 0x10000 -#define NVREG_LINKSPEED_10 10 +#define NVREG_LINKSPEED_10 1000 #define NVREG_LINKSPEED_100 100 -#define NVREG_LINKSPEED_1000 1000 +#define NVREG_LINKSPEED_1000 50 NvRegUnknownSetupReg5 = 0x130, #define NVREG_UNKSETUP5_BIT31 (1<<31) - NvRegUnknownSetupReg3 = 0x134, + NvRegUnknownSetupReg3 = 0x13c, #define NVREG_UNKSETUP3_VAL1 0x200010 NvRegTxRxControl = 0x144, #define NVREG_TXRXCTL_KICK 0x0001 @@ -213,15 +228,15 @@ enum { NvRegAdapterControl = 0x188, #define NVREG_ADAPTCTL_START 0x02 #define NVREG_ADAPTCTL_LINKUP 0x04 -#define NVREG_ADAPTCTL_PHYVALID 0x4000 +#define NVREG_ADAPTCTL_PHYVALID 0x40000 #define NVREG_ADAPTCTL_RUNNING 0x100000 #define NVREG_ADAPTCTL_PHYSHIFT 24 NvRegMIISpeed = 0x18c, #define NVREG_MIISPEED_BIT8 (1<<8) #define NVREG_MIIDELAY 5 NvRegMIIControl = 0x190, -#define NVREG_MIICTL_INUSE 0x10000 -#define NVREG_MIICTL_WRITE 0x08000 +#define NVREG_MIICTL_INUSE 0x08000 +#define NVREG_MIICTL_WRITE 0x00400 #define NVREG_MIICTL_ADDRSHIFT 5 NvRegMIIData = 0x194, NvRegWakeUpFlags = 0x200, @@ -253,34 +268,63 @@ enum { #define NVREG_POWERSTATE_D3 0x0003 }; +/* Big endian: should work, but is untested */ struct ring_desc { u32 PacketBuffer; - u16 Length; - u16 Flags; + u32 FlagLen; }; -#define NV_TX_LASTPACKET (1<<0) -#define NV_TX_RETRYERROR (1<<3) -#define NV_TX_LASTPACKET1 (1<<8) -#define NV_TX_DEFERRED (1<<10) -#define NV_TX_CARRIERLOST (1<<11) -#define NV_TX_LATECOLLISION (1<<12) -#define NV_TX_UNDERFLOW (1<<13) -#define NV_TX_ERROR (1<<14) -#define NV_TX_VALID (1<<15) - -#define NV_RX_DESCRIPTORVALID (1<<0) -#define NV_RX_MISSEDFRAME (1<<1) -#define NV_RX_SUBSTRACT1 (1<<3) -#define NV_RX_ERROR1 (1<<7) -#define NV_RX_ERROR2 (1<<8) -#define NV_RX_ERROR3 (1<<9) -#define NV_RX_ERROR4 (1<<10) -#define NV_RX_CRCERR (1<<11) -#define NV_RX_OVERFLOW (1<<12) -#define NV_RX_FRAMINGERR (1<<13) -#define NV_RX_ERROR (1<<14) -#define NV_RX_AVAIL (1<<15) +#define FLAG_MASK_V1 0xffff0000 +#define FLAG_MASK_V2 0xffffc000 +#define LEN_MASK_V1 (0xffffffff ^ FLAG_MASK_V1) +#define LEN_MASK_V2 (0xffffffff ^ FLAG_MASK_V2) + +#define NV_TX_LASTPACKET (1<<16) +#define NV_TX_RETRYERROR (1<<19) +#define NV_TX_LASTPACKET1 (1<<24) +#define NV_TX_DEFERRED (1<<26) +#define NV_TX_CARRIERLOST (1<<27) +#define NV_TX_LATECOLLISION (1<<28) +#define NV_TX_UNDERFLOW (1<<29) +#define NV_TX_ERROR (1<<30) +#define NV_TX_VALID (1<<31) + +#define NV_TX2_LASTPACKET (1<<29) +#define NV_TX2_RETRYERROR (1<<18) +#define NV_TX2_LASTPACKET1 (1<<23) +#define NV_TX2_DEFERRED (1<<25) +#define NV_TX2_CARRIERLOST (1<<26) +#define NV_TX2_LATECOLLISION (1<<27) +#define NV_TX2_UNDERFLOW (1<<28) +/* error and valid are the same for both */ +#define NV_TX2_ERROR (1<<30) +#define NV_TX2_VALID (1<<31) + +#define NV_RX_DESCRIPTORVALID (1<<16) +#define NV_RX_MISSEDFRAME (1<<17) +#define NV_RX_SUBSTRACT1 (1<<18) +#define NV_RX_ERROR1 (1<<23) +#define NV_RX_ERROR2 (1<<24) +#define NV_RX_ERROR3 (1<<25) +#define NV_RX_ERROR4 (1<<26) +#define NV_RX_CRCERR (1<<27) +#define NV_RX_OVERFLOW (1<<28) +#define NV_RX_FRAMINGERR (1<<29) +#define NV_RX_ERROR (1<<30) +#define NV_RX_AVAIL (1<<31) + +#define NV_RX2_DESCRIPTORVALID (1<<29) +#define NV_RX2_SUBSTRACT1 (1<<25) +#define NV_RX2_ERROR1 (1<<18) +#define NV_RX2_ERROR2 (1<<19) +#define NV_RX2_ERROR3 (1<<20) +#define NV_RX2_ERROR4 (1<<21) +#define NV_RX2_CRCERR (1<<22) +#define NV_RX2_OVERFLOW (1<<23) +#define NV_RX2_FRAMINGERR (1<<24) +/* error and avail are the same for both */ +#define NV_RX2_ERROR (1<<30) +#define NV_RX2_AVAIL (1<<31) /* Miscelaneous hardware related defines: */ #define NV_PCI_REGSZ 0x270 @@ -306,28 +350,67 @@ struct ring_desc { /* General driver defaults */ #define NV_WATCHDOG_TIMEO (5*HZ) -#define DEFAULT_MTU 1500 /* also maximum supported, at least for now */ #define RX_RING 128 -#define TX_RING 16 -/* limited to 1 packet until we understand NV_TX_LASTPACKET */ -#define TX_LIMIT_STOP 10 -#define TX_LIMIT_START 5 +#define TX_RING 64 +/* + * If your nic mysteriously hangs then try to reduce the limits + * to 1/0: It might be required to set NV_TX_LASTPACKET in the + * last valid ring entry. But this would be impossible to + * implement - probably a disassembly error. + */ +#define TX_LIMIT_STOP 63 +#define TX_LIMIT_START 62 /* rx/tx mac addr + type + vlan + align + slack*/ -#define RX_NIC_BUFSIZE (DEFAULT_MTU + 64) +#define RX_NIC_BUFSIZE (ETH_DATA_LEN + 64) /* even more slack */ -#define RX_ALLOC_BUFSIZE (DEFAULT_MTU + 128) +#define RX_ALLOC_BUFSIZE (ETH_DATA_LEN + 128) #define OOM_REFILL (1+HZ/20) #define POLL_WAIT (1+HZ/100) +#define LINK_TIMEOUT (3*HZ) + +#define DESC_VER_1 0x0 +#define DESC_VER_2 0x02100 + +/* PHY defines */ +#define PHY_OUI_MARVELL 0x5043 +#define PHY_OUI_CICADA 0x03f1 +#define PHYID1_OUI_MASK 0x03ff +#define PHYID1_OUI_SHFT 6 +#define PHYID2_OUI_MASK 0xfc00 +#define PHYID2_OUI_SHFT 10 +#define PHY_INIT1 0x0f000 +#define PHY_INIT2 0x0e00 +#define PHY_INIT3 0x01000 +#define PHY_INIT4 0x0200 +#define PHY_INIT5 0x0004 +#define PHY_INIT6 0x02000 +#define PHY_GIGABIT 0x0100 + +#define PHY_TIMEOUT 0x1 +#define PHY_ERROR 0x2 + +#define PHY_100 0x1 +#define PHY_1000 0x2 +#define PHY_HALF 0x100 + +/* FIXME: MII defines that should be added to */ +#define MII_1000BT_CR 0x09 +#define MII_1000BT_SR 0x0a +#define ADVERTISE_1000FULL 0x0200 +#define ADVERTISE_1000HALF 0x0100 +#define LPA_1000FULL 0x0800 +#define LPA_1000HALF 0x0400 + /* * SMP locking: * All hardware access under dev->priv->lock, except the performance * critical parts: * - rx is (pseudo-) lockless: it relies on the single-threading provided - * by the arch code for interrupts. + * by the arch code for interrupts. * - tx setup is lockless: it relies on dev->xmit_lock. Actual submission * needs dev->priv->lock :-( * - set_multicast_list: preparation lockless, relies on dev->xmit_lock. @@ -345,12 +428,15 @@ struct fe_priv { int duplex; int phyaddr; int wolenabled; + unsigned int phy_oui; + u16 gigabit; /* General data: RO fields */ dma_addr_t ring_addr; struct pci_dev *pci_dev; u32 orig_mac[2]; u32 irqmask; + u32 desc_ver; /* rx specific fields. * Locking: Within irq hander or disable_irq+spin_lock(&np->lock); @@ -363,6 +449,11 @@ struct fe_priv { struct timer_list oom_kick; struct timer_list nic_poll; + /* media detection workaround. + * Locking: Within irq hander or disable_irq+spin_lock(&np->lock); + */ + int need_linktimer; + unsigned long link_timeout; /* * tx specific fields. */ @@ -370,7 +461,7 @@ struct fe_priv { unsigned int next_tx, nic_tx; struct sk_buff *tx_skbuff[TX_RING]; dma_addr_t tx_dma[TX_RING]; - u16 tx_flags; + u32 tx_flags; }; /* @@ -395,6 +486,12 @@ static inline void pci_push(u8 * base) readl(base); } +static inline u32 nv_descr_getlength(struct ring_desc *prd, u32 v) +{ + return le32_to_cpu(prd->FlagLen) + & ((v == DESC_VER_1) ? LEN_MASK_V1 : LEN_MASK_V2); +} + static int reg_delay(struct net_device *dev, int offset, u32 mask, u32 target, int delay, int delaymax, const char *msg) { @@ -421,24 +518,18 @@ static int reg_delay(struct net_device * static int mii_rw(struct net_device *dev, int addr, int miireg, int value) { u8 *base = get_hwbase(dev); - int was_running; u32 reg; int retval; writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus); - was_running = 0; - reg = readl(base + NvRegAdapterControl); - if (reg & NVREG_ADAPTCTL_RUNNING) { - was_running = 1; - writel(reg & ~NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl); - } + reg = readl(base + NvRegMIIControl); if (reg & NVREG_MIICTL_INUSE) { writel(NVREG_MIICTL_INUSE, base + NvRegMIIControl); udelay(NV_MIIBUSY_DELAY); } - reg = NVREG_MIICTL_INUSE | (addr << NVREG_MIICTL_ADDRSHIFT) | miireg; + reg = (addr << NVREG_MIICTL_ADDRSHIFT) | miireg; if (value != MII_READ) { writel(value, base + NvRegMIIData); reg |= NVREG_MIICTL_WRITE; @@ -460,19 +551,117 @@ static int mii_rw(struct net_device *dev dev->name, miireg, addr); retval = -1; } else { - /* FIXME: why is that required? */ - udelay(50); retval = readl(base + NvRegMIIData); dprintk(KERN_DEBUG "%s: mii_rw read from reg %d at PHY %d: 0x%x.\n", dev->name, miireg, addr, retval); } - if (was_running) { - reg = readl(base + NvRegAdapterControl); - writel(reg | NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl); - } + return retval; } +static int phy_reset(struct net_device *dev) +{ + struct fe_priv *np = get_nvpriv(dev); + u32 miicontrol; + unsigned int tries = 0; + + miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); + miicontrol |= BMCR_RESET; + if (mii_rw(dev, np->phyaddr, MII_BMCR, miicontrol)) { + return -1; + } + + /* wait for 500ms */ + mdelay(500); + + /* must wait till reset is deasserted */ + while (miicontrol & BMCR_RESET) { + mdelay(10); + miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); + /* FIXME: 100 tries seem excessive */ + if (tries++ > 100) + return -1; + } + return 0; +} + +static int phy_init(struct net_device *dev) +{ + struct fe_priv *np = get_nvpriv(dev); + u8 *base = get_hwbase(dev); + u32 phyinterface, phy_reserved, mii_status, mii_control, mii_control_1000,reg; + + /* set advertise register */ + reg = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); + reg |= (ADVERTISE_10HALF|ADVERTISE_10FULL|ADVERTISE_100HALF|ADVERTISE_100FULL|0x800|0x400); + if (mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg)) { + printk(KERN_INFO "%s: phy write to advertise failed.\n", pci_name(np->pci_dev)); + return PHY_ERROR; + } + + /* get phy interface type */ + phyinterface = readl(base + NvRegPhyInterface); + + /* see if gigabit phy */ + mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ); + if (mii_status & PHY_GIGABIT) { + np->gigabit = PHY_GIGABIT; + mii_control_1000 = mii_rw(dev, np->phyaddr, MII_1000BT_CR, MII_READ); + mii_control_1000 &= ~ADVERTISE_1000HALF; + if (phyinterface & PHY_RGMII) + mii_control_1000 |= ADVERTISE_1000FULL; + else + mii_control_1000 &= ~ADVERTISE_1000FULL; + + if (mii_rw(dev, np->phyaddr, MII_1000BT_CR, mii_control_1000)) { + printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); + return PHY_ERROR; + } + } + else + np->gigabit = 0; + + /* reset the phy */ + if (phy_reset(dev)) { + printk(KERN_INFO "%s: phy reset failed\n", pci_name(np->pci_dev)); + return PHY_ERROR; + } + + /* phy vendor specific configuration */ + if ((np->phy_oui == PHY_OUI_CICADA) && (phyinterface & PHY_RGMII) ) { + phy_reserved = mii_rw(dev, np->phyaddr, MII_RESV1, MII_READ); + phy_reserved &= ~(PHY_INIT1 | PHY_INIT2); + phy_reserved |= (PHY_INIT3 | PHY_INIT4); + if (mii_rw(dev, np->phyaddr, MII_RESV1, phy_reserved)) { + printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); + return PHY_ERROR; + } + phy_reserved = mii_rw(dev, np->phyaddr, MII_NCONFIG, MII_READ); + phy_reserved |= PHY_INIT5; + if (mii_rw(dev, np->phyaddr, MII_NCONFIG, phy_reserved)) { + printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); + return PHY_ERROR; + } + } + if (np->phy_oui == PHY_OUI_CICADA) { + phy_reserved = mii_rw(dev, np->phyaddr, MII_SREVISION, MII_READ); + phy_reserved |= PHY_INIT6; + if (mii_rw(dev, np->phyaddr, MII_SREVISION, phy_reserved)) { + printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); + return PHY_ERROR; + } + } + + /* restart auto negotiation */ + mii_control = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); + mii_control |= (BMCR_ANRESTART | BMCR_ANENABLE); + if (mii_rw(dev, np->phyaddr, MII_BMCR, mii_control)) { + return PHY_ERROR; + } + + return 0; +} + static void nv_start_rx(struct net_device *dev) { struct fe_priv *np = get_nvpriv(dev); @@ -487,6 +676,8 @@ static void nv_start_rx(struct net_devic writel(np->linkspeed, base + NvRegLinkSpeed); pci_push(base); writel(NVREG_RCVCTL_START, base + NvRegReceiverControl); + dprintk(KERN_DEBUG "%s: nv_start_rx to duplex %d, speed 0x%08x.\n", + dev->name, np->duplex, np->linkspeed); pci_push(base); } @@ -497,8 +688,8 @@ static void nv_stop_rx(struct net_device dprintk(KERN_DEBUG "%s: nv_stop_rx\n", dev->name); writel(0, base + NvRegReceiverControl); reg_delay(dev, NvRegReceiverStatus, NVREG_RCVSTAT_BUSY, 0, - NV_RXSTOP_DELAY1, NV_RXSTOP_DELAY1MAX, - KERN_INFO "nv_stop_rx: ReceiverStatus remained busy"); + NV_RXSTOP_DELAY1, NV_RXSTOP_DELAY1MAX, + KERN_INFO "nv_stop_rx: ReceiverStatus remained busy"); udelay(NV_RXSTOP_DELAY2); writel(0, base + NvRegLinkSpeed); @@ -520,8 +711,8 @@ static void nv_stop_tx(struct net_device dprintk(KERN_DEBUG "%s: nv_stop_tx\n", dev->name); writel(0, base + NvRegTransmitterControl); reg_delay(dev, NvRegTransmitterStatus, NVREG_XMITSTAT_BUSY, 0, - NV_TXSTOP_DELAY1, NV_TXSTOP_DELAY1MAX, - KERN_INFO "nv_stop_tx: TransmitterStatus remained busy"); + NV_TXSTOP_DELAY1, NV_TXSTOP_DELAY1MAX, + KERN_INFO "nv_stop_tx: TransmitterStatus remained busy"); udelay(NV_TXSTOP_DELAY2); writel(0, base + NvRegUnknownTransmitterReg); @@ -529,13 +720,14 @@ static void nv_stop_tx(struct net_device static void nv_txrx_reset(struct net_device *dev) { + struct fe_priv *np = get_nvpriv(dev); u8 *base = get_hwbase(dev); dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name); - writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET, base + NvRegTxRxControl); + writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->desc_ver, base + NvRegTxRxControl); pci_push(base); udelay(NV_TXRX_RESET_DELAY); - writel(NVREG_TXRXCTL_BIT2, base + NvRegTxRxControl); + writel(NVREG_TXRXCTL_BIT2 | np->desc_ver, base + NvRegTxRxControl); pci_push(base); } @@ -556,7 +748,7 @@ static struct net_device_stats *nv_get_s return &np->stats; } -static int nv_ethtool_ioctl(struct net_device *dev, void *useraddr) +static int nv_ethtool_ioctl(struct net_device *dev, void __user *useraddr) { struct fe_priv *np = get_nvpriv(dev); u8 *base = get_hwbase(dev); @@ -634,7 +826,7 @@ static int nv_ioctl(struct net_device *d { switch(cmd) { case SIOCETHTOOL: - return nv_ethtool_ioctl(dev, (void *) rq->ifr_data); + return nv_ethtool_ioctl(dev, rq->ifr_data); default: return -EOPNOTSUPP; @@ -650,11 +842,12 @@ static int nv_alloc_rx(struct net_device { struct fe_priv *np = get_nvpriv(dev); unsigned int refill_rx = np->refill_rx; + int nr; while (np->cur_rx != refill_rx) { - int nr = refill_rx % RX_RING; struct sk_buff *skb; + nr = refill_rx % RX_RING; if (np->rx_skbuff[nr] == NULL) { skb = dev_alloc_skb(RX_ALLOC_BUFSIZE); @@ -669,10 +862,9 @@ static int nv_alloc_rx(struct net_device np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len, PCI_DMA_FROMDEVICE); np->rx_ring[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]); - np->rx_ring[nr].Length = cpu_to_le16(RX_NIC_BUFSIZE); wmb(); - np->rx_ring[nr].Flags = cpu_to_le16(NV_RX_AVAIL); - dprintk(KERN_DEBUG "%s: nv_alloc_rx: Packet %d marked as Available\n", + np->rx_ring[nr].FlagLen = cpu_to_le32(RX_NIC_BUFSIZE | NV_RX_AVAIL); + dprintk(KERN_DEBUG "%s: nv_alloc_rx: Packet %d marked as Available\n", dev->name, refill_rx); refill_rx++; } @@ -703,15 +895,13 @@ static int nv_init_ring(struct net_devic int i; np->next_tx = np->nic_tx = 0; - for (i = 0; i < TX_RING; i++) { - np->tx_ring[i].Flags = 0; - } + for (i = 0; i < TX_RING; i++) + np->tx_ring[i].FlagLen = 0; np->cur_rx = RX_RING; np->refill_rx = 0; - for (i = 0; i < RX_RING; i++) { - np->rx_ring[i].Flags = 0; - } + for (i = 0; i < RX_RING; i++) + np->rx_ring[i].FlagLen = 0; return nv_alloc_rx(dev); } @@ -720,7 +910,7 @@ static void nv_drain_tx(struct net_devic struct fe_priv *np = get_nvpriv(dev); int i; for (i = 0; i < TX_RING; i++) { - np->tx_ring[i].Flags = 0; + np->tx_ring[i].FlagLen = 0; if (np->tx_skbuff[i]) { pci_unmap_single(np->pci_dev, np->tx_dma[i], np->tx_skbuff[i]->len, @@ -737,7 +927,7 @@ static void nv_drain_rx(struct net_devic struct fe_priv *np = get_nvpriv(dev); int i; for (i = 0; i < RX_RING; i++) { - np->rx_ring[i].Flags = 0; + np->rx_ring[i].FlagLen = 0; wmb(); if (np->rx_skbuff[i]) { pci_unmap_single(np->pci_dev, np->rx_dma[i], @@ -769,11 +959,10 @@ static int nv_start_xmit(struct sk_buff PCI_DMA_TODEVICE); np->tx_ring[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]); - np->tx_ring[nr].Length = cpu_to_le16(skb->len-1); spin_lock_irq(&np->lock); wmb(); - np->tx_ring[nr].Flags = np->tx_flags; + np->tx_ring[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags ); dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission.\n", dev->name, np->next_tx); { @@ -792,7 +981,7 @@ static int nv_start_xmit(struct sk_buff if (np->next_tx - np->nic_tx >= TX_LIMIT_STOP) netif_stop_queue(dev); spin_unlock_irq(&np->lock); - writel(NVREG_TXRXCTL_KICK, get_hwbase(dev) + NvRegTxRxControl); + writel(NVREG_TXRXCTL_KICK|np->desc_ver, get_hwbase(dev) + NvRegTxRxControl); pci_push(get_hwbase(dev)); return 0; } @@ -805,27 +994,42 @@ static int nv_start_xmit(struct sk_buff static void nv_tx_done(struct net_device *dev) { struct fe_priv *np = get_nvpriv(dev); + u32 Flags; + int i; - while (np->nic_tx < np->next_tx) { - struct ring_desc *prd; - int i = np->nic_tx % TX_RING; + while (np->nic_tx != np->next_tx) { + i = np->nic_tx % TX_RING; - prd = &np->tx_ring[i]; + Flags = le32_to_cpu(np->tx_ring[i].FlagLen); dprintk(KERN_DEBUG "%s: nv_tx_done: looking at packet %d, Flags 0x%x.\n", - dev->name, np->nic_tx, prd->Flags); - if (prd->Flags & cpu_to_le16(NV_TX_VALID)) + dev->name, np->nic_tx, Flags); + if (Flags & NV_TX_VALID) break; - if (prd->Flags & cpu_to_le16(NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION| - NV_TX_UNDERFLOW|NV_TX_ERROR)) { - if (prd->Flags & cpu_to_le16(NV_TX_UNDERFLOW)) - np->stats.tx_fifo_errors++; - if (prd->Flags & cpu_to_le16(NV_TX_CARRIERLOST)) - np->stats.tx_carrier_errors++; - np->stats.tx_errors++; + if (np->desc_ver == DESC_VER_1) { + if (Flags & (NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION| + NV_TX_UNDERFLOW|NV_TX_ERROR)) { + if (Flags & NV_TX_UNDERFLOW) + np->stats.tx_fifo_errors++; + if (Flags & NV_TX_CARRIERLOST) + np->stats.tx_carrier_errors++; + np->stats.tx_errors++; + } else { + np->stats.tx_packets++; + np->stats.tx_bytes += np->tx_skbuff[i]->len; + } } else { - np->stats.tx_packets++; - np->stats.tx_bytes += np->tx_skbuff[i]->len; + if (Flags & (NV_TX2_RETRYERROR|NV_TX2_CARRIERLOST|NV_TX2_LATECOLLISION| + NV_TX2_UNDERFLOW|NV_TX2_ERROR)) { + if (Flags & NV_TX2_UNDERFLOW) + np->stats.tx_fifo_errors++; + if (Flags & NV_TX2_CARRIERLOST) + np->stats.tx_carrier_errors++; + np->stats.tx_errors++; + } else { + np->stats.tx_packets++; + np->stats.tx_bytes += np->tx_skbuff[i]->len; + } } pci_unmap_single(np->pci_dev, np->tx_dma[i], np->tx_skbuff[i]->len, @@ -875,9 +1079,9 @@ static void nv_tx_timeout(struct net_dev static void nv_rx_process(struct net_device *dev) { struct fe_priv *np = get_nvpriv(dev); + u32 Flags; for (;;) { - struct ring_desc *prd; struct sk_buff *skb; int len; int i; @@ -885,11 +1089,13 @@ static void nv_rx_process(struct net_dev break; /* we scanned the whole ring - do not continue */ i = np->cur_rx % RX_RING; - prd = &np->rx_ring[i]; + Flags = le32_to_cpu(np->rx_ring[i].FlagLen); + len = nv_descr_getlength(&np->rx_ring[i], np->desc_ver); + dprintk(KERN_DEBUG "%s: nv_rx_process: looking at packet %d, Flags 0x%x.\n", - dev->name, np->cur_rx, prd->Flags); + dev->name, np->cur_rx, Flags); - if (prd->Flags & cpu_to_le16(NV_RX_AVAIL)) + if (Flags & NV_RX_AVAIL) break; /* still owned by hardware, */ /* @@ -903,7 +1109,7 @@ static void nv_rx_process(struct net_dev { int j; - dprintk(KERN_DEBUG "Dumping packet (flags 0x%x).",prd->Flags); + dprintk(KERN_DEBUG "Dumping packet (flags 0x%x).",Flags); for (j=0; j<64; j++) { if ((j%16) == 0) dprintk("\n%03x:", j); @@ -912,41 +1118,69 @@ static void nv_rx_process(struct net_dev dprintk("\n"); } /* look at what we actually got: */ - if (!(prd->Flags & cpu_to_le16(NV_RX_DESCRIPTORVALID))) - goto next_pkt; - - - len = le16_to_cpu(prd->Length); + if (np->desc_ver == DESC_VER_1) { + if (!(Flags & NV_RX_DESCRIPTORVALID)) + goto next_pkt; - if (prd->Flags & cpu_to_le16(NV_RX_MISSEDFRAME)) { - np->stats.rx_missed_errors++; - np->stats.rx_errors++; - goto next_pkt; - } - if (prd->Flags & cpu_to_le16(NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3|NV_RX_ERROR4)) { - np->stats.rx_errors++; - goto next_pkt; - } - if (prd->Flags & cpu_to_le16(NV_RX_CRCERR)) { - np->stats.rx_crc_errors++; - np->stats.rx_errors++; - goto next_pkt; - } - if (prd->Flags & cpu_to_le16(NV_RX_OVERFLOW)) { - np->stats.rx_over_errors++; - np->stats.rx_errors++; - goto next_pkt; - } - if (prd->Flags & cpu_to_le16(NV_RX_ERROR)) { - /* framing errors are soft errors, the rest is fatal. */ - if (prd->Flags & cpu_to_le16(NV_RX_FRAMINGERR)) { - if (prd->Flags & cpu_to_le16(NV_RX_SUBSTRACT1)) { - len--; + if (Flags & NV_RX_MISSEDFRAME) { + np->stats.rx_missed_errors++; + np->stats.rx_errors++; + goto next_pkt; + } + if (Flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3|NV_RX_ERROR4)) { + np->stats.rx_errors++; + goto next_pkt; + } + if (Flags & NV_RX_CRCERR) { + np->stats.rx_crc_errors++; + np->stats.rx_errors++; + goto next_pkt; + } + if (Flags & NV_RX_OVERFLOW) { + np->stats.rx_over_errors++; + np->stats.rx_errors++; + goto next_pkt; + } + if (Flags & NV_RX_ERROR) { + /* framing errors are soft errors, the rest is fatal. */ + if (Flags & NV_RX_FRAMINGERR) { + if (Flags & NV_RX_SUBSTRACT1) { + len--; + } + } else { + np->stats.rx_errors++; + goto next_pkt; } - } else { + } + } else { + if (!(Flags & NV_RX2_DESCRIPTORVALID)) + goto next_pkt; + + if (Flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3|NV_RX2_ERROR4)) { + np->stats.rx_errors++; + goto next_pkt; + } + if (Flags & NV_RX2_CRCERR) { + np->stats.rx_crc_errors++; np->stats.rx_errors++; goto next_pkt; } + if (Flags & NV_RX2_OVERFLOW) { + np->stats.rx_over_errors++; + np->stats.rx_errors++; + goto next_pkt; + } + if (Flags & NV_RX2_ERROR) { + /* framing errors are soft errors, the rest is fatal. */ + if (Flags & NV_RX2_FRAMINGERR) { + if (Flags & NV_RX2_SUBSTRACT1) { + len--; + } + } else { + np->stats.rx_errors++; + goto next_pkt; + } + } } /* got a valid packet - forward it to the network core */ skb = np->rx_skbuff[i]; @@ -971,7 +1205,7 @@ next_pkt: */ static int nv_change_mtu(struct net_device *dev, int new_mtu) { - if (new_mtu > DEFAULT_MTU) + if (new_mtu > ETH_DATA_LEN) return -EINVAL; dev->mtu = new_mtu; return 0; @@ -1035,6 +1269,8 @@ static void nv_set_multicast(struct net_ writel(mask[0], base + NvRegMulticastMaskA); writel(mask[1], base + NvRegMulticastMaskB); writel(pff, base + NvRegPacketFilterFlags); + dprintk(KERN_INFO "%s: reconfiguration for multicast lists.\n", + dev->name); nv_start_rx(dev); spin_unlock_irq(&np->lock); } @@ -1042,16 +1278,62 @@ static void nv_set_multicast(struct net_ static int nv_update_linkspeed(struct net_device *dev) { struct fe_priv *np = get_nvpriv(dev); - int adv, lpa, newls, newdup; + u8 *base = get_hwbase(dev); + int adv, lpa; + int newls = np->linkspeed; + int newdup = np->duplex; + int mii_status; + int retval = 0; + u32 control_1000, status_1000, phyreg; + + /* BMSR_LSTATUS is latched, read it twice: + * we want the current value. + */ + mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ); + mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ); + + if (!(mii_status & BMSR_LSTATUS)) { + dprintk(KERN_DEBUG "%s: no link detected by phy - falling back to 10HD.\n", + dev->name); + newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; + newdup = 0; + retval = 0; + goto set_speed; + } + + /* check auto negotiation is complete */ + if (!(mii_status & BMSR_ANEGCOMPLETE)) { + /* still in autonegotiation - configure nic for 10 MBit HD and wait. */ + newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; + newdup = 0; + retval = 0; + dprintk(KERN_DEBUG "%s: autoneg not completed - falling back to 10HD.\n", dev->name); + goto set_speed; + } + + retval = 1; + if (np->gigabit == PHY_GIGABIT) { + control_1000 = mii_rw(dev, np->phyaddr, MII_1000BT_CR, MII_READ); + status_1000 = mii_rw(dev, np->phyaddr, MII_1000BT_SR, MII_READ); + + if ((control_1000 & ADVERTISE_1000FULL) && + (status_1000 & LPA_1000FULL)) { + dprintk(KERN_DEBUG "%s: nv_update_linkspeed: GBit ethernet detected.\n", + dev->name); + newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_1000; + newdup = 1; + goto set_speed; + } + } adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); lpa = mii_rw(dev, np->phyaddr, MII_LPA, MII_READ); dprintk(KERN_DEBUG "%s: nv_update_linkspeed: PHY advertises 0x%04x, lpa 0x%04x.\n", dev->name, adv, lpa); - /* FIXME: handle parallel detection properly, handle gigabit ethernet */ + /* FIXME: handle parallel detection properly */ lpa = lpa & adv; - if (lpa & LPA_100FULL) { + if (lpa & LPA_100FULL) { newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100; newdup = 1; } else if (lpa & LPA_100HALF) { @@ -1068,37 +1350,57 @@ static int nv_update_linkspeed(struct ne newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; newdup = 0; } - if (np->duplex != newdup || np->linkspeed != newls) { - np->duplex = newdup; - np->linkspeed = newls; - return 1; - } - return 0; -} -static void nv_link_irq(struct net_device *dev) -{ - struct fe_priv *np = get_nvpriv(dev); - u8 *base = get_hwbase(dev); - u32 miistat; - int miival; +set_speed: + if (np->duplex == newdup && np->linkspeed == newls) + return retval; + + dprintk(KERN_INFO "%s: changing link setting from %d/%d to %d/%d.\n", + dev->name, np->linkspeed, np->duplex, newls, newdup); + + np->duplex = newdup; + np->linkspeed = newls; + + if (np->gigabit == PHY_GIGABIT) { + phyreg = readl(base + NvRegRandomSeed); + phyreg &= ~(0x3FF00); + if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_10) + phyreg |= NVREG_RNDSEED_FORCE3; + else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_100) + phyreg |= NVREG_RNDSEED_FORCE2; + else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_1000) + phyreg |= NVREG_RNDSEED_FORCE; + writel(phyreg, base + NvRegRandomSeed); + } + + phyreg = readl(base + NvRegPhyInterface); + phyreg &= ~(PHY_HALF|PHY_100|PHY_1000); + if (np->duplex == 0) + phyreg |= PHY_HALF; + if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_100) + phyreg |= PHY_100; + else if ((np->linkspeed & 0xFFF) == NVREG_LINKSPEED_1000) + phyreg |= PHY_1000; + writel(phyreg, base + NvRegPhyInterface); - miistat = readl(base + NvRegMIIStatus); - writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus); - printk(KERN_DEBUG "%s: link change notification, status 0x%x.\n", dev->name, miistat); + writel(NVREG_MISC1_FORCE | ( np->duplex ? 0 : NVREG_MISC1_HD), + base + NvRegMisc1); + pci_push(base); + writel(np->linkspeed, base + NvRegLinkSpeed); + pci_push(base); - miival = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ); - if (miival & BMSR_ANEGCOMPLETE) { - nv_update_linkspeed(dev); + return retval; +} +static void nv_linkchange(struct net_device *dev) +{ + if (nv_update_linkspeed(dev)) { if (netif_carrier_ok(dev)) { nv_stop_rx(dev); } else { netif_carrier_on(dev); printk(KERN_INFO "%s: link up.\n", dev->name); } - writel(NVREG_MISC1_FORCE | ( np->duplex ? 0 : NVREG_MISC1_HD), - base + NvRegMisc1); nv_start_rx(dev); } else { if (netif_carrier_ok(dev)) { @@ -1106,11 +1408,23 @@ static void nv_link_irq(struct net_devic printk(KERN_INFO "%s: link down.\n", dev->name); nv_stop_rx(dev); } - writel(np->linkspeed, base + NvRegLinkSpeed); - pci_push(base); } } +static void nv_link_irq(struct net_device *dev) +{ + u8 *base = get_hwbase(dev); + u32 miistat; + + miistat = readl(base + NvRegMIIStatus); + writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus); + dprintk(KERN_INFO "%s: link change irq, status 0x%x.\n", dev->name, miistat); + + if (miistat & (NVREG_MIISTAT_LINKCHANGE)) + nv_linkchange(dev); + dprintk(KERN_DEBUG "%s: link change notification done.\n", dev->name); +} + static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs) { struct net_device *dev = (struct net_device *) data; @@ -1135,7 +1449,7 @@ static irqreturn_t nv_nic_irq(int foo, v spin_unlock(&np->lock); } - if (events & (NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF)) { + if (events & (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF)) { nv_rx_process(dev); if (nv_alloc_rx(dev)) { spin_lock(&np->lock); @@ -1150,6 +1464,12 @@ static irqreturn_t nv_nic_irq(int foo, v nv_link_irq(dev); spin_unlock(&np->lock); } + if (np->need_linktimer && time_after(jiffies, np->link_timeout)) { + spin_lock(&np->lock); + nv_linkchange(dev); + spin_unlock(&np->lock); + np->link_timeout = jiffies + LINK_TIMEOUT; + } if (events & (NVREG_IRQ_TX_ERR)) { dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n", dev->name, events); @@ -1157,7 +1477,7 @@ static irqreturn_t nv_nic_irq(int foo, v if (events & (NVREG_IRQ_UNKNOWN)) { printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n", dev->name, events); - } + } if (i > max_interrupt_work) { spin_lock(&np->lock); /* disable interrupts on the nic */ @@ -1210,21 +1530,27 @@ static int nv_open(struct net_device *de writel(0, base + NvRegMulticastMaskA); writel(0, base + NvRegMulticastMaskB); writel(0, base + NvRegPacketFilterFlags); + + writel(0, base + NvRegTransmitterControl); + writel(0, base + NvRegReceiverControl); + writel(0, base + NvRegAdapterControl); + + /* 2) initialize descriptor rings */ + oom = nv_init_ring(dev); + writel(0, base + NvRegLinkSpeed); writel(0, base + NvRegUnknownTransmitterReg); nv_txrx_reset(dev); writel(0, base + NvRegUnknownSetupReg6); - /* 2) initialize descriptor rings */ np->in_shutdown = 0; - oom = nv_init_ring(dev); /* 3) set mac address */ { u32 mac[2]; - mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) + + mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) + (dev->dev_addr[2] << 16) + (dev->dev_addr[3] << 24); mac[1] = (dev->dev_addr[4] << 0) + (dev->dev_addr[5] << 8); @@ -1232,53 +1558,31 @@ static int nv_open(struct net_device *de writel(mac[1], base + NvRegMacAddrB); } - /* 4) continue setup */ + /* 4) give hw rings */ + writel((u32) np->ring_addr, base + NvRegRxRingPhysAddr); + writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr); + writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT), + base + NvRegRingSizes); + + /* 5) continue setup */ np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; np->duplex = 0; + + writel(np->linkspeed, base + NvRegLinkSpeed); writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3); - writel(0, base + NvRegTxRxControl); + writel(np->desc_ver, base + NvRegTxRxControl); pci_push(base); - writel(NVREG_TXRXCTL_BIT1, base + NvRegTxRxControl); + writel(NVREG_TXRXCTL_BIT1|np->desc_ver, base + NvRegTxRxControl); reg_delay(dev, NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP5_BIT31, NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX, KERN_INFO "open: SetupReg5, Bit 31 remained off\n"); - writel(0, base + NvRegUnknownSetupReg4); - - /* 5) Find a suitable PHY */ - writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed); - for (i = 1; i < 32; i++) { - int id1, id2; - - spin_lock_irq(&np->lock); - id1 = mii_rw(dev, i, MII_PHYSID1, MII_READ); - spin_unlock_irq(&np->lock); - if (id1 < 0 || id1 == 0xffff) - continue; - spin_lock_irq(&np->lock); - id2 = mii_rw(dev, i, MII_PHYSID2, MII_READ); - spin_unlock_irq(&np->lock); - if (id2 < 0 || id2 == 0xffff) - continue; - dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n", - dev->name, id1, id2, i); - np->phyaddr = i; - - spin_lock_irq(&np->lock); - nv_update_linkspeed(dev); - spin_unlock_irq(&np->lock); - break; - } - if (i == 32) { - printk(KERN_INFO "%s: open: failing due to lack of suitable PHY.\n", - dev->name); - ret = -EINVAL; - goto out_drain; - } + writel(0, base + NvRegUnknownSetupReg4); + writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); + writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus); /* 6) continue setup */ - writel(NVREG_MISC1_FORCE | ( np->duplex ? 0 : NVREG_MISC1_HD), - base + NvRegMisc1); + writel(NVREG_MISC1_FORCE | NVREG_MISC1_HD, base + NvRegMisc1); writel(readl(base + NvRegTransmitterStatus), base + NvRegTransmitterStatus); writel(NVREG_PFF_ALWAYS, base + NvRegPacketFilterFlags); writel(NVREG_OFFLOAD_NORMAL, base + NvRegOffloadConfig); @@ -1290,17 +1594,12 @@ static int nv_open(struct net_device *de writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2); writel(NVREG_POLL_DEFAULT, base + NvRegPollingInterval); writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6); - writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID, + writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl); + writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed); writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4); writel(NVREG_WAKEUPFLAGS_VAL, base + NvRegWakeUpFlags); - /* 7) start packet processing */ - writel((u32) np->ring_addr, base + NvRegRxRingPhysAddr); - writel((u32) (np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr); - writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT), - base + NvRegRingSizes); - i = readl(base + NvRegPowerState); if ( (i & NVREG_POWERSTATE_POWEREDUP) == 0) writel(NVREG_POWERSTATE_POWEREDUP|i, base + NvRegPowerState); @@ -1308,13 +1607,9 @@ static int nv_open(struct net_device *de pci_push(base); udelay(10); writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID, base + NvRegPowerState); - writel(NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl); - writel(0, base + NvRegIrqMask); pci_push(base); - writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); - pci_push(base); writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus); writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); pci_push(base); @@ -1323,6 +1618,7 @@ static int nv_open(struct net_device *de if (ret) goto out_drain; + /* ask for interrupts */ writel(np->irqmask, base + NvRegIrqMask); spin_lock_irq(&np->lock); @@ -1331,18 +1627,27 @@ static int nv_open(struct net_device *de writel(0, base + NvRegMulticastMaskA); writel(0, base + NvRegMulticastMaskB); writel(NVREG_PFF_ALWAYS|NVREG_PFF_MYADDR, base + NvRegPacketFilterFlags); + /* One manual link speed update: Interrupts are enabled, future link + * speed changes cause interrupts and are handled by nv_link_irq(). + */ + { + u32 miistat; + miistat = readl(base + NvRegMIIStatus); + writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus); + dprintk(KERN_INFO "startup: got 0x%08x.\n", miistat); + } + ret = nv_update_linkspeed(dev); nv_start_rx(dev); nv_start_tx(dev); netif_start_queue(dev); - if (oom) - mod_timer(&np->oom_kick, jiffies + OOM_REFILL); - if (mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ) & BMSR_ANEGCOMPLETE) { + if (ret) { netif_carrier_on(dev); } else { printk("%s: no link during initialization.\n", dev->name); netif_carrier_off(dev); } - + if (oom) + mod_timer(&np->oom_kick, jiffies + OOM_REFILL); spin_unlock_irq(&np->lock); return 0; @@ -1406,7 +1711,6 @@ static int __devinit nv_probe(struct pci np->pci_dev = pci_dev; spin_lock_init(&np->lock); SET_MODULE_OWNER(dev); - SET_NETDEV_DEV(dev, &pci_dev->dev); init_timer(&np->oom_kick); np->oom_kick.data = (unsigned long) dev; @@ -1424,7 +1728,7 @@ static int __devinit nv_probe(struct pci pci_set_master(pci_dev); - err = pci_request_regions(pci_dev, dev->name); + err = pci_request_regions(pci_dev, DRV_NAME); if (err < 0) goto out_disable; @@ -1447,6 +1751,14 @@ static int __devinit nv_probe(struct pci goto out_relreg; } + /* handle different descriptor versions */ + if (pci_dev->device == PCI_DEVICE_ID_NVIDIA_NVENET_1 || + pci_dev->device == PCI_DEVICE_ID_NVIDIA_NVENET_2 || + pci_dev->device == PCI_DEVICE_ID_NVIDIA_NVENET_3) + np->desc_ver = DESC_VER_1; + else + np->desc_ver = DESC_VER_2; + err = -ENOMEM; dev->base_addr = (unsigned long) ioremap(addr, NV_PCI_REGSZ); if (!dev->base_addr) @@ -1506,15 +1818,65 @@ static int __devinit nv_probe(struct pci writel(0, base + NvRegWakeUpFlags); np->wolenabled = 0; - np->tx_flags = cpu_to_le16(NV_TX_LASTPACKET|NV_TX_LASTPACKET1|NV_TX_VALID); - if (id->driver_data & DEV_NEED_LASTPACKET1) - np->tx_flags |= cpu_to_le16(NV_TX_LASTPACKET1); + if (np->desc_ver == DESC_VER_1) { + np->tx_flags = NV_TX_LASTPACKET|NV_TX_VALID; + if (id->driver_data & DEV_NEED_LASTPACKET1) + np->tx_flags |= NV_TX_LASTPACKET1; + } else { + np->tx_flags = NV_TX2_LASTPACKET|NV_TX2_VALID; + if (id->driver_data & DEV_NEED_LASTPACKET1) + np->tx_flags |= NV_TX2_LASTPACKET1; + } if (id->driver_data & DEV_IRQMASK_1) np->irqmask = NVREG_IRQMASK_WANTED_1; if (id->driver_data & DEV_IRQMASK_2) np->irqmask = NVREG_IRQMASK_WANTED_2; if (id->driver_data & DEV_NEED_TIMERIRQ) np->irqmask |= NVREG_IRQ_TIMER; + if (id->driver_data & DEV_NEED_LINKTIMER) { + dprintk(KERN_INFO "%s: link timer on.\n", pci_name(pci_dev)); + np->need_linktimer = 1; + np->link_timeout = jiffies + LINK_TIMEOUT; + } else { + dprintk(KERN_INFO "%s: link timer off.\n", pci_name(pci_dev)); + np->need_linktimer = 0; + } + + /* find a suitable phy */ + for (i = 1; i < 32; i++) { + int id1, id2; + + spin_lock_irq(&np->lock); + id1 = mii_rw(dev, i, MII_PHYSID1, MII_READ); + spin_unlock_irq(&np->lock); + if (id1 < 0 || id1 == 0xffff) + continue; + spin_lock_irq(&np->lock); + id2 = mii_rw(dev, i, MII_PHYSID2, MII_READ); + spin_unlock_irq(&np->lock); + if (id2 < 0 || id2 == 0xffff) + continue; + + id1 = (id1 & PHYID1_OUI_MASK) << PHYID1_OUI_SHFT; + id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT; + dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n", + pci_name(pci_dev), id1, id2, i); + np->phyaddr = i; + np->phy_oui = id1 | id2; + break; + } + if (i == 32) { + /* PHY in isolate mode? No phy attached and user wants to + * test loopback? Very odd, but can be correct. + */ + printk(KERN_INFO "%s: open: Could not find a valid PHY.\n", + pci_name(pci_dev)); + } + + if (i != 32) { + /* reset it */ + phy_init(dev); + } err = register_netdev(dev); if (err) { @@ -1569,21 +1931,77 @@ static void __devexit nv_remove(struct p static struct pci_device_id pci_tbl[] = { { /* nForce Ethernet Controller */ .vendor = PCI_VENDOR_ID_NVIDIA, - .device = 0x1C3, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_1, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, - .driver_data = DEV_IRQMASK_1|DEV_NEED_TIMERIRQ, + .driver_data = DEV_IRQMASK_1|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER, }, { /* nForce2 Ethernet Controller */ .vendor = PCI_VENDOR_ID_NVIDIA, - .device = 0x0066, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_2, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER, + }, + { /* nForce3 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_3, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER, + }, + { /* nForce3 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_4, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, }, { /* nForce3 Ethernet Controller */ .vendor = PCI_VENDOR_ID_NVIDIA, - .device = 0x00D6, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_5, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + }, + { /* nForce3 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_6, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + }, + { /* nForce3 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_7, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + }, + { /* CK804 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_8, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + }, + { /* CK804 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_9, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + }, + { /* MCP04 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_10, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, + }, + { /* MCP04 Ethernet Controller */ + .vendor = PCI_VENDOR_ID_NVIDIA, + .device = PCI_DEVICE_ID_NVIDIA_NVENET_11, .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, .driver_data = DEV_NEED_LASTPACKET1|DEV_IRQMASK_2|DEV_NEED_TIMERIRQ, @@ -1612,7 +2030,7 @@ static void __exit exit_nic(void) MODULE_PARM(max_interrupt_work, "i"); MODULE_PARM_DESC(max_interrupt_work, "forcedeth maximum events handled per interrupt"); - + MODULE_AUTHOR("Manfred Spraul "); MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver"); MODULE_LICENSE("GPL"); --- 2.4/include/linux/pci_ids.h 2004-09-05 12:19:08.000000000 +0200 +++ build-2.4/include/linux/pci_ids.h 2004-09-05 14:34:14.043803399 +0200 @@ -981,21 +981,31 @@ #define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE 0x0035 #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA 0x0036 +#define PCI_DEVICE_ID_NVIDIA_NVENET_10 0x0037 +#define PCI_DEVICE_ID_NVIDIA_NVENET_11 0x0038 #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2 0x003e #define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE 0x0053 #define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA 0x0054 #define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2 0x0055 +#define PCI_DEVICE_ID_NVIDIA_NVENET_8 0x0056 +#define PCI_DEVICE_ID_NVIDIA_NVENET_9 0x0057 #define PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE 0x0065 +#define PCI_DEVICE_ID_NVIDIA_NVENET_2 0x0066 #define PCI_DEVICE_ID_NVIDIA_MCP2_AUDIO 0x006a #define PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE 0x0085 +#define PCI_DEVICE_ID_NVIDIA_NVENET_4 0x0086 +#define PCI_DEVICE_ID_NVIDIA_NVENET_5 0x008c #define PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA 0x008e #define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0 #define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1 #define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d5 #define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da +#define PCI_DEVICE_ID_NVIDIA_NVENET_7 0x00df #define PCI_DEVICE_ID_NVIDIA_NFORCE3S 0x00e1 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA 0x00e3 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE 0x00e5 +#define PCI_DEVICE_ID_NVIDIA_NVENET_6 0x00e6 #define PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2 0x00ee #define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100 #define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101 @@ -1012,6 +1022,7 @@ #define PCI_DEVICE_ID_NVIDIA_NFORCE 0x01a4 #define PCI_DEVICE_ID_NVIDIA_MCP1_AUDIO 0x01b1 #define PCI_DEVICE_ID_NVIDIA_NFORCE_IDE 0x01bc +#define PCI_DEVICE_ID_NVIDIA_NVENET_1 0x01c3 #define PCI_DEVICE_ID_NVIDIA_NFORCE2 0x01e0 #define PCI_DEVICE_ID_NVIDIA_GEFORCE3 0x0200 #define PCI_DEVICE_ID_NVIDIA_GEFORCE3_1 0x0201 From linux_lover2004@yahoo.com Sun Sep 5 06:41:10 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 06:41:15 -0700 (PDT) Received: from web52202.mail.yahoo.com (web52202.mail.yahoo.com [206.190.39.84]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i85DfA30000543 for ; Sun, 5 Sep 2004 06:41:10 -0700 Message-ID: <20040905134056.87431.qmail@web52202.mail.yahoo.com> Received: from [66.218.69.220] by web52202.mail.yahoo.com via HTTP; Sun, 05 Sep 2004 06:40:56 PDT Date: Sun, 5 Sep 2004 06:40:56 -0700 (PDT) From: linux lover Subject: Skbuff modification To: linux-kernel@vger.kernel.org Cc: netdev@oss.sgi.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-archive-position: 8424 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: linux_lover2004@yahoo.com Precedence: bulk X-list: netdev Hello, can it be possible to add a my own structure to skbuff structure, so that it will also be send with packet on network? Regards, linux lover __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From linux_lover2004@yahoo.com Sun Sep 5 06:40:17 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 06:40:21 -0700 (PDT) Received: from web52201.mail.yahoo.com (web52201.mail.yahoo.com [206.190.39.83]) by oss.sgi.com (8.13.0/8.13.0) with SMTP id i85DeGsu000449 for ; Sun, 5 Sep 2004 06:40:17 -0700 Message-ID: <20040905134002.41285.qmail@web52201.mail.yahoo.com> Received: from [66.218.69.220] by web52201.mail.yahoo.com via HTTP; Sun, 05 Sep 2004 06:40:02 PDT Date: Sun, 5 Sep 2004 06:40:02 -0700 (PDT) From: linux lover Subject: Skbuff modification To: linux-kernel@vger.kernel.org Cc: netdev@oss.sgi.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-archive-position: 8423 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: linux_lover2004@yahoo.com Precedence: bulk X-list: netdev Hello, can it be possible to add a my own structure to skbuff structure, so that it will also be send with packet on network? Regards, linux lover __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail From khc@pm.waw.pl Sun Sep 5 07:21:06 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 07:21:12 -0700 (PDT) Received: from inx.pm.waw.pl (IDENT:m289MuBeM+kxjLD6Nb2shH9aHL4dI/6o@inx.pm.waw.pl [195.116.170.20]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85EL6nq001800 for ; Sun, 5 Sep 2004 07:21:06 -0700 Received: from defiant.pm.waw.pl (qr224.warszawa.cvx.ppp.tpnet.pl [217.99.27.224]) by inx.pm.waw.pl (Postfix) with ESMTP id 92540E0E1; Sun, 5 Sep 2004 16:19:27 +0200 (CEST) Received: by defiant.pm.waw.pl (Postfix, from userid 500) id E00E9302D5; Sun, 5 Sep 2004 16:19:59 +0200 (CEST) To: Jeff Garzik , marcelo.tosatti@cyclades.com, Subject: fix for integer overflow in hd6457[02] driver code From: Krzysztof Halasa Date: Sun, 05 Sep 2004 16:19:59 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-archive-position: 8425 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: khc@pm.waw.pl Precedence: bulk X-list: netdev Hi, The attached patch fixes an integer overflow in drivers for N2, C101, PCI200SYN WAN cards (brv * port->settings.clock_rate overflowed at requested clock rate of 8*1024*1024 bps, problem noted by Nagaraj Kanniah). Please apply to 2.4 and 2.6 kernel trees. Thanks. -- Krzysztof Halasa From khc@pm.waw.pl Sun Sep 5 07:27:36 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 07:27:41 -0700 (PDT) Received: from inx.pm.waw.pl (IDENT:D/MleOFHhP+CevyBUcJGYBBEOvD4vRJd@inx.pm.waw.pl [195.116.170.20]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85ERW1E002193 for ; Sun, 5 Sep 2004 07:27:35 -0700 Received: from defiant.pm.waw.pl (qr224.warszawa.cvx.ppp.tpnet.pl [217.99.27.224]) by inx.pm.waw.pl (Postfix) with ESMTP id A1337E0E1; Sun, 5 Sep 2004 16:25:54 +0200 (CEST) Received: by defiant.pm.waw.pl (Postfix, from userid 500) id 71FD9302D5; Sun, 5 Sep 2004 16:26:26 +0200 (CEST) To: Jeff Garzik , marcelo.tosatti@cyclades.com, Subject: [PATCH] fix for integer overflow in hd6457[02] driver code From: Krzysztof Halasa Date: Sun, 05 Sep 2004 16:26:26 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-archive-position: 8426 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: khc@pm.waw.pl Precedence: bulk X-list: netdev --=-=-= Hi, The attached patch fixes an integer overflow in drivers for N2, C101, PCI200SYN WAN cards (brv * port->settings.clock_rate overflowed at requested clock rate of 8*1024*1024 bps, problem noted by Nagaraj Kanniah). Please apply to 2.4 and 2.6 kernel trees. Thanks. [now the patch has made it here] -- Krzysztof Halasa --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=hd6457x-speed-fix.patch --- linux-2.6/drivers/net/wan/hd6457x.c 1 Jun 2004 03:47:44 -0000 +++ linux-2.6/drivers/net/wan/hd6457x.c 5 Sep 2004 13:59:22 -0000 @@ -463,8 +463,8 @@ brv >>= 1; /* brv = 2^9 = 512 max in specs */ /* Baud Rate = CLOCK_BASE / TMC / 2^BR */ - tmc = CLOCK_BASE / (brv * port->settings.clock_rate); - }while(br > 1 && tmc <= 128); + tmc = CLOCK_BASE / brv / port->settings.clock_rate; + }while (br > 1 && tmc <= 128); if (tmc < 1) { tmc = 1; @@ -473,7 +473,7 @@ } else if (tmc > 255) tmc = 256; /* tmc=0 means 256 - low baud rates */ - port->settings.clock_rate = CLOCK_BASE / (brv * tmc); + port->settings.clock_rate = CLOCK_BASE / brv / tmc; } else { br = 9; /* Minimum clock rate */ tmc = 256; /* 8bit = 0 */ --=-=-=-- From jeffpc@optonline.net Sun Sep 5 09:20:01 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 09:20:06 -0700 (PDT) Received: from mta5.srv.hcvlny.cv.net (mta5.srv.hcvlny.cv.net [167.206.5.78]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85GJwnP007097 for ; Sun, 5 Sep 2004 09:20:01 -0700 Received: from [10.0.0.15] (ool-44c218a8.dyn.optonline.net [68.194.24.168]) by mta5.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.25 (built Mar 3 2004)) with ESMTP id <0I3K00JJCTD1X1@mta5.srv.hcvlny.cv.net> for netdev@oss.sgi.com; Sun, 05 Sep 2004 12:19:50 -0400 (EDT) Date: Sun, 05 Sep 2004 12:19:34 -0400 From: Jeff Sipek Subject: Re: [PATCH 2.6] watch64: generic variable monitoring system In-reply-to: <1094303999.1633.116.camel@jzny.localdomain> To: hadi@cyberus.ca Cc: Stephen Hemminger , linux-kernel@vger.kernel.org, netdev@oss.sgi.com Message-id: <200409051219.47590.jeffpc@optonline.net> MIME-version: 1.0 Content-type: Text/Plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline User-Agent: KMail/1.6.2 References: <200409031307.01240.jeffpc@optonline.net> <200409031744.32970.jeffpc@optonline.net> <1094303999.1633.116.camel@jzny.localdomain> X-archive-position: 8427 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jeffpc@optonline.net Precedence: bulk X-list: netdev -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Saturday 04 September 2004 09:19, jamal wrote: > I have a feeling this was discussed somewhere(other than netdev) and i > missed it. Why isnt this watch64 being done in user space? There was a discussion about 64-bit network statistics about a year ago on lkml. watch64 is a generic so that anyone in the kernel can use it. Jeff. - -- Mankind invented the atomic bomb, but no mouse would ever construct a mousetrap. - Albert Einstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBOzybwFP0+seVj/4RArmhAKC3ddX4ZGoAMQKxGplXqqbER9BBMQCfencW wDt06dC8MifG9NU3xWx0ULo= =z9kC -----END PGP SIGNATURE----- From jgarzik@pobox.com Sun Sep 5 13:10:13 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 13:10:17 -0700 (PDT) Received: from www.linux.org.uk (IDENT:93@parcelfarce.linux.theplanet.co.uk [195.92.249.252]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85KACOX014018 for ; Sun, 5 Sep 2004 13:10:13 -0700 Received: from rdu74-155-169.nc.rr.com ([24.74.155.169] helo=[10.10.10.88]) by www.linux.org.uk with asmtp (TLSv1:AES256-SHA:256) (Exim 4.33) id 1C43Ks-0002Ph-It; Sun, 05 Sep 2004 21:10:02 +0100 Message-ID: <413B728D.7000902@pobox.com> Date: Sun, 05 Sep 2004 16:09:49 -0400 From: Jeff Garzik User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Margit Schubert-While CC: netdev@oss.sgi.com, prism54-devel@prism54.org Subject: Re: [PATCH 0/6 linux-2.6.9-rc1/linux-2.4.28-pre2] prism54 patches resend References: <200409051158.59976.margitsw@t-online.de> In-Reply-To: <200409051158.59976.margitsw@t-online.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8428 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jgarzik@pobox.com Precedence: bulk X-list: netdev applied 2.4 sync-up patch, and the series 1-6 to 2.4 and 2.6. only patch #1 went into net-drivers-2.[46] for immediate queueing, the rest went into netdev-2.[46] (and thus -mm) for further testing of new features. Jeff From herbert@gondor.apana.org.au Sun Sep 5 15:05:21 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 15:05:28 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85M5Jrk015961 for ; Sun, 5 Sep 2004 15:05:20 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1C456w-0001KV-00; Mon, 06 Sep 2004 08:03:46 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1C456r-0003Ri-00; Mon, 06 Sep 2004 08:03:41 +1000 Date: Mon, 6 Sep 2004 08:03:41 +1000 To: Andi Kleen Cc: davem@redhat.com, netdev@oss.sgi.com, akepner@sgi.com Subject: Re: [PATCH] Do less atomic count changes in dev_queue_xmit Message-ID: <20040905220341.GA13217@gondor.apana.org.au> References: <20040904135439.GA23934@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040904135439.GA23934@wotan.suse.de> User-Agent: Mutt/1.5.6+20040722i From: Herbert Xu X-archive-position: 8429 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev On Sat, Sep 04, 2004 at 01:54:39PM +0000, Andi Kleen wrote: > > diff -u linux-2.6.8/net/core/dev.c-o linux-2.6.8/net/core/dev.c > --- linux-2.6.8/net/core/dev.c-o 2004-09-04 13:10:47.000000000 +0000 > +++ linux-2.6.8/net/core/dev.c 2004-09-04 13:47:16.765722813 +0000 > @@ -1249,14 +1249,14 @@ > return 0; > } > > -#define HARD_TX_LOCK_BH(dev, cpu) { \ > +#define HARD_TX_LOCK(dev, cpu) { \ > if ((dev->features & NETIF_F_LLTX) == 0) { \ > spin_lock_bh(&dev->xmit_lock); \ You can remove the _bh here as well. > @@ -1358,12 +1361,11 @@ > Either shot noqueue qdisc, it is even simpler 8) > */ > if (dev->flags & IFF_UP) { > - int cpu = get_cpu(); > + int cpu = smp_processor_id(); /* ok because BHs are off */ Hmm this means that the loopback xmit function will now execute with BH/preempt turned off. Is this what we want? Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt From dr@cluenet.de Sun Sep 5 16:02:30 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 16:02:34 -0700 (PDT) Received: from mail1.cluenet.de (mail1.cluenet.de [195.20.121.7]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i85N2Shb016954 for ; Sun, 5 Sep 2004 16:02:29 -0700 Received: by mail1.cluenet.de (Postfix, from userid 500) id 4D946178A4; Mon, 6 Sep 2004 01:02:19 +0200 (CEST) Date: Mon, 6 Sep 2004 01:02:19 +0200 From: Daniel Roesen To: Paul Jakma Cc: lkml@einar-lueck.de, linux-kernel@vger.kernel.org, netdev@oss.sgi.com Subject: Re: [PATCH] net/ipv4 for Source VIPA support, kernel BK Head Message-ID: <20040905230219.GA24688@srv01.cluenet.de> Mail-Followup-To: Paul Jakma , lkml@einar-lueck.de, linux-kernel@vger.kernel.org, netdev@oss.sgi.com References: <200409011441.10154.elueck@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-archive-position: 8430 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: dr@cluenet.de Precedence: bulk X-list: netdev On Thu, Sep 02, 2004 at 05:22:01PM +0100, Paul Jakma wrote: > ip route add default via src Sitenote: unfortunately, "src <...>" doesn't work for IPv6 routes, at least in 2.4 -- can someone confirm this problem to still exist in current 2.6? Copying netdev for the record. Regards, Daniel From davem@davemloft.net Sun Sep 5 20:24:38 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 20:24:44 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i863ObW2030035 for ; Sun, 5 Sep 2004 20:24:38 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C4A59-0006R0-00; Sun, 05 Sep 2004 20:22:15 -0700 Date: Sun, 5 Sep 2004 20:22:15 -0700 From: "David S. Miller" To: Daniel Roesen Cc: paul@clubi.ie, lkml@einar-lueck.de, linux-kernel@vger.kernel.org, netdev@oss.sgi.com Subject: Re: [PATCH] net/ipv4 for Source VIPA support, kernel BK Head Message-Id: <20040905202215.5ed8bf5f.davem@davemloft.net> In-Reply-To: <20040905230219.GA24688@srv01.cluenet.de> References: <200409011441.10154.elueck@de.ibm.com> <20040905230219.GA24688@srv01.cluenet.de> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8431 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev On Mon, 6 Sep 2004 01:02:19 +0200 Daniel Roesen wrote: > On Thu, Sep 02, 2004 at 05:22:01PM +0100, Paul Jakma wrote: > > ip route add default via src > > Sitenote: unfortunately, "src <...>" doesn't work for IPv6 routes, at > least in 2.4 -- can someone confirm this problem to still exist in > current 2.6? That's right, no routing by source in ipv6 yet, the folks working with the USAGI guys on MIPV6 support will add the feature. From glen.turner@aarnet.edu.au Sun Sep 5 21:19:40 2004 Received: with ECARTIS (v1.0.0; list netdev); Sun, 05 Sep 2004 21:19:49 -0700 (PDT) Received: from clix.aarnet.edu.au (clix.aarnet.edu.au [192.94.63.10]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i864JduA031291 for ; Sun, 5 Sep 2004 21:19:40 -0700 Received: from [202.158.193.5] (andromache.adelaide.aarnet.edu.au [202.158.193.5]) (authenticated bits=0) by clix.aarnet.edu.au (8.12.8/8.12.8) with ESMTP id i864JTCS018371 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 6 Sep 2004 14:19:29 +1000 Subject: DHCP and jumbo frames From: Glen Turner To: netdev@oss.sgi.com Content-Type: text/plain Organization: Australian Academic and Research Network Message-Id: <1094444369.22662.32.camel@andromache> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 06 Sep 2004 13:49:29 +0930 Content-Transfer-Encoding: 7bit X-MDSA: Yes X-Scanned-By: MIMEDefang 2.39 X-archive-position: 8432 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: glen.turner@aarnet.edu.au Precedence: bulk X-list: netdev Hi folks, I'm trying to make DHCP work correctly for ethernet jumbo frame media and jumbo+standard MTU subnets on jumbo media. It's turning into a bit of a long slog (RFC amendments, etc), but jumbo frames will never seen widespread host deployment without it. It turns out that the DHCP client has to be able to select from a range of potential DHCP offers (all else equal it should select the offer with the largest MTU) and has to be able to reject an offer with an MTU the hardware cannot support. Setting the MTU often re-sets the ethernet controller (as far as I can tell from the e1000 source). So checking each DHCP offer by attempting to write the MTU to the hardware isn't going to work well. Especially if an ethernet controller reset causes the PHY to drop carrier, as spanning tree hold-downs could then cause the DHCP state machine to time out. Is there any way for the DHCP client to query every interface for the MTU size ranges that the interface supports? Advice is very appreciated, Glen -- Glen Turner Tel: (08) 8303 3936 or +61 8 8303 3936 Australia's Academic & Research Network www.aarnet.edu.au From nakam@linux-ipv6.org Mon Sep 6 00:47:58 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 00:48:02 -0700 (PDT) Received: from mail206.noc.n-bone.net (mail2.noc.n-bone.net [138.243.50.142]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i867lvo4006504 for ; Mon, 6 Sep 2004 00:47:58 -0700 Received: from localhost (unknown [203.178.140.10]) by mail206.noc.n-bone.net (NBONE-MTA) with ESMTP id 49801A85; Mon, 6 Sep 2004 16:47:43 +0900 (JST) Date: Mon, 6 Sep 2004 16:47:42 +0900 From: Masahide Nakamura To: Stephen Hemminger Cc: netdev@oss.sgi.com, linux-net@vger.kernel.org, nakam@linux-ipv6.org Subject: [PATCH] [iproute2] XFRM: support ICMP/ICMPv6's type and code Message-Id: <20040906164742.54795bf4@localhost> X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8436 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nakam@linux-ipv6.org Precedence: bulk X-list: netdev This patch supports ICMP/ICMPv6's type and code in IPsec selector. Kernel has supported this feature from 2.6.9-rc1. The ChangeSet is also available at: # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/09/01 14:45:04+09:00 nakam@linux-ipv6.org # support ICMP and ICMPv6's type/code for IPsec. # # ip/xfrm_state.c # 2004/09/01 14:44:59+09:00 nakam@linux-ipv6.org +3 -1 # fix usage. # # ip/xfrm_policy.c # 2004/09/01 14:44:59+09:00 nakam@linux-ipv6.org +2 -1 # fix usage. # # ip/ipxfrm.c # 2004/09/01 14:44:59+09:00 nakam@linux-ipv6.org +75 -4 # ICMP and ICMPv6's type/code can be specified in selector. # fix to show sport/dport values when mask is specified. # diff -Nru a/ip/ipxfrm.c b/ip/ipxfrm.c --- a/ip/ipxfrm.c 2004-09-02 23:08:19 +09:00 +++ b/ip/ipxfrm.c 2004-09-02 23:08:19 +09:00 @@ -352,10 +352,25 @@ if (sel->proto) fprintf(fp, "proto %s ", strxf_proto(sel->proto)); - if (sel->sport) - fprintf(fp, "sport %u ", ntohs(sel->sport)); - if (sel->dport) - fprintf(fp, "dport %u ", ntohs(sel->dport)); + switch (sel->proto) { + case IPPROTO_TCP: + case IPPROTO_UDP: + case IPPROTO_SCTP: + default: /* XXX */ + if (sel->sport_mask) + fprintf(fp, "sport %u ", ntohs(sel->sport)); + if (sel->dport_mask) + fprintf(fp, "dport %u ", ntohs(sel->dport)); + break; + case IPPROTO_ICMP: + case IPPROTO_ICMPV6: + /* type/code is stored at sport/dport in selector */ + if (sel->sport_mask) + fprintf(fp, "type %u ", ntohs(sel->sport)); + if (sel->dport_mask) + fprintf(fp, "code %u ", ntohs(sel->dport)); + break; + } if (sel->ifindex > 0) { char buf[IF_NAMESIZE]; @@ -653,6 +668,10 @@ { int argc = *argcp; char **argv = *argvp; + char *sportp = NULL; + char *dportp = NULL; + char *typep = NULL; + char *codep = NULL; while (1) { if (strcmp(*argv, "proto") == 0) { @@ -677,6 +696,8 @@ filter.upspec_proto_mask = XFRM_FILTER_MASK_FULL; } else if (strcmp(*argv, "sport") == 0) { + sportp = *argv; + NEXT_ARG(); if (get_u16(&sel->sport, *argv, 0)) @@ -688,6 +709,8 @@ filter.upspec_sport_mask = XFRM_FILTER_MASK_FULL; } else if (strcmp(*argv, "dport") == 0) { + dportp = *argv; + NEXT_ARG(); if (get_u16(&sel->dport, *argv, 0)) @@ -698,6 +721,33 @@ filter.upspec_dport_mask = XFRM_FILTER_MASK_FULL; + } else if (strcmp(*argv, "type") == 0) { + typep = *argv; + + NEXT_ARG(); + + if (get_u16(&sel->sport, *argv, 0) || + (sel->sport & ~((__u16)0xff))) + invarg("\"type\" value is invalid", *argv); + sel->sport = htons(sel->sport); + sel->sport_mask = ~((__u16)0); + + filter.upspec_sport_mask = XFRM_FILTER_MASK_FULL; + + + } else if (strcmp(*argv, "code") == 0) { + codep = *argv; + + NEXT_ARG(); + + if (get_u16(&sel->dport, *argv, 0) || + (sel->dport & ~((__u16)0xff))) + invarg("\"code\" value is invalid", *argv); + sel->dport = htons(sel->dport); + sel->dport_mask = ~((__u16)0); + + filter.upspec_dport_mask = XFRM_FILTER_MASK_FULL; + } else { PREV_ARG(); /* back track */ break; @@ -709,6 +759,27 @@ } if (argc == *argcp) missarg("UPSPEC"); + if (sportp || dportp) { + switch (sel->proto) { + case IPPROTO_TCP: + case IPPROTO_UDP: + case IPPROTO_SCTP: + break; + default: + fprintf(stderr, "\"sport\" and \"dport\" are invalid with proto=%s\n", strxf_proto(sel->proto)); + exit(1); + } + } + if (typep || codep) { + switch (sel->proto) { + case IPPROTO_ICMP: + case IPPROTO_ICMPV6: + break; + default: + fprintf(stderr, "\"type\" and \"code\" are invalid with proto=%s\n", strxf_proto(sel->proto)); + exit(1); + } + } *argcp = argc; *argvp = argv; diff -Nru a/ip/xfrm_policy.c b/ip/xfrm_policy.c --- a/ip/xfrm_policy.c 2004-09-02 23:08:19 +09:00 +++ b/ip/xfrm_policy.c 2004-09-02 23:08:19 +09:00 @@ -62,7 +62,8 @@ fprintf(stderr, "SELECTOR := src ADDR[/PLEN] dst ADDR[/PLEN] [ UPSPEC ] [ dev DEV ]\n"); - fprintf(stderr, "UPSPEC := proto PROTO [ sport PORT ] [ dport PORT ]\n"); + fprintf(stderr, "UPSPEC := proto PROTO [ [ sport PORT ] [ dport PORT ] |\n"); + fprintf(stderr, " [ type NUMBER ] [ code NUMBER ] ]\n"); //fprintf(stderr, "DEV - device name(default=none)\n"); diff -Nru a/ip/xfrm_state.c b/ip/xfrm_state.c --- a/ip/xfrm_state.c 2004-09-02 23:08:19 +09:00 +++ b/ip/xfrm_state.c 2004-09-02 23:08:19 +09:00 @@ -91,7 +91,9 @@ fprintf(stderr, "SELECTOR := src ADDR[/PLEN] dst ADDR[/PLEN] [ upspec UPSPEC ] [ dev DEV ]\n"); - fprintf(stderr, "UPSPEC := proto PROTO [ sport PORT ] [ dport PORT ]\n"); + fprintf(stderr, "UPSPEC := proto PROTO [ [ sport PORT ] [ dport PORT ] |\n"); + fprintf(stderr, " [ type NUMBER ] [ code NUMBER ] ]\n"); + //fprintf(stderr, "DEV - device name(default=none)\n"); fprintf(stderr, "LIMIT-LIST := [ LIMIT-LIST ] | [ limit LIMIT ]\n"); -- Masahide NAKAMURA From nakam@linux-ipv6.org Mon Sep 6 00:47:18 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 00:47:23 -0700 (PDT) Received: from mail406.noc.n-bone.net (mail4.noc.n-bone.net [138.243.50.144]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i867lHgG006164 for ; Mon, 6 Sep 2004 00:47:17 -0700 Received: from localhost (unknown [203.178.140.10]) by mail406.noc.n-bone.net (NBONE-MTA) with ESMTP id DCA2B97C; Mon, 6 Sep 2004 16:47:03 +0900 (JST) Date: Mon, 6 Sep 2004 16:47:03 +0900 From: Masahide Nakamura To: Stephen Hemminger Cc: netdev@oss.sgi.com, linux-net@vger.kernel.org, nakam@linux-ipv6.org Subject: [PATCH] [iproute2] XFRM: fixing protocol Message-Id: <20040906164703.3e674496@localhost> X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8435 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nakam@linux-ipv6.org Precedence: bulk X-list: netdev Talking about "protocol" on IPsec/XFRM, there are two kinds of it, one is in selector and the other is in SA(state for transformation). This patch makes it is managed separately. The ChangeSets are also available at: # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/09/02 19:11:13+09:00 nakam@linux-ipv6.org # fix error message. # # ip/xfrm_state.c # 2004/09/02 19:11:13+09:00 nakam@linux-ipv6.org +2 -2 # fix error message to use strxf_xfrmproto(). # # ChangeSet # 2004/09/02 13:35:13+09:00 nakam@linux-ipv6.org # distinguish xfrm protocol and selector protocol. # # ip/xfrm_state.c # 2004/09/02 13:35:10+09:00 nakam@linux-ipv6.org +4 -4 # fix usage. # # ip/xfrm_policy.c # 2004/09/02 13:35:10+09:00 nakam@linux-ipv6.org +4 -4 # fix usage. # # ip/xfrm.h # 2004/09/02 13:35:10+09:00 nakam@linux-ipv6.org +2 -0 # add interfaces of xfrmproto. # # ip/ipxfrm.c # 2004/09/02 13:35:10+09:00 nakam@linux-ipv6.org +45 -21 # add "xfrmproto" to distinguish xfrm protocol and selector protocol. # diff -Nru a/ip/ipxfrm.c b/ip/ipxfrm.c --- a/ip/ipxfrm.c 2004-09-02 23:03:08 +09:00 +++ b/ip/ipxfrm.c 2004-09-02 23:03:08 +09:00 @@ -57,6 +57,43 @@ int t_type; }; +static const struct typeent xfrmproto_types[]= { + { "esp", IPPROTO_ESP }, { "ah", IPPROTO_AH }, + { "comp", IPPROTO_COMP }, { NULL, -1 } +}; + +int xfrm_xfrmproto_getbyname(char *name) +{ + int i; + + for (i = 0; ; i++) { + const struct typeent *t = &xfrmproto_types[i]; + if (!t->t_name || t->t_type == -1) + break; + + if (strcmp(t->t_name, name) == 0) + return t->t_type; + } + + return -1; +} + +const char *strxf_xfrmproto(__u8 proto) +{ + int i; + + for (i = 0; ; i++) { + const struct typeent *t = &xfrmproto_types[i]; + if (!t->t_name || t->t_type == -1) + break; + + if (t->t_type == proto) + return t->t_name; + } + + return NULL; +} + static const struct typeent algo_types[]= { { "enc", XFRMA_ALG_CRYPT }, { "auth", XFRMA_ALG_AUTH }, { "comp", XFRMA_ALG_COMP }, { NULL, -1 } @@ -172,7 +209,7 @@ fprintf(fp, prefix); fprintf(fp, "\t"); - fprintf(fp, "proto %s ", strxf_proto(id->proto)); + fprintf(fp, "proto %s ", strxf_xfrmproto(id->proto)); spi = ntohl(id->spi); fprintf(fp, "spi 0x%08x", spi); @@ -522,7 +559,6 @@ char **argv = *argvp; inet_prefix dst; inet_prefix src; - __u8 proto = 0; memset(&dst, 0, sizeof(dst)); memset(&src, 0, sizeof(src)); @@ -555,27 +591,15 @@ filter.id_dst_mask = dst.bitlen; } else if (strcmp(*argv, "proto") == 0) { - struct protoent *pp; + int ret; NEXT_ARG(); - pp = getprotobyname(*argv); - if (pp) - proto = pp->p_proto; - else { - if (get_u8(&proto, *argv, 0)) - invarg("\"XFRM_PROTO\" is invalid", *argv); - } + ret = xfrm_xfrmproto_getbyname(*argv); + if (ret < 0) + invarg("\"XFRM_PROTO\" is invalid", *argv); - switch (proto) { - case IPPROTO_ESP: - case IPPROTO_AH: - case IPPROTO_COMP: - id->proto = proto; - break; - default: - invarg("\"XFRM_PROTO\" is unsuppored proto", *argv); - } + id->proto = (__u8)ret; filter.id_proto_mask = XFRM_FILTER_MASK_FULL; @@ -604,8 +628,8 @@ if (src.family && dst.family && (src.family != dst.family)) invarg("the same address family is required between \"SADDR\" and \"DADDR\"", *argv); - if (loose == 0 && proto == 0) - missarg("PROTO"); + if (loose == 0 && id->proto == 0) + missarg("XFRM_PROTO"); if (argc == *argcp) missarg("ID"); diff -Nru a/ip/xfrm.h b/ip/xfrm.h --- a/ip/xfrm.h 2004-09-02 23:03:08 +09:00 +++ b/ip/xfrm.h 2004-09-02 23:03:08 +09:00 @@ -78,7 +78,9 @@ int do_xfrm_state(int argc, char **argv); int do_xfrm_policy(int argc, char **argv); +int xfrm_xfrmproto_getbyname(char *name); int xfrm_algotype_getbyname(char *name); +const char *strxf_xfrmproto(__u8 proto); const char *strxf_algotype(int type); const char *strxf_flags(__u8 flags); const char *strxf_share(__u8 share); diff -Nru a/ip/xfrm_policy.c b/ip/xfrm_policy.c --- a/ip/xfrm_policy.c 2004-09-02 23:03:08 +09:00 +++ b/ip/xfrm_policy.c 2004-09-02 23:03:08 +09:00 @@ -78,11 +78,11 @@ fprintf(stderr, "TMPL := ID [ mode MODE ] [ reqid REQID ] [ level LEVEL ]\n"); fprintf(stderr, "ID := [ src ADDR ] [ dst ADDR ] [ proto XFRM_PROTO ] [ spi SPI ]\n"); - //fprintf(stderr, "XFRM_PROTO := [ esp | ah | ipcomp ]\n"); + //fprintf(stderr, "XFRM_PROTO := [ esp | ah | comp ]\n"); fprintf(stderr, "XFRM_PROTO := [ "); - fprintf(stderr, "%s | ", strxf_proto(IPPROTO_ESP)); - fprintf(stderr, "%s | ", strxf_proto(IPPROTO_AH)); - fprintf(stderr, "%s", strxf_proto(IPPROTO_COMP)); + fprintf(stderr, "%s | ", strxf_xfrmproto(IPPROTO_ESP)); + fprintf(stderr, "%s | ", strxf_xfrmproto(IPPROTO_AH)); + fprintf(stderr, "%s", strxf_xfrmproto(IPPROTO_COMP)); fprintf(stderr, " ]\n"); fprintf(stderr, "MODE := [ transport | tunnel ](default=transport)\n"); diff -Nru a/ip/xfrm_state.c b/ip/xfrm_state.c --- a/ip/xfrm_state.c 2004-09-02 23:03:08 +09:00 +++ b/ip/xfrm_state.c 2004-09-02 23:03:08 +09:00 @@ -63,11 +63,11 @@ fprintf(stderr, " [ FLAG_LIST ]\n"); fprintf(stderr, "ID := [ src ADDR ] [ dst ADDR ] [ proto XFRM_PROTO ] [ spi SPI ]\n"); - //fprintf(stderr, "XFRM_PROTO := [ esp | ah | ipcomp ]\n"); + //fprintf(stderr, "XFRM_PROTO := [ esp | ah | comp ]\n"); fprintf(stderr, "XFRM_PROTO := [ "); - fprintf(stderr, "%s | ", strxf_proto(IPPROTO_ESP)); - fprintf(stderr, "%s | ", strxf_proto(IPPROTO_AH)); - fprintf(stderr, "%s ", strxf_proto(IPPROTO_COMP)); + fprintf(stderr, "%s | ", strxf_xfrmproto(IPPROTO_ESP)); + fprintf(stderr, "%s | ", strxf_xfrmproto(IPPROTO_AH)); + fprintf(stderr, "%s ", strxf_xfrmproto(IPPROTO_COMP)); fprintf(stderr, "]\n"); //fprintf(stderr, "SPI - security parameter index(default=0)\n"); @@ -308,14 +308,14 @@ if (req.xsinfo.id.proto != IPPROTO_ESP && req.xsinfo.id.proto != IPPROTO_AH && req.xsinfo.id.proto != IPPROTO_COMP) { - fprintf(stderr, "\"ALGO\" is invalid with proto=%s\n", strxf_proto(req.xsinfo.id.proto)); + fprintf(stderr, "\"ALGO\" is invalid with proto=%s\n", strxf_xfrmproto(req.xsinfo.id.proto)); exit(1); } } else { if (req.xsinfo.id.proto == IPPROTO_ESP || req.xsinfo.id.proto == IPPROTO_AH || req.xsinfo.id.proto == IPPROTO_COMP) { - fprintf(stderr, "\"ALGO\" is required with proto=%s\n", strxf_proto(req.xsinfo.id.proto)); + fprintf(stderr, "\"ALGO\" is required with proto=%s\n", strxf_xfrmproto(req.xsinfo.id.proto)); exit (1); } } -- Masahide NAKAMURA From nakam@linux-ipv6.org Mon Sep 6 00:46:31 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 00:46:37 -0700 (PDT) Received: from mail406.noc.n-bone.net (mail4.noc.n-bone.net [138.243.50.144]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i867kUiP006012 for ; Mon, 6 Sep 2004 00:46:31 -0700 Received: from localhost (unknown [203.178.140.10]) by mail406.noc.n-bone.net (NBONE-MTA) with ESMTP id 3DA53F05; Mon, 6 Sep 2004 16:46:16 +0900 (JST) Date: Mon, 6 Sep 2004 16:46:15 +0900 From: Masahide Nakamura To: Stephen Hemminger Cc: netdev@oss.sgi.com, linux-net@vger.kernel.org, yoshfuji@linux-ipv6.org, nakam@linux-ipv6.org Subject: [PATCH] [iproute2] XFRM: fixing IPsec algorithm key Message-Id: <20040906164615.6320ab5f@localhost> X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8433 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nakam@linux-ipv6.org Precedence: bulk X-list: netdev Hello, This patch fixes `ip xfrm`'s algorithm key when using hexadecimal number from command line. Please apply it. The ChangeSet is also available at: # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/09/02 17:35:23+09:00 nakam@linux-ipv6.org # fix specifying IPsec algorithm key. # # ip/xfrm_state.c # 2004/09/02 17:35:21+09:00 nakam@linux-ipv6.org +27 -26 # fix algorithm key when using hexadecimal number # (clean-up by Hideaki YOSHIFUJI ). # diff -Nru a/ip/xfrm_state.c b/ip/xfrm_state.c --- a/ip/xfrm_state.c 2004-09-02 23:04:14 +09:00 +++ b/ip/xfrm_state.c 2004-09-02 23:04:14 +09:00 @@ -114,34 +114,35 @@ strncpy(alg->alg_name, name, sizeof(alg->alg_name)); if (slen > 2 && strncmp(key, "0x", 2) == 0) { - /* - * XXX: fix me!! + /* split two chars "0x" from the top */ + char *p = key + 2; + int plen = slen - 2; + int i; + int j; + + /* Converting hexadecimal numbered string into real key; + * Convert each two chars into one char(value). If number + * of the length is odd, add zero on the top for rounding. */ - union { - __u64 x; - unsigned char p[8]; - } val; - - memset(&val, 0, sizeof(val)); - - if (get_u64(&val.x, key, 16)) - invarg("\"ALGOKEY\" is invalid", key); - - len = (slen - 2) / 2; - if (len > sizeof(val)) - invarg("\"ALGOKEY\" is invalid: too large", key); - - if (len > 0) { - int i; - - if (len > max) - invarg("\"ALGOKEY\" makes buffer overflow\n", key); - for (i = sizeof(val.p) - 1; i >= 0; i--) { - int j = sizeof(val.p) - 1 - i; - alg->alg_key[j] = val.p[i]; - } - } + /* calculate length of the converted values(real key) */ + len = (plen + 1) / 2; + if (len > max) + invarg("\"ALGOKEY\" makes buffer overflow\n", key); + + for (i = - (plen % 2), j = 0; j < len; i += 2, j++) { + char vbuf[3]; + char val; + + vbuf[0] = i >= 0 ? p[i] : '0'; + vbuf[1] = p[i + 1]; + vbuf[2] = '\0'; + + if (get_u8(&val, vbuf, 16)) + invarg("\"ALGOKEY\" is invalid", key); + + alg->alg_key[j] = val; + } } else { len = slen; if (len > 0) { -- Masahide NAKAMURA -- Masahide NAKAMURA From nakam@linux-ipv6.org Mon Sep 6 00:46:56 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 00:47:00 -0700 (PDT) Received: from mail406.noc.n-bone.net (mail4.noc.n-bone.net [138.243.50.144]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i867kt8h006034 for ; Mon, 6 Sep 2004 00:46:56 -0700 Received: from localhost (unknown [203.178.140.10]) by mail406.noc.n-bone.net (NBONE-MTA) with ESMTP id B67D75A7; Mon, 6 Sep 2004 16:46:41 +0900 (JST) Date: Mon, 6 Sep 2004 16:46:40 +0900 From: Masahide Nakamura To: Stephen Hemminger Cc: netdev@oss.sgi.com, linux-net@vger.kernel.org, nakam@linux-ipv6.org Subject: [PATCH] [iproute2] XFRM: using flush message type Message-Id: <20040906164640.19710b12@localhost> X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8434 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: nakam@linux-ipv6.org Precedence: bulk X-list: netdev Kernel has flush message types for XFRM's policy/state so I've fixed to use it in which case no argument are specified after "flush" in the command line. Please apply a patch below. The ChangeSet is also available at: # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/09/02 22:58:16+09:00 nakam@linux-ipv6.org # use flush message types. # # ip/xfrm_state.c # 2004/09/02 22:58:11+09:00 nakam@linux-ipv6.org +37 -3 # use XFRM_MSG_FLUSHSA message type in flushing without any other # arguments. # # ip/xfrm_policy.c # 2004/09/02 22:58:11+09:00 nakam@linux-ipv6.org +33 -2 # use XFRM_MSG_FLUSHPOLICY message type in flushing without any other # arguments. # # include/utils.h # 2004/09/02 22:58:10+09:00 nakam@linux-ipv6.org +3 -0 # add IPSEC_PROTO_ANY in kernel's include/linux/ipsec.h. # diff -Nru a/include/utils.h b/include/utils.h --- a/include/utils.h 2004-09-02 23:05:20 +09:00 +++ b/include/utils.h 2004-09-02 23:05:20 +09:00 @@ -25,6 +25,9 @@ #ifndef IPPROTO_COMP #define IPPROTO_COMP 108 #endif +#ifndef IPSEC_PROTO_ANY +#define IPSEC_PROTO_ANY 255 +#endif #define SPRINT_BSIZE 64 #define SPRINT_BUF(x) char x[SPRINT_BSIZE] diff -Nru a/ip/xfrm_policy.c b/ip/xfrm_policy.c --- a/ip/xfrm_policy.c 2004-09-02 23:05:20 +09:00 +++ b/ip/xfrm_policy.c 2004-09-02 23:05:20 +09:00 @@ -680,6 +680,33 @@ exit(0); } +static int xfrm_policy_flush_all(void) +{ + struct rtnl_handle rth; + struct { + struct nlmsghdr n; + } req; + + memset(&req, 0, sizeof(req)); + + req.n.nlmsg_len = NLMSG_LENGTH(0); /* nlmsg data is nothing */ + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = XFRM_MSG_FLUSHPOLICY; + + if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + exit(1); + + if (show_stats > 1) + fprintf(stderr, "Flush all\n"); + + if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) + exit(2); + + rtnl_close(&rth); + + return 0; +} + int do_xfrm_policy(int argc, char **argv) { if (argc < 1) @@ -698,8 +725,12 @@ return xfrm_policy_list_or_flush(argc-1, argv+1, 0); if (matches(*argv, "get") == 0) return xfrm_policy_get(argc-1, argv+1); - if (matches(*argv, "flush") == 0) - return xfrm_policy_list_or_flush(argc-1, argv+1, 1); + if (matches(*argv, "flush") == 0) { + if (argc-1 < 1) + return xfrm_policy_flush_all(); + else + return xfrm_policy_list_or_flush(argc-1, argv+1, 1); + } if (matches(*argv, "help") == 0) usage(); fprintf(stderr, "Command \"%s\" is unknown, try \"ip xfrm policy help\".\n", *argv); diff -Nru a/ip/xfrm_state.c b/ip/xfrm_state.c --- a/ip/xfrm_state.c 2004-09-02 23:05:20 +09:00 +++ b/ip/xfrm_state.c 2004-09-02 23:05:20 +09:00 @@ -563,7 +563,8 @@ char *idp = NULL; struct rtnl_handle rth; - filter.use = 1; + if(argc > 0) + filter.use = 1; filter.xsinfo.family = preferred_family; while (argc > 0) { @@ -661,6 +662,35 @@ exit(0); } +static int xfrm_state_flush_all(void) +{ + struct rtnl_handle rth; + struct { + struct nlmsghdr n; + struct xfrm_usersa_flush xsf; + } req; + + memset(&req, 0, sizeof(req)); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(req.xsf)); + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = XFRM_MSG_FLUSHSA; + req.xsf.proto = IPSEC_PROTO_ANY; + + if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + exit(1); + + if (show_stats > 1) + fprintf(stderr, "Flush all\n"); + + if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) + exit(2); + + rtnl_close(&rth); + + return 0; +} + int do_xfrm_state(int argc, char **argv) { if (argc < 1) @@ -679,8 +709,12 @@ return xfrm_state_list_or_flush(argc-1, argv+1, 0); if (matches(*argv, "get") == 0) return xfrm_state_get_or_delete(argc-1, argv+1, 0); - if (matches(*argv, "flush") == 0) - return xfrm_state_list_or_flush(argc-1, argv+1, 1); + if (matches(*argv, "flush") == 0) { + if (argc-1 < 1) + return xfrm_state_flush_all(); + else + return xfrm_state_list_or_flush(argc-1, argv+1, 1); + } if (matches(*argv, "help") == 0) usage(); fprintf(stderr, "Command \"%s\" is unknown, try \"ip xfrm state help\".\n", *argv); -- Masahide NAKAMURA From hch@lst.de Mon Sep 6 03:10:27 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 03:10:49 -0700 (PDT) Received: from mail.lst.de (verein.lst.de [213.95.11.210]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86AAO0E013305 for ; Mon, 6 Sep 2004 03:10:25 -0700 Received: from verein.lst.de (localhost [127.0.0.1]) by mail.lst.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i86AAE95017630 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Mon, 6 Sep 2004 12:10:14 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id i86AAEdd017628; Mon, 6 Sep 2004 12:10:14 +0200 Date: Mon, 6 Sep 2004 12:10:14 +0200 From: Christoph Hellwig To: netdev@oss.sgi.com, linux-scsi@vger.kernel.org Subject: [PATCH] remove iph5526 driver Message-ID: <20040906101014.GA17597@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-archive-position: 8438 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hch@lst.de Precedence: bulk X-list: netdev Content-Length: 193095 Lines: 5941 This driver is for totally obsolete early fibrechannel hardware and doesn't compile anymore since early 2.5.x. In addition it'll require a major rewrite to fit into the current framework for fc drivers. --- 1.91/drivers/net/Kconfig 2004-09-03 11:08:21 +02:00 +++ edited/drivers/net/Kconfig 2004-09-06 11:56:04 +02:00 @@ -2618,15 +2618,6 @@ adaptor below. You also should have said Y to "SCSI support" and "SCSI generic support". -config IPHASE5526 - tristate "Interphase 5526 Tachyon chipset based adapter support" - depends on NET_FC && SCSI && PCI && BROKEN - help - Say Y here if you have a Fibre Channel adaptor of this kind. - - To compile this driver as a module, choose M here: the module - will be called iph5526. - config SHAPER tristate "Traffic Shaper (EXPERIMENTAL)" depends on NETDEVICES && EXPERIMENTAL ===== drivers/net/fc/Makefile 1.5 vs edited ===== --- 1.5/drivers/net/fc/Makefile 2002-12-14 13:38:56 +01:00 +++ edited/drivers/net/fc/Makefile 2004-09-06 11:54:26 +02:00 @@ -1,8 +0,0 @@ -# -# Makefile for linux/drivers/net/fc -# -# 9 Aug 2000, Christoph Hellwig -# Rewritten to use lists instead of if-statements. -# - -obj-$(CONFIG_IPHASE5526) += iph5526.o ===== drivers/net/fc/iph5526.c 1.35 vs edited ===== --- 1.35/drivers/net/fc/iph5526.c 2004-06-19 17:54:02 +02:00 +++ edited/drivers/net/fc/iph5526.c 2004-09-06 11:53:59 +02:00 @@ -1,4645 +0,0 @@ -/********************************************************************** - * iph5526.c: IP/SCSI driver for the Interphase 5526 PCI Fibre Channel - * Card. - * Copyright (C) 1999 Vineet M Abraham - * - * 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. - *********************************************************************/ -/********************************************************************** -Log: -Vineet M Abraham -02.12.99 Support multiple cards. -03.15.99 Added Fabric support. -04.04.99 Added N_Port support. -04.15.99 Added SCSI support. -06.18.99 Added ABTS Protocol. -06.24.99 Fixed data corruption when multiple XFER_RDYs are received. -07.07.99 Can be loaded as part of the Kernel. Changed semaphores. Added - more checks before invalidating SEST entries. -07.08.99 Added Broadcast IP stuff and fixed an unicast timeout bug. -***********************************************************************/ -/* TODO: - R_T_TOV set to 15msec in Loop topology. Need to be 100 msec. - SMP testing. - Fix ADISC Tx before completing FLOGI. -*/ - -static const char *version = - "iph5526.c:v1.0 07.08.99 Vineet Abraham (vmabraham@hotmail.com)\n"; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* had the declarations for init_fcdev among - others + includes if_fcdevice.h */ - -#include "../../scsi/scsi.h" -#include -#include "../../fc4/fcp.h" - -#include -#include - -/* driver specific header files */ -#include "tach.h" -#include "tach_structs.h" -#include "iph5526_ip.h" -#include "iph5526_scsi.h" -#include "iph5526_novram.c" - -#define RUN_AT(x) (jiffies + (x)) - -#define DEBUG_5526_0 0 -#define DEBUG_5526_1 0 -#define DEBUG_5526_2 0 - -#if DEBUG_5526_0 -#define DPRINTK(format, a...) {printk("%s: ", fi->name); \ - printk(format, ##a); \ - printk("\n");} -#define ENTER(x) {printk("%s: ", fi->name); \ - printk("iph5526.c : entering %s()\n", x);} -#define LEAVE(x) {printk("%s: ", fi->name); \ - printk("iph5526.c : leaving %s()\n",x);} - -#else -#define DPRINTK(format, a...) {} -#define ENTER(x) {} -#define LEAVE(x) {} -#endif - -#if DEBUG_5526_1 -#define DPRINTK1(format, a...) {printk("%s: ", fi->name); \ - printk(format, ##a); \ - printk("\n");} -#else -#define DPRINTK1(format, a...) {} -#endif - -#if DEBUG_5526_2 -#define DPRINTK2(format, a...) {printk("%s: ", fi->name); \ - printk(format, ##a); \ - printk("\n");} -#else -#define DPRINTK2(format, a...) {} -#endif - -#define T_MSG(format, a...) {printk("%s: ", fi->name); \ - printk(format, ##a);\ - printk("\n");} - -#define ALIGNED_SFS_ADDR(addr) ((((unsigned long)(addr) + (SFS_BUFFER_SIZE - 1)) & ~(SFS_BUFFER_SIZE - 1)) - (unsigned long)(addr)) -#define ALIGNED_ADDR(addr, len) ((((unsigned long)(addr) + (len - 1)) & ~(len - 1)) - (unsigned long)(addr)) - - -static struct pci_device_id iph5526_pci_tbl[] = { - { PCI_VENDOR_ID_INTERPHASE, PCI_DEVICE_ID_INTERPHASE_5526, PCI_ANY_ID, PCI_ANY_ID, }, - { PCI_VENDOR_ID_INTERPHASE, PCI_DEVICE_ID_INTERPHASE_55x6, PCI_ANY_ID, PCI_ANY_ID, }, - { } /* Terminating entry */ -}; -MODULE_DEVICE_TABLE(pci, iph5526_pci_tbl); - -MODULE_LICENSE("GPL"); - -#define MAX_FC_CARDS 2 -static struct fc_info *fc[MAX_FC_CARDS+1]; -static unsigned int pci_irq_line; -static struct { - unsigned short vendor_id; - unsigned short device_id; - char *name; -} -clone_list[] __initdata = { - {PCI_VENDOR_ID_INTERPHASE, PCI_DEVICE_ID_INTERPHASE_5526, "Interphase Fibre Channel HBA"}, - {PCI_VENDOR_ID_INTERPHASE, PCI_DEVICE_ID_INTERPHASE_55x6, "Interphase Fibre Channel HBA"}, - {0,} -}; - -static irqreturn_t tachyon_interrupt(int irq, void *dev_id, struct pt_regs *regs); -static void tachyon_interrupt_handler(int irq, void* dev_id, struct pt_regs* regs); - -static int initialize_register_pointers(struct fc_info *fi); -void clean_up_memory(struct fc_info *fi); - -static int tachyon_init(struct fc_info *fi); -static int build_queues(struct fc_info *fi); -static void build_tachyon_header(struct fc_info *fi, u_int my_id, u_int r_ctl, u_int d_id, u_int type, u_char seq_id, u_char df_ctl, u_short ox_id, u_short rx_id, char *data); -static int get_free_header(struct fc_info *fi); -static void build_EDB(struct fc_info *fi, char *data, u_short flags, u_short len); -static int get_free_EDB(struct fc_info *fi); -static void build_ODB(struct fc_info *fi, u_char seq_id, u_int d_id, u_int len, u_int cntl, u_short mtu, u_short ox_id, u_short rx_id, int NW_header, int int_required, u_int frame_class); -static void write_to_tachyon_registers(struct fc_info *fi); -static void reset_latch(struct fc_info *fi); -static void reset_tachyon(struct fc_info *fi, u_int value); -static void take_tachyon_offline(struct fc_info *fi); -static void read_novram(struct fc_info *fi); -static void reset_ichip(struct fc_info *fi); -static void update_OCQ_indx(struct fc_info *fi); -static void update_IMQ_indx(struct fc_info *fi, int count); -static void update_SFSBQ_indx(struct fc_info *fi); -static void update_MFSBQ_indx(struct fc_info *fi, int count); -static void update_tachyon_header_indx(struct fc_info *fi); -static void update_EDB_indx(struct fc_info *fi); -static void handle_FM_interrupt(struct fc_info *fi); -static void handle_MFS_interrupt(struct fc_info *fi); -static void handle_OOO_interrupt(struct fc_info *fi); -static void handle_SFS_interrupt(struct fc_info *fi); -static void handle_OCI_interrupt(struct fc_info *fi); -static void handle_SFS_BUF_WARN_interrupt(struct fc_info *fi); -static void handle_MFS_BUF_WARN_interrupt(struct fc_info *fi); -static void handle_IMQ_BUF_WARN_interrupt(struct fc_info *fi); -static void handle_Unknown_Frame_interrupt(struct fc_info *fi); -static void handle_Busied_Frame_interrupt(struct fc_info *fi); -static void handle_Bad_SCSI_Frame_interrupt(struct fc_info *fi); -static void handle_Inbound_SCSI_Status_interrupt(struct fc_info *fi); -static void handle_Inbound_SCSI_Command_interrupt(struct fc_info *fi); -static void completion_message_handler(struct fc_info *fi, u_int imq_int_type); -static void fill_login_frame(struct fc_info *fi, u_int logi); - -static int tx_exchange(struct fc_info *fi, char *data, u_int len, u_int r_ctl, u_int type, u_int d_id, u_int mtu, int int_required, u_short ox_id, u_int frame_class); -static int tx_sequence(struct fc_info *fi, char *data, u_int len, u_int mtu, u_int d_id, u_short ox_id, u_short rx_id, u_char seq_id, int NW_flag, int int_required, u_int frame_class); -static int validate_login(struct fc_info *fi, u_int *base_ptr); -static void add_to_address_cache(struct fc_info *fi, u_int *base_ptr); -static void remove_from_address_cache(struct fc_info *fi, u_int *data, u_int cmnd_code); -static int node_logged_in_prev(struct fc_info *fi, u_int *buff_addr); -static int sid_logged_in(struct fc_info *fi, u_int s_id); -static struct fc_node_info *look_up_cache(struct fc_info *fi, char *data); -static int display_cache(struct fc_info *fi); - -static void tx_logi(struct fc_info *fi, u_int logi, u_int d_id); -static void tx_logi_acc(struct fc_info *fi, u_int logi, u_int d_id, u_short received_ox_id); -static void tx_prli(struct fc_info *fi, u_int command_code, u_int d_id, u_short received_ox_id); -static void tx_logo(struct fc_info *fi, u_int d_id, u_short received_ox_id); -static void tx_adisc(struct fc_info *fi, u_int cmnd_code, u_int d_id, u_short received_ox_id); -static void tx_ls_rjt(struct fc_info *fi, u_int d_id, u_short received_ox_id, u_short reason_code, u_short expln_code); -static u_int plogi_ok(struct fc_info *fi, u_int *buff_addr, int size); -static void tx_acc(struct fc_info *fi, u_int d_id, u_short received_ox_id); -static void tx_name_server_req(struct fc_info *fi, u_int req); -static void rscn_handler(struct fc_info *fi, u_int node_id); -static void tx_scr(struct fc_info *fi); -static void scr_timer(unsigned long data); -static void explore_fabric(struct fc_info *fi, u_int *buff_addr); -static void perform_adisc(struct fc_info *fi); -static void local_port_discovery(struct fc_info *fi); -static void add_to_ox_id_list(struct fc_info *fi, u_int transaction_id, u_int cmnd_code); -static u_int remove_from_ox_id_list(struct fc_info *fi, u_short received_ox_id); -static void add_display_cache_timer(struct fc_info *fi); - -/* Timers... */ -static void nos_ols_timer(unsigned long data); -static void loop_timer(unsigned long data); -static void fabric_explore_timer(unsigned long data); -static void port_discovery_timer(unsigned long data); -static void display_cache_timer(unsigned long data); - -/* SCSI Stuff */ -static int add_to_sest(struct fc_info *fi, Scsi_Cmnd *Cmnd, struct fc_node_info *ni); -static struct fc_node_info *resolve_target(struct fc_info *fi, u_char target); -static void update_FCP_CMND_indx(struct fc_info *fi); -static int get_free_SDB(struct fc_info *fi); -static void update_SDB_indx(struct fc_info *fi); -static void mark_scsi_sid(struct fc_info *fi, u_int *buff_addr, u_char action); -static void invalidate_SEST_entry(struct fc_info *fi, u_short received_ox_id); -static int abort_exchange(struct fc_info *fi, u_short ox_id); -static void flush_tachyon_cache(struct fc_info *fi, u_short ox_id); -static int get_scsi_oxid(struct fc_info *fi); -static void update_scsi_oxid(struct fc_info *fi); - -static Scsi_Host_Template driver_template = IPH5526_SCSI_FC; - -static void iph5526_timeout(struct net_device *dev); - -static int iph5526_probe_pci(struct net_device *dev); - -int __init iph5526_probe(struct net_device *dev) -{ - if (iph5526_probe_pci(dev) == 0) - return 0; - return -ENODEV; -} - -static int __init iph5526_probe_pci(struct net_device *dev) -{ - struct fc_info *fi = dev->priv; - fi->dev = dev; - dev->base_addr = fi->base_addr; - dev->irq = fi->irq; - if (dev->priv == NULL) - dev->priv = fi; - fcdev_init(dev); - /* Assign ur MAC address. - */ - dev->dev_addr[0] = (fi->g.my_port_name_high & 0x0000FF00) >> 8; - dev->dev_addr[1] = fi->g.my_port_name_high; - dev->dev_addr[2] = (fi->g.my_port_name_low & 0xFF000000) >> 24; - dev->dev_addr[3] = (fi->g.my_port_name_low & 0x00FF0000) >> 16; - dev->dev_addr[4] = (fi->g.my_port_name_low & 0x0000FF00) >> 8; - dev->dev_addr[5] = fi->g.my_port_name_low; - display_cache(fi); - return 0; -} - -static int __init fcdev_init(struct net_device *dev) -{ - SET_MODULE_OWNER(dev); - dev->open = iph5526_open; - dev->stop = iph5526_close; - dev->hard_start_xmit = iph5526_send_packet; - dev->get_stats = iph5526_get_stats; - dev->set_multicast_list = NULL; - dev->change_mtu = iph5526_change_mtu; - dev->tx_timeout = iph5526_timeout; - dev->watchdog_timeo = 5*HZ; - return 0; -} - -/* initialize tachyon and take it OnLine */ -static int tachyon_init(struct fc_info *fi) -{ - ENTER("tachyon_init"); - if (build_queues(fi) == 0) { - T_MSG("build_queues() failed"); - return 0; - } - - /* Retrieve your port/node name. - */ - read_novram(fi); - - reset_ichip(fi); - - reset_tachyon(fi, SOFTWARE_RESET); - - LEAVE("tachyon_init"); - return 1; -} - -/* Build the 4 Qs - IMQ, OCQ, MFSBQ, SFSBQ */ -/* Lots of dma_pages needed as Tachyon DMAs almost everything into - * host memory. - */ -static int build_queues(struct fc_info *fi) -{ -int i,j; -u_char *addr; - ENTER("build_queues"); - /* Initializing Queue Variables. - */ - fi->q.ptr_host_ocq_cons_indx = NULL; - fi->q.ptr_host_hpcq_cons_indx = NULL; - fi->q.ptr_host_imq_prod_indx = NULL; - - fi->q.ptr_ocq_base = NULL; - fi->q.ocq_len = 0; - fi->q.ocq_end = 0; - fi->q.ocq_prod_indx = 0; - - fi->q.ptr_imq_base = NULL; - fi->q.imq_len = 0; - fi->q.imq_end = 0; - fi->q.imq_cons_indx = 0; - fi->q.imq_prod_indx = 0; - - fi->q.ptr_mfsbq_base = NULL; - fi->q.mfsbq_len = 0; - fi->q.mfsbq_end = 0; - fi->q.mfsbq_prod_indx = 0; - fi->q.mfsbq_cons_indx = 0; - fi->q.mfsbuff_len = 0; - fi->q.mfsbuff_end = 0; - fi->g.mfs_buffer_count = 0; - - fi->q.ptr_sfsbq_base = NULL; - fi->q.sfsbq_len = 0; - fi->q.sfsbq_end = 0; - fi->q.sfsbq_prod_indx = 0; - fi->q.sfsbq_cons_indx = 0; - fi->q.sfsbuff_len = 0; - fi->q.sfsbuff_end = 0; - - fi->q.sdb_indx = 0; - fi->q.fcp_cmnd_indx = 0; - - fi->q.ptr_edb_base = NULL; - fi->q.edb_buffer_indx = 0; - fi->q.ptr_tachyon_header_base = NULL; - fi->q.tachyon_header_indx = 0; - fi->node_info_list = NULL; - fi->ox_id_list = NULL; - fi->g.loop_up = FALSE; - fi->g.ptp_up = FALSE; - fi->g.link_up = FALSE; - fi->g.fabric_present = FALSE; - fi->g.n_port_try = FALSE; - fi->g.dont_init = FALSE; - fi->g.nport_timer_set = FALSE; - fi->g.lport_timer_set = FALSE; - fi->g.no_of_targets = 0; - fi->g.sem = 0; - fi->g.perform_adisc = FALSE; - fi->g.e_i = 0; - - /* build OCQ */ - if ( (fi->q.ptr_ocq_base = (u_int *)__get_free_pages(GFP_KERNEL, 0)) == 0) { - T_MSG("failed to get OCQ page"); - return 0; - } - /* set up the OCQ structures */ - for (i = 0; i < OCQ_LENGTH; i++) - fi->q.ptr_odb[i] = fi->q.ptr_ocq_base + NO_OF_ENTRIES*i; - - /* build IMQ */ - if ( (fi->q.ptr_imq_base = (u_int *)__get_free_pages(GFP_KERNEL, 0)) == 0) { - T_MSG("failed to get IMQ page"); - return 0; - } - for (i = 0; i < IMQ_LENGTH; i++) - fi->q.ptr_imqe[i] = fi->q.ptr_imq_base + NO_OF_ENTRIES*i; - - /* build MFSBQ */ - if ( (fi->q.ptr_mfsbq_base = (u_int *)__get_free_pages(GFP_KERNEL, 0)) == 0) { - T_MSG("failed to get MFSBQ page"); - return 0; - } - memset((char *)fi->q.ptr_mfsbq_base, 0, MFSBQ_LENGTH * 32); - /* Allocate one huge chunk of memory... helps while reassembling - * frames. - */ - if ( (addr = (u_char *)__get_free_pages(GFP_KERNEL, 5) ) == 0) { - T_MSG("failed to get MFSBQ page"); - return 0; - } - /* fill in addresses of empty buffers */ - for (i = 0; i < MFSBQ_LENGTH; i++) { - for (j = 0; j < NO_OF_ENTRIES; j++) { - *(fi->q.ptr_mfsbq_base + i*NO_OF_ENTRIES + j) = htonl(virt_to_bus(addr)); - addr += MFS_BUFFER_SIZE; - } - } - - /* The number of entries in each MFS buffer is 8. There are 8 - * MFS buffers. That leaves us with 4096-256 bytes. We use them - * as temporary space for ELS frames. This is done to make sure that - * the addresses are aligned. - */ - fi->g.els_buffer[0] = fi->q.ptr_mfsbq_base + MFSBQ_LENGTH*NO_OF_ENTRIES; - for (i = 1; i < MAX_PENDING_FRAMES; i++) - fi->g.els_buffer[i] = fi->g.els_buffer[i-1] + 64; - - /* build SFSBQ */ - if ( (fi->q.ptr_sfsbq_base = (u_int *)__get_free_pages(GFP_KERNEL, 0)) == 0) { - T_MSG("failed to get SFSBQ page"); - return 0; - } - memset((char *)fi->q.ptr_sfsbq_base, 0, SFSBQ_LENGTH * 32); - /* fill in addresses of empty buffers */ - for (i = 0; i < SFSBQ_LENGTH; i++) - for (j = 0; j < NO_OF_ENTRIES; j++){ - addr = kmalloc(SFS_BUFFER_SIZE*2, GFP_KERNEL); - if (addr == NULL){ - T_MSG("ptr_sfs_buffer : memory not allocated"); - return 0; - } - else { - int offset = ALIGNED_SFS_ADDR(addr); - memset((char *)addr, 0, SFS_BUFFER_SIZE); - fi->q.ptr_sfs_buffers[i*NO_OF_ENTRIES +j] = (u_int *)addr; - addr += offset; - *(fi->q.ptr_sfsbq_base + i*NO_OF_ENTRIES + j) = htonl(virt_to_bus(addr)); - } - } - - /* The number of entries in each SFS buffer is 8. There are 8 - * MFS buffers. That leaves us with 4096-256 bytes. We use them - * as temporary space for ARP frames. This is done inorder to - * support HW_Types of 0x1 and 0x6. - */ - fi->g.arp_buffer = (char *)fi->q.ptr_sfsbq_base + SFSBQ_LENGTH*NO_OF_ENTRIES*4; - - /* build EDB */ - if ((fi->q.ptr_edb_base = (u_int *)__get_free_pages(GFP_KERNEL, 5) ) == 0) { - T_MSG("failed to get EDB page"); - return 0; - } - for (i = 0; i < EDB_LEN; i++) - fi->q.ptr_edb[i] = fi->q.ptr_edb_base + 2*i; - - /* build SEST */ - - /* OX_IDs range from 0x0 - 0x4FFF. - */ - if ((fi->q.ptr_sest_base = (u_int *)__get_free_pages(GFP_KERNEL, 5)) == 0) { - T_MSG("failed to get SEST page"); - return 0; - } - for (i = 0; i < SEST_LENGTH; i++) - fi->q.ptr_sest[i] = fi->q.ptr_sest_base + NO_OF_ENTRIES*i; - - if ((fi->q.ptr_sdb_base = (u_int *)__get_free_pages(GFP_KERNEL, 5)) == 0) { - T_MSG("failed to get SDB page"); - return 0; - } - for (i = 0 ; i < NO_OF_SDB_ENTRIES; i++) - fi->q.ptr_sdb_slot[i] = fi->q.ptr_sdb_base + (SDB_SIZE/4)*i; - - if ((fi->q.ptr_fcp_cmnd_base = (u_int *)__get_free_pages(GFP_KERNEL, 0)) == 0) { - T_MSG("failed to get FCP_CMND page"); - return 0; - } - for (i = 0; i < NO_OF_FCP_CMNDS; i++) - fi->q.ptr_fcp_cmnd[i] = fi->q.ptr_fcp_cmnd_base + NO_OF_ENTRIES*i; - - /* Allocate space for Tachyon Header as well... - */ - if ((fi->q.ptr_tachyon_header_base = (u_int *)__get_free_pages(GFP_KERNEL, 0) ) == 0) { - T_MSG("failed to get tachyon_header page"); - return 0; - } - for (i = 0; i < NO_OF_TACH_HEADERS; i++) - fi->q.ptr_tachyon_header[i] = fi->q.ptr_tachyon_header_base + 16*i; - - /* Allocate memory for indices. - * Indices should be aligned on 32 byte boundaries. - */ - fi->q.host_ocq_cons_indx = kmalloc(2*32, GFP_KERNEL); - if (fi->q.host_ocq_cons_indx == NULL){ - T_MSG("fi->q.host_ocq_cons_indx : memory not allocated"); - return 0; - } - fi->q.ptr_host_ocq_cons_indx = fi->q.host_ocq_cons_indx; - if ((u_long)(fi->q.host_ocq_cons_indx) % 32) - fi->q.host_ocq_cons_indx++; - - fi->q.host_hpcq_cons_indx = kmalloc(2*32, GFP_KERNEL); - if (fi->q.host_hpcq_cons_indx == NULL){ - T_MSG("fi->q.host_hpcq_cons_indx : memory not allocated"); - return 0; - } - fi->q.ptr_host_hpcq_cons_indx= fi->q.host_hpcq_cons_indx; - if ((u_long)(fi->q.host_hpcq_cons_indx) % 32) - fi->q.host_hpcq_cons_indx++; - - fi->q.host_imq_prod_indx = kmalloc(2*32, GFP_KERNEL); - if (fi->q.host_imq_prod_indx == NULL){ - T_MSG("fi->q.host_imq_prod_indx : memory not allocated"); - return 0; - } - fi->q.ptr_host_imq_prod_indx = fi->q.host_imq_prod_indx; - if ((u_long)(fi->q.host_imq_prod_indx) % 32) - fi->q.host_imq_prod_indx++; - - LEAVE("build_queues"); - return 1; -} - - -static void write_to_tachyon_registers(struct fc_info *fi) -{ -u_int bus_addr, bus_indx_addr, i; - - ENTER("write_to_tachyon_registers"); - - /* Clear Queues each time Tachyon is reset */ - memset((char *)fi->q.ptr_ocq_base, 0, OCQ_LENGTH * 32); - memset((char *)fi->q.ptr_imq_base, 0, IMQ_LENGTH * 32); - memset((char *)fi->q.ptr_edb_base, 0, EDB_LEN * 8); - memset((char *)fi->q.ptr_sest_base, 0, SEST_LENGTH * 32); - memset((char *)fi->q.ptr_sdb_base, 0, NO_OF_SDB_ENTRIES * SDB_SIZE); - memset((char *)fi->q.ptr_tachyon_header_base, 0xFF, NO_OF_TACH_HEADERS * TACH_HEADER_SIZE); - for (i = 0; i < SEST_LENGTH; i++) - fi->q.free_scsi_oxid[i] = OXID_AVAILABLE; - for (i = 0; i < NO_OF_SDB_ENTRIES; i++) - fi->q.sdb_slot_status[i] = SDB_FREE; - - take_tachyon_offline(fi); - writel(readl(fi->t_r.ptr_tach_config_reg) | SCSI_ENABLE | WRITE_STREAM_SIZE | READ_STREAM_SIZE | PARITY_EVEN | OOO_REASSEMBLY_DISABLE, fi->t_r.ptr_tach_config_reg); - - /* Write OCQ registers */ - fi->q.ocq_prod_indx = 0; - *(fi->q.host_ocq_cons_indx) = 0; - - /* The Tachyon needs to be passed the "real" address */ - bus_addr = virt_to_bus(fi->q.ptr_ocq_base); - writel(bus_addr, fi->t_r.ptr_ocq_base_reg); - writel(OCQ_LENGTH - 1, fi->t_r. ptr_ocq_len_reg); - bus_indx_addr = virt_to_bus(fi->q.host_ocq_cons_indx); - writel(bus_indx_addr, fi->t_r.ptr_ocq_cons_indx_reg); - - /* Write IMQ registers */ - fi->q.imq_cons_indx = 0; - *(fi->q.host_imq_prod_indx) = 0; - bus_addr = virt_to_bus(fi->q.ptr_imq_base); - writel(bus_addr, fi->t_r.ptr_imq_base_reg); - writel(IMQ_LENGTH - 1, fi->t_r.ptr_imq_len_reg); - bus_indx_addr = virt_to_bus(fi->q.host_imq_prod_indx); - writel(bus_indx_addr, fi->t_r.ptr_imq_prod_indx_reg); - - /* Write MFSBQ registers */ - fi->q.mfsbq_prod_indx = MFSBQ_LENGTH - 1; - fi->q.mfsbuff_end = MFS_BUFFER_SIZE - 1; - fi->q.mfsbq_cons_indx = 0; - bus_addr = virt_to_bus(fi->q.ptr_mfsbq_base); - writel(bus_addr, fi->t_r.ptr_mfsbq_base_reg); - writel(MFSBQ_LENGTH - 1, fi->t_r.ptr_mfsbq_len_reg); - writel(fi->q.mfsbuff_end, fi->t_r.ptr_mfsbuff_len_reg); - /* Do this last as tachyon will prefetch the - * first entry as soon as we write to it. - */ - writel(fi->q.mfsbq_prod_indx, fi->t_r.ptr_mfsbq_prod_reg); - - /* Write SFSBQ registers */ - fi->q.sfsbq_prod_indx = SFSBQ_LENGTH - 1; - fi->q.sfsbuff_end = SFS_BUFFER_SIZE - 1; - fi->q.sfsbq_cons_indx = 0; - bus_addr = virt_to_bus(fi->q.ptr_sfsbq_base); - writel(bus_addr, fi->t_r.ptr_sfsbq_base_reg); - writel(SFSBQ_LENGTH - 1, fi->t_r.ptr_sfsbq_len_reg); - writel(fi->q.sfsbuff_end, fi->t_r.ptr_sfsbuff_len_reg); - /* Do this last as tachyon will prefetch the first - * entry as soon as we write to it. - */ - writel(fi->q.sfsbq_prod_indx, fi->t_r.ptr_sfsbq_prod_reg); - - /* Write SEST registers */ - bus_addr = virt_to_bus(fi->q.ptr_sest_base); - writel(bus_addr, fi->t_r.ptr_sest_base_reg); - writel(SEST_LENGTH - 1, fi->t_r.ptr_sest_len_reg); - /* the last 2 bits _should_ be 1 */ - writel(SEST_BUFFER_SIZE - 1, fi->t_r.ptr_scsibuff_len_reg); - - /* write AL_TIME & E_D_TOV into the registers */ - writel(TOV_VALUES, fi->t_r.ptr_fm_tov_reg); - /* Tell Tachyon to pick a Soft Assigned AL_PA */ - writel(LOOP_INIT_SOFT_ADDRESS, fi->t_r.ptr_fm_config_reg); - - /* Read the WWN from EEPROM . But, for now we assign it here. */ - writel(WORLD_WIDE_NAME_LOW, fi->t_r.ptr_fm_wwn_low_reg); - writel(WORLD_WIDE_NAME_HIGH, fi->t_r.ptr_fm_wwn_hi_reg); - - DPRINTK1("TACHYON initializing as L_Port...\n"); - writel(INITIALIZE, fi->t_r.ptr_fm_control_reg); - - LEAVE("write_to_tachyon_registers"); -} - - -static irqreturn_t tachyon_interrupt(int irq, void* dev_id, struct pt_regs* regs) -{ -struct Scsi_Host *host = dev_id; -struct iph5526_hostdata *hostdata = (struct iph5526_hostdata *)host->hostdata; -struct fc_info *fi = hostdata->fi; -u_long flags; - spin_lock_irqsave(&fi->fc_lock, flags); - tachyon_interrupt_handler(irq, dev_id, regs); - spin_unlock_irqrestore(&fi->fc_lock, flags); - return IRQ_HANDLED; -} - -static void tachyon_interrupt_handler(int irq, void* dev_id, struct pt_regs* regs) -{ -struct Scsi_Host *host = dev_id; -struct iph5526_hostdata *hostdata = (struct iph5526_hostdata *)host->hostdata; -struct fc_info *fi = hostdata->fi; -u_int *ptr_imq_entry; -u_int imq_int_type, current_IMQ_index = 0, prev_IMQ_index; -int index, no_of_entries = 0; - - DPRINTK("\n"); - ENTER("tachyon_interrupt"); - if (fi->q.host_imq_prod_indx != NULL) { - current_IMQ_index = ntohl(*(fi->q.host_imq_prod_indx)); - } - else { - /* _Should not_ happen */ - T_MSG("IMQ_indx NULL. DISABLING INTERRUPTS!!!\n"); - writel(0x0, fi->i_r.ptr_ichip_hw_control_reg); - } - - if (current_IMQ_index > fi->q.imq_cons_indx) - no_of_entries = current_IMQ_index - fi->q.imq_cons_indx; - else - if (current_IMQ_index < fi->q.imq_cons_indx) - no_of_entries = IMQ_LENGTH - (fi->q.imq_cons_indx - current_IMQ_index); - - if (no_of_entries == 0) { - u_int ichip_status; - ichip_status = readl(fi->i_r.ptr_ichip_hw_status_reg); - if (ichip_status & 0x20) { - /* Should _never_ happen. Might require a hard reset */ - T_MSG("Too bad... PCI Bus Error. Resetting (i)chip"); - reset_ichip(fi); - T_MSG("DISABLING INTERRUPTS!!!\n"); - writel(0x0, fi->i_r.ptr_ichip_hw_control_reg); - } - } - - prev_IMQ_index = current_IMQ_index; - for (index = 0; index < no_of_entries; index++) { - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - imq_int_type = ntohl(*ptr_imq_entry); - - completion_message_handler(fi, imq_int_type); - if ((fi->g.link_up == FALSE) && ((imq_int_type == MFS_BUF_WARN) || (imq_int_type == SFS_BUF_WARN) || (imq_int_type == IMQ_BUF_WARN))) - break; - update_IMQ_indx(fi, 1); - - /* Check for more entries */ - current_IMQ_index = ntohl(*(fi->q.host_imq_prod_indx)); - if (current_IMQ_index != prev_IMQ_index) { - no_of_entries++; - prev_IMQ_index = current_IMQ_index; - } - } /*end of for loop*/ - LEAVE("tachyon_interrupt"); - return; -} - - -static void handle_SFS_BUF_WARN_interrupt(struct fc_info *fi) -{ -int i; - ENTER("handle_SFS_BUF_WARN_interrupt"); - if (fi->g.link_up == FALSE) { - reset_tachyon(fi, SOFTWARE_RESET); - return; - } - /* Free up all but one entry in the Q. - */ - for (i = 0; i < ((SFSBQ_LENGTH - 1) * NO_OF_ENTRIES); i++) { - handle_SFS_interrupt(fi); - update_IMQ_indx(fi, 1); - } - LEAVE("handle_SFS_BUF_WARN_interrupt"); -} - -/* Untested_Code_Begin */ -static void handle_MFS_BUF_WARN_interrupt(struct fc_info *fi) -{ -int i; - ENTER("handle_MFS_BUF_WARN_interrupt"); - if (fi->g.link_up == FALSE) { - reset_tachyon(fi, SOFTWARE_RESET); - return; - } - /* FIXME: freeing up 8 entries. - */ - for (i = 0; i < NO_OF_ENTRIES; i++) { - handle_MFS_interrupt(fi); - update_IMQ_indx(fi, 1); - } - LEAVE("handle_MFS_BUF_WARN_interrupt"); -} -/*Untested_Code_End */ - -static void handle_IMQ_BUF_WARN_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry; -u_int imq_int_type, current_IMQ_index = 0, temp_imq_cons_indx; -int index, no_of_entries = 0; - - ENTER("handle_IMQ_BUF_WARN_interrupt"); - if (fi->g.link_up == FALSE) { - reset_tachyon(fi, SOFTWARE_RESET); - return; - } - current_IMQ_index = ntohl(*(fi->q.host_imq_prod_indx)); - - if (current_IMQ_index > fi->q.imq_cons_indx) - no_of_entries = current_IMQ_index - fi->q.imq_cons_indx; - else - if (current_IMQ_index < fi->q.imq_cons_indx) - no_of_entries = IMQ_LENGTH - (fi->q.imq_cons_indx - current_IMQ_index); - /* We don't want to look at the same IMQ entry again. - */ - temp_imq_cons_indx = fi->q.imq_cons_indx + 1; - if (no_of_entries != 0) - no_of_entries -= 1; - for (index = 0; index < no_of_entries; index++) { - ptr_imq_entry = fi->q.ptr_imqe[temp_imq_cons_indx]; - imq_int_type = ntohl(*ptr_imq_entry); - if (imq_int_type != IMQ_BUF_WARN) - completion_message_handler(fi, imq_int_type); - temp_imq_cons_indx++; - if (temp_imq_cons_indx == IMQ_LENGTH) - temp_imq_cons_indx = 0; - } /*end of for loop*/ - if (no_of_entries != 0) - update_IMQ_indx(fi, no_of_entries); - LEAVE("handle_IMQ_BUF_WARN_interrupt"); -} - -static void completion_message_handler(struct fc_info *fi, u_int imq_int_type) -{ - switch(imq_int_type) { - case OUTBOUND_COMPLETION: - DPRINTK("OUTBOUND_COMPLETION message received"); - break; - case OUTBOUND_COMPLETION_I: - DPRINTK("OUTBOUND_COMPLETION_I message received"); - handle_OCI_interrupt(fi); - break; - case OUT_HI_PRI_COMPLETION: - DPRINTK("OUT_HI_PRI_COMPLETION message received"); - break; - case OUT_HI_PRI_COMPLETION_I: - DPRINTK("OUT_HI_PRI_COMPLETION_I message received"); - break; - case INBOUND_MFS_COMPLETION: - DPRINTK("INBOUND_MFS_COMPLETION message received"); - handle_MFS_interrupt(fi); - break; - case INBOUND_OOO_COMPLETION: - DPRINTK("INBOUND_OOO_COMPLETION message received"); - handle_OOO_interrupt(fi); - break; - case INBOUND_SFS_COMPLETION: - DPRINTK("INBOUND_SFS_COMPLETION message received"); - handle_SFS_interrupt(fi); - break; - case INBOUND_UNKNOWN_FRAME_I: - DPRINTK("INBOUND_UNKNOWN_FRAME message received"); - handle_Unknown_Frame_interrupt(fi); - break; - case INBOUND_BUSIED_FRAME: - DPRINTK("INBOUND_BUSIED_FRAME message received"); - handle_Busied_Frame_interrupt(fi); - break; - case FRAME_MGR_INTERRUPT: - DPRINTK("FRAME_MGR_INTERRUPT message received"); - handle_FM_interrupt(fi); - break; - case READ_STATUS: - DPRINTK("READ_STATUS message received"); - break; - case SFS_BUF_WARN: - DPRINTK("SFS_BUF_WARN message received"); - handle_SFS_BUF_WARN_interrupt(fi); - break; - case MFS_BUF_WARN: - DPRINTK("MFS_BUF_WARN message received"); - handle_MFS_BUF_WARN_interrupt(fi); - break; - case IMQ_BUF_WARN: - DPRINTK("IMQ_BUF_WARN message received"); - handle_IMQ_BUF_WARN_interrupt(fi); - break; - case INBOUND_C1_TIMEOUT: - DPRINTK("INBOUND_C1_TIMEOUT message received"); - break; - case BAD_SCSI_FRAME: - DPRINTK("BAD_SCSI_FRAME message received"); - handle_Bad_SCSI_Frame_interrupt(fi); - break; - case INB_SCSI_STATUS_COMPLETION: - DPRINTK("INB_SCSI_STATUS_COMPL message received"); - handle_Inbound_SCSI_Status_interrupt(fi); - break; - case INBOUND_SCSI_COMMAND: - DPRINTK("INBOUND_SCSI_COMMAND message received"); - handle_Inbound_SCSI_Command_interrupt(fi); - break; - case INBOUND_SCSI_DATA_COMPLETION: - DPRINTK("INBOUND_SCSI_DATA message received"); - /* Only for targets */ - break; - default: - T_MSG("DEFAULT message received, type = %x", imq_int_type); - return; - } - reset_latch(fi); -} - -static void handle_OCI_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry; -u_long transaction_id = 0; -unsigned short status, seq_count, transmitted_ox_id; -struct Scsi_Host *host = fi->host; -struct iph5526_hostdata *hostdata = (struct iph5526_hostdata *)host->hostdata; -Scsi_Cmnd *Cmnd; -u_int tag; - - ENTER("handle_OCI_interrupt"); - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - transaction_id = ntohl(*(ptr_imq_entry + 1)); - status = ntohl(*(ptr_imq_entry + 2)) >> 16; - seq_count = ntohl(*(ptr_imq_entry + 3)); - DPRINTK("transaction_id= %x", (u_int)transaction_id); - tag = transaction_id & 0xFFFF0000; - transmitted_ox_id = transaction_id; - - /* The INT could be either due to TIME_OUT | BAD_ALPA. - * But we check only for TimeOuts. Bad AL_PA will - * caught by FM_interrupt handler. - */ - - if ((status == OCM_TIMEOUT_OR_BAD_ALPA) && (!fi->g.port_discovery) && (!fi->g.perform_adisc)){ - DPRINTK("Frame TimeOut on OX_ID = %x", (u_int)transaction_id); - - /* Is it a SCSI frame that is timing out ? Not a very good check... - */ - if ((transmitted_ox_id <= MAX_SCSI_OXID) && ((tag == FC_SCSI_BAD_TARGET) || (tag < 0x00FF0000))) { - /* If it is a Bad AL_PA, we report it as BAD_TARGET. - * Else, we allow the command to time-out. A Link - * re-initialization could be taking place. - */ - if (tag == FC_SCSI_BAD_TARGET) { - Cmnd = hostdata->cmnd_handler[transmitted_ox_id & MAX_SCSI_XID]; - hostdata->cmnd_handler[transmitted_ox_id & MAX_SCSI_XID] = NULL; - if (Cmnd != NULL) { - Cmnd->result = DID_BAD_TARGET << 16; - (*Cmnd->scsi_done) (Cmnd); - } - else - T_MSG("NULL Command out of handler!"); - } /* if Bad Target */ - else { - u_char missing_target = tag >> 16; - struct fc_node_info *q = fi->node_info_list; - /* A Node that we thought was logged in has gone - * away. We are the optimistic kind and we keep - * hoping that our dear little Target will come back - * to us. For now we log him out. - */ - DPRINTK2("Missing Target = %d", missing_target); - while (q != NULL) { - if (q->target_id == missing_target) { - T_MSG("Target %d Logged out", q->target_id); - q->login = LOGIN_ATTEMPTED; - if (fi->num_nodes > 0) - fi->num_nodes--; - tx_logi(fi, ELS_PLOGI, q->d_id); - break; - } - else - q = q->next; - } - } - } /* End of SCSI frame timing out. */ - else { - if (seq_count > 1) { - /* An IP frame was transmitted to a Bad AL_PA. Free up - * the skb used. - */ - dev_kfree_skb_irq((struct sk_buff *)(bus_to_virt(transaction_id))); - netif_wake_queue(fi->dev); - } - } /* End of IP frame timing out. */ - } /* End of frame timing out. */ - else { - /* Frame was transmitted successfully. Check if it was an ELS - * frame or an IP frame or a Bad_Target_Notification frame (in - * case of a ptp_link). Ugly! - */ - if ((status == 0) && (seq_count == 0)) { - u_int tag = transaction_id & 0xFFFF0000; - /* Continue with port discovery after an ELS is successfully - * transmitted. (status == 0). - */ - DPRINTK("tag = %x", tag); - switch(tag) { - case ELS_FLOGI: - /* Letz use the Name Server instead */ - fi->g.explore_fabric = TRUE; - fi->g.port_discovery = FALSE; - fi->g.alpa_list_index = MAX_NODES; - add_to_ox_id_list(fi, transaction_id, tag); - break; - case ELS_PLOGI: - if (fi->g.fabric_present && (fi->g.name_server == FALSE)) - add_to_ox_id_list(fi,transaction_id,ELS_NS_PLOGI); - else - add_to_ox_id_list(fi, transaction_id, tag); - break; - case FC_SCSI_BAD_TARGET: - Cmnd = hostdata->cmnd_handler[transmitted_ox_id & MAX_SCSI_XID]; - hostdata->cmnd_handler[transmitted_ox_id & MAX_SCSI_XID] = NULL; - if (Cmnd != NULL) { - Cmnd->result = DID_BAD_TARGET << 16; - (*Cmnd->scsi_done) (Cmnd); - } - else - T_MSG("NULL Command out of handler!"); - break; - default: - add_to_ox_id_list(fi, transaction_id, tag); - } - - if (fi->g.alpa_list_index >= MAX_NODES) { - if (fi->g.port_discovery == TRUE) { - fi->g.port_discovery = FALSE; - add_display_cache_timer(fi); - } - fi->g.alpa_list_index = MAX_NODES; - } - if (fi->g.port_discovery == TRUE) - local_port_discovery(fi); - } - else { - /* An IP frame has been successfully transmitted. - * Free the skb that was used for this IP frame. - */ - if ((status == 0) && (seq_count > 1)) { - dev_kfree_skb_irq((struct sk_buff *)(bus_to_virt(transaction_id))); - netif_wake_queue(fi->dev); - } - } - } - LEAVE("handle_OCI_interrupt"); -} - -/* Right now we discard OOO frames */ -static void handle_OOO_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry; -int queue_indx, offset, payload_size; -int no_of_buffers = 1; /* header is in a separate buffer */ - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - payload_size = ntohl(*(ptr_imq_entry + 2)) - TACHYON_HEADER_LEN; - /* Calculate total number of buffers */ - no_of_buffers += payload_size / MFS_BUFFER_SIZE; - if (payload_size % MFS_BUFFER_SIZE) - no_of_buffers++; - - /* provide Tachyon will another set of buffers */ - fi->g.mfs_buffer_count += no_of_buffers; - if (fi->g.mfs_buffer_count >= NO_OF_ENTRIES) { - int count = fi->g.mfs_buffer_count / NO_OF_ENTRIES; - fi->g.mfs_buffer_count -= NO_OF_ENTRIES * count; - update_MFSBQ_indx(fi, count); - } -} - -static void handle_MFS_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry, *buff_addr; -u_int type_of_frame, s_id; -int queue_indx, offset, payload_size, starting_indx, starting_offset; -u_short received_ox_id; -int no_of_buffers = 1; /* header is in a separate buffer */ -struct sk_buff *skb; -int wrap_around = FALSE, no_of_wrap_buffs = NO_OF_ENTRIES - 1; - ENTER("handle_MFS_interrupt"); - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - DPRINTK("queue_indx = %d, offset = %d\n", queue_indx, offset); - payload_size = ntohl(*(ptr_imq_entry + 2)) - TACHYON_HEADER_LEN; - DPRINTK("payload_size = %d", payload_size); - /* Calculate total number of buffers */ - no_of_buffers += payload_size / MFS_BUFFER_SIZE; - if (payload_size % MFS_BUFFER_SIZE) - no_of_buffers++; - DPRINTK("no_of_buffers = %d", no_of_buffers); - - if ((no_of_buffers - 1) <= offset) { - starting_offset = offset - (no_of_buffers - 1); - starting_indx = queue_indx; - } - else { - int temp = no_of_buffers - (offset + 1); - int no_of_queues = temp / NO_OF_ENTRIES; - starting_offset = temp % NO_OF_ENTRIES; - if (starting_offset != 0) { - no_of_wrap_buffs = starting_offset - 1; //exclude header - starting_offset = NO_OF_ENTRIES - starting_offset; - no_of_queues++; - } - starting_indx = queue_indx - no_of_queues; - if (starting_indx < 0) { - no_of_wrap_buffs -= (starting_indx + 1) * NO_OF_ENTRIES; - starting_indx = MFSBQ_LENGTH + starting_indx; - wrap_around = TRUE; - } - } - - DPRINTK("starting_indx = %d, starting offset = %d no_of_wrap_buffs = %d\n", starting_indx, starting_offset, no_of_wrap_buffs); - /* Get Tachyon Header from first buffer */ - buff_addr = bus_to_virt(ntohl(*(fi->q.ptr_mfsbq_base + starting_indx*NO_OF_ENTRIES + starting_offset))); - - - /* extract Type of Frame */ - type_of_frame = (u_int)ntohl(*(buff_addr + 4)) & 0xFF000000; - s_id = (u_int)ntohl(*(buff_addr + 3)) & 0x00FFFFFF; - received_ox_id = ntohl(*(buff_addr + 6)) >> 16; - buff_addr += MFS_BUFFER_SIZE/4; - DPRINTK("type_of_frame = %x, s_id = %x, ox_id = %x", type_of_frame, s_id, received_ox_id); - - switch(type_of_frame) { - case TYPE_LLC_SNAP: - skb = dev_alloc_skb(payload_size); - if (skb == NULL) { - printk(KERN_NOTICE "%s: In handle_MFS_interrupt() Memory squeeze, dropping packet.\n", fi->name); - fi->fc_stats.rx_dropped++; - fi->g.mfs_buffer_count += no_of_buffers; - if (fi->g.mfs_buffer_count >= NO_OF_ENTRIES) { - int count = fi->g.mfs_buffer_count / NO_OF_ENTRIES; - fi->g.mfs_buffer_count -= NO_OF_ENTRIES * count; - update_MFSBQ_indx(fi, count); - } - return; - } - if (wrap_around) { - int wrap_size = no_of_wrap_buffs * MFS_BUFFER_SIZE; - int tail_size = payload_size - wrap_size; - DPRINTK("wrap_size = %d, tail_size = %d\n", wrap_size, tail_size); - if (no_of_wrap_buffs) - memcpy(skb_put(skb, wrap_size), buff_addr, wrap_size); - buff_addr = bus_to_virt(ntohl(*(fi->q.ptr_mfsbq_base))); - memcpy(skb_put(skb, tail_size), buff_addr, tail_size); - } - else - memcpy(skb_put(skb, payload_size), buff_addr, payload_size); - rx_net_mfs_packet(fi, skb); - break; - default: - T_MSG("Unknown Frame Type received. Type = %x", type_of_frame); - } - - /* provide Tachyon will another set of buffers */ - fi->g.mfs_buffer_count += no_of_buffers; - if (fi->g.mfs_buffer_count >= NO_OF_ENTRIES) { - int count = fi->g.mfs_buffer_count / NO_OF_ENTRIES; - fi->g.mfs_buffer_count -= NO_OF_ENTRIES * count; - update_MFSBQ_indx(fi, count); - } - LEAVE("handle_MFS_interrupt"); -} - -static void handle_Unknown_Frame_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry; -int queue_indx, offset; - ENTER("handle_Unknown_Frame_interrupt"); - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - /* We discard the "unknown" frame */ - /* provide Tachyon will another set of buffers */ - if (offset == (NO_OF_ENTRIES - 1)) - update_SFSBQ_indx(fi); - LEAVE("handle_Unknown_Frame_interrupt"); -} - -static void handle_Busied_Frame_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry; -int queue_indx, offset; - ENTER("handle_Busied_Frame_interrupt"); - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - /* We discard the "busied" frame */ - /* provide Tachyon will another set of buffers */ - if (offset == (NO_OF_ENTRIES - 1)) - update_SFSBQ_indx(fi); - LEAVE("handle_Busied_Frame_interrupt"); -} - -static void handle_Bad_SCSI_Frame_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry, *buff_addr, *tach_header, *ptr_edb; -u_int s_id, rctl, frame_class, burst_len, transfered_len, len = 0; -int queue_indx, offset, payload_size, i; -u_short ox_id, rx_id, x_id, mtu = 512; -u_char target_id = 0xFF; - - ENTER("handle_Bad_SCSI_Frame_interrupt"); - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - payload_size = ntohl(*(ptr_imq_entry + 2)); - - buff_addr = bus_to_virt(ntohl(*(fi->q.ptr_sfsbq_base + queue_indx*NO_OF_ENTRIES + offset))); - - rctl = ntohl(*(buff_addr + 2)) & 0xFF000000; - s_id = ntohl(*(buff_addr + 3)) & 0x00FFFFFF; - ox_id = ntohl(*(buff_addr + 6)) >> 16; - rx_id = ntohl(*(buff_addr + 6)); - x_id = ox_id & MAX_SCSI_XID; - - /* Any frame that comes in with OX_ID that matches an OX_ID - * that has been allocated for SCSI, will be called a Bad - * SCSI frame if the Exchange is not valid any more. - * - * We will also get a Bad SCSI frame interrupt if we receive - * a XFER_RDY with offset != 0. Tachyon washes its hands off - * this Exchange. We have to take care of ourselves. Grrr... - */ - if (rctl == DATA_DESCRIPTOR) { - struct fc_node_info *q = fi->node_info_list; - while (q != NULL) { - if (q->d_id == s_id) { - target_id = q->target_id; - mtu = q->mtu; - break; - } - else - q = q->next; - } - frame_class = target_id; - transfered_len = ntohl(*(buff_addr + 8)); - burst_len = ntohl(*(buff_addr + 9)); - - build_ODB(fi, fi->g.seq_id, s_id, burst_len, 0, mtu, ox_id, rx_id, 0, 0, frame_class << 16); - /* Update the SEQ_ID and Relative Offset in the - * Tachyon Header Structure. - */ - tach_header = bus_to_virt(ntohl(*(fi->q.ptr_sest[x_id] + 5))); - *(tach_header + 5) = htonl(fi->g.seq_id << 24); - *(tach_header + 7) = htonl(transfered_len); - fi->g.odb.hdr_addr = *(fi->q.ptr_sest[x_id] + 5); - - /* Invalidate the EDBs used - */ - ptr_edb = bus_to_virt(ntohl(*(fi->q.ptr_sest[x_id] + 7))); - - for (i = 0; i < EDB_LEN; i++) - if (fi->q.ptr_edb[i] == ptr_edb) - break; - ptr_edb--; - - if (i < EDB_LEN) { - int j; - do { - ptr_edb += 2; - len += (htonl(*ptr_edb) & 0xFFFF); - j = i; - fi->q.free_edb_list[i++] = EDB_FREE; - if (i == EDB_LEN) { - i = 0; - ptr_edb = fi->q.ptr_edb_base - 1; - } - } while (len < transfered_len); - if (len > transfered_len) { - ptr_edb--; - fi->q.free_edb_list[j] = EDB_BUSY; - } - else - ptr_edb++; - } - else { - T_MSG("EDB not found while freeing"); - if (offset == (NO_OF_ENTRIES - 1)) - update_SFSBQ_indx(fi); - return; - } - - /* Update the EDB pointer in the ODB. - */ - fi->g.odb.edb_addr = htonl(virt_to_bus(ptr_edb)); - memcpy(fi->q.ptr_odb[fi->q.ocq_prod_indx], &(fi->g.odb), sizeof(ODB)); - /* Update the EDB pointer in the SEST entry. We might need - * this if get another XFER_RDY for the same Exchange. - */ - *(fi->q.ptr_sest[x_id] + 7) = htonl(virt_to_bus(ptr_edb)); - - update_OCQ_indx(fi); - if (fi->g.seq_id == MAX_SEQ_ID) - fi->g.seq_id = 0; - else - fi->g.seq_id++; - } - else - /* Could be a BA_ACC or a BA_RJT. - */ - if (rctl == RCTL_BASIC_ACC) { - u_int bls_type = remove_from_ox_id_list(fi, ox_id); - DPRINTK1("BA_ACC received from S_ID 0x%x with OX_ID = %x in response to %x", s_id, ox_id, bls_type); - if (bls_type == RCTL_BASIC_ABTS) { - u_int STE_bit; - /* Invalidate resources for that Exchange. - */ - STE_bit = ntohl(*fi->q.ptr_sest[x_id]); - if (STE_bit & SEST_V) { - *(fi->q.ptr_sest[x_id]) &= htonl(SEST_INV); - invalidate_SEST_entry(fi, ox_id); - } - } - } - else - if (rctl == RCTL_BASIC_RJT) { - u_int bls_type = remove_from_ox_id_list(fi, ox_id); - DPRINTK1("BA_RJT received from S_ID 0x%x with OX_ID = %x in response to %x", s_id, ox_id, bls_type); - if (bls_type == RCTL_BASIC_ABTS) { - u_int STE_bit; - /* Invalidate resources for that Exchange. - */ - STE_bit = ntohl(*fi->q.ptr_sest[x_id]); - if (STE_bit & SEST_V) { - *(fi->q.ptr_sest[x_id]) &= htonl(SEST_INV); - invalidate_SEST_entry(fi, ox_id); - } - } - } - else - DPRINTK1("Frame with R_CTL = %x received from S_ID 0x%x with OX_ID %x", rctl, s_id, ox_id); - - /* Else, discard the "Bad" SCSI frame. - */ - - /* provide Tachyon will another set of buffers - */ - if (offset == (NO_OF_ENTRIES - 1)) - update_SFSBQ_indx(fi); - LEAVE("handle_Bad_SCSI_Frame_interrupt"); -} - -static void handle_Inbound_SCSI_Status_interrupt(struct fc_info *fi) -{ -struct Scsi_Host *host = fi->host; -struct iph5526_hostdata *hostdata = (struct iph5526_hostdata *)host->hostdata; -u_int *ptr_imq_entry, *buff_addr, *ptr_rsp_info, *ptr_sense_info = NULL; -int queue_indx, offset, payload_size; -u_short received_ox_id, x_id; -Scsi_Cmnd *Cmnd; -u_int fcp_status, fcp_rsp_info_len = 0, fcp_sense_info_len = 0, s_id; - ENTER("handle_SCSI_status_interrupt"); - - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - buff_addr = bus_to_virt(ntohl(*(fi->q.ptr_sfsbq_base + queue_indx*NO_OF_ENTRIES + offset))); - payload_size = ntohl(*(ptr_imq_entry + 2)); - received_ox_id = ntohl(*(buff_addr + 6)) >> 16; - - buff_addr = bus_to_virt(ntohl(*(fi->q.ptr_sfsbq_base + queue_indx*NO_OF_ENTRIES + offset))); - - fcp_status = ntohl(*(buff_addr + 10)); - ptr_rsp_info = buff_addr + 14; - if (fcp_status & FCP_STATUS_RSP_LEN) - fcp_rsp_info_len = ntohl(*(buff_addr + 13)); - - if (fcp_status & FCP_STATUS_SENSE_LEN) { - ptr_sense_info = ptr_rsp_info + fcp_rsp_info_len / 4; - fcp_sense_info_len = ntohl(*(buff_addr + 12)); - DPRINTK("sense_info = %x", (u_int)ntohl(*ptr_sense_info)); - } - DPRINTK("fcp_status = %x, fcp_rsp_len = %x", fcp_status, fcp_rsp_info_len); - x_id = received_ox_id & MAX_SCSI_XID; - Cmnd = hostdata->cmnd_handler[x_id]; - hostdata->cmnd_handler[x_id] = NULL; - if (Cmnd != NULL) { - memset(Cmnd->sense_buffer, 0, sizeof(Cmnd->sense_buffer)); - /* Check if there is a Sense field */ - if (fcp_status & FCP_STATUS_SENSE_LEN) { - int size = sizeof(Cmnd->sense_buffer); - if (fcp_sense_info_len < size) - size = fcp_sense_info_len; - memcpy(Cmnd->sense_buffer, (char *)ptr_sense_info, size); - } - Cmnd->result = fcp_status & FCP_STATUS_MASK; - (*Cmnd->scsi_done) (Cmnd); - } - else - T_MSG("NULL Command out of handler!"); - - invalidate_SEST_entry(fi, received_ox_id); - s_id = ntohl(*(buff_addr + 3)) & 0x00FFFFFF; - fi->q.free_scsi_oxid[x_id] = OXID_AVAILABLE; - - /* provide Tachyon will another set of buffers */ - if (offset == (NO_OF_ENTRIES - 1)) - update_SFSBQ_indx(fi); - LEAVE("handle_SCSI_status_interrupt"); -} - -static void invalidate_SEST_entry(struct fc_info *fi, u_short received_ox_id) -{ -u_short x_id = received_ox_id & MAX_SCSI_XID; - /* Invalidate SEST entry if it is an OutBound SEST Entry - */ - if (!(received_ox_id & SCSI_READ_BIT)) { - u_int *ptr_tach_header, *ptr_edb; - u_short temp_ox_id = NOT_SCSI_XID; - int i; - *(fi->q.ptr_sest[x_id]) &= htonl(SEST_INV); - - /* Invalidate the Tachyon Header structure - */ - ptr_tach_header = bus_to_virt(ntohl(*(fi->q.ptr_sest[x_id] + 5))); - for (i = 0; i < NO_OF_TACH_HEADERS; i++) - if(fi->q.ptr_tachyon_header[i] == ptr_tach_header) - break; - if (i < NO_OF_TACH_HEADERS) - memset(ptr_tach_header, 0xFF, 32); - else - T_MSG("Tachyon Header not found while freeing in invalidate_SEST_entry()"); - - /* Invalidate the EDB used - */ - ptr_edb = bus_to_virt(ntohl(*(fi->q.ptr_sest[x_id] + 7))); - for (i = 0; i < EDB_LEN; i++) - if (fi->q.ptr_edb[i] == ptr_edb) - break; - ptr_edb--; - if (i < EDB_LEN) { - do { - ptr_edb += 2; - fi->q.free_edb_list[i++] = EDB_FREE; - if (i == EDB_LEN) { - i = 0; - ptr_edb = fi->q.ptr_edb_base - 1; - } - } while ((htonl(*ptr_edb) & 0x80000000) != 0x80000000); - } - else - T_MSG("EDB not found while freeing in invalidate_SEST_entry()"); - - /* Search for its other header structure and destroy it! - */ - if ((ptr_tach_header + 16) < (fi->q.ptr_tachyon_header_base + (MY_PAGE_SIZE/4))) - ptr_tach_header += 16; - else - ptr_tach_header = fi->q.ptr_tachyon_header_base; - while (temp_ox_id != x_id) { - temp_ox_id = ntohl(*(ptr_tach_header + 6)) >> 16; - if (temp_ox_id == x_id) { - /* Paranoid checking... - */ - for (i = 0; i < NO_OF_TACH_HEADERS; i++) - if(fi->q.ptr_tachyon_header[i] == ptr_tach_header) - break; - if (i < NO_OF_TACH_HEADERS) - memset(ptr_tach_header, 0xFF, 32); - else - T_MSG("Tachyon Header not found while freeing in invalidate_SEST_entry()"); - break; - } - else { - if ((ptr_tach_header + 16) < (fi->q.ptr_tachyon_header_base + (MY_PAGE_SIZE/4))) - ptr_tach_header += 16; - else - ptr_tach_header = fi->q.ptr_tachyon_header_base; - } - } - } - else { - u_short sdb_table_indx; - /* An Inbound Command has completed or needs to be Aborted. - * Clear up the SDB buffers. - */ - sdb_table_indx = *(fi->q.ptr_sest[x_id] + 5); - fi->q.sdb_slot_status[sdb_table_indx] = SDB_FREE; - } -} - -static void handle_Inbound_SCSI_Command_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry; -int queue_indx, offset; - ENTER("handle_Inbound_SCSI_Command_interrupt"); - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - /* We discard the SCSI frame as we shouldn't be receiving - * a SCSI Command in the first place - */ - /* provide Tachyon will another set of buffers */ - if (offset == (NO_OF_ENTRIES - 1)) - update_SFSBQ_indx(fi); - LEAVE("handle_Inbound_SCSI_Command_interrupt"); -} - -static void handle_SFS_interrupt(struct fc_info *fi) -{ -u_int *ptr_imq_entry, *buff_addr; -u_int class_of_frame, type_of_frame, s_id, els_type = 0, rctl; -int queue_indx, offset, payload_size, login_state; -u_short received_ox_id, fs_cmnd_code; - ENTER("handle_SFS_interrupt"); - ptr_imq_entry = fi->q.ptr_imqe[fi->q.imq_cons_indx]; - offset = ntohl(*(ptr_imq_entry + 1)) & 0x00000007; - queue_indx = ntohl(*(ptr_imq_entry + 1)) & 0xFFFF0000; - queue_indx = queue_indx >> 16; - DPRINTK("queue_indx = %d, offset = %d\n", queue_indx, offset); - payload_size = ntohl(*(ptr_imq_entry + 2)); - DPRINTK("payload_size = %d", payload_size); - - buff_addr = bus_to_virt(ntohl(*(fi->q.ptr_sfsbq_base + queue_indx*NO_OF_ENTRIES + offset))); - - /* extract Type of Frame */ - type_of_frame = ntohl(*(buff_addr + 4)) & 0xFF000000; - s_id = ntohl(*(buff_addr + 3)) & 0x00FFFFFF; - received_ox_id = ntohl(*(buff_addr + 6)) >> 16; - switch(type_of_frame) { - case TYPE_BLS: - rctl = ntohl(*(buff_addr + 2)) & 0xFF000000; - switch(rctl) { - case RCTL_BASIC_ABTS: - /* As an Initiator, we should never be receiving - * this. - */ - DPRINTK1("ABTS received from S_ID 0x%x with OX_ID = %x", s_id, received_ox_id); - break; - } - break; - case TYPE_ELS: - class_of_frame = ntohl(*(buff_addr + 8)); - login_state = sid_logged_in(fi, s_id); - switch(class_of_frame & 0xFF000000) { - case ELS_PLOGI: - if (s_id != fi->g.my_id) { - u_int ret_code; - DPRINTK1("PLOGI received from D_ID 0x%x with 0X_ID = %x", s_id, received_ox_id); - if ((ret_code = plogi_ok(fi, buff_addr, payload_size)) == 0){ - tx_logi_acc(fi, ELS_ACC, s_id, received_ox_id); - add_to_address_cache(fi, buff_addr); - } - else { - u_short cmnd_code = ret_code >> 16; - u_short expln_code = ret_code; - tx_ls_rjt(fi, s_id, received_ox_id, cmnd_code, expln_code); - } - } - break; - case ELS_ACC: - els_type = remove_from_ox_id_list(fi, received_ox_id); - DPRINTK1("ELS_ACC received from D_ID 0x%x in response to ELS %x", s_id, els_type); - switch(els_type) { - case ELS_PLOGI: - add_to_address_cache(fi, buff_addr); - tx_prli(fi, ELS_PRLI, s_id, OX_ID_FIRST_SEQUENCE); - break; - case ELS_FLOGI: - add_to_address_cache(fi, buff_addr); - fi->g.my_id = ntohl(*(buff_addr + 2)) & 0x00FFFFFF; - fi->g.fabric_present = TRUE; - fi->g.my_ddaa = fi->g.my_id & 0xFFFF00; - /* Login to the Name Server - */ - tx_logi(fi, ELS_PLOGI, DIRECTORY_SERVER); - break; - case ELS_NS_PLOGI: - fi->g.name_server = TRUE; - add_to_address_cache(fi, buff_addr); - tx_name_server_req(fi, FCS_RFC_4); - tx_scr(fi); - /* Some devices have a delay before - * registering with the Name Server - */ - udelay(500); - tx_name_server_req(fi, FCS_GP_ID4); - break; - case ELS_PRLI: - mark_scsi_sid(fi, buff_addr, ADD_ENTRY); - break; - case ELS_ADISC: - if (!(validate_login(fi, buff_addr))) - tx_logo(fi, s_id, OX_ID_FIRST_SEQUENCE); - break; - } - break; - case ELS_PDISC: - DPRINTK1("ELS_PDISC received from D_ID 0x%x", s_id); - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_ADISC: - DPRINTK1("ELS_ADISC received from D_ID 0x%x", s_id); - if (node_logged_in_prev(fi, buff_addr)) - tx_adisc(fi, ELS_ACC, s_id, received_ox_id); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_PRLI: - DPRINTK1("ELS_PRLI received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) { - tx_prli(fi, ELS_ACC, s_id, received_ox_id); - mark_scsi_sid(fi, buff_addr, ADD_ENTRY); - } - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_PRLO: - DPRINTK1("ELS_PRLO received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_OUT) || (login_state == NODE_NOT_PRESENT)) - tx_logo(fi, s_id, received_ox_id); - else - if (login_state == NODE_LOGGED_IN) - - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - if (login_state == NODE_PROCESS_LOGGED_IN) { - tx_prli(fi, ELS_ACC, s_id, received_ox_id); - mark_scsi_sid(fi, buff_addr, DELETE_ENTRY); - } - break; - case ELS_LS_RJT: - els_type = remove_from_ox_id_list(fi, received_ox_id); - DPRINTK1("ELS_LS_RJT received from D_ID 0x%x in response to %x", s_id, els_type); - /* We should be chking the reason code. - */ - switch (els_type) { - case ELS_ADISC: - tx_logi(fi, ELS_PLOGI, s_id); - break; - } - break; - case ELS_LOGO: - els_type = remove_from_ox_id_list(fi, received_ox_id); - DPRINTK1("ELS_LOGO received from D_ID 0x%x in response to %x", s_id, els_type); - remove_from_address_cache(fi, buff_addr, ELS_LOGO); - tx_acc(fi, s_id, received_ox_id); - if (els_type == ELS_ADISC) - tx_logi(fi, ELS_PLOGI, s_id); - break; - case ELS_RSCN: - DPRINTK1("ELS_RSCN received from D_ID 0x%x", s_id); - tx_acc(fi, s_id, received_ox_id); - remove_from_address_cache(fi, buff_addr, ELS_RSCN); - break; - case ELS_FARP_REQ: - /* We do not support FARP. - So, silently discard it */ - DPRINTK1("ELS_FARP_REQ received from D_ID 0x%x", s_id); - break; - case ELS_ABTX: - DPRINTK1("ELS_ABTX received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_FLOGI: - DPRINTK1("ELS_FLOGI received from D_ID 0x%x", s_id); - if (fi->g.ptp_up == TRUE) { - /* The node could have come up as an N_Port - * in a Loop! So,try initializing as an NL_port - */ - take_tachyon_offline(fi); - /* write AL_TIME & E_D_TOV into the registers */ - writel(TOV_VALUES, fi->t_r.ptr_fm_tov_reg); - writel(LOOP_INIT_SOFT_ADDRESS, fi->t_r.ptr_fm_config_reg); - DPRINTK1("FLOGI received, TACHYON initializing as L_Port...\n"); - writel(INITIALIZE, fi->t_r.ptr_fm_control_reg); - } - else { - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - } - break; - case ELS_ADVC: - DPRINTK1("ELS_ADVC received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_ECHO: - DPRINTK1("ELS_ECHO received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_ESTC: - DPRINTK1("ELS_ESTC received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_ESTS: - DPRINTK1("ELS_ESTS received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RCS: - DPRINTK1("ELS_RCS received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RES: - DPRINTK1("ELS_RES received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RLS: - DPRINTK1("ELS_RLS received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RRQ: - DPRINTK1("ELS_RRQ received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RSS: - DPRINTK1("ELS_RSS received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RTV: - DPRINTK1("ELS_RTV received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RSI: - DPRINTK1("ELS_RSI received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_TEST: - /* No reply sequence */ - DPRINTK1("ELS_TEST received from D_ID 0x%x", s_id); - break; - case ELS_RNC: - DPRINTK1("ELS_RNC received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_RVCS: - DPRINTK1("ELS_RVCS received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_TPLS: - DPRINTK1("ELS_TPLS received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_GAID: - DPRINTK1("ELS_GAID received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_FACT: - DPRINTK1("ELS_FACT received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_FAN: - /* Hmmm... You don't support FAN ??? */ - DPRINTK1("ELS_FAN received from D_ID 0x%x", s_id); - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - break; - case ELS_FDACT: - DPRINTK1("ELS_FDACT received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_NACT: - DPRINTK1("ELS_NACT received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_NDACT: - DPRINTK1("ELS_NDACT received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_QoSR: - DPRINTK1("ELS_QoSR received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - case ELS_FDISC: - DPRINTK1("ELS_FDISC received from D_ID 0x%x", s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - default: - DPRINTK1("ELS Frame %x received from D_ID 0x%x", class_of_frame, s_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) - tx_ls_rjt(fi, s_id, received_ox_id, CMND_NOT_SUPP, NO_EXPLN); - else - tx_logo(fi, s_id, received_ox_id); - break; - } - break; - case TYPE_FC_SERVICES: - fs_cmnd_code = (ntohl(*(buff_addr + 10)) & 0xFFFF0000) >>16; - switch(fs_cmnd_code) { - case FCS_ACC: - els_type = remove_from_ox_id_list(fi, received_ox_id); - DPRINTK1("FCS_ACC received from D_ID 0x%x in response to %x", s_id, els_type); - if (els_type == FCS_GP_ID4) - explore_fabric(fi, buff_addr); - break; - case FCS_REJECT: - DPRINTK1("FCS_REJECT received from D_ID 0x%x in response to %x", s_id, els_type); - break; - } - break; - case TYPE_LLC_SNAP: - rx_net_packet(fi, (u_char *)buff_addr, payload_size); - break; - default: - T_MSG("Frame Type %x received from %x", type_of_frame, s_id); - } - - /* provide Tachyon will another set of buffers */ - if (offset == (NO_OF_ENTRIES - 1)) - update_SFSBQ_indx(fi); - LEAVE("handle_SFS_interrupt"); -} - -static void handle_FM_interrupt(struct fc_info *fi) -{ -u_int fm_status; -u_int tachyon_status; - - ENTER("handle_FM_interrupt"); - fm_status = readl(fi->t_r.ptr_fm_status_reg); - tachyon_status = readl(fi->t_r.ptr_tach_status_reg); - DPRINTK("FM_status = %x, Tachyon_status = %x", fm_status, tachyon_status); - if (fm_status & LINK_DOWN) { - T_MSG("Fibre Channel Link DOWN"); - fm_status = readl(fi->t_r.ptr_fm_status_reg); - - del_timer(&fi->explore_timer); - del_timer(&fi->nport_timer); - del_timer(&fi->lport_timer); - del_timer(&fi->display_cache_timer); - fi->g.link_up = FALSE; - if (fi->g.ptp_up == TRUE) - fi->g.n_port_try = FALSE; - fi->g.ptp_up = FALSE; - fi->g.port_discovery = FALSE; - fi->g.explore_fabric = FALSE; - fi->g.perform_adisc = FALSE; - - /* Logout will all nodes */ - if (fi->node_info_list) { - struct fc_node_info *temp_list = fi->node_info_list; - while(temp_list) { - temp_list->login = LOGIN_ATTEMPTED; - temp_list = temp_list->next; - } - fi->num_nodes = 0; - } - - if ((fi->g.n_port_try == FALSE) && (fi->g.dont_init == FALSE)){ - take_tachyon_offline(fi); - /* write AL_TIME & E_D_TOV into the registers */ - writel(TOV_VALUES, fi->t_r.ptr_fm_tov_reg); - - if ((fi->g.fabric_present == TRUE) && (fi->g.loop_up == TRUE)) { - u_int al_pa = fi->g.my_id & 0xFF; - writel((al_pa << 24) | LOOP_INIT_FABRIC_ADDRESS | LOOP_INIT_PREVIOUS_ADDRESS, fi->t_r.ptr_fm_config_reg); - } - else - if (fi->g.loop_up == TRUE) { - u_int al_pa = fi->g.my_id & 0xFF; - writel((al_pa << 24) | LOOP_INIT_PREVIOUS_ADDRESS, fi->t_r.ptr_fm_config_reg); - } - else - writel(LOOP_INIT_SOFT_ADDRESS, fi->t_r.ptr_fm_config_reg); - fi->g.loop_up = FALSE; - DPRINTK1("In LDWN TACHYON initializing as L_Port...\n"); - writel(INITIALIZE, fi->t_r.ptr_fm_control_reg); - } - } - - if (fm_status & NON_PARTICIPATING) { - T_MSG("Did not acquire an AL_PA. I am not participating"); - } - else - if ((fm_status & LINK_UP) && ((fm_status & LINK_DOWN) == 0)) { - T_MSG("Fibre Channel Link UP"); - if ((fm_status & NON_PARTICIPATING) != TRUE) { - fi->g.link_up = TRUE; - if (tachyon_status & OSM_FROZEN) { - reset_tachyon(fi, ERROR_RELEASE); - reset_tachyon(fi, OCQ_RESET); - } - init_timer(&fi->explore_timer); - init_timer(&fi->nport_timer); - init_timer(&fi->lport_timer); - init_timer(&fi->display_cache_timer); - if ((fm_status & OLD_PORT) == 0) { - fi->g.loop_up = TRUE; - fi->g.ptp_up = FALSE; - fi->g.my_id = readl(fi->t_r.ptr_fm_config_reg) >> 24; - DPRINTK1("My AL_PA = %x", fi->g.my_id); - fi->g.port_discovery = TRUE; - fi->g.explore_fabric = FALSE; - } - else - if (((fm_status & 0xF0) == OLD_PORT) && ((fm_status & 0x0F) == PORT_STATE_ACTIVE)) { - fi->g.loop_up = FALSE; - fi->g.my_id = 0x0; - /* In a point-to-point configuration, we expect to be - * connected to an F_Port. This driver does not yet support - * a configuration where it is connected to another N_Port - * directly. - */ - fi->g.explore_fabric = TRUE; - fi->g.port_discovery = FALSE; - if (fi->g.n_port_try == FALSE) { - take_tachyon_offline(fi); - /* write R_T_TOV & E_D_TOV into the registers */ - writel(PTP_TOV_VALUES, fi->t_r.ptr_fm_tov_reg); - writel(BB_CREDIT | NPORT, fi->t_r.ptr_fm_config_reg); - fi->g.n_port_try = TRUE; - DPRINTK1("In LUP TACHYON initializing as N_Port...\n"); - writel(INITIALIZE, fi->t_r.ptr_fm_control_reg); - } - else { - fi->g.ptp_up = TRUE; - tx_logi(fi, ELS_FLOGI, F_PORT); - } - } - fi->g.my_ddaa = 0x0; - fi->g.fabric_present = FALSE; - /* We havn't sent out any Name Server Reqs */ - fi->g.name_server = FALSE; - fi->g.alpa_list_index = 0; - fi->g.ox_id = NOT_SCSI_XID; - fi->g.my_mtu = TACH_FRAME_SIZE; - - /* Implicitly LOGO with all logged-in nodes. - */ - if (fi->node_info_list) { - struct fc_node_info *temp_list = fi->node_info_list; - while(temp_list) { - temp_list->login = LOGIN_ATTEMPTED; - temp_list = temp_list->next; - } - fi->num_nodes = 0; - fi->g.perform_adisc = TRUE; - //fi->g.perform_adisc = FALSE; - fi->g.port_discovery = FALSE; - tx_logi(fi, ELS_FLOGI, F_PORT); - } - else { - /* If Link coming up for the _first_ time or no nodes - * were logged in before... - */ - fi->g.scsi_oxid = 0; - fi->g.seq_id = 0x00; - fi->g.perform_adisc = FALSE; - } - - /* reset OX_ID table */ - while (fi->ox_id_list) { - struct ox_id_els_map *temp = fi->ox_id_list; - fi->ox_id_list = fi->ox_id_list->next; - kfree(temp); - } - fi->ox_id_list = NULL; - } /* End of if partipating */ - } - - if (fm_status & ELASTIC_STORE_ERROR) { - /* Too much junk on the Link - */ - /* Trying to clear it up by Txing PLOGI to urself */ - if (fi->g.link_up == TRUE) - tx_logi(fi, ELS_PLOGI, fi->g.my_id); - } - - if (fm_status & LOOP_UP) { - if (tachyon_status & OSM_FROZEN) { - reset_tachyon(fi, ERROR_RELEASE); - reset_tachyon(fi, OCQ_RESET); - } - } - - if (fm_status & NOS_OLS_RECEIVED){ - if (fi->g.nport_timer_set == FALSE) { - DPRINTK("NOS/OLS Received"); - DPRINTK("FM_status = %x", fm_status); - fi->nport_timer.function = nos_ols_timer; - fi->nport_timer.data = (unsigned long)fi; - fi->nport_timer.expires = RUN_AT((3*HZ)/100); /* 30 msec */ - init_timer(&fi->nport_timer); - add_timer(&fi->nport_timer); - fi->g.nport_timer_set = TRUE; - } - } - - if (((fm_status & 0xF0) == OLD_PORT) && (((fm_status & 0x0F) == PORT_STATE_LF1) || ((fm_status & 0x0F) == PORT_STATE_LF2))) { - DPRINTK1("Link Fail-I in OLD-PORT."); - take_tachyon_offline(fi); - reset_tachyon(fi, SOFTWARE_RESET); - } - - if (fm_status & LOOP_STATE_TIMEOUT){ - if ((fm_status & 0xF0) == ARBITRATING) - DPRINTK1("ED_TOV timesout.In ARBITRATING state..."); - if ((fm_status & 0xF0) == ARB_WON) - DPRINTK1("ED_TOV timesout.In ARBITRATION WON state..."); - if ((fm_status & 0xF0) == OPEN) - DPRINTK1("ED_TOV timesout.In OPEN state..."); - if ((fm_status & 0xF0) == OPENED) - DPRINTK1("ED_TOV timesout.In OPENED state..."); - if ((fm_status & 0xF0) == TX_CLS) - DPRINTK1("ED_TOV timesout.In XMITTED CLOSE state..."); - if ((fm_status & 0xF0) == RX_CLS) - DPRINTK1("ED_TOV timesout.In RECEIVED CLOSE state..."); - if ((fm_status & 0xF0) == INITIALIZING) - DPRINTK1("ED_TOV timesout.In INITIALIZING state..."); - DPRINTK1("Initializing Loop..."); - writel(INITIALIZE, fi->t_r.ptr_fm_control_reg); - } - - if ((fm_status & BAD_ALPA) && (fi->g.loop_up == TRUE)) { - u_char bad_alpa = (readl(fi->t_r.ptr_fm_rx_al_pa_reg) & 0xFF00) >> 8; - if (tachyon_status & OSM_FROZEN) { - reset_tachyon(fi, ERROR_RELEASE); - reset_tachyon(fi, OCQ_RESET); - } - /* Fix for B34 */ - tx_logi(fi, ELS_PLOGI, fi->g.my_id); - - if (!fi->g.port_discovery && !fi->g.perform_adisc) { - if (bad_alpa != 0xFE) - DPRINTK("Bad AL_PA = %x", bad_alpa); - } - else { - if ((fi->g.perform_adisc == TRUE) && (bad_alpa == 0x00)) { - DPRINTK1("Performing ADISC..."); - fi->g.fabric_present = FALSE; - perform_adisc(fi); - } - } - } - - if (fm_status & LIPF_RECEIVED){ - DPRINTK("LIP(F8) Received"); - } - - if (fm_status & LINK_FAILURE) { - if (fm_status & LOSS_OF_SIGNAL) - DPRINTK1("Detected Loss of Signal."); - if (fm_status & OUT_OF_SYNC) - DPRINTK1("Detected Loss of Synchronization."); - } - - if (fm_status & TRANSMIT_PARITY_ERROR) { - /* Bad! Should not happen. Solution-> Hard Reset. - */ - T_MSG("Parity Error. Perform Hard Reset!"); - } - - if (fi->g.alpa_list_index >= MAX_NODES){ - if (fi->g.port_discovery == TRUE) { - fi->g.port_discovery = FALSE; - add_display_cache_timer(fi); - } - fi->g.alpa_list_index = MAX_NODES; - } - - if (fi->g.port_discovery == TRUE) - local_port_discovery(fi); - - LEAVE("handle_FM_interrupt"); - return; -} - -static void local_port_discovery(struct fc_info *fi) -{ - if (fi->g.loop_up == TRUE) { - /* If this is not here, some of the Bad AL_PAs are missed. - */ - udelay(20); - if ((fi->g.alpa_list_index == 0) && (fi->g.fabric_present == FALSE)){ - tx_logi(fi, ELS_FLOGI, F_PORT); - } - else { - int login_state = sid_logged_in(fi, fi->g.my_ddaa | alpa_list[fi->g.alpa_list_index]); - while ((fi->g.alpa_list_index == 0) || ((fi->g.alpa_list_index < MAX_NODES) && ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN) || (alpa_list[fi->g.alpa_list_index] == (fi->g.my_id & 0xFF))))) - fi->g.alpa_list_index++; - if (fi->g.alpa_list_index < MAX_NODES) - tx_logi(fi, ELS_PLOGI, alpa_list[fi->g.alpa_list_index]); - } - fi->g.alpa_list_index++; - if (fi->g.alpa_list_index >= MAX_NODES){ - if (fi->g.port_discovery == TRUE) { - fi->g.port_discovery = FALSE; - add_display_cache_timer(fi); - } - fi->g.alpa_list_index = MAX_NODES; - } - } -} - -static void nos_ols_timer(unsigned long data) -{ -struct fc_info *fi = (struct fc_info*)data; -u_int fm_status; - fm_status = readl(fi->t_r.ptr_fm_status_reg); - DPRINTK1("FM_status in timer= %x", fm_status); - fi->g.nport_timer_set = FALSE; - del_timer(&fi->nport_timer); - if ((fi->g.ptp_up == TRUE) || (fi->g.loop_up == TRUE)) - return; - if (((fm_status & 0xF0) == OLD_PORT) && (((fm_status & 0x0F) == PORT_STATE_ACTIVE) || ((fm_status & 0x0F) == PORT_STATE_OFFLINE))) { - DPRINTK1("In OLD-PORT after E_D_TOV."); - take_tachyon_offline(fi); - /* write R_T_TOV & E_D_TOV into the registers */ - writel(PTP_TOV_VALUES, fi->t_r.ptr_fm_tov_reg); - writel(BB_CREDIT | NPORT, fi->t_r.ptr_fm_config_reg); - fi->g.n_port_try = TRUE; - DPRINTK1("In timer, TACHYON initializing as N_Port...\n"); - writel(INITIALIZE, fi->t_r.ptr_fm_control_reg); - } - else - if ((fi->g.lport_timer_set == FALSE) && ((fm_status & 0xF0) == LOOP_FAIL)) { - DPRINTK1("Loop Fail after E_D_TOV."); - fi->lport_timer.function = loop_timer; - fi->lport_timer.data = (unsigned long)fi; - fi->lport_timer.expires = RUN_AT((8*HZ)/100); - init_timer(&fi->lport_timer); - add_timer(&fi->lport_timer); - fi->g.lport_timer_set = TRUE; - take_tachyon_offline(fi); - reset_tachyon(fi, SOFTWARE_RESET); - } - else - if (((fm_status & 0xF0) == OLD_PORT) && (((fm_status & 0x0F) == PORT_STATE_LF1) || ((fm_status & 0x0F) == PORT_STATE_LF2))) { - DPRINTK1("Link Fail-II in OLD-PORT."); - take_tachyon_offline(fi); - reset_tachyon(fi, SOFTWARE_RESET); - } -} - -static void loop_timer(unsigned long data) -{ -struct fc_info *fi = (struct fc_info*)data; - fi->g.lport_timer_set = FALSE; - del_timer(&fi->lport_timer); - if ((fi->g.ptp_up == TRUE) || (fi->g.loop_up == TRUE)) - return; -} - -static void add_display_cache_timer(struct fc_info *fi) -{ - fi->display_cache_timer.function = display_cache_timer; - fi->display_cache_timer.data = (unsigned long)fi; - fi->display_cache_timer.expires = RUN_AT(fi->num_nodes * HZ); - init_timer(&fi->display_cache_timer); - add_timer(&fi->display_cache_timer); -} - -static void display_cache_timer(unsigned long data) -{ -struct fc_info *fi = (struct fc_info*)data; - del_timer(&fi->display_cache_timer); - display_cache(fi); - return; -} - -static void reset_tachyon(struct fc_info *fi, u_int value) -{ -u_int tachyon_status, reset_done = OCQ_RESET_STATUS | SCSI_FREEZE_STATUS; -int not_done = 1, i = 0; - writel(value, fi->t_r.ptr_tach_control_reg); - if (value == OCQ_RESET) - fi->q.ocq_prod_indx = 0; - tachyon_status = readl(fi->t_r.ptr_tach_status_reg); - - /* Software resets are immediately done, whereas other aren't. It - about 30 clocks to do the reset */ - if (value != SOFTWARE_RESET) { - while(not_done) { - if (i++ > 100000) { - T_MSG("Reset was unsuccessful! Tachyon Status = %x", tachyon_status); - break; - } - tachyon_status = readl(fi->t_r.ptr_tach_status_reg); - if ((tachyon_status & reset_done) == 0) - not_done = 0; - } - } - else { - write_to_tachyon_registers(fi); - } -} - -static void take_tachyon_offline(struct fc_info *fi) -{ -u_int fm_status = readl(fi->t_r.ptr_fm_status_reg); - - /* The first two conditions will never be true. The Manual and - * the errata say this. But the current implementation is - * decently stable. - */ - //if ((fm_status & 0xF0) == LOOP_FAIL) { - if (fm_status == LOOP_FAIL) { - // workaround as in P. 89 - writel(HOST_CONTROL, fi->t_r.ptr_fm_control_reg); - if (fi->g.loop_up == TRUE) - writel(SOFTWARE_RESET, fi->t_r.ptr_tach_control_reg); - else { - writel(OFFLINE, fi->t_r.ptr_fm_control_reg); - writel(EXIT_HOST_CONTROL, fi->t_r.ptr_fm_control_reg); - } - } - else - //if ((fm_status & LOOP_UP) == LOOP_UP) { - if (fm_status == LOOP_UP) { - writel(SOFTWARE_RESET, fi->t_r.ptr_tach_control_reg); - } - else - writel(OFFLINE, fi->t_r.ptr_fm_control_reg); -} - - -static void read_novram(struct fc_info *fi) -{ -int off = 0; - fi->n_r.ptr_novram_hw_control_reg = fi->i_r.ptr_ichip_hw_control_reg; - fi->n_r.ptr_novram_hw_status_reg = fi->i_r.ptr_ichip_hw_status_reg; - iph5526_nr_do_init(fi); - if (fi->clone_id == PCI_VENDOR_ID_INTERPHASE) - off = 32; - - fi->g.my_node_name_high = (fi->n_r.data[off] << 16) | fi->n_r.data[off+1]; - fi->g.my_node_name_low = (fi->n_r.data[off+2] << 16) | fi->n_r.data[off+3]; - fi->g.my_port_name_high = (fi->n_r.data[off+4] << 16) | fi->n_r.data[off+5]; - fi->g.my_port_name_low = (fi->n_r.data[off+6] << 16) | fi->n_r.data[off+7]; - DPRINTK("node_name = %x %x", fi->g.my_node_name_high, fi->g.my_node_name_low); - DPRINTK("port_name = %x %x", fi->g.my_port_name_high, fi->g.my_port_name_low); -} - -static void reset_ichip(struct fc_info *fi) -{ - /* (i)chip reset */ - writel(ICHIP_HCR_RESET, fi->i_r.ptr_ichip_hw_control_reg); - /*wait for chip to get reset */ - mdelay(10); - /*de-assert reset */ - writel(ICHIP_HCR_DERESET, fi->i_r.ptr_ichip_hw_control_reg); - - /* enable INT lines on the (i)chip */ - writel(ICHIP_HCR_ENABLE_INTA , fi->i_r.ptr_ichip_hw_control_reg); - /* enable byte swap */ - writel(ICHIP_HAMR_BYTE_SWAP_ADDR_TR, fi->i_r.ptr_ichip_hw_addr_mask_reg); -} - -static void tx_logi(struct fc_info *fi, u_int logi, u_int d_id) -{ -int int_required = 1; -u_short ox_id = OX_ID_FIRST_SEQUENCE; -u_int r_ctl = RCTL_ELS_UCTL; -u_int type = TYPE_ELS | SEQUENCE_INITIATIVE | FIRST_SEQUENCE; -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_logi"); - /* We don't want interrupted for our own logi. - * It screws up the port discovery process. - */ - if (d_id == fi->g.my_id) - int_required = 0; - fill_login_frame(fi, logi); - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.login, sizeof(LOGIN)); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),sizeof(LOGIN), r_ctl, type, d_id, my_mtu, int_required, ox_id, logi); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_logi"); - return; -} - -static void tx_logi_acc(struct fc_info *fi, u_int logi, u_int d_id, u_short received_ox_id) -{ -int int_required = 0; -u_int r_ctl = RCTL_ELS_SCTL; -u_int type = TYPE_ELS | EXCHANGE_RESPONDER | LAST_SEQUENCE; -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_logi_acc"); - fill_login_frame(fi, logi); - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.login, sizeof(LOGIN)); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),sizeof(LOGIN), r_ctl, type, d_id, my_mtu, int_required, received_ox_id, logi); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_logi_acc"); - return; -} - -static void tx_prli(struct fc_info *fi, u_int command_code, u_int d_id, u_short received_ox_id) -{ -int int_required = 1; -u_int r_ctl = RCTL_ELS_UCTL; -u_int type = TYPE_ELS | SEQUENCE_INITIATIVE | FIRST_SEQUENCE; -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_prli"); - if (command_code == ELS_PRLI) - fi->g.prli.cmnd_code = htons((ELS_PRLI | PAGE_LEN) >> 16); - else { - fi->g.prli.cmnd_code = htons((ELS_ACC | PAGE_LEN) >> 16); - int_required = 0; - type = TYPE_ELS | EXCHANGE_RESPONDER | LAST_SEQUENCE; - r_ctl = RCTL_ELS_SCTL; - } - fi->g.prli.payload_length = htons(PRLI_LEN); - fi->g.prli.type_code = htons(FCP_TYPE_CODE); - fi->g.prli.est_image_pair = htons(IMAGE_PAIR); - fi->g.prli.responder_pa = 0; - fi->g.prli.originator_pa = 0; - fi->g.prli.service_params = htonl(INITIATOR_FUNC | READ_XFER_RDY_DISABLED); - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.prli, sizeof(PRLI)); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]), sizeof(PRLI), r_ctl, type, d_id, my_mtu, int_required, received_ox_id, command_code); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_prli"); - return; -} - -static void tx_logo(struct fc_info *fi, u_int d_id, u_short received_ox_id) -{ -int int_required = 1; -u_int r_ctl = RCTL_ELS_UCTL; -u_int type = TYPE_ELS | EXCHANGE_RESPONDER | SEQUENCE_RESPONDER | FIRST_SEQUENCE | END_SEQUENCE | SEQUENCE_INITIATIVE; -int size = sizeof(LOGO); -char fc_id[3]; -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_logo"); - fi->g.logo.logo_cmnd = htonl(ELS_LOGO); - fi->g.logo.reserved = 0; - memcpy(fc_id, &(fi->g.my_id), 3); - fi->g.logo.n_port_id_0 = fc_id[0]; - fi->g.logo.n_port_id_1 = fc_id[1]; - fi->g.logo.n_port_id_2 = fc_id[2]; - fi->g.logo.port_name_up = htonl(N_PORT_NAME_HIGH); - fi->g.logo.port_name_low = htonl(N_PORT_NAME_LOW); - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.logo, sizeof(LOGO)); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),size, r_ctl, type, d_id, my_mtu, int_required, received_ox_id, ELS_LOGO); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_logo"); -} - -static void tx_adisc(struct fc_info *fi, u_int cmnd_code, u_int d_id, u_short received_ox_id) -{ -int int_required = 0; -u_int r_ctl = RCTL_ELS_SCTL; -u_int type = TYPE_ELS | EXCHANGE_RESPONDER | SEQUENCE_RESPONDER | FIRST_SEQUENCE | END_SEQUENCE; -int size = sizeof(ADISC); -u_int my_mtu = fi->g.my_mtu; - fi->g.adisc.ls_cmnd_code = htonl(cmnd_code); - fi->g.adisc.hard_address = htonl(0); - fi->g.adisc.port_name_high = htonl(N_PORT_NAME_HIGH); - fi->g.adisc.port_name_low = htonl(N_PORT_NAME_LOW); - fi->g.adisc.node_name_high = htonl(NODE_NAME_HIGH); - fi->g.adisc.node_name_low = htonl(NODE_NAME_LOW); - fi->g.adisc.n_port_id = htonl(fi->g.my_id); - if (cmnd_code == ELS_ADISC) { - int_required = 1; - r_ctl = RCTL_ELS_UCTL; - type = TYPE_ELS | SEQUENCE_INITIATIVE | FIRST_SEQUENCE; - } - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.adisc, size); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),size, r_ctl, type, d_id, my_mtu, int_required, received_ox_id, cmnd_code); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; -} - -static void tx_ls_rjt(struct fc_info *fi, u_int d_id, u_short received_ox_id, u_short reason_code, u_short expln_code) -{ -int int_required = 0; -u_int r_ctl = RCTL_ELS_SCTL; -u_int type = TYPE_ELS | EXCHANGE_RESPONDER | LAST_SEQUENCE; -int size = sizeof(LS_RJT); -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_ls_rjt"); - fi->g.ls_rjt.cmnd_code = htonl(ELS_LS_RJT); - fi->g.ls_rjt.reason_code = htonl((reason_code << 16) | expln_code); - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.ls_rjt, size); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),size, r_ctl, type, d_id, my_mtu, int_required, received_ox_id, ELS_LS_RJT); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_ls_rjt"); -} - -static void tx_abts(struct fc_info *fi, u_int d_id, u_short ox_id) -{ -int int_required = 1; -u_int r_ctl = RCTL_BASIC_ABTS; -u_int type = TYPE_BLS | SEQUENCE_INITIATIVE | FIRST_SEQUENCE; -int size = 0; -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_abts"); - fi->g.type_of_frame = FC_BLS; - tx_exchange(fi, NULL, size, r_ctl, type, d_id, my_mtu, int_required, ox_id, RCTL_BASIC_ABTS); - LEAVE("tx_abts"); -} - -static u_int plogi_ok(struct fc_info *fi, u_int *buff_addr, int size) -{ -int ret_code = 0; -u_short mtu = ntohl(*(buff_addr + 10)) & 0x00000FFF; -u_short class3 = ntohl(*(buff_addr + 25)) >> 16; -u_short class3_conc_seq = ntohl(*(buff_addr + 27)) >> 16; -u_short open_seq = ntohl(*(buff_addr + 28)) >> 16; - DPRINTK1("mtu = %x class3 = %x conc_seq = %x open_seq = %x", mtu, class3, class3_conc_seq, open_seq); - size -= TACHYON_HEADER_LEN; - if (!(class3 & 0x8000)) { - DPRINTK1("Received PLOGI with class3 = %x", class3); - ret_code = (LOGICAL_ERR << 16) | NO_EXPLN; - return ret_code; - } - if (mtu < 256) { - DPRINTK1("Received PLOGI with MTU set to %x", mtu); - ret_code = (LOGICAL_ERR << 16) | RECV_FIELD_SIZE; - return ret_code; - } - if (size != PLOGI_LEN) { - DPRINTK1("Received PLOGI of size %x", size); - ret_code = (LOGICAL_ERR << 16) | INV_PAYLOAD_LEN; - return ret_code; - } - if (class3_conc_seq == 0) { - DPRINTK1("Received PLOGI with conc_seq == 0"); - ret_code = (LOGICAL_ERR << 16) | CONC_SEQ; - return ret_code; - } - if (open_seq == 0) { - DPRINTK1("Received PLOGI with open_seq == 0"); - ret_code = (LOGICAL_ERR << 16) | NO_EXPLN; - return ret_code; - } - - /* Could potentially check for more fields, but might end up - not talking to most of the devices. ;-) */ - /* Things that could get checked are: - common_features = 0x8800 - total_concurrent_seq = at least 1 - */ - return ret_code; -} - -static void tx_acc(struct fc_info *fi, u_int d_id, u_short received_ox_id) -{ -int int_required = 0; -u_int r_ctl = RCTL_ELS_SCTL; -u_int type = TYPE_ELS | EXCHANGE_RESPONDER | LAST_SEQUENCE; -int size = sizeof(ACC); -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_acc"); - fi->g.acc.cmnd_code = htonl(ELS_ACC); - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.acc, size); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),size, r_ctl, type, d_id, my_mtu, int_required, received_ox_id, ELS_ACC); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_acc"); -} - - -static void tx_name_server_req(struct fc_info *fi, u_int req) -{ -int int_required = 1, i, size = 0; -u_short ox_id = OX_ID_FIRST_SEQUENCE; -u_int type = TYPE_FC_SERVICES | SEQUENCE_INITIATIVE | FIRST_SEQUENCE; -u_int r_ctl = FC4_DEVICE_DATA | UNSOLICITED_CONTROL; -u_int my_mtu = fi->g.my_mtu, d_id = DIRECTORY_SERVER; -CT_HDR ct_hdr; - ENTER("tx_name_server_req"); - /* Fill up CT_Header */ - ct_hdr.rev_in_id = htonl(FC_CT_REV); - ct_hdr.fs_type = DIRECTORY_SERVER_APP; - ct_hdr.fs_subtype = NAME_SERVICE; - ct_hdr.options = 0; - ct_hdr.resv1 = 0; - ct_hdr.cmnd_resp_code = htons(req >> 16); - ct_hdr.max_res_size = 0; - ct_hdr.resv2 = 0; - ct_hdr.reason_code = 0; - ct_hdr.expln_code = 0; - ct_hdr.vendor_unique = 0; - - fi->g.type_of_frame = FC_ELS; - switch(req) { - case FCS_RFC_4: - memcpy(&(fi->g.rfc_4.ct_hdr), &ct_hdr, sizeof(CT_HDR)); - fi->g.rfc_4.s_id = htonl(fi->g.my_id); - for (i = 0; i < 32; i++) - fi->g.rfc_4.bit_map[i] = 0; - /* We support IP & SCSI */ - fi->g.rfc_4.bit_map[2] = 0x01; - fi->g.rfc_4.bit_map[3] = 0x20; - size = sizeof(RFC_4); - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.rfc_4, size); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),size, r_ctl, type, d_id, my_mtu, int_required, ox_id, req); - break; - case FCS_GP_ID4: - memcpy(&(fi->g.gp_id4.ct_hdr), &ct_hdr, sizeof(CT_HDR)); - fi->g.gp_id4.port_type = htonl(PORT_TYPE_NX_PORTS); - size = sizeof(GP_ID4); - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.gp_id4, size); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),size, r_ctl, type, d_id, my_mtu, int_required, ox_id, req); - break; - } - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_name_server_req"); -} - -static void tx_scr(struct fc_info *fi) -{ -int int_required = 1, size = sizeof(SCR); -u_short ox_id = OX_ID_FIRST_SEQUENCE; -u_int type = TYPE_ELS | SEQUENCE_INITIATIVE | FIRST_SEQUENCE; -u_int r_ctl = RCTL_ELS_UCTL; -u_int my_mtu = fi->g.my_mtu, d_id = FABRIC_CONTROLLER; - ENTER("tx_scr"); - fi->g.scr.cmnd_code = htonl(ELS_SCR); - fi->g.scr.reg_function = htonl(FULL_REGISTRATION); - fi->g.type_of_frame = FC_ELS; - memcpy(fi->g.els_buffer[fi->g.e_i], &fi->g.scr, size); - tx_exchange(fi, (char *)(fi->g.els_buffer[fi->g.e_i]),size, r_ctl, type, d_id, my_mtu, int_required, ox_id, ELS_SCR); - fi->g.e_i++; - if (fi->g.e_i == MAX_PENDING_FRAMES) - fi->g.e_i = 0; - LEAVE("tx_scr"); -} - -static void perform_adisc(struct fc_info *fi) -{ -int count = 0; - /* Will be set to TRUE when timer expires in a PLDA environment. - */ - fi->g.port_discovery = FALSE; - - if (fi->node_info_list) { - struct fc_node_info *temp_list = fi->node_info_list; - while(temp_list) { - /* Tx ADISC to all non-fabric based - * entities. - */ - if ((temp_list->d_id & 0xFF0000) != 0xFF0000) - tx_adisc(fi, ELS_ADISC, temp_list->d_id, OX_ID_FIRST_SEQUENCE); - temp_list = temp_list->next; - udelay(20); - count++; - } - } - /* Perform Port Discovery after timer expires. - * We are giving time for the ADISCed nodes to respond - * so that we don't have to perform PLOGI to those whose - * login are _still_ valid. - */ - fi->explore_timer.function = port_discovery_timer; - fi->explore_timer.data = (unsigned long)fi; - fi->explore_timer.expires = RUN_AT((count*3*HZ)/100); - init_timer(&fi->explore_timer); - add_timer(&fi->explore_timer); -} - -static void explore_fabric(struct fc_info *fi, u_int *buff_addr) -{ -u_int *addr = buff_addr + 12; /* index into payload */ -u_char control_code; -u_int d_id; -int count = 0; - ENTER("explore_fabric"); - DPRINTK1("entering explore_fabric"); - - /*fi->g.perform_adisc = TRUE; - fi->g.explore_fabric = TRUE; - perform_adisc(fi);*/ - - do { - d_id = ntohl(*addr) & 0x00FFFFFF; - if (d_id != fi->g.my_id) { - if (sid_logged_in(fi, d_id) == NODE_NOT_PRESENT) - tx_logi(fi, ELS_PLOGI, d_id); - else - if (sid_logged_in(fi, d_id) == NODE_LOGGED_OUT) - tx_adisc(fi, ELS_ADISC, d_id, OX_ID_FIRST_SEQUENCE); - count++; - } - control_code = (ntohl(*addr) & 0xFF000000) >> 24; - addr++; - DPRINTK1("cc = %x, d_id = %x", control_code, d_id); - } while (control_code != 0x80); - - fi->explore_timer.function = fabric_explore_timer; - fi->explore_timer.data = (unsigned long)fi; - /* We give 30 msec for each device to respond and then send out - * our SCSI enquiries. - */ - fi->explore_timer.expires = RUN_AT((count*3*HZ)/100); - init_timer(&fi->explore_timer); - add_timer(&fi->explore_timer); - - DPRINTK1("leaving explore_fabric"); - LEAVE("explore_fabric"); -} - -static void fabric_explore_timer(unsigned long data) -{ -struct fc_info *fi = (struct fc_info*)data; - del_timer(&fi->explore_timer); - - if ((fi->g.loop_up == TRUE) && (fi->g.ptp_up == FALSE)) { - /* Initiate Local Port Discovery on the Local Loop. - */ - fi->g.port_discovery = TRUE; - fi->g.alpa_list_index = 1; - local_port_discovery(fi); - } - fi->g.explore_fabric = FALSE; - return; -} - -static void port_discovery_timer(unsigned long data) -{ -struct fc_info *fi = (struct fc_info*)data; - del_timer(&fi->explore_timer); - - if ((fi->g.loop_up == TRUE) && (fi->g.explore_fabric != TRUE)) { - fi->g.port_discovery = TRUE; - fi->g.alpa_list_index = 1; - local_port_discovery(fi); - } - fi->g.perform_adisc = FALSE; - return; -} - -static void add_to_ox_id_list(struct fc_info *fi, u_int transaction_id, u_int cmnd_code) -{ -struct ox_id_els_map *p, *q = fi->ox_id_list, *r = NULL; -int size = sizeof(struct ox_id_els_map); - while (q != NULL) { - r = q; - q = q->next; - } - p = (struct ox_id_els_map *)kmalloc(size, GFP_ATOMIC); - if (p == NULL) { - T_MSG("kmalloc failed in add_to_ox_id_list()"); - return; - } - p->ox_id = transaction_id; - p->els = cmnd_code; - p->next = NULL; - if (fi->ox_id_list == NULL) - fi->ox_id_list = p; - else - r->next = p; - return; -} - -static u_int remove_from_ox_id_list(struct fc_info *fi, u_short received_ox_id) -{ -struct ox_id_els_map *p = fi->ox_id_list, *q = fi->ox_id_list; -u_int els_type; - while (q != NULL) { - if (q->ox_id == received_ox_id) { - - if (q == fi->ox_id_list) - fi->ox_id_list = fi->ox_id_list->next; - else - if (q->next == NULL) - p->next = NULL; - else - p->next = q->next; - - els_type = q->els; - kfree(q); - return els_type; - } - p = q; - q = q->next; - } - if (q == NULL) - DPRINTK2("Could not find ox_id %x in ox_id_els_map", received_ox_id); - return 0; -} - -static void build_tachyon_header(struct fc_info *fi, u_int my_id, u_int r_ctl, u_int d_id, u_int type, u_char seq_id, u_char df_ctl, u_short ox_id, u_short rx_id, char *data) -{ -u_char alpa = d_id & 0x0000FF; -u_int dest_ddaa = d_id &0xFFFF00; - - ENTER("build_tachyon_header"); - DPRINTK("d_id = %x, my_ddaa = %x", d_id, fi->g.my_ddaa); - /* Does it have to go to/thru a Fabric? */ - if ((dest_ddaa != 0) && ((d_id == F_PORT) || (fi->g.fabric_present && (dest_ddaa != fi->g.my_ddaa)))) - alpa = 0x00; - fi->g.tach_header.resv = 0x00000000; - fi->g.tach_header.sof_and_eof = SOFI3 | EOFN; - fi->g.tach_header.dest_alpa = alpa; - /* Set LCr properly to have enuff credit */ - if (alpa == REPLICATE) - fi->g.tach_header.lcr_and_time_stamp = htons(0xC00);/* LCr=3 */ - else - fi->g.tach_header.lcr_and_time_stamp = 0; - fi->g.tach_header.r_ctl_and_d_id = htonl(r_ctl | d_id); - fi->g.tach_header.vc_id_and_s_id = htonl(my_id); - fi->g.tach_header.type_and_f_cntl = htonl(type); - fi->g.tach_header.seq_id = seq_id; - fi->g.tach_header.df_cntl = df_ctl; - fi->g.tach_header.seq_cnt = 0; - fi->g.tach_header.ox_id = htons(ox_id); - fi->g.tach_header.rx_id = htons(rx_id); - fi->g.tach_header.ro = 0; - if (data) { - /* We use the Seq_Count to keep track of IP frames in the - * OCI_interrupt handler. Initial Seq_Count of IP frames is 1. - */ - if (fi->g.type_of_frame == FC_BROADCAST) - fi->g.tach_header.seq_cnt = htons(0x1); - else - fi->g.tach_header.seq_cnt = htons(0x2); - fi->g.tach_header.nw_header.d_naa = htons(0x1000); - fi->g.tach_header.nw_header.s_naa = htons(0x1000); - memcpy(&(fi->g.tach_header.nw_header.dest_high), data, 2); - memcpy(&(fi->g.tach_header.nw_header.dest_low), data + 2, 4); - memcpy(&(fi->g.tach_header.nw_header.source_high), data + 6, 2); - memcpy(&(fi->g.tach_header.nw_header.source_low), data + 8, 4); - } - LEAVE("build_tachyon_header"); -} - -static void build_EDB(struct fc_info *fi, char *data, u_short flags, u_short len) -{ - fi->g.edb.buf_addr = ntohl((u_int)virt_to_bus(data)); - fi->g.edb.ehf = ntohs(flags); - if (len % 4) - len += (4 - (len % 4)); - fi->g.edb.buf_len = ntohs(len); -} - -static void build_ODB(struct fc_info *fi, u_char seq_id, u_int d_id, u_int len, u_int cntl, u_short mtu, u_short ox_id, u_short rx_id, int NW_header, int int_required, u_int frame_class) -{ - fi->g.odb.seq_d_id = htonl(seq_id << 24 | d_id); - fi->g.odb.tot_len = len; - if (NW_header) - fi->g.odb.tot_len += NW_HEADER_LEN; - if (fi->g.odb.tot_len % 4) - fi->g.odb.tot_len += (4 - (fi->g.odb.tot_len % 4)); - fi->g.odb.tot_len = htonl(fi->g.odb.tot_len); - switch(int_required) { - case NO_COMP_AND_INT: - fi->g.odb.cntl = htons(ODB_CLASS_3 | ODB_EE_CREDIT | ODB_NO_INT | ODB_NO_COMP | cntl); - break; - case INT_AND_COMP_REQ: - fi->g.odb.cntl = htons(ODB_CLASS_3 | ODB_EE_CREDIT | cntl); - break; - case NO_INT_COMP_REQ: - fi->g.odb.cntl = htons(ODB_CLASS_3 | ODB_EE_CREDIT | ODB_NO_INT | cntl); - break; - } - fi->g.odb.rx_id = htons(rx_id); - fi->g.odb.cs_enable = 0; - fi->g.odb.cs_seed = htons(1); - - fi->g.odb.hdr_addr = htonl(virt_to_bus(fi->q.ptr_tachyon_header[fi->q.tachyon_header_indx])); - fi->g.odb.frame_len = htons(mtu); - - if (NW_header) { - /* The pointer to the sk_buff is in here. Freed up when the - * OCI_interrupt is received. - */ - fi->g.odb.trans_id = htonl(frame_class); - fi->g.odb.hdr_len = TACHYON_HEADER_LEN + NW_HEADER_LEN; - } - else { - /* helps in tracking transmitted OX_IDs */ - fi->g.odb.trans_id = htonl((frame_class & 0xFFFF0000) | ox_id); - fi->g.odb.hdr_len = TACHYON_HEADER_LEN; - } - fi->g.odb.hdr_len = htons(fi->g.odb.hdr_len); - - fi->g.odb.edb_addr = htonl(virt_to_bus(fi->q.ptr_edb[fi->q.edb_buffer_indx])); -} - -static void fill_login_frame(struct fc_info *fi, u_int logi) -{ -int i; - fi->g.login.ls_cmnd_code= htonl(logi); - fi->g.login.fc_ph_version = htons(PH_VERSION); - if (fi->g.loop_up) - fi->g.login.buff_to_buff_credit = htons(LOOP_BB_CREDIT); - else - if (fi->g.ptp_up) - fi->g.login.buff_to_buff_credit = htons(PT2PT_BB_CREDIT); - if ((logi != ELS_FLOGI) || (logi == ELS_ACC)) - fi->g.login.common_features = htons(PLOGI_C_F); - else - if (logi == ELS_FLOGI) - fi->g.login.common_features = htons(FLOGI_C_F); - fi->g.login.recv_data_field_size = htons(TACH_FRAME_SIZE); - fi->g.login.n_port_total_conc_seq = htons(CONCURRENT_SEQUENCES); - fi->g.login.rel_off_by_info_cat = htons(RO_INFO_CATEGORY); - fi->g.login.ED_TOV = htonl(E_D_TOV); - fi->g.login.n_port_name_high = htonl(N_PORT_NAME_HIGH); - fi->g.login.n_port_name_low = htonl(N_PORT_NAME_LOW); - fi->g.login.node_name_high = htonl(NODE_NAME_HIGH); - fi->g.login.node_name_low = htonl(NODE_NAME_LOW); - - /* Fill Class 1 parameters */ - fi->g.login.c_of_s[0].service_options = htons(0); - fi->g.login.c_of_s[0].initiator_ctl = htons(0); - fi->g.login.c_of_s[0].recipient_ctl = htons(0); - fi->g.login.c_of_s[0].recv_data_field_size = htons(0); - fi->g.login.c_of_s[0].concurrent_sequences = htons(0); - fi->g.login.c_of_s[0].n_port_end_to_end_credit = htons(0); - fi->g.login.c_of_s[0].open_seq_per_exchange = htons(0); - fi->g.login.c_of_s[0].resv = htons(0); - - /* Fill Class 2 parameters */ - fi->g.login.c_of_s[1].service_options = htons(0); - fi->g.login.c_of_s[1].initiator_ctl = htons(0); - fi->g.login.c_of_s[1].recipient_ctl = htons(0); - fi->g.login.c_of_s[1].recv_data_field_size = htons(0); - fi->g.login.c_of_s[1].concurrent_sequences = htons(0); - fi->g.login.c_of_s[1].n_port_end_to_end_credit = htons(0); - fi->g.login.c_of_s[1].open_seq_per_exchange = htons(0); - fi->g.login.c_of_s[1].resv = htons(0); - - /* Fill Class 3 parameters */ - if (logi == ELS_FLOGI) - fi->g.login.c_of_s[2].service_options = htons(SERVICE_VALID | SEQUENCE_DELIVERY); - else - fi->g.login.c_of_s[2].service_options = htons(SERVICE_VALID); - fi->g.login.c_of_s[2].initiator_ctl = htons(0); - fi->g.login.c_of_s[2].recipient_ctl = htons(0); - fi->g.login.c_of_s[2].recv_data_field_size = htons(TACH_FRAME_SIZE); - fi->g.login.c_of_s[2].concurrent_sequences = htons(CLASS3_CONCURRENT_SEQUENCE); - fi->g.login.c_of_s[2].n_port_end_to_end_credit = htons(0); - fi->g.login.c_of_s[2].open_seq_per_exchange = htons(CLASS3_OPEN_SEQUENCE); - fi->g.login.c_of_s[2].resv = htons(0); - - for(i = 0; i < 4; i++) { - fi->g.login.resv[i] = 0; - fi->g.login.vendor_version_level[i] = 0; - } -} - - -/* clear the Interrupt Latch on the (i)chip, so that you can receive - * Interrupts from Tachyon in future - */ -static void reset_latch(struct fc_info *fi) -{ - writel(readl(fi->i_r.ptr_ichip_hw_status_reg) | ICHIP_HSR_INT_LATCH, fi->i_r.ptr_ichip_hw_status_reg); -} - -static void update_OCQ_indx(struct fc_info *fi) -{ - fi->q.ocq_prod_indx++; - if (fi->q.ocq_prod_indx == OCQ_LENGTH) - fi->q.ocq_prod_indx = 0; - writel(fi->q.ocq_prod_indx, fi->t_r.ptr_ocq_prod_indx_reg); -} - -static void update_IMQ_indx(struct fc_info *fi, int count) -{ - fi->q.imq_cons_indx += count; - if (fi->q.imq_cons_indx >= IMQ_LENGTH) - fi->q.imq_cons_indx -= IMQ_LENGTH; - writel(fi->q.imq_cons_indx, fi->t_r.ptr_imq_cons_indx_reg); -} - -static void update_SFSBQ_indx(struct fc_info *fi) -{ - fi->q.sfsbq_prod_indx++; - if (fi->q.sfsbq_prod_indx == SFSBQ_LENGTH) - fi->q.sfsbq_prod_indx = 0; - writel(fi->q.sfsbq_prod_indx, fi->t_r.ptr_sfsbq_prod_reg); -} - -static void update_MFSBQ_indx(struct fc_info *fi, int count) -{ - fi->q.mfsbq_prod_indx += count; - if (fi->q.mfsbq_prod_indx >= MFSBQ_LENGTH) - fi->q.mfsbq_prod_indx -= MFSBQ_LENGTH; - writel(fi->q.mfsbq_prod_indx, fi->t_r.ptr_mfsbq_prod_reg); -} - - -static void update_tachyon_header_indx(struct fc_info *fi) -{ - fi->q.tachyon_header_indx++; - if (fi->q.tachyon_header_indx == NO_OF_TACH_HEADERS) - fi->q.tachyon_header_indx = 0; -} - -static void update_EDB_indx(struct fc_info *fi) -{ - fi->q.edb_buffer_indx++; - if (fi->q.edb_buffer_indx == EDB_LEN) - fi->q.edb_buffer_indx = 0; -} - -static int iph5526_open(struct net_device *dev) -{ - netif_start_queue(dev); - return 0; -} - -static int iph5526_close(struct net_device *dev) -{ - netif_stop_queue(dev); - return 0; -} - -static void iph5526_timeout(struct net_device *dev) -{ - struct fc_info *fi = dev->priv; - printk(KERN_WARNING "%s: timed out on send.\n", dev->name); - fi->fc_stats.tx_dropped++; - dev->trans_start = jiffies; - netif_wake_queue(dev); -} - -static int iph5526_send_packet(struct sk_buff *skb, struct net_device *dev) -{ - struct fc_info *fi = dev->priv; - int status = 0; - short type = 0; - u_long flags; - struct fcllc *fcllc; - - ENTER("iph5526_send_packet"); - - netif_stop_queue(dev); - /* Strip off the pseudo header. - */ - skb->data = skb->data + 2*FC_ALEN; - skb->len = skb->len - 2*FC_ALEN; - fcllc = (struct fcllc *)skb->data; - type = ntohs(fcllc->ethertype); - - spin_lock_irqsave(&fi->fc_lock, flags); - switch(type) { - case ETH_P_IP: - status = tx_ip_packet(skb, skb->len, fi); - break; - case ETH_P_ARP: - status = tx_arp_packet(skb->data, skb->len, fi); - break; - default: - T_MSG("WARNING!!! Received Unknown Packet Type... Discarding..."); - fi->fc_stats.rx_dropped++; - break; - } - spin_unlock_irqrestore(&fi->fc_lock, flags); - - if (status) { - fi->fc_stats.tx_bytes += skb->len; - fi->fc_stats.tx_packets++; - } - else - fi->fc_stats.tx_dropped++; - dev->trans_start = jiffies; - /* We free up the IP buffers in the OCI_interrupt handler. - * status == 0 implies that the frame was not transmitted. So the - * skb is freed here. - */ - if ((type == ETH_P_ARP) || (status == 0)) - dev_kfree_skb(skb); - netif_wake_queue(dev); - LEAVE("iph5526_send_packet"); - return 0; -} - -static int iph5526_change_mtu(struct net_device *dev, int mtu) -{ - return 0; -} - -static int tx_ip_packet(struct sk_buff *skb, unsigned long len, struct fc_info *fi) -{ -u_int d_id; -int int_required = 1; -u_int r_ctl = FC4_DEVICE_DATA | UNSOLICITED_DATA; -u_int type = TYPE_LLC_SNAP; -u_short ox_id = OX_ID_FIRST_SEQUENCE; -u_int mtu; -struct fc_node_info *q; - - ENTER("tx_ip_packet"); - q = look_up_cache(fi, skb->data - 2*FC_ALEN); - if (q != NULL) { - d_id = q->d_id; - DPRINTK("Look-Up Cache Succeeded for d_id = %x", d_id); - mtu = q->mtu; - if (q->login == LOGIN_COMPLETED){ - fi->g.type_of_frame = FC_IP; - return tx_exchange(fi, skb->data, len, r_ctl, type, d_id, mtu, int_required, ox_id, virt_to_bus(skb)); - } - - if (q->d_id == BROADCAST) { - struct fc_node_info *p = fi->node_info_list; - int return_value = FALSE; - fi->g.type_of_frame = FC_BROADCAST; - /* Do unicast to local nodes. - */ - int_required = 0; - while(p != NULL) { - d_id = p->d_id; - if ((d_id & 0xFFFF00) == fi->g.my_ddaa) - return_value |= tx_exchange(fi, skb->data, len, r_ctl, type, d_id, fi->g.my_mtu, int_required, ox_id, TYPE_LLC_SNAP); - p = p->next; - } - kfree(q); - return return_value; - } - - if (q->login != LOGIN_COMPLETED) { - DPRINTK1("Node not logged in... Txing PLOGI to %x", d_id); - /* FIXME: we are dumping the frame here */ - tx_logi(fi, ELS_PLOGI, d_id); - } - } - DPRINTK2("Look-Up Cache Failed"); - LEAVE("tx_ip_packet"); - return 0; -} - -static int tx_arp_packet(char *data, unsigned long len, struct fc_info *fi) -{ -u_int opcode = data[ARP_OPCODE_0]; -u_int d_id; -int int_required = 0, return_value = FALSE; -u_int r_ctl = FC4_DEVICE_DATA | UNSOLICITED_DATA; -u_int type = TYPE_LLC_SNAP; -u_short ox_id = OX_ID_FIRST_SEQUENCE; -u_int my_mtu = fi->g.my_mtu; - ENTER("tx_arp_packet"); - - opcode = opcode << 8 | data[ARP_OPCODE_1]; - fi->g.type_of_frame = FC_IP; - - if (opcode == ARPOP_REQUEST) { - struct fc_node_info *q = fi->node_info_list; - d_id = BROADCAST; - return_value |= tx_exchange(fi, data, len, r_ctl, type, d_id, my_mtu, int_required, ox_id, TYPE_LLC_SNAP); - /* Some devices support HW_TYPE 0x01 */ - memcpy(fi->g.arp_buffer, data - 2*FC_ALEN, len + 2*FC_ALEN); - fi->g.arp_buffer[9 + 2*FC_ALEN] = 0x01; - return_value |= tx_exchange(fi, (char *)(fi->g.arp_buffer + 2*FC_ALEN), len, r_ctl, type, d_id, my_mtu, int_required, ox_id, TYPE_LLC_SNAP); - - /* Do unicast to local nodes. - */ - while(q != NULL) { - fi->g.type_of_frame = FC_BROADCAST; - d_id = q->d_id; - if ((d_id & 0xFFFF00) == fi->g.my_ddaa) { - return_value |= tx_exchange(fi, data, len, r_ctl, type, d_id, my_mtu, int_required, ox_id, TYPE_LLC_SNAP); - // Some devices support HW_TYPE 0x01 - memcpy(fi->g.arp_buffer, data - 2*FC_ALEN, len + 2*FC_ALEN); - fi->g.arp_buffer[9 + 2*FC_ALEN] = 0x01; - return_value |= tx_exchange(fi, (char *)(fi->g.arp_buffer + 2*FC_ALEN), len, r_ctl, type, d_id, my_mtu, int_required, ox_id, TYPE_LLC_SNAP); - } - q = q->next; - } - return return_value; - } - else - if (opcode == ARPOP_REPLY) { - struct fc_node_info *q; u_int mtu; - DPRINTK("We are sending out an ARP reply"); - q = look_up_cache(fi, data - 2*FC_ALEN); - if (q != NULL) { - d_id = q->d_id; - DPRINTK("Look-Up Cache Succeeded for d_id = %x", d_id); - mtu = q->mtu; - if (q->login == LOGIN_COMPLETED){ - tx_exchange(fi, data, len, r_ctl, type, d_id, mtu, int_required, ox_id, TYPE_LLC_SNAP); - /* Some devices support HW_TYPE 0x01 */ - memcpy(fi->g.arp_buffer, data - 2*FC_ALEN, len + 2*FC_ALEN); - fi->g.arp_buffer[9 + 2*FC_ALEN] = 0x01; - return tx_exchange(fi, (char *)(fi->g.arp_buffer + 2*FC_ALEN), len, r_ctl, type, d_id, my_mtu, int_required, ox_id, TYPE_LLC_SNAP); - } - else { - DPRINTK1("Node not logged in... Txing PLOGI to %x", d_id); - tx_logi(fi, ELS_PLOGI, d_id); /* FIXME: we are dumping the frame here */ - } - } - DPRINTK2("Look-Up Cache Failed"); - } - else { - T_MSG("Warning!!! Invalid Opcode in ARP Packet!"); - } - LEAVE("tx_arp_packet"); - return 0; -} - - -static void rx_net_packet(struct fc_info *fi, u_char *buff_addr, int payload_size) -{ -struct net_device *dev = fi->dev; -struct sk_buff *skb; -u_int skb_size = 0; -struct fch_hdr fch; - ENTER("rx_net_packet"); - skb_size = payload_size - TACHYON_HEADER_LEN; - DPRINTK("skb_size = %d", skb_size); - fi->fc_stats.rx_bytes += skb_size - 2; - skb = dev_alloc_skb(skb_size); - if (skb == NULL) { - printk(KERN_NOTICE "%s: In rx_net_packet() Memory squeeze, dropping packet.\n", dev->name); - fi->fc_stats.rx_dropped++; - return; - } - /* Skip over the Tachyon Frame Header. - */ - buff_addr += TACHYON_HEADER_LEN; - - memcpy(fch.daddr, buff_addr + 2, FC_ALEN); - memcpy(fch.saddr, buff_addr + 10, FC_ALEN); - buff_addr += 2; - memcpy(buff_addr, fch.daddr, FC_ALEN); - memcpy(buff_addr + 6, fch.saddr, FC_ALEN); - skb_reserve(skb, 2); - memcpy(skb_put(skb, skb_size - 2), buff_addr, skb_size - 2); - skb->dev = dev; - skb->protocol = fc_type_trans(skb, dev); - DPRINTK("protocol = %x", skb->protocol); - - /* Hmmm... to accept HW Type 0x01 as well... - */ - if (skb->protocol == ntohs(ETH_P_ARP)) - skb->data[1] = 0x06; - netif_rx(skb); - dev->last_rx = jiffies; - fi->fc_stats.rx_packets++; - LEAVE("rx_net_packet"); -} - - -static void rx_net_mfs_packet(struct fc_info *fi, struct sk_buff *skb) -{ -struct net_device *dev = fi->dev; -struct fch_hdr fch; - ENTER("rx_net_mfs_packet"); - /* Construct your Hard Header */ - memcpy(fch.daddr, skb->data + 2, FC_ALEN); - memcpy(fch.saddr, skb->data + 10, FC_ALEN); - skb_pull(skb, 2); - memcpy(skb->data, fch.daddr, FC_ALEN); - memcpy(skb->data + 6, fch.saddr, FC_ALEN); - skb->dev = dev; - skb->protocol = fc_type_trans(skb, dev); - DPRINTK("protocol = %x", skb->protocol); - netif_rx(skb); - dev->last_rx = jiffies; - LEAVE("rx_net_mfs_packet"); -} - -static int tx_exchange(struct fc_info *fi, char *data, u_int len, u_int r_ctl, u_int type, u_int d_id, u_int mtu, int int_required, u_short tx_ox_id, u_int frame_class) -{ -u_char df_ctl; -int NW_flag = 0, h_size, return_value; -u_short rx_id = RX_ID_FIRST_SEQUENCE; -u_int tachyon_status; -u_int my_id = fi->g.my_id; - ENTER("tx_exchange"); - - tachyon_status = readl(fi->t_r.ptr_tach_status_reg); - DPRINTK("Tachyon Status = %x len = %d MTU = %d", tachyon_status, len, mtu); - if (tachyon_status & OSM_FROZEN) { - reset_tachyon(fi, ERROR_RELEASE); - reset_tachyon(fi, OCQ_RESET); - DPRINTK("Tachyon Status = %x len = %d MTU = %d", tachyon_status, len, mtu); - } - if (tx_ox_id == OX_ID_FIRST_SEQUENCE) { - switch(fi->g.type_of_frame) { - case FC_SCSI_READ: - tx_ox_id = fi->g.scsi_oxid | SCSI_READ_BIT; - break; - case FC_SCSI_WRITE: - tx_ox_id = fi->g.scsi_oxid; - break; - default: - tx_ox_id = fi->g.ox_id; - break; - } - } - else { - switch(fi->g.type_of_frame) { - case FC_SCSI_READ: - rx_id = fi->g.scsi_oxid | SCSI_READ_BIT; - break; - case FC_SCSI_WRITE: - rx_id = fi->g.scsi_oxid; - break; - case FC_BLS: - rx_id = RX_ID_FIRST_SEQUENCE; - break; - default: - rx_id = fi->g.ox_id; - break; - } - } - - if (type == TYPE_LLC_SNAP) { - df_ctl = 0x20; - NW_flag = 1; - /* Multi Frame Sequence ? If yes, set RO bit */ - if (len > mtu) - type |= RELATIVE_OFF_PRESENT; - build_tachyon_header(fi, my_id, r_ctl, d_id, type, fi->g.seq_id, df_ctl, tx_ox_id, rx_id, data - 2*FC_ALEN); - } - else { - df_ctl = 0; - /* Multi Frame Sequence ? If yes, set RO bit */ - if (len > mtu) - type |= RELATIVE_OFF_PRESENT; - build_tachyon_header(fi, my_id, r_ctl, d_id, type, fi->g.seq_id, df_ctl, tx_ox_id, rx_id, NULL); - } - - /* Get free Tachyon Headers and EDBs */ - if (get_free_header(fi) || get_free_EDB(fi)) - return 0; - - if ((type & 0xFF000000) == TYPE_LLC_SNAP) { - h_size = TACHYON_HEADER_LEN + NW_HEADER_LEN; - memcpy(fi->q.ptr_tachyon_header[fi->q.tachyon_header_indx], &(fi->g.tach_header), h_size); - } - else - memcpy(fi->q.ptr_tachyon_header[fi->q.tachyon_header_indx], &(fi->g.tach_header), TACHYON_HEADER_LEN); - - return_value = tx_sequence(fi, data, len, mtu, d_id, tx_ox_id, rx_id, fi->g.seq_id, NW_flag, int_required, frame_class); - - switch(fi->g.type_of_frame) { - case FC_SCSI_READ: - case FC_SCSI_WRITE: - update_scsi_oxid(fi); - break; - case FC_BLS: - break; - default: - fi->g.ox_id++; - if (fi->g.ox_id == 0xFFFF) - fi->g.ox_id = NOT_SCSI_XID; - break; - } - - if (fi->g.seq_id == MAX_SEQ_ID) - fi->g.seq_id = 0; - else - fi->g.seq_id++; - LEAVE("tx_exchange"); - return return_value; -} - -static int tx_sequence(struct fc_info *fi, char *data, u_int len, u_int mtu, u_int d_id, u_short ox_id, u_short rx_id, u_char seq_id, int NW_flag, int int_required, u_int frame_class) -{ -u_int cntl = 0; -int return_value; - ENTER("tx_sequence"); - build_EDB(fi, data, EDB_END, len); - memcpy(fi->q.ptr_edb[fi->q.edb_buffer_indx], &(fi->g.edb), sizeof(EDB)); - build_ODB(fi, seq_id, d_id, len, cntl, mtu, ox_id, rx_id, NW_flag, int_required, frame_class); - memcpy(fi->q.ptr_odb[fi->q.ocq_prod_indx], &(fi->g.odb), sizeof(ODB)); - if (fi->g.link_up != TRUE) { - DPRINTK2("Fibre Channel Link not up. Dropping Exchange!"); - return_value = FALSE; - } - else { - /* To be on the safe side, a check should be included - * at this point to check if we are overrunning - * Tachyon. - */ - update_OCQ_indx(fi); - return_value = TRUE; - } - update_EDB_indx(fi); - update_tachyon_header_indx(fi); - LEAVE("tx_sequence"); - return return_value; -} - -static int get_free_header(struct fc_info *fi) -{ -u_short temp_ox_id; -u_int *tach_header, initial_indx = fi->q.tachyon_header_indx; - /* Check if the header is in use. - * We could have an outstanding command. - * We should find a free slot as we can queue a - * maximum of 32 SCSI commands only. - */ - tach_header = fi->q.ptr_tachyon_header[fi->q.tachyon_header_indx]; - temp_ox_id = ntohl(*(tach_header + 6)) >> 16; - /* We care about the SCSI writes only. Those are the wicked ones - * that need an additional set of buffers. - */ - while(temp_ox_id <= MAX_SCSI_XID) { - update_tachyon_header_indx(fi); - if (fi->q.tachyon_header_indx == initial_indx) { - /* Should never happen. - */ - T_MSG("No free Tachyon headers available"); - reset_tachyon(fi, SOFTWARE_RESET); - return 1; - } - tach_header = fi->q.ptr_tachyon_header[fi->q.tachyon_header_indx]; - temp_ox_id = ntohl(*(tach_header + 6)) >> 16; - } - return 0; -} - -static int get_free_EDB(struct fc_info *fi) -{ -unsigned int initial_indx = fi->q.edb_buffer_indx; - /* Check if the EDB is in use. - * We could have an outstanding SCSI Write command. - * We should find a free slot as we can queue a - * maximum of 32 SCSI commands only. - */ - while (fi->q.free_edb_list[fi->q.edb_buffer_indx] != EDB_FREE) { - update_EDB_indx(fi); - if (fi->q.edb_buffer_indx == initial_indx) { - T_MSG("No free EDB buffers avaliable") - reset_tachyon(fi, SOFTWARE_RESET); - return 1; - } - } - return 0; -} - -static int validate_login(struct fc_info *fi, u_int *base_ptr) -{ -struct fc_node_info *q = fi->node_info_list; -char n_port_name[PORT_NAME_LEN]; -char node_name[NODE_NAME_LEN]; -u_int s_id; - ENTER("validate_login"); - /*index to Port Name in the payload. We need the 8 byte Port Name */ - memcpy(n_port_name, base_ptr + 10, PORT_NAME_LEN); - memcpy(node_name, base_ptr + 12, NODE_NAME_LEN); - s_id = ntohl(*(base_ptr + 3)) & 0x00FFFFFF; - - /* check if Fibre Channel IDs have changed */ - while(q != NULL) { - if (memcmp(n_port_name, q->hw_addr, PORT_NAME_LEN) == 0) { - if ((s_id != q->d_id) || (memcmp(node_name, q->node_name, NODE_NAME_LEN) != 0)) { - DPRINTK1("Fibre Channel ID of Node has changed. Txing LOGO."); - return 0; - } - q->login = LOGIN_COMPLETED; -#if DEBUG_5526_2 - display_cache(fi); -#endif - return 1; - } - q = q->next; - } - DPRINTK1("Port Name does not match. Txing LOGO."); - LEAVE("validate_login"); - return 0; -} - -static void add_to_address_cache(struct fc_info *fi, u_int *base_ptr) -{ -int size = sizeof(struct fc_node_info); -struct fc_node_info *p, *q = fi->node_info_list, *r = NULL; -char n_port_name[PORT_NAME_LEN]; -u_int s_id; - ENTER("add_to_address_cache"); - /*index to Port Name in the payload. We need the 8 byte Port Name */ - memcpy(n_port_name, base_ptr + 13, PORT_NAME_LEN); - s_id = ntohl(*(base_ptr + 3)) & 0x00FFFFFF; - - /* check if info already exists */ - while(q != NULL) { - if (memcmp(n_port_name, q->hw_addr, PORT_NAME_LEN) == 0) { - if (s_id != q->d_id) { - memcpy(&(q->c_of_s[0]), base_ptr + 17, 3 * sizeof(CLASS_OF_SERVICE)); - q->mtu = ntohl(*(base_ptr + 10)) & 0x00000FFF; - q->d_id = s_id; - memcpy(q->node_name, base_ptr + 15, NODE_NAME_LEN); - } - q->login = LOGIN_COMPLETED; - q->scsi = FALSE; - fi->num_nodes++; -#if DEBUG_5526_2 - display_cache(fi); -#endif - return; - } - r = q; - q = q->next; - } - p = (struct fc_node_info *)kmalloc(size, GFP_ATOMIC); - if (p == NULL) { - T_MSG("kmalloc failed in add_to_address_cache()"); - return; - } - memcpy(&(p->c_of_s[0]), base_ptr + 17, 3 * sizeof(CLASS_OF_SERVICE)); - p->mtu = ntohl(*(base_ptr + 10)) & 0x00000FFF; - p->d_id = s_id; - memcpy(p->hw_addr, base_ptr + 13, PORT_NAME_LEN); - memcpy(p->node_name, base_ptr + 15, NODE_NAME_LEN); - p->login = LOGIN_COMPLETED; - p->scsi = FALSE; - p->target_id = 0xFF; - p->next = NULL; - if (fi->node_info_list == NULL) - fi->node_info_list = p; - else - r->next = p; - fi->num_nodes++; -#if DEBUG_5526_2 - display_cache(fi); -#endif - LEAVE("add_to_address_cache"); - return; -} - -static void remove_from_address_cache(struct fc_info *fi, u_int *base_ptr, u_int cmnd_code) -{ -struct fc_node_info *q = fi->node_info_list; -u_int s_id; - ENTER("remove_from_address_cache"); - s_id = ntohl(*(base_ptr + 3)) & 0x00FFFFFF; - switch(cmnd_code) { - case ELS_LOGO: - /* check if info exists */ - while (q != NULL) { - if (s_id == q->d_id) { - if (q->login == LOGIN_COMPLETED) - q->login = LOGIN_ATTEMPTED; - if (fi->num_nodes > 0) - fi->num_nodes--; -#if DEBUG_5526_2 - display_cache(fi); -#endif - return; - } - q = q->next; - } - DPRINTK1("ELS_LOGO received from node 0x%x which is not logged-in", s_id); - break; - case ELS_RSCN: - { - int payload_len = ntohl(*(base_ptr + 8)) & 0xFF; - int no_of_pages, i; - u_char address_format; - u_short received_ox_id = ntohl(*(base_ptr + 6)) >> 16; - u_int node_id, mask, *page_ptr = base_ptr + 9; - if ((payload_len < 4) || (payload_len > 256)) { - DPRINTK1("RSCN with invalid payload length received"); - tx_ls_rjt(fi, s_id, received_ox_id, LOGICAL_ERR, RECV_FIELD_SIZE); - return; - } - /* Page_size includes the Command Code */ - no_of_pages = (payload_len / 4) - 1; - for (i = 0; i < no_of_pages; i++) { - address_format = ntohl(*page_ptr) >> 24; - node_id = ntohl(*page_ptr) & 0x00FFFFFF; - switch(address_format) { - case PORT_ADDRESS_FORMAT: - rscn_handler(fi, node_id); - break; - case AREA_ADDRESS_FORMAT: - case DOMAIN_ADDRESS_FORMAT: - if (address_format == AREA_ADDRESS_FORMAT) - mask = 0xFFFF00; - else - mask = 0xFF0000; - while(q != NULL) { - if ((q->d_id & mask) == (node_id & mask)) - rscn_handler(fi, q->d_id); - q = q->next; - } - /* There might be some new nodes to be - * discovered. But, some of the earlier - * requests as a result of the RSCN might be - * in progress. We don't want to duplicate that - * effort. So letz call SCR after a lag. - */ - fi->explore_timer.function = scr_timer; - fi->explore_timer.data = (unsigned long)fi; - fi->explore_timer.expires = RUN_AT((no_of_pages*3*HZ)/100); - init_timer(&fi->explore_timer); - add_timer(&fi->explore_timer); - break; - default: - T_MSG("RSCN with invalid address format received"); - tx_ls_rjt(fi, s_id, received_ox_id, LOGICAL_ERR, NO_EXPLN); - } - page_ptr += 1; - } /* end of for loop */ - } /* end of case RSCN: */ - break; - } -#if DEBUG_5526_2 - display_cache(fi); -#endif - LEAVE("remove_from_address_cache"); -} - -static void rscn_handler(struct fc_info *fi, u_int node_id) -{ -struct fc_node_info *q = fi->node_info_list; -int login_state = sid_logged_in(fi, node_id); - if ((login_state == NODE_LOGGED_IN) || (login_state == NODE_PROCESS_LOGGED_IN)) { - while(q != NULL) { - if (q->d_id == node_id) { - q->login = LOGIN_ATTEMPTED; - if (fi->num_nodes > 0) - fi->num_nodes--; - break; - } - else - q = q->next; - } - } - else - if (login_state == NODE_LOGGED_OUT) - tx_adisc(fi, ELS_ADISC, node_id, OX_ID_FIRST_SEQUENCE); - else - if (login_state == NODE_LOGGED_OUT) - tx_logi(fi, ELS_PLOGI, node_id); -} - -static void scr_timer(unsigned long data) -{ -struct fc_info *fi = (struct fc_info *)data; - del_timer(&fi->explore_timer); - tx_name_server_req(fi, FCS_GP_ID4); -} - -static int sid_logged_in(struct fc_info *fi, u_int s_id) -{ -struct fc_node_info *temp = fi->node_info_list; - while(temp != NULL) - if ((temp->d_id == s_id) && (temp->login == LOGIN_COMPLETED)) { - if (temp->scsi != FALSE) - return NODE_PROCESS_LOGGED_IN; - else - return NODE_LOGGED_IN; - } - else - if ((temp->d_id == s_id) && (temp->login != LOGIN_COMPLETED)) - return NODE_LOGGED_OUT; - else - temp = temp->next; - return NODE_NOT_PRESENT; -} - -static void mark_scsi_sid(struct fc_info *fi, u_int *buff_addr, u_char action) -{ -struct fc_node_info *temp = fi->node_info_list; -u_int s_id; -u_int service_params; - s_id = ntohl(*(buff_addr + 3)) & 0x00FFFFFF; - service_params = ntohl(*(buff_addr + 12)) & 0x000000F0; - while(temp != NULL) - if ((temp->d_id == s_id) && (temp->login == LOGIN_COMPLETED)) { - if (action == DELETE_ENTRY) { - temp->scsi = FALSE; -#if DEBUG_5526_2 - display_cache(fi); -#endif - return; - } - /* Check if it is a SCSI Target */ - if (!(service_params & TARGET_FUNC)) { - temp->scsi = INITIATOR; -#if DEBUG_5526_2 - display_cache(fi); -#endif - return; - } - temp->scsi = TARGET; - /* This helps to maintain the target_id no matter what your - * Fibre Channel ID is. - */ - if (temp->target_id == 0xFF) { - if (fi->g.no_of_targets <= MAX_SCSI_TARGETS) - temp->target_id = fi->g.no_of_targets++; - else - T_MSG("MAX TARGETS reached!"); - } - else - DPRINTK1("Target_id %d already present", temp->target_id); -#if DEBUG_5526_2 - display_cache(fi); -#endif - return; - } - else - temp = temp->next; - return; -} - -static int node_logged_in_prev(struct fc_info *fi, u_int *buff_addr) -{ -struct fc_node_info *temp; -u_char *data = (u_char *)buff_addr; -u_int s_id; -char node_name[NODE_NAME_LEN]; - s_id = ntohl(*(buff_addr + 3)) & 0x00FFFFFF; - memcpy(node_name, buff_addr + 12, NODE_NAME_LEN); - /* point to port_name in the ADISC payload */ - data += 10 * 4; - /* point to last 6 bytes of port_name */ - data += 2; - temp = look_up_cache(fi, data); - if (temp != NULL) { - if ((temp->d_id == s_id) && (memcmp(node_name, temp->node_name, NODE_NAME_LEN) == 0)) { - temp->login = LOGIN_COMPLETED; -#if DEBUG_5526_2 - display_cache(fi); -#endif - return TRUE; - } - } - return FALSE; -} - -static struct fc_node_info *look_up_cache(struct fc_info *fi, char *data) -{ -struct fc_node_info *temp_list = fi->node_info_list, *q; -u_char n_port_name[FC_ALEN], temp_addr[FC_ALEN]; - ENTER("look_up_cache"); - memcpy(n_port_name, data, FC_ALEN); - while(temp_list) { - if (memcmp(n_port_name, &(temp_list->hw_addr[2]), FC_ALEN) == 0) - return temp_list; - else - temp_list = temp_list->next; - } - - /* Broadcast IP ? - */ - temp_addr[0] = temp_addr[1] = temp_addr[2] = 0xFF; - temp_addr[3] = temp_addr[4] = temp_addr[5] = 0xFF; - if (memcmp(n_port_name, temp_addr, FC_ALEN) == 0) { - q = (struct fc_node_info *)kmalloc(sizeof(struct fc_node_info), GFP_ATOMIC); - if (q == NULL) { - T_MSG("kmalloc failed in look_up_cache()"); - return NULL; - } - q->d_id = BROADCAST; - return q; - } - LEAVE("look_up_cache"); - return NULL; -} - -static int display_cache(struct fc_info *fi) -{ -struct fc_node_info *q = fi->node_info_list; -#if DEBUG_5526_2 -struct ox_id_els_map *temp_ox_id_list = fi->ox_id_list; -#endif -int count = 0, j; - printk("\nFibre Channel Node Information for %s\n", fi->name); - printk("My FC_ID = %x, My WWN = %x %x, ", fi->g.my_id, fi->g.my_node_name_high, fi->g.my_node_name_low); - if (fi->g.ptp_up == TRUE) - printk("Port_Type = N_Port\n"); - if (fi->g.loop_up == TRUE) - printk("Port_Type = L_Port\n"); - while(q != NULL) { - printk("WWN = "); - for (j = 0; j < PORT_NAME_LEN; j++) - printk("%x ", q->hw_addr[j]); - printk("FC_ID = %x, ", q->d_id); - printk("Login = "); - if (q->login == LOGIN_COMPLETED) - printk("ON "); - else - printk("OFF "); - if (q->scsi == TARGET) - printk("Target_ID = %d ", q->target_id); - printk("\n"); - q = q->next; - count++; - } - -#if DEBUG_5526_2 - printk("OX_ID -> ELS Map\n"); - while(temp_ox_id_list) { - printk("ox_id = %x, ELS = %x\n", temp_ox_id_list->ox_id, temp_ox_id_list->els); - temp_ox_id_list = temp_ox_id_list->next; - } -#endif - - return 0; -} - -static struct net_device_stats * iph5526_get_stats(struct net_device *dev) -{ -struct fc_info *fi = dev->priv; - return (struct net_device_stats *) &fi->fc_stats; -} - - -/* SCSI stuff starts here */ - -int iph5526_detect(Scsi_Host_Template *tmpt) -{ - struct Scsi_Host *host = NULL; - struct iph5526_hostdata *hostdata; - struct fc_info *fi = NULL; - int no_of_hosts = 0, i, j, count = 0; - u_int pci_maddr = 0; - struct pci_dev *pdev = NULL; - unsigned long timeout; - - tmpt->proc_name = "iph5526"; - - for (i = 0; i <= MAX_FC_CARDS; i++) - fc[i] = NULL; - - for (i = 0; clone_list[i].vendor_id != 0; i++) - while ((pdev = pci_find_device(clone_list[i].vendor_id, clone_list[i].device_id, pdev))) { - unsigned short pci_command; - if (pci_enable_device(pdev)) - continue; - if (count < MAX_FC_CARDS) { - fc[count] = kmalloc(sizeof(struct fc_info), GFP_ATOMIC); - if (fc[count] == NULL) { - printk("iph5526.c: Unable to register card # %d\n", count + 1); - return no_of_hosts; - } - memset(fc[count], 0, sizeof(struct fc_info)); - } - else { - printk("iph5526.c: Maximum Number of cards reached.\n"); - return no_of_hosts; - } - - fi = fc[count]; - sprintf(fi->name, "fc%d", count); - - host = scsi_register(tmpt, sizeof(struct iph5526_hostdata)); - if(host==NULL) { - kfree(fc[count]); - return no_of_hosts; - } - - hostdata = (struct iph5526_hostdata *)host->hostdata; - memset(hostdata, 0 , sizeof(struct iph5526_hostdata)); - for (j = 0; j < MAX_SCSI_TARGETS; j++) - hostdata->tag_ages[j] = jiffies; - hostdata->fi = fi; - fi->host = host; - //host->max_id = MAX_SCSI_TARGETS; - host->max_id = 5; - host->this_id = tmpt->this_id; - - pci_maddr = pci_resource_start(pdev, 0); - if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) { - printk("iph5526.c : Cannot find proper PCI device base address.\n"); - scsi_unregister(host); - kfree(fc[count]); - fc[count] = NULL; - continue; - } - - DPRINTK("pci_maddr = %x", pci_maddr); - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - - pci_irq_line = pdev->irq; - printk("iph5526.c: PCI BIOS reports %s at i/o %#x, irq %d.\n", clone_list[i].name, pci_maddr, pci_irq_line); - fi->g.mem_base = ioremap(pci_maddr & PAGE_MASK, 1024); - - /* We use Memory Mapped IO. The initial space contains the - * PCI Configuration registers followed by the (i) chip - * registers followed by the Tachyon registers. - */ - /* Thatz where (i)chip maps Tachyon Address Space. - */ - fi->g.tachyon_base = (u_long)fi->g.mem_base + TACHYON_OFFSET + ( pci_maddr & ~PAGE_MASK ); - DPRINTK("fi->g.tachyon_base = %x", (u_int)fi->g.tachyon_base); - if (fi->g.mem_base == NULL) { - printk("iph5526.c : ioremap failed!!!\n"); - scsi_unregister(host); - kfree(fc[count]); - fc[count] = NULL; - continue; - } - DPRINTK("IRQ1 = %d\n", pci_irq_line); - printk(version); - fi->base_addr = (long) pdev; - - if (pci_irq_line) { - int irqval = 0; - /* Found it, get IRQ. - */ - irqval = request_irq(pci_irq_line, &tachyon_interrupt, pci_irq_line ? SA_SHIRQ : 0, fi->name, host); - if (irqval) { - printk("iph5526.c : Unable to get IRQ %d (irqval = %d).\n", pci_irq_line, irqval); - scsi_unregister(host); - kfree(fc[count]); - fc[count] = NULL; - continue; - } - host->irq = fi->irq = pci_irq_line; - pci_irq_line = 0; - fi->clone_id = clone_list[i].vendor_id; - } - - if (!initialize_register_pointers(fi) || !tachyon_init(fi)) { - printk("iph5526.c: TACHYON initialization failed for card # %d!!!\n", count + 1); - free_irq(host->irq, host); - scsi_unregister(host); - if (fi) - clean_up_memory(fi); - kfree(fc[count]); - fc[count] = NULL; - break; - } - DPRINTK1("Fibre Channel card initialized"); - /* Wait for the Link to come up and the login process - * to complete. - */ - for(timeout = jiffies + 10*HZ; time_before(jiffies, timeout) && ((fi->g.link_up == FALSE) || (fi->g.port_discovery == TRUE) || (fi->g.explore_fabric == TRUE) || (fi->g.perform_adisc == TRUE));) - { - cpu_relax(); - barrier(); - } - - count++; - no_of_hosts++; - } - DPRINTK1("no_of_hosts = %d",no_of_hosts); - - /* This is to make sure that the ACC to the PRLI comes in - * for the last ALPA. - */ - mdelay(1000); /* Ugly! Let the Gods forgive me */ - - DPRINTK1("leaving iph5526_detect\n"); - return no_of_hosts; -} - - -int iph5526_biosparam(struct scsi_device *sdev, struct block_device *n, - sector_t capacity, int ip[]) -{ -int size = capacity; - ip[0] = 64; - ip[1] = 32; - ip[2] = size >> 11; - if (ip[2] > 1024) { - ip[0] = 255; - ip[1] = 63; - ip[2] = size / (ip[0] * ip[1]); - } - return 0; -} - -int iph5526_queuecommand(Scsi_Cmnd *Cmnd, void (*done) (Scsi_Cmnd *)) -{ -int int_required = 0; -u_int r_ctl = FC4_DEVICE_DATA | UNSOLICITED_COMMAND; -u_int type = TYPE_FCP | SEQUENCE_INITIATIVE; -u_int frame_class = Cmnd->device->id; -u_short ox_id = OX_ID_FIRST_SEQUENCE; -struct Scsi_Host *host = Cmnd->device->host; -struct iph5526_hostdata *hostdata = (struct iph5526_hostdata*)host->hostdata; -struct fc_info *fi = hostdata->fi; -struct fc_node_info *q; -u_long flags; - ENTER("iph5526_queuecommand"); - - spin_lock_irqsave(&fi->fc_lock, flags); - Cmnd->scsi_done = done; - - if (Cmnd->device->tagged_supported) { - switch(Cmnd->tag) { - case SIMPLE_QUEUE_TAG: - hostdata->cmnd.fcp_cntl = FCP_CNTL_QTYPE_SIMPLE; - break; - case HEAD_OF_QUEUE_TAG: - hostdata->cmnd.fcp_cntl = FCP_CNTL_QTYPE_HEAD_OF_Q; - break; - case ORDERED_QUEUE_TAG: - hostdata->cmnd.fcp_cntl = FCP_CNTL_QTYPE_ORDERED; - break; - default: - if ((jiffies - hostdata->tag_ages[Cmnd->device->id]) > (5 * HZ)) { - hostdata->cmnd.fcp_cntl = FCP_CNTL_QTYPE_ORDERED; - hostdata->tag_ages[Cmnd->device->id] = jiffies; - } - else - hostdata->cmnd.fcp_cntl = FCP_CNTL_QTYPE_SIMPLE; - break; - } - } - /*else - hostdata->cmnd.fcp_cntl = FCP_CNTL_QTYPE_UNTAGGED; - */ - - hostdata->cmnd.fcp_addr[3] = 0; - hostdata->cmnd.fcp_addr[2] = 0; - hostdata->cmnd.fcp_addr[1] = 0; - hostdata->cmnd.fcp_addr[0] = htons(Cmnd->device->lun); - - memcpy(&hostdata->cmnd.fcp_cdb, Cmnd->cmnd, Cmnd->cmd_len); - hostdata->cmnd.fcp_data_len = htonl(Cmnd->request_bufflen); - - /* Get an used OX_ID. We could have pending commands. - */ - if (get_scsi_oxid(fi)) { - spin_unlock_irqrestore(&fi->fc_lock, flags); - return 1; - } - fi->q.free_scsi_oxid[fi->g.scsi_oxid] = OXID_INUSE; - - /* Maintain a handler so that we can associate the done() function - * on completion of the SCSI command. - */ - hostdata->cmnd_handler[fi->g.scsi_oxid] = Cmnd; - - switch(Cmnd->cmnd[0]) { - case WRITE_6: - case WRITE_10: - case WRITE_12: - fi->g.type_of_frame = FC_SCSI_WRITE; - hostdata->cmnd.fcp_cntl = htonl(FCP_CNTL_WRITE | hostdata->cmnd.fcp_cntl); - break; - default: - fi->g.type_of_frame = FC_SCSI_READ; - hostdata->cmnd.fcp_cntl = htonl(FCP_CNTL_READ | hostdata->cmnd.fcp_cntl); - } - - memcpy(fi->q.ptr_fcp_cmnd[fi->q.fcp_cmnd_indx], &(hostdata->cmnd), sizeof(fcp_cmd)); - - q = resolve_target(fi, Cmnd->device->id); - - if (q == NULL) { - u_int bad_id = fi->g.my_ddaa | 0xFE; - /* We transmit to an non-existant AL_PA so that the "done" - * function can be called while receiving the interrupt - * due to a Timeout for a bad AL_PA. In a PTP configuration, - * the int_required field is set, since there is no notion - * of AL_PAs. This approach sucks, but works alright! - */ - if (fi->g.ptp_up == TRUE) - int_required = 1; - tx_exchange(fi, (char *)(&(hostdata->cmnd)), sizeof(fcp_cmd), r_ctl, type, bad_id, fi->g.my_mtu, int_required, ox_id, FC_SCSI_BAD_TARGET); - spin_unlock_irqrestore(&fi->fc_lock, flags); - DPRINTK1("Target ID %x not present", Cmnd->target); - return 0; - } - if (q->login == LOGIN_COMPLETED) { - if (add_to_sest(fi, Cmnd, q)) { - DPRINTK1("add_to_sest() failed."); - spin_unlock_irqrestore(&fi->fc_lock, flags); - return 0; - } - tx_exchange(fi, (char *)(fi->q.ptr_fcp_cmnd[fi->q.fcp_cmnd_indx]), sizeof(fcp_cmd), r_ctl, type, q->d_id, q->mtu, int_required, ox_id, frame_class << 16); - update_FCP_CMND_indx(fi); - } - spin_unlock_irqrestore(&fi->fc_lock, flags); - /* If q != NULL, then we have a SCSI Target. - * If q->login != LOGIN_COMPLETED, then that device could be - * offline temporarily. So we let the command to time-out. - */ - LEAVE("iph5526_queuecommand"); - return 0; -} - -int iph5526_abort(Scsi_Cmnd *Cmnd) -{ -struct Scsi_Host *host = Cmnd->device->host; -struct iph5526_hostdata *hostdata = (struct iph5526_hostdata *)host->hostdata; -struct fc_info *fi = hostdata->fi; -struct fc_node_info *q; -u_int r_ctl = FC4_DEVICE_DATA | UNSOLICITED_COMMAND; -u_int type = TYPE_FCP | SEQUENCE_INITIATIVE; -u_short ox_id = OX_ID_FIRST_SEQUENCE; -int int_required = 1, i, abort_status = FALSE; -u_long flags; - - ENTER("iph5526_abort"); - - spin_lock_irqsave(&fi->fc_lock, flags); - - q = resolve_target(fi, Cmnd->device->id); - if (q == NULL) { - u_int bad_id = fi->g.my_ddaa | 0xFE; - /* This should not happen as we should always be able to - * resolve a target id. But, jus in case... - * We transmit to an non-existant AL_PA so that the done - * function can be called while receiving the interrupt - * for a bad AL_PA. - */ - DPRINTK1("Unresolved Target ID!"); - tx_exchange(fi, (char *)(&(hostdata->cmnd)), sizeof(fcp_cmd), r_ctl, type, bad_id, fi->g.my_mtu, int_required, ox_id, FC_SCSI_BAD_TARGET); - DPRINTK1("Target ID %x not present", Cmnd->target); - spin_unlock_irqrestore(&fi->fc_lock, flags); - return FAILED; - } - - /* If q != NULL, then we have a SCSI Target. If - * q->login != LOGIN_COMPLETED, then that device could - * be offline temporarily. So we let the command to time-out. - */ - - /* Get the OX_ID for the Command to be aborted. - */ - for (i = 0; i <= MAX_SCSI_XID; i++) { - if (hostdata->cmnd_handler[i] == Cmnd) { - hostdata->cmnd_handler[i] = NULL; - ox_id = i; - break; - } - } - if (i > MAX_SCSI_XID) { - T_MSG("Command could not be resolved to OX_ID"); - spin_unlock_irqrestore(&fi->fc_lock, flags); - return FAILED; - } - - switch(Cmnd->cmnd[0]) { - case WRITE_6: - case WRITE_10: - case WRITE_12: - break; - default: - ox_id |= SCSI_READ_BIT; - } - abort_status = abort_exchange(fi, ox_id); - - if ((q->login == LOGIN_COMPLETED) && (abort_status == TRUE)) { - /* Then, transmit an ABTS to the target. The rest - * is done when the BA_ACC is received for the ABTS. - */ - tx_abts(fi, q->d_id, ox_id); - } - else { - u_int STE_bit; - u_short x_id; - /* Invalidate resources for that Exchange. - */ - x_id = ox_id & MAX_SCSI_XID; - STE_bit = ntohl(*fi->q.ptr_sest[x_id]); - if (STE_bit & SEST_V) { - *(fi->q.ptr_sest[x_id]) &= htonl(SEST_INV); - invalidate_SEST_entry(fi, ox_id); - } - } - - LEAVE("iph5526_abort"); - spin_unlock_irqrestore(&fi->fc_lock, flags); - return SUCCESS; -} - -static int abort_exchange(struct fc_info *fi, u_short ox_id) -{ -u_short x_id; -volatile u_int flush_SEST, STE_bit; - x_id = ox_id & MAX_SCSI_XID; - DPRINTK1("Aborting Exchange %x", ox_id); - - STE_bit = ntohl(*fi->q.ptr_sest[x_id]); - /* Is the Exchange still active?. - */ - if (STE_bit & SEST_V) { - if (ox_id & SCSI_READ_BIT) { - /* If the Exchange to be aborted is Inbound, - * Flush the SEST Entry from Tachyon's Cache. - */ - *(fi->q.ptr_sest[x_id]) &= htonl(SEST_INV); - flush_tachyon_cache(fi, ox_id); - flush_SEST = readl(fi->t_r.ptr_tach_flush_oxid_reg); - while ((flush_SEST & 0x80000000) != 0) - flush_SEST = readl(fi->t_r.ptr_tach_flush_oxid_reg); - STE_bit = ntohl(*fi->q.ptr_sest[x_id]); - while ((STE_bit & 0x80000000) != 0) - STE_bit = ntohl(*fi->q.ptr_sest[x_id]); - flush_SEST = readl(fi->t_r.ptr_tach_flush_oxid_reg); - invalidate_SEST_entry(fi, ox_id); - } - else { - int i; - u_int *ptr_edb; - /* For In-Order Reassembly, the following is done: - * First, write zero as the buffer length in the EDB. - */ - ptr_edb = bus_to_virt(ntohl(*(fi->q.ptr_sest[x_id] + 7))); - for (i = 0; i < EDB_LEN; i++) - if (fi->q.ptr_edb[i] == ptr_edb) - break; - if (i < EDB_LEN) - *ptr_edb = *ptr_edb & 0x0000FFFF; - else - T_MSG("EDB not found while clearing in abort_exchange()"); - } - DPRINTK1("Exchange %x invalidated", ox_id); - return TRUE; - } - else { - DPRINTK1("SEST Entry for exchange %x not valid", ox_id); - return FALSE; - } -} - -static void flush_tachyon_cache(struct fc_info *fi, u_short ox_id) -{ -volatile u_int tachyon_status; - if (fi->g.loop_up == TRUE) { - writel(HOST_CONTROL, fi->t_r.ptr_fm_control_reg); - /* Make sure that the Inbound FIFO is empty. - */ - do { - tachyon_status = readl(fi->t_r.ptr_tach_status_reg); - udelay(200); - }while ((tachyon_status & RECEIVE_FIFO_EMPTY) == 0); - /* Ok. Go ahead and flushhhhhhhhh! - */ - writel(0x80000000 | ox_id, fi->t_r.ptr_tach_flush_oxid_reg); - writel(EXIT_HOST_CONTROL, fi->t_r.ptr_fm_control_reg); - return; - } - if (fi->g.ptp_up == TRUE) { - take_tachyon_offline(fi); - /* Make sure that the Inbound FIFO is empty. - */ - do { - tachyon_status = readl(fi->t_r.ptr_tach_status_reg); - udelay(200); - }while ((tachyon_status & RECEIVE_FIFO_EMPTY) == 0); - writel(0x80000000 | ox_id, fi->t_r.ptr_tach_flush_oxid_reg); - /* Write the Initialize command to the FM Control reg. - */ - fi->g.n_port_try = TRUE; - DPRINTK1("In abort_exchange, TACHYON initializing as N_Port...\n"); - writel(INITIALIZE, fi->t_r.ptr_fm_control_reg); - } -} - -static struct fc_node_info *resolve_target(struct fc_info *fi, u_char target) -{ -struct fc_node_info *temp = fi->node_info_list; - while(temp != NULL) - if (temp->target_id == target) { - if ((temp->scsi == TARGET) && (temp->login == LOGIN_COMPLETED)) - return temp; - else { - if (temp->login != LOGIN_COMPLETED) { - /* The Target is not currently logged in. - * It could be a Target on the Local Loop or - * on a Remote Loop connected through a switch. - * In either case, we will know whenever the Target - * comes On-Line again. We let the command to - * time-out so that it gets retried. - */ - T_MSG("Target %d not logged in.", temp->target_id); - tx_logi(fi, ELS_PLOGI, temp->d_id); - return temp; - } - else { - if (temp->scsi != TARGET) { - /* For some reason, we did not get a response to - * PRLI. Letz try it again... - */ - DPRINTK1("Node not PRLIied. Txing PRLI..."); - tx_prli(fi, ELS_PRLI, temp->d_id, OX_ID_FIRST_SEQUENCE); - } - } - return temp; - } - } - else - temp = temp->next; - return NULL; -} - -static int add_to_sest(struct fc_info *fi, Scsi_Cmnd *Cmnd, struct fc_node_info *ni) -{ -/* we have at least 1 buffer, the terminator */ -int no_of_sdb_buffers = 1, i; -int no_of_edb_buffers = 0; -u_int *req_buffer = (u_int *)Cmnd->request_buffer; -u_int *ptr_sdb = NULL; -struct scatterlist *sl1, *sl2 = NULL; -int no_of_sg = 0; - - switch(fi->g.type_of_frame) { - case FC_SCSI_READ: - fi->g.inb_sest_entry.flags_and_byte_offset = htonl(INB_SEST_VED); - fi->g.inb_sest_entry.byte_count = 0; - fi->g.inb_sest_entry.no_of_recvd_frames = 0; - fi->g.inb_sest_entry.no_of_expected_frames = 0; - fi->g.inb_sest_entry.last_fctl = 0; - - if (Cmnd->use_sg) { - no_of_sg = Cmnd->use_sg; - sl1 = sl2 = (struct scatterlist *)Cmnd->request_buffer; - for (i = 0; i < no_of_sg; i++) { - no_of_sdb_buffers += sl1->length / SEST_BUFFER_SIZE; - if (sl1->length % SEST_BUFFER_SIZE) - no_of_sdb_buffers++; - sl1++; - } - } - else { - no_of_sdb_buffers += Cmnd->request_bufflen / SEST_BUFFER_SIZE; - if (Cmnd->request_bufflen % SEST_BUFFER_SIZE) - no_of_sdb_buffers++; - } /* if !use_sg */ - - /* We are working with the premise that at the max we would - * get a scatter-gather buffer containing 63 buffers - * of size 1024 bytes each. Is it a _bad_ assumption? - */ - if (no_of_sdb_buffers > 512) { - T_MSG("Number of SDB buffers needed = %d", no_of_sdb_buffers); - T_MSG("Disable Scatter-Gather!!!"); - return 1; - } - - - /* Store it in the sdb_table so that we can retrieve that - * free up the memory when the Read Command completes. - */ - if (get_free_SDB(fi)) - return 1; - ptr_sdb = fi->q.ptr_sdb_slot[fi->q.sdb_indx]; - fi->q.sdb_slot_status[fi->q.sdb_indx] = SDB_BUSY; - fi->g.inb_sest_entry.sdb_address = htonl(virt_to_bus(ptr_sdb)); - - if (Cmnd->use_sg) { - int count = 0, j; - for(i = 0; i < no_of_sg; i++) { - char *addr_ptr = sl2->address; - count = sl2->length / SEST_BUFFER_SIZE; - if (sl2->length % SEST_BUFFER_SIZE) - count++; - for (j = 0; j < count; j++) { - *(ptr_sdb) = htonl(virt_to_bus(addr_ptr)); - addr_ptr += SEST_BUFFER_SIZE; - ptr_sdb++; - } - count = 0; - sl2++; - } - } - else { - for (i = 0; i < no_of_sdb_buffers - 1; i++) { - *(ptr_sdb) = htonl(virt_to_bus(req_buffer)); - req_buffer += SEST_BUFFER_SIZE/4; - ptr_sdb++; - } - } - *(ptr_sdb) = htonl(0x1); /* Terminator */ - - /* The scratch pad is used to hold the index into the SDB. - */ - fi->g.inb_sest_entry.scratch_pad = fi->q.sdb_indx; - fi->g.inb_sest_entry.expected_ro = 0; - fi->g.inb_sest_entry.buffer_index = 0; - fi->g.inb_sest_entry.buffer_offset = 0; - memcpy(fi->q.ptr_sest[fi->g.scsi_oxid], &fi->g.inb_sest_entry, sizeof(INB_SEST_ENTRY)); - break; - case FC_SCSI_WRITE: - fi->g.outb_sest_entry.flags_and_did = htonl(OUTB_SEST_VED | ni->d_id); - fi->g.outb_sest_entry.max_frame_len = htons(ni->mtu << 4); - fi->g.outb_sest_entry.cntl = htons(ODB_CLASS_3 | ODB_EE_CREDIT | ODB_NO_INT | ODB_NO_COMP); - fi->g.outb_sest_entry.total_seq_length = INV_SEQ_LEN; - fi->g.outb_sest_entry.link = htons(OUTB_SEST_LINK); - fi->g.outb_sest_entry.transaction_id = htonl(fi->g.scsi_oxid); - fi->g.outb_sest_entry.seq_id = fi->g.seq_id; - fi->g.outb_sest_entry.reserved = 0x0; - fi->g.outb_sest_entry.header_length = htons(TACHYON_HEADER_LEN); - - { - u_char df_ctl = 0; - u_short rx_id = RX_ID_FIRST_SEQUENCE; - u_int r_ctl = FC4_DEVICE_DATA | SOLICITED_DATA; - u_int type = TYPE_FCP | SEQUENCE_INITIATIVE; - /* Multi Frame Sequence ? If yes, set RO bit. - */ - if (Cmnd->request_bufflen > ni->mtu) - type |= RELATIVE_OFF_PRESENT; - build_tachyon_header(fi, fi->g.my_id, r_ctl, ni->d_id, type, fi->g.seq_id, df_ctl, fi->g.scsi_oxid, rx_id, NULL); - if (get_free_header(fi) || get_free_EDB(fi)) - return 1; - memcpy(fi->q.ptr_tachyon_header[fi->q.tachyon_header_indx], &(fi->g.tach_header), TACHYON_HEADER_LEN); - fi->g.outb_sest_entry.header_address = htonl(virt_to_bus(fi->q.ptr_tachyon_header[fi->q.tachyon_header_indx])); - update_tachyon_header_indx(fi); - } - - if (Cmnd->use_sg) { - no_of_sg = Cmnd->use_sg; - sl1 = sl2 = (struct scatterlist *)Cmnd->request_buffer; - for (i = 0; i < no_of_sg; i++) { - no_of_edb_buffers += sl1->length / SEST_BUFFER_SIZE; - if (sl1->length % SEST_BUFFER_SIZE) - no_of_edb_buffers++; - sl1++; - } - } - else { - no_of_edb_buffers += Cmnd->request_bufflen / SEST_BUFFER_SIZE; - if (Cmnd->request_bufflen % SEST_BUFFER_SIZE) - no_of_edb_buffers++; - } /* if !use_sg */ - - - /* We need "no_of_edb_buffers" _contiguous_ EDBs - * that are FREE. Check for that first. - */ - for (i = 0; i < no_of_edb_buffers; i++) { - int j; - if ((fi->q.edb_buffer_indx + no_of_edb_buffers) >= EDB_LEN) - fi->q.edb_buffer_indx = 0; - if (fi->q.free_edb_list[fi->q.edb_buffer_indx + i] != EDB_FREE) { - for (j = 0; j < i; j++) - update_EDB_indx(fi); - if (get_free_EDB(fi)) - return 1; - i = 0; - } - } - - /* We got enuff FREE EDBs. - */ - if (Cmnd->use_sg) { - fi->g.outb_sest_entry.edb_address = htonl(virt_to_bus(fi->q.ptr_edb[fi->q.edb_buffer_indx])); - sl1 = (struct scatterlist *)Cmnd->request_buffer; - for(i = 0; i < no_of_sg; i++) { - int count = 0, j; - count = sl1->length / SEST_BUFFER_SIZE; - for (j = 0; j < count; j++) { - build_EDB(fi, (char *)sl1->address, 0, SEST_BUFFER_SIZE); - memcpy(fi->q.ptr_edb[fi->q.edb_buffer_indx], &(fi->g.edb), sizeof(EDB)); - /* Mark this EDB as being in use */ - fi->q.free_edb_list[fi->q.edb_buffer_indx] = EDB_BUSY; - /* We have already made sure that we have enuff - * free EDBs that are contiguous. So this is - * safe. - */ - update_EDB_indx(fi); - sl1->address += SEST_BUFFER_SIZE; - } - /* Just in case itz not a multiple of - * SEST_BUFFER_SIZE bytes. - */ - if (sl1->length % SEST_BUFFER_SIZE) { - build_EDB(fi, (char *)sl1->address, 0, sl1->length % SEST_BUFFER_SIZE); - memcpy(fi->q.ptr_edb[fi->q.edb_buffer_indx], &(fi->g.edb), sizeof(EDB)); - fi->q.free_edb_list[fi->q.edb_buffer_indx] = EDB_BUSY; - update_EDB_indx(fi); - } - sl1++; - } - /* The last EDB is special. It needs the "end bit" to - * be set. - */ - *(fi->q.ptr_edb[fi->q.edb_buffer_indx - 1] + 1) = *(fi->q.ptr_edb[fi->q.edb_buffer_indx - 1] + 1) | ntohs(EDB_END); - } - else { - int count = 0, j; - fi->g.outb_sest_entry.edb_address = htonl(virt_to_bus(fi->q.ptr_edb[fi->q.edb_buffer_indx])); - count = Cmnd->request_bufflen / SEST_BUFFER_SIZE; - for (j = 0; j < count; j++) { - build_EDB(fi, (char *)req_buffer, 0, SEST_BUFFER_SIZE); - memcpy(fi->q.ptr_edb[fi->q.edb_buffer_indx], &(fi->g.edb), sizeof(EDB)); - /* Mark this EDB as being in use */ - fi->q.free_edb_list[fi->q.edb_buffer_indx] = EDB_BUSY; - /* We have already made sure that we have enuff - * free EDBs that are contiguous. So this is - * safe. - */ - update_EDB_indx(fi); - req_buffer += SEST_BUFFER_SIZE; - } - /* Just in case itz not a multiple of - * SEST_BUFFER_SIZE bytes. - */ - if (Cmnd->request_bufflen % SEST_BUFFER_SIZE) { - build_EDB(fi, (char *)req_buffer, EDB_END, Cmnd->request_bufflen % SEST_BUFFER_SIZE); - memcpy(fi->q.ptr_edb[fi->q.edb_buffer_indx], &(fi->g.edb), sizeof(EDB)); - fi->q.free_edb_list[fi->q.edb_buffer_indx] = EDB_BUSY; - update_EDB_indx(fi); - } - else { - /* Mark the last EDB as the "end edb". - */ - *(fi->q.ptr_edb[fi->q.edb_buffer_indx - 1] + 1) = *(fi->q.ptr_edb[fi->q.edb_buffer_indx - 1] + 1) | htons(EDB_END); - } - } - - /* Finally we have something to send!. - */ - memcpy(fi->q.ptr_sest[fi->g.scsi_oxid], &fi->g.outb_sest_entry, sizeof(OUTB_SEST_ENTRY)); - break; - } - return 0; -} - -static void update_FCP_CMND_indx(struct fc_info *fi) -{ - fi->q.fcp_cmnd_indx++; - if (fi->q.fcp_cmnd_indx == NO_OF_FCP_CMNDS) - fi->q.fcp_cmnd_indx = 0; -} - -static int get_scsi_oxid(struct fc_info *fi) -{ -u_short initial_oxid = fi->g.scsi_oxid; - /* Check if the OX_ID is in use. - * We could have an outstanding SCSI command. - */ - while (fi->q.free_scsi_oxid[fi->g.scsi_oxid] != OXID_AVAILABLE) { - update_scsi_oxid(fi); - if (fi->g.scsi_oxid == initial_oxid) { - T_MSG("No free OX_IDs avaliable") - reset_tachyon(fi, SOFTWARE_RESET); - return 1; - } - } - return 0; -} - -static void update_scsi_oxid(struct fc_info *fi) -{ - fi->g.scsi_oxid++; - if (fi->g.scsi_oxid == (MAX_SCSI_XID + 1)) - fi->g.scsi_oxid = 0; -} - -static int get_free_SDB(struct fc_info *fi) -{ -unsigned int initial_indx = fi->q.sdb_indx; - /* Check if the SDB is in use. - * We could have an outstanding SCSI Read command. - * We should find a free slot as we can queue a - * maximum of 32 SCSI commands only. - */ - while (fi->q.sdb_slot_status[fi->q.sdb_indx] != SDB_FREE) { - update_SDB_indx(fi); - if (fi->q.sdb_indx == initial_indx) { - T_MSG("No free SDB buffers avaliable") - reset_tachyon(fi, SOFTWARE_RESET); - return 1; - } - } - return 0; -} - -static void update_SDB_indx(struct fc_info *fi) -{ - fi->q.sdb_indx++; - if (fi->q.sdb_indx == NO_OF_SDB_ENTRIES) - fi->q.sdb_indx = 0; -} - -int iph5526_release(struct Scsi_Host *host) -{ -struct iph5526_hostdata *hostdata = (struct iph5526_hostdata*)host->hostdata; -struct fc_info *fi = hostdata->fi; - free_irq(host->irq, host); - iounmap(fi->g.mem_base); - return 0; -} - -const char *iph5526_info(struct Scsi_Host *host) -{ -static char buf[80]; - sprintf(buf, "Interphase 5526 Fibre Channel PCI SCSI Adapter using IRQ %d\n", host->irq); - return buf; -} - -#define NAMELEN 8 /* # of chars for storing dev->name */ - -static struct net_device *dev_fc[MAX_FC_CARDS]; - -static int io; -static int irq; -static int bad; /* 0xbad = bad sig or no reset ack */ -static int scsi_registered; - - -static int __init iph5526_init(void) -{ - int i = 0; - - driver_template.module = THIS_MODULE; - scsi_register_host(&driver_template); - if (driver_template.present) - scsi_registered = TRUE; - else { - printk("iph5526: SCSI registeration failed!!!\n"); - scsi_registered = FALSE; - scsi_unregister_host(&driver_template); - } - - while(fc[i] != NULL) { - struct net_device *dev = alloc_fcdev(0); - int err; - - if (!dev) { - printk("iph5526.c: init_fcdev failed for card #%d\n", i+1); - break; - } - dev->priv = fc[i]; - iph5526_probe_pci(dev); - err = register_netdev(dev); - if (err < 0) { - free_netdev(dev); - printk("iph5526.c: init_fcdev failed for card #%d\n", i+1); - break; - } - dev_fc[i] = dev; - i++; - } - if (i == 0) - return -ENODEV; - - return 0; -} - -static void __exit iph5526_exit(void) -{ - int i = 0; - while(fc[i] != NULL) { - struct net_device *dev = fc[i]->dev; - void *priv = dev->priv; - fc[i]->g.dont_init = TRUE; - take_tachyon_offline(fc[i]); - unregister_netdev(dev); - clean_up_memory(fc[i]); - if (dev->priv) - kfree(priv); - free_netdev(dev); - dev = NULL; - i++; - } - if (scsi_registered == TRUE) - scsi_unregister_host(&driver_template); -} - -module_init(iph5526_init); -module_exit(iph5526_exit); - -void clean_up_memory(struct fc_info *fi) -{ -int i,j; - ENTER("clean_up_memory"); - if (fi->q.ptr_mfsbq_base) - free_pages((u_long)bus_to_virt(ntohl(*(fi->q.ptr_mfsbq_base))), 5); - DPRINTK("after kfree2"); - for (i = 0; i < SFSBQ_LENGTH; i++) - for (j = 0; j < NO_OF_ENTRIES; j++) - if (fi->q.ptr_sfs_buffers[i*NO_OF_ENTRIES + j]) - kfree(fi->q.ptr_sfs_buffers[i*NO_OF_ENTRIES + j]); - DPRINTK("after kfree1"); - if (fi->q.ptr_ocq_base) - free_page((u_long)fi->q.ptr_ocq_base); - if (fi->q.ptr_imq_base) - free_page((u_long)fi->q.ptr_imq_base); - if (fi->q.ptr_mfsbq_base) - free_page((u_long)fi->q.ptr_mfsbq_base); - if (fi->q.ptr_sfsbq_base) - free_page((u_long)fi->q.ptr_sfsbq_base); - if (fi->q.ptr_edb_base) - free_pages((u_long)fi->q.ptr_edb_base, 5); - if (fi->q.ptr_sest_base) - free_pages((u_long)fi->q.ptr_sest_base, 5); - if (fi->q.ptr_tachyon_header_base) - free_page((u_long)fi->q.ptr_tachyon_header_base); - if (fi->q.ptr_sdb_base) - free_pages((u_long)fi->q.ptr_sdb_base, 5); - if (fi->q.ptr_fcp_cmnd_base) - free_page((u_long)fi->q.ptr_fcp_cmnd_base); - DPRINTK("after free_pages"); - if (fi->q.ptr_host_ocq_cons_indx) - kfree(fi->q.ptr_host_ocq_cons_indx); - if (fi->q.ptr_host_hpcq_cons_indx) - kfree(fi->q.ptr_host_hpcq_cons_indx); - if (fi->q.ptr_host_imq_prod_indx) - kfree(fi->q.ptr_host_imq_prod_indx); - DPRINTK("after kfree3"); - while (fi->node_info_list) { - struct fc_node_info *temp_list = fi->node_info_list; - fi->node_info_list = fi->node_info_list->next; - kfree(temp_list); - } - while (fi->ox_id_list) { - struct ox_id_els_map *temp = fi->ox_id_list; - fi->ox_id_list = fi->ox_id_list->next; - kfree(temp); - } - LEAVE("clean_up_memory"); -} - -static int initialize_register_pointers(struct fc_info *fi) -{ -ENTER("initialize_register_pointers"); -if(fi->g.tachyon_base == 0) - return -ENOMEM; - -fi->i_r.ptr_ichip_hw_control_reg = ICHIP_HW_CONTROL_REG_OFF + fi->g.tachyon_base; -fi->i_r.ptr_ichip_hw_status_reg = ICHIP_HW_STATUS_REG_OFF + fi->g.tachyon_base; -fi->i_r.ptr_ichip_hw_addr_mask_reg = ICHIP_HW_ADDR_MASK_REG_OFF + fi->g.tachyon_base; -fi->t_r.ptr_ocq_base_reg = OCQ_BASE_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_ocq_len_reg = OCQ_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_ocq_prod_indx_reg = OCQ_PRODUCER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_ocq_cons_indx_reg = OCQ_CONSUMER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_imq_base_reg = IMQ_BASE_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_imq_len_reg = IMQ_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_imq_cons_indx_reg = IMQ_CONSUMER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_imq_prod_indx_reg = IMQ_PRODUCER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_mfsbq_base_reg = MFSBQ_BASE_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_mfsbq_len_reg = MFSBQ_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_mfsbq_prod_reg = MFSBQ_PRODUCER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_mfsbq_cons_reg = MFSBQ_CONSUMER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_mfsbuff_len_reg = MFS_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_sfsbq_base_reg = SFSBQ_BASE_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_sfsbq_len_reg = SFSBQ_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_sfsbq_prod_reg = SFSBQ_PRODUCER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_sfsbq_cons_reg = SFSBQ_CONSUMER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_sfsbuff_len_reg = SFS_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_sest_base_reg = SEST_BASE_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_sest_len_reg = SEST_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_scsibuff_len_reg = SCSI_LENGTH_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_tach_config_reg = TACHYON_CONFIG_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_tach_control_reg = TACHYON_CONTROL_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_tach_status_reg = TACHYON_STATUS_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_tach_flush_oxid_reg = TACHYON_FLUSH_SEST_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_fm_config_reg = FMGR_CONFIG_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_fm_control_reg = FMGR_CONTROL_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_fm_status_reg = FMGR_STATUS_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_fm_tov_reg = FMGR_TIMER_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_fm_wwn_hi_reg = FMGR_WWN_HI_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_fm_wwn_low_reg = FMGR_WWN_LO_REGISTER_OFFSET + fi->g.tachyon_base; -fi->t_r.ptr_fm_rx_al_pa_reg = FMGR_RCVD_ALPA_REGISTER_OFFSET + fi->g.tachyon_base; - -LEAVE("initialize_register_pointers"); -return 1; -} - - - -/* - * Local variables: - * compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c iph5526.c" - * version-control: t - * kept-new-versions: 5 - * End: - */ ===== drivers/net/fc/iph5526_ip.h 1.1 vs edited ===== --- 1.1/drivers/net/fc/iph5526_ip.h 2002-02-05 18:40:03 +01:00 +++ edited/drivers/net/fc/iph5526_ip.h 2004-09-06 11:54:04 +02:00 @@ -1,25 +0,0 @@ -#ifndef IPH5526_IP_H -#define IPH5526_IP_H - -#define LLC_SNAP_LEN 0x8 - -/* Offsets into the ARP frame */ -#define ARP_OPCODE_0 (0x6 + LLC_SNAP_LEN) -#define ARP_OPCODE_1 (0x7 + LLC_SNAP_LEN) - -int iph5526_probe(struct net_device *dev); -static int fcdev_init(struct net_device *dev); -static int iph5526_open(struct net_device *dev); -static int iph5526_close(struct net_device *dev); -static int iph5526_send_packet(struct sk_buff *skb, struct net_device *dev); -static struct net_device_stats * iph5526_get_stats(struct net_device *dev); -static int iph5526_change_mtu(struct net_device *dev, int mtu); - - -static void rx_net_packet(struct fc_info *fi, u_char *buff_addr, int payload_size); -static void rx_net_mfs_packet(struct fc_info *fi, struct sk_buff *skb); -unsigned short fc_type_trans(struct sk_buff *skb, struct net_device *dev); -static int tx_ip_packet(struct sk_buff *skb, unsigned long len, struct fc_info *fi); -static int tx_arp_packet(char *data, unsigned long len, struct fc_info *fi); -#endif - ===== drivers/net/fc/iph5526_novram.c 1.1 vs edited ===== --- 1.1/drivers/net/fc/iph5526_novram.c 2002-02-05 18:40:03 +01:00 +++ edited/drivers/net/fc/iph5526_novram.c 2004-09-06 11:54:09 +02:00 @@ -1,278 +0,0 @@ -/********************************************************************** - * Reading the NVRAM on the Interphase 5526 PCI Fibre Channel Card. - * All contents in this file : courtesy Interphase Corporation. - * Special thanks to Kevin Quick, kquick@iphase.com. - **********************************************************************/ - -#define FF_MAGIC 0x4646 -#define DB_MAGIC 0x4442 -#define DL_MAGIC 0x444d - - -#define CMD_LEN 9 - -/*********** - * - * Switches and defines for header files. - * - * The following defines are used to turn on and off - * various options in the header files. Primarily useful - * for debugging. - * - ***********/ - -static const unsigned short novram_default[4] = { - FF_MAGIC, - DB_MAGIC, - DL_MAGIC, - 0 }; - - -/* - * a list of the commands that can be sent to the NOVRAM - */ - -#define NR_EXTEND 0x100 -#define NR_WRITE 0x140 -#define NR_READ 0x180 -#define NR_ERASE 0x1c0 - -#define EWDS 0x00 -#define WRAL 0x10 -#define ERAL 0x20 -#define EWEN 0x30 - -/* - * Defines for the pins on the NOVRAM - */ - -#define BIT(x) (1 << (x)) - -#define NVDI_B 31 -#define NVDI BIT(NVDI_B) -#define NVDO BIT(9) -#define NVCE BIT(30) -#define NVSK BIT(29) -#define NV_MANUAL BIT(28) - -/*********** - * - * Include files. - * - ***********/ - -#define KeStallExecutionProcessor(x) {volatile int d, p;\ - for (d=0; dn_r.ptr_novram_hw_control_reg); \ - t &= (val); \ - writel(t, fi->n_r.ptr_novram_hw_control_reg); \ - } - -/*********************** - * - * This define ors the value and the current config register and puts - * the result in the config register - * - ***********************/ - -#define CFG_OR(val) { volatile int t; \ - t = readl(fi->n_r.ptr_novram_hw_control_reg); \ - t |= (val); \ - writel(t, fi->n_r.ptr_novram_hw_control_reg); \ - } - -/*********************** - * - * Send a command to the NOVRAM, the command is in cmd. - * - * clear CE and SK. Then assert CE. - * Clock each of the command bits out in the correct order with SK - * exit with CE still asserted - * - ***********************/ - -#define NVRAM_CMD(cmd) { int i; \ - int c = cmd; \ - CFG_AND(~(NVCE|NVSK)); \ - CFG_OR(NVCE); \ - for (i=0; in_r.ptr_novram_hw_status_reg) & NVDO) ? 1 : 0; \ - } - -/*********** - * - * Function Prototypes - * - ***********/ - -static int iph5526_nr_get(struct fc_info *fi, int addr); -static void iph5526_nr_do_init(struct fc_info *fi); -static void iph5526_nr_checksum(struct fc_info *fi); - - -/******************************************************************* - * - * Local routine: iph5526_nr_do_init - * Purpose: initialize novram server - * Description: - * - * iph5526_nr_do_init reads the novram into the temporary holding place. - * A checksum is done on the area and the Magic Cookies are checked. - * If any of them are bad, the NOVRAM is initialized with the - * default values and a warning message is displayed. - * - *******************************************************************/ - -static void iph5526_nr_do_init(struct fc_info *fi) -{ - int i; - unsigned short chksum = 0; - int bad = 0; - - for (i=0; in_r.data[i] = iph5526_nr_get(fi, i); - chksum += fi->n_r.data[i]; - } - - if (chksum) - bad = 1; - - if (fi->n_r.data[IPH5526_NOVRAM_SIZE - 4] != FF_MAGIC) - bad = 1; - if (fi->n_r.data[IPH5526_NOVRAM_SIZE - 3] != DB_MAGIC) - bad = 1; - if (fi->n_r.data[IPH5526_NOVRAM_SIZE - 2] != DL_MAGIC) - bad = 1; - - if (bad) { - for (i=0; in_r.data[i] = 0xffff; - } else { - fi->n_r.data[i] = novram_default[i - (IPH5526_NOVRAM_SIZE - 4)]; - } - } - iph5526_nr_checksum(fi); - } -} - - -/******************************************************************* - * - * Local routine: iph5526_nr_get - * Purpose: read a single word of NOVRAM - * Description: - * - * read the 16 bits that make up a word addr of the novram. - * The 16 bits of data that are read are returned as the return value - * - *******************************************************************/ - -static int iph5526_nr_get(struct fc_info *fi, int addr) -{ - int i; - int t; - int val = 0; - - CFG_OR(NV_MANUAL); - - /* - * read the first bit that was clocked with the falling edge of the - * the last command data clock - */ - - NVRAM_CMD(NR_READ + addr); - - /* - * Now read the rest of the bits, the next bit read is D1, then D2, - * and so on - */ - - val = 0; - for (i=0; i<16; i++) { - NVRAM_CLKIN(t); - val <<= 1; - val |= t; - } - NVRAM_CLR_CE; - - CFG_OR(NVDI); - CFG_AND(~NV_MANUAL); - - return(val); -} - - - - -/******************************************************************* - * - * Local routine: iph5526_nr_checksum - * Purpose: calculate novram checksum on fi->n_r.data - * Description: - * - * calculate a checksum for the novram on the image that is - * currently in fi->n_r.data - * - *******************************************************************/ - -static void iph5526_nr_checksum(struct fc_info *fi) -{ - int i; - unsigned short chksum = 0; - - for (i=0; i<(IPH5526_NOVRAM_SIZE - 1); i++) - chksum += fi->n_r.data[i]; - - fi->n_r.data[i] = -chksum; -} ===== drivers/net/fc/iph5526_scsi.h 1.4 vs edited ===== --- 1.4/drivers/net/fc/iph5526_scsi.h 2004-01-10 16:32:23 +01:00 +++ edited/drivers/net/fc/iph5526_scsi.h 2004-09-06 11:54:12 +02:00 @@ -1,31 +0,0 @@ -#ifndef IPH5526_SCSI_H -#define IPH5526_SCSI_H - -#define IPH5526_CAN_QUEUE 32 -#define IPH5526_SCSI_FC { \ - .name = "Interphase 5526 Fibre Channel SCSI Adapter", \ - .detect = iph5526_detect, \ - .release = iph5526_release, \ - .info = iph5526_info, \ - .queuecommand = iph5526_queuecommand, \ - .bios_param = iph5526_biosparam, \ - .can_queue = IPH5526_CAN_QUEUE, \ - .this_id = -1, \ - .sg_tablesize = 255, \ - .cmd_per_lun = 8, \ - .use_clustering = DISABLE_CLUSTERING, \ - .eh_abort_handler = iph5526_abort, \ - .eh_device_reset_handler = NULL, \ - .eh_bus_reset_handler = NULL, \ - .eh_host_reset_handler = NULL, \ -} - -int iph5526_detect(Scsi_Host_Template *tmpt); -int iph5526_queuecommand(Scsi_Cmnd *Cmnd, void (*done) (Scsi_Cmnd *)); -int iph5526_release(struct Scsi_Host *host); -int iph5526_abort(Scsi_Cmnd *Cmnd); -const char *iph5526_info(struct Scsi_Host *host); -int iph5526_biosparam(struct Scsi_Disk * disk, struct block_device *n, int ip[]); - -#endif - ===== drivers/net/fc/tach.h 1.2 vs edited ===== --- 1.2/drivers/net/fc/tach.h 2002-02-05 08:49:26 +01:00 +++ edited/drivers/net/fc/tach.h 2004-09-06 11:54:16 +02:00 @@ -1,475 +0,0 @@ -/********************************************************************** - * Defines for the Tachyon Fibre Channel Controller and the Interphase - * (i)chip TPI. - *********************************************************************/ - -#ifndef _TACH_H -#define _TACH_H - -#define MY_PAGE_SIZE 4096 -#define REPLICATE 0xFF -#define MAX_NODES 127 -#define BROADCAST 0xFFFFFF -#define BROADCAST_ADDR 0xFFFFFFFFFFFF -#define LOGIN_COMPLETED 2 -#define LOGIN_ATTEMPTED 1 -#define LOGIN_NOT_ATTEMPTED 0 -#define TRUE 1 -#define FALSE 0 - -#define TACHYON_LIMIT 0x01EF -#define TACHYON_OFFSET 0x200 - -/* Offsets to the (i) chip */ -#define ICHIP_HW_CONTROL_REG_OFF (0x080 - TACHYON_OFFSET) -#define ICHIP_HW_STATUS_REG_OFF (0x084 - TACHYON_OFFSET) -#define ICHIP_HW_ADDR_MASK_REG_OFF (0x090 - TACHYON_OFFSET) - -/* (i)chip Hardware Control Register defines */ -#define ICHIP_HCR_RESET 0x01 -#define ICHIP_HCR_DERESET 0x0 -#define ICHIP_HCR_ENABLE_INTA 0x0000003E -#define ICHIP_HCR_ENABLE_INTB 0x003E0000 -#define ICHIP_HCR_IWDATA_FIFO 0x800000 - -/* (i)chip Hardware Status Register defines */ -#define ICHIP_HSR_INT_LATCH 0x02 - -/* (i)chip Hardware Address Mask Register defines */ -#define ICHIP_HAMR_BYTE_SWAP_ADDR_TR 0x08 -#define ICHIP_HAMR_BYTE_SWAP_NO_ADDR_TR 0x04 - -/* NOVRAM defines */ -#define IPH5526_NOVRAM_SIZE 64 - - -/* Offsets for the registers that correspond to the - * Qs on the Tachyon (As defined in the Tachyon Manual). - */ - -/* Outbound Command Queue (OCQ). - */ -#define OCQ_BASE_REGISTER_OFFSET 0x000 -#define OCQ_LENGTH_REGISTER_OFFSET 0x004 -#define OCQ_PRODUCER_REGISTER_OFFSET 0x008 -#define OCQ_CONSUMER_REGISTER_OFFSET 0x00C - -/* Inbound Message Queue (IMQ). - */ -#define IMQ_BASE_REGISTER_OFFSET 0x080 -#define IMQ_LENGTH_REGISTER_OFFSET 0x084 -#define IMQ_CONSUMER_REGISTER_OFFSET 0x088 -#define IMQ_PRODUCER_REGISTER_OFFSET 0x08C - -/* Multiframe Sequence Buffer Queue (MFSBQ) - */ -#define MFSBQ_BASE_REGISTER_OFFSET 0x0C0 -#define MFSBQ_LENGTH_REGISTER_OFFSET 0x0C4 -#define MFSBQ_PRODUCER_REGISTER_OFFSET 0x0C8 -#define MFSBQ_CONSUMER_REGISTER_OFFSET 0x0CC -#define MFS_LENGTH_REGISTER_OFFSET 0x0D0 - -/* Single Frame Sequence Buffer Queue (SFSBQ) - */ -#define SFSBQ_BASE_REGISTER_OFFSET 0x100 -#define SFSBQ_LENGTH_REGISTER_OFFSET 0x104 -#define SFSBQ_PRODUCER_REGISTER_OFFSET 0x108 -#define SFSBQ_CONSUMER_REGISTER_OFFSET 0x10C -#define SFS_LENGTH_REGISTER_OFFSET 0x110 - -/* SCSI Exchange State Table (SEST) - */ -#define SEST_BASE_REGISTER_OFFSET 0x140 -#define SEST_LENGTH_REGISTER_OFFSET 0x144 -#define SCSI_LENGTH_REGISTER_OFFSET 0x148 - -/* Length of the various Qs - */ -#define NO_OF_ENTRIES 8 -#define OCQ_LENGTH (MY_PAGE_SIZE/32) -#define IMQ_LENGTH (MY_PAGE_SIZE/32) -#define MFSBQ_LENGTH 8 -#define SFSBQ_LENGTH 8 -#define SEST_LENGTH MY_PAGE_SIZE - -/* Size of the various buffers. - */ -#define TACH_FRAME_SIZE 2048 -#define MFS_BUFFER_SIZE TACH_FRAME_SIZE -#define SFS_BUFFER_SIZE (TACH_FRAME_SIZE + TACHYON_HEADER_LEN) -#define SEST_BUFFER_SIZE 512 -#define TACH_HEADER_SIZE 64 -#define NO_OF_TACH_HEADERS ((MY_PAGE_SIZE)/TACH_HEADER_SIZE) - -#define NO_OF_FCP_CMNDS (MY_PAGE_SIZE/32) -#define SDB_SIZE 2048 -#define NO_OF_SDB_ENTRIES ((32*MY_PAGE_SIZE)/SDB_SIZE) - - -/* Offsets to the other Tachyon registers. - * (As defined in the Tachyon manual) - */ -#define TACHYON_CONFIG_REGISTER_OFFSET 0x184 -#define TACHYON_CONTROL_REGISTER_OFFSET 0x188 -#define TACHYON_STATUS_REGISTER_OFFSET 0x18C -#define TACHYON_FLUSH_SEST_REGISTER_OFFSET 0x190 - -/* Defines for the Tachyon Configuration register. - */ -#define SCSI_ENABLE 0x40000000 -#define WRITE_STREAM_SIZE 0x800 /* size = 16 */ -#define READ_STREAM_SIZE 0x300 /* size = 64 */ -#define PARITY_EVEN 0x2 -#define OOO_REASSEMBLY_DISABLE 0x40 - -/* Defines for the Tachyon Control register. - */ -#define SOFTWARE_RESET 0x80000000 -#define OCQ_RESET 0x4 -#define ERROR_RELEASE 0x2 - -/* Defines for the Tachyon Status register. - */ -#define RECEIVE_FIFO_EMPTY 0x10 -#define OSM_FROZEN 0x1 -#define OCQ_RESET_STATUS 0x20 -#define SCSI_FREEZE_STATUS 0x40 - - -/* Offsets to the Frame Manager registers. - */ -#define FMGR_CONFIG_REGISTER_OFFSET 0x1C0 -#define FMGR_CONTROL_REGISTER_OFFSET 0x1C4 -#define FMGR_STATUS_REGISTER_OFFSET 0x1C8 -#define FMGR_TIMER_REGISTER_OFFSET 0x1CC -#define FMGR_WWN_HI_REGISTER_OFFSET 0x1E0 -#define FMGR_WWN_LO_REGISTER_OFFSET 0x1E4 -#define FMGR_RCVD_ALPA_REGISTER_OFFSET 0x1E8 - -/* Defines for the Frame Manager Configuration register. - */ -#define BB_CREDIT 0x10000 -#define NPORT 0x8000 -#define LOOP_INIT_FABRIC_ADDRESS 0x400 -#define LOOP_INIT_PREVIOUS_ADDRESS 0x200 -#define LOOP_INIT_SOFT_ADDRESS 0x80 - -/* Defines for the Frame Manager Control register. - */ -#define HOST_CONTROL 0x02 -#define EXIT_HOST_CONTROL 0x03 -#define OFFLINE 0x05 -#define INITIALIZE 0x06 -#define CLEAR_LF 0x07 - -/* Defines for the Frame Manager Status register. - */ -#define LOOP_UP 0x80000000 -#define TRANSMIT_PARITY_ERROR 0x40000000 -#define NON_PARTICIPATING 0x20000000 -#define OUT_OF_SYNC 0x02000000 -#define LOSS_OF_SIGNAL 0x01000000 -#define NOS_OLS_RECEIVED 0x00080000 -#define LOOP_STATE_TIMEOUT 0x00040000 -#define LIPF_RECEIVED 0x00020000 -#define BAD_ALPA 0x00010000 -#define LINK_FAILURE 0x00001000 -#define ELASTIC_STORE_ERROR 0x00000400 -#define LINK_UP 0x00000200 -#define LINK_DOWN 0x00000100 -#define ARBITRATING 0x00000010 -#define ARB_WON 0x00000020 -#define OPEN 0x00000030 -#define OPENED 0x00000040 -#define TX_CLS 0x00000050 -#define RX_CLS 0x00000060 -#define TRANSFER 0x00000070 -#define INITIALIZING 0x00000080 -#define LOOP_FAIL 0x000000D0 -#define OLD_PORT 0x000000F0 -#define PORT_STATE_ACTIVE 0x0000000F -#define PORT_STATE_OFFLINE 0x00000000 -#define PORT_STATE_LF1 0x00000009 -#define PORT_STATE_LF2 0x0000000A - -/* Completion Message Types - * (defined in P.177 of the Tachyon manual) - */ -#define OUTBOUND_COMPLETION 0x000 -#define OUTBOUND_COMPLETION_I 0x100 -#define OUT_HI_PRI_COMPLETION 0x001 -#define OUT_HI_PRI_COMPLETION_I 0x101 -#define INBOUND_MFS_COMPLETION 0x102 -#define INBOUND_OOO_COMPLETION 0x003 -#define INBOUND_SFS_COMPLETION 0x104 -#define INBOUND_C1_TIMEOUT 0x105 -#define INBOUND_UNKNOWN_FRAME_I 0x106 -#define INBOUND_BUSIED_FRAME 0x006 -#define SFS_BUF_WARN 0x107 -#define MFS_BUF_WARN 0x108 -#define IMQ_BUF_WARN 0x109 -#define FRAME_MGR_INTERRUPT 0x10A -#define READ_STATUS 0x10B -#define INBOUND_SCSI_DATA_COMPLETION 0x10C -#define INBOUND_SCSI_COMMAND 0x10D -#define BAD_SCSI_FRAME 0x10E -#define INB_SCSI_STATUS_COMPLETION 0x10F - -/* One of the things that we care about when we receive an - * Outbound Completion Message (OCM). - */ -#define OCM_TIMEOUT_OR_BAD_ALPA 0x0800 - -/* Defines for the Tachyon Header structure. - */ -#define SOFI3 0x70 -#define SOFN3 0xB0 -#define EOFN 0x5 - -/* R_CTL */ -#define FC4_DEVICE_DATA 0 -#define EXTENDED_LINK_DATA 0x20000000 -#define FC4_LINK_DATA 0x30000000 -#define BASIC_LINK_DATA 0x80000000 -#define LINK_CONTROL 0xC0000000 -#define SOLICITED_DATA 0x1000000 -#define UNSOLICITED_CONTROL 0x2000000 -#define SOLICITED_CONTROL 0x3000000 -#define UNSOLICITED_DATA 0x4000000 -#define DATA_DESCRIPTOR 0x5000000 -#define UNSOLICITED_COMMAND 0x6000000 - -#define RCTL_ELS_UCTL 0x22000000 -#define RCTL_ELS_SCTL 0x23000000 -#define RCTL_BASIC_ABTS 0x81000000 -#define RCTL_BASIC_ACC 0x84000000 -#define RCTL_BASIC_RJT 0x85000000 - -/* TYPE */ -#define TYPE_BLS 0x00000000 -#define TYPE_ELS 0x01000000 -#define TYPE_FC_SERVICES 0x20000000 -#define TYPE_LLC_SNAP 0x05000000 -#define TYPE_FCP 0x08000000 - -/* F_CTL */ -#define EXCHANGE_RESPONDER 0x800000 -#define SEQUENCE_RESPONDER 0x400000 -#define FIRST_SEQUENCE 0x200000 -#define LAST_SEQUENCE 0x100000 -#define SEQUENCE_INITIATIVE 0x10000 -#define RELATIVE_OFF_PRESENT 0x8 -#define END_SEQUENCE 0x80000 - -#define TACHYON_HEADER_LEN 32 -#define NW_HEADER_LEN 16 -/* Defines for the Outbound Descriptor Block (ODB). - */ -#define ODB_CLASS_3 0xC000 -#define ODB_NO_COMP 0x400 -#define ODB_NO_INT 0x200 -#define ODB_EE_CREDIT 0xF - -/* Defines for the Extended Descriptor Block (EDB). - */ -#define EDB_LEN ((32*MY_PAGE_SIZE)/8) -#define EDB_END 0x8000 -#define EDB_FREE 0 -#define EDB_BUSY 1 - -/* Command Codes */ -#define ELS_LS_RJT 0x01000000 -#define ELS_ACC 0x02000000 -#define ELS_PLOGI 0x03000000 -#define ELS_FLOGI 0x04000000 -#define ELS_LOGO 0x05000000 -#define ELS_TPRLO 0x24000000 -#define ELS_ADISC 0x52000000 -#define ELS_PDISC 0x50000000 -#define ELS_PRLI 0x20000000 -#define ELS_PRLO 0x21000000 -#define ELS_SCR 0x62000000 -#define ELS_RSCN 0x61000000 -#define ELS_FARP_REQ 0x54000000 -#define ELS_ABTX 0x06000000 -#define ELS_ADVC 0x0D000000 -#define ELS_ECHO 0x10000000 -#define ELS_ESTC 0x0C000000 -#define ELS_ESTS 0x0B000000 -#define ELS_RCS 0x07000000 -#define ELS_RES 0x08000000 -#define ELS_RLS 0x0F000000 -#define ELS_RRQ 0x12000000 -#define ELS_RSS 0x09000000 -#define ELS_RTV 0x0E000000 -#define ELS_RSI 0x0A000000 -#define ELS_TEST 0x11000000 -#define ELS_RNC 0x53000000 -#define ELS_RVCS 0x41000000 -#define ELS_TPLS 0x23000000 -#define ELS_GAID 0x30000000 -#define ELS_FACT 0x31000000 -#define ELS_FAN 0x60000000 -#define ELS_FDACT 0x32000000 -#define ELS_NACT 0x33000000 -#define ELS_NDACT 0x34000000 -#define ELS_QoSR 0x40000000 -#define ELS_FDISC 0x51000000 - -#define ELS_NS_PLOGI 0x03FFFFFC - -/* LS_RJT reason codes. - */ -#define INV_LS_CMND_CODE 0x0001 -#define LOGICAL_ERR 0x0003 -#define LOGICAL_BUSY 0x0005 -#define PROTOCOL_ERR 0x0007 -#define UNABLE_TO_PERFORM 0x0009 -#define CMND_NOT_SUPP 0x000B - -/* LS_RJT explanation codes. - */ -#define NO_EXPLN 0x0000 -#define RECV_FIELD_SIZE 0x0700 -#define CONC_SEQ 0x0900 -#define REQ_NOT_SUPPORTED 0x2C00 -#define INV_PAYLOAD_LEN 0x2D00 - -/* Payload Length defines. - */ -#define PLOGI_LEN 116 - -#define CONCURRENT_SEQUENCES 0x01 -#define RO_INFO_CATEGORY 0xFE -#define E_D_TOV 0x07D0 /* 2 Secs */ -#define AL_TIME 0x0010 /* ~15 msec */ -#define TOV_VALUES (AL_TIME << 16) | E_D_TOV -#define RT_TOV 0x64 /* 100 msec */ -#define PTP_TOV_VALUES (RT_TOV << 16) | E_D_TOV -#define SERVICE_VALID 0x8000 -#define SEQUENCE_DELIVERY 0x0800 -#define CLASS3_CONCURRENT_SEQUENCE 0x01 -#define CLASS3_OPEN_SEQUENCE 0x01 - -/* These are retrieved from the NOVRAM. - */ -#define WORLD_WIDE_NAME_LOW fi->g.my_port_name_low -#define WORLD_WIDE_NAME_HIGH fi->g.my_port_name_high -#define N_PORT_NAME_HIGH fi->g.my_port_name_high -#define N_PORT_NAME_LOW fi->g.my_port_name_low -#define NODE_NAME_HIGH fi->g.my_node_name_high -#define NODE_NAME_LOW fi->g.my_node_name_low - -#define PORT_NAME_LEN 8 -#define NODE_NAME_LEN 8 - - -#define PH_VERSION 0x0909 - -#define LOOP_BB_CREDIT 0x00 -#define PT2PT_BB_CREDIT 0x01 -#define FLOGI_C_F 0x0800 /* Alternate BB_Credit Mgmnt */ -#define PLOGI_C_F 0x8800 /* Continuously Increasing + Alternate BB_Credit Management */ - -/* Fabric defines */ -#define DIRECTORY_SERVER 0xFFFFFC -#define FABRIC_CONTROLLER 0xFFFFFD -#define F_PORT 0xFFFFFE - -#define FLOGI_DID 0xFFFE -#define NS_PLOGI_DID 0xFFFC - -/* Fibre Channel Services defines */ -#define FCS_RFC_4 0x02170000 -#define FCS_GP_ID4 0x01A10000 -#define FCS_ACC 0x8002 -#define FCS_REJECT 0x8001 - -/* CT Header defines */ -#define FC_CT_REV 0x01000000 -#define DIRECTORY_SERVER_APP 0xFC -#define NAME_SERVICE 0x02 - -/* Port Type defines */ -#define PORT_TYPE_IP 0x05000000 -#define PORT_TYPE_NX_PORTS 0x7F000000 - -/* SCR defines */ -#define FABRIC_DETECTED_REG 0x00000001 -#define N_PORT_DETECTED_REG 0x00000002 -#define FULL_REGISTRATION 0x00000003 -#define CLEAR_REGISTRATION 0x000000FF - -/* Command structure has only one byte to address targets - */ -#define MAX_SCSI_TARGETS 0xFF - -#define FC_SCSI_READ 0x80 -#define FC_SCSI_WRITE 0x81 -#define FC_ELS 0x01 -#define FC_BLS 0x00 -#define FC_IP 0x05 -#define FC_BROADCAST 0xFF - -/* SEST defines. - */ -#define SEST_V 0x80000000 /* V = 1 */ -#define INB_SEST_VED 0xA0000000 /* V = 1, D = 1 */ -#define SEST_INV 0x7FFFFFFF -#define OUTB_SEST_VED 0x80000000 /* V = 1 */ -#define INV_SEQ_LEN 0xFFFFFFFF -#define OUTB_SEST_LINK 0xFFFF - -/* PRLI defines. - */ -#define PAGE_LEN 0x100000 /* 3rd byte - 0x10 */ -#define PRLI_LEN 0x0014 /* 20 bytes */ -#define FCP_TYPE_CODE 0x0800 /* FCP-SCSI */ -#define IMAGE_PAIR 0x2000 /* establish image pair */ -#define INITIATOR_FUNC 0x00000020 -#define TARGET_FUNC 0x00000010 -#define READ_XFER_RDY_DISABLED 0x00000002 - -#define NODE_PROCESS_LOGGED_IN 0x3 -#define NODE_NOT_PRESENT 0x2 -#define NODE_LOGGED_IN 0x1 -#define NODE_LOGGED_OUT 0x0 - -/* Defines to determine what should be returned when a SCSI frame - * times out. - */ -#define FC_SCSI_BAD_TARGET 0xFFFE0000 - -/* RSCN Address formats */ -#define PORT_ADDRESS_FORMAT 0x00 -#define AREA_ADDRESS_FORMAT 0x01 -#define DOMAIN_ADDRESS_FORMAT 0x02 - -/* Defines used to determine whether a frame transmission should - * be indicated by an interrupt or not. - */ -#define NO_COMP_AND_INT 0 -#define INT_AND_COMP_REQ 1 -#define NO_INT_COMP_REQ 2 - -/* Other junk... - */ -#define SDB_FREE 0 -#define SDB_BUSY 1 -#define MAX_PENDING_FRAMES 15 -#define RX_ID_FIRST_SEQUENCE 0xFFFF -#define OX_ID_FIRST_SEQUENCE 0xFFFF -#define NOT_SCSI_XID 0x8000 -#define MAX_SCSI_XID 0x0FFF /* X_IDs are from 0-4095 */ -#define SCSI_READ_BIT 0x4000 -#define MAX_SCSI_OXID 0x4FFF -#define OXID_AVAILABLE 0 -#define OXID_INUSE 1 -#define MAX_SEQ_ID 0xFF - -#define INITIATOR 2 -#define TARGET 1 -#define DELETE_ENTRY 1 -#define ADD_ENTRY 2 - -#endif /* _TACH_H */ ===== drivers/net/fc/tach_structs.h 1.2 vs edited ===== --- 1.2/drivers/net/fc/tach_structs.h 2003-02-25 11:44:51 +01:00 +++ edited/drivers/net/fc/tach_structs.h 2004-09-06 11:54:19 +02:00 @@ -1,428 +0,0 @@ -/********************************************************************** - * iph5526.c: Structures for the Interphase 5526 PCI Fibre Channel - * IP/SCSI driver. - * Copyright (C) 1999 Vineet M Abraham - **********************************************************************/ - -#ifndef _TACH_STRUCT_H -#define _TACH_STRUCT_H - -typedef struct { - u_short cmnd_code; - u_short payload_length; - u_short type_code; - u_short est_image_pair; - u_int originator_pa; - u_int responder_pa; - u_int service_params; -} PRLI; - -typedef struct { - u_int flags_and_byte_offset; - u_int byte_count; - u_short no_of_recvd_frames; - u_short no_of_expected_frames; - u_int last_fctl; - u_int sdb_address; - u_int scratch_pad; - u_int expected_ro; - u_short buffer_index; - u_short buffer_offset; - } INB_SEST_ENTRY; - -typedef struct { - u_int flags_and_did; - u_short max_frame_len; - u_short cntl; - u_int total_seq_length; - u_short link; - u_short rx_id; - u_int transaction_id; - u_int header_address; - u_char seq_id; - u_char reserved; - u_short header_length; - u_int edb_address; - } OUTB_SEST_ENTRY; - -typedef struct { - u_short d_naa; - u_short dest_high; - u_int dest_low; - u_short s_naa; - u_short source_high; - u_int source_low; - } NW_HEADER; - -typedef struct { - u_int resv; - u_char sof_and_eof; - u_char dest_alpa; - u_short lcr_and_time_stamp; - u_int r_ctl_and_d_id; - u_int vc_id_and_s_id; - u_int type_and_f_cntl; - u_char seq_id; - u_char df_cntl; - u_short seq_cnt; - u_short ox_id; - u_short rx_id; - u_int ro; - NW_HEADER nw_header; - } TACHYON_HEADER; - -typedef struct { - u_short service_options; - u_short initiator_ctl; - u_short recipient_ctl; - u_short recv_data_field_size; - u_short concurrent_sequences; - u_short n_port_end_to_end_credit; - u_short open_seq_per_exchange; - u_short resv; - }CLASS_OF_SERVICE; - -typedef struct { - u_int logo_cmnd; - u_char reserved; - u_char n_port_id_2; - u_char n_port_id_1; - u_char n_port_id_0; - u_int port_name_up; - u_int port_name_low; - } LOGO; - -typedef struct { - u_int ls_cmnd_code; - u_int hard_address; - u_int port_name_high; - u_int port_name_low; - u_int node_name_high; - u_int node_name_low; - u_int n_port_id; - } ADISC; - -typedef struct { - u_int cmnd_code; - u_int reason_code; - } LS_RJT; - -typedef struct { - u_int cmnd_code; - } ACC; - -typedef struct { - u_int seq_d_id; - u_int tot_len; - u_short cntl; - u_short rx_id; - u_short cs_enable; - u_short cs_seed; - u_int trans_id; - u_int hdr_addr; - u_short frame_len; - u_short hdr_len; - u_int edb_addr; - }ODB; - -typedef struct { - u_int cmnd_code; - u_int reg_function; /* in the last byte */ - } SCR; - -typedef struct { - u_int rev_in_id; - u_char fs_type; - u_char fs_subtype; - u_char options; - u_char resv1; - u_short cmnd_resp_code; - u_short max_res_size; - u_char resv2; - u_char reason_code; - u_char expln_code; - u_char vendor_unique; - } CT_HDR; - -typedef struct { - CT_HDR ct_hdr; - u_int s_id; - u_char bit_map[32]; /* 32 byte bit map */ - } RFC_4; - -typedef struct { - u_int ls_cmnd_code; - u_short fc_ph_version; - u_short buff_to_buff_credit; - u_short common_features; - u_short recv_data_field_size; - u_short n_port_total_conc_seq; - u_short rel_off_by_info_cat; - u_int ED_TOV; - u_int n_port_name_high; - u_int n_port_name_low; - u_int node_name_high; - u_int node_name_low; - CLASS_OF_SERVICE c_of_s[3]; - u_int resv[4]; - u_int vendor_version_level[4]; - }LOGIN; - -typedef struct { - CT_HDR ct_hdr; - u_int port_type; /* in the first byte */ - } GP_ID4; - -typedef struct { - u_int buf_addr; - u_short ehf; - u_short buf_len; - }EDB; - -/* (i)chip Registers */ -struct i_chip_regs { - u_int ptr_ichip_hw_control_reg; - u_int ptr_ichip_hw_status_reg; - u_int ptr_ichip_hw_addr_mask_reg; -}; - -struct iph5526_novram { - u_int ptr_novram_hw_control_reg; - u_int ptr_novram_hw_status_reg; - u_short data[IPH5526_NOVRAM_SIZE]; -}; - -/* Tachyon Registers */ -struct tachyon_regs { - u_int ptr_ocq_base_reg; - u_int ptr_ocq_len_reg; - u_int ptr_ocq_prod_indx_reg; - u_int ptr_ocq_cons_indx_reg; - - u_int ptr_imq_base_reg; - u_int ptr_imq_len_reg; - u_int ptr_imq_cons_indx_reg; - u_int ptr_imq_prod_indx_reg; - - u_int ptr_mfsbq_base_reg; - u_int ptr_mfsbq_len_reg; - u_int ptr_mfsbq_prod_reg; - u_int ptr_mfsbq_cons_reg; - u_int ptr_mfsbuff_len_reg; - - u_int ptr_sfsbq_base_reg; - u_int ptr_sfsbq_len_reg; - u_int ptr_sfsbq_prod_reg; - u_int ptr_sfsbq_cons_reg; - u_int ptr_sfsbuff_len_reg; - - u_int ptr_sest_base_reg; - u_int ptr_sest_len_reg; - u_int ptr_scsibuff_len_reg; - - u_int ptr_tach_config_reg; - u_int ptr_tach_control_reg; - u_int ptr_tach_status_reg; - u_int ptr_tach_flush_oxid_reg; - - u_int ptr_fm_config_reg; - u_int ptr_fm_control_reg; - u_int ptr_fm_status_reg; - u_int ptr_fm_tov_reg; - u_int ptr_fm_wwn_hi_reg; - u_int ptr_fm_wwn_low_reg; - u_int ptr_fm_rx_al_pa_reg; -}; - -struct globals { - u_long tachyon_base; - u_int *mem_base; - u_short ox_id; /* OX_ID used for IP and ELS frames */ - u_short scsi_oxid; /* OX_ID for SEST entry */ - u_char seq_id; - u_int my_id; - u_int my_ddaa; /* my domain and area in a fabric */ - volatile u_char loop_up; - volatile u_char ptp_up; /* we have a point-to-point link */ - volatile u_char link_up; - volatile u_char n_port_try; - volatile u_char nport_timer_set; - volatile u_char lport_timer_set; - /* Hmmm... We don't want to Initialize while closing */ - u_char dont_init; - u_int my_node_name_high; - u_int my_node_name_low; - u_int my_port_name_high; - u_int my_port_name_low; - u_char fabric_present; - u_char explore_fabric; - u_char name_server; - u_int my_mtu; - u_int *els_buffer[MAX_PENDING_FRAMES]; /* temp space for ELS frames */ - char *arp_buffer; /* temp space for ARP frames */ - u_int mfs_buffer_count; /* keep track of MFS buffers used*/ - u_char scsi_registered; - /* variables for port discovery */ - volatile u_char port_discovery; - volatile u_char perform_adisc; - u_short alpa_list_index; - u_short type_of_frame; /* Could be IP/SCSI Read/SCSI Write*/ - u_char no_of_targets; /* used to assign target_ids */ - u_long sem; /* to synchronize between IP and SCSI */ - u_char e_i; - - /* the frames */ - TACHYON_HEADER tach_header; - LOGIN login; - PRLI prli; - LOGO logo; - ADISC adisc; - LS_RJT ls_rjt; - ODB odb; - INB_SEST_ENTRY inb_sest_entry; - OUTB_SEST_ENTRY outb_sest_entry; - ACC acc; - SCR scr; - EDB edb; - RFC_4 rfc_4; - GP_ID4 gp_id4; -}; - -struct queue_variables { - /* Indices maintained in host memory. - */ - u_int *host_ocq_cons_indx, *host_hpcq_cons_indx, *host_imq_prod_indx; - u_int *ptr_host_ocq_cons_indx, *ptr_host_hpcq_cons_indx, *ptr_host_imq_prod_indx; - - /* Variables for Outbound Command Queue (OCQ). - */ - u_int *ptr_ocq_base; - u_int ocq_len, ocq_end; - u_int ocq_prod_indx; - u_int *ptr_odb[OCQ_LENGTH]; - - /* Variables for Inbound Message Queue (IMQ). - */ - u_int *ptr_imq_base; - u_int imq_len, imq_end; - u_int imq_cons_indx; - u_int imq_prod_indx; - u_int *ptr_imqe[IMQ_LENGTH]; - - u_int *ptr_mfsbq_base; - u_int mfsbq_len, mfsbq_end; - u_int mfsbq_prod_indx; - u_int mfsbq_cons_indx; - u_int mfsbuff_len, mfsbuff_end; - - u_int *ptr_sfsbq_base; - u_int sfsbq_len, sfsbq_end; - u_int sfsbq_prod_indx; - u_int sfsbq_cons_indx; - u_int sfsbuff_len, sfsbuff_end; - u_int *ptr_sfs_buffers[SFSBQ_LENGTH * NO_OF_ENTRIES]; - - /* Tables for SCSI Transactions */ - u_int *ptr_sest_base; - u_int *ptr_sest[SEST_LENGTH]; - u_char free_scsi_oxid[SEST_LENGTH]; - u_int *ptr_sdb_base; - u_int *ptr_sdb_slot[NO_OF_SDB_ENTRIES]; - u_char sdb_slot_status[NO_OF_SDB_ENTRIES]; - u_int sdb_indx; - u_int *ptr_fcp_cmnd_base; - u_int *ptr_fcp_cmnd[NO_OF_FCP_CMNDS]; - u_int fcp_cmnd_indx; - - /* Table for data to be transmitted. - */ - u_int *ptr_edb_base; - u_int *ptr_edb[EDB_LEN]; - u_int edb_buffer_indx; - volatile u_char free_edb_list[EDB_LEN]; - - /* Table of Tachyon Headers. - */ - u_int *ptr_tachyon_header[NO_OF_TACH_HEADERS]; - u_int *ptr_tachyon_header_base; - u_int tachyon_header_indx; -}; - -/* Used to match incoming ACCs to ELS requests sent out */ -struct ox_id_els_map { - u_short ox_id; - u_int els; - struct ox_id_els_map *next; -}; - - -/* Carries info about individual nodes... stores the info got at login - * time. Also maintains mapping between MAC->FC addresses - */ -struct fc_node_info { - /* Itz the WWN (8 bytes), the last 6 bytes is the MAC address */ - u_char hw_addr[PORT_NAME_LEN]; - u_char node_name[NODE_NAME_LEN]; - u_int d_id; /*real FC address, 3 bytes */ - int mtu; - /* login = 1 if login attempted - * login = 2 if login completed - */ - int login; - u_char scsi; /* = 1 if device is a SCSI Target */ - u_char target_id; - CLASS_OF_SERVICE c_of_s[3]; - struct fc_node_info *next; -}; - -struct fc_info { - char name[8]; - u_long base_addr; - int irq; - struct net_device_stats fc_stats; - struct fc_node_info *node_info_list; - int num_nodes; - struct ox_id_els_map *ox_id_list; - struct i_chip_regs i_r; - struct tachyon_regs t_r; - struct queue_variables q; - struct globals g; - struct iph5526_novram n_r; - u_short clone_id; - struct timer_list nport_timer; - struct timer_list lport_timer; - struct timer_list explore_timer; - struct timer_list display_cache_timer; - struct net_device *dev; - struct Scsi_Host *host; - spinlock_t fc_lock; -}; - -struct iph5526_hostdata { - struct fc_info *fi; - fcp_cmd cmnd; - Scsi_Cmnd *cmnd_handler[SEST_LENGTH]; - u_int tag_ages[MAX_SCSI_TARGETS]; -}; - -/* List of valid AL_PAs */ -u_char alpa_list[127] = { - 0x00, 0x01, 0x02, 0x04, 0x08, 0x0F, 0x10, 0x17, - 0x18, 0x1B, 0x1D, 0x1E, 0x1F, 0x23, 0x25, 0x26, - 0x27, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x31, - 0x32, 0x33, 0x34, 0x35, 0x36, 0x39, 0x3A, 0x3C, - 0x43, 0x45, 0x46, 0x47, 0x49, 0x4A, 0x4B, 0x4C, - 0x4D, 0x4E, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, - 0x59, 0x5A, 0x5C, 0x63, 0x65, 0x66, 0x67, 0x69, - 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x71, 0x72, 0x73, - 0x74, 0x75, 0x76, 0x79, 0x7A, 0x7C, 0x80, 0x81, - 0x82, 0x84, 0x88, 0x8F, 0x90, 0x97, 0x98, 0x9B, - 0x9D, 0x9E, 0x9F, 0xA3, 0xA5, 0xA6, 0xA7, 0xA9, - 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xB1, 0xB2, 0xB3, - 0xB4, 0xB5, 0xB6, 0xB9, 0xBA, 0xBC, 0xC3, 0xC5, - 0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, - 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD9, 0xDA, - 0xDC, 0xE0, 0xE1, 0xE2, 0xE4, 0xE8, 0xEF -}; - -#endif /* _TACH_STRUCT_H */ From jchapman@katalix.com Mon Sep 6 04:57:40 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 04:57:53 -0700 (PDT) Received: from s14.s14avahost.net (s14.s14avahost.net [66.98.146.55]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86Bvdlv019007 for ; Mon, 6 Sep 2004 04:57:40 -0700 Received: from cpanel by s14.s14avahost.net with local (Exim 4.42) id 1C4I65-0000bl-4V; Mon, 06 Sep 2004 06:55:45 -0500 Received: from 212.56.89.216 ([212.56.89.216]) by www.katalix.com (IMP) with HTTP for ; Mon, 6 Sep 2004 12:55:44 +0100 Message-ID: <1094471744.413c5040e7f06@www.katalix.com> Date: Mon, 6 Sep 2004 12:55:44 +0100 From: James Chapman To: netdev@oss.sgi.com Cc: Martijn van Oosterhout Subject: PPP-over-L2TP kernel support, patch for review MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.2 X-Originating-IP: 212.56.89.216 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - s14.s14avahost.net X-AntiAbuse: Original Domain - oss.sgi.com X-AntiAbuse: Originator/Caller UID/GID - [32001 960] / [47 12] X-AntiAbuse: Sender Address Domain - katalix.com X-Source: /usr/local/cpanel/3rdparty/bin/php X-Source-Args: /usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/base/horde/imp/compose.php X-Source-Dir: :/base/horde/imp X-archive-position: 8439 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jchapman@katalix.com Precedence: bulk X-list: netdev Content-Length: 717 Lines: 19 Attached is a PPP-over-L2TP driver for review. The patch is against vanilla 2.6.8.1. It was originally developed for 2.4 and forward- ported to 2.6 so please look for typical 2.4-to-2.6 porting bugs. The original version of this driver was written by Martijn van Oosterhout, distributed as kl2tp-0.2 last year. Note that this code handles only the datapath of L2TP; a userland daemon runs the L2TP control protocol, setting up tunnels and sessions with its peers. OpenL2TP is a recently released L2TP client/server written specifically for Linux and includes this driver in its distribution, http://openl2tp.sourceforge.net. I'm working towards having this driver integrated into the kernel tree. Comments? /jc From jchapman@katalix.com Mon Sep 6 05:01:06 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 05:01:11 -0700 (PDT) Received: from s14.s14avahost.net (s14.s14avahost.net [66.98.146.55]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86C15DS019359 for ; Mon, 6 Sep 2004 05:01:06 -0700 Received: from cpanel by s14.s14avahost.net with local (Exim 4.42) id 1C4I9V-0000vB-02; Mon, 06 Sep 2004 06:59:17 -0500 Received: from 212.56.89.216 ([212.56.89.216]) by www.katalix.com (IMP) with HTTP for ; Mon, 6 Sep 2004 12:59:16 +0100 Message-ID: <1094471956.413c5114de2d7@www.katalix.com> Date: Mon, 6 Sep 2004 12:59:16 +0100 From: James Chapman To: netdev@oss.sgi.com Cc: Martijn van Oosterhout Subject: PPP-over-L2TP kernel support, patch for review MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-MOQ10944719560baa5174fac6e4ed97ac1aeaf3061f31" User-Agent: Internet Messaging Program (IMP) 3.2.2 X-Originating-IP: 212.56.89.216 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - s14.s14avahost.net X-AntiAbuse: Original Domain - oss.sgi.com X-AntiAbuse: Originator/Caller UID/GID - [32001 960] / [47 12] X-AntiAbuse: Sender Address Domain - katalix.com X-Source: /usr/local/cpanel/3rdparty/bin/php X-Source-Args: /usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/base/horde/imp/compose.php X-Source-Dir: :/base/horde/imp X-archive-position: 8440 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: jchapman@katalix.com Precedence: bulk X-list: netdev Content-Length: 97057 Lines: 1279 This message is in MIME format. ---MOQ10944719560baa5174fac6e4ed97ac1aeaf3061f31 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Attached this time... sorry. Attached is a PPP-over-L2TP driver for review. The patch is against vanilla 2.6.8.1. It was originally developed for 2.4 and forward- ported to 2.6 so please look for typical 2.4-to-2.6 porting bugs. The original version of this driver was written by Martijn van Oosterhout, distributed as kl2tp-0.2 last year. Note that this code handles only the datapath of L2TP; a userland daemon runs the L2TP control protocol, setting up tunnels and sessions with its peers. OpenL2TP is a recently released L2TP client/server written specifically for Linux and includes this driver in its distribution, http://openl2tp.sourceforge.net. I'm working towards having this driver integrated into the kernel tree. Comments? /jc ---MOQ10944719560baa5174fac6e4ed97ac1aeaf3061f31 Content-Type: application/octet-stream; name="pppol2tp-linux-2.6.8.1.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pppol2tp-linux-2.6.8.1.patch" ZGlmZiAtTmF1ciBsaW51eC0yLjYuOC4xLm9yaWcvZHJpdmVycy9uZXQvS2NvbmZpZyBsaW51eC0y LjYuOC4xL2RyaXZlcnMvbmV0L0tjb25maWcKLS0tIGxpbnV4LTIuNi44LjEub3JpZy9kcml2ZXJz L25ldC9LY29uZmlnCTIwMDQtMDgtMTQgMTE6NTY6MDAuMDAwMDAwMDAwICswMTAwCisrKyBsaW51 eC0yLjYuOC4xL2RyaXZlcnMvbmV0L0tjb25maWcJMjAwNC0wOS0wNCAwMTowMjowMC4wMDAwMDAw MDAgKzAxMDAKQEAgLTI0ODEsNiArMjQ4MSwxOSBAQAogCSAgd2hpY2ggY2FuIGxlYWQgdG8gYmFk IHJlc3VsdHMgaWYgdGhlIEFUTSBwZWVyIGxvc2VzIHN0YXRlIGFuZAogCSAgY2hhbmdlcyBpdHMg ZW5jYXBzdWxhdGlvbiB1bmlsYXRlcmFsbHkuCiAKK2NvbmZpZyBQUFBPTDJUUAorCXRyaXN0YXRl ICJQUFAgb3ZlciBMMlRQIChFWFBFUklNRU5UQUwpIgorCWRlcGVuZHMgb24gRVhQRVJJTUVOVEFM ICYmIFBQUE9FCisJaGVscAorCSAgU3VwcG9ydCBmb3IgUFBQLW92ZXItTDJUUCBzb2NrZXQgZmFt aWx5LiBMMlRQIGlzIGEgcHJvdG9jb2wKKwkgIHVzZWQgYnkgSVNQcyBhbmQgZW50ZXJwcmlzZXMg dG8gdHVubmVsIFBQUCB0cmFmZmljIG92ZXIgVURQCisJICB0dW5uZWxzLiBMMlRQIGlzIHJlcGxh Y2luZyBQUFRQIGZvciBWUE4gdXNlcy4KKworCSAgVGhpcyBrZXJuZWwgY29tcG9uZW50IGhhbmRs ZXMgb25seSBMMlRQIGRhdGEgcGFja2V0czogYQorCSAgdXNlcmxhbmQgZGFlbW9uIGhhbmRsZXMg TD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jb25zdCBjaGFyICp3aGF0KQoreworCVBSSU5U SyhkZWJ1Z19tYXNrLCBQUFBPTDJUUF9NU0dfQ09OVFJPTCwgS0VSTl9XQVJOSU5HLCAKKwkgICAg ICAgImZlYXR1cmUgJXMgbm90IHlldCBpbXBsZW1lbnRlZFxuIiwgd2hhdCk7Cit9CisKK3N0YXRp YyByd2xvY2tfdCBwcHBvbDJ0cF9oYXNoX2xvY2sgPSBSV19MT0NLX1VOTE9DS0VEOworCisvKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioKKyAqIEhhc2ggdGFibGUgaW1wbGVtZW50YXRpb24uCisgKgorICog V2UgbmVlZCB0byBmaW5kIHNlc3Npb25zIGVmZmljaWVudGx5LCBpZGVudGlmaWVkIGJ5IGEgdHVu bmVsX2lkL3Nlc3Npb25faWQKKyAqIHBhaXIsIGhlbmNlIHdlIHVzZSBhIGhhc2ggdGFibGUuCisg KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyBpbmxpbmUgaW50IGNtcF9hZGRyKHN0cnVj dCBwcHBvbDJ0cF9hZGRyICphZGRyLCB1MTYgdHVubmVsLCB1MTYgc2Vzc2lvbikKK3sKKwlyZXR1 cm4gKChhZGRyLT5zX3R1bm5lbCA9PSB0dW5uZWwpICYmIChhZGRyLT5zX3Nlc3Npb24gPT0gc2Vz c2lvbikpOworfQorCitzdGF0aWMgaW50IGhhc2hfaXRlbSh1MTYgdHVubmVsLCB1MTYgc2Vzc2lv bikKK3sKKwlpbnQgaSwgdGVtcCwgaGFzaDsKKworCWhhc2ggPSAwOwkKKwl0ZW1wID0gdHVubmVs IF4gc2Vzc2lvbjsKKworCWZvciAoaSA9IDA7IGkgPD0gc2l6ZW9mKHUxNikvUFBQT0wyVFBfSEFT SF9CSVRTOyArK2kpIHsK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2tfYmgoJnBwcG9sMnRwX2hhc2hfbG9jayk7CisJcmV0ID0gX19kZWxldGVfaXRlbSh0dW5uZWws IHR1bm5lbF9pZCwgc2Vzc2lvbl9pZCk7CisJd3JpdGVfdW5sb2NrX2JoKCZwcHBvbDJ0cF9oYXNo X2xvY2spOworCisJRVhJVF9GVU5DVElPTjsKKwlyZXR1cm4gcmV0OworfQorCisvKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioKKyAqIFJlY2VpdmUgZGF0YSBoYW5kbGluZworICoqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqLworCisvKiBJbnRlcm5hbCByZWNlaXZlIGZyYW1lLiBEbyB0aGUgcmVhbCB3b3JrIG9mIHJl Y2VpdmluZyBhbiBMMlRQIGRhdGEgZnJhbWUKKyAqIGhlcmUuCisgKiBSZXR1cm5zIDAgaWYgdGhl IHBhY2tldCB3YXMgYSBkYXRhIHBhY2tldCBhbmQgd2FzIHN1Y2Nlc3NmdWxseSBwYXNzZWQgb24u CisgKiBSZXR1cm5zIDEgaWYgdGhlIHBhY2tldCB3YXMgbm90IGEgZ29vZCBkYXRhIHBhY2tldCBh bmQgY291bGQgbm90IGJlCisgKiBmb3J3YXJkZWQuICBBbGwgc3VjaCBwYWNrZXRzIGFyZSBwYXNz ZWQgdXAgdG8gdXNlcnNwYWNlIHRvIGRlYWwgd2l0aC4KKyAqLworc3RhdGljIGludCBwcHBvbDJ0 cF9yZWN2X2NvcmUoc3RydWN0IHNvY2sgKnNvY2ssIHN0cnVjdCBza19idWZmICpza2IpCit7CisJ c3RydWN0IHBwcG94X29wdCAqcG87CisJc3RydWN0IHBwcG9sMnRwX3Nlc3Npb24gKnNlc3Npb24g PSBOVUxMOworCWludCBlcnJvciA9IDA7CisJc3RydWN0IHBwcG9sMnRwX3R1bm5lbCAq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UxMOworCXN0cnVjdCBzb2Nr ICpzayA9IHNvY2stPnNrOworCisJRU5URVJfRlVOQ1RJT047CisKKwllcnIgPSAtRUlPOworCWlm IChzb2NrLT5zdGF0ZSAmIFBQUE9YX0JPVU5EKQorCQlnb3RvIGVycm9yOworCQkJCisJbXNnLT5t c2dfbmFtZWxlbiA9IDA7CisJCisJc2tiPXNrYl9yZWN2X2RhdGFncmFtKHNrLCBmbGFncyAmIH5N U0dfRE9OVFdBSVQsCisJCQkgICAgICBmbGFncyAmIE1TR19ET05UV0FJVCwgJmVycik7CisJaWYg KHNrYikgeworCQllcnIgPSBtZW1jcHlfdG9pb3ZlYyhtc2ctPm1zZ19pb3YsICh1bnNpZ25lZCBj aGFyICopIHNrYi0+ZGF0YSwKKwkJCQkgICAgIHNrYi0+bGVuKTsKKwkJaWYgKGVyciA8IDApCisJ CQlnb3RvIGRvX3NrYl9mcmVlOworCQllcnIgPSBza2ItPmxlbjsKKwl9Citkb19za2JfZnJlZToK KwlpZiAoc2tiKQorCQlrZnJlZV9za2Ioc2tiKTsKK2Vycm9yOgorCUVYSVRfRlVOQ1RJT047CisJ cmV0dXJuIGVycjsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogVHJhbnNtaXQgaGFuZGxpbmcK KyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKi8KKworLyogSW50ZXJuYWwgVURQIHNvY2tldCB0cmFuc21pc3Npb24K KyAqLworc3RhdGljIGludCBwcHBvbDJ0cF91ZHBfc29ja19zZW5kKHN0cnVjdCBraW9jYiAqaW9j YiwKKwkJCQkgIHN0cnVjdCBwcHBvbDJ0cF9zZXNzaW9uICpzZXNzaW9uLCAKKwkJCQkgIHN0cnVj dCBwcHBvbDJ0cF90dW5uZWwgKnR1bm5lbCwKKwkJCQkgIHN0cnVjd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CisKKwlrZnJlZV9za2Ioc2tiKTsKKworZW5kOgorCUVYSVRfRlVOQ1RJT047CisJcmV0 dXJuIGVycm9yOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIFNlc3Npb24gKGFuZCB0 dW5uZWwgY29udHJvbCkgc29ja2V0IGNyZWF0ZS9kZXN0cm95LgorICoqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqLworCisvKiBXaGVuIHRoZSB0dW5uZWwgVURQIHNvY2tldCBpcyBjbG9zZWQsIGFsbCB0aGUg YXR0YWNoZWQgc29ja2V0cyBuZWVkIHRvIGdvCisgKiB0b28uIFRoaXMgaGFuZGxlcyB0aGF0Lgor ICovCitzdGF0aWMgdm9pZCBwcHBvbDJ0cF90dW5uZWxfY2xvc2VhbGwoc3RydWN0IHBwcG9sMnRw X3R1bm5lbCAqdHVubmVsKQoreworCWludCBoYXNoOworCisJRU5URVJfRlVOQ1RJT047CisJCisJ aWYgKHR1bm5lbCA9PSBOVUxMKQorCQlCVUcoKTsKKworCVBSSU5USyh0dW5uZWwtPmRlYnVnLCBQ UFBPTDJUUF9NU0dfQ09OVFJPTCwgS0VSTl9JTkZPLCAKKwkgICAgICAgIiVzOiBjbG9zaW5nIGFs bCBzZXNzaW9ucy4uLlxuIiwgdHVubmVsLT5uYW1lKTsKKworCXJlYWRfbG9ja19iaCgmcHBwb2wy dHBfaGFzaF9sb2NrKTsKKwlmb3IgKGhhc2ggPSAwOyBoYXNoIDwgUFBQT0wyVFBfSEFTSF9TSVpF OyBoYXNoKyspIHsKKwkJc3RydWN0IHBwcG9sMnRwX3Nlc3Npb24gKnNlc3Npb24gPSB0dW5uZWwt Pmhhc2hbaGFzaF07CisJCXN0cnVjdCBwcHBvbDJ0cF9zZXNzaW9uICpuZXh0OworCisJCXdoa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worCW1lbWNweSh1YWRkciwgJnNwLCBs ZW4pOworCisJKnVzb2NrYWRkcl9sZW4gPSBsZW47CisKKwllcnJvciA9IDA7CitlbmQ6CisJRVhJ VF9GVU5DVElPTjsKKwlyZXR1cm4gZXJyb3I7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisg KiBpb2N0bCgpIGhhbmRsZXJzLgorICoKKyAqIFRoZSBQUFBvWCBzb2NrZXQgaXMgY3JlYXRlZCBm b3IgTDJUUCBzZXNzaW9uczogdHVubmVscyBoYXZlIHRoZWlyIG93biBVRFAKKyAqIHNvY2tldHMu IEhvd2V2ZXIsIGluIG9yZGVyIHRvIGNvbnRyb2wga2VybmVsIHR1bm5lbCBmZWF0dXJlcywgd2Ug YWxsb3cKKyAqIHVzZXJzcGFjZSB0byBjcmVhdGUgYSBzcGVjaWFsICJ0dW5uZWwiIFBQUG9YIHNv Y2tldCB3aGljaCBpcyB1c2VkIGZvcgorICogY29udHJvbCBvbmx5LiAgVHVubmVsIFBQUG9YIHNv Y2tldHMgaGF2ZSBzZXNzaW9uX2lkID09IDAgYW5kIHNpbXBseSBhbGxvdworICogdGhlIHVzZXIg YXBwbGljYXRpb24gdG8gaXNzdWUgTDJUUCBzZXRzb2Nrb3B0KCksIGdldHNvY2tvcHQoKSBhbmQg aW9jdGwoKQorICogY2FsbHMuCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyogU2Vzc2lvbiBp b2N0bCBoZWxwZXIuCisgKi8KK3N0YXRpYyBpbnQgcHBwb2wydHBfc2Vzc2lvbl9pb2N0bChzdHJ1 Y3QgcHBwb2wydHBfc2Vzc2lvbiAqc2Vzc2lvbiwgCisJCQkJICB1bnNpZ25lZCBpbnQgY21kLCB1 bnNpZ25lZCBsb25nIGFyZykKK3sK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5lbCwgb3B0bmFtZSwgJnZhbCk7CisJZWxzZQorCQllcnIgPSBwcHBvbDJ0cF9zZXNz aW9uX2dldHNvY2tvcHQoc2Vzc2lvbiwgb3B0bmFtZSwgJnZhbCk7CisJCisKKwlpZiAocHV0X3Vz ZXIobGVuLCAoaW50IF9fdXNlciAqKSBvcHRsZW4pKQorCQlyZXR1cm4gLUVGQVVMVDsKKworCWlm IChjb3B5X3RvX3VzZXIoKHZvaWQgX191c2VyICopIG9wdHZhbCwgJnZhbCwgbGVuKSkKKwkJcmV0 dXJuIC1FRkFVTFQ7CisKK2VuZDoKKwlyZXR1cm4gZXJyOworfQorCisvKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioKKyAqIC9wcm9jIGZpbGVzeXN0ZW0gZm9yIGRlYnVnCisgKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KiovCisKKyNpZmRlZiBDT05GSUdfUFJPQ19GUworCisjaW5jbHVkZSA8bGludXgvc2VxX2ZpbGUu aD4KKworI2lmIChMSU5VWF9WRVJTSU9OX0NPREUgIT0gS0VSTkVMX1ZFUlNJT04oMiw0LDI3KSkK KyNpZiAoTElOVVhfVkVSU0lPTl9DT0RFIDwgS0VSTkVMX1ZFUlNJT04oMiw1LDApKQorc3RhdGlj IGlubGluZSBzdHJ1Y3QgcHJvY19kaXJfZW50cnkgKlBERShjb25zdCBzdHJ1Y3QgaW5vZGUgKmlu b2RlKQoreworCXJldHVybiAoc3RydWN0IHByb2NfZGlyX2VudHJ5ICopaW5vZGUtPnUuZ2VuZXJp Y19pcDsKK30KKyNlbmRpZgorI2VuZGlmCitzdGF0aWMgc3RydWN0IHByb2NfZGlyX2VudHJ5ICpw cHBvbDJ0cF9wcm9jOworCitzdGF0aWMgaW50IHBwcG9sMnRwX3Byb2Nfb3BlbihzdHJ1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T5yZW9yZGVyX3RpbWVvdXQpOworCQkJc2VxX3ByaW50ZihtLCAiICAgJWh1LyVodSAl dS8ldS8ldSAldS8ldS8ldVxuIiwKKwkJCQkgICBzZXNzaW9uLT5uciwgc2Vzc2lvbi0+bnMsCisJ CQkJICAgc2Vzc2lvbi0+c3RhdHMudHhfcGFja2V0cywgCisJCQkJICAgc2Vzc2lvbi0+c3RhdHMu dHhfYnl0ZXMsIAorCQkJCSAgIHNlc3Npb24tPnN0YXRzLnR4X2Vycm9ycywKKwkJCQkgICBzZXNz aW9uLT5zdGF0cy5yeF9wYWNrZXRzLCAKKwkJCQkgICBzZXNzaW9uLT5zdGF0cy5yeF9ieXRlcywg CisJCQkJICAgc2Vzc2lvbi0+c3RhdHMucnhfZXJyb3JzKTsKKworCQkJaWYgKHNlc3Npb24tPm1h Z2ljICE9IEwyVFBfU0VTU0lPTl9NQUdJQykgeworCQkJCXNlcV9wdXRzKG0sICIqKiogQWJvcnRp bmcgKioqXG4iKTsKKwkJCQlicmVhazsKKwkJCX0KKworCQkJc2Vzc2lvbiA9IHNlc3Npb24tPm5l eHQ7CisJCX0KKworCQlpZiAoc2Vzc2lvbikKKwkJCWJyZWFrOworCX0KKwlzZXFfcHV0cyhtLCAi XG4iKTsKKworb3V0OgorCUVYSVRfRlVOQ1RJT047CisKKwlyZXR1cm4gMDsKK30KKworI2VuZGlm IC8qIENPTkZJR19QUk9DX0ZTICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogSW5pdCBh bmQgY2xlYW51cAorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdGF0aWMgc3RydWN0IHByb3Rv X29wcyBwcHBvbDJ0cF9vcHMgPSB7CisJLmZhbWlseQkJPSBBRl9QUFBPWCwKKwkub3duZXIJCT0g VEhJ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vY2th ZGRyX3BwcG94IHsgCiAgICAgICAgc2FfZmFtaWx5X3QgICAgIHNhX2ZhbWlseTsgICAgICAgICAg ICAvKiBhZGRyZXNzIGZhbWlseSwgQUZfUFBQT1ggKi8gCiAgICAgICAgdW5zaWduZWQgaW50ICAg IHNhX3Byb3RvY29sOyAgICAgICAgICAvKiBwcm90b2NvbCBpZGVudGlmaWVyICovIAogICAgICAg IHVuaW9ueyAKICAgICAgICAgICAgICAgIHN0cnVjdCBwcHBvZV9hZGRyICAgICAgIHBwcG9lOyAK KyAgICAgICAgICAgICAgIHN0cnVjdCBwcHBvbDJ0cF9hZGRyICAgIHBwcG9sMnRwOwogICAgICAg IH1zYV9hZGRyOyAKIH1fX2F0dHJpYnV0ZV9fICgocGFja2VkKSk7IAogCmRpZmYgLU5hdXIgbGlu dXgtMi42LjguMS5vcmlnL2luY2x1ZGUvbGludXgvc29ja2V0LmggbGludXgtMi42LjguMS9pbmNs dWRlL2xpbnV4L3NvY2tldC5oCi0tLSBsaW51eC0yLjYuOC4xLm9yaWcvaW5jbHVkZS9saW51eC9z b2NrZXQuaAkyMDA0LTA4LTE0IDExOjU1OjU5LjAwMDAwMDAwMCArMDEwMAorKysgbGludXgtMi42 LjguMS9pbmNsdWRlL2xpbnV4L3NvY2tldC5oCTIwMDQtMDktMDEgMTc6Mzc6NTUuMDAwMDAwMDAw ICswMTAwCkBAIC0yNjgsNiArMjY4LDcgQEAKICNkZWZpbmUgU09MX0lSREEgICAgICAgIDI2Ngog I2RlZmluZSBTT0xfTkVUQkVVSQkyNjcKICNkZWZpbmUgU09MX0xMQwkJMjY4CisjZGVmaW5lIFNP TF9QUFBPTDJUUAkyNjkKIAogLyogSVBYIG9wdGlvbnMgKi8KICNkZWZpbmUgSVBYX1RZUEUJMQo= ---MOQ10944719560baa5174fac6e4ed97ac1aeaf3061f31-- From shemminger@osdl.org Mon Sep 6 05:15:37 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 05:15:41 -0700 (PDT) Received: from fire-1.osdl.org (fire.osdl.org [65.172.181.4]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86CFala019966 for ; Mon, 6 Sep 2004 05:15:36 -0700 Received: from linux.site ([192.44.87.116]) (authenticated bits=0) by fire-1.osdl.org (8.12.8/8.12.8) with ESMTP id i86CFFSf013899 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Mon, 6 Sep 2004 05:15:18 -0700 Date: Mon, 6 Sep 2004 05:15:23 -0700 From: Stephen Hemminger To: David Miller Cc: netdev@oss.sgi.com Subject: [PATCH] bridge deadlock on device removal Message-Id: <20040906051523.16e6a431@linux.site> Organization: OSDL X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i686-suse-linux) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-MIMEDefang-Filter: osdl$Revision: 1.73 $ X-Scanned-By: MIMEDefang 2.36 X-archive-position: 8441 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: shemminger@osdl.org Precedence: bulk X-list: netdev Content-Length: 667 Lines: 29 Fixes: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=131569 Dead lock in bridge when removing device interface module. br_del_if assumes br->lock not held. This fixes case of: brctl addbr b0 brctl addif b0 eth0 rmmod eth0 Signed-off-by: Stephen Hemminger diff -Nru a/net/bridge/br_notify.c b/net/bridge/br_notify.c --- a/net/bridge/br_notify.c 2004-09-06 04:45:31 -07:00 +++ b/net/bridge/br_notify.c 2004-09-06 04:45:31 -07:00 @@ -76,10 +76,12 @@ break; case NETDEV_UNREGISTER: + spin_unlock_bh(&br->lock); br_del_if(br, dev); - break; + goto done; } spin_unlock_bh(&br->lock); + done: return NOTIFY_DONE; } From hch@lst.de Mon Sep 6 10:23:06 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 10:23:11 -0700 (PDT) Received: from mail.lst.de (verein.lst.de [213.95.11.210]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86HN5W1002973 for ; Mon, 6 Sep 2004 10:23:06 -0700 Received: from verein.lst.de (localhost [127.0.0.1]) by mail.lst.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i86HMt95024218 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Mon, 6 Sep 2004 19:22:55 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id i86HMtci024216; Mon, 6 Sep 2004 19:22:55 +0200 Date: Mon, 6 Sep 2004 19:22:55 +0200 From: Christoph Hellwig To: netdev@oss.sgi.com, linux-scsi@vger.kernel.org Subject: Re: [PATCH] remove iph5526 driver Message-ID: <20040906172255.GA24194@lst.de> References: <20040906101014.GA17597@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040906101014.GA17597@lst.de> User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-archive-position: 8442 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hch@lst.de Precedence: bulk X-list: netdev Content-Length: 681 Lines: 17 On Mon, Sep 06, 2004 at 12:10:14PM +0200, Christoph Hellwig wrote: > This driver is for totally obsolete early fibrechannel hardware and > doesn't compile anymore since early 2.5.x. In addition it'll require > a major rewrite to fit into the current framework for fc drivers. In addition this makefile fixup is needed to build with CONFIG_NET_FC: --- 1.86/drivers/net/Makefile 2004-08-22 22:57:31 +02:00 +++ edited/drivers/net/Makefile 2004-09-06 19:06:10 +02:00 @@ -184,7 +184,6 @@ obj-$(CONFIG_FEC_8XX) += fec_8xx/ obj-$(CONFIG_ARM) += arm/ -obj-$(CONFIG_NET_FC) += fc/ obj-$(CONFIG_DEV_APPLETALK) += appletalk/ obj-$(CONFIG_TR) += tokenring/ obj-$(CONFIG_WAN) += wan/ From sam@errno.com Mon Sep 6 11:14:36 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 11:14:44 -0700 (PDT) Received: from ebb.errno.com (ebb.errno.com [66.127.85.87]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86IEaZw004175 for ; Mon, 6 Sep 2004 11:14:36 -0700 Received: from [66.127.85.89] ([66.127.85.89]) (authenticated bits=0) by ebb.errno.com (8.12.9/8.12.6) with ESMTP id i86IDVWi084251 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO); Mon, 6 Sep 2004 11:13:32 -0700 (PDT) (envelope-from sam@errno.com) In-Reply-To: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <757AB580-0030-11D9-9224-000A95AD0668@errno.com> Content-Transfer-Encoding: 7bit Cc: jgarzik@pobox.com, netdev@oss.sgi.com, acx100-devel@lists.sourceforge.net, Jean Tourrilhes , Jouni Malinen , prism54-devel@prism54.org From: Sam Leffler Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Mon, 6 Sep 2004 11:13:31 -0700 To: Denis Vlasenko X-Mailer: Apple Mail (2.619) X-archive-position: 8443 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: sam@errno.com Precedence: bulk X-list: netdev Content-Length: 2380 Lines: 54 On Aug 31, 2004, at 11:11 AM, Denis Vlasenko wrote: > Hi all, > > It looks like acx100 approaches state when we can consider it's > inclusion > into mainline kernel. > > Some background information: acx100 and acx111 hardware is a bit like > Atheros and possibly prism54 "softmac": it handles mostly low-level > rx/tx stuff, leaving 802.11 stack implementation up to OS > (which is good. To have largish potentially buggy binary-only firmware > to cope with is a nightmare). > > I think what acx100 devel is working on can be best described as > "yet another 802.11 stack implementation". This is not ok. > > I think we definitely need generic 802.11 stack, with individual > drivers > providing only needed callbacks, just like it is done for wired eth > drivers. > > I think 'senior' network guys are in position to decide upon which > of currently available 802.11 stacks we should continue to work. > (Atheros has one, said to be derived from BSD, is there any others?) To correct this oft-repeated misinformation: "Atheros has one" is wrong. There is a freely available device-independent 802.11 protocol stack that is dual BSD/GPL licensed. The only relationship between this code and Atheros is that the madwifi project uses it to support Atheros hardware under Linux. Atheros holds no copyrights on any of the net80211 code. As to it being derived from BSD, that is correct but misleading. The 1st generation of this code was done for netbsd but the current code is very different and has been developed almost exclusively in Linux for over a year (though I'm now trying to find time to backport to FreeBSD). The net80211 code is actively used in netbsd to support 6+ drivers and a similar number in freebsd. There is a fairly complete implementation of the 802.11 protocols (fragmentation isn't there but will be soon) including 11g, WPA/11i, WME and WSM (coming soon). WPA/802.11i supplicant support using wpa_supplicant has been available for a while and a hostapd-based authenticator will hit CVS shortly. The management API for Linux is based on wireless extensions (WE is insufficient so like everyone else you'll find lots of private ioctls). I've suggested this code as a good starting point for a "generic 802.11 stack" but received only misinformed responses. Folks who are unaware of the work should take a look at it. Sam From vkondra@mail.ru Mon Sep 6 11:58:31 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 11:58:36 -0700 (PDT) Received: from mx2.mail.ru (mx2.mail.ru [194.67.23.122]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86IwUoI005337 for ; Mon, 6 Sep 2004 11:58:31 -0700 Received: from [212.179.200.204] (port=38255 helo=[192.168.10.2]) by mx2.mail.ru with esmtp id 1C4Oh1-000OE2-00; Mon, 06 Sep 2004 22:58:20 +0400 From: Vladimir Kondratiev To: netdev@oss.sgi.com Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Mon, 6 Sep 2004 21:57:35 +0300 User-Agent: KMail/1.7 Cc: Sam Leffler , Denis Vlasenko , jgarzik@pobox.com, acx100-devel@lists.sourceforge.net, Jean Tourrilhes , Jouni Malinen , prism54-devel@prism54.org References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <757AB580-0030-11D9-9224-000A95AD0668@errno.com> In-Reply-To: <757AB580-0030-11D9-9224-000A95AD0668@errno.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1520535.EX0V45s7vl"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200409062157.52042.vkondra@mail.ru> X-Spam: Probable Spam X-archive-position: 8444 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vkondra@mail.ru Precedence: bulk X-list: netdev Content-Length: 765 Lines: 32 --nextPart1520535.EX0V45s7vl Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sam, could you please provide URL where this code is hosted? I know it only as p= art=20 of madwifi.=20 Vladimir SL> I've suggested this code as a good starting point for a "generic 802.11 SL> stack" but received only misinformed responses. Folks who are unaware SL> of the work should take a look at it. SL> SL> Sam --nextPart1520535.EX0V45s7vl Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBBPLMvqxdj7mhC6o0RAj0KAJsExyiAY/GQGsH8FgpdbpfIq6G7ewCgqeq8 3H21MwboAZl/LwwDGEM6/AE= =5WfY -----END PGP SIGNATURE----- --nextPart1520535.EX0V45s7vl-- From sam@errno.com Mon Sep 6 12:31:46 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 12:31:51 -0700 (PDT) Received: from ebb.errno.com (ebb.errno.com [66.127.85.87]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86JVjIx009382 for ; Mon, 6 Sep 2004 12:31:45 -0700 Received: from [66.127.85.89] ([66.127.85.89]) (authenticated bits=0) by ebb.errno.com (8.12.9/8.12.6) with ESMTP id i86JUsWi084517 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO); Mon, 6 Sep 2004 12:30:54 -0700 (PDT) (envelope-from sam@errno.com) In-Reply-To: <200409062157.52042.vkondra@mail.ru> References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <757AB580-0030-11D9-9224-000A95AD0668@errno.com> <200409062157.52042.vkondra@mail.ru> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <44D53E64-003B-11D9-B426-000A95AD0668@errno.com> Content-Transfer-Encoding: 7bit Cc: Denis Vlasenko , netdev@oss.sgi.com, acx100-devel@lists.sourceforge.net, jgarzik@pobox.com, Jean Tourrilhes , Jouni Malinen , prism54-devel@prism54.org From: Sam Leffler Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Mon, 6 Sep 2004 12:30:54 -0700 To: Vladimir Kondratiev X-Mailer: Apple Mail (2.619) X-archive-position: 8445 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: sam@errno.com Precedence: bulk X-list: netdev Content-Length: 382 Lines: 16 On Sep 6, 2004, at 11:57 AM, Vladimir Kondratiev wrote: > Sam, > > could you please provide URL where this code is hosted? I know it only > as part > of madwifi. The madwifi project is hosted at sourceforge http;//sourceforge.net/projects/madwifi. Source code is currently available only via cvs (but there's a web interface that you can reach through the above url). Sam From vkondra@mail.ru Mon Sep 6 13:09:53 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 13:09:57 -0700 (PDT) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86K9qGU010331 for ; Mon, 6 Sep 2004 13:09:52 -0700 Received: from [212.179.200.204] (port=56485 helo=[192.168.10.2]) by mx1.mail.ru with esmtp id 1C4Po5-0000id-00; Tue, 07 Sep 2004 00:09:42 +0400 From: Vladimir Kondratiev To: netdev@oss.sgi.com Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Mon, 6 Sep 2004 23:09:18 +0300 User-Agent: KMail/1.7 Cc: Sam Leffler , Denis Vlasenko , acx100-devel@lists.sourceforge.net, jgarzik@pobox.com, Jean Tourrilhes , Jouni Malinen , prism54-devel@prism54.org References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <200409062157.52042.vkondra@mail.ru> <44D53E64-003B-11D9-B426-000A95AD0668@errno.com> In-Reply-To: <44D53E64-003B-11D9-B426-000A95AD0668@errno.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart5058822.29dr7VZc3Q"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200409062309.26113.vkondra@mail.ru> X-Spam: Probable Spam X-archive-position: 8446 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vkondra@mail.ru Precedence: bulk X-list: netdev Content-Length: 1054 Lines: 38 --nextPart5058822.29dr7VZc3Q Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I know about madwifi. I wondering whether there is URL for net80211, or it= =20 exist only as part of madwifi. Thanks, Vladimir On Monday 06 September 2004 22:30, Sam Leffler wrote: SL> On Sep 6, 2004, at 11:57 AM, Vladimir Kondratiev wrote: SL> SL> > Sam, SL> > SL> > could you please provide URL where this code is hosted? I know it only SL> > as part SL> > of madwifi. SL> SL> The madwifi project is hosted at sourceforge SL> http;//sourceforge.net/projects/madwifi. Source code is currently SL> available only via cvs (but there's a web interface that you can reach SL> through the above url). SL> SL> Sam --nextPart5058822.29dr7VZc3Q Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBBPMP2qxdj7mhC6o0RAvWCAKCOyYzH/QM+TncdMjwqMy/tRv4D6gCaAnmq V0Qm5+89YAX/B/uMhdZiUf8= =pcep -----END PGP SIGNATURE----- --nextPart5058822.29dr7VZc3Q-- From sam@errno.com Mon Sep 6 16:00:27 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 16:00:34 -0700 (PDT) Received: from ebb.errno.com (ebb.errno.com [66.127.85.87]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i86N0RjV013700 for ; Mon, 6 Sep 2004 16:00:27 -0700 Received: from [66.127.85.91] ([66.127.85.91]) (authenticated bits=0) by ebb.errno.com (8.12.9/8.12.6) with ESMTP id i86N06Wi085214 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Mon, 6 Sep 2004 16:00:06 -0700 (PDT) (envelope-from sam@errno.com) From: Sam Leffler Organization: Errno Consulting To: Vladimir Kondratiev Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Mon, 6 Sep 2004 16:04:13 -0700 User-Agent: KMail/1.6.2 Cc: netdev@oss.sgi.com, Denis Vlasenko , acx100-devel@lists.sourceforge.net, jgarzik@pobox.com, Jean Tourrilhes , Jouni Malinen , prism54-devel@prism54.org References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <44D53E64-003B-11D9-B426-000A95AD0668@errno.com> <200409062309.26113.vkondra@mail.ru> In-Reply-To: <200409062309.26113.vkondra@mail.ru> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409061604.13045.sam@errno.com> X-archive-position: 8447 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: sam@errno.com Precedence: bulk X-list: netdev Content-Length: 255 Lines: 7 On Monday 06 September 2004 01:09 pm, Vladimir Kondratiev wrote: > I know about madwifi. I wondering whether there is URL for net80211, or it > exist only as part of madwifi. It only exists as part of other systems (madwifi, netbsd, freebsd, etc.) Sam From davem@davemloft.net Mon Sep 6 18:26:15 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 18:26:20 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i871QFeS020057 for ; Mon, 6 Sep 2004 18:26:15 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C4Uhk-00006n-00; Mon, 06 Sep 2004 18:23:28 -0700 Date: Mon, 6 Sep 2004 18:23:28 -0700 From: "David S. Miller" To: Sam Leffler Cc: vda@port.imtp.ilyichevsk.odessa.ua, jgarzik@pobox.com, netdev@oss.sgi.com, acx100-devel@lists.sourceforge.net, jt@bougret.hpl.hp.com, jkmaline@cc.hut.fi, prism54-devel@prism54.org Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Message-Id: <20040906182328.08faf843.davem@davemloft.net> In-Reply-To: <757AB580-0030-11D9-9224-000A95AD0668@errno.com> References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <757AB580-0030-11D9-9224-000A95AD0668@errno.com> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8448 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 470 Lines: 12 On Mon, 6 Sep 2004 11:13:31 -0700 Sam Leffler wrote: > I've suggested this code as a good starting point for a "generic 802.11 > stack" but received only misinformed responses. Sam, I've told you multiple times why your stack isn't a good starting point. It isn't implemented as a true network stack, like IPV4, Appletalk, etc. Instead it's a gross input packet hooked packet eater thing that's an ugly wart bolted onto the side of the driver API. From sam@errno.com Mon Sep 6 21:29:35 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 21:29:40 -0700 (PDT) Received: from ebb.errno.com (ebb.errno.com [66.127.85.87]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i874TYRI001353 for ; Mon, 6 Sep 2004 21:29:35 -0700 Received: from [66.127.85.91] ([66.127.85.91]) (authenticated bits=0) by ebb.errno.com (8.12.9/8.12.6) with ESMTP id i874SiWi086212 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Mon, 6 Sep 2004 21:28:44 -0700 (PDT) (envelope-from sam@errno.com) From: Sam Leffler Organization: Errno Consulting To: "David S. Miller" Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Date: Mon, 6 Sep 2004 21:32:49 -0700 User-Agent: KMail/1.6.2 Cc: vda@port.imtp.ilyichevsk.odessa.ua, jgarzik@pobox.com, netdev@oss.sgi.com, acx100-devel@lists.sourceforge.net, jt@bougret.hpl.hp.com, jkmaline@cc.hut.fi, prism54-devel@prism54.org References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <757AB580-0030-11D9-9224-000A95AD0668@errno.com> <20040906182328.08faf843.davem@davemloft.net> In-Reply-To: <20040906182328.08faf843.davem@davemloft.net> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200409062132.49356.sam@errno.com> X-archive-position: 8449 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: sam@errno.com Precedence: bulk X-list: netdev Content-Length: 1625 Lines: 33 On Monday 06 September 2004 06:23 pm, David S. Miller wrote: > On Mon, 6 Sep 2004 11:13:31 -0700 > > Sam Leffler wrote: > > I've suggested this code as a good starting point for a "generic 802.11 > > stack" but received only misinformed responses. > > Sam, I've told you multiple times why your stack isn't a good > starting point. It isn't implemented as a true network stack, > like IPV4, Appletalk, etc. Instead it's a gross input packet > hooked packet eater thing that's an ugly wart bolted onto the > side of the driver API. Actually, this is the first time you've said anything to me about this code. We corresponded intensely for about a week 2+ years ago after which you declared you now knew how to "write an 802.11 stack right" and were going to do it that weekend. I waited but it seems the sum total result was the shell of code that Jeff referenced in a previous note. Perhaps you can point me at a description of what a "true network stack" means to you. I'm guessing this has to do with your wanting queues inserted at various places instead of direct handoffs. Regardless, I've never suggested the current code is suitable as-is but rather should be reshaped to suit the intended structure of the system. There is a lot of hard-earned experience in the code that is independent of coding style and operational infrastructure. Anyway, the point of my note was to correct a comment in the original posting and make folks aware that working code existed from which they could crib stuff. Good luck finding someone to reimplement eveything according to your wishes. Sam From davem@davemloft.net Mon Sep 6 23:51:02 2004 Received: with ECARTIS (v1.0.0; list netdev); Mon, 06 Sep 2004 23:51:09 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i876p2vQ005579 for ; Mon, 6 Sep 2004 23:51:02 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C4Zkr-0000Nd-00; Mon, 06 Sep 2004 23:47:01 -0700 Date: Mon, 6 Sep 2004 23:47:01 -0700 From: "David S. Miller" To: Sam Leffler Cc: vda@port.imtp.ilyichevsk.odessa.ua, jgarzik@pobox.com, netdev@oss.sgi.com, acx100-devel@lists.sourceforge.net, jt@bougret.hpl.hp.com, jkmaline@cc.hut.fi, prism54-devel@prism54.org Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Message-Id: <20040906234701.511a8940.davem@davemloft.net> In-Reply-To: <200409062132.49356.sam@errno.com> References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <757AB580-0030-11D9-9224-000A95AD0668@errno.com> <20040906182328.08faf843.davem@davemloft.net> <200409062132.49356.sam@errno.com> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8450 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 1022 Lines: 23 On Mon, 6 Sep 2004 21:32:49 -0700 Sam Leffler wrote: > Actually, this is the first time you've said anything to me about this code. I do remember telling you how much I was against this element of your design. At the time, you were not willing to rearchitect things and you were in a sort-of bug-fix only mode. > Perhaps you can point me at a description of what a "true network stack" means > to you. It means passing the 802.11 protocol packets into the networking just like any other type of packet, via netif_rx() or netif_receive_skb(). Creating an ETH_P_80211 protocol type and registering the stack via dev_add_pack() just like any other real protocol layer does. Then responses generated in that 802.11 stack need to feed packets back out to the network via the normal and usual methods of transmitting packets in the networking, namely dev_queue_xmit(). That is exactly what my shell protocol layer does, and it is exactly how a real 802.11 soft stack should be implemented and operate. From olh@suse.de Tue Sep 7 03:00:01 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 03:00:45 -0700 (PDT) Received: from Cantor.suse.de (cantor.suse.de [195.135.220.2]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i879xxvr014849 for ; Tue, 7 Sep 2004 03:00:00 -0700 Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 253AEB9CB72; Tue, 7 Sep 2004 11:59:45 +0200 (CEST) Date: Mon, 6 Sep 2004 15:36:00 +0200 From: Olaf Hering To: Jeff Garzik , netdev@oss.sgi.com Cc: linuxppc-dev@lists.linuxppc.org Subject: [PATCH] mark mace and bmac as ppc32 only Message-ID: <20040906133600.GA9143@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-DOS: I got your 640K Real Mode Right Here Buddy! X-Homeland-Security: You are not supposed to read this line! You are a terrorist! User-Agent: Mutt und vi sind doch schneller als Notes (und GroupWise) X-archive-position: 8451 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: olh@suse.de Precedence: bulk X-list: netdev Content-Length: 974 Lines: 29 mace and bmac are only used in "oldworld" PowerMacs. Mark them as ppc32 only. diff -purN linux-2.6.9-rc1-bk13.orig/drivers/net/Kconfig linux-2.6.9-rc1-bk13/drivers/net/Kconfig --- linux-2.6.9-rc1-bk13.orig/drivers/net/Kconfig 2004-09-06 15:23:35.000000000 +0200 +++ linux-2.6.9-rc1-bk13/drivers/net/Kconfig 2004-09-06 15:27:26.290604859 +0200 @@ -200,7 +200,7 @@ source "drivers/net/arm/Kconfig" config MACE tristate "MACE (Power Mac ethernet) support" - depends on NET_ETHERNET && PPC_PMAC + depends on NET_ETHERNET && PPC_PMAC && PPC32 select CRC32 help Power Macintoshes and clones with Ethernet built-in on the @@ -223,7 +223,7 @@ config MACE_AAUI_PORT config BMAC tristate "BMAC (G3 ethernet) support" - depends on NET_ETHERNET && PPC_PMAC + depends on NET_ETHERNET && PPC_PMAC && PPC32 select CRC32 help Say Y for support of BMAC Ethernet interfaces. These are used on G3 -- USB is for mice, FireWire is for men! sUse lINUX ag, nÜRNBERG From hadi@cyberus.ca Tue Sep 7 03:18:50 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 03:18:55 -0700 (PDT) Received: from lotus.znyx.com (znx208-2-156-007.znyx.com [208.2.156.7]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87AIoQl015467 for ; Tue, 7 Sep 2004 03:18:50 -0700 Received: from localhost.tpn.ch ([208.2.156.2]) by lotus.znyx.com (Lotus Domino Release 5.0.11) with ESMTP id 2004090703200939:31348 ; Tue, 7 Sep 2004 03:20:09 -0700 Subject: Re: [PATCH 2.6] watch64: generic variable monitoring system From: jamal Reply-To: hadi@cyberus.ca To: Jeff Sipek Cc: Stephen Hemminger , linux-kernel@vger.kernel.org, netdev@oss.sgi.com In-Reply-To: <200409051219.47590.jeffpc@optonline.net> References: <200409031307.01240.jeffpc@optonline.net> <200409031744.32970.jeffpc@optonline.net> <1094303999.1633.116.camel@jzny.localdomain> <200409051219.47590.jeffpc@optonline.net> Organization: jamalopolis Message-Id: <1094460391.1151.26.camel@jzny.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 07 Sep 2004 06:18:11 -0400 X-MIMETrack: Itemize by SMTP Server on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/07/2004 03:20:09 AM, Serialize by Router on Lotus/Znyx(Release 5.0.11 |July 24, 2002) at 09/07/2004 03:20:12 AM, Serialize complete at 09/07/2004 03:20:12 AM Content-Transfer-Encoding: 7bit Content-Type: text/plain X-archive-position: 8452 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hadi@cyberus.ca Precedence: bulk X-list: netdev Content-Length: 566 Lines: 19 On Sun, 2004-09-05 at 12:19, Jeff Sipek wrote: > On Saturday 04 September 2004 09:19, jamal wrote: > > I have a feeling this was discussed somewhere(other than netdev) and i > > missed it. Why isnt this watch64 being done in user space? > > There was a discussion about 64-bit network statistics about a year ago on > lkml. Sorry unsubscribed from lkml since summer of '94. [net related discussions should really happen on netdev]. > watch64 is a generic so that anyone in the kernel can use it. Ok - so why does this have to be in the kernel? cheers, jamal From util@deuroconsult.ro Tue Sep 7 03:36:03 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 03:36:07 -0700 (PDT) Received: from hosting.rdsbv.ro (webhosting.rdsbv.ro [213.157.185.164]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87Aa298016053 for ; Tue, 7 Sep 2004 03:36:02 -0700 Received: from hosting.rdsbv.ro (hosting.rdsbv.ro [213.157.185.164]) by hosting.rdsbv.ro (8.12.11/8.12.11) with ESMTP id i87AZq1Z009700; Tue, 7 Sep 2004 13:35:52 +0300 Date: Tue, 7 Sep 2004 13:35:52 +0300 (EEST) From: "Catalin(ux aka Dino) BOIE" X-X-Sender: util@hosting.rdsbv.ro To: netdev@oss.sgi.com cc: linux-kernel@vger.kernel.org Subject: [PATCH] Trivial fix for out of bounds array access in xfrm4_policy_check Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1646943047-1948299716-1094553352=:8637" X-archive-position: 8453 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: util@deuroconsult.ro Precedence: bulk X-list: netdev Content-Length: 1831 Lines: 42 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1646943047-1948299716-1094553352=:8637 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Hello! Coverity found a bug in accessing xfrm4_policy_check using XFRM_POLICY_FWD (=2) as index in sk->sk_policy. sk->sk_policy[] is defined in sock.h as: struct xfrm_policy *sk_policy[2]; Attached is the fix. http://linuxbugs.coverity.com/external/editbugparent.php?viewbugid=2138&checkers%5B%5D=all&status%5B%5D=BUG&status%5B%5D=UNINSPECTED&status%5B%5D=UNKNOWN&status%5B%5D=DON%27T%20CARE&status%5B%5D=PENDING&product%5B%5D=all&component%5B%5D=all&file=&fn=&sortby=reverse_rank&before=&after=&curpage=2&bugid=-1&comment=&reason= --- Catalin(ux aka Dino) BOIE catab at deuroconsult.ro http://kernel.umbrella.ro/ ---1646943047-1948299716-1094553352=:8637 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="out-of-bounds-xfrm_policy.patch" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="out-of-bounds-xfrm_policy.patch" LS0tIGxpbnV4L2luY2x1ZGUvbmV0L3NvY2suaAkyMDA0LTA5LTA3IDEzOjEz OjMxLjAwMDAwMDAwMCArMDMwMA0KKysrIG15bGludXgvaW5jbHVkZS9uZXQv c29jay5oCTIwMDQtMDktMDcgMTM6MTQ6MzYuMDAwMDAwMDAwICswMzAwDQpA QCAtMjAxLDcgKzIwMSw3IEBAIHN0cnVjdCBzb2NrIHsNCiAJd2FpdF9xdWV1 ZV9oZWFkX3QJKnNrX3NsZWVwOw0KIAlzdHJ1Y3QgZHN0X2VudHJ5CSpza19k c3RfY2FjaGU7DQogCXJ3bG9ja190CQlza19kc3RfbG9jazsNCi0Jc3RydWN0 IHhmcm1fcG9saWN5CSpza19wb2xpY3lbMl07DQorCXN0cnVjdCB4ZnJtX3Bv bGljeQkqc2tfcG9saWN5WzNdOw0KIAlhdG9taWNfdAkJc2tfcm1lbV9hbGxv YzsNCiAJc3RydWN0IHNrX2J1ZmZfaGVhZAlza19yZWNlaXZlX3F1ZXVlOw0K IAlhdG9taWNfdAkJc2tfd21lbV9hbGxvYzsNCg== ---1646943047-1948299716-1094553352=:8637-- From ak@suse.de Tue Sep 7 04:57:11 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 04:57:17 -0700 (PDT) Received: from Cantor.suse.de (cantor.suse.de [195.135.220.2]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87BvASp022072 for ; Tue, 7 Sep 2004 04:57:11 -0700 Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id BD582B9DCC9; Tue, 7 Sep 2004 13:56:55 +0200 (CEST) Date: Tue, 7 Sep 2004 13:56:55 +0200 From: Andi Kleen To: Herbert Xu Cc: Andi Kleen , davem@redhat.com, netdev@oss.sgi.com, akepner@sgi.com Subject: Re: [PATCH] Do less atomic count changes in dev_queue_xmit Message-ID: <20040907115655.GA25051@wotan.suse.de> References: <20040904135439.GA23934@wotan.suse.de> <20040905220341.GA13217@gondor.apana.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040905220341.GA13217@gondor.apana.org.au> X-archive-position: 8454 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ak@suse.de Precedence: bulk X-list: netdev Content-Length: 3842 Lines: 144 On Mon, Sep 06, 2004 at 08:03:41AM +1000, Herbert Xu wrote: > On Sat, Sep 04, 2004 at 01:54:39PM +0000, Andi Kleen wrote: > > > > diff -u linux-2.6.8/net/core/dev.c-o linux-2.6.8/net/core/dev.c > > --- linux-2.6.8/net/core/dev.c-o 2004-09-04 13:10:47.000000000 +0000 > > +++ linux-2.6.8/net/core/dev.c 2004-09-04 13:47:16.765722813 +0000 > > @@ -1249,14 +1249,14 @@ > > return 0; > > } > > > > -#define HARD_TX_LOCK_BH(dev, cpu) { \ > > +#define HARD_TX_LOCK(dev, cpu) { \ > > if ((dev->features & NETIF_F_LLTX) == 0) { \ > > spin_lock_bh(&dev->xmit_lock); \ > > You can remove the _bh here as well. Ok done. > > > @@ -1358,12 +1361,11 @@ > > Either shot noqueue qdisc, it is even simpler 8) > > */ > > if (dev->flags & IFF_UP) { > > - int cpu = get_cpu(); > > + int cpu = smp_processor_id(); /* ok because BHs are off */ > > Hmm this means that the loopback xmit function will now execute with > BH/preempt turned off. Is this what we want? I think so yes. It is not that costly. David, can you please consider this patch, thanks? -Andi --------------------------------------------------------------- Streamline atomic count handling in queue xmit fast path. Only do it once instead of multiple times. diff -u linux-2.6.8/net/core/dev.c-o linux-2.6.8/net/core/dev.c --- linux-2.6.8/net/core/dev.c-o 2004-09-04 13:10:47.000000000 +0000 +++ linux-2.6.8/net/core/dev.c 2004-09-07 08:09:52.000000000 +0000 @@ -1249,17 +1249,17 @@ return 0; } -#define HARD_TX_LOCK_BH(dev, cpu) { \ +#define HARD_TX_LOCK(dev, cpu) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \ - spin_lock_bh(&dev->xmit_lock); \ + spin_lock(&dev->xmit_lock); \ dev->xmit_lock_owner = cpu; \ } \ } -#define HARD_TX_UNLOCK_BH(dev) { \ +#define HARD_TX_UNLOCK(dev) { \ if ((dev->features & NETIF_F_LLTX) == 0) { \ dev->xmit_lock_owner = -1; \ - spin_unlock_bh(&dev->xmit_lock); \ + spin_unlock(&dev->xmit_lock); \ } \ } @@ -1313,7 +1313,12 @@ if (skb_checksum_help(&skb, 0)) goto out_kfree_skb; - rcu_read_lock(); + + /* Disable soft irqs for various locks below. Also + * stops preemption for RCU. + */ + local_bh_disable(); + /* Updates of qdisc are serialized by queue_lock. * The struct Qdisc which is pointed to by qdisc is now a * rcu structure - it may be accessed without acquiring @@ -1332,18 +1337,16 @@ #endif if (q->enqueue) { /* Grab device queue */ - spin_lock_bh(&dev->queue_lock); + spin_lock(&dev->queue_lock); rc = q->enqueue(skb, q); qdisc_run(dev); - spin_unlock_bh(&dev->queue_lock); - rcu_read_unlock(); + spin_unlock(&dev->queue_lock); rc = rc == NET_XMIT_BYPASS ? NET_XMIT_SUCCESS : rc; goto out; } - rcu_read_unlock(); /* The device has no queue. Common case for software devices: loopback, all the sorts of tunnels... @@ -1358,12 +1361,11 @@ Either shot noqueue qdisc, it is even simpler 8) */ if (dev->flags & IFF_UP) { - int cpu = get_cpu(); + int cpu = smp_processor_id(); /* ok because BHs are off */ if (dev->xmit_lock_owner != cpu) { - HARD_TX_LOCK_BH(dev, cpu); - put_cpu(); + HARD_TX_LOCK(dev, cpu); if (!netif_queue_stopped(dev)) { if (netdev_nit) @@ -1371,17 +1373,16 @@ rc = 0; if (!dev->hard_start_xmit(skb, dev)) { - HARD_TX_UNLOCK_BH(dev); + HARD_TX_UNLOCK(dev); goto out; } } - HARD_TX_UNLOCK_BH(dev); + HARD_TX_UNLOCK(dev); if (net_ratelimit()) printk(KERN_CRIT "Virtual device %s asks to " "queue packet!\n", dev->name); goto out_enetdown; } else { - put_cpu(); /* Recursion is detected! It is possible, * unfortunately */ if (net_ratelimit()) @@ -1394,6 +1395,7 @@ out_kfree_skb: kfree_skb(skb); out: + local_bh_enable(); return rc; } From ak@suse.de Tue Sep 7 05:08:10 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 05:08:15 -0700 (PDT) Received: from Cantor.suse.de (cantor.suse.de [195.135.220.2]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87C893Z022627 for ; Tue, 7 Sep 2004 05:08:10 -0700 Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 3D8EAB9AC39; Tue, 7 Sep 2004 14:05:32 +0200 (CEST) Date: Tue, 7 Sep 2004 14:05:32 +0200 From: Andi Kleen To: davem@redhat.com, netdev@oss.sgi.com Subject: [PATCH] NETIF_F_LLTX for devices 2 Message-ID: <20040907120532.GB25051@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-archive-position: 8455 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ak@suse.de Precedence: bulk X-list: netdev Content-Length: 4874 Lines: 162 New version of the NETIF_F_LLTX for network devices patch. This allows network drivers to set the NETIF_F_LLTX flag and then do their own locking in start_queue_xmit. This lowers locking overhead in this critical path. The drivers can use try lock if they want and return -1 when the lock wasn't grabbed. In this case the packet will be requeued. For better compatibility this is only done for drivers with LLTX set, others don't give a special meaning to -1. Most of the modern drivers who have a lock around hard_start_xmit can just set this flag. It may be a good idea to convert the spin lock there to a try lock. The only thing that should be audited is that they do enough locking in the set_multicast_list function too, and not also rely on xmit_lock here. Now doesn't move any code around and does things with gotos instead. The loop printk is also still there even for NETIF_F_LLTX For drivers that don't set the new flag nothing changes. Please consider applying. -Andi diff -u linux-2.6.8/net/core/pktgen.c-LLTX linux-2.6.8/net/core/pktgen.c --- linux-2.6.8/net/core/pktgen.c-LLTX 2004-09-04 12:47:05.000000000 +0000 +++ linux-2.6.8/net/core/pktgen.c 2004-09-04 14:07:12.000000000 +0000 @@ -634,7 +634,8 @@ nr_frags = skb_shinfo(skb)->nr_frags; - spin_lock_bh(&odev->xmit_lock); + if (!(odev->features & NETIF_F_LLTX)) + spin_lock_bh(&odev->xmit_lock); if (!netif_queue_stopped(odev)) { atomic_inc(&skb->users); @@ -659,8 +660,8 @@ last_ok = 0; } - - spin_unlock_bh(&odev->xmit_lock); + if (!(odev->features & NETIF_F_LLTX)) + spin_unlock_bh(&odev->xmit_lock); if (info->ipg) { /* Try not to busy-spin if we have larger sleep times. diff -u linux-2.6.8/net/sched/sch_generic.c-LLTX linux-2.6.8/net/sched/sch_generic.c --- linux-2.6.8/net/sched/sch_generic.c-LLTX 2004-09-04 12:47:05.000000000 +0000 +++ linux-2.6.8/net/sched/sch_generic.c 2004-09-07 11:58:45.595363313 +0000 @@ -97,46 +97,73 @@ /* Dequeue packet */ if ((skb = q->dequeue(q)) != NULL) { - if (spin_trylock(&dev->xmit_lock)) { + unsigned nolock = (dev->features & NETIF_F_LLTX); + /* + * When the driver has LLTX set it does its own locking + * in start_xmit. No need to add additional overhead by + * locking again. These checks are worth it because + * even uncongested locks can be quite expensive. + * The driver can do trylock like here too, in case + * of lock congestion it should return -1 and the packet + * will be requeued. + */ + if (!nolock) { + if (!spin_trylock(&dev->xmit_lock)) { + collision: + /* So, someone grabbed the driver. */ + + /* It may be transient configuration error, + when hard_start_xmit() recurses. We detect + it by checking xmit owner and drop the + packet when deadloop is detected. + */ + if (dev->xmit_lock_owner == smp_processor_id()) { + kfree_skb(skb); + if (net_ratelimit()) + printk(KERN_DEBUG "Dead loop on netdevice %s, fix it urgently!\n", dev->name); + return -1; + } + __get_cpu_var(netdev_rx_stat).cpu_collision++; + goto requeue; + } /* Remember that the driver is grabbed by us. */ dev->xmit_lock_owner = smp_processor_id(); - + } + + { /* And release queue */ spin_unlock(&dev->queue_lock); if (!netif_queue_stopped(dev)) { + int ret; if (netdev_nit) dev_queue_xmit_nit(skb, dev); - if (dev->hard_start_xmit(skb, dev) == 0) { - dev->xmit_lock_owner = -1; - spin_unlock(&dev->xmit_lock); - + /* hard_start_xmit returns: + 0 device not ready + 1 everything ok + -1 didn't get device lock (for LLTX) + */ + ret = dev->hard_start_xmit(skb, dev); + if (ret == 0) { + if (!nolock) { + dev->xmit_lock_owner = -1; + spin_unlock(&dev->xmit_lock); + } spin_lock(&dev->queue_lock); return -1; } + if (ret == -1 && nolock) + goto collision; } /* Release the driver */ - dev->xmit_lock_owner = -1; - spin_unlock(&dev->xmit_lock); + if (!nolock) { + dev->xmit_lock_owner = -1; + spin_unlock(&dev->xmit_lock); + } spin_lock(&dev->queue_lock); q = dev->qdisc; - } else { - /* So, someone grabbed the driver. */ - - /* It may be transient configuration error, - when hard_start_xmit() recurses. We detect - it by checking xmit owner and drop the - packet when deadloop is detected. - */ - if (dev->xmit_lock_owner == smp_processor_id()) { - kfree_skb(skb); - if (net_ratelimit()) - printk(KERN_DEBUG "Dead loop on netdevice %s, fix it urgently!\n", dev->name); - return -1; - } - __get_cpu_var(netdev_rx_stat).cpu_collision++; } /* Device kicked us out :( @@ -149,6 +176,7 @@ 3. device is buggy (ppp) */ + requeue: q->ops->requeue(skb, q); netif_schedule(dev); return 1; From ak@suse.de Tue Sep 7 05:18:56 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 05:19:00 -0700 (PDT) Received: from Cantor.suse.de (cantor.suse.de [195.135.220.2]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87CItrb023062 for ; Tue, 7 Sep 2004 05:18:56 -0700 Received: from hermes.suse.de (hermes-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 63E98B9E117; Tue, 7 Sep 2004 14:18:41 +0200 (CEST) Date: Tue, 7 Sep 2004 14:18:41 +0200 From: Andi Kleen To: davem@redhat.com, netdev@oss.sgi.com Subject: [PATCH] LLTX for tg3 Message-ID: <20040907121841.GA4398@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-archive-position: 8456 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: ak@suse.de Precedence: bulk X-list: netdev Content-Length: 959 Lines: 30 Add LLTX suppor to tg3. Locking was already safe for it, so only trivial changes. Depends on the LLTX patch sent earlier. diff -u linux-2.6.8/drivers/net/tg3.c-o linux-2.6.8/drivers/net/tg3.c --- linux-2.6.8/drivers/net/tg3.c-o 2004-09-04 13:10:46.000000000 +0000 +++ linux-2.6.8/drivers/net/tg3.c 2004-09-07 08:17:36.000000000 +0000 @@ -3036,7 +3036,11 @@ * So we really do need to disable interrupts when taking * tx_lock here. */ - spin_lock_irqsave(&tp->tx_lock, flags); + local_irq_save(flags); + if (!spin_trylock(&tp->tx_lock)) { + local_irq_restore(flags); + return -1; + } /* This is a hard error, log it. */ if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { @@ -8255,6 +8259,7 @@ if (pci_using_dac) dev->features |= NETIF_F_HIGHDMA; + dev->features |= NETIF_F_LLTX; #if TG3_VLAN_TAG_USED dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; dev->vlan_rx_register = tg3_vlan_rx_register; From herbert@gondor.apana.org.au Tue Sep 7 05:46:55 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 05:47:03 -0700 (PDT) Received: from arnor.apana.org.au (mail@arnor.apana.org.au [203.14.152.115]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87Ckr69023753 for ; Tue, 7 Sep 2004 05:46:54 -0700 Received: from gondolin.me.apana.org.au ([192.168.0.6] ident=mail) by arnor.apana.org.au with esmtp (Exim 3.35 #1 (Debian)) id 1C4fMi-0008Q6-00; Tue, 07 Sep 2004 22:46:28 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 3.36 #1 (Debian)) id 1C4fMc-000817-00; Tue, 07 Sep 2004 22:46:22 +1000 From: Herbert Xu To: util@deuroconsult.ro (Catalinux aka Dino BOIE) Subject: Re: [PATCH] Trivial fix for out of bounds array access in xfrm4_policy_check Cc: netdev@oss.sgi.com, linux-kernel@vger.kernel.org Organization: Core In-Reply-To: X-Newsgroups: apana.lists.os.linux.kernel,apana.lists.os.linux.netdev User-Agent: tin/1.7.4-20040225 ("Benbecula") (UNIX) (Linux/2.4.26-1-686-smp (i686)) Message-Id: Date: Tue, 07 Sep 2004 22:46:22 +1000 X-archive-position: 8457 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: herbert@gondor.apana.org.au Precedence: bulk X-list: netdev Content-Length: 552 Lines: 17 Catalinux aka Dino BOIE wrote: > > Coverity found a bug in accessing xfrm4_policy_check using XFRM_POLICY_FWD > (=2) as index in sk->sk_policy. > > sk->sk_policy[] is defined in sock.h as: > > struct xfrm_policy *sk_policy[2]; > > Attached is the fix. This is bogus as if the packet is forwarded then sk == NULL. -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt From SRS0+cdae3b82a2e6926aca13+380+infradead.org+dwmw2@canuck.srs.infradead.org Tue Sep 7 06:36:54 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 06:36:58 -0700 (PDT) Received: from canuck.infradead.org (canuck.infradead.org [205.233.218.70]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87Darn6025294 for ; Tue, 7 Sep 2004 06:36:54 -0700 Received: from imladris.demon.co.uk ([193.237.130.41] helo=[192.168.1.253]) by canuck.infradead.org with asmtp (Exim 4.33 #1 (Red Hat Linux)) id 1C4g9L-0008Vn-8j; Tue, 07 Sep 2004 09:36:43 -0400 Subject: [PATCH] Compat32 setsockopt overzealous conversions From: David Woodhouse To: netdev@oss.sgi.com Cc: davem@redhat.com Content-Type: text/plain Date: Tue, 07 Sep 2004 14:23:00 +0100 Message-Id: <1094563381.5122.8.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 1.5.94.1 (1.5.94.1-1) Content-Transfer-Encoding: 7bit X-SRS-Rewrite: SMTP reverse-path rewritten from by canuck.infradead.org See http://www.infradead.org/rpr.html X-archive-position: 8458 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: dwmw2@infradead.org Precedence: bulk X-list: netdev Content-Length: 1513 Lines: 38 compat_sys_setsockopt() is a little overzealous about converting 32-bit stuff into 64-bit. It should match on level _and_ optname, not just optname. Currently it eats the IPV6_V6ONLY sockopt because its value (26) happens to match SO_ATTACH_FILTER. This makes it at least check 'level' for everything but IPT_SO_SET_REPLACE == IPT6_SO_SET_REPLACE, because that does seem to be the same in different levels. But do_netfilter_replace() is another can of worms entirely -- it doesn't actually work either, because some netfilter modules (like ipt_limit) include kernel-only bits which change size in the structure they share with userspace. --- net/compat.c~ 2004-08-14 06:37:15.000000000 +0100 +++ net/compat.c 2004-09-03 17:47:26.260926176 +0100 @@ -455,13 +455,15 @@ asmlinkage long compat_sys_setsockopt(int fd, int level, int optname, char __user *optval, int optlen) { + /* SO_SET_REPLACE seems to be the same in all levels */ if (optname == IPT_SO_SET_REPLACE) return do_netfilter_replace(fd, level, optname, optval, optlen); - if (optname == SO_ATTACH_FILTER) + if (level == SOL_SOCKET && optname == SO_ATTACH_FILTER) return do_set_attach_filter(fd, level, optname, optval, optlen); - if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) + if (level == SOL_SOCKET && + (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) return do_set_sock_timeout(fd, level, optname, optval, optlen); return sys_setsockopt(fd, level, optname, optval, optlen); -- dwmw2 From hch@lst.de Tue Sep 7 08:18:08 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 08:18:12 -0700 (PDT) Received: from mail.lst.de (verein.lst.de [213.95.11.210]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87FI6ki029520 for ; Tue, 7 Sep 2004 08:18:07 -0700 Received: from verein.lst.de (localhost [127.0.0.1]) by mail.lst.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i87FHr95009747 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 7 Sep 2004 17:17:53 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id i87FHrVu009745; Tue, 7 Sep 2004 17:17:53 +0200 Date: Tue, 7 Sep 2004 17:17:53 +0200 From: Christoph Hellwig To: akpm@osdl.org Cc: netdev@oss.sgi.com Subject: [PATCH] remove secure_ipv6_id Message-ID: <20040907151753.GA9735@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-archive-position: 8459 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hch@lst.de Precedence: bulk X-list: netdev Content-Length: 939 Lines: 36 looks like the ipv6 code doesn't need this one anymore --- 1.54/drivers/char/random.c 2004-09-03 11:08:21 +02:00 +++ edited/drivers/char/random.c 2004-09-07 15:51:23 +02:00 @@ -2279,19 +2279,7 @@ return seq; } EXPORT_SYMBOL(secure_tcpv6_sequence_number); - -__u32 secure_ipv6_id(__u32 *daddr) -{ - struct keydata *keyptr; - - keyptr = check_and_rekey(get_seconds()); - - return halfMD4Transform(daddr, keyptr->secret); -} - -EXPORT_SYMBOL(secure_ipv6_id); #endif - __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport) --- 1.3/include/linux/random.h 2003-09-21 23:50:34 +02:00 +++ edited/include/linux/random.h 2004-09-07 14:07:58 +02:00 @@ -67,8 +67,6 @@ extern __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr, __u16 sport, __u16 dport); -extern __u32 secure_ipv6_id(__u32 *daddr); - #ifndef MODULE extern struct file_operations random_fops, urandom_fops; #endif From hch@lst.de Tue Sep 7 08:19:29 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 08:19:34 -0700 (PDT) Received: from mail.lst.de (verein.lst.de [213.95.11.210]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87FJSDA000418 for ; Tue, 7 Sep 2004 08:19:29 -0700 Received: from verein.lst.de (localhost [127.0.0.1]) by mail.lst.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i87FJJ95009785 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 7 Sep 2004 17:19:19 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id i87FJJZU009783; Tue, 7 Sep 2004 17:19:19 +0200 Date: Tue, 7 Sep 2004 17:19:18 +0200 From: Christoph Hellwig To: davem@redhat.com Cc: netdev@oss.sgi.com Subject: [PATCH] mark inet_family_ops static Message-ID: <20040907151918.GB9735@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-archive-position: 8460 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hch@lst.de Precedence: bulk X-list: netdev Content-Length: 1039 Lines: 34 except for a stale extern in net/sctp/protocol.c it's not referenced anywhere outside af_inet.c --- 1.74/net/ipv4/af_inet.c 2004-07-07 07:01:31 +02:00 +++ edited/net/ipv4/af_inet.c 2004-09-07 13:47:22 +02:00 @@ -837,7 +837,7 @@ .sendpage = inet_sendpage, }; -struct net_proto_family inet_family_ops = { +static struct net_proto_family inet_family_ops = { .family = PF_INET, .create = inet_create, .owner = THIS_MODULE, @@ -1157,7 +1157,6 @@ EXPORT_SYMBOL(inet_bind); EXPORT_SYMBOL(inet_dgram_connect); EXPORT_SYMBOL(inet_dgram_ops); -EXPORT_SYMBOL(inet_family_ops); EXPORT_SYMBOL(inet_getname); EXPORT_SYMBOL(inet_ioctl); EXPORT_SYMBOL(inet_listen); --- 1.72/net/sctp/protocol.c 2004-08-13 01:41:13 +02:00 +++ edited/net/sctp/protocol.c 2004-09-07 13:47:08 +02:00 @@ -81,8 +81,6 @@ kmem_cache_t *sctp_chunk_cachep; kmem_cache_t *sctp_bucket_cachep; -extern struct net_proto_family inet_family_ops; - extern int sctp_snmp_proc_init(void); extern int sctp_snmp_proc_exit(void); extern int sctp_eps_proc_init(void); From hch@lst.de Tue Sep 7 08:20:40 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 08:20:45 -0700 (PDT) Received: from mail.lst.de (verein.lst.de [213.95.11.210]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87FKdZg000763 for ; Tue, 7 Sep 2004 08:20:40 -0700 Received: from verein.lst.de (localhost [127.0.0.1]) by mail.lst.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id i87FKU95009804 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Tue, 7 Sep 2004 17:20:30 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id i87FKTfD009802; Tue, 7 Sep 2004 17:20:29 +0200 Date: Tue, 7 Sep 2004 17:20:29 +0200 From: Christoph Hellwig To: davem@redhat.com Cc: netdev@oss.sgi.com Subject: [PATCH] unexport alloc_divert_blk/free_divert_blk Message-ID: <20040907152029.GC9735@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-archive-position: 8461 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hch@lst.de Precedence: bulk X-list: netdev Content-Length: 274 Lines: 14 these are called by dev.c for every device (and nowhere else) --- 1.10/net/core/dv.c 2004-04-16 22:56:10 +02:00 +++ edited/net/core/dv.c 2004-09-07 15:07:09 +02:00 @@ -553,6 +553,3 @@ break; } } - -EXPORT_SYMBOL(alloc_divert_blk); -EXPORT_SYMBOL(free_divert_blk); From greg@atheros.com Tue Sep 7 10:03:00 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 10:03:05 -0700 (PDT) Received: from atheros.com (mail.atheros.com [65.212.155.130]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87H2xRe003329 for ; Tue, 7 Sep 2004 10:03:00 -0700 Received: from [10.10.10.169] (account greg HELO atheros.com) by atheros.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 8808706; Tue, 07 Sep 2004 10:02:44 -0700 Message-ID: <413DE9ED.30300@atheros.com> Date: Tue, 07 Sep 2004 10:03:41 -0700 From: greg chesson User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sam Leffler CC: "David S. Miller" , vda@port.imtp.ilyichevsk.odessa.ua, jgarzik@pobox.com, netdev@oss.sgi.com, acx100-devel@lists.sourceforge.net, jt@bougret.hpl.hp.com, jkmaline@cc.hut.fi, prism54-devel@prism54.org Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <757AB580-0030-11D9-9224-000A95AD0668@errno.com> <20040906182328.08faf843.davem@davemloft.net> <200409062132.49356.sam@errno.com> In-Reply-To: <200409062132.49356.sam@errno.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-archive-position: 8462 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: greg@atheros.com Precedence: bulk X-list: netdev Content-Length: 4139 Lines: 101 Oh really? What about eth_type_trans()? It is not implemented as a true network stack. Many drivers call it, but it is a gross input packet hooked eater thing that's an ugly wart bolted onto the side of the driver API. what's good for the goose, etc. My point is that there is ample precedent in the OS for common driver "assistance" subroutines that contain protocol knowledge or implement policy yet are not implemented in strict stack-like manner because it didn't make sense to do 'em that way. It seems to me that Sam's net80211 code is performing three essential functions: 1. encap/decap service for converting between 802.3 and 802.11 2. the MLME protocol (802.11 management messages and state keeping) 3. interface to upper layer ioctl stuff, particularly user-land crypto supplicants and authenticators in addition to the usual group of tools. The MLME protocol works as a stack already since it really does implement a protocol. The encap/decap could be implemented stack-like instead of eth_type_trans-like, but it seems very suboptimal to do it another way. The ioctl interfaces are a wart on the side of the driver API anyway, but let's not have an argument about that since it is a design feature of the OS inherited from unix. The complaint seems to be mainly about the encap/decap procedures which are implemented more as driver helper functions. If somebody wants to rewrite them as a stack, then go for it. I'll be interested in seeing whether or not good methods can be found for exporting driver-local information (e.g. the mac address of the AP, or the tx PHY rate needed to calculate the duration field value, or whether or not to do mac tx fragmentation, etc) up the stack without creating a pile of spaghetti to rival Microsoft's failed "native 802.11" project. I've thought about this problem and don't think there is a good answer if a layered approach to protocol implementation stipulates that each layer be self-contained. The 802.11 situation requires more data-sharing between layers than is conducive to a strict layering approach. I suspect that what's needed is a data structure tailored to wireless which can be shared between layers and common across devices. Perhaps it could be an extention to dev (wdev?) that captures the necessary sharing. But the problems don't stop there. Think for a moment about where power-save should be implemented - which layer? cheers, g Sam Leffler wrote: > On Monday 06 September 2004 06:23 pm, David S. Miller wrote: > >>On Mon, 6 Sep 2004 11:13:31 -0700 >> >>Sam Leffler wrote: >> >>>I've suggested this code as a good starting point for a "generic 802.11 >>>stack" but received only misinformed responses. >> >>Sam, I've told you multiple times why your stack isn't a good >>starting point. It isn't implemented as a true network stack, >>like IPV4, Appletalk, etc. Instead it's a gross input packet >>hooked packet eater thing that's an ugly wart bolted onto the >>side of the driver API. > > > Actually, this is the first time you've said anything to me about this code. > We corresponded intensely for about a week 2+ years ago after which you > declared you now knew how to "write an 802.11 stack right" and were going to > do it that weekend. I waited but it seems the sum total result was the shell > of code that Jeff referenced in a previous note. > > Perhaps you can point me at a description of what a "true network stack" means > to you. I'm guessing this has to do with your wanting queues inserted at > various places instead of direct handoffs. Regardless, I've never suggested > the current code is suitable as-is but rather should be reshaped to suit the > intended structure of the system. There is a lot of hard-earned experience > in the code that is independent of coding style and operational > infrastructure. > > Anyway, the point of my note was to correct a comment in the original posting > and make folks aware that working code existed from which they could crib > stuff. Good luck finding someone to reimplement eveything according to your > wishes. > > Sam From davem@davemloft.net Tue Sep 7 10:15:42 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 10:15:48 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87HFgjr003855 for ; Tue, 7 Sep 2004 10:15:42 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C4jUB-0001KL-00; Tue, 07 Sep 2004 10:10:27 -0700 Date: Tue, 7 Sep 2004 10:10:27 -0700 From: "David S. Miller" To: greg chesson Cc: sam@errno.com, vda@port.imtp.ilyichevsk.odessa.ua, jgarzik@pobox.com, netdev@oss.sgi.com, acx100-devel@lists.sourceforge.net, jt@bougret.hpl.hp.com, jkmaline@cc.hut.fi, prism54-devel@prism54.org Subject: Re: [RFC] acx100 inclusion in mainline; generic 802.11 stack Message-Id: <20040907101027.7547e591.davem@davemloft.net> In-Reply-To: <413DE9ED.30300@atheros.com> References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <757AB580-0030-11D9-9224-000A95AD0668@errno.com> <20040906182328.08faf843.davem@davemloft.net> <200409062132.49356.sam@errno.com> <413DE9ED.30300@atheros.com> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8463 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 1229 Lines: 32 On Tue, 07 Sep 2004 10:03:41 -0700 greg chesson wrote: > What about eth_type_trans()? It determines the protocol type from the ethernet header fields. It is a simple shorthand header field fetcher, not a protocol stack. You would need a eth80211_type_trans() for wireless drivers too, and surprise surprise my skeleton 802.11 stack code in fact does exactly this. > I've thought about this problem and don't think there is a good answer > if a layered approach to protocol implementation stipulates that each layer > be self-contained. In my 802.11 stack the 802.11 information structure can be found given a generic device pointer. All the wireless info can be retrieved from that, and you can use it to call the wireless stack routines if you wish as well. This is no different than how we keep ipv4 information hooked onto the generic device structure and walk between these various entities in the ipv4 and generic networking code. Please read my skeletal stack code, it is exactly how I truly believe something like this should be architected. It's all the base layout stuff that's important, the rest are details that will fit in cleanly and readily once you have a solid and firm foundation. From vkondra@mail.ru Tue Sep 7 10:22:47 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 10:22:52 -0700 (PDT) Received: from mx1.mail.ru (mx1.mail.ru [194.67.23.121]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87HMk1I004293 for ; Tue, 7 Sep 2004 10:22:47 -0700 Received: from [81.218.208.137] (port=11904 helo=[192.168.10.2]) by mx1.mail.ru with esmtp id 1C4jft-000E28-00; Tue, 07 Sep 2004 21:22:35 +0400 From: Vladimir Kondratiev To: "David S. Miller" Subject: generic 802.11 stack Date: Tue, 7 Sep 2004 20:22:07 +0300 User-Agent: KMail/1.7 References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <200409062132.49356.sam@errno.com> <20040906234701.511a8940.davem@davemloft.net> In-Reply-To: <20040906234701.511a8940.davem@davemloft.net> Cc: netdev@oss.sgi.com MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1168438.PPxzXlkP8u"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200409072022.14330.vkondra@mail.ru> X-Spam: Not detected X-archive-position: 8464 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: vkondra@mail.ru Precedence: bulk X-list: netdev Content-Length: 2133 Lines: 65 --nextPart1168438.PPxzXlkP8u Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dave, I'd like to evaluate possibility to use your stack for real driver. 80211 h= ave=20 some specifics thus we need to answer following questions: =2D some devices handles almost all MAC in firmware; some - handle control = frame=20 exchange in firmware, rest - on host; some use other separation of work=20 between host and firmware. So, quite flexible mechanism to specify offloadi= ng=20 of parts of .11 stack to firmware required. What is best way?=20 netdev->features? =2D there are cases when PHY information needed, to make decisions (like se= lect=20 AP from list), or for information purposes (sniffer). What is your vision h= ow=20 to do this? I.e. provide some standard PHY header before MAC header, out of= =20 band (use cb?) I see the following info that may be interesting: rate;modulation;preamble;TSF timer;RSSI;antenna;signal;noise;AGC. This list= =20 may vary from NIC to NIC. =2D there is PHY level information that may be needed for Tx: modulation;rate;retry policy and rates;Tx power;protection(RTS/CTS, CTS to= =20 self). Same question as above: how to provide it? =2D there is some interesting information that may come from Tx status, lik= e=20 success indication, last rate, retry count, energy in channel after packet,= =20 actual backoff time. =2D is it feasible to do rate scaling in generic way in stack? Or should it= be=20 done always in the driver? =2D Since WME and TGe introduction, NICs will likely to have multiple Tx qu= eues.=20 It would be wise for driver to use multiple Tx queues and start/stop them=20 separately, like have all functions netif_start_queue() etc. have additiona= l=20 parameter - queue number. Will it fit into your stack? --nextPart1168438.PPxzXlkP8u Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBBPe5Fqxdj7mhC6o0RAmd7AKCJKmxTQk6dRx2cnDaYQyiLoQ0USwCglzfj aPOJ5j1um3UnBtf1NnS8H3w= =JkZo -----END PGP SIGNATURE----- --nextPart1168438.PPxzXlkP8u-- From davem@davemloft.net Tue Sep 7 10:34:52 2004 Received: with ECARTIS (v1.0.0; list netdev); Tue, 07 Sep 2004 10:34:56 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i87HYqWP005415 for ; Tue, 7 Sep 2004 10:34:52 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C4jp5-0001Ob-00; Tue, 07 Sep 2004 10:32:03 -0700 Date: Tue, 7 Sep 2004 10:32:03 -0700 From: "David S. Miller" To: Vladimir Kondratiev Cc: netdev@oss.sgi.com Subject: Re: generic 802.11 stack Message-Id: <20040907103203.52199758.davem@davemloft.net> In-Reply-To: <200409072022.14330.vkondra@mail.ru> References: <200408312111.02438.vda@port.imtp.ilyichevsk.odessa.ua> <200409062132.49356.sam@errno.com> <20040906234701.511a8940.davem@davemloft.net> <200409072022.14330.vkondra@mail.ru> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8465 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 2532 Lines: 57 On Tue, 7 Sep 2004 20:22:07 +0300 Vladimir Kondratiev wrote: > I'd like to evaluate possibility to use your stack for real driver. 80211 have > some specifics thus we need to answer following questions: > > - some devices handles almost all MAC in firmware; some - handle control frame > exchange in firmware, rest - on host; some use other separation of work > between host and firmware. So, quite flexible mechanism to specify offloading > of parts of .11 stack to firmware required. What is best way? > netdev->features? Use function pointers for the handlers that can be overridden by the driver, or something similar like that. Start with "pure %100 software" stack, then once that is fully functional work back to add the necessary hooks to support partial software stacks. > - there are cases when PHY information needed, to make decisions (like select > AP from list), or for information purposes (sniffer). What is your vision how > to do this? I.e. provide some standard PHY header before MAC header, out of > band (use cb?) This should be stored in the 802.11 specific information struct which I allocate for each generic device which registers with the 802.11 layer. There should be a standard 802.11 stack interface the driver can use the pass the information in so that the details of the layout inside of the 802.11 device information structure need not be exported publicly. > - there is PHY level information that may be needed for Tx: > modulation;rate;retry policy and rates;Tx power;protection(RTS/CTS, CTS to > self). Same question as above: how to provide it? Same way. > - there is some interesting information that may come from Tx status, like > success indication, last rate, retry count, energy in channel after packet, > actual backoff time. Feed it back into the software stack with some kind of function call. > - is it feasible to do rate scaling in generic way in stack? Or should it be > done always in the driver? I believe so. > - Since WME and TGe introduction, NICs will likely to have multiple Tx queues. > It would be wise for driver to use multiple Tx queues and start/stop them > separately, like have all functions netif_start_queue() etc. have additional > parameter - queue number. Will it fit into your stack? We can represent this using multiple generic netdev objects, perhaps. Or we can finally start supporting multiple queues in the generic device struct. I like the latter idea better, and it allows us to do other things