Netdev List
 help / color / mirror / Atom feed
* Re: RDMA will be reverted
From: Andi Kleen @ 2006-07-04 23:01 UTC (permalink / raw)
  To: Andy Gay; +Cc: Tom Tucker, David Miller, rdreier, netdev, akpm
In-Reply-To: <1152051753.3285.600.camel@tahini.andynet.net>


> My point wasn't really about performance here, more that systems needing
> this level of performance (server farm is just an example) will probably
> be on an 'inside' network with firewalling being done elsewhere (at the
> access layer, to use the Cisco paradigm). It's just not good design to
> attach such systems directly to an untrusted network, IMHO. So these
> systems just don't need netfilter capabilities.

Don't think of the highend. It is exotic and rare.

Think of the ordinary single linux box somewhere at a rackspace provider which 
represents the majority of Linux boxes around. 

With a not too skilled admin who mostly uses the default settings of his configuration.
For that running firewalling on the same box makes a lot of sense.

Normally it is not that loaded and it doesn't matter much how it performs,
but it might be occasionally slashdotted and then it should still hold up.

BTW basic firewalling is not really that bad as long as you don't have too many
rules. Mostly conntrack is painful right now. I'm sure at some point it will
be fixed too.

-Andi

^ permalink raw reply

* Re: [PATCH 1/3] [PKT_SCHED]: Fix illegal memory dereferences when dumping actions
From: Patrick McHardy @ 2006-07-04 23:42 UTC (permalink / raw)
  To: Thomas Graf; +Cc: davem, netdev, hadi
In-Reply-To: <20060704220549.952720000@postel.suug.ch>

Thomas Graf wrote:
> The TCA_ACT_KIND attribute is used without checking its
> availability when dumping actions therefore leading to a
> value of 0x4 being dereferenced.
> 
> The use of strcmp() in tc_lookup_action_n() isn't safe
> when fed with string from an attribute without enforcing
> proper NUL termination.
> 
> Both bugs can be triggered with malformed netlink message
> and don't require any privileges.
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> 
> Index: net-2.6.git/net/sched/act_api.c
> ===================================================================
> --- net-2.6.git.orig/net/sched/act_api.c
> +++ net-2.6.git/net/sched/act_api.c
> @@ -776,7 +776,7 @@ replay:
>  	return ret;
>  }
>  
> -static char *
> +static struct rtattr *
>  find_dump_kind(struct nlmsghdr *n)
>  {
>  	struct rtattr *tb1, *tb2[TCA_ACT_MAX+1];
> @@ -804,7 +804,7 @@ find_dump_kind(struct nlmsghdr *n)
>  		return NULL;
>  	kind = tb2[TCA_ACT_KIND-1];
>  
> -	return (char *) RTA_DATA(kind);
> +	return kind;
>  }
>  
>  static int
> @@ -817,16 +817,15 @@ tc_dump_action(struct sk_buff *skb, stru
>  	struct tc_action a;
>  	int ret = 0;
>  	struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh);
> -	char *kind = find_dump_kind(cb->nlh);
> +	struct rtattr *kind = find_dump_kind(cb->nlh);
>  
>  	if (kind == NULL) {
>  		printk("tc_dump_action: action bad kind\n");
>  		return 0;
>  	}
>  
> -	a_o = tc_lookup_action_n(kind);
> +	a_o = tc_lookup_action(kind);
>  	if (a_o == NULL) {
> -		printk("failed to find %s\n", kind);
>  		return 0;
>  	}
>  
> @@ -834,7 +833,7 @@ tc_dump_action(struct sk_buff *skb, stru
>  	a.ops = a_o;
>  
>  	if (a_o->walk == NULL) {
> -		printk("tc_dump_action: %s !capable of dumping table\n", kind);
> +		printk("tc_dump_action: %s !capable of dumping table\n", a_o->kind);
>  		goto rtattr_failure;
>  	}

Can't we just get rid of these printks? This seems like a good
opportunity.


^ permalink raw reply

* Re: RDMA will be reverted
From: Andy Gay @ 2006-07-04 23:48 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Tom Tucker, David Miller, rdreier, netdev, akpm
In-Reply-To: <200607050101.12476.ak@suse.de>

On Wed, 2006-07-05 at 01:01 +0200, Andi Kleen wrote:
> > My point wasn't really about performance here, more that systems needing
> > this level of performance (server farm is just an example) will probably
> > be on an 'inside' network with firewalling being done elsewhere (at the
> > access layer, to use the Cisco paradigm). It's just not good design to
> > attach such systems directly to an untrusted network, IMHO. So these
> > systems just don't need netfilter capabilities.
> 
> Don't think of the highend. It is exotic and rare.
Sure. But isn't the high end exactly where these new technologies are
intended to fit?

> 
> Think of the ordinary single linux box somewhere at a rackspace provider which 
> represents the majority of Linux boxes around. 
How many of those need 10G nics?

> 
> With a not too skilled admin who mostly uses the default settings of his configuration.
> For that running firewalling on the same box makes a lot of sense.
Yup. I run a few of those. And I run firewalls on them. But they're on
1.5M T1 pipes at best.
I probably fit into your 'not too skilled' category, too :) 

> 
> Normally it is not that loaded and it doesn't matter much how it performs,
> but it might be occasionally slashdotted and then it should still hold up.
> 
> BTW basic firewalling is not really that bad as long as you don't have too many
> rules. Mostly conntrack is painful right now. I'm sure at some point it will
> be fixed too.
Actually, I wasn't aware of any pain with conntrack, it works great for
me. But like I said, I don't run any real high speed connections.

We're focusing on netfilter here. Is breaking netfilter really the only
issue with this stuff? I know you mentioned some other concerns (about
TOE specifically), they were really scalability things though weren't
they - like you're not convinced this really solves any performance
issues long term. I'm certainly not qualified to discuss that, hopefully
some of the others will weigh in here.

> 
> -Andi
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply

* Re: [PATCH 0/2] NET: Accurate packet scheduling for ATM/ADSL
From: Patrick McHardy @ 2006-07-04 23:53 UTC (permalink / raw)
  To: hadi
  Cc: Jesper Dangaard Brouer, netdev, Stephen Hemminger, Alan Cox,
	Russell Stuart, Russell Stuart
In-Reply-To: <1152041373.5276.36.camel@jzny2>

jamal wrote:
> On Tue, 2006-04-07 at 15:29 +0200, Patrick McHardy wrote:
> 
>>Russell Stuart wrote:
> 
> [..]
> 
>>>Without seeing your actual proposal it is difficult to
>>>judge whether this is a reasonable trade-off or not.
>>>Hopefully we will see your code soon.  Do you have any
>>>idea when?
>>
>>Unfortunately I still didn't got to cleaning them up, so I'm sending
>>them in their preliminary state. Its not much that is missing, but
>>the netem usage of skb->cb needs to be integrated better, I failed
>>to move it to the qdisc_skb_cb so far because of circular includes.
>>But nothing unfixable. I'm mostly interested if the current size-tables
>>can express what you need for ATM, I wasn't able to understand the
>>big comment in tc_core.c in your patch.
>>
> 
> 
> Looks good from within the range of "change within reason" of addressed
> problem. The cb on the qdisc seems only usable for netem, correct?

Yes, it has the same limitations as current netem cb usage. Really
makeing it useable for all qdiscs would require reserving a few bytes
for every level, so far that isn't necessary and I would prefer to
just add a time_to_send field for netem. The problem with this is
that it currently requires sch_generic.h and pkt_sched.h to include
one another, so I did the qdisc_skb_cb() thing to at least get it to
compile for now.

> Also while not unreasonable, i wasnt sure how qdisc_enqueue_root()
> fit in the grand scheme of things for this change (it seemed out of
> place).

Its there as a spot to do the initial time calculations and store them
in the cb. I didn't want to put this in net/core/dev.c.


^ permalink raw reply

* Re: RDMA will be reverted
From: Andi Kleen @ 2006-07-05  0:04 UTC (permalink / raw)
  To: Andy Gay; +Cc: Tom Tucker, David Miller, rdreier, netdev, akpm
In-Reply-To: <1152056909.3285.617.camel@tahini.andynet.net>


> > Think of the ordinary single linux box somewhere at a rackspace provider which 
> > represents the majority of Linux boxes around. 
> How many of those need 10G nics?

Most of them already have gigabit. At some point they will have 10G too.

Admittedly the iThingy under discussion here seems to be Infiniband only which
will probably not appear in such a use case.

> We're focusing on netfilter here. Is breaking netfilter really the only
> issue with this stuff?

Another concern is that it will just not be able to keep 
up with a high rate of new connections or a high number of them
(because the hardware has too limited state)

And then there are the other issues I listed like subtle TCP bugs
(TSO is already a nightmare in this area and it's still not quite
right) etc. 

> I know you mentioned some other concerns (about 
> TOE specifically), they were really scalability things though weren't
> they 

There was more than just scalability. Reread it.

Anyways the thread is already getting off topic - i'm not actually
that much interested in a generic TOE discussion because the issue
is pretty much settled already with broad consensus. You can refer
to the netdev archives or the respective web pages if you want more
details.

It would need someone who can describe how this new RDMA device avoids
all the problems, but so far its advocates don't seem to be interested
in doing that and I cannot contribute more.

-Andi

^ permalink raw reply

* possible dos / wsize affected frozen connection length (was: Re: 2.6.17.1: fails to fully get webpage)
From: CaT @ 2006-07-05  0:55 UTC (permalink / raw)
  To: linux-kernel, netdev
In-Reply-To: <20060629225039.GO2149@zip.com.au>

On Fri, Jun 30, 2006 at 08:50:39AM +1000, CaT wrote:
> Another datapoint to this is that I've had this my netcat web test
> running since 8:42pm yesterday. It's 8:37am now. It hasn't progressed
> in any way. It hasn't quit. It hasn't timed out. It just sits there,
> hung. This leads me to consider the possibility of a DOS, either
> intentional or accidental (think about 2.6.17.x running on a mail server
> and someone mails/spams from a broken place).

I'm just wondering if connections hanging around this long are normal.
The above has now been running for 6 days. netstat is still reporting an
established session. netcat has not timed out. It's all just sitting
there doing nothing.

-- 
    "To the extent that we overreact, we proffer the terrorists the
    greatest tribute."
    	- High Court Judge Michael Kirby

^ permalink raw reply

* Re: [PATCH 1/3] [PKT_SCHED]: Fix illegal memory dereferences when dumping actions
From: jamal @ 2006-07-05  1:34 UTC (permalink / raw)
  To: Thomas Graf; +Cc: netdev, davem
In-Reply-To: <20060704220549.952720000@postel.suug.ch>

On Wed, 2006-05-07 at 00:00 +0200, Thomas Graf wrote:
> plain text document attachment (act_fix_dump_null_deref)
> The TCA_ACT_KIND attribute is used without checking its
> availability when dumping actions therefore leading to a
> value of 0x4 being dereferenced.
> 
> The use of strcmp() in tc_lookup_action_n() isn't safe
> when fed with string from an attribute without enforcing
> proper NUL termination.
> 
> Both bugs can be triggered with malformed netlink message
> and don't require any privileges.
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> 

Good catch.

Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>


cheers,
jamal


^ permalink raw reply

* Re: [PATCH 2/3] [PKT_SCHED]: Return ENOENT if action module is unavailable
From: jamal @ 2006-07-05  1:40 UTC (permalink / raw)
  To: Thomas Graf; +Cc: netdev, davem
In-Reply-To: <20060704220550.113899000@postel.suug.ch>

On Wed, 2006-05-07 at 00:00 +0200, Thomas Graf wrote:
> plain text document attachment (act_fix_init_ret_val)
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> 
> Index: net-2.6.git/net/sched/act_api.c
> ===================================================================
> --- net-2.6.git.orig/net/sched/act_api.c
> +++ net-2.6.git/net/sched/act_api.c
> @@ -305,6 +305,7 @@ struct tc_action *tcf_action_init_1(stru
>  			goto err_mod;
>  		}
>  #endif
> +		*err = -ENOENT;
>  		goto err_out;
>  	}
>  

Ok, this falls under the LinuxWay(tm). Quick inspection of the qdisc
code reveals the same bug. The cls side seems fine - but i didnt spend
more than 30 secs. So why dont you fix the qdisc one while you are at
it?

Acked-by: Jamal Hadi Salim <hadi@cyberus.ca>


^ permalink raw reply

* Re: [PATCH 3/3] [PKT_SCHED]: Fix error handling while dumping actions
From: jamal @ 2006-07-05  1:47 UTC (permalink / raw)
  To: Thomas Graf; +Cc: netdev, davem
In-Reply-To: <20060704220550.406275000@postel.suug.ch>


I need to stare at this one for longer than 1 minute and i dont have
time right now; it does look strange (I am unsure what my thoughts were
at that point with -err - or maybe that was a change made by someone
else). 
I dont have time until tommorow - but i would  think the better fix will
be to change "return -err" to  "return -1"?

cheers,
jamal 

On Wed, 2006-05-07 at 00:00 +0200, Thomas Graf wrote:
> plain text document attachment (act_fix_dump_err_handling)
> "return -err" and blindly inheriting the error code in the netlink
> failure exception handler causes errors codes to be returned as
> positive value therefore making them being ignored by the caller.
> 
> May lead to sending out incomplete netlink messages.
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> 
> 
> Index: net-2.6.git/net/sched/act_api.c
> ===================================================================
> --- net-2.6.git.orig/net/sched/act_api.c
> +++ net-2.6.git/net/sched/act_api.c
> @@ -250,15 +250,17 @@ tcf_action_dump(struct sk_buff *skb, str
>  		RTA_PUT(skb, a->order, 0, NULL);
>  		err = tcf_action_dump_1(skb, a, bind, ref);
>  		if (err < 0)
> -			goto rtattr_failure;
> +			goto errout;
>  		r->rta_len = skb->tail - (u8*)r;
>  	}
>  
>  	return 0;
>  
>  rtattr_failure:
> +	err = -EINVAL;
> +errout:
>  	skb_trim(skb, b - skb->data);
> -	return -err;
> +	return err;
>  }
>  
>  struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
> 
> --
> 
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply

* Re: [PATCH 1/3] [PKT_SCHED]: Fix illegal memory dereferences when dumping actions
From: jamal @ 2006-07-05  1:49 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netdev, davem, Thomas Graf
In-Reply-To: <44AAFCF6.9000706@trash.net>

On Wed, 2006-05-07 at 01:42 +0200, Patrick McHardy wrote:
> Thomas Graf wrote:
> >  	if (a_o->walk == NULL) {
> > -		printk("tc_dump_action: %s !capable of dumping table\n", kind);
> > +		printk("tc_dump_action: %s !capable of dumping table\n", a_o->kind);
> >  		goto rtattr_failure;
> >  	}
> 
> Can't we just get rid of these printks? This seems like a good
> opportunity.
> 

perhaps convert to DPRINTKs instead

cheers,
jamal



^ permalink raw reply

* Hottest Deal out there (a JOB)
From: Angelique @ 2006-07-05  6:07 UTC (permalink / raw)
  To: netdev

Hola!.

Este correo electrónico le muestra una oferta de trabajo, que podría ser interesante a usted.

Gerente financiero situado en su país! Trabajo en Internet con buen sueldo!
GoldLeader Inc. busca a personas enérgicas y responsables para completar el
puesto de encargado de deudores de media jornada.
Como encargado de deudores, usted será el responsable de procesar y facilitar
las transferencias de fondos iniciadas por nuestros clientes bajo la supervisión del gerente regional.

 Ofrecemos:

- Ventajas buenas (más de 1000 $ por semana);

- Contrato legal;

 Se precisa puntualidad, capacidades directivas y responsabilidad.

Usted también recibirá instrucciones detalladas para acciones
subsecuentes de nuestro gerente, con información sobre como recibir/transferir el dinero.

 
1. Ser capaz de comprobar su correo electrónico varias veces por día

2. Ser capaz de responder a correos electrónico inmediatamente

3. Ser capaz de trabajar horas extra si es necesario

4. Ser responsable y trabajador

5. Hablar ingles

6. Tener más de 21 años;

7. Debería tener una cuenta bancaria personal

Para información adicionales y preguntas sobre el puesto de trabajo,
por favor envíe sus datos de contacto a  career@goldleader.biz

NO SON VENTAS!!! NO SON LLAMADAS!!!
USTED NO NECESITA DINERO PARA COMENZAR!!!
 
Gracias por su atencion.
Con respeto,
Departamento de personal Goldleader Inc.
http://www.goldleader.biz


^ permalink raw reply

* Re: [patch 1/7] net_device list cleanup: core
From: Andrey Savochkin @ 2006-07-05  8:26 UTC (permalink / raw)
  To: Alexey Kuznetsov
  Cc: Christoph Hellwig, netdev, Kirill Korotaev, Eric W. Biederman
In-Reply-To: <20060704163537.GA10990@ms2.inr.ac.ru>

On Tue, Jul 04, 2006 at 08:35:37PM +0400, A.N.Kuznetsov wrote:
> 
> > Different modules want different kinds of lookup.
> > So, I'm thinking about something like ilookup5.
> ....
> > The next question: would people agree to review a patch doing this for
> > net_devices? :)
> 
> One not original suggestion, which did not sound nevertheless:
> to implement netdev_iterate_list() or whatever, update only core
> and a few of devices and deprecate dev_base_head
> with __deprecated_for_modules adding it to
> Documentation/feature-removal-schedule.txt

I like this idea

	Andrey

^ permalink raw reply

* Re: [PATCH 1/3] [PKT_SCHED]: Fix illegal memory dereferences when dumping actions
From: Thomas Graf @ 2006-07-05  9:09 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev, hadi
In-Reply-To: <44AAFCF6.9000706@trash.net>

* Patrick McHardy <kaber@trash.net> 2006-07-05 01:42
> Thomas Graf wrote:
> > @@ -834,7 +833,7 @@ tc_dump_action(struct sk_buff *skb, stru
> >  	a.ops = a_o;
> >  
> >  	if (a_o->walk == NULL) {
> > -		printk("tc_dump_action: %s !capable of dumping table\n", kind);
> > +		printk("tc_dump_action: %s !capable of dumping table\n", a_o->kind);
> >  		goto rtattr_failure;
> >  	}
> 
> Can't we just get rid of these printks? This seems like a good
> opportunity.

I agree, since this patch is definitely a stable candidate I
wanted it to stay as small as possible.

^ permalink raw reply

* [PATCH] SNMPv2 tcpAttemptFails counter error
From: Wei Yongjun @ 2006-07-05  9:19 UTC (permalink / raw)
  To: netdev

Refer to RFC2012, tcpAttemptFails is defined as following:
  tcpAttemptFails OBJECT-TYPE
      SYNTAX      Counter32
      MAX-ACCESS  read-only
      STATUS      current
      DESCRIPTION
              "The number of times TCP connections have made a direct
              transition to the CLOSED state from either the SYN-SENT
              state or the SYN-RCVD state, plus the number of times TCP
              connections have made a direct transition to the LISTEN
              state from the SYN-RCVD state."
      ::= { tcp 7 }

When I lookup into RFC793, I found that the state change should occured
under following condition:
  1. SYN-SENT -> CLOSED
     a) Received ACK,RST segment when SYN-SENT state.

  2. SYN-RCVD -> CLOSED
     b) Received SYN segment when SYN-RCVD state(came from LISTEN).
     c) Received RST segment when SYN-RCVD state(came from SYN-SENT).
     d) Received SYN segment when SYN-RCVD state(came from SYN-SENT).

  3. SYN-RCVD -> LISTEN
     e) Received RST segment when SYN-RCVD state(came from LISTEN).

In my test, those direct state transition can not be counted to
tcpAttemptFails. Following is my patch:

Signed-off-by: Wei Yongjun <yjwei@nanjing-fnst.com>

--- a/net/ipv4/tcp_input.c	2006-06-30 13:37:38.000000000 -0400
+++ b/net/ipv4/tcp_input.c	2006-07-05 04:45:04.000000000 -0400
@@ -4089,6 +4089,7 @@ static int tcp_rcv_synsent_state_process
 		 */
 
 		if (th->rst) {
+			TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
 			tcp_reset(sk);
 			goto discard;
 		}
@@ -4377,6 +4378,8 @@ int tcp_rcv_state_process(struct sock *s
 
 	/* step 2: check RST bit */
 	if(th->rst) {
+		if(sk->sk_state == TCP_SYN_RECV)
+			TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
 		tcp_reset(sk);
 		goto discard;
 	}
@@ -4390,6 +4393,8 @@ int tcp_rcv_state_process(struct sock *s
 	 *	Check for a SYN in window.
 	 */
 	if (th->syn && !before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
+		if(sk->sk_state == TCP_SYN_RECV)
+			TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
 		NET_INC_STATS_BH(LINUX_MIB_TCPABORTONSYN);
 		tcp_reset(sk);
 		return 1;
--- a/net/ipv4/tcp_minisocks.c	2006-06-30 13:37:38.000000000 -0400
+++ b/net/ipv4/tcp_minisocks.c	2006-07-05 04:45:04.000000000 -0400
@@ -592,8 +592,10 @@ struct sock *tcp_check_req(struct sock *
 		/* RFC793: "second check the RST bit" and
 		 *	   "fourth, check the SYN bit"
 		 */
-		if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN))
+		if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN)) {
+			TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS);
 			goto embryonic_reset;
+		}
 
 		/* ACK sequence verified above, just make sure ACK is
 		 * set.  If ACK not set, just silently drop the packet.





^ permalink raw reply

* Re[3]:hello from Galina S.
From: Galya @ 2006-07-05  9:40 UTC (permalink / raw)
  To: netdev

Hello…	

I want to start my first letter from a question: "Is it possible to be happy without LOVE?"
I think that you will agree with me if the answer will be "NO WAY". Love is the most beautiful and exciting thing
that may happen between man and woman! It inspires us only for doing positive things towards each other.
One very famous writer said: "The beauty will rescue the world" i agree with his words but still i would add :
" LOVE and Beauty will rescure the world". 
I hope you agree with me that Love is a big notion.
There's love to  God, to Mother, to a child to the country where you were born, and there's love that joins a man
and woman for all their life. That is the LOVE i'm looking for! And i'm seeking for the man who is also eager to have
this life long adventure full of surprises and new experience we can share together! Will you join me for this trip?
I do realise that it should be very difficult to say "Yes" from the first letter having no idea about me.
That's why i just offer to get to know each other better though correspondence that will help us to reveal many things
about each other whether we mach perfectly or not. In addition you can look at my pictures and read some info about me here
http://foryou-mydestiny.com/
I hope you'll like what you see and read there.
Well closing my first letter to you i just want to thank you for reading it and i really hope that you'll share
my point of view on what i said above. I do really hope that you'll answer me soon.

a rivederci,

Galya



^ permalink raw reply

* Re: 2.6.17-mm6
From: Stefan Richter @ 2006-07-05 10:27 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: netdev, Rafael J. Wysocki, Andrew Morton, linux-kernel,
	Ingo Molnar
In-Reply-To: <1152043271.3109.95.camel@laptopd505.fenrus.org>

On 7/4/2006 10:01 PM, Arjan van de Ven wrote:
> this is one for the networking people, and thus netdev

It's actually ieee1394 using net infrastructure for purposes which ar
unrelated to networking.

Furthermore...

> On Tue, 2006-07-04 at 21:53 +0200, Rafael J. Wysocki wrote:
>> On Monday 03 July 2006 12:03, Andrew Morton wrote:
>> > ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.17/2.6.17-mm6/
>> > 
>> > - A major update to the e1000 driver.
>> > - 1394 updates

...I believe it is unrelated to the 1394 updates new to -mm6.

>> Just found this in dmesg:
>> 
>> =================================
>> [ INFO: inconsistent lock state ]
>> ---------------------------------
>> inconsistent {in-hardirq-W} -> {hardirq-on-W} usage.
>> nscd/4929 [HC0[0]:SC0[1]:HE1:SE0] takes:
>>  (&skb_queue_lock_key){++..}, at: [<ffffffff8044fe40>] udp_ioctl+0x50/0xa0
>> {in-hardirq-W} state was registered at:
>>   [<ffffffff8024b4fa>] lock_acquire+0x8a/0xc0
>>   [<ffffffff80476e3f>] _spin_lock_irqsave+0x3f/0x60
>>   [<ffffffff80408c25>] skb_queue_tail+0x25/0x60
> 
> ok so skb_queue_lock is used in a hardirq context
> 
>>   [<ffffffff881c9517>] queue_packet_complete+0x27/0x40 [ieee1394]
>>   [<ffffffff881c9d6b>] hpsb_packet_sent+0xab/0x100 [ieee1394]
>>   [<ffffffff8822a4b5>] dma_trm_reset+0x115/0x140 [ohci1394]
>>   [<ffffffff8822c512>] ohci_devctl+0x1c2/0x540 [ohci1394]
>>   [<ffffffff881c9673>] hpsb_bus_reset+0x43/0xb0 [ieee1394]
>>   [<ffffffff8822d7f6>] ohci_irq_handler+0x416/0x830 [ohci1394]
>>   [<ffffffff802631ab>] handle_IRQ_event+0x2b/0x70
>>   [<ffffffff80264dd4>] handle_level_irq+0xc4/0x130
>>   [<ffffffff8020c762>] do_IRQ+0x112/0x130
>>   [<ffffffff80209d90>] common_interrupt+0x64/0x65
>> irq event stamp: 4280
>> hardirqs last  enabled at (4279): [<ffffffff8047606a>] trace_hardirqs_on_thunk+0x35/0x37
>> hardirqs last disabled at (4278): [<ffffffff804760a1>] trace_hardirqs_off_thunk+0x35/0x67
>> softirqs last  enabled at (4258): [<ffffffff804065b5>] release_sock+0xd5/0xe0
>> softirqs last disabled at (4280): [<ffffffff804764d1>] _spin_lock_bh+0x11/0x50
>> 
>> other info that might help us debug this:
>> no locks held by nscd/4929.
>> 
>> stack backtrace:
>> 
>> Call Trace:
>>  [<ffffffff8020ab9f>] show_trace+0x9f/0x240
>>  [<ffffffff8020af75>] dump_stack+0x15/0x20
>>  [<ffffffff80249e52>] print_usage_bug+0x272/0x290
>>  [<ffffffff8024a0d7>] mark_lock+0x267/0x5f0
>>  [<ffffffff8024a9a6>] __lock_acquire+0x546/0xd10
>>  [<ffffffff8024b4fb>] lock_acquire+0x8b/0xc0
>>  [<ffffffff804764f4>] _spin_lock_bh+0x34/0x50
>>  [<ffffffff8044fe40>] udp_ioctl+0x50/0xa0
> 
> yet udp_ioctl takes it only for _bh
> 
>>  [<ffffffff80457359>] inet_ioctl+0x69/0x70
>>  [<ffffffff804033ac>] sock_ioctl+0x22c/0x270
>>  [<ffffffff802a32b1>] do_ioctl+0x31/0xa0
>>  [<ffffffff802a35db>] vfs_ioctl+0x2bb/0x2e0
>>  [<ffffffff802a366a>] sys_ioctl+0x6a/0xa0
>>  [<ffffffff8020985a>] system_call+0x7e/0x83
>>  [<00002b2d76ab98a9>]
> 
> is this a real scenario, or is this a case of "firewire is special and
> needs it's own rules"?

Well, firewire is special, but that should already be addressed by this
patch: "lockdep: annotate ieee1394 skb-queue-head locking"
http://kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff_plain;h=d378834840907326ac9d448056d957d13cc3718f

Why is there still a lockdep warning?

(Ieee1394 core's usage of the skb_* API is entirely unrelated to
networking; even if eth1394 was used.)
-- 
Stefan Richter
-=====-=-==- -=== --=-=
http://arcgraph.de/sr/

^ permalink raw reply

* Re: 2.6.17-mm6
From: Stefan Richter @ 2006-07-05 10:36 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: netdev, Rafael J. Wysocki, Andrew Morton, linux-kernel,
	Ingo Molnar
In-Reply-To: <44AB940F.7000801@s5r6.in-berlin.de>

I wrote:
> (Ieee1394 core's usage of the skb_* API is entirely unrelated to
> networking; even if eth1394 was used.)

PS:
I wonder if it wouldn't be better to migrate ieee1394 core away from
skb_*. I didn't look thoroughly at it yet but the benefit of using this
API appears quite low to me.

We use it to keep track of IEEE 1394 transactions [ = outgoing request
&& (incoming response || expiry)], with completion of transactions often
in-order due to mostly single-threaded usage, but sometimes out-of-order
(may happen regardless of multithreaded or single-threaded usage).
-- 
Stefan Richter
-=====-=-==- -=== --=-=
http://arcgraph.de/sr/

^ permalink raw reply

* Re: possible recursive locking in ATM layer
From: Duncan Sands @ 2006-07-05 10:23 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: netdev, linux-kernel, Ingo Molnar, chas
In-Reply-To: <1152029582.3109.70.camel@laptopd505.fenrus.org>

> ok this is a real potential deadlock in a way, it takes two locks of 2
> skbuffs without doing any kind of lock ordering; I think the following
> patch should fix it. Just sort the lock taking order by address of the
> skb.. it's not pretty but it's the best this can do in a minimally
> invasive way.

The patch is effective.  Thanks for making it!

Best wishes,

Duncan.

^ permalink raw reply

* Re: 2.6.17-mm6
From: Ingo Molnar @ 2006-07-05 11:13 UTC (permalink / raw)
  To: Stefan Richter
  Cc: Arjan van de Ven, netdev, Rafael J. Wysocki, Andrew Morton,
	linux-kernel
In-Reply-To: <44AB9633.9090208@s5r6.in-berlin.de>


* Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:

> I wrote:
> > (Ieee1394 core's usage of the skb_* API is entirely unrelated to
> > networking; even if eth1394 was used.)
> 
> PS:
> I wonder if it wouldn't be better to migrate ieee1394 core away from 
> skb_*. I didn't look thoroughly at it yet but the benefit of using 
> this API appears quite low to me.

yeah, it seems to be the wrong abstraction to use. It's also more 
expensive than necessary: e.g. skb-heads have a qlen field that is 
maintained in every list op - but the ieee1394 code does not make use of 
the queue-length information. Using list.h plus a spinlock should do the 
trick?

	Ingo

^ permalink raw reply

* Re: sky2 rx error problems...
From: Daniel J Blueman @ 2006-07-05 11:44 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Netfilter Developer, netdev
In-Reply-To: <20060530161714.4420e9b4@dxpl.pdx.osdl.net>

Hi Stephen,

Sorry to bring you more trouble. I'm able to reproduce this 'status
0x977d977d' rx race even with a 100Mb FD connection (MTU 1500) to the
host sending the data.

Would it help if I try and capture some packet stats or a dump of
this? The packets being received at the sending host will be a steady
stream of TCP acks and SMB protocol acks (every 64KB of data), so not
too heavy. The sending host has a Pentium-M 1.7GHz with 2MB L2$ and is
quiescent apart from samba sending data via sendfile(), so is
relatively powerful.

Let me know if there is anything I can do to help.

Many thanks,
  Daniel

On 31/05/06, Stephen Hemminger <shemminger@osdl.org> wrote:
> On Tue, 30 May 2006 22:08:12 +0100
> "Daniel J Blueman" <daniel.blueman@gmail.com> wrote:
>
> > To follow on from the previous 'sky2 rx error' problem reported, the
> > problem doesn't have anything to do with iptables or MTU settings, ie
> > can be reproduced out the box.
> >
> > The race is hit after a couple of GBs of data. Initially, I thought
> > this may have something to do with broken MSI support on my Intel
> > ICH-7M chipset, but disabling MSI didn't help.
> >
> > kernel: sky2 lan0: rx error, status 0x977d977d length 0
> >
> > Is there any debug information I can get to help or such? Voluntary
> > preemption is enabled, UP, HZ=100 on 2.6.17-rc4 on i686.
> >
> > Dan
>
> No the problem is your CPU isn't keeping up with the incoming flood
> and what ever you are connected to doesn't do hardware flow control.
> The driver doesn't properly flush the FIFO (yet), and it is not clear
> even from the NDA documentation the steps required.
-- 
Daniel J Blueman

^ permalink raw reply

* Re: possible dos / wsize affected frozen connection length (was: Re: 2.6.17.1: fails to fully get webpage)
From: linux-os (Dick Johnson) @ 2006-07-05 11:54 UTC (permalink / raw)
  To: CaT; +Cc: linux-kernel, netdev
In-Reply-To: <20060705005540.GL2344@zip.com.au>


On Tue, 4 Jul 2006, CaT wrote:

> On Fri, Jun 30, 2006 at 08:50:39AM +1000, CaT wrote:
>> Another datapoint to this is that I've had this my netcat web test
>> running since 8:42pm yesterday. It's 8:37am now. It hasn't progressed
>> in any way. It hasn't quit. It hasn't timed out. It just sits there,
>> hung. This leads me to consider the possibility of a DOS, either
>> intentional or accidental (think about 2.6.17.x running on a mail server
>> and someone mails/spams from a broken place).
>
> I'm just wondering if connections hanging around this long are normal.
> The above has now been running for 6 days. netstat is still reporting an
> established session. netcat has not timed out. It's all just sitting
> there doing nothing.
>
> --

>    "To the extent that we overreact, we proffer the terrorists the
>    greatest tribute."
>    	- High Court Judge Michael Kirby

TCP/IP connections can continue forever. That's one of the reasons why
Berkeley sockets has SO_KEEPALIVE for a socket option. In the absence
of such an option, the physical connection can be broken for a week,
reconnected, then the session can continue.

In your case, you probably have a real error in which one end of the
connection crashed. However, until the other end shuts down that
socket, the connection is logically correct and should not be
forcefully terminated.

A DOS is unlikely because with no data being transferred, little
non-swapable resources are used. You can control the maximum number
of connections allowed from a host with your firewall software
(like iptables).

Cheers,
Dick Johnson
Penguin : Linux version 2.6.16.4 on an i686 machine (5592.86 BogoMips).
New book: http://www.AbominableFirebug.com/
_
\x1a\x04

****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

^ permalink raw reply

* [PATCH 2.6.17 0/9] NetXen: ethernet nic driver
From: Linsys Contractor Amit S. Kale @ 2006-07-05 13:15 UTC (permalink / raw)
  To: netdev; +Cc: jeff, sanjeev, unmproj

Hi,

I'll be sending a NetXen 1G/10G ethernet driver patch in subsequent 
emails. We have made changes as per the feedback received. We would like 
this driver to be included in mainline kernel.

Kindly review it and feel free to send feedback.

Thanks,
-Amit

Signed-off-by: Amit S. Kale <amitkale@unminc.com>

  Kconfig                      |    5
  Makefile                     |    1
  netxen/Makefile              |   35 +
  netxen/netxen_nic.h          |  998 ++++++++++++++++++++++++++++++++
  netxen/netxen_nic_ethtool.c  |  707 +++++++++++++++++++++++
  netxen/netxen_nic_hdr.h      |  684 ++++++++++++++++++++++
  netxen/netxen_nic_hw.c       | 1308 +++++++++++++++++++++++++++++++++++++++++++
  netxen/netxen_nic_hw.h       |  346 +++++++++++
  netxen/netxen_nic_init.c     | 1263 +++++++++++++++++++++++++++++++++++++++++
  netxen/netxen_nic_ioctl.h    |   75 ++
  netxen/netxen_nic_isr.c      |  430 ++++++++++++++
  netxen/netxen_nic_main.c     | 1228 ++++++++++++++++++++++++++++++++++++++++
  netxen/netxen_nic_niu.c      |  761 +++++++++++++++++++++++++
  netxen/netxen_nic_phan_reg.h |  293 +++++++++
  14 files changed, 8134 insertions(+)

^ permalink raw reply

* [PATCH 2.6.17 1/9] NetXen: Makefile and ethtool interface
From: Linsys Contractor Amit S. Kale @ 2006-07-05 13:20 UTC (permalink / raw)
  To: netdev; +Cc: jeff, sanjeev, unmproj
In-Reply-To: <Pine.LNX.4.64.0607050602310.27969@dut46>

diff -Naru linux-2.6.17.orig/drivers/net/Kconfig linux-2.6.17/drivers/net/Kconfig
--- linux-2.6.17.orig/drivers/net/Kconfig	2006-07-05 01:15:38.740111318 -0700
+++ linux-2.6.17/drivers/net/Kconfig	2006-07-05 01:18:13.066500584 -0700
@@ -2311,6 +2311,11 @@

  	  If in doubt, say N.

+config NETXEN_NIC
+	tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC"
+	help
+	  This enables the support for NetXen's Gigabit Ethernet card.
+
  endmenu

  source "drivers/net/tokenring/Kconfig"
diff -Naru linux-2.6.17.orig/drivers/net/Makefile linux-2.6.17/drivers/net/Makefile
--- linux-2.6.17.orig/drivers/net/Makefile	2006-07-05 01:15:39.197017758 -0700
+++ linux-2.6.17/drivers/net/Makefile	2006-07-05 01:18:40.408898046 -0700
@@ -213,3 +213,4 @@

  obj-$(CONFIG_FS_ENET) += fs_enet/

+obj-$(CONFIG_NETXEN_NIC) += netxen/
diff -Naru linux-2.6.17.orig/drivers/net/netxen/Makefile linux-2.6.17/drivers/net/netxen/Makefile
--- linux-2.6.17.orig/drivers/net/netxen/Makefile	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.17/drivers/net/netxen/Makefile	2006-07-05 01:18:40.410897637 -0700
@@ -0,0 +1,35 @@
+# Copyright (C) 2003 - 2006 NetXen, Inc.
+# All rights reserved.
+# 
+# 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
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA  02111-1307, USA.
+# 
+# The full GNU General Public License is included in this distribution
+# in the file called LICENSE.
+# 
+# Contact Information:
+#    info@netxen.com
+# NetXen,
+# 3965 Freedom Circle, Fourth floor,
+# Santa Clara, CA 95054
+#
+# Makefile for the NetXen NIC Driver
+#
+
+
+obj-$(CONFIG_NETXEN_NIC) := netxen_nic.o
+
+netxen_nic-y := netxen_nic_hw.o netxen_nic_main.o netxen_nic_init.o \
+	netxen_nic_isr.o netxen_nic_ethtool.o netxen_nic_niu.o
diff -Naru linux-2.6.17.orig/drivers/net/netxen/netxen_nic_ethtool.c linux-2.6.17/drivers/net/netxen/netxen_nic_ethtool.c
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_ethtool.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_ethtool.c	2006-07-05 01:18:40.363907266 -0700
@@ -0,0 +1,707 @@
+/*
+ * Copyright (C) 2003 - 2006 NetXen, Inc.
+ * All rights reserved.
+ * 
+ * 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
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.
+ * 
+ * Contact Information:
+ *    info@netxen.com
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ *
+ *
+ * ethtool support for netxen nic
+ *
+ */
+
+#include <linux/types.h>
+#include <asm/uaccess.h>
+#include <linux/pci.h>
+#include <asm/io.h>
+#include <linux/netdevice.h>
+#include <linux/ethtool.h>
+#include <linux/version.h>
+
+#include "netxen_nic_hw.h"
+#include "netxen_nic.h"
+#include "netxen_nic_phan_reg.h"
+#include "netxen_nic_ioctl.h"
+
+struct netxen_nic_stats {
+	char stat_string[ETH_GSTRING_LEN];
+	int sizeof_stat;
+	int stat_offset;
+};
+
+#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \
+                    offsetof(struct netxen_port, m)
+
+static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = {
+	{"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)},
+	{"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)},
+	{"xmited_frames", NETXEN_NIC_STAT(stats.xmitedframes)},
+	{"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)},
+	{"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)},
+	{"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)},
+	{"polled", NETXEN_NIC_STAT(stats.polled)},
+	{"uphappy", NETXEN_NIC_STAT(stats.uphappy)},
+	{"updropped", NETXEN_NIC_STAT(stats.updropped)},
+	{"uplcong", NETXEN_NIC_STAT(stats.uplcong)},
+	{"uphcong", NETXEN_NIC_STAT(stats.uphcong)},
+	{"upmcong", NETXEN_NIC_STAT(stats.upmcong)},
+	{"updunno", NETXEN_NIC_STAT(stats.updunno)},
+	{"skb_freed", NETXEN_NIC_STAT(stats.skbfreed)},
+	{"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)},
+	{"tx_null_skb", NETXEN_NIC_STAT(stats.txnullskb)},
+	{"csummed", NETXEN_NIC_STAT(stats.csummed)},
+	{"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)},
+	{"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)},
+	{"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)},
+};
+
+#define NETXEN_NIC_STATS_LEN        \
+        sizeof(netxen_nic_gstrings_stats) / sizeof(struct netxen_nic_stats)
+
+static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = {
+	"Register_Test  (offline)", "EEPROM_Test    (offline)",
+	"Interrupt_Test (offline)", "Loopback_Test  (offline)",
+	"Link_Test   (on/offline)"
+};
+
+#define NETXEN_NIC_TEST_LEN sizeof(netxen_nic_gstrings_test) / ETH_GSTRING_LEN
+
+#define NETXEN_NIC_REGS_COUNT 42
+#define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(netxen_crbword_t))
+
+static int netxen_nic_get_eeprom_len(struct net_device *dev)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	int n;
+
+	if ((netxen_rom_fast_read(adapter, 0, &n) == 0) && (n & 0x80000000)) {
+		n &= ~0x80000000;
+		if (n < 1024)
+			return n;
+	}
+	return 0;
+}
+
+static void
+netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
+{
+	struct netxen_port *port = netdev_priv(dev);
+
+	strncpy(drvinfo->driver, "NetXen NIC Driver", 32);
+	strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
+	strncpy(drvinfo->fw_version, NETXEN_NIC_FW_VERSIONID, 32);
+	strncpy(drvinfo->bus_info, pci_name(port->pdev), 32);
+	drvinfo->n_stats = NETXEN_NIC_STATS_LEN;
+	drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN;
+	drvinfo->regdump_len = NETXEN_NIC_REGS_LEN;
+	drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev);
+}
+
+static int
+netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+
+	/* read which mode */
+	if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
+		ecmd->supported = (SUPPORTED_10baseT_Half |
+				   SUPPORTED_10baseT_Full |
+				   SUPPORTED_100baseT_Half |
+				   SUPPORTED_100baseT_Full |
+				   SUPPORTED_1000baseT_Half |
+				   SUPPORTED_1000baseT_Full |
+				   SUPPORTED_TP |
+				   SUPPORTED_MII | SUPPORTED_Autoneg);
+
+		ecmd->advertising = (ADVERTISED_100baseT_Half |
+				     ADVERTISED_100baseT_Full |
+				     ADVERTISED_1000baseT_Half |
+				     ADVERTISED_1000baseT_Full |
+				     ADVERTISED_TP |
+				     ADVERTISED_MII | ADVERTISED_Autoneg);
+
+		ecmd->port = PORT_TP;
+
+		if (netif_running(dev)) {
+			ecmd->speed = port->link_speed;
+			ecmd->duplex = port->link_duplex;
+		} else
+			return -EIO;	/* link absent */
+
+		ecmd->phy_address = port->portnum;
+		ecmd->transceiver = XCVR_EXTERNAL;
+
+		/* get autoneg settings */
+		ecmd->autoneg = port->link_autoneg;
+		return 0;
+	}
+
+	if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
+		ecmd->supported = (SUPPORTED_TP |
+				   SUPPORTED_1000baseT_Full |
+				   SUPPORTED_10000baseT_Full);
+		ecmd->advertising = (ADVERTISED_TP |
+				     ADVERTISED_1000baseT_Full |
+				     ADVERTISED_10000baseT_Full);
+		ecmd->port = PORT_TP;
+
+		ecmd->speed = SPEED_10000;
+		ecmd->duplex = DUPLEX_FULL;
+		ecmd->phy_address = port->portnum;
+		ecmd->transceiver = XCVR_EXTERNAL;
+		ecmd->autoneg = AUTONEG_DISABLE;
+		return 0;
+	}
+
+	return -EIO;
+}
+
+static int
+netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	struct netxen_niu_phy_status status;
+
+	/* read which mode */
+	if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
+		/* autonegotiation */
+		if (netxen_nic_phy_write(port->adapter, port->portnum,
+					 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
+					 (netxen_crbword_t) ecmd->autoneg) != 0)
+			return -EIO;
+		else
+			port->link_autoneg = ecmd->autoneg;
+
+		if (netxen_nic_phy_read(port->adapter, port->portnum,
+					NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+					(netxen_crbword_t *) & status) != 0)
+			return -EIO;
+
+		/* speed */
+		switch (ecmd->speed) {
+		case SPEED_10:
+			status.speed = 0;
+			break;
+		case SPEED_100:
+			status.speed = 1;
+			break;
+		case SPEED_1000:
+			status.speed = 2;
+			break;
+		}
+		/* set duplex mode */
+		if (ecmd->duplex == DUPLEX_HALF)
+			status.duplex = 0;
+		if (ecmd->duplex == DUPLEX_FULL)
+			status.duplex = 1;
+
+		if (netxen_nic_phy_write(port->adapter, port->portnum,
+					 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+					 *((int *)&status)) != 0)
+			return -EIO;
+		else {
+			port->link_speed = ecmd->speed;
+			port->link_duplex = ecmd->duplex;
+		}
+	}
+	if (netif_running(dev)) {
+		dev->stop(dev);
+		dev->open(dev);
+	}
+	return 0;
+}
+
+static int netxen_nic_get_regs_len(struct net_device *dev)
+{
+	return NETXEN_NIC_REGS_LEN;
+}
+
+struct netxen_niu_regs {
+	netxen_crbword_t	reg[NETXEN_NIC_REGS_COUNT];
+};
+
+static struct netxen_niu_regs niu_registers[] = {
+	{
+	 /* GB Mode */
+	 {
+	  NETXEN_NIU_GB_SERDES_RESET,
+	  NETXEN_NIU_GB0_MII_MODE,
+	  NETXEN_NIU_GB1_MII_MODE,
+	  NETXEN_NIU_GB2_MII_MODE,
+	  NETXEN_NIU_GB3_MII_MODE,
+	  NETXEN_NIU_GB0_GMII_MODE,
+	  NETXEN_NIU_GB1_GMII_MODE,
+	  NETXEN_NIU_GB2_GMII_MODE,
+	  NETXEN_NIU_GB3_GMII_MODE,
+	  NETXEN_NIU_REMOTE_LOOPBACK,
+	  NETXEN_NIU_GB0_HALF_DUPLEX,
+	  NETXEN_NIU_GB1_HALF_DUPLEX,
+	  NETXEN_NIU_RESET_SYS_FIFOS,
+	  NETXEN_NIU_GB_CRC_DROP,
+	  NETXEN_NIU_GB_DROP_WRONGADDR,
+	  NETXEN_NIU_TEST_MUX_CTL,
+ 
+	  NETXEN_NIU_GB_MAC_CONFIG_0(0),
+	  NETXEN_NIU_GB_MAC_CONFIG_1(0),
+	  NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
+	  NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
+	  NETXEN_NIU_GB_TEST_REG(0),
+	  NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
+	  NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
+	  NETXEN_NIU_GB_MII_MGMT_ADDR(0),
+	  NETXEN_NIU_GB_MII_MGMT_CTRL(0),
+	  NETXEN_NIU_GB_MII_MGMT_STATUS(0),
+	  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
+	  NETXEN_NIU_GB_INTERFACE_CTRL(0),
+	  NETXEN_NIU_GB_INTERFACE_STATUS(0),
+	  NETXEN_NIU_GB_STATION_ADDR_0(0),
+	  NETXEN_NIU_GB_STATION_ADDR_1(0),
+	  -1,
+	 }
+	},
+	{
+	 /* XG Mode */
+	 {
+	  NETXEN_NIU_XG_SINGLE_TERM,
+	  NETXEN_NIU_XG_DRIVE_HI,
+	  NETXEN_NIU_XG_DRIVE_LO,
+	  NETXEN_NIU_XG_DTX,
+	  NETXEN_NIU_XG_DEQ,
+	  NETXEN_NIU_XG_WORD_ALIGN,
+	  NETXEN_NIU_XG_RESET,
+	  NETXEN_NIU_XG_POWER_DOWN,
+	  NETXEN_NIU_XG_RESET_PLL,
+	  NETXEN_NIU_XG_SERDES_LOOPBACK,
+	  NETXEN_NIU_XG_DO_BYTE_ALIGN,
+	  NETXEN_NIU_XG_TX_ENABLE,
+	  NETXEN_NIU_XG_RX_ENABLE,
+	  NETXEN_NIU_XG_STATUS,
+	  NETXEN_NIU_XG_PAUSE_THRESHOLD,
+	  NETXEN_NIU_XGE_CONFIG_0,
+	  NETXEN_NIU_XGE_CONFIG_1,
+	  NETXEN_NIU_XGE_IPG,
+	  NETXEN_NIU_XGE_STATION_ADDR_0_HI,
+	  NETXEN_NIU_XGE_STATION_ADDR_0_1,
+	  NETXEN_NIU_XGE_STATION_ADDR_1_LO,
+	  NETXEN_NIU_XGE_STATUS,
+	  NETXEN_NIU_XGE_MAX_FRAME_SIZE,
+	  NETXEN_NIU_XGE_PAUSE_FRAME_VALUE,
+	  NETXEN_NIU_XGE_TX_BYTE_CNT,
+	  NETXEN_NIU_XGE_TX_FRAME_CNT,
+	  NETXEN_NIU_XGE_RX_BYTE_CNT,
+	  NETXEN_NIU_XGE_RX_FRAME_CNT,
+	  NETXEN_NIU_XGE_AGGR_ERROR_CNT,
+	  NETXEN_NIU_XGE_MULTICAST_FRAME_CNT,
+	  NETXEN_NIU_XGE_UNICAST_FRAME_CNT,
+	  NETXEN_NIU_XGE_CRC_ERROR_CNT,
+	  NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
+	  NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
+	  NETXEN_NIU_XGE_LOCAL_ERROR_CNT,
+	  NETXEN_NIU_XGE_REMOTE_ERROR_CNT,
+	  NETXEN_NIU_XGE_CONTROL_CHAR_CNT,
+	  NETXEN_NIU_XGE_PAUSE_FRAME_CNT,
+	  -1,
+	 }
+	}
+};
+
+static void
+netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	netxen_crbword_t mode, *regs_buff = p;
+	unsigned long flags;
+	void *addr;
+	int i, window;
+
+	memset(p, 0, NETXEN_NIC_REGS_LEN);
+	regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
+	    adapter->ahw.device_id;
+	write_lock_irqsave(&adapter->adapter_lock, flags);
+	/* which mode */
+	NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, &regs_buff[0]);
+	mode = regs_buff[0];
+
+	/* Common registers to all the modes */
+	NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER,
+				   &regs_buff[2]);
+	/* GB/XGB Mode */
+	mode = (mode/2) - 1;
+	window = 0;
+	if(mode <= 1) {
+		for ( i = 3; niu_registers[mode].reg[i - 3] != -1; i++) {
+			/* GB: port specific registers */
+			if(mode == 0 && i >= 19)
+				window = port->portnum * 0x10000;
+
+			NETXEN_NIC_LOCKED_READ_REG
+			    (niu_registers[mode].reg[i - 3] + window,
+			    &regs_buff[i]);
+		}
+	}
+	write_unlock_irqrestore(&adapter->adapter_lock, flags);
+}
+
+static void
+netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+	wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
+	wol->wolopts = 0;	/* options can be added depending upon the mode */
+}
+
+/* Restart Link Process */
+static int netxen_nic_nway_reset(struct net_device *dev)
+{
+	if (netif_running(dev)) {
+		dev->stop(dev);	/* verify */
+		dev->open(dev);
+	}
+	return 0;
+}
+
+static u32 netxen_nic_get_link(struct net_device *dev)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	struct netxen_niu_phy_status status;
+
+	/* read which mode */
+	if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
+		if (netxen_nic_phy_read(port->adapter, port->portnum,
+					NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
+					(netxen_crbword_t *) & status) != 0)
+			return -EIO;
+		else
+			return status.link;
+	}
+	return -EIO;
+}
+
+static int
+netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
+		      u8 * bytes)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	int offset;
+
+	if (eeprom->len == 0)
+		return -EINVAL;
+
+	eeprom->magic = adapter->ahw.vendor_id | (adapter->ahw.device_id << 16);
+	for (offset = 0; offset < eeprom->len; offset++)
+		if (netxen_rom_fast_read
+		    (adapter, (8 * offset) + 8, (int *)eeprom->data) == -1)
+			return -1;
+	return 0;
+}
+
+static void
+netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	int i, j;
+	struct netxen_ring_context *ctx;
+
+	ring->rx_pending = 0;
+	ring->rx_max_pending = 0;
+	ring->tx_max_pending = 0;
+	for (i = 0; i < MAX_RING_CTX; ++i) {
+		ctx = &adapter->ring_ctx[i];
+		for (j = 0; j < NUM_RCV_DESC_RINGS; j++)
+			ring->rx_pending +=
+			    ctx->recv_ctx.rcv_desc[j].rcv_pending;
+		ring->tx_pending += ctx->pending_cmd_count;
+		ring->rx_max_pending += ctx->max_rx_desc_count;
+		ring->tx_max_pending += ctx->max_tx_desc_count;
+	}
+
+	ring->rx_mini_max_pending = 0;
+	ring->rx_mini_pending = 0;
+	ring->rx_jumbo_max_pending = 0;
+	ring->rx_jumbo_pending = 0;
+}
+
+static void
+netxen_nic_get_pauseparam(struct net_device *dev,
+			  struct ethtool_pauseparam *pause)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	struct netxen_niu_gb_mac_config_0_t val;
+
+	if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
+		/* get flow control settings */
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
+				   (u32 *) & val);
+		pause->rx_pause = val.rx_flowctl;
+		pause->tx_pause = val.tx_flowctl;
+		/* get autoneg settings */
+		pause->autoneg = port->link_autoneg;
+	}
+}
+
+static int
+netxen_nic_set_pauseparam(struct net_device *dev,
+			  struct ethtool_pauseparam *pause)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	struct netxen_niu_gb_mac_config_0_t val;
+	unsigned int autoneg;
+
+	/* read mode */
+	if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
+		/* set flow control */
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
+				   (u32 *) & val);
+		val.rx_flowctl = pause->rx_pause;
+		val.tx_flowctl = pause->tx_pause;
+		netxen_nic_write_w0(adapter,
+				    NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
+				    *(u32 *) (&val));
+		/* set autoneg */
+		autoneg = pause->autoneg;
+		if (netxen_nic_phy_write(port->adapter, port->portnum,
+					 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
+					 (netxen_crbword_t) autoneg) != 0)
+			return -EIO;
+		else {
+			port->link_autoneg = pause->autoneg;
+			return 0;
+		}
+	} else
+		return -EIO;
+}
+
+static int netxen_nic_reg_test(struct net_device *dev)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	struct netxen_adapter *adapter = port->adapter;
+	int data_read, data_written, save;
+	struct netxen_niu_control mode;
+
+	/* 
+	 * first test the "Read Only" registers by writing which mode
+	 */
+	netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, (u32 *) & mode);
+	if (mode.enable_ge) {	/* GB Mode */
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
+				   &data_read);
+
+		save = data_read;
+		if (data_read)
+			data_written = data_read & 0xDEADBEEF;
+		else
+			data_written = 0xDEADBEEF;
+		netxen_nic_write_w0(adapter,
+				    NETXEN_NIU_GB_MII_MGMT_STATUS(port->
+								  portnum),
+				    data_written);
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
+				   &data_read);
+
+		if (data_written == data_read) {
+			netxen_nic_write_w0(adapter,
+					    NETXEN_NIU_GB_MII_MGMT_STATUS(port->
+									  portnum),
+					    save);
+
+			return 0;
+		}
+
+		/* netxen_niu_gb_mii_mgmt_indicators_t is read only */
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
+								   portnum),
+				   &data_read);
+
+		save = data_read;
+		if (data_read)
+			data_written = data_read & 0xDEADBEEF;
+		else
+			data_written = 0xDEADBEEF;
+		netxen_nic_write_w0(adapter,
+				    NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
+								    portnum),
+				    data_written);
+
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
+								   portnum),
+				   &data_read);
+
+		if (data_written == data_read) {
+			netxen_nic_write_w0(adapter,
+					    NETXEN_NIU_GB_MII_MGMT_INDICATE
+					    (port->portnum), save);
+			return 0;
+		}
+
+		/* netxen_niu_gb_interface_status_t is read only */
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_INTERFACE_STATUS(port->
+								  portnum),
+				   &data_read);
+
+		save = data_read;
+		if (data_read)
+			data_written = data_read & 0xDEADBEEF;
+		else
+			data_written = 0xDEADBEEF;
+		netxen_nic_write_w0(adapter,
+				    NETXEN_NIU_GB_INTERFACE_STATUS(port->
+								   portnum),
+				    data_written);
+
+		netxen_nic_read_w0(adapter,
+				   NETXEN_NIU_GB_INTERFACE_STATUS(port->
+								  portnum),
+				   &data_read);
+
+		if (data_written == data_read) {
+			netxen_nic_write_w0(adapter,
+					    NETXEN_NIU_GB_INTERFACE_STATUS
+					    (port->portnum), save);
+
+			return 0;
+		}
+	}			/* GB Mode */
+	return 1;
+}
+
+static int netxen_nic_diag_test_count(struct net_device *dev)
+{
+	return NETXEN_NIC_TEST_LEN;
+}
+
+static void
+netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
+		     u64 * data)
+{
+	if (eth_test->flags == ETH_TEST_FL_OFFLINE) {	/* offline tests */
+		/* link test */
+		if (!(data[4] = (u64) netxen_nic_get_link(dev)))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		if (netif_running(dev))
+			dev->stop(dev);
+
+		/* register tests */
+		if (!(data[0] = netxen_nic_reg_test(dev)))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+		/* other tests pass as of now */
+		data[1] = data[2] = data[3] = 1;
+		if (netif_running(dev))
+			dev->open(dev);
+	} else {		/* online tests */
+		/* link test */
+		if (!(data[4] = (u64) netxen_nic_get_link(dev)))
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+
+		/* other tests pass by default */
+		data[0] = data[1] = data[2] = data[3] = 1;
+	}
+}
+
+static void
+netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data)
+{
+	int index;
+
+	switch (stringset) {
+	case ETH_SS_TEST:
+		memcpy(data, *netxen_nic_gstrings_test,
+		       NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN);
+		break;
+	case ETH_SS_STATS:
+		for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
+			memcpy(data + index * ETH_GSTRING_LEN,
+			       netxen_nic_gstrings_stats[index].stat_string,
+			       ETH_GSTRING_LEN);
+		}
+		break;
+	}
+}
+
+static int netxen_nic_get_stats_count(struct net_device *dev)
+{
+	return NETXEN_NIC_STATS_LEN;
+}
+
+static void
+netxen_nic_get_ethtool_stats(struct net_device *dev,
+			     struct ethtool_stats *stats, u64 * data)
+{
+	struct netxen_port *port = netdev_priv(dev);
+	int index;
+
+	for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
+		char *p =
+		    (char *)port + netxen_nic_gstrings_stats[index].stat_offset;
+		data[index] =
+		    (netxen_nic_gstrings_stats[index].sizeof_stat ==
+		     sizeof(u64)) ? *(u64 *) p : *(u32 *) p;
+	}
+
+}
+
+struct ethtool_ops netxen_nic_ethtool_ops = {
+	.get_settings = netxen_nic_get_settings,
+	.set_settings = netxen_nic_set_settings,
+	.get_drvinfo = netxen_nic_get_drvinfo,
+	.get_regs_len = netxen_nic_get_regs_len,
+	.get_regs = netxen_nic_get_regs,
+	.get_wol = netxen_nic_get_wol,
+	.nway_reset = netxen_nic_nway_reset,
+	.get_link = netxen_nic_get_link,
+	.get_eeprom_len = netxen_nic_get_eeprom_len,
+	.get_eeprom = netxen_nic_get_eeprom,
+	.get_ringparam = netxen_nic_get_ringparam,
+	.get_pauseparam = netxen_nic_get_pauseparam,
+	.set_pauseparam = netxen_nic_set_pauseparam,
+	.get_tx_csum = ethtool_op_get_tx_csum,
+	.set_tx_csum = ethtool_op_set_tx_csum,
+	.get_sg = ethtool_op_get_sg,
+	.set_sg = ethtool_op_set_sg,
+#ifdef NETIF_F_TSO
+	.get_tso = ethtool_op_get_tso,
+	.set_tso = ethtool_op_set_tso,
+#endif
+	.self_test_count = netxen_nic_diag_test_count,
+	.self_test = netxen_nic_diag_test,
+	.get_strings = netxen_nic_get_strings,
+	.get_stats_count = netxen_nic_get_stats_count,
+	.get_ethtool_stats = netxen_nic_get_ethtool_stats,
+	.get_perm_addr = ethtool_op_get_perm_addr,
+};

^ permalink raw reply

* [PATCH 2.6.17 2/9] NetXen: Main header file.
From: Linsys Contractor Amit S. Kale @ 2006-07-05 13:29 UTC (permalink / raw)
  To: netdev; +Cc: jeff, sanjeev, unmproj
In-Reply-To: <Pine.LNX.4.64.0607050602310.27969@dut46>

diff -Naru linux-2.6.17.orig/drivers/net/netxen/netxen_nic.h linux-2.6.17/drivers/net/netxen/netxen_nic.h
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic.h	2006-07-05 01:18:40.363907266 -0700
@@ -0,0 +1,998 @@
+/*
+ * Copyright (C) 2003 - 2006 NetXen, Inc.
+ * All rights reserved.
+ * 
+ * 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
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.
+ * 
+ * Contact Information:
+ *    info@netxen.com
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef _NETXEN_NIC_H_
+#define _NETXEN_NIC_H_
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/compiler.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/ip.h>
+#include <linux/in.h>
+#include <linux/tcp.h>
+#include <linux/skbuff.h>
+#include <linux/version.h>
+
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+#include <linux/interrupt.h>
+#include <linux/timer.h>
+
+#include <linux/mm.h>
+#include <linux/mman.h>
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/byteorder.h>
+#include <asm/uaccess.h>
+#include <asm/pgtable.h>
+
+#include <linux/skbuff.h>
+
+#include "netxen_nic_hw.h"
+#include "netxen_nic_hdr.h"
+
+#define NETXEN_NIC_BUILD_NO     "231"
+#define _NETXEN_NIC_LINUX_MAJOR 2
+#define _NETXEN_NIC_LINUX_MINOR 1
+#define _NETXEN_NIC_LINUX_SUBVERSION 39
+#define NETXEN_NIC_LINUX_VERSIONID  "2.1.39"
+#define NETXEN_NIC_FW_VERSIONID "2.1.39"
+#define NETXEN_NIC_TIMESTAMP "Mon May  1 01:34:07 PDT 2006"
+
+#define RCV_DESC_RINGSIZE(ctxid)	\
+	(sizeof(struct rcv_desc_t) * adapter->ring_ctx[ctxid].max_rx_desc_count)
+#define STATUS_DESC_RINGSIZE(i)	\
+	(sizeof(struct status_desc_t)* adapter->ring_ctx[i].max_rx_desc_count)
+#define TX_RINGSIZE(i)	(sizeof(struct netxen_cmd_buffer)	\
+	* adapter->ring_ctx[i].max_tx_desc_count)
+#define JUMBO_DESC_RINGSIZE	\
+	(sizeof(rcvDesc_t) * adapter->ring_ctx[i].MaxJumboRxDescCount)
+#define RCV_BUFFSIZE	\
+	(sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
+
+#define DB_PAGE_SIZE    0x1000
+#define NETXEN_CMD_PRODUCER_OFFSET(ctx) \
+	((NETXEN_CMD_PRODUCER_DB_PAGE(ctx)) * DB_PAGE_SIZE)
+#define NETXEN_RCV_STATUS_CONSUMER_OFFSET(ctx) \
+	((NETXEN_RCV_STATUS_CONSUMER_DB_PAGE(ctx)) * DB_PAGE_SIZE)
+#define NETXEN_RCV_PRODUCER_OFFSET(ctx,ring) \
+	((NETXEN_RCV_PRODUCER_DB_PAGE(ctx,ring)) * DB_PAGE_SIZE)
+
+#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
+
+#define NETXEN_NETDEV_STATUS 0x1
+
+#define ADDR_IN_WINDOW1(off)	\
+	((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
+
+/* 
+ * normalize a 64MB crb address to 32MB PCI window 
+ * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
+ */
+#define NETXEN_CRB_NORMALIZE(adapter, reg) \
+	(void *)(ptrdiff_t)(adapter->ahw.pci_base+ (reg)	\
+	- NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
+
+#define DB_NORMALIZE(adapter, off) \
+	(void *)(ptrdiff_t)(adapter->ahw.db_base + (off))
+
+#define MAX_RX_BUFFER_LENGTH		2000
+#define MAX_RX_JUMBO_BUFFER_LENGTH 	9046
+#define RX_DMA_MAP_LEN 		(MAX_RX_BUFFER_LENGTH - NET_IP_ALIGN)
+#define RX_JUMBO_DMA_MAP_LEN	\
+	(MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN)
+
+/*
+ * Maximum number of ring contexts
+ */
+#define MAX_RING_CTX 1
+
+/* Opcodes to be used with the commands */
+#define	TX_ETHER_PKT 0x01
+/* The following opcodes are for IP checksum	*/
+#define	TX_TCP_PKT 	0x02
+#define	TX_UDP_PKT	0x03
+#define	TX_IP_PKT	0x04
+#define	TX_TCP_LSO	0x05
+#define	TX_IPSEC	0x06
+#define	TX_IPSEC_CMD	0x07
+
+/* The following opcodes are for internal consumption. */
+#define NETXEN_CONTROL_OP	0x10
+#define PEGNET_REQUEST		0x11
+
+#define	MAX_NUM_CARDS		4
+
+#define MAX_BUFFERS_PER_CMD	32
+
+/*
+ * Following are the states of the Phantom. Phantom will set them and
+ * Host will read to check if the fields are correct.
+ */
+#define PHAN_INITIALIZE_START		0xff00
+#define PHAN_INITIALIZE_FAILED		0xffff
+#define PHAN_INITIALIZE_COMPLETE	0xff01
+
+/* Host writes the following to notify that it has done the init-handshake */
+#define PHAN_INITIALIZE_ACK	0xf00f
+
+#define NUM_RCV_DESC_RINGS	2	/* No of Rcv Descriptor contexts */
+
+/* descriptor types */
+#define RCV_DESC_NORMAL		0x01
+#define RCV_DESC_JUMBO		0x02
+#define RCV_DESC_NORMAL_CTXID	0
+#define RCV_DESC_JUMBO_CTXID	1
+
+#define RCV_DESC_TYPE(ID) \
+	((ID == RCV_DESC_JUMBO_CTXID) ? RCV_DESC_JUMBO : RCV_DESC_NORMAL)
+
+#define MAX_CMD_DESCRIPTORS		1024
+#define MAX_RCV_DESCRIPTORS		32768
+#define MAX_JUMBO_RCV_DESCRIPTORS	1024
+#define MAX_RCVSTATUS_DESCRIPTORS	MAX_RCV_DESCRIPTORS
+#define MAX_JUMBO_RCV_DESC	MAX_JUMBO_RCV_DESCRIPTORS
+#define MAX_RCV_DESC		MAX_RCV_DESCRIPTORS
+#define MAX_RCVSTATUS_DESC	MAX_RCV_DESCRIPTORS
+#define NUM_RCV_DESC		(MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS)
+#define MAX_EPG_DESCRIPTORS	MAX_CMD_DESCRIPTORS * 8
+
+#define MIN_TX_COUNT	4096
+#define MIN_RX_COUNT	4096
+
+#define MAX_FRAME_SIZE	0x10000	/* 64K MAX size for LSO */
+
+#define PHAN_PEG_RCV_INITIALIZED	0xff01
+#define PHAN_PEG_RCV_START_INITIALIZE	0xff00
+
+#define get_next_index(index, length)	\
+	((((index) + 1) == length) ? \
+		0 : \
+		(index) +1)
+
+#define get_index_range(index,length,count)	\
+	((((index) + (count)) >= length) ?	\
+		(((index) + (count))-(length)) :	\
+		((index) + (count)))
+
+/**
+ * Following data structures describe the descriptors that will be used.
+ * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
+ * we are doing LSO (above the 1500 size packet) only.
+ **/
+
+/**
+ * The size of reference handle been changed to 16 bits to pass the MSS fields
+ * for the LSO packet
+ **/
+
+#define FLAGS_CHECKSUM_ENABLED	0x01
+#define FLAGS_LSO_ENABLED	0x02
+#define FLAGS_IPSEC_SA_ADD	0x04
+#define FLAGS_IPSEC_SA_DELETE	0x08
+#define FLAGS_VLAN_TAGGED	0x10
+
+struct cmd_desc_type0_t {
+	u64 netxen_next;	/* for fragments handled by Phantom */
+	union {
+		struct {
+			u32 addr_low_part2;
+			u32 addr_high_part2;
+		};
+		u64 addr_buffer2;
+	};
+
+	u64 total_length:24,	/* Total size of the packet */
+	 tcp_hdr_offset:8,	/* For LSO only */
+	 ip_hdr_offset:8,	/* For LSO only */
+	 num_of_buffers:8,	/* total number of segments */
+	 flags:8,		/* as defined above */
+	 opcode:8;
+
+	u64 reference_handle:16,	/* changed to u16 to add mss */
+	 mss:16,		/* passed by NDIS_PACKET for LSO */
+	 port:4,
+	 ctx_id:4,
+	 total_hdr_length:8,	/* LSO only : MAC+IP+TCP Hdr size */
+	 conn_id:16;		/* IPSec offoad only */
+
+	union {
+		struct {
+			u32 addr_low_part3;
+			u32 addr_high_part3;
+		};
+		u64 addr_buffer3;
+	};
+
+	union {
+		struct {
+			u32 addr_low_part1;
+			u32 addr_high_part1;
+		};
+		u64 addr_buffer1;
+	};
+
+	u64 buffer1_length:16,
+	    buffer2_length:16, buffer3_length:16, buffer4_length:16;
+
+	union {
+		struct {
+			u32 addr_low_part4;
+			u32 addr_high_part4;
+		};
+		u64 addr_buffer4;
+	};
+
+} __attribute__ ((aligned(64)));
+
+/* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
+struct rcv_desc_t {
+	u64 reference_handle:16,
+	 reserved:16,
+	 buffer_length:32;	/* allocated buffer length (usually 2K) */
+	u64 addr_buffer;
+};
+
+/* opcode field in status_desc_t */
+#define RCV_NIC_PKT	(0xA)
+#define STATUS_NIC_PKT	((RCV_NIC_PKT) << 12)
+
+/* for status field in status_desc_t */
+#define STATUS_NEED_CKSUM	(1)
+#define STATUS_CKSUM_OK		(2)
+
+/* owner bits of status_desc_t */
+#define STATUS_OWNER_HOST	(1ULL)
+#define STATUS_OWNER_PHANTOM	(2ULL)
+#define HOST_STATUS_DESC	((STATUS_OWNER_HOST) << 48)
+#define PHANTOM_STATUS_DESC	((STATUS_OWNER_PHANTOM) << 48)
+
+#define NETXEN_PROT_IP		(1)
+#define NETXEN_PROT_UNKNOWN	(0)
+
+/* Note: sizeof(status_desc) should always be a mutliple of 2 */
+struct status_desc_t {
+	u64 port:4,		/* initially to be used but noe now */
+	 status:4,		/* completion status may not have use */
+	 type:4,		/* type/index of descriptor ring */
+	 opcode:4,		/* Completion of receive or transmit */
+	 total_length:16,	/* NIC mode */
+	 reference_handle:16,	/* handle for the associated packet */
+	 owner:2,		/* Owner of the descriptor */
+	 prot:4;		/* protocol type for skb (Linux) */
+} __attribute__ ((aligned(8)));
+
+enum {
+	NETXEN_RCV_PEG_0 = 0,
+	NETXEN_RCV_PEG_1
+};
+
+/* The version of the main data structure */
+#define	NETXEN_BDINFO_VERSION 1
+
+/* Magic number to let user know flash is programmed */
+#define	NETXEN_BDINFO_MAGIC 0x12345678
+
+/* Max number of Gig ports on a Phantom board */
+#define NETXEN_MAX_PORTS 4
+
+typedef enum {
+	NETXEN_BRDTYPE_P1_BD = 0x0000,
+	NETXEN_BRDTYPE_P1_SB = 0x0001,
+	NETXEN_BRDTYPE_P1_SMAX = 0x0002,
+	NETXEN_BRDTYPE_P1_SOCK = 0x0003,
+
+	NETXEN_BRDTYPE_P2_SOCK_31 = 0x0008,
+	NETXEN_BRDTYPE_P2_SOCK_35 = 0x0009,
+	NETXEN_BRDTYPE_P2_SB35_4G = 0x000a,
+	NETXEN_BRDTYPE_P2_SB31_10G = 0x000b,
+	NETXEN_BRDTYPE_P2_SB31_2G = 0x000c,
+
+	NETXEN_BRDTYPE_P2_SB31_10G_IMEZ = 0x000d,
+	NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
+	NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f
+} netxen_brdtype_t;
+
+typedef enum {
+	NETXEN_BRDMFG_INVENTEC = 1
+} netxen_brdmfg;
+
+typedef enum {
+	MEM_ORG_128Mbx4 = 0x0,	/* DDR1 only */
+	MEM_ORG_128Mbx8 = 0x1,	/* DDR1 only */
+	MEM_ORG_128Mbx16 = 0x2,	/* DDR1 only */
+	MEM_ORG_256Mbx4 = 0x3,
+	MEM_ORG_256Mbx8 = 0x4,
+	MEM_ORG_256Mbx16 = 0x5,
+	MEM_ORG_512Mbx4 = 0x6,
+	MEM_ORG_512Mbx8 = 0x7,
+	MEM_ORG_512Mbx16 = 0x8,
+	MEM_ORG_1Gbx4 = 0x9,
+	MEM_ORG_1Gbx8 = 0xa,
+	MEM_ORG_1Gbx16 = 0xb,
+	MEM_ORG_2Gbx4 = 0xc,
+	MEM_ORG_2Gbx8 = 0xd,
+	MEM_ORG_2Gbx16 = 0xe,
+	MEM_ORG_128Mbx32 = 0x10002,	/* GDDR only */
+	MEM_ORG_256Mbx32 = 0x10005	/* GDDR only */
+} netxen_mn_mem_org_t;
+
+typedef enum {
+	MEM_ORG_512Kx36 = 0x0,
+	MEM_ORG_1Mx36 = 0x1,
+	MEM_ORG_2Mx36 = 0x2
+} netxen_sn_mem_org_t;
+
+typedef enum {
+	MEM_DEPTH_4MB = 0x1,
+	MEM_DEPTH_8MB = 0x2,
+	MEM_DEPTH_16MB = 0x3,
+	MEM_DEPTH_32MB = 0x4,
+	MEM_DEPTH_64MB = 0x5,
+	MEM_DEPTH_128MB = 0x6,
+	MEM_DEPTH_256MB = 0x7,
+	MEM_DEPTH_512MB = 0x8,
+	MEM_DEPTH_1GB = 0x9,
+	MEM_DEPTH_2GB = 0xa,
+	MEM_DEPTH_4GB = 0xb,
+	MEM_DEPTH_8GB = 0xc,
+	MEM_DEPTH_16GB = 0xd,
+	MEM_DEPTH_32GB = 0xe
+} netxen_mem_depth_t;
+
+struct netxen_board_info {
+	u32 header_version;
+
+	u32 board_mfg;
+	u32 board_type;
+	u32 board_num;
+	u32 chip_id;
+	u32 chip_minor;
+	u32 chip_major;
+	u32 chip_pkg;
+	u32 chip_lot;
+
+	u32 port_mask;		/* available niu ports */
+	u32 peg_mask;		/* available pegs */
+	u32 icache_ok;		/* can we run with icache? */
+	u32 dcache_ok;		/* can we run with dcache? */
+	u32 casper_ok;
+
+	u32 mac_addr_lo_0;
+	u32 mac_addr_lo_1;
+	u32 mac_addr_lo_2;
+	u32 mac_addr_lo_3;
+
+	/* MN-related config */
+	u32 mn_sync_mode;	/* enable/ sync shift cclk/ sync shift mclk */
+	u32 mn_sync_shift_cclk;
+	u32 mn_sync_shift_mclk;
+	u32 mn_wb_en;
+	u32 mn_crystal_freq;	/* in MHz */
+	u32 mn_speed;		/* in MHz */
+	u32 mn_org;
+	u32 mn_depth;
+	u32 mn_ranks_0;		/* ranks per slot */
+	u32 mn_ranks_1;		/* ranks per slot */
+	u32 mn_rd_latency_0;
+	u32 mn_rd_latency_1;
+	u32 mn_rd_latency_2;
+	u32 mn_rd_latency_3;
+	u32 mn_rd_latency_4;
+	u32 mn_rd_latency_5;
+	u32 mn_rd_latency_6;
+	u32 mn_rd_latency_7;
+	u32 mn_rd_latency_8;
+	u32 mn_dll_val[18];
+	u32 mn_mode_reg;	/* MIU DDR Mode Register */
+	u32 mn_ext_mode_reg;	/* MIU DDR Extended Mode Register */
+	u32 mn_timing_0;	/* MIU Memory Control Timing Rgister */
+	u32 mn_timing_1;	/* MIU Extended Memory Ctrl Timing Register */
+	u32 mn_timing_2;	/* MIU Extended Memory Ctrl Timing2 Register */
+
+	/* SN-related config */
+	u32 sn_sync_mode;	/* enable/ sync shift cclk / sync shift mclk */
+	u32 sn_pt_mode;		/* pass through mode */
+	u32 sn_ecc_en;
+	u32 sn_wb_en;
+	u32 sn_crystal_freq;
+	u32 sn_speed;
+	u32 sn_org;
+	u32 sn_depth;
+	u32 sn_dll_tap;
+	u32 sn_rd_latency;
+
+	u32 mac_addr_hi_0;
+	u32 mac_addr_hi_1;
+	u32 mac_addr_hi_2;
+	u32 mac_addr_hi_3;
+
+	u32 magic;		/* indicates flash has been initialized */
+
+	u32 mn_rdimm;
+	u32 mn_dll_override;
+
+};
+
+#define FLASH_NUM_PORTS		(4)
+
+struct netxen_flash_mac_addr {
+	u32 flash_addr[32];
+};
+
+#define FLASH_NUM_MAC_PER_PORT	32
+struct netxen_user_info {
+	u8 flash_md5[16 * 64];
+	/* bootloader */
+	u32 bootld_version;
+	u32 bootld_size;
+	/* image */
+	u32 image_version;
+	u32 image_size;
+	/* primary image status */
+	u32 primary_status;
+	u32 secondary_present;
+
+	/* MAC address , 4 ports, 32 address per port */
+	u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
+	u32 sub_sys_id;
+	u8 serial_num[32];
+
+	/* Any user defined data */
+};
+
+/*
+ * Flash Layout - new format.
+ */
+#define FLASH_NUM_MAC_PER_PORT	32
+struct netxen_new_user_info {
+	u8 flash_md5[16 * 64];
+	/* bootloader */
+	u32 bootld_version;
+	u32 bootld_size;
+	/* image */
+	u32 image_version;
+	u32 image_size;
+	/* primary image status */
+	u32 primary_status;
+	u32 secondary_present;
+
+	/* MAC address , 4 ports, 32 address per port */
+	u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
+	u32 sub_sys_id;
+	u8 serial_num[32];
+
+	/* Any user defined data */
+};
+
+#define SECONDARY_IMAGE_PRESENT 0xb3b4b5b6
+#define SECONDARY_IMAGE_ABSENT	0xffffffff
+#define PRIMARY_IMAGE_GOOD	0x5a5a5a5a
+#define PRIMARY_IMAGE_BAD	0xffffffff
+
+/* Flash memory map */
+typedef enum {
+	CRBINIT_START = 0,	/* Crbinit section */
+	BRDCFG_START = 0x4000,	/* board config */
+	INITCODE_START = 0x6000,	/* pegtune code */
+	BOOTLD_START = 0x10000,	/* bootld */
+	IMAGE_START = 0x43000,	/* compressed image */
+	SECONDARY_START = 0x200000,	/* backup images */
+	PXE_START = 0x3E0000,	/* user defined region */
+	USER_START = 0x3E8000,	/* User defined region for new boards */
+	FIXED_START = 0x3F0000	/* backup of crbinit */
+} netxen_flash_map_t;
+
+#define USER_START_OLD PXE_START	/* for backward compatibility */
+
+#define FLASH_START		(CRBINIT_START)
+#define INIT_SECTOR		(0)
+#define PRIMARY_START 		(BOOTLD_START)
+#define FLASH_CRBINIT_SIZE 	(0x4000)
+#define FLASH_BRDCFG_SIZE 	(sizeof(struct netxen_board_info))
+#define FLASH_USER_SIZE		(sizeof(netxen_user_info)/sizeof(u32))
+#define FLASH_SECONDARY_SIZE 	(USER_START-SECONDARY_START)
+#define NUM_PRIMARY_SECTORS	(0x20)
+#define NUM_CONFIG_SECTORS 	(1)
+int is_flash_supported(struct netxen_adapter *adapter);
+int get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
+extern char netxen_nic_driver_string[];
+extern void netxen_change_ringparam(struct netxen_adapter *adapter);
+extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
+				int *valp);
+
+extern struct ethtool_ops netxen_nic_ethtool_ops;
+
+/*
+ * The PCI VendorID and DeviceID for our board.
+ */
+#define PCI_VENDOR_ID_NX       0x4040
+#define PCI_DEVICE_ID_NX_XG    0x0001
+#define PCI_DEVICE_ID_NX_CX4   0x0002
+#define PCI_DEVICE_ID_NX_QG    0x0003
+#define PCI_DEVICE_ID_NX_IMEZ  0x0004
+#define PCI_DEVICE_ID_NX_HMEZ  0x0005
+
+#define NETXEN_PCI_ID(X) { PCI_DEVICE(PCI_VENDOR_ID_NX, (X)) }
+
+#define PFX "netxen: "
+
+/* Note: Make sure to not call this before adapter->port is valid */
+#if !defined(NETXEN_DEBUG)
+#define DPRINTK(klevel, fmt, args...)	do { \
+	} while (0)
+#else
+#define DPRINTK(klevel, fmt, args...)	do { \
+	printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
+		(adapter != NULL && adapter->port != NULL && \
+		adapter->port[0] != NULL && \
+		adapter->port[0]->netdev != NULL) ? \
+		adapter->port[0]->netdev->name : NULL, \
+		## args); } while(0)
+#endif
+
+/* Number of status descriptors to handle per interrupt */
+#define MAX_STATUS_HANDLE	(128)
+
+/*
+ * netxen_skb_frag{} is to contain mapping info for each SG list. This
+ * has to be freed when DMA is complete. This is part of netxen_tx_buffer{}.
+ */
+struct netxen_skb_frag {
+	u64 dma;
+	u32 length;
+};
+
+/*    Following defines are for the state of the buffers    */
+#define	NETXEN_BUFFER_FREE	0
+#define	NETXEN_BUFFER_BUSY	1
+
+/*
+ * There will be one netxen_buffer per skb packet.    These will be
+ * used to save the dma info for pci_unmap_page()
+ */
+struct netxen_cmd_buffer {
+	struct sk_buff *skb;
+	struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
+	u32 total_length;
+	u32 mss;
+	u32 port:16, cmd:8, frag_count:8;
+	unsigned long time_stamp;
+	u32 state;
+	u32 no_of_descriptors;
+};
+
+/* In rx_buffer, we do not need multiple fragments as is a single buffer */
+struct netxen_rx_buffer {
+	struct sk_buff *skb;
+	u64 dma;
+	u32 ref_handle:16, state:16;
+};
+
+/* Board types */
+#define	NETXEN_NIC_GBE	0x01
+#define	NETXEN_NIC_XGBE	0x02
+
+/*
+ * One hardware_context{} per adapter
+ * contains interrupt info as well shared hardware info.
+ */
+struct netxen_hardware_context {
+	struct pci_dev *pdev;
+	unsigned long pci_base;	/* base of mapped phantom memory */
+	unsigned long pci_len;	/* length of mapped phantom memory */
+	u16 vendor_id;
+	u16 device_id;
+	u8 revision_id;
+	u16 pci_cmd_word;
+	u16 board_type;
+	u16 max_ports;
+	struct netxen_board_info boardcfg;
+	u32 xg_linkup;
+	struct netxen_adapter *adapter;
+	u32 crb_base;
+	unsigned long db_base;	/* base of mapped db memory */
+	unsigned long db_len;	/* length of mapped db memory */
+};
+
+#define MINIMUM_ETHERNET_FRAME_SIZE	64	/* With FCS */
+#define ETHERNET_FCS_SIZE		4
+
+struct netxen_adapter_stats {
+	u64 ints;
+	u64 hostints;
+	u64 otherints;
+	u64 process_rcv;
+	u64 process_xmit;
+	u64 noxmitdone;
+	u64 xmitcsummed;
+	u64 post_called;
+	u64 posted;
+	u64 lastposted;
+	u64 goodskbposts;
+};
+
+/*
+ * Ring which will hold the skbs which can be fed to receive ring
+ */
+#define NETXEN_SKB_ARRAY_SIZE	1024
+
+struct netxen_recv_skb_ring {
+	struct sk_buff **skb_array;
+	u32 interrupt_index;
+	u32 tasklet_index;
+	u32 data_size;
+};
+
+/*
+ * Rcv Descriptor Context. One such per Rcv Descriptor. There may
+ * be one Rcv Descriptor for normal packets, one for jumbo and may be others.
+ */
+struct netxen_rcv_desc_ctx {
+	u32 flags;
+	u32 producer;
+	u32 rcv_pending;	/* Num of bufs posted in phantom */
+	u32 rcv_free;		/* Num of bufs in free list */
+	u32 phys_addr;
+	struct rcv_desc_t *desc_head;	/* address of rx ring in Phantom */
+	u32 max_rx_desc_count;
+	u32 dma_size;
+	u32 skb_size;
+	struct netxen_rx_buffer *rx_buf_arr;	/* rx buffers for receive   */
+	dma_addr_t rx_buf_phys;	/* physical address of above */
+	int begin_alloc;
+};
+
+/*
+ * Receive context. There is one such structure per instance of the
+ * receive processing. Any state information that is relevant to
+ * the receive, and is must be in this structure. The global data may be
+ * present elsewhere.
+ */
+struct netxen_recv_context {
+	struct netxen_rcv_desc_ctx rcv_desc[NUM_RCV_DESC_RINGS];
+	u32 status_rx_producer;
+	u32 status_rx_consumer;
+	u32 rcv_status_desc_phys_addr;
+	struct status_desc_t *rcv_status_desc_head;
+};
+
+#define NETXEN_NIC_MSI_ENABLED 0x02
+
+struct netxen_hardware_ring_context {
+	/* Address of cmd ring in Phantom */
+	struct cmd_desc_type0_t *cmd_desc_head;
+	u32 cmd_producer;
+	u32 cmd_consumer;
+	u32 status_rx_producer;
+	u32 status_rx_consumer;
+	u32 cmd_desc_phys_addr;
+};
+
+struct netxen_ring_context {
+	struct netxen_hardware_ring_context hw_ring_ctx;
+	u32 cmd_producer;
+	u32 *cmd_consumer;
+
+	u32 last_cmd_consumer;
+	/* Num of bufs posted in phantom */
+	u32 pending_cmd_count;
+	u32 free_cmd_count;	/* Num of bufs in free list */
+	u32 max_tx_desc_count;
+	u32 max_rx_desc_count;
+	u32 max_jumbo_rx_desc_count;
+	/* Num of instances active on cmd buffer ring */
+	u32 proc_cmd_buf_counter;
+	volatile u32 cmd_peg_consumer;
+
+	struct netxen_cmd_buffer *cmd_buf_arr;	/* Command buffers for xmit */
+	struct netxen_rx_buffer *rx_buf_arr;	/* rx buffers for receive   */
+
+	/*
+	 * Receive instance.
+	 */
+	struct netxen_recv_context recv_ctx;
+
+	/* context interface shared between card and host */
+	struct ring_context *ctx_desc;
+	u32 ctx_desc_phys_addr;
+
+};
+
+/* this structure by all ports on the adapter */
+struct netxen_adapter {
+	struct netxen_hardware_context ahw;
+	int port_count;		/* Number of configured ports  */
+	int active_ports;	/* Number of open ports */
+	struct netxen_port **port;	/* ptr to each port  */
+	spinlock_t tx_lock;
+	rwlock_t adapter_lock;
+	spinlock_t lock;
+	struct work_struct watchdog_task;
+	struct work_struct tx_timeout_task[4];
+	struct timer_list watchdog_timer;
+
+	u32 curr_window;
+
+	u32 num_threads, total_threads;	/*Use to keep track of xmit threads */
+
+	u32 flags;
+	u32 irq;
+	int driver_mismatch;
+
+	struct netxen_adapter_stats stats;
+
+	struct netxen_ring_context ring_ctx[MAX_RING_CTX];
+	int number;
+	int is_up;
+	int work_done;
+};				/* netxen_adapter structure */
+
+/* Max number of xmit producer threads that can run simultaneously */
+#define	MAX_XMIT_PRODUCERS		16
+
+struct netxen_port_stats {
+	u64 rcvdbadskb;
+	u64 xmitcalled;
+	u64 xmitedframes;
+	u64 xmitfinished;
+	u64 badskblen;
+	u64 nocmddescriptor;
+	u64 polled;
+	u64 uphappy;
+	u64 updropped;
+	u64 uplcong;
+	u64 uphcong;
+	u64 upmcong;
+	u64 updunno;
+	u64 skbfreed;
+	u64 txdropped;
+	u64 txnullskb;
+	u64 csummed;
+	u64 no_rcv;
+	u64 rxbytes;
+	u64 txbytes;
+};
+
+struct netxen_port {
+	struct netxen_adapter *adapter;
+
+	u16 portnum;		/* GBE port number */
+	u16 link_speed;
+	u16 link_duplex;
+	u16 link_autoneg;
+
+	int flags;
+	spinlock_t stats_lock;
+
+	struct net_device *netdev;
+	struct pci_dev *pdev;
+	struct net_device_stats net_stats;
+	struct netxen_port_stats stats;
+};
+
+extern char netxen_nic_driver_name[];
+
+#define NETXEN_CTX_SIGNATURE	0xdee0
+#define MAX_PEG_RING_CTX	4
+
+#define RX_PRODUCER 0
+#define RX_PRODUCER_JUMBO 1
+#define TX_PRODUCER 2
+#define STS_PRODUCER 3
+
+#define NUM_DB_CODE 16
+
+#define NETXEN_RCV_PRODUCER(ringid)	(ringid)
+
+#define NETXEN_CMD_PRODUCER 2
+#define NETXEN_RCV_STATUS_CONSUMER 3
+
+struct ctx_msg {
+	u32 PegId:2, Count:16, CtxId:10, Opcode:4;
+};
+
+struct rcv_context {
+	u64 RcvRingAddrLo:32, RcvRingAddrHi:32;
+	u32 RcvRingSize;
+	u32 Rsrv;
+};
+
+struct ring_context {
+
+	u64 CMD_CONSUMER_OFFSET;
+	u64 CmdRingAddrLo:32, CmdRingAddrHi:32;
+	u32 CmdRingSize;
+	u32 Rsrv;
+	struct rcv_context RcvContext[2];
+	u64 StsRingAddrLo:32, StsRingAddrHi:32;
+	u32 StsRingSize;
+	u32 CtxId;
+} __attribute__ ((aligned(64)));
+
+#define NETXEN_RCV_PEG_DB_ID  1
+#define NETXEN_XMIT_PEG_DB_ID 2
+
+long netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter,
+					  long port);
+long netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter,
+					   long port);
+long netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter,
+					 long port);
+void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, long port,
+				 long enable);
+void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, long port,
+				  long enable);
+long netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, long reg,
+			     netxen_crbword_t * readval);
+long netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy,
+			      long reg, netxen_crbword_t val);
+
+/* Functions available from netxen_nic_hw.c */
+void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw);
+void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
+int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
+void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
+void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value);
+
+int netxen_nic_get_board_info(struct netxen_adapter *adapter);
+void netxen_nic_hw_block_write(struct netxen_adapter *adapter,
+			       u64 off, void *data, int num_words);
+int netxen_nic_pci_mem_write(struct netxen_adapter *adapter,
+			     u64 off, void *data, int size);
+int netxen_nic_pci_mem_read(struct netxen_adapter *adapter,
+			    u64 off, void *data, int size);
+void netxen_nic_mem_block_read(struct netxen_adapter *adapter, u64 off,
+			       void *data, int num_words);
+void netxen_nic_mem_block_write(struct netxen_adapter *adapter, u64 off,
+				void *data, int num_words);
+int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
+			  int len);
+int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
+			   int len);
+int netxen_nic_macaddr_set(struct netxen_port *port, u8 * addr);
+int netxen_nic_macaddr_get(struct netxen_port *port, u8 ** addr);
+int netxen_nic_macaddr_set(struct netxen_port *port, u8 * addr);
+int netxen_nic_macaddr_get(struct netxen_port *port, u8 ** addr);
+int netxen_nic_set_mtu(struct netxen_port *port, int new_mtu);
+long netxen_nic_phy_read(struct netxen_adapter *adapter, long phy, long, u32 *);
+long netxen_nic_phy_write(struct netxen_adapter *adapter, long phy, long reg,
+			  u32);
+long netxen_nic_init_port(struct netxen_port *port);
+void netxen_nic_init_niu(struct netxen_adapter *adapter);
+void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
+				 unsigned long off, int data);
+
+/* Functions from netxen_nic_init.c */
+void phantom_init(struct netxen_adapter *adapter);
+void load_firmware(struct netxen_adapter *adapter);
+int pinit_from_rom(struct netxen_adapter *adapter, int verbose);
+int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
+
+/* Functions from netxen_nic_isr.c */
+void netxen_nic_isr_other(struct netxen_adapter *adapter);
+void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter);
+long netxen_nic_phy_read(struct netxen_adapter *adapter, long phy, long reg,
+			 u32 * readval);
+long netxen_nic_phy_write(struct netxen_adapter *adapter, long phy, long reg,
+			  u32 val);
+long netxen_nic_enable_phy_interrupts(struct netxen_adapter *adapter,
+				      long port);
+long netxen_nic_disable_phy_interrupts(struct netxen_adapter *adapter,
+				       long port);
+long netxen_nic_clear_phy_interrupts(struct netxen_adapter *adapter, long port);
+void netxen_nic_set_mii_mode(struct netxen_adapter *adapter, long port,
+			     long enable);
+void netxen_nic_set_gmii_mode(struct netxen_adapter *adapter, long port,
+			      long enable);
+void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 port,
+				 u32 link);
+void netxen_handle_port_int(struct netxen_adapter *adapter, u32 port,
+			    u32 enable);
+int netxen_nic_set_promisc_mode(struct netxen_port *port);
+int netxen_nic_unset_promisc_mode(struct netxen_port *port);
+void netxen_nic_stop_all_ports(struct netxen_adapter *adapter);
+void netxen_nic_stop_port(struct netxen_port *port);
+int netxen_nic_get_board_num(struct netxen_adapter *adapter);
+void initialize_adapter_sw(struct netxen_adapter *adapter);
+int initialize_adapter_hw(struct netxen_adapter *adapter);
+int init_firmware(struct netxen_adapter *adapter);
+void netxen_free_hw_resources(struct netxen_adapter *adapter);
+void netxen_tso_check(struct netxen_adapter *adapter,
+		      struct cmd_desc_type0_t *desc, struct sk_buff *skb);
+int netxen_nic_hw_resources(struct netxen_adapter *adapter);
+void netxen_nic_clear_stats(struct netxen_adapter *adapter);
+int
+netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
+		    struct netxen_port *port);
+int netxen_nic_rx_has_work(struct netxen_adapter *adapter);
+int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
+void netxen_watchdog_task(unsigned long v);
+void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
+			    u32 ringid);
+void netxen_process_cmd_ring(unsigned long data, int ctxid);
+u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
+void netxen_nic_set_multi(struct net_device *netdev);
+int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
+int netxen_nic_set_mac(struct net_device *netdev, void *p);
+struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
+int netxen_nic_suspend(struct pci_dev *pdev, pm_message_t state);
+int netxen_nic_resume(struct pci_dev *pdev);
+void netxen_nic_down(struct netxen_port *port);
+void __devinit netxen_check_options(struct netxen_adapter *adapter);
+void netxen_check_cmdline_params(void);
+
+static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
+{
+	u32 mask;
+
+	mask = 0x7ff;
+
+	/*
+	 * ISR_INT_MASK: Can be read from window 0 or 1.
+	 */
+	writel(mask, (void *)(adapter->ahw.pci_base + ISR_INT_MASK));
+}
+
+static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
+{
+	u32 mask;
+
+	switch (adapter->ahw.board_type) {
+	case NETXEN_NIC_GBE:
+		mask = 0x77b;
+		break;
+	case NETXEN_NIC_XGBE:
+		mask = 0x77f;
+		break;
+	default:
+		mask = 0x7ff;
+		break;
+	}
+
+	writel(mask, (void *)(adapter->ahw.pci_base + ISR_INT_MASK));
+
+	if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
+		mask = 0xbff;
+		writel(mask,
+		       (void *)(adapter->ahw.pci_base + ISR_INT_TARGET_MASK));
+	}
+}
+
+#endif				/* __NETXEN_NIC_H_ */


^ permalink raw reply

* [PATCH 2.6.17 3/9] NetXen: Registers info header file.
From: Linsys Contractor Amit S. Kale @ 2006-07-05 13:31 UTC (permalink / raw)
  To: netdev; +Cc: jeff, sanjeev, unmproj
In-Reply-To: <Pine.LNX.4.64.0607050602310.27969@dut46>

diff -Naru linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hdr.h linux-2.6.17/drivers/net/netxen/netxen_nic_hdr.h
--- linux-2.6.17.orig/drivers/net/netxen/netxen_nic_hdr.h	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.17/drivers/net/netxen/netxen_nic_hdr.h	2006-07-05 01:18:40.359908085 -0700
@@ -0,0 +1,684 @@
+/*
+ * Copyright (C) 2003 - 2006 NetXen, Inc.
+ * All rights reserved.
+ * 
+ * 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
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA  02111-1307, USA.
+ * 
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.
+ * 
+ * Contact Information:
+ *    info@netxen.com
+ * NetXen,
+ * 3965 Freedom Circle, Fourth floor,
+ * Santa Clara, CA 95054
+ */
+
+#ifndef __NETXEN_NIC_HDR_H_
+#define __NETXEN_NIC_HDR_H_
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/config.h>
+#include <linux/version.h>
+
+#include <asm/semaphore.h>
+#include <linux/spinlock.h>
+#include <asm/irq.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include <asm/uaccess.h>
+#include <asm/string.h>		/* for memset */
+
+extern struct netxen_adapter *g_adapter;
+
+/*
+ * The basic unit of access when reading/writing control registers.
+ */
+
+typedef u32 netxen_crbword_t;	/* single word in CRB space */
+
+#define NETXEN_HW_H0_CH_HUB_ADR	0x05
+#define NETXEN_HW_H1_CH_HUB_ADR	0x0E
+#define NETXEN_HW_H2_CH_HUB_ADR	0x03
+#define NETXEN_HW_H3_CH_HUB_ADR	0x01
+#define NETXEN_HW_H4_CH_HUB_ADR	0x06
+#define NETXEN_HW_H5_CH_HUB_ADR	0x07
+#define NETXEN_HW_H6_CH_HUB_ADR	0x08
+
+/*  Hub 0 */
+#define NETXEN_HW_MN_CRB_AGT_ADR	0x15
+#define NETXEN_HW_MS_CRB_AGT_ADR	0x25
+
+/*  Hub 1 */
+#define NETXEN_HW_PS_CRB_AGT_ADR	0x73
+#define NETXEN_HW_SS_CRB_AGT_ADR	0x20
+#define NETXEN_HW_RPMX3_CRB_AGT_ADR	0x0b
+#define NETXEN_HW_QMS_CRB_AGT_ADR	0x00
+#define NETXEN_HW_SQGS0_CRB_AGT_ADR	0x01
+#define NETXEN_HW_SQGS1_CRB_AGT_ADR	0x02
+#define NETXEN_HW_SQGS2_CRB_AGT_ADR	0x03
+#define NETXEN_HW_SQGS3_CRB_AGT_ADR	0x04
+#define NETXEN_HW_C2C0_CRB_AGT_ADR	0x58
+#define NETXEN_HW_C2C1_CRB_AGT_ADR	0x59
+#define NETXEN_HW_C2C2_CRB_AGT_ADR	0x5a
+#define NETXEN_HW_RPMX2_CRB_AGT_ADR	0x0a
+#define NETXEN_HW_RPMX4_CRB_AGT_ADR	0x0c
+#define NETXEN_HW_RPMX7_CRB_AGT_ADR	0x0f
+#define NETXEN_HW_RPMX9_CRB_AGT_ADR	0x12
+#define NETXEN_HW_SMB_CRB_AGT_ADR	0x18
+
+/*  Hub 2 */
+#define NETXEN_HW_NIU_CRB_AGT_ADR	0x31
+#define NETXEN_HW_I2C0_CRB_AGT_ADR	0x19
+#define NETXEN_HW_I2C1_CRB_AGT_ADR	0x29
+
+#define NETXEN_HW_SN_CRB_AGT_ADR	0x10
+#define NETXEN_HW_I2Q_CRB_AGT_ADR	0x20
+#define NETXEN_HW_LPC_CRB_AGT_ADR	0x22
+#define NETXEN_HW_ROMUSB_CRB_AGT_ADR	0x21
+#define NETXEN_HW_QM_CRB_AGT_ADR	0x66
+#define NETXEN_HW_SQG0_CRB_AGT_ADR	0x60
+#define NETXEN_HW_SQG1_CRB_AGT_ADR	0x61
+#define NETXEN_HW_SQG2_CRB_AGT_ADR	0x62
+#define NETXEN_HW_SQG3_CRB_AGT_ADR	0x63
+#define NETXEN_HW_RPMX1_CRB_AGT_ADR	0x09
+#define NETXEN_HW_RPMX5_CRB_AGT_ADR	0x0d
+#define NETXEN_HW_RPMX6_CRB_AGT_ADR	0x0e
+#define NETXEN_HW_RPMX8_CRB_AGT_ADR	0x11
+
+/*  Hub 3 */
+#define NETXEN_HW_PH_CRB_AGT_ADR	0x1A
+#define NETXEN_HW_SRE_CRB_AGT_ADR	0x50
+#define NETXEN_HW_EG_CRB_AGT_ADR	0x51
+#define NETXEN_HW_RPMX0_CRB_AGT_ADR	0x08
+
+/*  Hub 4 */
+#define NETXEN_HW_PEGN0_CRB_AGT_ADR	0x40
+#define NETXEN_HW_PEGN1_CRB_AGT_ADR	0x41
+#define NETXEN_HW_PEGN2_CRB_AGT_ADR	0x42
+#define NETXEN_HW_PEGN3_CRB_AGT_ADR	0x43
+#define NETXEN_HW_PEGNI_CRB_AGT_ADR	0x44
+#define NETXEN_HW_PEGND_CRB_AGT_ADR	0x45
+#define NETXEN_HW_PEGNC_CRB_AGT_ADR	0x46
+#define NETXEN_HW_PEGR0_CRB_AGT_ADR	0x47
+#define NETXEN_HW_PEGR1_CRB_AGT_ADR	0x48
+#define NETXEN_HW_PEGR2_CRB_AGT_ADR	0x49
+#define NETXEN_HW_PEGR3_CRB_AGT_ADR	0x4a
+
+/*  Hub 5 */
+#define NETXEN_HW_PEGS0_CRB_AGT_ADR	0x40
+#define NETXEN_HW_PEGS1_CRB_AGT_ADR	0x41
+#define NETXEN_HW_PEGS2_CRB_AGT_ADR	0x42
+#define NETXEN_HW_PEGS3_CRB_AGT_ADR	0x43
+#define NETXEN_HW_PEGSI_CRB_AGT_ADR	0x44
+#define NETXEN_HW_PEGSD_CRB_AGT_ADR	0x45
+#define NETXEN_HW_PEGSC_CRB_AGT_ADR	0x46
+
+/*  Hub 6 */
+#define NETXEN_HW_CAS0_CRB_AGT_ADR	0x46
+#define NETXEN_HW_CAS1_CRB_AGT_ADR	0x47
+#define NETXEN_HW_CAS2_CRB_AGT_ADR	0x48
+#define NETXEN_HW_CAS3_CRB_AGT_ADR	0x49
+#define NETXEN_HW_NCM_CRB_AGT_ADR	0x16
+#define NETXEN_HW_TMR_CRB_AGT_ADR	0x17
+#define NETXEN_HW_XDMA_CRB_AGT_ADR	0x05
+#define NETXEN_HW_OCM0_CRB_AGT_ADR	0x06
+#define NETXEN_HW_OCM1_CRB_AGT_ADR	0x07
+
+/*  Floaters - non existent modules */
+#define NETXEN_HW_EFC_RPMX0_CRB_AGT_ADR	0x67
+
+/*  This field defines PCI/X adr [25:20] of agents on the CRB */
+#define NETXEN_HW_PX_MAP_CRB_PH		0
+#define NETXEN_HW_PX_MAP_CRB_PS		1
+#define NETXEN_HW_PX_MAP_CRB_MN		2
+#define NETXEN_HW_PX_MAP_CRB_MS		3
+#define NETXEN_HW_PX_MAP_CRB_SRE	5
+#define NETXEN_HW_PX_MAP_CRB_NIU	6
+#define NETXEN_HW_PX_MAP_CRB_QMN	7
+#define NETXEN_HW_PX_MAP_CRB_SQN0	8
+#define NETXEN_HW_PX_MAP_CRB_SQN1	9
+#define NETXEN_HW_PX_MAP_CRB_SQN2	10
+#define NETXEN_HW_PX_MAP_CRB_SQN3	11
+#define NETXEN_HW_PX_MAP_CRB_QMS	12
+#define NETXEN_HW_PX_MAP_CRB_SQS0	13
+#define NETXEN_HW_PX_MAP_CRB_SQS1	14
+#define NETXEN_HW_PX_MAP_CRB_SQS2	15
+#define NETXEN_HW_PX_MAP_CRB_SQS3	16
+#define NETXEN_HW_PX_MAP_CRB_PGN0	17
+#define NETXEN_HW_PX_MAP_CRB_PGN1	18
+#define NETXEN_HW_PX_MAP_CRB_PGN2	19
+#define NETXEN_HW_PX_MAP_CRB_PGN3	20
+#define NETXEN_HW_PX_MAP_CRB_PGND	21
+#define NETXEN_HW_PX_MAP_CRB_PGNI	22
+#define NETXEN_HW_PX_MAP_CRB_PGS0	23
+#define NETXEN_HW_PX_MAP_CRB_PGS1	24
+#define NETXEN_HW_PX_MAP_CRB_PGS2	25
+#define NETXEN_HW_PX_MAP_CRB_PGS3	26
+#define NETXEN_HW_PX_MAP_CRB_PGSD	27
+#define NETXEN_HW_PX_MAP_CRB_PGSI	28
+#define NETXEN_HW_PX_MAP_CRB_SN		29
+#define NETXEN_HW_PX_MAP_CRB_EG		31
+#define NETXEN_HW_PX_MAP_CRB_PH2	32
+#define NETXEN_HW_PX_MAP_CRB_PS2	33
+#define NETXEN_HW_PX_MAP_CRB_CAM	34
+#define NETXEN_HW_PX_MAP_CRB_CAS0	35
+#define NETXEN_HW_PX_MAP_CRB_CAS1	36
+#define NETXEN_HW_PX_MAP_CRB_CAS2	37
+#define NETXEN_HW_PX_MAP_CRB_C2C0	38
+#define NETXEN_HW_PX_MAP_CRB_C2C1	39
+#define NETXEN_HW_PX_MAP_CRB_TIMR	40
+#define NETXEN_HW_PX_MAP_CRB_RPMX1	42
+#define NETXEN_HW_PX_MAP_CRB_RPMX2	43
+#define NETXEN_HW_PX_MAP_CRB_RPMX3	44
+#define NETXEN_HW_PX_MAP_CRB_RPMX4	45
+#define NETXEN_HW_PX_MAP_CRB_RPMX5	46
+#define NETXEN_HW_PX_MAP_CRB_RPMX6	47
+#define NETXEN_HW_PX_MAP_CRB_RPMX7	48
+#define NETXEN_HW_PX_MAP_CRB_XDMA	49
+#define NETXEN_HW_PX_MAP_CRB_I2Q	50
+#define NETXEN_HW_PX_MAP_CRB_ROMUSB	51
+#define NETXEN_HW_PX_MAP_CRB_CAS3	52
+#define NETXEN_HW_PX_MAP_CRB_RPMX0	53
+#define NETXEN_HW_PX_MAP_CRB_RPMX8	54
+#define NETXEN_HW_PX_MAP_CRB_RPMX9	55
+#define NETXEN_HW_PX_MAP_CRB_OCM0	56
+#define NETXEN_HW_PX_MAP_CRB_OCM1	57
+#define NETXEN_HW_PX_MAP_CRB_SMB	58
+#define NETXEN_HW_PX_MAP_CRB_I2C0	59
+#define NETXEN_HW_PX_MAP_CRB_I2C1	60
+#define NETXEN_HW_PX_MAP_CRB_LPC	61
+#define NETXEN_HW_PX_MAP_CRB_PGNC	62
+#define NETXEN_HW_PX_MAP_CRB_PGR0	63
+#define NETXEN_HW_PX_MAP_CRB_PGR1	4
+#define NETXEN_HW_PX_MAP_CRB_PGR2	30
+#define NETXEN_HW_PX_MAP_CRB_PGR3	41
+
+/*  This field defines CRB adr [31:20] of the agents */
+
+#define NETXEN_HW_CRB_HUB_AGT_ADR_MN	\
+	((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_MN_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PH	\
+	((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_PH_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_MS	\
+	((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_MS_CRB_AGT_ADR)
+
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PS	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_PS_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SS	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SS_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX3	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX3_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_QMS	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_QMS_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS0	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS1	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS2	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS2_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS3	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS3_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_C2C0	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_C2C0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_C2C1	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_C2C1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX2	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX2_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX4	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX4_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX7	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX7_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX9	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX9_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SMB	\
+	((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SMB_CRB_AGT_ADR)
+
+#define NETXEN_HW_CRB_HUB_AGT_ADR_NIU	\
+	((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_NIU_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_I2C0	\
+	((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_I2C0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_I2C1	\
+	((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_I2C1_CRB_AGT_ADR)
+
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SRE	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SRE_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_EG	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_EG_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX0	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_QMN	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_QM_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN0	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN1	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN2	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG2_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN3	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG3_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX1	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX5	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX5_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX6	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX6_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX8	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX8_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS0	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS1	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS2	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS2_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS3	\
+	((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS3_CRB_AGT_ADR)
+
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGNI	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGNI_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGND	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGND_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN0	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN1	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN2	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN2_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN3	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN3_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGNC	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGNC_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR0	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR1	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR2	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR2_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR3	\
+	((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR3_CRB_AGT_ADR)
+
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSI	\
+	((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSI_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSD	\
+	((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSD_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS0	\
+	((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS1	\
+	((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS2	\
+	((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS2_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS3	\
+	((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS3_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSC	\
+	((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSC_CRB_AGT_ADR)
+
+#define NETXEN_HW_CRB_HUB_AGT_ADR_CAM	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_NCM_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_TIMR	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_TMR_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_XDMA	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_XDMA_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_SN	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_SN_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_I2Q	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_I2Q_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_ROMUSB_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_OCM0	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_OCM0_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_OCM1	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_OCM1_CRB_AGT_ADR)
+#define NETXEN_HW_CRB_HUB_AGT_ADR_LPC	\
+	((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_LPC_CRB_AGT_ADR)
+
+/* ------------------------------------------------------------------------ */
+/*  NCM IMBus Port Tag Defines */
+/* ------------------------------------------------------------------------ */
+#define NETXEN_HW_PH_CAM_TAG	0x3
+#define NETXEN_HW_CAS_CAM_TAG	0x4
+#define NETXEN_HW_PS_CAM_TAG	0x5
+#define NETXEN_HW_PEGN0_CAM_TAG	0x6
+#define NETXEN_HW_PEGN1_CAM_TAG	0x7
+#define NETXEN_HW_PEGN2_CAM_TAG	0x9
+#define NETXEN_HW_PEGN3_CAM_TAG	0xa
+#define NETXEN_HW_PEGS0_CAM_TAG	0xb
+#define NETXEN_HW_PEGS1_CAM_TAG	0xc
+#define NETXEN_HW_PEGS2_CAM_TAG	0xd
+#define NETXEN_HW_PEGS3_CAM_TAG	0xe
+
+/* ------------------------------------------------------------------------ */
+/*  Network QM IMBus Port Tag Defines */
+/* ------------------------------------------------------------------------ */
+#define NETXEN_HW_EG_QM_REQ_TAG		0x4
+#define NETXEN_HW_PEGN0_QM_REQ_TAG	0x5
+#define NETXEN_HW_PEGN1_QM_REQ_TAG	0x6
+#define NETXEN_HW_PEGN2_QM_REQ_TAG	0x7
+#define NETXEN_HW_PEGN3_QM_REQ_TAG	0xE
+#define NETXEN_HW_I2Q_QM_REQ_TAG	0x8
+#define NETXEN_HW_PS_DMA_QMN_REQ_TAG	0x9
+#define NETXEN_HW_PS_QMN_REQ_TAG	0xA
+#define NETXEN_HW_XDMA_QMN_REQ_TAG	0xB
+#define NETXEN_HW_PCIX_QM_REQ_TAG	0xC
+#define NETXEN_HW_CAS_QMN_REQ_TAG	0xD
+#define NETXEN_HW_TMR_QMN_REQ_TAG	0xF
+#define NETXEN_HW_QMS_QMN_REQ_TAG	0xB
+#define NETXEN_HW_C2C0_QM_REQ_TAG	0x9
+
+/* ------------------------------------------------------------------------ */
+/*  Storage QM IMBus Port Tag Defines */
+/* ------------------------------------------------------------------------ */
+#define NETXEN_HW_PEGS0_QMS_REQ_TAG	0x0
+#define NETXEN_HW_PEGS1_QMS_REQ_TAG	0x1
+#define NETXEN_HW_PEGS2_QMS_REQ_TAG	0x2
+#define NETXEN_HW_PEGS3_QMS_REQ_TAG	0xf
+#define NETXEN_HW_C2C1_QMS_REQ_TAG	0x4
+#define NETXEN_HW_PS_QMS_REQ_TAG	0x5
+#define NETXEN_HW_PH_QMS_REQ_TAG	0x6
+#define NETXEN_HW_XDMA_QMS_REQ_TAG	0x9
+#define NETXEN_HW_QMN_QMS_REQ_TAG	0xE
+
+/* ------------------------------------------------------------------------ */
+/*  OCM0 IMBus Port Tag Defines */
+/* ------------------------------------------------------------------------ */
+#define NETXEN_HW_MN_OCM0_PORT_TAG	0x00
+#define NETXEN_HW_SN_OCM0_PORT_TAG	0x01
+#define NETXEN_HW_P2D0_OCM0_PORT_TAG	0x02
+#define NETXEN_HW_P2D1_OCM0_PORT_TAG	0x03
+#define NETXEN_HW_XDMA_OCM0_PORT_TAG	0x04
+
+/* ------------------------------------------------------------------------ */
+/*  OCM0 IMBus Port Tag Defines */
+/* ------------------------------------------------------------------------ */
+#define NETXEN_HW_MN_OCM1_PORT_TAG	0x00
+#define NETXEN_HW_SN_OCM1_PORT_TAG	0x01
+#define NETXEN_HW_P2D0_OCM1_PORT_TAG	0x02
+#define NETXEN_HW_P2D1_OCM1_PORT_TAG	0x03
+#define NETXEN_HW_XDMA_OCM1_PORT_TAG	0x04
+
+/*  Q SubAgent Field for Locking */
+
+#define NETXEN_HW_NPEG0_VPEG0_SUB_AGNT	0x0
+#define NETXEN_HW_NPEG0_VPEG1_SUB_AGNT	0x1
+#define NETXEN_HW_NPEG1_VPEG0_SUB_AGNT	0x2
+#define NETXEN_HW_NPEG1_VPEG1_SUB_AGNT	0x3
+#define NETXEN_HW_NPEG2_VPEG0_SUB_AGNT	0x4
+#define NETXEN_HW_NPEG2_VPEG1_SUB_AGNT	0x5
+#define NETXEN_HW_CAS_SUB_AGNT		0x6
+#define NETXEN_HW_PCI_SUB_AGNT		0x7
+#define NETXEN_HW_SPEG0_VPEG0_SUB_AGNT	0x8
+#define NETXEN_HW_SPEG0_VPEG1_SUB_AGNT	0x9
+#define NETXEN_HW_SPEG1_VPEG0_SUB_AGNT	0xa
+#define NETXEN_HW_SPEG1_VPEG1_SUB_AGNT	0xb
+#define NETXEN_HW_SPEG2_VPEG0_SUB_AGNT	0xc
+#define NETXEN_HW_SPEG2_VPEG1_SUB_AGNT	0xd
+
+/*
+ * MAX_RCV_CTX : The number of receive contexts that are available on
+ * the phantom.
+ */
+#define MAX_RCV_CTX		1
+
+#define NETXEN_SRE_INT_STATUS		(NETXEN_CRB_SRE + 0x00034)
+#define NETXEN_SRE_PBI_ACTIVE_STATUS	(NETXEN_CRB_SRE + 0x01014)
+#define NETXEN_SRE_L1RE_CTL		(NETXEN_CRB_SRE + 0x03000)
+#define NETXEN_SRE_L2RE_CTL		(NETXEN_CRB_SRE + 0x05000)
+#define NETXEN_SRE_BUF_CTL		(NETXEN_CRB_SRE + 0x01000)
+
+#define	NETXEN_DMA_BASE(U)	(NETXEN_CRB_PCIX_MD + 0x20000 + ((U)<<16))
+#define	NETXEN_DMA_COMMAND(U)	(NETXEN_DMA_BASE(U) + 0x00008)
+
+#define NETXEN_I2Q_CLR_PCI_HI	(NETXEN_CRB_I2Q + 0x00034)
+
+#define PEG_NETWORK_BASE(N)	(NETXEN_CRB_PEG_NET_0 + (((N)&3) << 20))
+#define CRB_REG_EX_PC		0x3c
+
+#define ROMUSB_GLB	(NETXEN_CRB_ROMUSB + 0x00000)
+#define ROMUSB_ROM	(NETXEN_CRB_ROMUSB + 0x10000)
+
+#define NETXEN_ROMUSB_GLB_STATUS	(ROMUSB_GLB + 0x0004)
+#define NETXEN_ROMUSB_GLB_SW_RESET	(ROMUSB_GLB + 0x0008)
+#define NETXEN_ROMUSB_GLB_PAD_GPIO_I	(ROMUSB_GLB + 0x000c)
+#define NETXEN_ROMUSB_GLB_CAS_RST	(ROMUSB_GLB + 0x0038)
+#define NETXEN_ROMUSB_GLB_TEST_MUX_SEL	(ROMUSB_GLB + 0x0044)
+#define NETXEN_ROMUSB_GLB_PEGTUNE_DONE	(ROMUSB_GLB + 0x005c)
+#define NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL	(ROMUSB_GLB + 0x00A8)
+
+#define NETXEN_ROMUSB_GPIO(n)		(ROMUSB_GLB + 0x60 + (4 * (n)))
+
+#define NETXEN_ROMUSB_ROM_INSTR_OPCODE	(ROMUSB_ROM + 0x0004)
+#define NETXEN_ROMUSB_ROM_ADDRESS	(ROMUSB_ROM + 0x0008)
+#define NETXEN_ROMUSB_ROM_ABYTE_CNT	(ROMUSB_ROM + 0x0010)
+#define NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT (ROMUSB_ROM + 0x0014)
+#define NETXEN_ROMUSB_ROM_RDATA		(ROMUSB_ROM + 0x0018)
+
+/* Lock IDs for ROM lock */
+#define ROM_LOCK_DRIVER	0x0d417340
+
+#define NETXEN_PCI_CRB_WINDOWSIZE	0x00100000	/* all are 1MB windows */
+#define NETXEN_PCI_CRB_WINDOW(A)	\
+	(NETXEN_PCI_CRBSPACE + (A)*NETXEN_PCI_CRB_WINDOWSIZE)
+
+#define NETXEN_CRB_NIU		NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_NIU)
+#define NETXEN_CRB_SRE		NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_SRE)
+#define NETXEN_CRB_ROMUSB	\
+	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_ROMUSB)
+#define NETXEN_CRB_I2Q		NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_I2Q)
+#define NETXEN_CRB_MAX		NETXEN_PCI_CRB_WINDOW(64)
+
+#define NETXEN_CRB_PCIX_HOST	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PH)
+#define NETXEN_CRB_PCIX_HOST2	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PH2)
+#define NETXEN_CRB_PEG_NET_0	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN0)
+#define NETXEN_CRB_PEG_NET_1	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN1)
+#define NETXEN_CRB_PEG_NET_2	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN2)
+#define NETXEN_CRB_PEG_NET_3	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN3)
+#define NETXEN_CRB_PEG_NET_D	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGND)
+#define NETXEN_CRB_PEG_NET_I	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGNI)
+#define NETXEN_CRB_DDR_NET	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_MN)
+
+#define NETXEN_CRB_PCIX_MD	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PS)
+#define NETXEN_CRB_PCIE		NETXEN_CRB_PCIX_MD
+
+#define ISR_INT_VECTOR		(NETXEN_PCIX_PS_REG(PCIX_INT_VECTOR))
+#define ISR_INT_MASK		(NETXEN_PCIX_PS_REG(PCIX_INT_MASK))
+#define ISR_INT_MASK_SLOW	(NETXEN_PCIX_PS_REG(PCIX_INT_MASK))
+#define ISR_INT_TARGET_STATUS	(NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS))
+#define ISR_INT_TARGET_MASK	(NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK))
+
+#define NETXEN_PCI_MAPSIZE	128
+#define NETXEN_PCI_DDR_NET	(unsigned long)0x00000000
+#define NETXEN_PCI_QDR_NET	(unsigned long)0x04000000
+#define NETXEN_PCI_DIRECT_CRB	(unsigned long)0x04400000
+#define NETXEN_PCI_CAMQM_MAX	(unsigned long)0x04ffffff
+#define NETXEN_PCI_OCM0		(unsigned long)0x05000000
+#define NETXEN_PCI_OCM0_MAX	(unsigned long)0x050fffff
+#define NETXEN_PCI_OCM1		(unsigned long)0x05100000
+#define NETXEN_PCI_OCM1_MAX	(unsigned long)0x051fffff
+#define NETXEN_PCI_CRBSPACE	(unsigned long)0x06000000
+
+#define NETXEN_CRB_CAM	NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_CAM)
+
+#define NETXEN_ADDR_DDR_NET	(0x0000000000000000ULL)
+#define NETXEN_ADDR_DDR_NET_MAX (0x000000000fffffffULL)
+#define NETXEN_ADDR_OCM0	(0x0000000200000000ULL)
+#define NETXEN_ADDR_OCM0_MAX	(0x00000002000fffffULL)
+#define NETXEN_ADDR_OCM1	(0x0000000200400000ULL)
+#define NETXEN_ADDR_OCM1_MAX	(0x00000002004fffffULL)
+#define NETXEN_ADDR_QDR_NET	(0x0000000300000000ULL)
+#define NETXEN_ADDR_QDR_NET_MAX (0x00000003003fffffULL)
+
+	/* 200ms delay in each loop */
+#define	NETXEN_NIU_PHY_WAITLEN		200000
+	/* 10 seconds before we give up */
+#define	NETXEN_NIU_PHY_WAITMAX		50
+#define	NETXEN_NIU_MAX_GBE_PORTS	4
+
+#define	NETXEN_NIU_MODE			(NETXEN_CRB_NIU + 0x00000)
+
+#define	NETXEN_NIU_XG_SINGLE_TERM	(NETXEN_CRB_NIU + 0x00004)
+#define	NETXEN_NIU_XG_DRIVE_HI		(NETXEN_CRB_NIU + 0x00008)
+#define	NETXEN_NIU_XG_DRIVE_LO		(NETXEN_CRB_NIU + 0x0000c)
+#define	NETXEN_NIU_XG_DTX		(NETXEN_CRB_NIU + 0x00010)
+#define	NETXEN_NIU_XG_DEQ		(NETXEN_CRB_NIU + 0x00014)
+#define	NETXEN_NIU_XG_WORD_ALIGN	(NETXEN_CRB_NIU + 0x00018)
+#define	NETXEN_NIU_XG_RESET		(NETXEN_CRB_NIU + 0x0001c)
+#define	NETXEN_NIU_XG_POWER_DOWN	(NETXEN_CRB_NIU + 0x00020)
+#define	NETXEN_NIU_XG_RESET_PLL		(NETXEN_CRB_NIU + 0x00024)
+#define	NETXEN_NIU_XG_SERDES_LOOPBACK	(NETXEN_CRB_NIU + 0x00028)
+#define	NETXEN_NIU_XG_DO_BYTE_ALIGN	(NETXEN_CRB_NIU + 0x0002c)
+#define	NETXEN_NIU_XG_TX_ENABLE		(NETXEN_CRB_NIU + 0x00030)
+#define	NETXEN_NIU_XG_RX_ENABLE		(NETXEN_CRB_NIU + 0x00034)
+#define	NETXEN_NIU_XG_STATUS		(NETXEN_CRB_NIU + 0x00038)
+#define	NETXEN_NIU_XG_PAUSE_THRESHOLD	(NETXEN_CRB_NIU + 0x0003c)
+#define	NETXEN_NIU_INT_MASK		(NETXEN_CRB_NIU + 0x00040)
+#define	NETXEN_NIU_ACTIVE_INT		(NETXEN_CRB_NIU + 0x00044)
+#define	NETXEN_NIU_MASKABLE_INT		(NETXEN_CRB_NIU + 0x00048)
+
+#define NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER	(NETXEN_CRB_NIU + 0x0004c)
+
+#define	NETXEN_NIU_GB_SERDES_RESET	(NETXEN_CRB_NIU + 0x00050)
+#define	NETXEN_NIU_GB0_GMII_MODE	(NETXEN_CRB_NIU + 0x00054)
+#define	NETXEN_NIU_GB0_MII_MODE		(NETXEN_CRB_NIU + 0x00058)
+#define	NETXEN_NIU_GB1_GMII_MODE	(NETXEN_CRB_NIU + 0x0005c)
+#define	NETXEN_NIU_GB1_MII_MODE		(NETXEN_CRB_NIU + 0x00060)
+#define	NETXEN_NIU_GB2_GMII_MODE	(NETXEN_CRB_NIU + 0x00064)
+#define	NETXEN_NIU_GB2_MII_MODE		(NETXEN_CRB_NIU + 0x00068)
+#define	NETXEN_NIU_GB3_GMII_MODE	(NETXEN_CRB_NIU + 0x0006c)
+#define	NETXEN_NIU_GB3_MII_MODE		(NETXEN_CRB_NIU + 0x00070)
+#define	NETXEN_NIU_REMOTE_LOOPBACK	(NETXEN_CRB_NIU + 0x00074)
+#define	NETXEN_NIU_GB0_HALF_DUPLEX	(NETXEN_CRB_NIU + 0x00078)
+#define	NETXEN_NIU_GB1_HALF_DUPLEX	(NETXEN_CRB_NIU + 0x0007c)
+#define	NETXEN_NIU_RESET_SYS_FIFOS	(NETXEN_CRB_NIU + 0x00088)
+#define	NETXEN_NIU_GB_CRC_DROP		(NETXEN_CRB_NIU + 0x0008c)
+#define	NETXEN_NIU_GB_DROP_WRONGADDR	(NETXEN_CRB_NIU + 0x00090)
+#define	NETXEN_NIU_TEST_MUX_CTL		(NETXEN_CRB_NIU + 0x00094)
+#define	NETXEN_NIU_XG_PAUSE_CTL		(NETXEN_CRB_NIU + 0x00098)
+#define	NETXEN_NIU_XG_PAUSE_LEVEL	(NETXEN_CRB_NIU + 0x000dc)
+#define	NETXEN_NIU_XG_SEL		(NETXEN_CRB_NIU + 0x00128)
+
+#define	NETXEN_NIU_GB_MAC_CONFIG_0(I)		\
+	(NETXEN_CRB_NIU + 0x30000 + (I)*0x10000)
+#define	NETXEN_NIU_GB_MAC_CONFIG_1(I)		\
+	(NETXEN_CRB_NIU + 0x30004 + (I)*0x10000)
+#define	NETXEN_NIU_GB_MAC_IPG_IFG(I)		\
+	(NETXEN_CRB_NIU + 0x30008 + (I)*0x10000)
+#define	NETXEN_NIU_GB_HALF_DUPLEX_CTRL(I)	\
+	(NETXEN_CRB_NIU + 0x3000c + (I)*0x10000)
+#define	NETXEN_NIU_GB_MAX_FRAME_SIZE(I)		\
+	(NETXEN_CRB_NIU + 0x30010 + (I)*0x10000)
+#define	NETXEN_NIU_GB_TEST_REG(I)		\
+	(NETXEN_CRB_NIU + 0x3001c + (I)*0x10000)
+#define	NETXEN_NIU_GB_MII_MGMT_CONFIG(I)	\
+	(NETXEN_CRB_NIU + 0x30020 + (I)*0x10000)
+#define	NETXEN_NIU_GB_MII_MGMT_COMMAND(I)	\
+	(NETXEN_CRB_NIU + 0x30024 + (I)*0x10000)
+#define	NETXEN_NIU_GB_MII_MGMT_ADDR(I)		\
+	(NETXEN_CRB_NIU + 0x30028 + (I)*0x10000)
+#define	NETXEN_NIU_GB_MII_MGMT_CTRL(I)		\
+	(NETXEN_CRB_NIU + 0x3002c + (I)*0x10000)
+#define	NETXEN_NIU_GB_MII_MGMT_STATUS(I)	\
+	(NETXEN_CRB_NIU + 0x30030 + (I)*0x10000)
+#define	NETXEN_NIU_GB_MII_MGMT_INDICATE(I)	\
+	(NETXEN_CRB_NIU + 0x30034 + (I)*0x10000)
+#define	NETXEN_NIU_GB_INTERFACE_CTRL(I)		\
+	(NETXEN_CRB_NIU + 0x30038 + (I)*0x10000)
+#define	NETXEN_NIU_GB_INTERFACE_STATUS(I)	\
+	(NETXEN_CRB_NIU + 0x3003c + (I)*0x10000)
+#define	NETXEN_NIU_GB_STATION_ADDR_0(I)		\
+	(NETXEN_CRB_NIU + 0x30040 + (I)*0x10000)
+#define	NETXEN_NIU_GB_STATION_ADDR_1(I)		\
+	(NETXEN_CRB_NIU + 0x30044 + (I)*0x10000)
+
+#define	NETXEN_NIU_XGE_CONFIG_0			(NETXEN_CRB_NIU + 0x70000)
+#define	NETXEN_NIU_XGE_CONFIG_1			(NETXEN_CRB_NIU + 0x70004)
+#define	NETXEN_NIU_XGE_IPG			(NETXEN_CRB_NIU + 0x70008)
+#define	NETXEN_NIU_XGE_STATION_ADDR_0_HI	(NETXEN_CRB_NIU + 0x7000c)
+#define	NETXEN_NIU_XGE_STATION_ADDR_0_1		(NETXEN_CRB_NIU + 0x70010)
+#define	NETXEN_NIU_XGE_STATION_ADDR_1_LO	(NETXEN_CRB_NIU + 0x70014)
+#define	NETXEN_NIU_XGE_STATUS			(NETXEN_CRB_NIU + 0x70018)
+#define	NETXEN_NIU_XGE_MAX_FRAME_SIZE		(NETXEN_CRB_NIU + 0x7001c)
+#define	NETXEN_NIU_XGE_PAUSE_FRAME_VALUE	(NETXEN_CRB_NIU + 0x70020)
+#define	NETXEN_NIU_XGE_TX_BYTE_CNT		(NETXEN_CRB_NIU + 0x70024)
+#define	NETXEN_NIU_XGE_TX_FRAME_CNT		(NETXEN_CRB_NIU + 0x70028)
+#define	NETXEN_NIU_XGE_RX_BYTE_CNT		(NETXEN_CRB_NIU + 0x7002c)
+#define	NETXEN_NIU_XGE_RX_FRAME_CNT		(NETXEN_CRB_NIU + 0x70030)
+#define	NETXEN_NIU_XGE_AGGR_ERROR_CNT		(NETXEN_CRB_NIU + 0x70034)
+#define	NETXEN_NIU_XGE_MULTICAST_FRAME_CNT 	(NETXEN_CRB_NIU + 0x70038)
+#define	NETXEN_NIU_XGE_UNICAST_FRAME_CNT	(NETXEN_CRB_NIU + 0x7003c)
+#define	NETXEN_NIU_XGE_CRC_ERROR_CNT		(NETXEN_CRB_NIU + 0x70040)
+#define	NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR	(NETXEN_CRB_NIU + 0x70044)
+#define	NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR	(NETXEN_CRB_NIU + 0x70048)
+#define	NETXEN_NIU_XGE_LOCAL_ERROR_CNT		(NETXEN_CRB_NIU + 0x7004c)
+#define	NETXEN_NIU_XGE_REMOTE_ERROR_CNT		(NETXEN_CRB_NIU + 0x70050)
+#define	NETXEN_NIU_XGE_CONTROL_CHAR_CNT		(NETXEN_CRB_NIU + 0x70054)
+#define	NETXEN_NIU_XGE_PAUSE_FRAME_CNT		(NETXEN_CRB_NIU + 0x70058)
+
+/* XG Link status */
+#define XG_LINK_UP	0x10
+#define XG_LINK_DOWN	0x20
+
+#define NETXEN_CAM_RAM_BASE	(NETXEN_CRB_CAM + 0x02000)
+#define NETXEN_CAM_RAM(reg)	(NETXEN_CAM_RAM_BASE + (reg))
+#define NETXEN_FW_VERSION_MAJOR (NETXEN_CAM_RAM(0x150))
+#define NETXEN_FW_VERSION_MINOR (NETXEN_CAM_RAM(0x154))
+#define NETXEN_FW_VERSION_SUB	(NETXEN_CAM_RAM(0x158))
+#define NETXEN_ROM_LOCK_ID	(NETXEN_CAM_RAM(0x100))
+
+/*
+ * CRB window register.
+ */
+struct netxen_pcix_crb_window {
+	netxen_crbword_t rsvd1:25, addrbit:1,	/* bit 25 of CRB address */
+	 rsvd2:6;
+};
+
+#define PCIX_PS_OP_ADDR_LO	(0x10000) /* Used for PS PCI Memory access */
+#define PCIX_PS_OP_ADDR_HI	(0x10004) /*   via CRB  (PS side only)     */
+
+#define PCIX_INT_VECTOR		(0x10100)
+#define PCIX_INT_MASK		(0x10104)
+
+#define PCIX_MN_WINDOW		(0x10200)
+#define PCIX_MS_WINDOW		(0x10204)
+#define PCIX_SN_WINDOW		(0x10208)
+#define PCIX_CRB_WINDOW		(0x10210)
+
+#define PCIX_TARGET_STATUS	(0x10118)
+#define PCIX_TARGET_MASK	(0x10128)
+
+#define PCIX_MSI_F0		(0x13000)
+
+#define PCIX_PS_MEM_SPACE	(0x90000)
+
+#define NETXEN_PCIX_PH_REG(reg)	(NETXEN_CRB_PCIE + (reg))
+#define NETXEN_PCIX_PS_REG(reg)	(NETXEN_CRB_PCIX_MD + (reg))
+
+#define NETXEN_PCIE_REG(reg)	(NETXEN_CRB_PCIE + (reg))
+
+#define PCIE_MAX_DMA_XFER_SIZE	(0x1404c)
+
+#define PCIE_DCR		0x00d8
+
+#define PCIE_SEM2_LOCK		(0x1c010)	/* Flash lock   */
+#define PCIE_SEM2_UNLOCK	(0x1c014)	/* Flash unlock */
+
+#define PCIE_TGT_SPLIT_CHICKEN	(0x12080)
+
+#define PCIE_MAX_MASTER_SPLIT	(0x14048)
+
+#endif				/* __NETXEN_NIC_HDR_H_ */


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox